Skip to content

Commit

Permalink
NDEV-3481 testing Mainnet bug (#490)
Browse files Browse the repository at this point in the history
1. Added out_of_contract_scope.sol contract for proper
2. Added test_all_accounts_sent_in_last_iteration.py. Bug is reproducing in v1.18.0
  • Loading branch information
sshiganov authored Jan 22, 2025
1 parent 6fbfa85 commit 45459a1
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
13 changes: 13 additions & 0 deletions contracts/neon_evm/out_of_contract_scope.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pragma solidity 0.8.12;


contract SaveNumber {
bytes32[64] public b;
uint256 public non_zero_number;
uint256 public new_var;

function saveNumberToVar(uint256 number) public {
new_var = non_zero_number + number;
non_zero_number = number;
}
}
106 changes: 106 additions & 0 deletions integration/tests/neon_evm/test_all_accounts_sent_in_last_iteration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
from solders.pubkey import Pubkey

from integration.tests.neon_evm.utils.constants import TAG_FINALIZED_STATE
from integration.tests.neon_evm.utils.contract import make_contract_call_trx, deploy_contract
from integration.tests.neon_evm.utils.transaction_checks import check_holder_account_tag, \
check_transaction_logs_have_text
from utils.evm_loader import EVM_STEPS
from utils.layouts import FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT
from utils.types import Contract


class TestAccInLastIteration:

def test_all_accounts_sent_in_last_iteration(
self,
user_account,
evm_loader,
operator_keypair,
treasury_pool,
holder_acc,
neon_api_client,
sol_client
):

contract: Contract = deploy_contract(
operator=operator_keypair,
user=user_account,
contract_file_name="neon_evm/out_of_contract_scope.sol",
evm_loader=evm_loader,
neon_api_client=neon_api_client,
treasury_pool=treasury_pool,
solana_client=sol_client,
contract_name="SaveNumber",
version="0.8.12"
)

signed_tx = make_contract_call_trx(
evm_loader, user_account, contract, "saveNumberToVar(uint256)", params=[5]
)
evm_loader.write_transaction_to_holder_account(signed_tx, holder_acc, operator_keypair)

emulate_result = neon_api_client.emulate_contract_call(
user_account.eth_address.hex(),
contract.eth_address.hex(),
"saveNumberToVar(uint256)",
params=[5]
)

acc_from_emulation = [Pubkey.from_string(item["pubkey"]) for item in emulate_result["solana_accounts"]]

signed_tx = make_contract_call_trx(
evm_loader, user_account, contract, "saveNumberToVar(uint256)", params=[5]
)
evm_loader.write_transaction_to_holder_account(signed_tx, holder_acc, operator_keypair)

operator_balance = evm_loader.get_operator_balance_pubkey(operator_keypair)

# First iteration
for i in range(2):
evm_loader.send_transaction_step_from_account(
index=i,
operator=operator_keypair,
operator_balance_pubkey=operator_balance,
treasury=treasury_pool,
storage_account=holder_acc,
additional_accounts=[
contract.solana_address,
user_account.balance_account_address
],
steps_count=1,
signer=operator_keypair
)

evm_loader.send_transaction_step_from_account(
index=2,
operator=operator_keypair,
operator_balance_pubkey=operator_balance,
treasury=treasury_pool,
storage_account=holder_acc,
additional_accounts=acc_from_emulation,
steps_count=EVM_STEPS,
signer=operator_keypair
)

trx_final = evm_loader.send_transaction_step_from_account(
index=3,
operator=operator_keypair,
operator_balance_pubkey=operator_balance,
treasury=treasury_pool,
storage_account=holder_acc,
additional_accounts=acc_from_emulation,
steps_count=EVM_STEPS,
signer=operator_keypair
)

check_holder_account_tag(
solana_client=sol_client,
storage_account=holder_acc,
layout=FINALIZED_STORAGE_ACCOUNT_INFO_LAYOUT,
expected_tag=TAG_FINALIZED_STATE,
)

check_transaction_logs_have_text(
solana_client=sol_client, trx=trx_final, text="exit_status=0x11"
)

0 comments on commit 45459a1

Please sign in to comment.