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

Block consensus methods refactoring #3571

Merged
merged 47 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8fd3556
Move clique.ts into subdirectory
scorbajio Aug 7, 2024
317ad18
Fix import
scorbajio Aug 7, 2024
84aece0
Make ethashCanonicalDifficulty, _requireClique, and cliqueSigHash sta…
scorbajio Aug 7, 2024
6e67e93
Make cliqueIsEpochTransition a standalone function
scorbajio Aug 7, 2024
22460a4
Remove unused import
scorbajio Aug 7, 2024
b73dfb5
Make cliqueExtraVanity a standalone function and cleanup
scorbajio Aug 7, 2024
5f4dfe6
Make cliqueExtraSeal a standalone function
scorbajio Aug 7, 2024
32dfad5
Make cliqueEpochTransitionSigners a standalone function
scorbajio Aug 7, 2024
ba0284a
Make cliqueVerifySignature and cliqueSigner standalone functions
scorbajio Aug 7, 2024
37fea1f
Fix linting issues
scorbajio Aug 7, 2024
1187d33
Merge branch 'master' into block-consensus-methods-refactoring
scorbajio Aug 7, 2024
eddfb1d
Fix test
scorbajio Aug 7, 2024
7dc74a0
Remove unused import
scorbajio Aug 7, 2024
ef51a55
Update package and package-lock files
scorbajio Aug 7, 2024
50ab7e4
Fix lint issues
scorbajio Aug 7, 2024
16241f6
Merge branch 'block-consensus-methods-refactoring' of github.com:ethe…
scorbajio Aug 7, 2024
c8f4fc1
Fix linting issue
scorbajio Aug 7, 2024
3c30ee3
Merge branch 'master' of github.com:ethereumjs/ethereumjs-monorepo in…
scorbajio Aug 8, 2024
41ffe66
Remove block dependency and pass in cliqueSigner as option to evm
scorbajio Aug 8, 2024
c7dea57
Add more typing for cliqueSigner option
scorbajio Aug 8, 2024
05a84b5
Move cliqueSealBlock functionality into standalone constructor function
scorbajio Aug 8, 2024
54114e7
Fix imports
scorbajio Aug 8, 2024
dd58b43
fix header typing
acolytec3 Aug 9, 2024
bf8ca68
Merge remote-tracking branch 'origin/master' into block-consensus-met…
acolytec3 Aug 12, 2024
c9204ab
remove pointless underscore
acolytec3 Aug 12, 2024
eb89c3c
revise codedoc [no ci]
acolytec3 Aug 12, 2024
a0bb705
Create and use block and header constructor for PoA/cliques
scorbajio Aug 12, 2024
9a02915
Merge branch 'block-consensus-methods-refactoring' of github.com:ethe…
scorbajio Aug 12, 2024
917d48f
Fix linting issue
scorbajio Aug 12, 2024
b95ae39
Fix tests
scorbajio Aug 12, 2024
aab9b6e
Fix test
scorbajio Aug 12, 2024
eec50fe
Make constructor signatures more similar
scorbajio Aug 12, 2024
598b922
Fix read-only error
scorbajio Aug 12, 2024
4818096
fix extraData function reference
acolytec3 Aug 13, 2024
4b7090a
fix the freeze
acolytec3 Aug 13, 2024
8d53ea0
Fix test
scorbajio Aug 13, 2024
6048d8f
Fix test
scorbajio Aug 13, 2024
c981daf
Handle creating a sealed block for PoA blocks in vm block builder
scorbajio Aug 13, 2024
f6a02d1
Fix tests
scorbajio Aug 13, 2024
aec9005
Update docstring
scorbajio Aug 13, 2024
fe00092
reorganize test with proper it-ing [no ci]
acolytec3 Aug 13, 2024
07342f8
handle clique consensus validation at correct point
acolytec3 Aug 13, 2024
be12a25
clean up code docs
acolytec3 Aug 13, 2024
ad688cd
Merge remote-tracking branch 'origin/master' into block-consensus-met…
acolytec3 Aug 13, 2024
831e1d6
revert invalid check
acolytec3 Aug 13, 2024
8a02fbe
Fix lint issue
scorbajio Aug 13, 2024
c029904
Merge branch 'master' into block-consensus-methods-refactoring
acolytec3 Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/evm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"visualize:bundle": "npx vite build --config=./vite.config.bundler.ts --emptyOutDir=false --outDir ."
},
"dependencies": {
"@ethereumjs/block": "^5.2.0",
"@ethereumjs/common": "^4.3.0",
"@ethereumjs/statemanager": "^2.3.0",
"@ethereumjs/tx": "^5.3.0",
Expand Down
12 changes: 10 additions & 2 deletions packages/evm/src/interpreter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { cliqueSigner } from '@ethereumjs/block'
import { ConsensusAlgorithm } from '@ethereumjs/common'
import {
Account,
Expand Down Expand Up @@ -159,6 +158,15 @@ export class Interpreter {
this._evm = evm
this._stateManager = stateManager
this.common = this._evm.common

if (
this.common.consensusType() === 'poa' &&
this._evm['_optsCached'].cliqueSigner === undefined
)
throw new Error(
'Must include cliqueSigner function if clique/poa is being used for consensus type',
)

this._runState = {
programCounter: 0,
opCode: 0xfe, // INVALID opcode
Expand Down Expand Up @@ -782,7 +790,7 @@ export class Interpreter {
getBlockCoinbase(): bigint {
let coinbase: Address
if (this.common.consensusAlgorithm() === ConsensusAlgorithm.Clique) {
coinbase = cliqueSigner(this._env.block.header as any)
coinbase = this._evm['_optsCached'].cliqueSigner!(this._env.block.header as any)
} else {
coinbase = this._env.block.header.coinbase
}
Expand Down
5 changes: 5 additions & 0 deletions packages/evm/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ export interface EVMOpts {
*
*/
profiler?: EVMProfilerOpts

/**
* Must be present if consensus type is clique/poa, else error will be thrown
scorbajio marked this conversation as resolved.
Show resolved Hide resolved
*/
cliqueSigner?: Function
scorbajio marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
Loading