-
Notifications
You must be signed in to change notification settings - Fork 20.4k
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
core/evm: Random opcode (EIP-4399) #24141
Changes from 7 commits
461995d
62e9c1a
4a4948b
2e1b399
ea26584
4d59679
7d72217
e1a30c1
b80b6a1
c73dc4c
72896f4
8253191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,8 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common | |
Difficulty: new(big.Int).Set(header.Difficulty), | ||
BaseFee: baseFee, | ||
GasLimit: header.GasLimit, | ||
Random: header.MixDigest, | ||
IsPostMerge: header.Difficulty.Cmp(common.Big0) == 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this as a field though? We do pass in the difficult anyway, couldn't we just compare in there? Or look at the |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,8 @@ type BlockContext struct { | |
Time *big.Int // Provides information for TIME | ||
Difficulty *big.Int // Provides information for DIFFICULTY | ||
BaseFee *big.Int // Provides information for BASEFEE | ||
Random common.Hash // Provides information for RANDOM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't we have this be |
||
IsPostMerge bool // Set if we are post-merge | ||
} | ||
|
||
// TxContext provides the EVM with information about a transaction. | ||
|
@@ -131,7 +133,7 @@ func NewEVM(blockCtx BlockContext, txCtx TxContext, statedb StateDB, chainConfig | |
StateDB: statedb, | ||
Config: config, | ||
chainConfig: chainConfig, | ||
chainRules: chainConfig.Rules(blockCtx.BlockNumber), | ||
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.IsPostMerge), | ||
} | ||
evm.interpreter = NewEVMInterpreter(evm, config) | ||
return evm | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,6 +99,7 @@ const ( | |
CHAINID OpCode = 0x46 | ||
SELFBALANCE OpCode = 0x47 | ||
BASEFEE OpCode = 0x48 | ||
RANDOM OpCode = 0x44 // Same as DIFFICULTY | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please keep the sort order |
||
) | ||
|
||
// 0x50 range - 'storage' and execution. | ||
|
@@ -275,7 +276,7 @@ var opCodeToString = map[OpCode]string{ | |
COINBASE: "COINBASE", | ||
TIMESTAMP: "TIMESTAMP", | ||
NUMBER: "NUMBER", | ||
DIFFICULTY: "DIFFICULTY", | ||
DIFFICULTY: "DIFFICULTY", // TODO (MariusVanDerWijden) rename to RANDOM post merge | ||
MariusVanDerWijden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GASLIMIT: "GASLIMIT", | ||
CHAINID: "CHAINID", | ||
SELFBALANCE: "SELFBALANCE", | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, I think we should keep this as
nil
before the merge, just to catch any code accidentally touching this field prematurely.