From 6960198db876653d1db6ac5ca6c7d1046e6387ab Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Fri, 16 Feb 2024 16:46:38 +0100 Subject: [PATCH 1/7] fix accounts structure --- integration/tests/neon_evm/utils/layouts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/tests/neon_evm/utils/layouts.py b/integration/tests/neon_evm/utils/layouts.py index 461358bd0b..08f331debf 100644 --- a/integration/tests/neon_evm/utils/layouts.py +++ b/integration/tests/neon_evm/utils/layouts.py @@ -2,7 +2,7 @@ STORAGE_ACCOUNT_INFO_LAYOUT = Struct( "tag" / Int8ul, - "blocked" / Int8ul, + "revision" / Int32ul, "owner" / Bytes(32), "hash" / Bytes(32), "caller" / Bytes(20), @@ -26,7 +26,7 @@ FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT = Struct( "tag" / Int8ul, - "blocked" / Int8ul, + "revision" / Int32ul, "owner" / Bytes(32), "hash" / Bytes(32), ) @@ -34,7 +34,7 @@ CONTRACT_ACCOUNT_LAYOUT = Struct( "type" / Int8ul, - "blocked" / Int8ul, + "revision" / Int32ul, "address" / Bytes(20), "chain_id" / Int64ul, "generation" / Int32ul, @@ -42,7 +42,7 @@ BALANCE_ACCOUNT_LAYOUT = Struct( "type" / Int8ul, - "blocked" / Int8ul, + "revision" / Int32ul, "address" / Bytes(20), "chain_id" / Int64ul, "trx_count" / Int64ul, From 699ecf0b861aea98cdc3ada3c477f0dc4fa145a0 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 19 Feb 2024 11:36:08 +0100 Subject: [PATCH 2/7] fixed tests with blocked account --- .../test_transaction_step_from_account.py | 86 +++++++++++-------- .../test_transaction_step_from_instruction.py | 85 ++++++++++-------- 2 files changed, 98 insertions(+), 73 deletions(-) diff --git a/integration/tests/neon_evm/test_transaction_step_from_account.py b/integration/tests/neon_evm/test_transaction_step_from_account.py index 1167ba663c..688c08837f 100644 --- a/integration/tests/neon_evm/test_transaction_step_from_account.py +++ b/integration/tests/neon_evm/test_transaction_step_from_account.py @@ -13,7 +13,7 @@ from solana.rpc.types import TxOpts from .solana_utils import solana_client, execute_transaction_steps_from_account, \ - write_transaction_to_holder_account, create_treasury_pool_address, send_transaction_step_from_account + write_transaction_to_holder_account, create_treasury_pool_address, send_transaction_step_from_account, EVM_STEPS from utils.helpers import gen_hash_of_block from .utils.assert_messages import InstructionAsserts from .utils.constants import TAG_FINALIZED_STATE @@ -443,43 +443,50 @@ def test_one_user_call_2_contracts(self, rw_lock_contract, string_setter_contrac signed_tx = make_contract_call_trx(user_account, rw_lock_contract, 'unchange_storage(uint8,uint8)', [1, 1]) write_transaction_to_holder_account(signed_tx, new_holder_acc, operator_keypair) - send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, new_holder_acc, - [user_account.balance_account_address, - user_account.solana_account_address, - rw_lock_contract.solana_address], 1, operator_keypair) + def send_transaction_steps(holder_acc, contract): + send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc, + [user_account.balance_account_address, + user_account.solana_account_address, + contract.solana_address], EVM_STEPS, operator_keypair) - signed_tx2 = make_contract_call_trx(user_account, string_setter_contract, 'get()') + send_transaction_steps(new_holder_acc, rw_lock_contract) + signed_tx2 = make_contract_call_trx(user_account, string_setter_contract, 'get()') holder_acc2 = create_holder(operator_keypair) write_transaction_to_holder_account(signed_tx2, holder_acc2, operator_keypair) - with pytest.raises(solana.rpc.core.RPCException, match=InstructionAsserts.LOCKED_ACC): - send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc2, - [user_account.balance_account_address, - user_account.solana_account_address, - string_setter_contract.solana_address], 1, operator_keypair) + send_transaction_steps(holder_acc2, string_setter_contract) + send_transaction_steps(new_holder_acc, rw_lock_contract) + send_transaction_steps(holder_acc2, string_setter_contract) + send_transaction_steps(new_holder_acc, rw_lock_contract) + send_transaction_steps(holder_acc2, string_setter_contract) + + check_holder_account_tag(new_holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_holder_account_tag(holder_acc2, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) def test_2_users_call_the_same_contract(self, rw_lock_contract, user_account, session_user, evm_loader, operator_keypair, treasury_pool, new_holder_acc): signed_tx = make_contract_call_trx(user_account, rw_lock_contract, 'unchange_storage(uint8,uint8)', [1, 1]) write_transaction_to_holder_account(signed_tx, new_holder_acc, operator_keypair) - - send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, new_holder_acc, - [user_account.solana_account_address, - user_account.balance_account_address, - rw_lock_contract.solana_address], 1, operator_keypair) - - signed_tx2 = make_contract_call_trx(session_user, rw_lock_contract, 'get_text()') - + signed_tx2 = make_contract_call_trx(session_user, rw_lock_contract, 'unchange_storage(uint8,uint8)', [2, 2]) holder_acc2 = create_holder(operator_keypair) write_transaction_to_holder_account(signed_tx2, holder_acc2, operator_keypair) - with pytest.raises(solana.rpc.core.RPCException, match=InstructionAsserts.LOCKED_ACC): - send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc2, - [session_user.solana_account_address, - session_user.balance_account_address, - rw_lock_contract.solana_address], 1, operator_keypair) + def send_transaction_steps(user, holder_acc): + send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc, + [user.solana_account_address, + user.balance_account_address, + rw_lock_contract.solana_address], EVM_STEPS, operator_keypair) + + send_transaction_steps(user_account, new_holder_acc) + send_transaction_steps(session_user, holder_acc2) + send_transaction_steps(user_account, new_holder_acc) + send_transaction_steps(session_user, holder_acc2) + send_transaction_steps(user_account, new_holder_acc) + send_transaction_steps(session_user, holder_acc2) + check_holder_account_tag(new_holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_holder_account_tag(holder_acc2, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) def test_two_contracts_call_same_contract(self, rw_lock_contract, user_account, session_user, evm_loader, operator_keypair, @@ -495,28 +502,31 @@ def test_two_contracts_call_same_contract(self, rw_lock_contract, user_account, signed_tx2 = make_contract_call_trx(session_user, contract2, 'get_text()') write_transaction_to_holder_account(signed_tx1, new_holder_acc, operator_keypair) - send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, new_holder_acc, - [user_account.solana_account_address, - user_account.balance_account_address, - rw_lock_contract.solana_address, - contract1.solana_address], 1, operator_keypair) + def send_transaction_steps(user, holder_acc, contract): + send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc, + [user.solana_account_address, + user.balance_account_address, + rw_lock_contract.solana_address, + contract.solana_address], EVM_STEPS, operator_keypair) holder_acc2 = create_holder(operator_keypair) write_transaction_to_holder_account(signed_tx2, holder_acc2, operator_keypair) - with pytest.raises(solana.rpc.core.RPCException, match=InstructionAsserts.LOCKED_ACC): - send_transaction_step_from_account(operator_keypair, evm_loader, treasury_pool, holder_acc2, - [session_user.solana_account_address, - session_user.balance_account_address, - rw_lock_contract.solana_address, - contract2.solana_address], 1, - operator_keypair) + send_transaction_steps(user_account, new_holder_acc, contract1) + send_transaction_steps(session_user, holder_acc2, contract2) + send_transaction_steps(user_account, new_holder_acc, contract1) + send_transaction_steps(session_user, holder_acc2, contract2) + send_transaction_steps(user_account, new_holder_acc, contract1) + send_transaction_steps(session_user, holder_acc2, contract2) + check_holder_account_tag(new_holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_holder_account_tag(holder_acc2, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + class TestStepFromAccountChangingOperatorsDuringTrxRun: def test_next_operator_can_continue_trx(self, rw_lock_contract, user_account, evm_loader, - operator_keypair, second_operator_keypair, treasury_pool, - new_holder_acc): + operator_keypair, second_operator_keypair, treasury_pool, + new_holder_acc): signed_tx = make_contract_call_trx(user_account, rw_lock_contract, 'update_storage_str(string)', ['text']) write_transaction_to_holder_account(signed_tx, new_holder_acc, operator_keypair) diff --git a/integration/tests/neon_evm/test_transaction_step_from_instruction.py b/integration/tests/neon_evm/test_transaction_step_from_instruction.py index e7dedf1a4c..f312fecd26 100644 --- a/integration/tests/neon_evm/test_transaction_step_from_instruction.py +++ b/integration/tests/neon_evm/test_transaction_step_from_instruction.py @@ -16,7 +16,7 @@ from solana.rpc.core import RPCException from .solana_utils import execute_transaction_steps_from_instruction, \ - create_treasury_pool_address, send_transaction_step_from_instruction + create_treasury_pool_address, send_transaction_step_from_instruction, EVM_STEPS from .utils.assert_messages import InstructionAsserts from .utils.constants import TAG_FINALIZED_STATE from .utils.contract import make_deployment_transaction, make_contract_call_trx, deploy_contract, get_contract_bin @@ -449,37 +449,49 @@ class TestTransactionStepFromInstructionParallelRuns: def test_one_user_call_2_contracts(self, rw_lock_contract, string_setter_contract, user_account, evm_loader, operator_keypair, treasury_pool, new_holder_acc): signed_tx = make_contract_call_trx(user_account, rw_lock_contract, 'unchange_storage(uint8,uint8)', [1, 1]) - send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, new_holder_acc, signed_tx, - [user_account.solana_account_address, - user_account.balance_account_address, - rw_lock_contract.solana_address], 1, operator_keypair) - signed_tx2 = make_contract_call_trx(user_account, string_setter_contract, 'get()') - holder_acc2 = create_holder(operator_keypair) - with pytest.raises(solana.rpc.core.RPCException, match=InstructionAsserts.LOCKED_ACC): - send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc2, signed_tx2, + def send_transaction_steps(holder_acc, contract, trx): + send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc, trx, [user_account.solana_account_address, user_account.balance_account_address, - string_setter_contract.solana_address], 1, operator_keypair) + contract.solana_address], EVM_STEPS, operator_keypair) + + send_transaction_steps(new_holder_acc, rw_lock_contract, signed_tx) + + signed_tx2 = make_contract_call_trx(user_account, string_setter_contract, 'get()') + holder_acc2 = create_holder(operator_keypair) + + send_transaction_steps(holder_acc2, string_setter_contract, signed_tx2) + send_transaction_steps(new_holder_acc, rw_lock_contract, signed_tx) + send_transaction_steps(holder_acc2, string_setter_contract, signed_tx2) + send_transaction_steps(new_holder_acc, rw_lock_contract, signed_tx) + send_transaction_steps(holder_acc2, string_setter_contract, signed_tx2) + check_holder_account_tag(new_holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_holder_account_tag(holder_acc2, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) def test_2_users_call_the_same_contract(self, rw_lock_contract, user_account, session_user, evm_loader, operator_keypair, treasury_pool, new_holder_acc): signed_tx = make_contract_call_trx(user_account, rw_lock_contract, 'unchange_storage(uint8,uint8)', [1, 1]) - send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, new_holder_acc, signed_tx, - [user_account.solana_account_address, - user_account.balance_account_address, - rw_lock_contract.solana_address], 1, operator_keypair) + def send_transaction_steps(user, holder_acc, trx): + send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc, + trx, + [user.solana_account_address, + user.balance_account_address, + rw_lock_contract.solana_address], EVM_STEPS, operator_keypair) + + send_transaction_steps(user_account, new_holder_acc, signed_tx) signed_tx2 = make_contract_call_trx(session_user, rw_lock_contract, 'get_text()') holder_acc2 = create_holder(operator_keypair) - - with pytest.raises(solana.rpc.core.RPCException, match=InstructionAsserts.LOCKED_ACC): - send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc2, signed_tx2, - [session_user.solana_account_address, - session_user.balance_account_address, - rw_lock_contract.solana_address], 1, operator_keypair) + send_transaction_steps(session_user, holder_acc2, signed_tx2) + send_transaction_steps(user_account, new_holder_acc, signed_tx) + send_transaction_steps(session_user, holder_acc2, signed_tx2) + send_transaction_steps(user_account, new_holder_acc, signed_tx) + send_transaction_steps(session_user, holder_acc2, signed_tx2) + check_holder_account_tag(new_holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_holder_account_tag(holder_acc2, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) def test_two_contracts_call_same_contract(self, rw_lock_contract, user_account, session_user, evm_loader, operator_keypair, @@ -493,27 +505,30 @@ def test_two_contracts_call_same_contract(self, rw_lock_contract, user_account, signed_tx1 = make_contract_call_trx(user_account, contract1, 'unchange_storage(uint8,uint8)', [1, 1]) signed_tx2 = make_contract_call_trx(session_user, contract2, 'get_text()') - - send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, new_holder_acc, signed_tx1, - [user_account.solana_account_address, - user_account.balance_account_address, - rw_lock_contract.solana_address, - contract1.solana_address], 1, operator_keypair) - holder_acc2 = create_holder(operator_keypair) - with pytest.raises(solana.rpc.core.RPCException, match=InstructionAsserts.LOCKED_ACC): - send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc2, signed_tx2, - [session_user.solana_account_address, - session_user.balance_account_address, + + def send_transaction_steps(user, holder_acc, contract, trx): + send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, holder_acc, + trx, + [user.solana_account_address, + user.balance_account_address, rw_lock_contract.solana_address, - contract2.solana_address], 1, - operator_keypair) + contract.solana_address], EVM_STEPS, operator_keypair) + + send_transaction_steps(user_account, new_holder_acc, contract1, signed_tx1) + send_transaction_steps(session_user, holder_acc2, contract2, signed_tx2) + send_transaction_steps(user_account, new_holder_acc, contract1, signed_tx1) + send_transaction_steps(session_user, holder_acc2, contract2, signed_tx2) + send_transaction_steps(user_account, new_holder_acc, contract1, signed_tx1) + send_transaction_steps(session_user, holder_acc2, contract2, signed_tx2) + check_holder_account_tag(new_holder_acc, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) + check_holder_account_tag(holder_acc2, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) class TestStepFromInstructionChangingOperatorsDuringTrxRun: def test_next_operator_can_continue_trx(self, rw_lock_contract, user_account, evm_loader, - operator_keypair, second_operator_keypair, treasury_pool, - new_holder_acc): + operator_keypair, second_operator_keypair, treasury_pool, + new_holder_acc): signed_tx = make_contract_call_trx(user_account, rw_lock_contract, 'update_storage_str(string)', ['text']) send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, new_holder_acc, From 57e00a4262fe02ab97603af7307a6db6429c50a8 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 19 Feb 2024 11:52:12 +0100 Subject: [PATCH 3/7] removed ParallelTransactionsTest --- integration/tests/neon_evm/test_parallel.py | 165 ------------------ .../tests/neon_evm/utils/assert_messages.py | 1 - 2 files changed, 166 deletions(-) delete mode 100644 integration/tests/neon_evm/test_parallel.py diff --git a/integration/tests/neon_evm/test_parallel.py b/integration/tests/neon_evm/test_parallel.py deleted file mode 100644 index 856ef47369..0000000000 --- a/integration/tests/neon_evm/test_parallel.py +++ /dev/null @@ -1,165 +0,0 @@ -from typing import Any -from unittest import TestCase - -from _pytest.fixtures import fixture -from solana.keypair import Keypair -from solana.publickey import PublicKey -from solana.rpc.core import RPCException - -from .solana_utils import EvmLoader, solana_client, make_new_user, deposit_neon, \ - cancel_transaction, send_transaction_step_from_account, execute_trx_from_instruction -from .utils.contract import write_transaction_to_holder_account, make_deployment_transaction -from .utils.ethereum import create_contract_address, make_eth_transaction -from .utils.storage import create_holder -from .types.types import Caller, TreasuryPool - -EVM_STEPS_COUNT = 0xFFFFFFFF -ONE_TOKEN = 10 ** 9 -MAX_PERMITTED_DATA_INCREASE = 10240 - - -class ParallelTransactionsTest(TestCase): - @fixture(autouse=True) - def prepare_fixture( - self, - user_account: Caller, - evm_loader: EvmLoader, - operator_keypair: Keypair, - treasury_pool: TreasuryPool, - ): - self.user_account = user_account - self.evm_loader = evm_loader - self.operator_keypair = operator_keypair - self.treasury_pool = treasury_pool - self.second_account = make_new_user(evm_loader) - - def test_create_same_accounts(self): - cases = [ - [2], - [3], - [4], - ] - - for case in cases: - iterations = case[0] - with self.subTest(iterations=iterations): - self.create_same_accounts_subtest(iterations) - - def create_same_accounts_subtest(self, iterations: int): - deposit_neon(self.evm_loader, self.operator_keypair, self.user_account.eth_address, ONE_TOKEN) - deposit_neon(self.evm_loader, self.operator_keypair, self.second_account.eth_address, ONE_TOKEN) - - contract = create_contract_address(self.user_account, self.evm_loader) - holder_acc = create_holder(self.operator_keypair) - deployment_tx = make_deployment_transaction(self.user_account, "big_contract", "BigContract") - write_transaction_to_holder_account(deployment_tx, holder_acc, self.operator_keypair) - - # First N iterations - for i in range(iterations): - deployment_receipt = send_transaction_step_from_account(self.operator_keypair, - self.evm_loader, - self.treasury_pool, - holder_acc, - [contract.balance_account_address, - contract.solana_address, - self.user_account.balance_account_address, - self.user_account.solana_account_address], - EVM_STEPS_COUNT, - self.operator_keypair, - index=i) - - assert not ParallelTransactionsTest.check_iteration_deployed(deployment_receipt) - - # Transferring to the same account in order to break deployment - ParallelTransactionsTest.transfer( - self.second_account, - contract.eth_address, - ONE_TOKEN, - self.evm_loader, - self.operator_keypair, - self.treasury_pool, - ) - - # Trying to finish deployment (expected to fail) - try: - send_transaction_step_from_account(self.operator_keypair, - self.evm_loader, - self.treasury_pool, - holder_acc, - [contract.balance_account_address, - contract.solana_address, - self.user_account.balance_account_address, - self.user_account.solana_account_address], - EVM_STEPS_COUNT, - self.operator_keypair) - - assert False, 'Deployment expected to fail' - except RPCException as e: - ParallelTransactionsTest.check_account_initialized_in_another_trx_exception(e, - contract.balance_account_address) - - # Cancel deployment transaction: - cancel_transaction( - self.evm_loader, - deployment_tx.hash, - holder_acc, - self.operator_keypair, - [contract.balance_account_address, - contract.solana_address, - self.user_account.balance_account_address, - self.user_account.solana_account_address], - ) - - @staticmethod - def check_iteration_deployed(receipt: Any) -> bool: - if receipt.value.transaction.meta.err: - raise AssertionError(f"Can't deploy contract: {receipt.value.transaction.meta.err}") - - for log in receipt.value.transaction.meta.log_messages: - if "exit_status" in log: - return True - if "ExitError" in log: - raise AssertionError(f"EVM Return error in logs: {receipt}") - return False - - @staticmethod - def transfer( - src_account: Caller, - dst_addr: bytes, - value: int, - evm_loader: EvmLoader, - operator_keypair: Keypair, - treasury_pool: TreasuryPool, - ): - message = make_eth_transaction( - dst_addr, - bytes(), - src_account, - value, - ) - - dst_solana_account, _ = evm_loader.ether2program(dst_addr) - dst_balance_account = evm_loader.ether2balance(dst_addr) - - trx = execute_trx_from_instruction(operator_keypair, evm_loader, treasury_pool.account, treasury_pool.buffer, - message, - [dst_balance_account, - PublicKey(dst_solana_account), - src_account.balance_account_address], - operator_keypair) - receipt = solana_client.get_transaction(trx.value) - print("Transfer receipt:", receipt) - assert receipt.value.transaction.meta.err is None - - return receipt - - @staticmethod - def check_account_initialized_in_another_trx_exception(exception: RPCException, solana_address: PublicKey): - error = exception.args[0] - print("error:", error) - - for log in error.data.logs: - if f'Account {solana_address} - was empty, created by another transaction' in log: - return - - assert False, "Search string not found in Solana logs" diff --git a/integration/tests/neon_evm/utils/assert_messages.py b/integration/tests/neon_evm/utils/assert_messages.py index 43511cd81c..1603ba50e0 100644 --- a/integration/tests/neon_evm/utils/assert_messages.py +++ b/integration/tests/neon_evm/utils/assert_messages.py @@ -1,5 +1,4 @@ class InstructionAsserts: - LOCKED_ACC = "trying to execute transaction on rw locked account" INVALID_CHAIN_ID = "Invalid Chain ID" INVALID_NONCE = "Invalid Nonce" TRX_ALREADY_FINALIZED = "Transaction already finalized" From 850bea1d832aaaab605ab78bb469c7e5f4acd712 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 19 Feb 2024 12:39:54 +0100 Subject: [PATCH 4/7] Update constants.py --- integration/tests/neon_evm/utils/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/tests/neon_evm/utils/constants.py b/integration/tests/neon_evm/utils/constants.py index af9c1119fc..3109143217 100644 --- a/integration/tests/neon_evm/utils/constants.py +++ b/integration/tests/neon_evm/utils/constants.py @@ -16,7 +16,7 @@ ACCOUNT_SEED_VERSION = b'\3' TAG_EMPTY = 0 -TAG_STATE = 23 +TAG_STATE = 24 TAG_FINALIZED_STATE = 32 TAG_HOLDER = 52 From 6a3626a9a4067720f0219609b35567a9e7bb2ad9 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Mon, 19 Feb 2024 13:05:24 +0100 Subject: [PATCH 5/7] removed STORAGE_ACCOUNT_INFO_LAYOUT using --- integration/tests/neon_evm/test_cancel_trx.py | 16 +++++++++------- .../tests/neon_evm/test_holder_account.py | 7 ++----- integration/tests/neon_evm/utils/constants.py | 1 - integration/tests/neon_evm/utils/layouts.py | 14 -------------- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/integration/tests/neon_evm/test_cancel_trx.py b/integration/tests/neon_evm/test_cancel_trx.py index cbb683a9a4..def825c592 100644 --- a/integration/tests/neon_evm/test_cancel_trx.py +++ b/integration/tests/neon_evm/test_cancel_trx.py @@ -2,11 +2,11 @@ from .solana_utils import send_transaction, solana_client, \ send_transaction_step_from_instruction -from .utils.constants import TAG_FINALIZED_STATE, TAG_STATE +from .utils.constants import TAG_FINALIZED_STATE from .utils.contract import make_contract_call_trx from .utils.storage import create_holder from .utils.instructions import make_Cancel -from .utils.layouts import FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, STORAGE_ACCOUNT_INFO_LAYOUT +from .utils.layouts import FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT from .utils.transaction_checks import check_holder_account_tag @@ -18,6 +18,8 @@ def test_cancel_trx(self, operator_keypair, rw_lock_contract, user_account, trea signed_tx = make_contract_call_trx(user_account, rw_lock_contract, "unchange_storage(uint8,uint8)", [1, 1]) storage_account = create_holder(operator_keypair) + user_nonce_before_first_step = evm_loader.get_neon_nonce(user_account.eth_address) + trx = send_transaction_step_from_instruction(operator_keypair, evm_loader, treasury_pool, storage_account, signed_tx, [rw_lock_contract.solana_address, @@ -27,16 +29,16 @@ def test_cancel_trx(self, operator_keypair, rw_lock_contract, user_account, trea receipt = solana_client.get_transaction(trx.value) assert receipt.value.transaction.meta.err is None - check_holder_account_tag(storage_account, STORAGE_ACCOUNT_INFO_LAYOUT, TAG_STATE) - user_nonce = evm_loader.get_neon_nonce(user_account.eth_address) + user_nonce_after_first_step = evm_loader.get_neon_nonce(user_account.eth_address) + assert user_nonce_before_first_step + 1 == user_nonce_after_first_step trx = Transaction() trx.add( make_Cancel(evm_loader, storage_account, operator_keypair, signed_tx.hash, [rw_lock_contract.solana_address, - rw_lock_contract.balance_account_address, - user_account.balance_account_address]) + rw_lock_contract.balance_account_address, + user_account.balance_account_address]) ) send_transaction(solana_client, trx, operator_keypair) check_holder_account_tag(storage_account, FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT, TAG_FINALIZED_STATE) - assert user_nonce < evm_loader.get_neon_nonce(user_account.eth_address) + assert user_nonce_after_first_step == evm_loader.get_neon_nonce(user_account.eth_address) diff --git a/integration/tests/neon_evm/test_holder_account.py b/integration/tests/neon_evm/test_holder_account.py index 807b567b92..bef1c13c01 100644 --- a/integration/tests/neon_evm/test_holder_account.py +++ b/integration/tests/neon_evm/test_holder_account.py @@ -12,11 +12,11 @@ from .solana_utils import solana_client, write_transaction_to_holder_account, \ send_transaction_step_from_account, get_solana_balance, execute_transaction_steps_from_account from .utils.assert_messages import InstructionAsserts -from .utils.constants import EVM_LOADER, TAG_STATE +from .utils.constants import EVM_LOADER from .utils.contract import make_deployment_transaction, make_contract_call_trx from .utils.ethereum import make_eth_transaction from .utils.instructions import make_WriteHolder -from .utils.layouts import STORAGE_ACCOUNT_INFO_LAYOUT, HOLDER_ACCOUNT_INFO_LAYOUT +from .utils.layouts import HOLDER_ACCOUNT_INFO_LAYOUT from .utils.storage import create_holder, delete_holder @@ -112,9 +112,6 @@ def test_write_to_not_finalized_holder(rw_lock_contract, user_account, evm_loade [user_account.solana_account_address, user_account.balance_account_address, rw_lock_contract.solana_address], 1, operator_keypair) - account_data = solana_client.get_account_info(new_holder_acc, commitment=Confirmed).value.data - parsed_data = STORAGE_ACCOUNT_INFO_LAYOUT.parse(account_data) - assert parsed_data.tag == TAG_STATE signed_tx2 = make_contract_call_trx(user_account, rw_lock_contract, "unchange_storage(uint8,uint8)", [1, 1]) diff --git a/integration/tests/neon_evm/utils/constants.py b/integration/tests/neon_evm/utils/constants.py index 3109143217..58760c5519 100644 --- a/integration/tests/neon_evm/utils/constants.py +++ b/integration/tests/neon_evm/utils/constants.py @@ -16,7 +16,6 @@ ACCOUNT_SEED_VERSION = b'\3' TAG_EMPTY = 0 -TAG_STATE = 24 TAG_FINALIZED_STATE = 32 TAG_HOLDER = 52 diff --git a/integration/tests/neon_evm/utils/layouts.py b/integration/tests/neon_evm/utils/layouts.py index 08f331debf..1c9972c557 100644 --- a/integration/tests/neon_evm/utils/layouts.py +++ b/integration/tests/neon_evm/utils/layouts.py @@ -1,19 +1,5 @@ from construct import Bytes, Int8ul, Struct, Int64ul, Int32ul -STORAGE_ACCOUNT_INFO_LAYOUT = Struct( - "tag" / Int8ul, - "revision" / Int32ul, - "owner" / Bytes(32), - "hash" / Bytes(32), - "caller" / Bytes(20), - "chain_id" / Int64ul, - "gas_limit" / Bytes(32), - "gas_price" / Bytes(32), - "gas_used" / Bytes(32), - "operator" / Bytes(32), - "slot" / Int64ul, - "account_list_len" / Int64ul, -) HOLDER_ACCOUNT_INFO_LAYOUT = Struct( "tag" / Int8ul, From cf7f7328536909056beee3e8458008b03ebd7106 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Wed, 21 Feb 2024 10:37:52 +0100 Subject: [PATCH 6/7] fix expected value for estimated gas for erc20 transfer --- integration/tests/basic/rpc/test_rpc_estimate_gas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/tests/basic/rpc/test_rpc_estimate_gas.py b/integration/tests/basic/rpc/test_rpc_estimate_gas.py index 99e683ea8d..d704f30c20 100644 --- a/integration/tests/basic/rpc/test_rpc_estimate_gas.py +++ b/integration/tests/basic/rpc/test_rpc_estimate_gas.py @@ -108,7 +108,7 @@ def test_rpc_estimate_gas_erc20(self, erc20_simple): assert "gas" in transaction estimated_gas = transaction["gas"] - assert estimated_gas == 1_394_160 + assert estimated_gas == 1_415_040 def test_rpc_estimate_gas_spl(self, erc20_spl): recipient_account = self.accounts[1] From d963f96b60dc6c8f797f9e48a7e546372f678c39 Mon Sep 17 00:00:00 2001 From: kristinaNikolaeva Date: Wed, 21 Feb 2024 13:43:58 +0100 Subject: [PATCH 7/7] skipped test --- .../audit/evm/opcodes/test_extcodehash.md | 30 +++++++++---------- .../basic/evm/opcodes/test_extcodehash.py | 1 + integration/tests/neon_evm/utils/layouts.py | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/docs/tests/audit/evm/opcodes/test_extcodehash.md b/docs/tests/audit/evm/opcodes/test_extcodehash.md index 16cfe55151..3711a7a2c1 100644 --- a/docs/tests/audit/evm/opcodes/test_extcodehash.md +++ b/docs/tests/audit/evm/opcodes/test_extcodehash.md @@ -4,18 +4,18 @@ Verify EIP-1052: EXTCODEHASH opcode # Tests list -| Test case | Description | XFailed | -|-------------------------------------------------------------------------------|------------------------------------------------------------|---------| -| TestExtCodeHashOpcode::test_extcodehash_for_contract_address | Execute via eth_call | | -| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_contract_address | Execute via transaction | | -| TestExtCodeHashOpcode::test_extcodehash_for_empty_account | Execute for empty account and eth_call | | -| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_empty_account | Execute for empty account via transaction | | -| TestExtCodeHashOpcode::test_extcodehash_for_non_existing_account | Execute for not existing account and eth_call | | -| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_non_existing_account | Execute for not existing account in transaction | | -| TestExtCodeHashOpcode::test_extcodehash_for_destroyed_contract | Execute for destroyed contract with eth_call | | -| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_destroyed_contract | Execute for destroyed contract in transaction | | -| TestExtCodeHashOpcode::test_extcodehash_for_reverted_destroyed_contract | Execute for revert contract in eth_call | | -| TestExtCodeHashOpcode::test_extcodehash_for_precompiled_contract | Execute for precompiled contract in eth_call | | -| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_precompiled_contract | Execute for precompiled contract in transaction | | -| TestExtCodeHashOpcode::test_extcodehash_for_new_account_with_changed_balance | Execute for a new account with changing balance in one trx | | -| TestExtCodeHashOpcode::test_extcodehash_for_new_account_with_changed_nonce | Execute for a new account with changing nonce in one trx | | +| Test case | Description | XFailed | +|-------------------------------------------------------------------------------|------------------------------------------------------------|-----------| +| TestExtCodeHashOpcode::test_extcodehash_for_contract_address | Execute via eth_call | | +| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_contract_address | Execute via transaction | | +| TestExtCodeHashOpcode::test_extcodehash_for_empty_account | Execute for empty account and eth_call | | +| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_empty_account | Execute for empty account via transaction | | +| TestExtCodeHashOpcode::test_extcodehash_for_non_existing_account | Execute for not existing account and eth_call | | +| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_non_existing_account | Execute for not existing account in transaction | | +| TestExtCodeHashOpcode::test_extcodehash_for_destroyed_contract | Execute for destroyed contract with eth_call | | +| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_destroyed_contract | Execute for destroyed contract in transaction | | +| TestExtCodeHashOpcode::test_extcodehash_for_reverted_destroyed_contract | Execute for revert contract in eth_call | | +| TestExtCodeHashOpcode::test_extcodehash_for_precompiled_contract | Execute for precompiled contract in eth_call | | +| TestExtCodeHashOpcode::test_extcodehash_with_send_tx_for_precompiled_contract | Execute for precompiled contract in transaction | | +| TestExtCodeHashOpcode::test_extcodehash_for_new_account_with_changed_balance | Execute for a new account with changing balance in one trx | | +| TestExtCodeHashOpcode::test_extcodehash_for_new_account_with_changed_nonce | Execute for a new account with changing nonce in one trx | NDEV-2666 | diff --git a/integration/tests/basic/evm/opcodes/test_extcodehash.py b/integration/tests/basic/evm/opcodes/test_extcodehash.py index e863344f3f..54c7576893 100644 --- a/integration/tests/basic/evm/opcodes/test_extcodehash.py +++ b/integration/tests/basic/evm/opcodes/test_extcodehash.py @@ -168,6 +168,7 @@ def test_extcodehash_for_new_account_with_changed_balance(self, eip1052_checker, assert event_logs[0]["args"]["hash"].hex() == ZERO_HASH assert event_logs[1]["args"]["hash"] == keccak(self.web3_client.eth.get_code(new_acc.address, "latest")) + @pytest.mark.skip(reason="bug NDEV-2666") def test_extcodehash_for_new_account_with_changed_nonce(self, eip1052_checker, json_rpc_client): new_account = self.web3_client.create_account() diff --git a/integration/tests/neon_evm/utils/layouts.py b/integration/tests/neon_evm/utils/layouts.py index 1c9972c557..5d88d99cb6 100644 --- a/integration/tests/neon_evm/utils/layouts.py +++ b/integration/tests/neon_evm/utils/layouts.py @@ -12,7 +12,7 @@ FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT = Struct( "tag" / Int8ul, - "revision" / Int32ul, + "nothing" / Int8ul, "owner" / Bytes(32), "hash" / Bytes(32), )