Skip to content
Merged
Changes from all 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
54 changes: 37 additions & 17 deletions proxy/plugin/solana_rest_api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
location_bin = ".deploy_contract.bin"
confirmation_check_delay = float(os.environ.get("NEON_CONFIRMATION_CHECK_DELAY", "0.1"))
neon_cli_timeout = float(os.environ.get("NEON_CLI_TIMEOUT", "0.1"))
USE_COMBINED_START_CONTINUE = os.environ.get("USE_COMBINED_START_CONTINUE")
USE_COMBINED_START_CONTINUE = os.environ.get("USE_COMBINED_START_CONTINUE", "YES") == "YES"
CONTINUE_COUNT_FACTOR = int(os.environ.get("CONTINUE_COUNT_FACTOR", "3"))

ACCOUNT_SEED_VERSION=b'\1'
Expand Down Expand Up @@ -465,14 +465,21 @@ def call_continue_bucked(signer, client, perm_accs, trx_accs, steps):
(continue_count, instruction_count) = simulate_continue(signer, client, perm_accs, trx_accs, steps)
logger.debug("Send bucked:")
result_list = []
for index in range(continue_count*CONTINUE_COUNT_FACTOR):
trx = Transaction().add(make_continue_instruction(perm_accs, trx_accs, instruction_count, index))
result = client.send_transaction(
trx,
signer,
opts=TxOpts(skip_confirmation=True, preflight_commitment=Confirmed)
)["result"]
result_list.append(result)
try:
for index in range(continue_count):
trx = Transaction().add(make_continue_instruction(perm_accs, trx_accs, instruction_count, index))
result = client.send_transaction(
trx,
signer,
opts=TxOpts(skip_confirmation=True, preflight_commitment=Confirmed)
)["result"]
result_list.append(result)
except Exception as err:
if str(err).startswith("Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1"):
pass
else:
raise

logger.debug("Collect bucked results:")
for trx in result_list:
confirm_transaction(client, trx)
Expand All @@ -489,14 +496,21 @@ def call_continue_bucked_0x0d(signer, client, perm_accs, trx_accs, steps, msg):
(continue_count, instruction_count) = simulate_continue_0x0d(signer, client, perm_accs, trx_accs, steps, msg)
logger.debug("Send bucked:")
result_list = []
for index in range(continue_count*CONTINUE_COUNT_FACTOR):
trx = Transaction().add(make_partial_call_or_continue_instruction_0x0d(perm_accs, trx_accs, instruction_count, msg, index))
result = client.send_transaction(
trx,
signer,
opts=TxOpts(skip_confirmation=True, preflight_commitment=Confirmed)
)["result"]
result_list.append(result)
try:
for index in range(continue_count*CONTINUE_COUNT_FACTOR):
trx = Transaction().add(make_partial_call_or_continue_instruction_0x0d(perm_accs, trx_accs, instruction_count, msg, index))
result = client.send_transaction(
trx,
signer,
opts=TxOpts(skip_confirmation=True, preflight_commitment=Confirmed)
)["result"]
result_list.append(result)
except Exception as err:
if str(err).startswith("Transaction simulation failed: Error processing Instruction 0: custom program error: 0x1"):
pass
else:
raise

logger.debug("Collect bucked results:")
for trx in result_list:
confirm_transaction(client, trx)
Expand Down Expand Up @@ -703,10 +717,13 @@ def simulate_continue_0x0d(signer, client, perm_accs, trx_accs, step_count, msg)
if continue_count == 0:
raise Exception("uninitialized storage account")
continue_count = instruction_error[0]
break
else:
logger.debug("Result:\n%s"%json.dumps(response, indent=3))
raise Exception("unspecified error")
else:
# In case of long Ethereum transaction we speculative send more iterations then need
continue_count = continue_count*CONTINUE_COUNT_FACTOR
break

logger.debug("tx_count = {}, step_count = {}".format(continue_count, step_count))
Expand Down Expand Up @@ -748,10 +765,13 @@ def simulate_continue(signer, client, perm_accs, trx_accs, step_count):
if continue_count == 0:
raise Exception("uninitialized storage account")
continue_count = instruction_error[0]
break
else:
logger.debug("Result:\n%s"%json.dumps(response, indent=3))
raise Exception("unspecified error")
else:
# In case of long Ethereum transaction we speculative send more iterations then need
continue_count = continue_count*CONTINUE_COUNT_FACTOR
break

logger.debug("tx_count = {}, step_count = {}".format(continue_count, step_count))
Expand Down