Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AA-446: Separate 'nonce' into two 256-bit values 'nonceKey' and 'nonceSequence' #117

Merged
merged 9 commits into from
Oct 21, 2024
2 changes: 1 addition & 1 deletion @rip7560
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dep-build = {composite = ["spec-build", "rip7560-build"]}
update-deps = {composite = ["submodule-update", "dep-build"]}
update-deps-remote = {shell = "git submodule update --init --recursive --remote && cd @account-abstraction && yarn && yarn compile && cd ../spec && yarn && yarn build && cd ../@rip7560 && yarn && yarn compile-hardhat"}
test = "pytest --tb=short -rA -W ignore::DeprecationWarning --url http://localhost:3000/rpc --entry-point 0x0000000071727De22E5E9d8BAf0edAc6f37da032 --ethereum-node http://127.0.0.1:8545/ tests/single"
test-rip7560 = "pytest --tb=short -rA -W ignore::DeprecationWarning --url http://localhost:3000/rpc --nonce-manager 0x63f63e798f5F6A934Acf0a3FD1C01f3Fac851fF0 --stake-manager 0x570Aa568b6cf62ff08c6C3a3b3DB1a0438E871Fb --ethereum-node http://127.0.0.1:8545/ tests/rip7560"
test-rip7560 = "pytest --tb=short -rA -W ignore::DeprecationWarning --url http://localhost:3000/rpc --nonce-manager 0x632FaFb21910D6C8b4A3995063Dd984F2b829C02 --stake-manager 0x570Aa568b6cf62ff08c6C3a3b3DB1a0438E871Fb --ethereum-node http://127.0.0.1:8545/ tests/rip7560"
p2ptest = "pytest --tb=short -rA -W ignore::DeprecationWarning --url http://localhost:3000/rpc --entry-point 0x0000000071727De22E5E9d8BAf0edAc6f37da032 --ethereum-node http://127.0.0.1:8545/ tests/p2p"
lint = "pylint tests"
format = "black tests"
Expand Down
12 changes: 4 additions & 8 deletions tests/rip7560/test_rip7712.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from eth_abi.packed import encode_packed

from tests.types import RPCErrorCode
from tests.utils import send_bundle_now, assert_rpc_error, assert_ok
from tests.utils import send_bundle_now, assert_rpc_error, assert_ok, to_number


def get_nonce(w3, nonce_manager, address, key):
get_nonce_call_data = encode_packed(["address", "uint192"], [address, key])
get_nonce_call_data = encode_packed(["address", "uint256"], [address, key])
return w3.eth.call({"to": nonce_manager.address, "data": get_nonce_call_data})


def pack_nonce(key, value):
return encode_packed(["uint192", "uint64"], [key, value])


def test_eth_sendTransaction7560_7712_valid(
w3, wallet_contract, nonce_manager, tx_7560
):
Expand All @@ -22,7 +18,7 @@ def test_eth_sendTransaction7560_7712_valid(
nonce_before = get_nonce(w3, nonce_manager, wallet_contract.address, key)
legacy_nonce_before = w3.eth.get_transaction_count(tx_7560.sender)
assert state_before == 0
assert nonce_before == pack_nonce(key, 0)
assert to_number(nonce_before.hex()) == 0
assert legacy_nonce_before == 1

tx_7560.nonceKey = hex(key)
Expand All @@ -33,7 +29,7 @@ def test_eth_sendTransaction7560_7712_valid(
state_after = wallet_contract.functions.state().call()
nonce_after = get_nonce(w3, nonce_manager, wallet_contract.address, key)
legacy_nonce_after = w3.eth.get_transaction_count(tx_7560.sender)
assert nonce_after == pack_nonce(key, 1)
assert to_number(nonce_after.hex()) == 1
assert state_after == 2
assert legacy_nonce_after == 1

Expand Down