From 6c046433d050973c2b10c9d66c4229bd7abd63c4 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 10 Sep 2024 19:22:05 -0300 Subject: [PATCH 01/23] compilation fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_balance.py | 1 - .../eip4762_verkle_gas_witness/test_calls.py | 5 +++-- .../test_codecopy_ext_precompile.py | 3 ++- .../test_codecopy_generic.py | 3 ++- .../test_codecopy_generic_initcode.py | 3 ++- .../test_coinbase_fees.py | 3 ++- .../test_contract_execution.py | 3 ++- .../eip4762_verkle_gas_witness/test_creates.py | 17 +++++++++++------ .../test_extcodehash.py | 7 ++++--- .../test_extcodesize.py | 7 ++++--- .../test_selfdestruct.py | 3 ++- .../eip4762_verkle_gas_witness/test_sload.py | 5 +++-- .../eip4762_verkle_gas_witness/test_sstore.py | 9 +++++---- .../eip4762_verkle_gas_witness/test_transfer.py | 5 +++-- .../test_withdrawals.py | 3 ++- 15 files changed, 47 insertions(+), 30 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py index 42a5aa1bfa..88d17519ee 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py @@ -14,7 +14,6 @@ Block, BlockchainTestFiller, Environment, - Hash, TestAddress, TestAddress2, Transaction, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py index 739f24686c..a38ef4c6e7 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -174,7 +175,7 @@ def _generic_call( value=tx_value, ) - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, caller_address, env.fee_recipient]: witness_check.add_account_full( address=address, @@ -260,7 +261,7 @@ def test_call_non_existent_account( gas_price=10, ) - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, caller_address, env.fee_recipient]: witness_check.add_account_full( address=address, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py index 47e4c50e7f..2962447c9c 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -62,7 +63,7 @@ def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: str data=Initcode(deploy_code=Op.EXTCODECOPY(target, 0, 0, 100)), ) - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [env.fee_recipient, TestAddress]: witness_check.add_account_full( address=address, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py index df6162ba50..586fd6d038 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -230,7 +231,7 @@ def _generic_codecopy( code_chunks = chunkify_code(pre[TestAddress2].code) # TODO: fix tests - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, tx_target_addr, env.fee_recipient]: witness_check.add_account_full( address=address, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py index fc5bd95fb7..48890ad62a 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Block, @@ -66,7 +67,7 @@ def test_generic_codecopy_initcode(blockchain_test: BlockchainTestFiller, fork: data=data, ) - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, contract_address, env.fee_recipient]: witness_check.add_account_full( address=address, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py b/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py index 32fcfb87aa..706dd57f3e 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -57,7 +58,7 @@ def test_coinbase_fees(blockchain_test: BlockchainTestFiller, priority_fee): # TODO(verkle): change value when filling post = {} if priority_fee == 0 else {coinbase_addr: Account(balance=0x42)} - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) witness_check.add_account_full(address=TestAddress, account=pre[TestAddress]) # TODO: # witness_check.add_account_full(address=coinbase_addr, account=None) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py index 9ca5c43847..bff50d49a9 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -246,7 +247,7 @@ def test_contract_execution( code_chunks = chunkify_code(bytecode) assert len(code_chunks) > 0 - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, TestAddress2, env.fee_recipient]: witness_check.add_account_full( address=address, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py index f081896a45..115ca63c54 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Block, @@ -71,7 +72,7 @@ def test_create(blockchain_test: BlockchainTestFiller, create_instruction: Opcod num_code_chunks = (len(contract_code) + 30) // 31 - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) witness_check_extra.add_account_full(contract_address, None) for i in range(num_code_chunks): witness_check_extra.add_code_chunk(contract_address, i, None) @@ -105,7 +106,7 @@ def test_create_with_value_insufficient_balance( _create( blockchain_test, create_instruction, - WitnessCheck(), + WitnessCheck(fork=Verkle), contract_code, value=100, creator_balance=0, @@ -159,7 +160,7 @@ def test_create_insufficient_gas( code_chunks = chunkify_code(bytes(contract_code)) - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) if witness_basic_data and witness_codehash: witness_check_extra.add_account_full(contract_address, None) for i in range(witness_chunk_count): @@ -199,7 +200,9 @@ def test_create_static_cost( _create( blockchain_test, create_instruction, - WitnessCheck(), # Static cost fail means the created contract shouldn't be in the witness + WitnessCheck( + fork=Verkle + ), # Static cost fail means the created contract shouldn't be in the witness Op.PUSH0 * (129 * 31 + 42), value=0, gas_limit=gas_limit, @@ -226,7 +229,9 @@ def test_create_collision( _create( blockchain_test, create_instruction, - WitnessCheck(), # Collision means the created contract shouldn't be in the witness + WitnessCheck( + fork=Verkle + ), # Collision means the created contract shouldn't be in the witness Op.PUSH0 * (129 * 31 + 42), value=0, generate_collision=True, @@ -261,7 +266,7 @@ def test_big_calldata( TestAddress2, 0xDEADBEEF, Initcode(initcode_prefix=Op.STOP, deploy_code=contract_code) ) - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) witness_check_extra.add_account_full(contract_address, None) # No code chunks since we do an immediate STOP in the Initcode. diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py index c7b990da8b..661fd7481d 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py @@ -8,6 +8,7 @@ import pytest from ethereum.crypto.hash import keccak256 +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -60,7 +61,7 @@ def test_extcodehash(blockchain_test: BlockchainTestFiller, fork: str, target): """ Test EXTCODEHASH witness. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) if target == ExampleAddress: witness_check_extra.add_account_codehash( ExampleAddress, HashVerkle(keccak256(ExampleAccount.code)) @@ -81,7 +82,7 @@ def test_extcodehash_warm(blockchain_test: BlockchainTestFiller): """ Test EXTCODEHASH with WARM cost. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) witness_check_extra.add_account_codehash( ExampleAddress, HashVerkle(keccak256(ExampleAccount.code)) ) @@ -112,7 +113,7 @@ def test_extcodehash_insufficient_gas( """ Test EXTCODEHASH with insufficient gas. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) if witness_assert_basic_data: witness_check_extra.add_account_basic_data(ExampleAddress, ExampleAccount) if witness_assert_codehash: diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py index 4a9da3ac9a..7fa4b4fc81 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -52,7 +53,7 @@ def test_extcodesize(blockchain_test: BlockchainTestFiller, target, bytecode): """ Test EXTCODESIZE witness. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) if target == EmptyAddress: witness_check_extra.add_account_basic_data(target, None) elif target != precompile_address and target != system_contract_address: @@ -72,7 +73,7 @@ def test_extcodesize_insufficient_gas(blockchain_test: BlockchainTestFiller): blockchain_test, TestAddress2, Op.PUSH0 * 1000, - WitnessCheck(), + WitnessCheck(fork=Verkle), gas_limit=53_540, fails=True, ) @@ -86,7 +87,7 @@ def test_extcodesize_warm(blockchain_test: BlockchainTestFiller): """ bytecode = Op.ADD(1, 2) * 10 account = Account(code=bytecode) - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) witness_check_extra.add_account_basic_data(TestAddress2, account) _extcodesize(blockchain_test, TestAddress2, bytecode, witness_check_extra, warm=True) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py index 6635b533af..3918c404db 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -144,7 +145,7 @@ def _selfdestruct( gas_price=10, ) - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, TestAddress2, env.fee_recipient]: witness_check.add_account_full( address=address, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_sload.py b/tests/verkle/eip4762_verkle_gas_witness/test_sload.py index 46727eaa4b..e9fd92380e 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_sload.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_sload.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Block, @@ -53,7 +54,7 @@ def test_sload(blockchain_test: BlockchainTestFiller, storage_slot_accesses): """ Test SLOAD witness. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) for slot in storage_slot_accesses: witness_check_extra.add_storage_slot(TestAddress2, slot, TestAddress2Storage.get(slot)) @@ -67,7 +68,7 @@ def test_sload_insufficient_gas(blockchain_test: BlockchainTestFiller, fork: str """ Test SLOAD with insufficient gas. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) for slot in [1000, 1001]: witness_check_extra.add_storage_slot(TestAddress2, slot, TestAddress2Storage.get(slot)) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py b/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py index c69ef5956e..25da59ef14 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Block, @@ -57,7 +58,7 @@ def test_sstore(blockchain_test: BlockchainTestFiller, storage_slot_writes): """ Test SSTORE witness. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) for sstore in storage_slot_writes: witness_check_extra.add_storage_slot( TestAddress2, sstore[0], TestAddress2Storage.get(sstore[0]) @@ -86,13 +87,13 @@ def test_sstore_insufficient_gas( """ Test SSTORE with insufficient gas. """ - witness_check_extra = WitnessCheck() + witness_check_extra = WitnessCheck(fork=Verkle) if must_be_in_witness: witness_check_extra.add_storage_slot(TestAddress2, 5000, None) _sstore( blockchain_test, - [(5000, 0xFF)], + [(5000, Hash(0xFF))], witness_check_extra, gas_limit=gas_limit, post_state_mutated_slot_count=0, @@ -101,7 +102,7 @@ def test_sstore_insufficient_gas( def _sstore( blockchain_test: BlockchainTestFiller, - storage_slot_writes: list[tuple[int, int]], + storage_slot_writes: list[tuple[int, Hash]], witness_check_extra: WitnessCheck, gas_limit=1_000_000, post_state_mutated_slot_count=None, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py index c608f187ee..5aecc28744 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Address, @@ -43,7 +44,7 @@ "value", [0, 1], ) -def test_transfer(blockchain_test: BlockchainTestFiller, target, value): +def test_transfer_foo(blockchain_test: BlockchainTestFiller, target, value): """ Test that value transfer generates a correct witness. """ @@ -76,7 +77,7 @@ def test_transfer(blockchain_test: BlockchainTestFiller, target, value): target: post_account, } - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) witness_check.add_account_full(env.fee_recipient, None) witness_check.add_account_full(TestAddress, pre[TestAddress]) if target != precompile_address and target != system_contract_address: diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py b/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py index 0c324d34b7..c5c2ff11c9 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py @@ -7,6 +7,7 @@ import pytest +from ethereum_test_forks import Verkle from ethereum_test_tools import ( Account, Block, @@ -45,7 +46,7 @@ def test_withdrawals(blockchain_test: BlockchainTestFiller, fork: str): TestAddress2: Account(balance=4000000000), } - witness_check = WitnessCheck() + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, TestAddress2]: witness_check.add_account_full( address=address, From 820f66deba427857b181aa2c5e509570eb598273 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 10 Sep 2024 19:24:26 -0300 Subject: [PATCH 02/23] more fixes Signed-off-by: Ignacio Hagopian --- .../test_codecopy_generic.py | 1 - .../eip4762_verkle_gas_witness/test_selfdestruct.py | 12 +++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py index 586fd6d038..48c731aed4 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py @@ -15,7 +15,6 @@ BlockchainTestFiller, Bytecode, Environment, - Initcode, TestAddress, TestAddress2, Transaction, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py index 3918c404db..5bbea60e67 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py @@ -161,15 +161,17 @@ def _selfdestruct( ) ] - post: Alloc = {} + post: Alloc = Alloc({}) if not fail and contract_balance > 0 and beneficiary != TestAddress2: beneficiary_account = pre.get(beneficiary) beneficiary_balance = 0 if beneficiary_account is None else beneficiary_account.balance pre[TestAddress2] - post = { - TestAddress2: Account(code=pre[TestAddress2].code, balance=0), - beneficiary: Account(balance=beneficiary_balance + contract_balance), - } + post = Alloc( + { + TestAddress2: Account(code=pre[TestAddress2].code, balance=0), + beneficiary: Account(balance=beneficiary_balance + contract_balance), + } + ) blockchain_test( genesis_environment=env, From bc144d814cf86fdf9b5f74fbf213140c68eaa415 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 10 Sep 2024 20:15:35 -0300 Subject: [PATCH 03/23] verkle: fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_calls.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py index a38ef4c6e7..447e9a2914 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py @@ -22,6 +22,7 @@ WitnessCheck, ) from ethereum_test_tools.vm.opcode import Opcodes as Op +from ethereum_test_types.verkle.helpers import chunkify_code # TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" @@ -49,12 +50,12 @@ @pytest.mark.parametrize( "target", [ - TestAddress2, + # TestAddress2, precompile_address, - system_contract_address, + # system_contract_address, ], ) -def test_calls( +def test_calls_foo( blockchain_test: BlockchainTestFiller, fork: str, call_instruction: Bytecode, @@ -181,11 +182,17 @@ def _generic_call( address=address, account=(None if address == env.fee_recipient else pre[address]), ) - if target != precompile_address and enough_gas_read_witness: - witness_check.add_account_basic_data( - address=target, - account=pre[target], - ) + if enough_gas_read_witness: + if value > 0 or (target != precompile_address and target != precompile_address): + witness_check.add_account_basic_data(address=target, account=pre[target]) + + code_chunks = chunkify_code(caller_code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=caller_address, chunk_number=i, value=chunk) + code_chunks = chunkify_code(pre[target].code) + if target != precompile_address and target != system_contract_address: + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=target, chunk_number=i, value=chunk) blocks = [ Block( From 9c56c4a012dbba6ac2eab81ebd5bfbfd4ec23cbe Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 10 Sep 2024 20:19:42 -0300 Subject: [PATCH 04/23] verkle: call warm fixes Signed-off-by: Ignacio Hagopian --- tests/verkle/eip4762_verkle_gas_witness/test_calls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py index 447e9a2914..2994084e9a 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py @@ -55,7 +55,7 @@ # system_contract_address, ], ) -def test_calls_foo( +def test_calls( blockchain_test: BlockchainTestFiller, fork: str, call_instruction: Bytecode, @@ -186,7 +186,7 @@ def _generic_call( if value > 0 or (target != precompile_address and target != precompile_address): witness_check.add_account_basic_data(address=target, account=pre[target]) - code_chunks = chunkify_code(caller_code) + code_chunks = chunkify_code(pre[caller_address].code) for i, chunk in enumerate(code_chunks, start=0): witness_check.add_code_chunk(address=caller_address, chunk_number=i, value=chunk) code_chunks = chunkify_code(pre[target].code) From fd637bea47253ea016778408df51531ce5c552b2 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 10:02:43 -0300 Subject: [PATCH 05/23] verkle: fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_calls.py | 5 +-- .../test_codecopy_ext_precompile.py | 35 +++++++++++++------ .../test_codecopy_generic_initcode.py | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py index 2994084e9a..e3a6ca9e90 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py @@ -178,10 +178,7 @@ def _generic_call( witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, caller_address, env.fee_recipient]: - witness_check.add_account_full( - address=address, - account=(None if address == env.fee_recipient else pre[address]), - ) + witness_check.add_account_full(address=address, account=pre.get(address)) if enough_gas_read_witness: if value > 0 or (target != precompile_address and target != precompile_address): witness_check.add_account_basic_data(address=target, account=pre[target]) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py index 2962447c9c..f0d376e098 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py @@ -14,19 +14,22 @@ Block, BlockchainTestFiller, Environment, - Initcode, TestAddress, + TestAddress2, Transaction, WitnessCheck, ) from ethereum_test_tools.vm.opcode import Opcodes as Op +from ethereum_test_types.verkle.helpers import chunkify_code +from ethereum_test_forks import Fork + # TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" precompile_address = Address("0x04") -system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") +system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") # TODO(verkle): update to Osaka when t8n supports the fork. @@ -34,11 +37,11 @@ @pytest.mark.parametrize( "target", [ - precompile_address, + # precompile_address, system_contract_address, ], ) -def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: str, target): +def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: Fork, target): """ Test EXTCODECOPY targeting a precompile or system contract. """ @@ -51,24 +54,34 @@ def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: str ) pre = { TestAddress: Account(balance=1000000000000000000000), + TestAddress2: Account( + balance=1000000000000000000000, code=Op.EXTCODECOPY(target, 0, 0, 100) + ), } tx = Transaction( ty=0x0, chain_id=0x01, nonce=0, - to=None, + to=TestAddress2, gas_limit=1_000_000, gas_price=10, - data=Initcode(deploy_code=Op.EXTCODECOPY(target, 0, 0, 100)), ) witness_check = WitnessCheck(fork=Verkle) - for address in [env.fee_recipient, TestAddress]: - witness_check.add_account_full( - address=address, - account=(None if address == env.fee_recipient else pre[address]), - ) + for address in [env.fee_recipient, TestAddress, TestAddress2]: + witness_check.add_account_full(address=address, account=pre.get(address)) + code_chunks = chunkify_code(pre[TestAddress2].code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk) + + if target == system_contract_address: + code = Account(**fork.pre_allocation_blockchain()[system_contract_address]).code + code_chunks = chunkify_code(code) + for i in range(5): + witness_check.add_code_chunk( + address=TestAddress2, chunk_number=i, value=code_chunks[i] + ) blocks = [ Block( diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py index 48890ad62a..8fa6ddec5f 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py @@ -32,7 +32,7 @@ "instruction", [ Op.CODECOPY, - Op.EXTCODECOPY, + # Op.EXTCODECOPY, ], ) def test_generic_codecopy_initcode(blockchain_test: BlockchainTestFiller, fork: str, instruction): From 129251d2e7ca56af810afcb7810a072f8e83195b Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 10:21:30 -0300 Subject: [PATCH 06/23] fixes Signed-off-by: Ignacio Hagopian --- src/ethereum_test_forks/forks/forks.py | 28 ++++++++++++++----- .../test_codecopy_ext_precompile.py | 6 ++-- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/ethereum_test_forks/forks/forks.py b/src/ethereum_test_forks/forks/forks.py index 88c9910f12..8232c376e2 100644 --- a/src/ethereum_test_forks/forks/forks.py +++ b/src/ethereum_test_forks/forks/forks.py @@ -404,7 +404,9 @@ def call_opcodes( """ At Homestead, DELEGATECALL opcode was introduced. """ - return [(Opcodes.DELEGATECALL, EVMCodeType.LEGACY),] + super( + return [ + (Opcodes.DELEGATECALL, EVMCodeType.LEGACY), + ] + super( Homestead, cls ).call_opcodes(block_number, timestamp) @@ -449,7 +451,9 @@ def call_opcodes( """ At Byzantium, STATICCALL opcode was introduced. """ - return [(Opcodes.STATICCALL, EVMCodeType.LEGACY),] + super( + return [ + (Opcodes.STATICCALL, EVMCodeType.LEGACY), + ] + super( Byzantium, cls ).call_opcodes(block_number, timestamp) @@ -483,7 +487,9 @@ def create_opcodes( """ At Constantinople, `CREATE2` opcode is added. """ - return [(Opcodes.CREATE2, EVMCodeType.LEGACY),] + super( + return [ + (Opcodes.CREATE2, EVMCodeType.LEGACY), + ] + super( Constantinople, cls ).create_opcodes(block_number, timestamp) @@ -974,7 +980,7 @@ def pre_allocation_blockchain(cls) -> Mapping: type tests. """ new_allocation = { - 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE: { + Address(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE): { "nonce": 1, "code": ( "0x60203611603157600143035f35116029575f35612000014311602957612000" @@ -1020,7 +1026,10 @@ def evm_code_types(cls, block_number: int = 0, timestamp: int = 0) -> List[EVMCo """ EOF V1 is supported starting from this fork. """ - return super(CancunEIP7692, cls,).evm_code_types( # noqa: SC200 + return super( + CancunEIP7692, + cls, + ).evm_code_types( # noqa: SC200 block_number, timestamp, ) + [EVMCodeType.EOF_V1] @@ -1049,7 +1058,9 @@ def create_opcodes( """ EOF V1 introduces `EOFCREATE`. """ - return [(Opcodes.EOFCREATE, EVMCodeType.EOF_V1),] + super( + return [ + (Opcodes.EOFCREATE, EVMCodeType.EOF_V1), + ] + super( CancunEIP7692, cls # noqa: SC200 ).create_opcodes(block_number, timestamp) @@ -1084,7 +1095,10 @@ def evm_code_types(cls, block_number: int = 0, timestamp: int = 0) -> List[EVMCo """ EOF V1 is supported starting from this fork. """ - return super(PragueEIP7692, cls,).evm_code_types( # noqa: SC200 + return super( + PragueEIP7692, + cls, + ).evm_code_types( # noqa: SC200 block_number, timestamp, ) + [EVMCodeType.EOF_V1] diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py index f0d376e098..34c4718477 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py @@ -55,7 +55,7 @@ def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: For pre = { TestAddress: Account(balance=1000000000000000000000), TestAddress2: Account( - balance=1000000000000000000000, code=Op.EXTCODECOPY(target, 0, 0, 100) + balance=1000000000000000000000, code=Op.EXTCODECOPY(target, 0, 0, 10) ), } @@ -78,9 +78,9 @@ def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: For if target == system_contract_address: code = Account(**fork.pre_allocation_blockchain()[system_contract_address]).code code_chunks = chunkify_code(code) - for i in range(5): + for i in range(1): witness_check.add_code_chunk( - address=TestAddress2, chunk_number=i, value=code_chunks[i] + address=system_contract_address, chunk_number=i, value=code_chunks[i] ) blocks = [ From ac10705d8e7a4d0c6cd4f5d2b4a79fd049abbddc Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 10:24:30 -0300 Subject: [PATCH 07/23] simplify Signed-off-by: Ignacio Hagopian --- .../test_codecopy_ext_precompile.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py index 34c4718477..85d581ac58 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py @@ -37,7 +37,7 @@ @pytest.mark.parametrize( "target", [ - # precompile_address, + precompile_address, system_contract_address, ], ) @@ -78,10 +78,9 @@ def test_extcodecopy_precompile(blockchain_test: BlockchainTestFiller, fork: For if target == system_contract_address: code = Account(**fork.pre_allocation_blockchain()[system_contract_address]).code code_chunks = chunkify_code(code) - for i in range(1): - witness_check.add_code_chunk( - address=system_contract_address, chunk_number=i, value=code_chunks[i] - ) + witness_check.add_code_chunk( + address=system_contract_address, chunk_number=0, value=code_chunks[0] + ) blocks = [ Block( From 94620c9b99700f0364923c752b9fcb3f2ee4aaa3 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 11:45:59 -0300 Subject: [PATCH 08/23] verkle: fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_balance.py | 2 +- .../test_codecopy_generic_initcode.py | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py index 88d17519ee..834d2cab79 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py @@ -27,7 +27,7 @@ REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" precompile_address = Address("0x04") -system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") +system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") example_address = Address("0xd94f5374fce5edbc8e2a8697c15331677e6ebf0c") diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py index 8fa6ddec5f..9ecb0eecc0 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py @@ -32,7 +32,7 @@ "instruction", [ Op.CODECOPY, - # Op.EXTCODECOPY, + Op.EXTCODECOPY, ], ) def test_generic_codecopy_initcode(blockchain_test: BlockchainTestFiller, fork: str, instruction): @@ -52,10 +52,9 @@ def test_generic_codecopy_initcode(blockchain_test: BlockchainTestFiller, fork: contract_address = compute_create_address(address=TestAddress, nonce=0) if instruction == Op.EXTCODECOPY: - deploy_code = Op.EXTCODECOPY(contract_address, 0, 0, 100) + Op.ORIGIN * 100 - data = Initcode(deploy_code=deploy_code) + data = Op.EXTCODECOPY(contract_address, 0, 0, 100) + Op.ORIGIN * 100 else: - data = Initcode(deploy_code=Op.CODECOPY(0, 0, 100) + Op.ORIGIN * 100) + data = Op.CODECOPY(0, 0, 100) + Op.ORIGIN * 100 tx = Transaction( ty=0x0, @@ -69,10 +68,7 @@ def test_generic_codecopy_initcode(blockchain_test: BlockchainTestFiller, fork: witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, contract_address, env.fee_recipient]: - witness_check.add_account_full( - address=address, - account=(None if address != TestAddress else pre[address]), - ) + witness_check.add_account_full(address=address, account=pre.get(address)) blocks = [ Block( From 5089d6a8f4cb9b045f8f30b1a35fe1379b350a09 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 14:43:36 -0300 Subject: [PATCH 09/23] verkle: codecopy/extcodecopy fixes Signed-off-by: Ignacio Hagopian --- .../test_codecopy_generic.py | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py index 48c731aed4..703fb3fe61 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py @@ -19,7 +19,6 @@ TestAddress2, Transaction, WitnessCheck, - compute_create_address, ) from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.helpers import chunkify_code @@ -65,7 +64,7 @@ "partial_out_of_bounds_touching_further_non_existent_code_chunk", ], ) -def test_generic_codecopy(blockchain_test: BlockchainTestFiller, instruction, offset, size): +def test_generic_codecopy_foo(blockchain_test: BlockchainTestFiller, instruction, offset, size): """ Test *CODECOPY witness. """ @@ -191,6 +190,7 @@ def _generic_codecopy( warm=False, gas_limit=1_000_000, ): + dummy_address = Address("0xffff19589531694250d570040a0c4b74576919b8") env = Environment( fee_recipient="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", difficulty=0x20000, @@ -202,15 +202,16 @@ def _generic_codecopy( codecopy_code = Op.CODECOPY(0, offset, size) * repeat pre = { TestAddress: Account(balance=1000000000000000000000), - TestAddress2: Account(code=codecopy_code + Op.PUSH0 * max(0, size - len(codecopy_code))), + TestAddress2: Account( + code=codecopy_code + Op.STOP + Op.PUSH0 * max(0, size - len(codecopy_code) - 1) + ), + dummy_address: Account(code=Op.EXTCODECOPY(TestAddress2, 0, offset, size) * repeat), } - to: Address | None = TestAddress2 + to = TestAddress2 data = Bytecode() if instr == Op.EXTCODECOPY: - to = None - extcodecopy_code = Op.EXTCODECOPY(TestAddress2, 0, offset, size) * repeat - data = extcodecopy_code + to = dummy_address tx = Transaction( ty=0x0, @@ -222,23 +223,21 @@ def _generic_codecopy( data=data, ) - tx_target_addr = ( - TestAddress2 - if instr == Op.CODECOPY - else compute_create_address(address=TestAddress, nonce=0) - ) - code_chunks = chunkify_code(pre[TestAddress2].code) - - # TODO: fix tests witness_check = WitnessCheck(fork=Verkle) - for address in [TestAddress, tx_target_addr, env.fee_recipient]: - witness_check.add_account_full( - address=address, - account=(pre[address] if address == TestAddress else None), - ) - if witness_target_basic_data: - witness_check.add_account_basic_data(TestAddress2, pre[TestAddress2]) + for address in [TestAddress, to, env.fee_recipient]: + witness_check.add_account_full(address=address, account=pre.get(address)) + code_chunks = chunkify_code(pre[to].code) + # We'll always have code-chunk 0 since it has the actual + # CODECOPY/EXTCODECOPY opcode execution. + witness_check.add_code_chunk(to, 0, code_chunks[0]) + + if instr == Op.EXTCODECOPY: + witness_check.add_account_basic_data(address=TestAddress2, account=pre.get(TestAddress2)) + + # Depending on the CODECOPY/EXTCODECOPY offset and size, we include the extra expected + # code-chunks. + code_chunks = chunkify_code(pre[TestAddress2].code) for chunk_num in witness_code_chunks: witness_check.add_code_chunk(TestAddress2, chunk_num, code_chunks[chunk_num]) From 3754d51e048f3196352ae4fa4bc7f73d4b19ae1e Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 14:47:39 -0300 Subject: [PATCH 10/23] verkle: remove noisy comments Signed-off-by: Ignacio Hagopian --- tests/verkle/eip4762_verkle_gas_witness/test_balance.py | 3 --- tests/verkle/eip4762_verkle_gas_witness/test_calls.py | 5 ----- .../test_codecopy_ext_precompile.py | 2 -- .../eip4762_verkle_gas_witness/test_codecopy_generic.py | 7 ------- .../test_codecopy_generic_initcode.py | 3 --- .../eip4762_verkle_gas_witness/test_coinbase_fees.py | 4 ---- .../eip4762_verkle_gas_witness/test_contract_execution.py | 2 -- tests/verkle/eip4762_verkle_gas_witness/test_creates.py | 6 ------ .../verkle/eip4762_verkle_gas_witness/test_extcodehash.py | 4 ---- .../verkle/eip4762_verkle_gas_witness/test_extcodesize.py | 4 ---- .../verkle/eip4762_verkle_gas_witness/test_selfdestruct.py | 3 --- tests/verkle/eip4762_verkle_gas_witness/test_sload.py | 3 --- tests/verkle/eip4762_verkle_gas_witness/test_sstore.py | 3 --- tests/verkle/eip4762_verkle_gas_witness/test_transfer.py | 2 -- .../verkle/eip4762_verkle_gas_witness/test_withdrawals.py | 2 -- .../test_contract_codechunking.py | 2 -- .../eip6800_genesis_verkle_tree/test_contract_creation.py | 2 -- .../eip6800_genesis_verkle_tree/test_storage_slot_write.py | 2 -- tests/verkle/eip6800_genesis_verkle_tree/test_transfer.py | 2 -- .../test_blockhash_instruction.py | 3 +-- 20 files changed, 1 insertion(+), 63 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py index 834d2cab79..5ab0441a34 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py @@ -22,7 +22,6 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.helpers import chunkify_code -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -31,7 +30,6 @@ example_address = Address("0xd94f5374fce5edbc8e2a8697c15331677e6ebf0c") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "target", @@ -49,7 +47,6 @@ def test_balance(blockchain_test: BlockchainTestFiller, fork: str, target, warm) _balance(blockchain_test, fork, target, [target], warm=warm) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize("target", [example_address, precompile_address]) def test_balance_insufficient_gas(blockchain_test: BlockchainTestFiller, fork: str, target): diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py index e3a6ca9e90..6ff8b8acf4 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py @@ -24,7 +24,6 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.helpers import chunkify_code -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -33,7 +32,6 @@ precompile_address = Address("0x04") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "call_instruction, value", @@ -68,7 +66,6 @@ def test_calls( _generic_call(blockchain_test, call_instruction, target, value) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "call_instruction", @@ -86,7 +83,6 @@ def test_calls_warm(blockchain_test: BlockchainTestFiller, fork: str, call_instr _generic_call(blockchain_test, call_instruction, TestAddress2, 0, warm=True) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("Pending TBD gas limits") @pytest.mark.parametrize( @@ -218,7 +214,6 @@ def _generic_call( ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "call_instruction, gas_limit, enough_gas_account_creation", diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py index 85d581ac58..ecb64d2335 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_ext_precompile.py @@ -24,7 +24,6 @@ from ethereum_test_forks import Fork -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -32,7 +31,6 @@ system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "target", diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py index 703fb3fe61..bb52516d8f 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py @@ -23,14 +23,12 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.helpers import chunkify_code -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" code_size = 200 * 31 + 60 -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "instruction", @@ -86,7 +84,6 @@ def test_generic_codecopy_foo(blockchain_test: BlockchainTestFiller, instruction ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "instruction", @@ -111,7 +108,6 @@ def test_generic_codecopy_warm(blockchain_test: BlockchainTestFiller, instructio ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("Pending to fill TBD gas limit") @pytest.mark.parametrize( @@ -125,7 +121,6 @@ def test_generic_codecopy_warm(blockchain_test: BlockchainTestFiller, instructio "partial_code_range", ], ) -# TODO(verkle): consider reusing code from test_generic_codecopy.py. def test_codecopy_insufficient_gas( blockchain_test: BlockchainTestFiller, gas_limit, witness_code_chunks ): @@ -143,7 +138,6 @@ def test_codecopy_insufficient_gas( ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("Pending to fill TBD gas limit") @pytest.mark.parametrize( @@ -159,7 +153,6 @@ def test_codecopy_insufficient_gas( "partial_code_range", ], ) -# TODO(verkle): consider reusing code from test_generic_codecopy.py. def test_extcodecopy_insufficient_gas( blockchain_test: BlockchainTestFiller, gas_limit, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py index 9ecb0eecc0..5aa1e886d4 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic_initcode.py @@ -13,7 +13,6 @@ Block, BlockchainTestFiller, Environment, - Initcode, TestAddress, Transaction, WitnessCheck, @@ -21,12 +20,10 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "instruction", diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py b/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py index 706dd57f3e..f9883f93a9 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py @@ -20,14 +20,10 @@ WitnessCheck, ) -# from ..temp_verkle_helpers import Witness - -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize("priority_fee", [0, 100]) def test_coinbase_fees(blockchain_test: BlockchainTestFiller, priority_fee): diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py index bff50d49a9..79f288d94a 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py @@ -22,7 +22,6 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.helpers import chunkify_code -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -72,7 +71,6 @@ def code_with_jumps(size, jumps: list[Jump | Jumpi] = []): return result_code -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "bytecode, gas_limit, witness_code_chunk_ranges", diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py index 115ca63c54..153ad23588 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py @@ -26,12 +26,10 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.helpers import chunkify_code -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "create_instruction", @@ -113,7 +111,6 @@ def test_create_with_value_insufficient_balance( ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("Pending TBD gas limits") @pytest.mark.parametrize( @@ -179,7 +176,6 @@ def test_create_insufficient_gas( ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("Pending TBD gas limits") @pytest.mark.parametrize( @@ -209,7 +205,6 @@ def test_create_static_cost( ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "create_instruction", @@ -238,7 +233,6 @@ def test_create_collision( ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "create_instruction", diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py index 661fd7481d..477b9edeff 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py @@ -24,7 +24,6 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.types import Hash as HashVerkle -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -38,7 +37,6 @@ ExampleAccount = Account(code=Op.PUSH0 * 300) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "target", @@ -76,7 +74,6 @@ def test_extcodehash(blockchain_test: BlockchainTestFiller, fork: str, target): _extcodehash(blockchain_test, target, witness_check_extra) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") def test_extcodehash_warm(blockchain_test: BlockchainTestFiller): """ @@ -90,7 +87,6 @@ def test_extcodehash_warm(blockchain_test: BlockchainTestFiller): _extcodehash(blockchain_test, ExampleAddress, witness_check_extra, warm=True) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("Pending TBD gas limits") @pytest.mark.parametrize( diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py index 7fa4b4fc81..87feb760d1 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py @@ -23,7 +23,6 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -32,7 +31,6 @@ EmptyAddress = Address("0xFFFFFFf6D732807Ef1319fB7B8bB8522d0BeacFF") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "target, bytecode", @@ -63,7 +61,6 @@ def test_extcodesize(blockchain_test: BlockchainTestFiller, target, bytecode): _extcodesize(blockchain_test, target, bytecode, witness_check_extra) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") def test_extcodesize_insufficient_gas(blockchain_test: BlockchainTestFiller): """ @@ -79,7 +76,6 @@ def test_extcodesize_insufficient_gas(blockchain_test: BlockchainTestFiller): ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") def test_extcodesize_warm(blockchain_test: BlockchainTestFiller): """ diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py index 5bbea60e67..eb9c468795 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py @@ -22,7 +22,6 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -31,7 +30,6 @@ system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "target, beneficiary_must_exist", @@ -72,7 +70,6 @@ def test_self_destruct( ) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("TBD gas limit") @pytest.mark.parametrize( diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_sload.py b/tests/verkle/eip4762_verkle_gas_witness/test_sload.py index e9fd92380e..d940a279d9 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_sload.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_sload.py @@ -22,14 +22,12 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.types import Hash -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" TestAddress2Storage: dict[int, Hash] = {0: Hash(0xAA), 1000: Hash(0xBB)} -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "storage_slot_accesses", @@ -61,7 +59,6 @@ def test_sload(blockchain_test: BlockchainTestFiller, storage_slot_accesses): _sload(blockchain_test, storage_slot_accesses, witness_check_extra) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.skip("Unskip when geth fixes Touch* witness inclusion with insufficient gas") @pytest.mark.valid_from("Verkle") def test_sload_insufficient_gas(blockchain_test: BlockchainTestFiller, fork: str): diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py b/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py index 25da59ef14..38ab0c4e10 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py @@ -22,14 +22,12 @@ from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.types import Hash -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" TestAddress2Storage: dict[int, Hash] = {0: Hash(0xAA), 1000: Hash(0xBB)} -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "storage_slot_writes", @@ -67,7 +65,6 @@ def test_sstore(blockchain_test: BlockchainTestFiller, storage_slot_writes): _sstore(blockchain_test, storage_slot_writes, witness_check_extra) -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.skip("TBD gas limit") @pytest.mark.parametrize( diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py index 5aecc28744..1c0d07a7d3 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py @@ -20,7 +20,6 @@ WitnessCheck, ) -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -29,7 +28,6 @@ system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "target", diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py b/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py index c5c2ff11c9..863570ece7 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_withdrawals.py @@ -19,12 +19,10 @@ WitnessCheck, ) -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") def test_withdrawals(blockchain_test: BlockchainTestFiller, fork: str): """ diff --git a/tests/verkle/eip6800_genesis_verkle_tree/test_contract_codechunking.py b/tests/verkle/eip6800_genesis_verkle_tree/test_contract_codechunking.py index c63d8dd2d7..1d083cf277 100644 --- a/tests/verkle/eip6800_genesis_verkle_tree/test_contract_codechunking.py +++ b/tests/verkle/eip6800_genesis_verkle_tree/test_contract_codechunking.py @@ -20,12 +20,10 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-6800.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "bytecode", diff --git a/tests/verkle/eip6800_genesis_verkle_tree/test_contract_creation.py b/tests/verkle/eip6800_genesis_verkle_tree/test_contract_creation.py index 210d49007a..28988bb220 100644 --- a/tests/verkle/eip6800_genesis_verkle_tree/test_contract_creation.py +++ b/tests/verkle/eip6800_genesis_verkle_tree/test_contract_creation.py @@ -20,12 +20,10 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-6800.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "bytecode", 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 9d8391a07e..5f38a93e50 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 @@ -19,14 +19,12 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-6800.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" precompile_address = Address("0x04") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "slot_num", diff --git a/tests/verkle/eip6800_genesis_verkle_tree/test_transfer.py b/tests/verkle/eip6800_genesis_verkle_tree/test_transfer.py index fb4136c0f3..fc7d00136c 100644 --- a/tests/verkle/eip6800_genesis_verkle_tree/test_transfer.py +++ b/tests/verkle/eip6800_genesis_verkle_tree/test_transfer.py @@ -18,14 +18,12 @@ Transaction, ) -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-6800.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" precompile_address = Address("0x04") -# TODO(verkle): update to Osaka when t8n supports the fork. @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize( "target", diff --git a/tests/verkle/eip7709_blockhash_witness/test_blockhash_instruction.py b/tests/verkle/eip7709_blockhash_witness/test_blockhash_instruction.py index 00e5158b4f..851c9f9ae0 100644 --- a/tests/verkle/eip7709_blockhash_witness/test_blockhash_instruction.py +++ b/tests/verkle/eip7709_blockhash_witness/test_blockhash_instruction.py @@ -20,11 +20,10 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op -# TODO(verkle): Update reference spec version REFERENCE_SPEC_GIT_PATH = "EIPS/eip-7709.md" REFERENCE_SPEC_VERSION = "TODO" -# TODO(verkle): to be confirmed +# TODO(verkle): fix blockhash_system_contract_address = Address("0xa4690f0ed0d089faa1e0ad94c8f1b4a2fd4b0734") HISTORY_STORAGE_ADDRESS = 8192 BLOCKHASH_OLD_WINDOW = 256 From 148845bdc2c9d6d0d31d6041cb46936bcc48be66 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 14:52:48 -0300 Subject: [PATCH 11/23] verkle: fix coinbase assertions Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_codecopy_generic.py | 2 +- .../verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py index bb52516d8f..d75c47e2df 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py @@ -62,7 +62,7 @@ "partial_out_of_bounds_touching_further_non_existent_code_chunk", ], ) -def test_generic_codecopy_foo(blockchain_test: BlockchainTestFiller, instruction, offset, size): +def test_generic_codecopy(blockchain_test: BlockchainTestFiller, instruction, offset, size): """ Test *CODECOPY witness. """ diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py b/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py index f9883f93a9..7065b52954 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_coinbase_fees.py @@ -56,9 +56,9 @@ def test_coinbase_fees(blockchain_test: BlockchainTestFiller, priority_fee): witness_check = WitnessCheck(fork=Verkle) witness_check.add_account_full(address=TestAddress, account=pre[TestAddress]) - # TODO: - # witness_check.add_account_full(address=coinbase_addr, account=None) - # witness_check.add_account_basic_data(address=TestAddress2, account=None) + witness_check.add_account_full(address=TestAddress2, account=None) + if priority_fee > 0: + witness_check.add_account_full(address=coinbase_addr, account=None) blocks = [ Block( From eab6961e4988ecb1bfa9773539797481a9ec82ee Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 15:18:38 -0300 Subject: [PATCH 12/23] verkle: fixes Signed-off-by: Ignacio Hagopian --- .../test_contract_execution.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py index 79f288d94a..0c062ca94d 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py @@ -91,7 +91,7 @@ def code_with_jumps(size, jumps: list[Jump | Jumpi] = []): [[0, 128]], ), ( # touches_only_last_byte_code_chunk - code_with_jumps(128 * 31 + 100, [Jump(10, 128 * 31 + 9)]), + code_with_jumps(128 * 31 + 100, [Jump(10, 128 * 31 + 99)]), 1_000_000, [[0, 0], [131, 131]], ), @@ -154,16 +154,16 @@ def code_with_jumps(size, jumps: list[Jump | Jumpi] = []): 21000 + 200 + 10 + 3 + 3, [[0, 0]], ), - ( # sufficient_gas_for_jump_instruction_but_not_for_code_chunk - code_with_jumps(150 * 31, [Jump(10, 1000)]), - 21000 + 200 + 10 + 3 + 8, - [[0, 0]], - ), - ( # sufficient_gas_for_jumpi_instruction_but_not_for_code_chunk - code_with_jumps(150 * 31, [Jumpi(10, 1000, True)]), - 21000 + 200 + 10 + 3 + 3 + 10, - [[0, 0]], - ), + # ( # sufficient_gas_for_jump_instruction_but_not_for_code_chunk + # code_with_jumps(150 * 31, [Jump(10, 1000)]), + # 21000 + 200 + 10 + 3 + 8, + # [[0, 0]], + # ), + # ( # sufficient_gas_for_jumpi_instruction_but_not_for_code_chunk + # code_with_jumps(150 * 31, [Jumpi(10, 1000, True)]), + # 21000 + 200 + 10 + 3 + 3 + 10, + # [[0, 0]], + # ), ( # jump_outside_code_size code_with_jumps(150 * 31, [Jump(10, 150 * 31 + 42)]), 1_000_000, @@ -172,7 +172,7 @@ def code_with_jumps(size, jumps: list[Jump | Jumpi] = []): ( # jumpi_outside_code_size code_with_jumps(150 * 31, [Jumpi(50, 150 * 31 + 42, True)]), 1_000_000, - [[0, 0]], + [[0, 1]], ), ( # push20 with data split in two chunks Op.PUSH0 * (31 - (1 + 10)) + Op.PUSH20(0xAA), @@ -204,8 +204,8 @@ def code_with_jumps(size, jumps: list[Jump | Jumpi] = []): "false_jumpi", "insufficient_gas_for_jump_instruction", "insufficient_gas_for_jumpi_instruction", - "sufficient_gas_for_jump_instruction_but_not_for_code_chunk", - "sufficient_gas_for_jumpi_instruction_but_not_for_code_chunk", + # "sufficient_gas_for_jump_instruction_but_not_for_code_chunk", # TODO(verkle): re-enable when fixing in geth + # "sufficient_gas_for_jumpi_instruction_but_not_for_code_chunk",# TODO(verkle): re-enable when fixing in geth "jump_outside_code_size", "jumpi_outside_code_size", "push20_with_data_split_in_two_chunks", @@ -213,7 +213,7 @@ def code_with_jumps(size, jumps: list[Jump | Jumpi] = []): "pushn_with_expected_data_past_code_size", ], ) -def test_contract_execution( +def test_contract_execution_foo( blockchain_test: BlockchainTestFiller, bytecode: bytes, gas_limit: int, From 656a4c654fd9d68824b93ff3e212b08998cd32be Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 16:02:04 -0300 Subject: [PATCH 13/23] verkle: fix creates tests Signed-off-by: Ignacio Hagopian --- .../test_contract_execution.py | 2 +- .../test_creates.py | 19 ++++++++++++++----- .../test_transfer.py | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py index 0c062ca94d..d5316b3f02 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_contract_execution.py @@ -213,7 +213,7 @@ def code_with_jumps(size, jumps: list[Jump | Jumpi] = []): "pushn_with_expected_data_past_code_size", ], ) -def test_contract_execution_foo( +def test_contract_execution( blockchain_test: BlockchainTestFiller, bytecode: bytes, gas_limit: int, diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py index 153ad23588..8a315c742a 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py @@ -54,7 +54,7 @@ "with_partial_code_chunk", ], ) -def test_create(blockchain_test: BlockchainTestFiller, create_instruction: Opcode, code_size): +def test_create_foo(blockchain_test: BlockchainTestFiller, create_instruction: Opcode, code_size): """ Test tx contract creation and *CREATE witness. """ @@ -106,7 +106,7 @@ def test_create_with_value_insufficient_balance( create_instruction, WitnessCheck(fork=Verkle), contract_code, - value=100, + value=100, # TODO(verkle): add test (or generalize this one) with value>0 and enough balance? creator_balance=0, ) @@ -307,8 +307,8 @@ def _create( tx_target = TestAddress2 tx_value = 0 tx_data = deploy_code + contract_address = compute_create_address(address=TestAddress2, nonce=0) if generate_collision: - contract_address = compute_create_address(address=TestAddress2, nonce=0) pre[contract_address] = Account(nonce=1) elif create_instruction is not None and create_instruction.int() == Op.CREATE2.int(): pre[TestAddress2] = Account( @@ -319,15 +319,15 @@ def _create( tx_target = TestAddress2 tx_value = 0 tx_data = deploy_code + contract_address = compute_create2_address(TestAddress2, 0xDEADBEEF, deploy_code) if generate_collision: - contract_address = compute_create2_address(TestAddress2, 0xDEADBEEF, deploy_code) pre[contract_address] = Account(nonce=1) else: tx_target = None tx_value = value tx_data = deploy_code + contract_address = compute_create_address(address=TestAddress, nonce=0) if generate_collision: - contract_address = compute_create_address(address=TestAddress, nonce=0) pre[contract_address] = Account(nonce=1) tx = Transaction( @@ -346,6 +346,15 @@ def _create( witness_check.add_account_full(TestAddress, pre[TestAddress]) if tx_target is not None: witness_check.add_account_full(tx_target, pre[tx_target]) + code_chunks = chunkify_code(pre[tx_target].code) + # Code that executes the CREATE* + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=tx_target, chunk_number=i, value=chunk) + + # Assert the code-chunks where the contract is deployed are provided. + code_chunks = chunkify_code(bytes(deploy_code.deploy_code)) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=contract_address, chunk_number=i, value=None) blocks = [ Block( diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py index 1c0d07a7d3..5b24b39c5e 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py @@ -42,7 +42,7 @@ "value", [0, 1], ) -def test_transfer_foo(blockchain_test: BlockchainTestFiller, target, value): +def test_transfer(blockchain_test: BlockchainTestFiller, target, value): """ Test that value transfer generates a correct witness. """ From 38accf28f25a76b324d4e68973d284e038aa4823 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 16:13:03 -0300 Subject: [PATCH 14/23] verkle: fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_calls.py | 2 +- .../test_creates.py | 2 +- .../test_extcodehash.py | 36 ++++++++++--------- .../test_extcodesize.py | 2 +- .../test_selfdestruct.py | 2 +- .../test_transfer.py | 2 +- 6 files changed, 25 insertions(+), 21 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py index 6ff8b8acf4..dd53134297 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py @@ -28,7 +28,7 @@ REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" caller_address = Address("0xd94f5374fce5edbc8e2a8697c15331677e6ebf0c") -system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") +system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") precompile_address = Address("0x04") diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py index 8a315c742a..a7e9bd08d2 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py @@ -54,7 +54,7 @@ "with_partial_code_chunk", ], ) -def test_create_foo(blockchain_test: BlockchainTestFiller, create_instruction: Opcode, code_size): +def test_create(blockchain_test: BlockchainTestFiller, create_instruction: Opcode, code_size): """ Test tx contract creation and *CREATE witness. """ diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py index 477b9edeff..6e9db730c0 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py @@ -23,12 +23,13 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.types import Hash as HashVerkle +from ethereum_test_types.verkle.helpers import chunkify_code REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" precompile_address = Address("0x04") -system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") +system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") EmptyAddress = Address("0xd94f5374fce5edbc8e2a8697c15331677e6ebf0c") TestAccount = Account(balance=1000000000000000000000) @@ -42,20 +43,20 @@ "target", [ TestAddress, - ExampleAddress, - EmptyAddress, - system_contract_address, - precompile_address, + # ExampleAddress, + # EmptyAddress, + # system_contract_address, + # precompile_address, ], ids=[ "eoa", - "contract", - "non_existent_account", - "system_contract", - "precompile", + # "contract", + # "non_existent_account", + # "system_contract", + # "precompile", ], ) -def test_extcodehash(blockchain_test: BlockchainTestFiller, fork: str, target): +def test_extcodehash_foo(blockchain_test: BlockchainTestFiller, fork: str, target): """ Test EXTCODEHASH witness. """ @@ -123,7 +124,7 @@ def test_extcodehash_insufficient_gas( def _extcodehash( blockchain_test: BlockchainTestFiller, target, - witness_check_extra, + witness_check_extra: WitnessCheck, gas_limit=1_000_000, warm=False, fails=False, @@ -154,15 +155,18 @@ def _extcodehash( post = {} if not fails: - # TODO(verkle): assign correct storage slot value when filling post[TestAddress2] = Account(code=pre[TestAddress2].code, storage={0: 0x424242}) witness_check = witness_check_extra for address in [TestAddress, TestAddress2, env.fee_recipient]: - witness_check.add_account_full( - address=address, - account=(None if address == env.fee_recipient else pre[address]), - ) + witness_check.add_account_full(address=address, account=pre.get(address)) + + code_chunks = chunkify_code(pre[TestAddress2].code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk) + + if not fails: + witness_check.add_storage_slot(address=TestAddress2, storage_slot=0, value=None) blocks = [ Block( diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py index 87feb760d1..299a56149a 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py @@ -27,7 +27,7 @@ REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" precompile_address = Address("0x04") -system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") +system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") EmptyAddress = Address("0xFFFFFFf6D732807Ef1319fB7B8bB8522d0BeacFF") diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py index eb9c468795..3cb4c4d6a6 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py @@ -27,7 +27,7 @@ ExampleAddress = Address("0xd94f5374fce5edbc8e2a8697c15331677e6ebf0c") precompile_address = Address("0x04") -system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") +system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") @pytest.mark.valid_from("Verkle") diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py index 5b24b39c5e..42c718e71f 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py @@ -25,7 +25,7 @@ EmptyAddress = Address("0xffff5374fce5edbc8e2a8697c15331677e6ebfff") precompile_address = Address("0x04") -system_contract_address = Address("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02") +system_contract_address = Address("0xfffffffffffffffffffffffffffffffffffffffe") @pytest.mark.valid_from("Verkle") From 17400d8b7316c8f30b9b6cd7d6ada9fe8a03b065 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 16:40:32 -0300 Subject: [PATCH 15/23] verkle: extcodesize fixes Signed-off-by: Ignacio Hagopian --- .../test_extcodehash.py | 18 +++++++++--------- .../test_extcodesize.py | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py index 6e9db730c0..e3172e1b58 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodehash.py @@ -43,20 +43,20 @@ "target", [ TestAddress, - # ExampleAddress, - # EmptyAddress, - # system_contract_address, - # precompile_address, + ExampleAddress, + EmptyAddress, + system_contract_address, + precompile_address, ], ids=[ "eoa", - # "contract", - # "non_existent_account", - # "system_contract", - # "precompile", + "contract", + "non_existent_account", + "system_contract", + "precompile", ], ) -def test_extcodehash_foo(blockchain_test: BlockchainTestFiller, fork: str, target): +def test_extcodehash(blockchain_test: BlockchainTestFiller, fork: str, target): """ Test EXTCODEHASH witness. """ diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py index 299a56149a..f8ce8423a6 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_extcodesize.py @@ -19,9 +19,9 @@ TestAddress2, Transaction, WitnessCheck, - compute_create_address, ) from ethereum_test_tools.vm.opcode import Opcodes as Op +from ethereum_test_types.verkle.helpers import chunkify_code REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -107,6 +107,9 @@ def _extcodesize( ) pre = { TestAddress: Account(balance=1000000000000000000000), + TestAddress2: Account( + code=Op.EXTCODESIZE(target) * (2 if warm else 1) + Op.PUSH0 + Op.SSTORE + ), } if len(bytecode) > 0: pre[TestAddress2] = Account(code=bytecode) @@ -115,20 +118,26 @@ def _extcodesize( ty=0x0, chain_id=0x01, nonce=0, - to=Address("0x00"), + to=TestAddress2, gas_limit=gas_limit, gas_price=10, - data=Op.EXTCODESIZE(target) * (2 if warm else 1) + Op.PUSH0 + Op.SSTORE, ) post = {} if not fails: - contract_address = compute_create_address(address=TestAddress, nonce=tx.nonce) - post[contract_address] = Account(storage={0: len(bytecode)}) + post[TestAddress2] = Account(code=pre[TestAddress2].code, storage={0: 0x424242}) witness_check = witness_check_extra witness_check.add_account_full(env.fee_recipient, None) witness_check.add_account_full(TestAddress, pre[TestAddress]) + witness_check.add_account_full(TestAddress2, pre[TestAddress2]) + + code_chunks = chunkify_code(pre[TestAddress2].code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk) + + if not fails: + witness_check.add_storage_slot(address=TestAddress2, storage_slot=0, value=None) blocks = [ Block( From d58e1ebc342888ac5c3d8995cff4ef27137c909e Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 17:19:20 -0300 Subject: [PATCH 16/23] verkle: selfdestruct fixes Signed-off-by: Ignacio Hagopian --- .../test_selfdestruct.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py index 3cb4c4d6a6..ab579192eb 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py @@ -21,6 +21,7 @@ WitnessCheck, ) from ethereum_test_tools.vm.opcode import Opcodes as Op +from ethereum_test_types.verkle.helpers import chunkify_code REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -50,7 +51,10 @@ ) @pytest.mark.parametrize( "contract_balance", - [0, 1], + [ + 0, + 1, + ], ) def test_self_destruct( blockchain_test: BlockchainTestFiller, @@ -66,7 +70,6 @@ def test_self_destruct( target, beneficiary_must_exist, contract_balance, - contract_balance > 0, ) @@ -102,7 +105,6 @@ def test_self_destruct_insufficient_gas( ExampleAddress, beneficiary_must_exist, 100, - beneficiary_add_basic_data, gas_limit=gas_limit, fail=True, ) @@ -113,7 +115,6 @@ def _selfdestruct( beneficiary: Address, beneficiary_must_exist: bool, contract_balance: int, - beneficiary_add_basic_data: bool, gas_limit=1_000_000, fail=False, ): @@ -144,12 +145,12 @@ def _selfdestruct( witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, TestAddress2, env.fee_recipient]: - witness_check.add_account_full( - address=address, - account=(None if address == env.fee_recipient else pre[address]), - ) - if beneficiary_add_basic_data: + witness_check.add_account_full(address=address, account=pre.get(address)) + if contract_balance > 0 or (beneficiary != precompile_address): witness_check.add_account_basic_data(beneficiary, pre.get(beneficiary)) + code_chunks = chunkify_code(pre[TestAddress2].code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk) blocks = [ Block( From cfc623e853d2ae8aa44be72f65eb5d4f19a23194 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 17:21:45 -0300 Subject: [PATCH 17/23] verkle: fix sload Signed-off-by: Ignacio Hagopian --- tests/verkle/eip4762_verkle_gas_witness/test_sload.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_sload.py b/tests/verkle/eip4762_verkle_gas_witness/test_sload.py index d940a279d9..7ee01ea9bc 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_sload.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_sload.py @@ -21,6 +21,7 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.types import Hash +from ethereum_test_types.verkle.helpers import chunkify_code REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -112,6 +113,9 @@ def _sload( address=address, account=pre.get(address), ) + code_chunks = chunkify_code(pre[TestAddress2].code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk) blocks = [ Block( From 617a9afeeb4b5fd34fa1de8e300021cffa63ee08 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 17:35:08 -0300 Subject: [PATCH 18/23] verkle: sstore fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_sstore.py | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py b/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py index 38ab0c4e10..69a65e146c 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_sstore.py @@ -21,6 +21,7 @@ ) from ethereum_test_tools.vm.opcode import Opcodes as Op from ethereum_test_types.verkle.types import Hash +from ethereum_test_types.verkle.helpers import chunkify_code REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -42,8 +43,8 @@ [(1000, 0xFF), (1000, 0xFE)], ], ids=[ - "subreeedit_chunkedit_in_account_header", - "subreeedit_chunkedit_outside_account_header", + "chunkedit_in_account_header", + "chunkedit_outside_account_header", "two_in_same_branch_with_fill_cost", "two_different_subtreeedit_cost_and_no_fill_cost", "fill_and_subtree_edit_cost", @@ -56,13 +57,7 @@ def test_sstore(blockchain_test: BlockchainTestFiller, storage_slot_writes): """ Test SSTORE witness. """ - witness_check_extra = WitnessCheck(fork=Verkle) - for sstore in storage_slot_writes: - witness_check_extra.add_storage_slot( - TestAddress2, sstore[0], TestAddress2Storage.get(sstore[0]) - ) - - _sstore(blockchain_test, storage_slot_writes, witness_check_extra) + _sstore(blockchain_test, storage_slot_writes) @pytest.mark.valid_from("Verkle") @@ -84,14 +79,9 @@ def test_sstore_insufficient_gas( """ Test SSTORE with insufficient gas. """ - witness_check_extra = WitnessCheck(fork=Verkle) - if must_be_in_witness: - witness_check_extra.add_storage_slot(TestAddress2, 5000, None) - _sstore( blockchain_test, [(5000, Hash(0xFF))], - witness_check_extra, gas_limit=gas_limit, post_state_mutated_slot_count=0, ) @@ -100,7 +90,6 @@ def test_sstore_insufficient_gas( def _sstore( blockchain_test: BlockchainTestFiller, storage_slot_writes: list[tuple[int, Hash]], - witness_check_extra: WitnessCheck, gas_limit=1_000_000, post_state_mutated_slot_count=None, ): @@ -148,12 +137,21 @@ def _sstore( ), } - witness_check = witness_check_extra + witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, TestAddress2, env.fee_recipient]: witness_check.add_account_full( address=address, account=pre.get(address), ) + code_chunks = chunkify_code(pre[TestAddress2].code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk) + for i in range(successful_writes): + witness_check.add_storage_slot( + TestAddress2, + storage_slot_writes[i][0], + TestAddress2Storage.get(storage_slot_writes[i][0]), + ) blocks = [ Block( From d444e434f0fcad28648109d24f3efd34577455f0 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 11 Sep 2024 17:43:37 -0300 Subject: [PATCH 19/23] verkle: fix transfer Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_creates.py | 2 +- .../eip4762_verkle_gas_witness/test_transfer.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py index a7e9bd08d2..bbdeae4f52 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py @@ -106,7 +106,7 @@ def test_create_with_value_insufficient_balance( create_instruction, WitnessCheck(fork=Verkle), contract_code, - value=100, # TODO(verkle): add test (or generalize this one) with value>0 and enough balance? + value=100, # TODO(verkle): generalize with value>0 and enough balance? creator_balance=0, ) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py index 42c718e71f..e51cae4c71 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_transfer.py @@ -19,6 +19,8 @@ Transaction, WitnessCheck, ) +from ethereum_test_forks import Fork +from ethereum_test_types.verkle.helpers import chunkify_code REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" @@ -42,7 +44,7 @@ "value", [0, 1], ) -def test_transfer(blockchain_test: BlockchainTestFiller, target, value): +def test_transfer(blockchain_test: BlockchainTestFiller, fork: Fork, target, value): """ Test that value transfer generates a correct witness. """ @@ -78,8 +80,15 @@ def test_transfer(blockchain_test: BlockchainTestFiller, target, value): witness_check = WitnessCheck(fork=Verkle) witness_check.add_account_full(env.fee_recipient, None) witness_check.add_account_full(TestAddress, pre[TestAddress]) - if target != precompile_address and target != system_contract_address: - witness_check.add_account_full(target, pre.get(target)) + witness_check.add_account_full(target, pre.get(target)) + + if target == system_contract_address: + code = Account(**fork.pre_allocation_blockchain()[system_contract_address]).code + code_chunks = chunkify_code(code) + for i, code_chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk( + address=system_contract_address, chunk_number=i, value=code_chunk + ) blocks = [ Block( From 0730d9f03035106105abe28fa4e41112b14dcdc2 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 12 Sep 2024 08:59:57 -0300 Subject: [PATCH 20/23] verkle: more calls fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_calls.py | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py index dd53134297..f72907d550 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_calls.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_calls.py @@ -231,7 +231,7 @@ def test_call_non_existent_account( enough_gas_account_creation: bool, ): """ - Test *CALL witness assertion when there's insufficient gas for different scenarios. + Test *CALL witness assertion when target account does not exist. """ env = Environment( fee_recipient="0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", @@ -262,12 +262,14 @@ def test_call_non_existent_account( witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, caller_address, env.fee_recipient]: - witness_check.add_account_full( - address=address, - account=(None if address == env.fee_recipient else pre[address]), - ) + witness_check.add_account_full(address=address, account=pre.get(address)) + + code_chunks = chunkify_code(pre[caller_address].code) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=caller_address, chunk_number=i, value=chunk) + if enough_gas_account_creation: - witness_check.add_account_basic_data(address=TestAddress2, account=None) + witness_check.add_account_full(address=TestAddress2, account=None) blocks = [ Block( @@ -278,11 +280,7 @@ def test_call_non_existent_account( post: Alloc = Alloc() if enough_gas_account_creation: - post = Alloc( - { - TestAddress2: Account(balance=call_value), - } - ) + post = Alloc({TestAddress2: Account(balance=call_value)}) blockchain_test( genesis_environment=env, From 340683eb98a713e646d255c61db826311e1636c2 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 12 Sep 2024 11:02:39 -0300 Subject: [PATCH 21/23] verkle: more fixes Signed-off-by: Ignacio Hagopian --- .../test_balance.py | 43 ++++++++------- .../test_codecopy_generic.py | 53 +++++++++++-------- 2 files changed, 56 insertions(+), 40 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py index 5ab0441a34..967b0b1769 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_balance.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_balance.py @@ -20,6 +20,7 @@ WitnessCheck, ) from ethereum_test_tools.vm.opcode import Opcodes as Op +from ethereum_test_forks import Fork from ethereum_test_types.verkle.helpers import chunkify_code REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" @@ -40,27 +41,27 @@ ], ) @pytest.mark.parametrize("warm", [True, False]) -def test_balance(blockchain_test: BlockchainTestFiller, fork: str, target, warm): +def test_balance(blockchain_test: BlockchainTestFiller, fork: Fork, target, warm): """ Test BALANCE witness with/without WARM access. """ - _balance(blockchain_test, fork, target, [target], warm=warm) + _balance(blockchain_test, fork, target, True, warm=warm) @pytest.mark.valid_from("Verkle") @pytest.mark.parametrize("target", [example_address, precompile_address]) -def test_balance_insufficient_gas(blockchain_test: BlockchainTestFiller, fork: str, target): +def test_balance_insufficient_gas(blockchain_test: BlockchainTestFiller, fork: Fork, target): """ Test BALANCE with insufficient gas. """ - _balance(blockchain_test, fork, target, [], 21_042) + _balance(blockchain_test, fork, target, False, 21_042) def _balance( blockchain_test: BlockchainTestFiller, - fork: str, + fork: Fork, target: Address, - exp_addr_basic_data: list[Address], + exp_target_basic_data: bool, gas_limit=1_000_000, warm=False, ): @@ -74,10 +75,12 @@ def _balance( pre = { TestAddress: Account(balance=1000000000000000000000), TestAddress2: Account(code=Op.BALANCE(target) * (2 if warm else 1) + Op.PUSH0 + Op.SSTORE), - target: Account(balance=0xF1), - precompile_address: Account(balance=0xF2), + precompile_address: Account(balance=0xF0), } + if target != precompile_address and target != system_contract_address: + pre[target] = Account(balance=0xF2) + tx = Transaction( ty=0x0, chain_id=0x01, @@ -88,19 +91,23 @@ def _balance( ) witness_check = WitnessCheck(fork=Verkle) - witness_check.add_account_full(address=TestAddress, account=pre[TestAddress]) - witness_check.add_account_full(address=TestAddress2, account=pre[TestAddress2]) - witness_check.add_storage_slot(address=TestAddress2, storage_slot=0, value=None) + for address in [TestAddress, TestAddress2, env.fee_recipient]: + witness_check.add_account_full(address=address, account=pre.get(address)) + code_chunks = chunkify_code(pre[TestAddress2].code) for i, chunk in enumerate(code_chunks, start=0): witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk) - witness_check.add_account_full(address=env.fee_recipient, account=None) - for address in exp_addr_basic_data: - witness_check.add_account_basic_data( - address=address, - account=pre[address], - ) + witness_check.add_storage_slot(address=TestAddress2, storage_slot=0, value=None) + + target_account = ( + pre[target] + if target != system_contract_address + else Account(**fork.pre_allocation_blockchain()[system_contract_address]) + ) + + if exp_target_basic_data: + witness_check.add_account_basic_data(address=target, account=target_account) blocks = [ Block( @@ -110,7 +117,7 @@ def _balance( ] post = { - TestAddress2: Account(code=pre[TestAddress2].code, storage={0: pre[target].balance}), + TestAddress2: Account(code=pre[TestAddress2].code, storage={0: target_account.balance}), } blockchain_test( diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py index d75c47e2df..844aa3592c 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_codecopy_generic.py @@ -13,7 +13,6 @@ Address, Block, BlockchainTestFiller, - Bytecode, Environment, TestAddress, TestAddress2, @@ -26,7 +25,7 @@ REFERENCE_SPEC_GIT_PATH = "EIPS/eip-4762.md" REFERENCE_SPEC_VERSION = "2f8299df31bb8173618901a03a8366a3183479b0" -code_size = 200 * 31 + 60 +code_size = 130 * 31 + 60 @pytest.mark.valid_from("Verkle") @@ -34,7 +33,7 @@ "instruction", [ Op.CODECOPY, - Op.EXTCODECOPY, + # Op.EXTCODECOPY, ], ) @pytest.mark.parametrize( @@ -66,12 +65,12 @@ def test_generic_codecopy(blockchain_test: BlockchainTestFiller, instruction, of """ Test *CODECOPY witness. """ - start = offset if offset < size else size + start = offset if offset < code_size else code_size end = offset + size if offset + size < code_size else code_size witness_code_chunks = range(0, 0) - if start < size and start != end: + if start < code_size and start != end: start_chunk = start // 31 - end_chunk = (end - 1) // 31 + end_chunk = end // 31 witness_code_chunks = range(start_chunk, end_chunk + 1) _generic_codecopy( @@ -96,12 +95,13 @@ def test_generic_codecopy_warm(blockchain_test: BlockchainTestFiller, instructio """ Test *CODECOPY with WARM access. """ - witness_code_chunks = range(0, (code_size - 5) // 31 + 1) + code_len = 150 + witness_code_chunks = range(0, code_len // 31 + 1) _generic_codecopy( blockchain_test, instruction, 0, - code_size - 5, + code_len, witness_code_chunks, witness_target_basic_data=True, warm=True, @@ -191,21 +191,20 @@ def _generic_codecopy( number=1, timestamp=1000, ) - repeat = 2 if warm else 1 - codecopy_code = Op.CODECOPY(0, offset, size) * repeat - pre = { - TestAddress: Account(balance=1000000000000000000000), - TestAddress2: Account( - code=codecopy_code + Op.STOP + Op.PUSH0 * max(0, size - len(codecopy_code) - 1) - ), - dummy_address: Account(code=Op.EXTCODECOPY(TestAddress2, 0, offset, size) * repeat), - } to = TestAddress2 - data = Bytecode() if instr == Op.EXTCODECOPY: to = dummy_address + repeat = 2 if warm else 1 + codecopy_code = Op.CODECOPY(0, offset, size) * repeat + Op.STOP + extcodecopy_code = Op.EXTCODECOPY(TestAddress2, 0, offset, size) * repeat + pre = { + TestAddress: Account(balance=1000000000000000000000), + TestAddress2: Account(code=codecopy_code + Op.PUSH0 * (code_size - len(codecopy_code))), + dummy_address: Account(code=extcodecopy_code), + } + tx = Transaction( ty=0x0, chain_id=0x01, @@ -213,17 +212,27 @@ def _generic_codecopy( to=to, gas_limit=gas_limit, gas_price=10, - data=data, ) witness_check = WitnessCheck(fork=Verkle) for address in [TestAddress, to, env.fee_recipient]: witness_check.add_account_full(address=address, account=pre.get(address)) + # Add code-chunks related to CODECOPY/EXTCODECOPY execution. code_chunks = chunkify_code(pre[to].code) - # We'll always have code-chunk 0 since it has the actual - # CODECOPY/EXTCODECOPY opcode execution. - witness_check.add_code_chunk(to, 0, code_chunks[0]) + executed_code_len = ( + # In CODECOPY, not all the code is executed, since we right-padded with dummy push0-s + # so we can copy more code than actually executed. If we didn't do that, we can't + # distinguish between the code in the witness that was executed and the code that + # was copied. + (len(codecopy_code) + 31) // 32 + if instr == Op.CODECOPY + # In EXTCODECOPY, all the code is executed since we're copying code from an external + # account. + else (len(extcodecopy_code) + 31) // 32 + ) + for i in range(executed_code_len): + witness_check.add_code_chunk(to, i, code_chunks[i]) if instr == Op.EXTCODECOPY: witness_check.add_account_basic_data(address=TestAddress2, account=pre.get(TestAddress2)) From eb7a9e64d564753627abc84ab3195ebaab3a40bf Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 12 Sep 2024 11:45:42 -0300 Subject: [PATCH 22/23] verkle: more fixes Signed-off-by: Ignacio Hagopian --- .../test_creates.py | 83 ++++--------------- 1 file changed, 14 insertions(+), 69 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py index bbdeae4f52..0deba0ddea 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_creates.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_creates.py @@ -59,26 +59,9 @@ def test_create(blockchain_test: BlockchainTestFiller, create_instruction: Opcod Test tx contract creation and *CREATE witness. """ contract_code = bytes(Op.PUSH0 * code_size) - if create_instruction is None: - contract_address = compute_create_address(address=TestAddress, nonce=0) - elif create_instruction == Op.CREATE: - contract_address = compute_create_address(address=TestAddress2, nonce=0) - else: - contract_address = compute_create2_address( - TestAddress2, 0xDEADBEEF, Initcode(deploy_code=contract_code) - ) - - num_code_chunks = (len(contract_code) + 30) // 31 - - witness_check_extra = WitnessCheck(fork=Verkle) - witness_check_extra.add_account_full(contract_address, None) - for i in range(num_code_chunks): - witness_check_extra.add_code_chunk(contract_address, i, None) - _create( blockchain_test, create_instruction, - witness_check_extra, contract_code, value=0, ) @@ -104,7 +87,6 @@ def test_create_with_value_insufficient_balance( _create( blockchain_test, create_instruction, - WitnessCheck(fork=Verkle), contract_code, value=100, # TODO(verkle): generalize with value>0 and enough balance? creator_balance=0, @@ -148,28 +130,10 @@ def test_create_insufficient_gas( Test *CREATE with insufficient gas at different points of execution. """ contract_code = Op.PUSH0 * (129 * 31 + 42) - if create_instruction is None or create_instruction == Op.CREATE: - contract_address = compute_create_address(address=TestAddress, nonce=0) - else: - contract_address = compute_create2_address( - TestAddress, 0xDEADBEEF, Initcode(deploy_code=contract_code) - ) - - code_chunks = chunkify_code(bytes(contract_code)) - - witness_check_extra = WitnessCheck(fork=Verkle) - if witness_basic_data and witness_codehash: - witness_check_extra.add_account_full(contract_address, None) - for i in range(witness_chunk_count): - witness_check_extra.add_code_chunk(contract_address, i, code_chunks[i]) # type: ignore - elif witness_basic_data and not witness_codehash: - witness_check_extra.add_account_basic_data(contract_address, None) - # No code chunks since we failed earlier. _create( blockchain_test, create_instruction, - witness_check_extra, contract_code, value=0, gas_limit=gas_limit, @@ -196,9 +160,6 @@ def test_create_static_cost( _create( blockchain_test, create_instruction, - WitnessCheck( - fork=Verkle - ), # Static cost fail means the created contract shouldn't be in the witness Op.PUSH0 * (129 * 31 + 42), value=0, gas_limit=gas_limit, @@ -214,20 +175,14 @@ def test_create_static_cost( Op.CREATE2, ], ) -def test_create_collision( - blockchain_test: BlockchainTestFiller, - create_instruction, -): +def test_create_collision(blockchain_test: BlockchainTestFiller, create_instruction): """ Test tx contract creation and *CREATE with address collision. """ _create( blockchain_test, create_instruction, - WitnessCheck( - fork=Verkle - ), # Collision means the created contract shouldn't be in the witness - Op.PUSH0 * (129 * 31 + 42), + Op.PUSH0 * (3 * 31 + 42), value=0, generate_collision=True, ) @@ -242,7 +197,7 @@ def test_create_collision( Op.CREATE2, ], ) -def test_big_calldata( +def test_create_big_calldata( blockchain_test: BlockchainTestFiller, create_instruction, ): @@ -251,23 +206,9 @@ def test_big_calldata( size but actual returned code from initcode execution. """ contract_code = bytes(Op.PUSH0 * (1000 * 31 + 42)) - if create_instruction is None: - contract_address = compute_create_address(address=TestAddress, nonce=0) - elif create_instruction == Op.CREATE: - contract_address = compute_create_address(address=TestAddress2, nonce=0) - else: - contract_address = compute_create2_address( - TestAddress2, 0xDEADBEEF, Initcode(initcode_prefix=Op.STOP, deploy_code=contract_code) - ) - - witness_check_extra = WitnessCheck(fork=Verkle) - witness_check_extra.add_account_full(contract_address, None) - # No code chunks since we do an immediate STOP in the Initcode. - _create( blockchain_test, create_instruction, - witness_check_extra, contract_code, value=0, initcode_stop_prefix=True, @@ -277,7 +218,6 @@ def test_big_calldata( def _create( blockchain_test: BlockchainTestFiller, create_instruction: Opcode | None, - witness_check_extra: WitnessCheck, contract_code, value: int = 0, gas_limit=10000000000, @@ -341,20 +281,25 @@ def _create( data=tx_data, ) - witness_check = witness_check_extra + witness_check = WitnessCheck(fork=Verkle) witness_check.add_account_full(env.fee_recipient, None) witness_check.add_account_full(TestAddress, pre[TestAddress]) if tx_target is not None: witness_check.add_account_full(tx_target, pre[tx_target]) + # Include code that executes the CREATE* code_chunks = chunkify_code(pre[tx_target].code) - # Code that executes the CREATE* for i, chunk in enumerate(code_chunks, start=0): witness_check.add_code_chunk(address=tx_target, chunk_number=i, value=chunk) - # Assert the code-chunks where the contract is deployed are provided. - code_chunks = chunkify_code(bytes(deploy_code.deploy_code)) - for i, chunk in enumerate(code_chunks, start=0): - witness_check.add_code_chunk(address=contract_address, chunk_number=i, value=None) + # The contract address will always appear in the witness: + # - If there's a collision, it should contain the existing contract for the collision check. + # - Otherwise, it should prove there's no collision. + witness_check.add_account_full(contract_address, pre.get(contract_address)) + # Assert the code-chunks where the contract is deployed are provided + if not generate_collision: + code_chunks = chunkify_code(bytes(deploy_code.deploy_code)) + for i, chunk in enumerate(code_chunks, start=0): + witness_check.add_code_chunk(address=contract_address, chunk_number=i, value=None) blocks = [ Block( From 0fcff0d88caa995b2c0d676fb157a15f1e46fea2 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 12 Sep 2024 11:53:01 -0300 Subject: [PATCH 23/23] verkle: more fixes Signed-off-by: Ignacio Hagopian --- .../eip4762_verkle_gas_witness/test_selfdestruct.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py index ab579192eb..edc016b36b 100644 --- a/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py +++ b/tests/verkle/eip4762_verkle_gas_witness/test_selfdestruct.py @@ -51,10 +51,7 @@ ) @pytest.mark.parametrize( "contract_balance", - [ - 0, - 1, - ], + [0, 1], ) def test_self_destruct( blockchain_test: BlockchainTestFiller, @@ -148,6 +145,9 @@ def _selfdestruct( witness_check.add_account_full(address=address, account=pre.get(address)) if contract_balance > 0 or (beneficiary != precompile_address): witness_check.add_account_basic_data(beneficiary, pre.get(beneficiary)) + if contract_balance > 0 and not beneficiary_must_exist: + witness_check.add_account_full(beneficiary, pre.get(beneficiary)) + code_chunks = chunkify_code(pre[TestAddress2].code) for i, chunk in enumerate(code_chunks, start=0): witness_check.add_code_chunk(address=TestAddress2, chunk_number=i, value=chunk)