From ac16617a4acb0f4558f15b14cb6e86319b393871 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Mon, 4 Nov 2024 15:09:34 -0300 Subject: [PATCH 1/2] verkle: add extra SSTORE test Signed-off-by: Ignacio Hagopian --- .../test_storage_slot_write.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py b/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py index 5f38a93e50..09139a62e3 100644 --- a/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py +++ b/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py @@ -46,6 +46,17 @@ ], ) def test_storage_slot_write(blockchain_test: BlockchainTestFiller, fork: str, slot_num): + _storage_slot_write(blockchain_test, fork, slot_num) + + +@pytest.mark.valid_from("Verkle") +def test_storage_slot_write_absent_zero(blockchain_test: BlockchainTestFiller, fork: str): + _storage_slot_write(blockchain_test, fork, 0x88, slot_value=0x00) + + +def _storage_slot_write( + blockchain_test: BlockchainTestFiller, fork: str, slot_num, slot_value: int = 0x42 +): """ Test that storage slot writes work as expected. """ @@ -66,7 +77,7 @@ def test_storage_slot_write(blockchain_test: BlockchainTestFiller, fork: str, sl to=None, gas_limit=100000000, gas_price=10, - data=Op.SSTORE(slot_num, 0x42), + data=Op.SSTORE(slot_num, slot_value), ) blocks = [Block(txs=[tx])] @@ -75,7 +86,7 @@ def test_storage_slot_write(blockchain_test: BlockchainTestFiller, fork: str, sl post = { contract_address: Account( storage={ - slot_num: 0x42, + slot_num: slot_value, }, ), } From dfeacd55d3548613eff34d3799488a48fbefb90c Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 5 Nov 2024 07:38:08 -0300 Subject: [PATCH 2/2] verkle: adjuste SSTORE loop test Signed-off-by: Ignacio Hagopian --- .../test_storage_slot_write.py | 54 +++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py b/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py index 09139a62e3..7e30512396 100644 --- a/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py +++ b/tests/verkle/eip6800_genesis_verkle_tree/test_storage_slot_write.py @@ -46,19 +46,53 @@ ], ) def test_storage_slot_write(blockchain_test: BlockchainTestFiller, fork: str, slot_num): - _storage_slot_write(blockchain_test, fork, slot_num) + """ + Test that executes a SSTORE with a non-zero value. + """ + env = Environment( + fee_recipient="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + difficulty=0x20000, + gas_limit=10000000000, + number=1, + timestamp=1000, + ) + pre = { + TestAddress: Account(balance=1000000000000000000000), + } + slot_value = 0x42 + tx = Transaction( + ty=0x0, + chain_id=0x01, + nonce=0, + to=None, + gas_limit=100000000, + gas_price=10, + data=Op.SSTORE(slot_num, slot_value), + ) + blocks = [Block(txs=[tx])] + contract_address = compute_create_address(address=TestAddress, nonce=tx.nonce) -@pytest.mark.valid_from("Verkle") -def test_storage_slot_write_absent_zero(blockchain_test: BlockchainTestFiller, fork: str): - _storage_slot_write(blockchain_test, fork, 0x88, slot_value=0x00) + post = { + contract_address: Account( + storage={ + slot_num: slot_value, + }, + ), + } + + blockchain_test( + genesis_environment=env, + pre=pre, + post=post, + blocks=blocks, + ) -def _storage_slot_write( - blockchain_test: BlockchainTestFiller, fork: str, slot_num, slot_value: int = 0x42 -): +@pytest.mark.valid_from("Verkle") +def test_storage_slot_zero_nonzero_zero(blockchain_test: BlockchainTestFiller, fork: str): """ - Test that storage slot writes work as expected. + Test that executes in the same tx a SSTORE looping from abscent to zero. """ env = Environment( fee_recipient="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", @@ -77,7 +111,7 @@ def _storage_slot_write( to=None, gas_limit=100000000, gas_price=10, - data=Op.SSTORE(slot_num, slot_value), + data=Op.SSTORE(0x88, 0x42) + Op.SSTORE(0x88, 0x00), ) blocks = [Block(txs=[tx])] @@ -86,7 +120,7 @@ def _storage_slot_write( post = { contract_address: Account( storage={ - slot_num: slot_value, + 0x88: 0x00, }, ), }