-
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: deep copy jumptable when enabling extra eips #26137
Conversation
When there's extra-eips, concurrent query could cause non-deterministic evm execution result. It could affect even if exists in historical states. Ref: ethereum/go-ethereum#26137
When there's extra-eips, concurrent query could cause non-deterministic evm execution result. It could affect even if exists in historical states. Ref: ethereum/go-ethereum#26137
The go-ethereum/core/vm/jump_table.go Line 111 in d30e39b
All the instruction tables are separate, and defined here: go-ethereum/core/vm/jump_table.go Line 47 in d30e39b
I'm interested in the root issue reported in #26136, what the actual background is where this was found to be a problem @yihuang ? |
@@ -83,14 +83,14 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter { | |||
} | |||
var extraEips []int | |||
for _, eip := range cfg.ExtraEips { |
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.
if len(cfg.ExtraEips) > 0 {
// Deep-copy jumptable to prevent modification of opcodes in other tables
cfg.JumpTable := copyJumpTable(cfg.JumpTable)
}
for _, eip := range cfg.ExtraEips {
if err := EnableEIP(eip, &cfg.JumpTable); err != nil {
// Disable it, so caller can check if it's activated or not
log.Error("EIP activation failed", "eip", eip, "error", err)
} else {
extraEips = append(extraEips, eip)
}
}
Would this work? No need to deep-copy it multiple times
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.
I think the original one also prevents a partial write if EnableEIP
returns an error in the middle.
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.
Ok, the original one set cfg.JumpTable
unconditionally, so it don't prevent a partial write neither.
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.
Ok. Doesn't matter a whole lot, this is not a hot path (for us)
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.
And there's no partial write to prevent anyway, I just changed to your version.
Co-authored-by: Martin Holst Swende <[email protected]>
@@ -83,14 +83,14 @@ func NewEVMInterpreter(evm *EVM, cfg Config) *EVMInterpreter { | |||
} | |||
var extraEips []int | |||
for _, eip := range cfg.ExtraEips { |
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.
Ok. Doesn't matter a whole lot, this is not a hot path (for us)
Co-authored-by: Martin Holst Swende <[email protected]>
Co-authored-by: Martin Holst Swende <[email protected]>
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.
LGTM. IMO this change makes EVM modifications less of a footgun, it might save us from a long debug session at some point.
When there's extra-eips, concurrent query could cause non-deterministic evm execution result. It could affect even if exists in historical states. Ref: ethereum/go-ethereum#26137
When the interpreter is configured to use extra-eips, this change makes it so that all the opcodes are deep-copied, to prevent accidental modification of the 'base' jumptable. Closes: ethereum#26136 Co-authored-by: Martin Holst Swende <[email protected]>
When the interpreter is configured to use extra-eips, this change makes it so that all the opcodes are deep-copied, to prevent accidental modification of the 'base' jumptable. Closes: ethereum#26136 Co-authored-by: Martin Holst Swende <[email protected]>
When the interpreter is configured to use extra-eips, this change makes it so that all the opcodes are deep-copied, to prevent accidental modification of the 'base' jumptable. Closes: ethereum#26136 Co-authored-by: Martin Holst Swende <[email protected]>
Closes: #26136
Thanks: @mmsqe