refactor(specs): delay get_code calls in CALL-like opcodes after gas charging and stack-depth checks#2473
Conversation
Signed-off-by: jsign <jsign.uy@gmail.com>
|
cc @kevaundray |
|
This makes sense to me CC @gurukamath (for thoughts) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2473 +/- ##
===================================================
- Coverage 85.97% 85.97% -0.01%
===================================================
Files 599 599
Lines 36916 36909 -7
Branches 3771 3771
===================================================
- Hits 31738 31731 -7
Misses 4560 4560
Partials 618 618
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
gurukamath
left a comment
There was a problem hiding this comment.
Is the concern here related to when the account access happens? Or is it when the code access happens?
If it is the latter, maybe we could just delay the code access and pass the code_hash to the generic_call instead of the code? That will enable us to keep the account access closely coupled with its gas charging and warming.
| return | ||
|
|
||
| tx_state = evm.message.tx_env.state | ||
| code_hash = get_account(tx_state, code_address).code_hash |
There was a problem hiding this comment.
Another thing to keep in mind is a potential interaction with EIP-2780 which is in CFI status for amsterdam. In that EIP, the gas charge is closely coupled with whether an account has code or not. So we will need to access the account at the gas charging stage itself.
IMO, this point is not a huge concern right now but if 2780 gets SFI'd, we'll have to move the get_account call, back to where it currently is.
|
Which stack overflow does this refer to? Is this the operand stack or is this the call stack? |
This is the call stack (message depth) check |
fselmo
left a comment
There was a problem hiding this comment.
lgtm but I'll defer to @gurukamath for a final review since he's assigned himself a review here.
Leave final review to @gurukamath (assignee)
Yeah. Looks good to me too but I'd still want to wait for what might happen with EIP-2780 just because that EIP tightly couples account access gas accounting with actual account access. |
🗒️ Description
Move the
get_codecall from eachCALL*opcode (call,callcode,delegatecall,staticcall) intogeneric_call, removing thecodeparameter from its signature.All four callers were doing the identical
get_account(tx_state, code_address).code_hash→get_code(tx_state, code_hash)sequence before passing the result togeneric_call, which already receivescode_address.The motivation for this is two-fold:
get_codecall after thecharge_gascall for CALL-like opcodes -- this avoids pulling bytecode that isn't used if that OOGs.charge_gasbut we would also fail due to a stack depth overflow, which would also not use pulled bytecodes.🔗 Related Issues or PRs
N/A.
✅ Checklist
toxchecks to avoid unnecessary CI fails, see also Code Standards and Enabling Pre-commit Checks:uvx tox -e statictype(scope):.mkdocs servelocally and verified the auto-generated docs for new tests in the Test Case Reference are correctly formatted.@ported_frommarker.Cute Animal Picture