fix(test-benchmark): account access subcall OOG issue#2614
fix(test-benchmark): account access subcall OOG issue#2614spencer-tb merged 2 commits intoethereum:forks/amsterdamfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #2614 +/- ##
================================================
Coverage 86.24% 86.24%
================================================
Files 599 599
Lines 36984 36984
Branches 3795 3795
================================================
Hits 31895 31895
Misses 4525 4525
Partials 564 564
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:
|
|
|
||
| if value_sent > 0: | ||
| post[attack_address] = Account( | ||
| balance=initial_balance - total_iterations * value_sent, |
There was a problem hiding this comment.
This assumes that we calculated the total_iterations correctly.
Note that we cannot do this, because we do not know how much gas the unknown contract will consume (yes, for repricing we target Bittrex, but we could target any contract). So our gas cost estimation will be lower than the actual cost, and therefore our total_iterations might be higher.
I think the correct test here is that the balance has decreased. Then at least one transaction succeeded and one value transfer succeeded there also.
Note that this verification does not work for contracts blocking ether sends (they will always revert/OOG)
There was a problem hiding this comment.
Will merge for now. Can follow up in another if still needs addressed.
There was a problem hiding this comment.
My refactor does not calculate the total_iterations for the post verification now.
The current workaround is to add an exit condition for the while loop, i calculate approximate the execution cost for all account mode variants (EXISTING_EOA, NON_EXISTING_EOA and EXISTING_CONTRACT).
The current approach is far from perfect, since we still lacking the verifcation to the test, i will continue on the validation part in a follow up PR.
71ea7c4 to
52cd483
Compare
52cd483 to
708941d
Compare
🗒️ Description
Fix
test_account_accessbenchmark: theWhileloop lacked an exit condition, causing every transaction and subcall to OOG and revert all value transfers. This made thevalue_sent=1variants (CALL/CALLCODE× 3 account modes × 3 cache strategies = 18 test cases) fail withBalanceMismatchError.Add gas threshold to
Whileloop (condition=Op.GT(Op.GAS, 0x9000)) forvalue_sent > 0so the loop terminates cleanly before running out of gas. The threshold (36,864) is just above the worst-case single-iteration cost (CALL + cold + value + new_account = 36,600).Skip Bittrex Controller nonce=1 contract via
calldata_offsetforEXISTING_CONTRACTmode. The nonce=1 child contract has a non-payable fallback (INVALIDat offset 44) that reverts when receiving ETH. Nonce ≥ 2 contracts (545 bytes, identical bytecode) have a payable fallback thatSTOPimmediately.Remove hardcoded
gas=1from CALL/CALLCODE andgas=1, args_size=1024from STATICCALL/DELEGATECALL parameters that were limiting subcall gas, which leads to OOG.Compute
total_iterationsfor future balance verification; replaceexpected_benchmark_gas_usedwithskip_gas_used_validation=True+expected_receipt_status=1, since we could not correctly calculate the gas cost here.🔗 Related Issues or PRs
✅ Checklist
just 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