BEP-341: Validators can produce consecutive blocks#2482
BEP-341: Validators can produce consecutive blocks#2482unclezoro merged 21 commits intobnb-chain:developfrom
Conversation
3193cf0 to
6f8423c
Compare
417a19f to
bb16185
Compare
e705707 to
e1723e1
Compare
9f663bf to
6589d44
Compare
a141a9b to
bd82176
Compare
| snap.updateAttestation(header, chainConfig, s.config) | ||
| // change validator set | ||
| if number > 0 && number%s.config.Epoch == uint64(len(snap.Validators)/2) { | ||
| if number > 0 && number%s.config.Epoch == snap.minerHistoryCheckLen() { |
There was a problem hiding this comment.
why not snap.minerHistoryCheckLen() + 1 to change validator set?
There was a problem hiding this comment.
why not
snap.minerHistoryCheckLen() + 1to change validator set?
when turnLenght==1, snap.minerHistoryCheckLen() == uint64(len(snap.Validators)/2), exactly the same as before.
why not +1 here?
for example when turnLenght ==1,
[200, 210] contains 11 validators, is a majority of validators, so can do the change at 210, not wait to 211.
| snap.Validators[val].Index = idx + 1 // offset by 1 | ||
| } | ||
| } | ||
| for i := snap.versionHistoryCheckLen(); i < oldVersionsLen; i++ { |
There was a problem hiding this comment.
this apply(...) is not code review friendly...
There was a problem hiding this comment.
we can compare to the old logic about deleting RecentForkHashes,
the effect is the same as before, but the code is much more simplified
| func (s *Snapshot) inturnValidator() common.Address { | ||
| validators := s.validators() | ||
| offset := (s.Number + 1) % uint64(len(validators)) | ||
| offset := (s.Number + 1) / uint64(s.TurnLength) % uint64(len(validators)) |
There was a problem hiding this comment.
(s.Number + s.TurnLength) / uint64(s.TurnLength)?
There was a problem hiding this comment.
(s.Number + s.TurnLength) / uint64(s.TurnLength)?
when at height s.Number + 1 , we can get snapshot with s.Number.
the function name is not quite clear. I will update the comments for the function
There was a problem hiding this comment.
(s.Number + s.TurnLength) == (s.Number + 1 + (s.TurnLength -1))
There was a problem hiding this comment.
(s.Number + s.TurnLength) == (s.Number + 1 + (s.TurnLength -1))
not enable the first validator after switch go generate s.TurnLength blocks
Description
BEP-341: Validators can produce consecutive blocks
related change in system contracts
Rationale
tell us why we need these changes...
Example
add an example CLI or API response...
Changes
Notable changes: