-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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/vm/runtime: set random to enable merge-opcodes #29799
Conversation
@@ -101,6 +101,10 @@ func setDefaults(cfg *Config) { | |||
if cfg.BlobBaseFee == nil { | |||
cfg.BlobBaseFee = big.NewInt(params.BlobTxMinBlobGasprice) | |||
} | |||
// Merge indicators | |||
if t := cfg.ChainConfig.ShanghaiTime; cfg.ChainConfig.TerminalTotalDifficultyPassed || (t != nil && *t == 0) { |
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.
It seems like block number can be overriden. Is the *t == 0 check enough?
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.
No, it's strictly enough nor correct. We're checking shanghai but shanghai is after merge. This change just makes it work better than it does right now.
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.
Shouldn't we also enable these forks by default?
e.g.
diff --git a/core/vm/runtime/runtime.go b/core/vm/runtime/runtime.go
index b587d6d5a0..9c448a80c7 100644
--- a/core/vm/runtime/runtime.go
+++ b/core/vm/runtime/runtime.go
@@ -57,21 +57,32 @@ type Config struct {
// sets defaults on the config
func setDefaults(cfg *Config) {
if cfg.ChainConfig == nil {
+ var (
+ shanghaiTime = uint64(0)
+ cancunTime = uint64(0)
+ )
cfg.ChainConfig = ¶ms.ChainConfig{
- ChainID: big.NewInt(1),
- HomesteadBlock: new(big.Int),
- DAOForkBlock: new(big.Int),
- DAOForkSupport: false,
- EIP150Block: new(big.Int),
- EIP155Block: new(big.Int),
- EIP158Block: new(big.Int),
- ByzantiumBlock: new(big.Int),
- ConstantinopleBlock: new(big.Int),
- PetersburgBlock: new(big.Int),
- IstanbulBlock: new(big.Int),
- MuirGlacierBlock: new(big.Int),
- BerlinBlock: new(big.Int),
- LondonBlock: new(big.Int),
+ ChainID: big.NewInt(1),
+ HomesteadBlock: new(big.Int),
+ DAOForkBlock: new(big.Int),
+ DAOForkSupport: false,
+ EIP150Block: new(big.Int),
+ EIP155Block: new(big.Int),
+ EIP158Block: new(big.Int),
+ ByzantiumBlock: new(big.Int),
+ ConstantinopleBlock: new(big.Int),
+ PetersburgBlock: new(big.Int),
+ IstanbulBlock: new(big.Int),
+ MuirGlacierBlock: new(big.Int),
+ BerlinBlock: new(big.Int),
+ LondonBlock: new(big.Int),
+ ArrowGlacierBlock: nil,
+ GrayGlacierBlock: nil,
+ TerminalTotalDifficulty: big.NewInt(0),
+ TerminalTotalDifficultyPassed: true,
+ MergeNetsplitBlock: nil,
+ ShanghaiTime: &shanghaiTime,
+ CancunTime: &cancunTime,
}
}
This PR closes #29782 and #29722 . The
IsMerge
indicator used by core/vm/runtime checked if the prevrandao/random was set. This is actually a somewhat sane indicator, because if it isnil
, it will trigger a nil deref later on if theRANDOM
opcode is used.This PR fixes it by setting it in case we're past Shanghai.