Fix/delegated code failed witness missing#1270
Conversation
📝 WalkthroughWalkthroughBumps Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant EVM
participant State
participant Parser
Caller->>EVM: Call(msg)
EVM->>State: Check balance(msg.From)
alt insufficient balance
EVM->>State: Read code at msg.To
State->>Parser: Provide code
Parser->>Parser: Parse for delegation target
Parser->>State: Load delegated target code into witness
EVM-->>Caller: return ErrInsufficientBalance
else sufficient balance
EVM->>State: proceed with normal call flow
EVM-->>Caller: return result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
core/vm/evm.go (1)
279-293: Add EIP-7702 delegation witness loading toCallCodefor parity withCall.The
CallCodemethod at line 291 is missing the EIP-7702 witness fix present in theCallmethod. When the balance check fails,CallCodeshould load delegated code into the witness before returningErrInsufficientBalance, consistent with the logic at lines 193-199 inCall:if !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) { // EIP-7702: Ensure delegated code is loaded into witness even when balance check fails. if code := evm.StateDB.GetCode(addr); len(code) > 0 { if target, ok := types.ParseDelegation(code); ok { evm.StateDB.GetCode(target) } } return nil, gas, ErrInsufficientBalance }
🧹 Nitpick comments (1)
core/vm/evm.go (1)
193-199: Consider addingIsEuclidV2guard for consistency.The
resolveCodeandresolveKeccakCodeHashmethods (lines 555-580) both guard delegation parsing withevm.chainRules.IsEuclidV2. This new code path parses delegation without the version check.While
ParseDelegationwould returnfalsefor non-delegation code, adding the guard maintains consistency and avoids unnecessary work pre-EuclidV2:Suggested fix
// Fail if we're trying to transfer more than the available balance if value.Sign() != 0 && !evm.Context.CanTransfer(evm.StateDB, caller.Address(), value) { // EIP-7702: Ensure delegated code is loaded into witness even when balance check fails. // revm always loads the code regardless of balance check result. - if code := evm.StateDB.GetCode(addr); len(code) > 0 { - if target, ok := types.ParseDelegation(code); ok { - evm.StateDB.GetCode(target) + if evm.chainRules.IsEuclidV2 { + if code := evm.StateDB.GetCode(addr); len(code) > 0 { + if target, ok := types.ParseDelegation(code); ok { + evm.StateDB.GetCode(target) + } } } return nil, gas, ErrInsufficientBalance }
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
core/vm/evm.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: build-and-push
- GitHub Check: semgrep/ci
- GitHub Check: test
- GitHub Check: Analyze (go)
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
…m:scroll-tech/go-ethereum into fix/delegated_code_failed_witness_missing
1. Purpose or design rationale of this PR
Essentially, the setting of witness is different from upstream
GetCodeto put the pre-check failure to witnessstatedb.WithWitness-> blockchain.Processor().Process to load witness, if the pre-check failed, will return and don't add the failed delegated code to witness.2. PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
3. Deployment tag versioning
Has the version in
params/version.gobeen updated?4. Breaking change label
Does this PR have the
breaking-changelabel?Summary by CodeRabbit
Chores
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.