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

Structural Preparations for PoA Support #937

Merged
merged 6 commits into from
Nov 10, 2020
Merged

Structural Preparations for PoA Support #937

merged 6 commits into from
Nov 10, 2020

Conversation

holgerd77
Copy link
Member

@holgerd77 holgerd77 commented Nov 4, 2020

This PR provides some ground for a future PoA support, see #689. I am doing this now since I hope that this will allow us for a future PoA feature addition without the need for another major release respectively introducing breaking changes. I have done some reading along on the Clique PoA EIP-225 and I think this should get a solid enough structural setup with this PR which should allow for non-breaking integration (by adding signer validation on PoA chains along an activated Blockchain.validateConsensus setting), this might benefit from some validation though.

The PR introduces code parts to now throw on Block or Blockchain validation triggers on setups which we just don't support yet (validate blocks on 'goerli') or which doesn't make sense (run 'validateDifficulty()' on goerli) and therefore reduces undefined behavior within the libraries.

@jochem-brouwer if this PR is supported and reviewed, we can merge on top of your blockchain refactoring changes with me rebasing or the the other way around, as you prefer.

@codecov
Copy link

codecov bot commented Nov 4, 2020

Codecov Report

Merging #937 (f81afa3) into master (f53559c) will decrease coverage by 0.62%.
The diff coverage is 42.30%.

Impacted file tree graph

Flag Coverage Δ
block 75.04% <31.81%> (-1.33%) ⬇️
blockchain 77.39% <46.15%> (-0.66%) ⬇️
common 91.87% <100.00%> (-0.17%) ⬇️
ethash 82.08% <ø> (ø)
tx 88.63% <100.00%> (+0.08%) ⬆️
vm 87.21% <ø> (ø)

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

@holgerd77
Copy link
Member Author

Some tests are failing, so relabelling this as WIP, can be picked up though.

@holgerd77
Copy link
Member Author

Ok, this was an easy fix 😄 , ready again for review.

@jochem-brouwer
Copy link
Member

Added some questions and some nitpicks. But looks great in general 😄

rumkin
rumkin previously requested changes Nov 4, 2020
packages/blockchain/src/index.ts Outdated Show resolved Hide resolved
packages/blockchain/src/index.ts Show resolved Hide resolved
packages/common/src/index.ts Show resolved Hide resolved
packages/vm/examples/run-blockchain/index.ts Show resolved Hide resolved
packages/common/src/index.ts Show resolved Hide resolved
packages/blockchain/src/index.ts Outdated Show resolved Hide resolved
packages/blockchain/src/index.ts Show resolved Hide resolved
@holgerd77
Copy link
Member Author

Ok, this is now ready for re-review, for an overview on the changes pushed see 60ecd32, thanks @jochem-brouwer and @rumkin for all the valuable suggestions.

I took a lot of time on giving the validation methods a better documentation, I think this should make this a lot clearer on first-time read, I also learned a lot myself here. 😄 I also made the validate methods for Block and Blockchain less strict again and don't completely throw on non-PoW chains but just skip the difficulty check and do everything else, think this makes more sense.

@jochem-brouwer
Copy link
Member

OK this is great! I also love that you added a lot of documentation here.

I think the way to proceed (see this comment) is to (in a new PR) remove most of this consensus logic from blockchain/block and use this strategy pattern so we can choose which strategy we use for validating the block/block header. So these concrete instances would be a PoW consensus and a Clique consensus. These would allow us to validate the consensus (PoW/Clique) and also validate the block/block header (note that in Clique there are no uncles, for instance, so the uncle hash is always the empty list hash).

@jochem-brouwer
Copy link
Member

@holgerd77 I suggest we merge this one after my block/blockchain PRs are merged so you can rebase on top of my changes (seems to be less work than the other way around).

@holgerd77
Copy link
Member Author

Currently blocked by #942

@holgerd77
Copy link
Member Author

Will take the next hour or so to update (hopefully rebase) with the changes from #942 and previous block/blockchain touching PRs.

@holgerd77
Copy link
Member Author

Bildschirmfoto 2020-11-10 um 09 27 25

Oh, that's a tough one. 😂

…on renaming, throw on unsupported chain consensus types (PoA)
…tion methods, allow blockchain and block validate methods to operate on non-PoW chains
@holgerd77
Copy link
Member Author

Ok, this is now ready for re-review. 😄 //cc @jochem-brouwer

Copy link
Member

@jochem-brouwer jochem-brouwer left a comment

Choose a reason for hiding this comment

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

LGTM! 😄

@holgerd77 holgerd77 merged commit d7d9123 into master Nov 10, 2020
@holgerd77 holgerd77 deleted the poa-preparations branch November 10, 2020 12:00
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.

3 participants