good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
f02da008
Commit
f02da008
authored
Apr 29, 2020
by
atvanguard
Browse files
Options
Downloads
Patches
Plain Diff
chg: dev: errMismatchingSprintValidators
parent
7e4e2b72
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
consensus/bor/bor.go
+8
-3
8 additions, 3 deletions
consensus/bor/bor.go
consensus/bor/bor_test/helper.go
+10
-1
10 additions, 1 deletion
consensus/bor/bor_test/helper.go
with
18 additions
and
4 deletions
consensus/bor/bor.go
+
8
−
3
View file @
f02da008
...
...
@@ -429,8 +429,9 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainReader, header *types.H
return
err
}
// If the block is a sprint end block, verify the validator list
if
number
%
c
.
config
.
Sprint
==
0
{
isSprintEnd
:=
(
number
+
1
)
%
c
.
config
.
Sprint
==
0
// verify the validator list in the last sprint block
if
isSprintEnd
{
validatorsBytes
:=
make
([]
byte
,
len
(
snap
.
ValidatorSet
.
Validators
)
*
validatorHeaderBytesLength
)
currentValidators
:=
snap
.
ValidatorSet
.
Copy
()
.
Validators
...
...
@@ -439,6 +440,10 @@ func (c *Bor) verifyCascadingFields(chain consensus.ChainReader, header *types.H
for
i
,
validator
:=
range
currentValidators
{
copy
(
validatorsBytes
[
i
*
validatorHeaderBytesLength
:
],
validator
.
HeaderBytes
())
}
// len(header.Extra) >= extraVanity+extraSeal has already been validated in validateHeaderExtraField, so this won't result in a panic
if
!
bytes
.
Equal
(
header
.
Extra
[
extraVanity
:
len
(
header
.
Extra
)
-
extraSeal
],
validatorsBytes
)
{
return
errMismatchingSprintValidators
}
}
// All basic checks passed, verify the seal and return
...
...
@@ -474,7 +479,7 @@ func (c *Bor) snapshot(chain consensus.ChainReader, number uint64, hash common.H
// up more headers than allowed to be reorged (chain reinit from a freezer),
// consider the checkpoint trusted and snapshot it.
// TODO fix this
if
number
==
0
/* || (number%c.config.Sprint == 0 && (len(headers) > params.ImmutabilityThreshold || chain.GetHeaderByNumber(number-1) == nil)) */
{
if
number
==
0
{
checkpoint
:=
chain
.
GetHeaderByNumber
(
number
)
if
checkpoint
!=
nil
{
// get checkpoint data
...
...
This diff is collapsed.
Click to expand it.
consensus/bor/bor_test/helper.go
+
10
−
1
View file @
f02da008
...
...
@@ -105,7 +105,16 @@ func buildMinimalNextHeader(t *testing.T, block *types.Block, borConfig *params.
header
.
Number
.
Add
(
header
.
Number
,
big
.
NewInt
(
1
))
header
.
ParentHash
=
block
.
Hash
()
header
.
Time
+=
bor
.
CalcProducerDelay
(
header
.
Number
.
Uint64
(),
borConfig
.
Period
,
borConfig
.
Sprint
,
borConfig
.
ProducerDelay
)
header
.
Extra
=
make
([]
byte
,
97
)
// vanity (32) + extraSeal (65)
isSprintEnd
:=
(
header
.
Number
.
Uint64
()
+
1
)
%
borConfig
.
Sprint
==
0
if
isSprintEnd
{
header
.
Extra
=
make
([]
byte
,
32
+
40
+
65
)
// vanity + validatorBytes + extraSeal
// the genesis file was initialized with a validator 0x71562b71999873db5b286df957af199ec94617f7 with power 10
// So, if you change ./genesis.json, do change the following as well
validatorBytes
,
_
:=
hex
.
DecodeString
(
"71562b71999873db5b286df957af199ec94617f7000000000000000000000000000000000000000a"
)
copy
(
header
.
Extra
[
32
:
72
],
validatorBytes
)
}
else
{
header
.
Extra
=
make
([]
byte
,
32
+
65
)
// vanity + extraSeal
}
_key
,
_
:=
hex
.
DecodeString
(
privKey
)
sig
,
err
:=
secp256k1
.
Sign
(
crypto
.
Keccak256
(
bor
.
BorRLP
(
header
)),
_key
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment