Skip to content

Commit 9b29e9c

Browse files
committed
refactor: polishes to clarity and consistency
Co-Authored-By: Claude <opus>
1 parent d10557d commit 9b29e9c

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/ethereum/forks/monad_eight/vm/precompiled_contracts/staking.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def staking(evm: Evm) -> None:
357357
evm.output = b"value is nonzero"
358358
raise RevertInMonadPrecompile
359359

360-
# Validate calldata size (addValidator does ABI validation instead)
360+
# Validate calldata size (addValidator defers to its handler)
361361
if selector != SELECTOR_ADD_VALIDATOR:
362362
if len(data) < expected_size:
363363
evm.output = b"input too short"
@@ -394,5 +394,7 @@ def staking(evm: Evm) -> None:
394394
elif selector == SELECTOR_WITHDRAW:
395395
evm.output = b"unknown withdrawal id"
396396
raise RevertInMonadPrecompile
397+
else:
398+
raise AssertionError(f"unhandled setter: {selector.hex()}")
397399
else:
398400
raise InvalidParameter

src/ethereum/forks/monad_nine/vm/precompiled_contracts/staking.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def staking(evm: Evm) -> None:
357357
evm.output = b"value is nonzero"
358358
raise RevertInMonadPrecompile
359359

360-
# Validate calldata size (addValidator does ABI validation instead)
360+
# Validate calldata size (addValidator defers to its handler)
361361
if selector != SELECTOR_ADD_VALIDATOR:
362362
if len(data) < expected_size:
363363
evm.output = b"input too short"
@@ -394,5 +394,7 @@ def staking(evm: Evm) -> None:
394394
elif selector == SELECTOR_WITHDRAW:
395395
evm.output = b"unknown withdrawal id"
396396
raise RevertInMonadPrecompile
397+
else:
398+
raise AssertionError(f"unhandled setter: {selector.hex()}")
397399
else:
398400
raise InvalidParameter

tests/monad_eight/staking_precompile/test_fork_transition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from execution_testing.forks.forks.forks import MONAD_EIGHT
1919
from execution_testing.forks.helpers import Fork
2020

21-
from .helpers import build_calldata, generous_gas
21+
from .helpers import CORRECT_SEL_ARGS_OFFSET, build_calldata, generous_gas
2222
from .spec import (
2323
GAS_GET_PROPOSER_VAL_ID,
2424
SELECTOR_GET_PROPOSER_VAL_ID,
@@ -55,7 +55,7 @@ def test_fork_transition(
5555
+ Op.CALL(
5656
gas=GAS_GET_PROPOSER_VAL_ID + 10000,
5757
address=STAKING_PRECOMPILE,
58-
args_offset=60,
58+
args_offset=CORRECT_SEL_ARGS_OFFSET,
5959
args_size=4,
6060
ret_offset=0,
6161
ret_size=32,

tests/monad_eight/staking_precompile/test_precompile_call.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
from .helpers import (
3636
CORRECT_SEL_ARGS_OFFSET,
37+
CORRECT_SEL_MSTORE_OFFSET,
3738
WRONG_SEL_ARGS_OFFSET,
3839
WRONG_SEL_MSTORE_OFFSET,
3940
build_calldata,
@@ -532,7 +533,7 @@ def test_selector(
532533
args_size = func.calldata_size
533534
gas = func.gas_cost + 10000
534535
else:
535-
calldata_setup = Op.MSTORE(32, selector)
536+
calldata_setup = Op.MSTORE(CORRECT_SEL_MSTORE_OFFSET, selector)
536537
args_size = 4
537538
gas = GAS_UNKNOWN_SELECTOR + 10000
538539

0 commit comments

Comments
 (0)