Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed speculative transaction sending #198
  • Loading branch information
Semen Medvedev committed Sep 30, 2021
commit 30542c3c8857ceebcea1b76ad0fa10b6223557db
50 changes: 34 additions & 16 deletions proxy/plugin/solana_rest_api_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,20 @@ 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
raise

logger.debug("Collect bucked results:")
for trx in result_list:
confirm_transaction(client, trx)
Expand All @@ -489,14 +495,20 @@ 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
raise

logger.debug("Collect bucked results:")
for trx in result_list:
confirm_transaction(client, trx)
Expand Down Expand Up @@ -703,10 +715,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 +763,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