Skip to content

Commit 96b5e0d

Browse files
committed
fix balance accounting of payable functions
1 parent f844e0c commit 96b5e0d

File tree

3 files changed

+4
-29
lines changed

3 files changed

+4
-29
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from ethereum_types.numeric import U256, Uint
1717

18-
from ...state import get_account, set_account_balance
1918
from ...vm import Evm
2019
from ...vm.exceptions import InvalidParameter, RevertInMonadPrecompile
2120
from ...vm.gas import charge_gas
@@ -397,13 +396,3 @@ def staking(evm: Evm) -> None:
397396
raise RevertInMonadPrecompile
398397
else:
399398
raise InvalidParameter
400-
401-
# FIXME: is that so?
402-
# Payable calls consume value (staking system absorbs it)
403-
if is_payable and evm.message.value != U256(0):
404-
state = evm.message.block_env.state
405-
precompile = evm.message.current_target
406-
account = get_account(state, precompile)
407-
set_account_balance(
408-
state, precompile, account.balance - evm.message.value
409-
)

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
from ethereum_types.numeric import U256, Uint
1717

18-
from ...state import get_account, set_account_balance
1918
from ...vm import Evm
2019
from ...vm.exceptions import InvalidParameter, RevertInMonadPrecompile
2120
from ...vm.gas import charge_gas
@@ -397,13 +396,3 @@ def staking(evm: Evm) -> None:
397396
raise RevertInMonadPrecompile
398397
else:
399398
raise InvalidParameter
400-
401-
# FIXME: is that so?
402-
# Payable calls consume value (staking system absorbs it)
403-
if is_payable and evm.message.value != U256(0):
404-
state = evm.message.block_env.state
405-
precompile = evm.message.current_target
406-
account = get_account(state, precompile)
407-
set_account_balance(
408-
state, precompile, account.balance - evm.message.value
409-
)

tests/monad_eight/staking_precompile/test_precompile_call.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,14 +1035,11 @@ def test_tx_revert_scenarios(
10351035
)
10361036

10371037
if scenario.should_succeed(func):
1038-
post: dict = {sender: Account(balance=0)}
1039-
# FIXME: which is correct? does the precompile hide the balance?
10401038
# Value was transferred to precompile
1041-
# post = {
1042-
# sender: Account(balance=0),
1043-
# STAKING_PRECOMPILE:
1044-
# Account(balance=value) if value > 0 else None,
1045-
# }
1039+
post = {
1040+
sender: Account(balance=0),
1041+
STAKING_PRECOMPILE: Account(balance=value) if value > 0 else None,
1042+
}
10461043
else:
10471044
post = {sender: Account(balance=value)}
10481045

0 commit comments

Comments
 (0)