Repository navigation
Conversation
Monad's staking contract at 0x1000 has been a precompile, and so warm, since MONAD_FOUR. Neither the testing framework nor the spec treated it as one: the framework left it out of `precompiles()`, and the spec left it out of `PRE_COMPILED_CONTRACTS`. So fixtures probed 0x1000 as a cold, empty neighbour of the reserve balance precompile, and `test_call_precompile_range_boundaries` expected a cold, successful call where monad performs a warm, failing one. List 0x1000 in `MONAD_EIGHT.precompiles()` and register a fallback-only staking stub in every Monad fork. The stub matches monad's behaviour for unsupported methods: a call other than CALL fails, and a CALL charges 40000 gas and reverts with "method not supported", consuming all gas. The staking methods themselves are not modelled. Drop the test skips that excluded 0x1000 as not yet implemented, and count it among the precompiles that reject empty input.
Comment on lines
+58
to
+63
| # GAS | ||
| charge_gas(evm, GasCosts.PRECOMPILE_STAKING_FALLBACK) | ||
|
|
||
| # OPERATION | ||
| evm.output = b"method not supported" | ||
| raise RevertInMonadPrecompile |
There was a problem hiding this comment.
Fallback boundaries lack tests
The new fallback has no focused test for its 40,000-gas cutoff or returned error bytes. Existing tests check call success or whether the gas difference is nonzero. Because failure burns all forwarded gas, another charge below 50,000 could pass those checks and produce incorrect fixtures.
Add cases for CALL with 39,999, 40,000, and 40,001 gas. Check returned bytes and remaining gas, including b"method not supported" when the charge succeeds. Also check that the other call opcodes return no bytes. This is non-blocking test coverage feedback.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/ethereum/forks/monad_eight/vm/precompiled_contracts/staking.py
Line: 58-63
Comment:
**Fallback boundaries lack tests**
The new fallback has no focused test for its 40,000-gas cutoff or returned error bytes. Existing tests check call success or whether the gas difference is nonzero. Because failure burns all forwarded gas, another charge below 50,000 could pass those checks and produce incorrect fixtures.
Add cases for `CALL` with 39,999, 40,000, and 40,001 gas. Check returned bytes and remaining gas, including `b"method not supported"` when the charge succeeds. Also check that the other call opcodes return no bytes. This is non-blocking test coverage feedback.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Monad's staking contract at
0x1000has been a precompile, and therefore warm, since MONAD_FOUR (monad:staking_active()incategory/vm/evm/traits.hpp,is_precompileincategory/execution/monad/monad_precompiles.cpp). Neither layer here treated it as one:MONAD_EIGHT.precompiles()did not list it, soprecompile_range_boundaries()produced0x1000as the cold neighbour of the reserve balance precompile at0x1001.PRE_COMPILED_CONTRACTShad noSTAKING_ADDRESSentry. The pre-warmed set comes from that mapping, so the t8n treated0x1000as cold, empty code.As a result,
tests-monad@v1.3.0is wrong forberlin/eip2929_gas_cost_increases/test_call.py::test_call_precompile_range_boundaries[...address_0x…1000-warm_False]on MONAD_NINE, MONAD_TEN and MONAD_NEXT_AMSTERDAM, for all four call opcodes:0x2789(cold)0x79(warm)This PR:
Address(0x1000, label="STAKING")toMONAD_EIGHT.precompiles(). NINE, TEN and NEXT_AMSTERDAM inherit it.PRE_COMPILED_CONTRACTSformonad_eight,monad_nine,monad_tenandmonad_next_amsterdam. It matches monad's behaviour for unsupported methods (precompile_dispatch/precompile_fallbackinstaking_contract.cpp):PRECOMPILE_STAKING_FALLBACK), runs out of gas if it has less, and otherwise reverts with"method not supported", consuming all gas.tests/frontier/precompiles/, and adds0x1000to the precompiles that reject empty input intest_touched_account_emptiness.py.Verification, with the release fill parameters (
-m blockchain_test --from=MONAD_EIGHT --until=MONAD_NEXT_AMSTERDAM --chain-id=143 -k "not invalid_header"):test_call_precompile_range_boundaries: 248 passed.0x1000is now probed as warm (slot 0 =0x79, call fails), with0x0fffand0x1000 | 1<<152probed as cold.tests/: 82660 passed, 0 failed.test_precompiles.py,test_precompile_absence.pyandtest_touched_account_emptiness.py: 570 passed on the Monad forks.test_precompile_absence.pyalso passes on Prague.Downstream, category-labs/monad#2751 temporarily excludes
call_precompile_range_boundaries.jsonfor MONAD_NINE, MONAD_TEN and MONAD_NEXT_AMSTERDAM. Those exclusions can be dropped once a release with this fix (e.g.tests-monad@v1.3.1) is cut.Open question for maintainers: whether this fix should also be backported to other fork branches.
Related Issues or PRs
Related: #17, a draft with a much fuller staking precompile model and tests. This PR is the minimal piece needed to fix the fixtures; #17's model could later replace the fallback-only
staking.pyin the same files.Checklist
just static<type>(<area>): <description>, where<type>and<area>come from an appropriateC-<type>, respectivelyA-<area>, label. The title should match the target squash commit message.Cute Animal Picture
The PR appears safe to merge, with a non-blocking request for focused fallback tests.
Fix with agent prompt
Summary
Makes
0x1000warm in the testing framework and specification for the four supported Monad forks.Acknowledged scope:
Baltoliexplicitly defers supported staking methods to a fuller model related to #17. Their absence is intentional and is not reported.Reviews (1) · Last reviewed commit: "fix(tests,fw,specs): Make the staking pr..." · Reviewed by Greptile