-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blockchain: More Modern and Flexible Consensus Layout / Tree Shaking …
…Optimization (#3504) * Switch to a more flexible Blockchain consensusDict options structure allowing to pass in different consensus objects * Remove misplaced (non consensus checkand useless (already checked in block header) difficulty equals 0 check from CasperConsensus * Shift to a new consensus semantics adhering to the fact that *consensus* and *consensus validation* is basically the same, allowing for more flexible instantiation and optional consensus object usage * Remove redundant validateConsensus flag, fix block validation, clique and custom consensus tests * Readd validateConsensus flag (default: true) to allow for more fine-grained settings to use the mechanism (e.g. Clique) but skip the respective validation * Find a middle ground between convenience (allow mainnet default blockchain without need for ethash passing in) and consensus availability validation (now in the validate() call) * Add clique example * Client fixes * Fix VM test * Minor * Remove Ethash dependency from Blockchain, adjust EthashConsensus ethash object integration * Re-add CasperConsensus exports * Rebuild package-lock.json * EtashConsensus fix * Fixes * Fix client CLI tests * Cleaner consensus check on validate call * More consistent check for consensus object, re-add test for custom consensus transition * Re-add difficulty check for PoS, re-activate removed test
- Loading branch information
Showing
23 changed files
with
237 additions
and
154 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createBlockchain, CliqueConsensus, ConsensusDict } from '@ethereumjs/blockchain' | ||
import { Chain, Common, ConsensusAlgorithm, Hardfork } from '@ethereumjs/common' | ||
|
||
const common = new Common({ chain: Chain.Goerli, hardfork: Hardfork.London }) | ||
|
||
const consensusDict: ConsensusDict = {} | ||
consensusDict[ConsensusAlgorithm.Clique] = new CliqueConsensus() | ||
const blockchain = await createBlockchain({ | ||
consensusDict, | ||
common, | ||
}) | ||
console.log(`Created blockchain with ${blockchain.consensus.algorithm} consensus algorithm`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.