Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clique small fixes / follow-up work #1074

Merged
merged 9 commits into from Feb 5, 2021
Merged

Clique small fixes / follow-up work #1074

merged 9 commits into from Feb 5, 2021

Conversation

ryanio
Copy link
Contributor

@ryanio ryanio commented Jan 29, 2021

This PR addresses some further work from review in #1032:

  • New block option to provide a privateKey to seal a block: cliqueSigner?: Buffer
  • Exactly compare checkpointSigners list with activeSigners list
  • Keep signer states for CLIQUE_SIGNER_HISTORY_BLOCK_LIMIT as number of blocks, not number of last states
  • Don't reset votes on epoch blocks to keep in case of reorgs, but only count non-stale votes in cliqueUpdateVotes() by checking if the vote's blockNumber >= last epoch block.
  • Explicitly check for availability of blockchain.cliqueActiveSigners() in BlockHeader.validateCliqueDifficulty() to not add to block's minimum blockchain interface (discussion)
  • Simplify Address.equals(address) checks with ethereumjs-util v7.0.8

@codecov
Copy link

codecov bot commented Jan 29, 2021

Codecov Report

Merging #1074 (786392c) into master (879b5db) will decrease coverage by 0.06%.
The diff coverage is 81.81%.

Impacted file tree graph

Flag Coverage Δ
block 81.33% <81.81%> (-0.06%) ⬇️
blockchain 83.55% <92.59%> (+0.64%) ⬆️
client 87.42% <ø> (-0.13%) ⬇️
common 86.28% <ø> (ø)
devp2p 82.48% <ø> (ø)
ethash 82.08% <ø> (ø)
tx 90.00% <ø> (ø)
vm 83.94% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@holgerd77 holgerd77 mentioned this pull request Jan 29, 2021
…` as number of blocks, not number of array entries

* don't reset votes on epoch blocks to keep in case of reorgs, but only count in `cliqueUpdateVotes()` if blockNumber >= last epoch block
* in trimming signer votes, keep votes until `lastEpochBlockNumber - CLIQUE_SIGNER_HISTORY_BLOCK_LIMIT` (as a safe number for potential recounts on reorgs)
@holgerd77
Copy link
Member

Can this PR get an update? Is this generally ready for review?

@ryanio
Copy link
Contributor Author

ryanio commented Feb 5, 2021

@holgerd77 yes now ready for review, thanks!

@holgerd77 holgerd77 marked this pull request as ready for review February 5, 2021 17:03
Copy link
Member

@holgerd77 holgerd77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks all good, thanks Ryan! 👍

// If cliqueSigner is provided, seal block with provided privateKey.
if (options.cliqueSigner) {
this.extraData = this.cliqueSealBlock(options.cliqueSigner)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, also like that the private key is not residing in the library, was a bit worried that we introduce some new potential security risks here.

const signerFound = signerList.find((signer) => {
return signer.toBuffer().equals(signerAddress)
return signer.equals(signerAddress)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, that's really a much nicer API! 😄

@holgerd77 holgerd77 merged commit 3f6d488 into master Feb 5, 2021
@holgerd77 holgerd77 deleted the clique-small-fixes branch February 5, 2021 17:24
@holgerd77 holgerd77 mentioned this pull request Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants