fix(evm): load delegation code during balance check in CallCode#1277
Conversation
📝 WalkthroughWalkthroughCallCode now loads delegated code into the witness when balance checks fail, mirroring Call behavior for consistency. Version patch constant incremented from 4 to 5, updating derived version strings accordingly. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 OpenGrep (1.16.2)core/vm/evm.go┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m �[1m Loading rules from local config...�[0m params/version.go┌──────────────┐ �[32m✔�[39m �[1mOpengrep OSS�[0m �[1m Loading rules from local config...�[0m 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.
🧹 Nitpick comments (1)
core/vm/evm.go (1)
292-298: Extract the delegation witness warm-up into a helper.This
GetCode(addr) -> ParseDelegation(code) -> GetCode(target)sequence now exists in both theCallandCallCodeinsufficient-balance branches. Pulling it behind one helper would keep the two paths from drifting again the next time the EIP-7702 witness behavior changes.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@core/vm/evm.go` around lines 292 - 298, Extract the delegation witness warm-up logic into a single helper to avoid duplication: create a function (e.g., ensureDelegationWitness or warmDelegationForAddr) that accepts the StateDB and an address, performs evm.StateDB.GetCode(addr), calls types.ParseDelegation(code) and if ParseDelegation returns (target, true) calls evm.StateDB.GetCode(target); then replace the duplicated sequences in the insufficient-balance branches inside Call and CallCode with a call to this helper (passing the same evm.StateDB and addr) so both paths share the same implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@core/vm/evm.go`:
- Around line 292-298: Extract the delegation witness warm-up logic into a
single helper to avoid duplication: create a function (e.g.,
ensureDelegationWitness or warmDelegationForAddr) that accepts the StateDB and
an address, performs evm.StateDB.GetCode(addr), calls
types.ParseDelegation(code) and if ParseDelegation returns (target, true) calls
evm.StateDB.GetCode(target); then replace the duplicated sequences in the
insufficient-balance branches inside Call and CallCode with a call to this
helper (passing the same evm.StateDB and addr) so both paths share the same
implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aca6748e-9e93-4408-bd7a-c9ab76dae168
📒 Files selected for processing (2)
core/vm/evm.goparams/version.go
1. Purpose or design rationale of this PR
Make sure delegated code is loaded, even if
CallCodefails with balance insufficient error (same as in #1270). This ensures that revm can process the produced execution 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
Bug Fixes
Chores