Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions proxy/common_neon/solana_interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,19 @@ def extract_measurements_from_receipt(receipt):


def check_if_program_exceeded_instructions(err_result):
err_instruction = "Program failed to complete: exceeded maximum number of instructions allowed"
err_budget = "failed: Computational budget exceeded"

if err_result['data']['logs'][-1].find(err_instruction) >= 0 or \
err_result['data']['logs'][-2].find(err_instruction) >= 0 or \
err_result['data']['logs'][-1].find(err_budget) >= 0:
return True
error_arr = get_from_dict(err_result, "err", "InstructionError")
if error_arr is not None and isinstance(error_arr, list):
error_type = error_arr[1]
if isinstance(error_type, str):
if error_type == 'ProgramFailedToComplete':
return True
if error_type == 'ComputationalBudgetExceeded':
return True
return False


def check_if_storage_is_empty_error(err_result):
error_arr = get_from_dict(err_result, "data", "err", "InstructionError")
error_arr = get_from_dict(err_result, "err", "InstructionError")
if error_arr is not None and isinstance(error_arr, list):
error_dict = error_arr[1]
if isinstance(error_dict, dict) and 'Custom' in error_dict:
Expand Down
17 changes: 13 additions & 4 deletions proxy/common_neon/transaction_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from .neon_instruction import NeonInstruction
from .solana_interactor import SolanaInteractor, check_if_continue_returned, \
check_if_program_exceeded_instructions, check_if_storage_is_empty_error
from .utils import get_from_dict
from ..environment import EVM_LOADER_ID
from ..plugin.eth_proto import Trx as EthTrx

Expand Down Expand Up @@ -321,6 +322,12 @@ def call_signed_noniterative(self):
call_txs_05.add(self.create_acc_trx)
call_txs_05.add(self.instruction.make_noniterative_call_transaction(len(call_txs_05.instructions)))
result = self.sender.send_measured_transaction(call_txs_05, self.eth_trx, 'CallFromRawEthereumTX')

if get_from_dict(result, 'result', 'meta', 'err') is not None:
if check_if_program_exceeded_instructions(result['result']['meta']):
raise Exception("Program failed to complete")
raise Exception(json.dumps(result['result']['meta']))

return result['result']['transaction']['signatures'][0]


Expand Down Expand Up @@ -359,7 +366,9 @@ def create_accounts_for_trx(self):
logger.debug(f"Create account for trx: {length}")
precall_txs = Transaction()
precall_txs.add(self.create_acc_trx)
self.sender.send_measured_transaction(precall_txs, self.eth_trx, 'CreateAccountsForTrx')
result = self.sender.send_measured_transaction(precall_txs, self.eth_trx, 'CreateAccountsForTrx')
if get_from_dict(result, 'result', 'meta', 'err', 'InstructionError') is not None:
raise Exception("Failed to create account for trx")


def write_trx_to_holder_account(self):
Expand Down Expand Up @@ -421,7 +430,7 @@ def call_continue_step(self):
result = self.sender.send_measured_transaction(trx, self.eth_trx, 'ContinueV02')
return result
except SendTransactionError as err:
if check_if_program_exceeded_instructions(err.result):
if check_if_program_exceeded_instructions(err.result['data']):
step_count = int(step_count * 90 / 100)
else:
raise
Expand All @@ -447,9 +456,9 @@ def call_continue_bucked(self):
receipts.append(self.sender.send_transaction_unconfirmed(trx))
except SendTransactionError as err:
logger.error(f"Failed to call continue bucked, error: {err.result}")
if check_if_storage_is_empty_error(err.result):
if check_if_storage_is_empty_error(err.result['data']):
pass
elif check_if_program_exceeded_instructions(err.result):
elif check_if_program_exceeded_instructions(err.result['data']):
steps = int(steps * 90 / 100)
else:
raise
Expand Down