Skip to content

Commit

Permalink
added a function for debug failed neon trx (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristinaNikolaevaa authored Feb 13, 2025
1 parent 4fad317 commit 6d8cbcb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 19 deletions.
3 changes: 2 additions & 1 deletion integration/tests/neon_evm/test_interoperability.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

from conftest import EnvironmentConfig
from integration.tests.neon_evm.utils.call_solana import SolanaCaller
from .utils.transaction_checks import check_holder_account_tag, check_transaction_logs_have_text, decode_logs
from utils.solana_logs_helper import decode_logs
from .utils.transaction_checks import check_holder_account_tag, check_transaction_logs_have_text

from integration.tests.neon_evm.utils.ethereum import make_eth_transaction, make_contract_call_trx

Expand Down
18 changes: 1 addition & 17 deletions integration/tests/neon_evm/utils/transaction_checks.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import base64

from solana.rpc.commitment import Confirmed
from solders.rpc.responses import GetTransactionResp, SendTransactionResp

from utils.solana_client import SolanaClient
from utils.solana_logs_helper import decode_logs


def check_transaction_logs_have_text(
Expand All @@ -17,21 +16,6 @@ def check_transaction_logs_have_text(
assert text in logs, f"Transaction logs don't contain '{text}'. Logs: {logs}"


def decode_logs(log_messages: list) -> list:
decoded_logs = ""

for log in log_messages:
if "Program data:" in log:
decoded_logs += "Program data: "
encoded_part = log.replace("Program data: ", "")
for item in encoded_part.split(" "):
decoded_logs += " " + str(base64.b64decode(item))
else:
decoded_logs += log
decoded_logs += " "
return decoded_logs


def check_holder_account_tag(solana_client: SolanaClient, storage_account, layout, expected_tag):
account_data = solana_client.get_account_info(storage_account, commitment=Confirmed).value.data
parsed_data = layout.parse(account_data)
Expand Down
3 changes: 2 additions & 1 deletion utils/evm_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from integration.tests.neon_evm.utils.contract import get_contract_bin
from integration.tests.neon_evm.utils.ethereum import create_contract_address, make_deployment_transaction
from integration.tests.neon_evm.utils.neon_api_client import NeonApiClient
from integration.tests.neon_evm.utils.transaction_checks import check_transaction_logs_have_text, decode_logs
from integration.tests.neon_evm.utils.transaction_checks import check_transaction_logs_have_text
from utils.scheduled_trx import ScheduledTransaction
from utils.neon_user import NeonUser
from integration.tests.neon_evm.utils.constants import TREASURY_POOL_SEED
Expand Down Expand Up @@ -61,6 +61,7 @@
OPERATOR_BALANCE_ACCOUNT_LAYOUT,
)
from utils.solana_client import SolanaClient
from utils.solana_logs_helper import decode_logs
from utils.types import Caller, Contract, TreasuryPool

EVM_STEPS = 500
Expand Down
33 changes: 33 additions & 0 deletions utils/solana_logs_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import base64

from solana.rpc.commitment import Confirmed
from solders.signature import Signature

from utils.web3client import Web3Client


def decode_logs(log_messages: list) -> str:
decoded_logs = ""

for log in log_messages:
if "Program data:" in log:
decoded_logs += "Program data: "
encoded_part = log.replace("Program data: ", "")
for item in encoded_part.split(" "):
decoded_logs += " " + str(base64.b64decode(item))
else:
decoded_logs += log
decoded_logs += " "
return decoded_logs


def get_all_solana_logs_for_neon_trx(web3_client: Web3Client, solana_client, trx_hash):
sol_trxs = web3_client.get_solana_trx_by_neon(trx_hash)["result"]
logs = []
for trx in sol_trxs:
encoded_log = solana_client.get_transaction(
Signature.from_string(trx), commitment=Confirmed
).value.transaction.meta.log_messages
logs.append(decode_logs(encoded_log))

return logs

0 comments on commit 6d8cbcb

Please sign in to comment.