clarify epoch sync handling (effectively a comment update only)

why:
  autorisation list verification is performed in the main module along
  with other header verifications
This commit is contained in:
Jordan Hrycaj 2021-06-16 09:07:18 +01:00 committed by Jordan Hrycaj
parent dd7ca174f0
commit 90b012ad3f
4 changed files with 16 additions and 21 deletions

View File

@ -250,7 +250,7 @@ type
errCliqueGasRepriceFork errCliqueGasRepriceFork
errCliqueSealSigFn errCliqueSealSigFn
errCliqueStopped = "Process was interrupted" errCliqueStopped = "process was interrupted"
errCliqueExpectedBaseFee = "header is missing baseFee" errCliqueExpectedBaseFee = "header is missing baseFee"
errCliqueGasLimitTooLow = "gas limit is too low" errCliqueGasLimitTooLow = "gas limit is too low"
errCliqueGasLimitTooHigh = "gas limit is too high" errCliqueGasLimitTooHigh = "gas limit is too high"

View File

@ -110,6 +110,11 @@ proc delVote*(t: var CliquePoll; signer, address: EthAddress) {.
t.votes[address].signers.del(signer) t.votes[address].signers.del(signer)
proc flushVotes*(t: var CliquePoll) =
## Reset/flush pending votes, authorised signers remain the same.
t.votes.clear
# clique/snapshot.go(141): func (s *Snapshot) validVote(address [..] # clique/snapshot.go(141): func (s *Snapshot) validVote(address [..]
proc validVote*(t: var CliquePoll; address: EthAddress; authorize: bool): bool = proc validVote*(t: var CliquePoll; address: EthAddress; authorize: bool): bool =
## Check whether voting would have an effect in `addVote()` ## Check whether voting would have an effect in `addVote()`

View File

@ -30,7 +30,6 @@ import
./clique_cfg, ./clique_cfg,
./clique_defs, ./clique_defs,
./clique_poll, ./clique_poll,
./clique_utils,
./ec_recover, ./ec_recover,
chronicles, chronicles,
eth/[common, rlp, trie/db] eth/[common, rlp, trie/db]
@ -82,7 +81,7 @@ proc pp(s: var Snapshot; h: var AddressHistory): string =
proc pp(s: var Snapshot; v: Vote): string = proc pp(s: var Snapshot; v: Vote): string =
proc authorized(b: bool): string = proc authorized(b: bool): string =
if b: "auhorize" else: "de-authorize" if b: "authorise" else: "de-authorise"
ppExceptionWrap: ppExceptionWrap:
"(" & &"address={s.pp(v.address)}" & "(" & &"address={s.pp(v.address)}" &
&",signer={s.pp(v.signer)}" & &",signer={s.pp(v.signer)}" &
@ -239,24 +238,15 @@ proc applySnapshot*(s: var Snapshot;
# Remove any votes on checkpoint blocks # Remove any votes on checkpoint blocks
if (number mod s.cfg.epoch) == 0: if (number mod s.cfg.epoch) == 0:
# clique/snapshot.go(210): snap.Votes = nil # Note that the correctness of the authorised accounts list is verified in
s.say "applySnapshot epoch => reset, state=", s.pp(41) # clique/clique.verifyCascadingFields(),
# see clique/clique.go(355): if number%c.config.Epoch == 0 {
# This part differs from the go implementation in that the `signer` # This means, the account list passed with the epoch header is verified
# list is re-assigned. The original implementation silently assumes # to be the same as the one we already have.
# that the `signer` list is the same as the previous one but this is
# not enforced.
# #
# The eip225 discussion has it as: [..] where every epoch transition # clique/snapshot.go(210): snap.Votes = nil
# flushes all pending votes. Furthermore, these epoch transitions can s.data.ballot.flushVotes
# also act as stateless checkpoints containing the list of current s.say "applySnapshot epoch => reset, state=", s.pp(41)
# authorized signers within the header extra-data. This permits clients
# to sync up based only on a checkpoint hash without having to replay
# all the voting that was done on the chain up to that point. It also
# allows the genesis header to fully define the chain, containing the
# list of initial signers.
s.data.ballot.initCliquePoll(header.extraData.extraDataAddresses)
s.data.ballot.setDebug(s.data.debug)
# Delete the oldest signer from the recent list to allow it signing again # Delete the oldest signer from the recent list to allow it signing again
block: block:

View File

@ -36,7 +36,7 @@ proc cliqueMain*(noisy = defined(debug)) =
# clique/snapshot_test.go(379): for i, tt := range tests { # clique/snapshot_test.go(379): for i, tt := range tests {
for tt in voterSamples.filterIt(it.id in testSet): for tt in voterSamples.filterIt(it.id in testSet):
test &"Snapshots {tt.id: 2}: {tt.info.substr(0,50)}...": test &"Snapshots {tt.id:2}: {tt.info.substr(0,50)}...":
pool.say "\n" pool.say "\n"
if tt.id in skipSet: if tt.id in skipSet: