Skip to content

Commit

Permalink
Call cancel on unknown errors for iterative transactions. #587
Browse files Browse the repository at this point in the history
  • Loading branch information
afalaleev authored Feb 21, 2022
1 parent 48c6267 commit c696a26
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
17 changes: 14 additions & 3 deletions proxy/common_neon/transaction_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ def __init__(self, sender: NeonTxSender, tx_list: [Transaction], name: str):
self._pending_list = []
self._budget_exceeded_list = []
self._storage_bad_status_list = []
self._unknown_error_list = []

self._all_tx_list = [self._bad_block_list,
self._blocked_account_list,
Expand Down Expand Up @@ -689,7 +690,7 @@ def send(self) -> SolTxListSender:
if custom in (1, 4):
self._storage_bad_status_list.append(receipt)
else:
raise SolanaTxError(receipt)
self._unknown_error_list.append(receipt)
else:
success_cnt += 1
self._on_success_send(tx, receipt)
Expand All @@ -700,7 +701,8 @@ def send(self) -> SolTxListSender:
f'bad blocks {len(self._bad_block_list)}, ' +
f'blocked accounts {len(self._blocked_account_list)}, ' +
f'budget exceeded {len(self._budget_exceeded_list)}, ' +
f'bad storage: {len(self._storage_bad_status_list)}')
f'bad storage: {len(self._storage_bad_status_list)}, ' +
f'unknown error: {len(self._unknown_error_list)}')

self._on_post_send()

Expand All @@ -716,7 +718,9 @@ def _on_success_send(self, tx: Transaction, receipt: {}):
self._blockhash = tx.recent_blockhash

def _on_post_send(self):
if len(self._storage_bad_status_list):
if len(self._unknown_error_list):
raise SolanaTxError(self._unknown_error_list[0])
elif len(self._storage_bad_status_list):
raise SolanaTxError(self._storage_bad_status_list[0])
elif len(self._budget_exceeded_list):
raise RuntimeError(COMPUTATION_BUDGET_EXCEEDED)
Expand Down Expand Up @@ -912,6 +916,13 @@ def _on_post_send(self):
self.debug(f'Got Neon tx {"cancel" if self._is_canceled else "result"}: {self.neon_res}')
return self.clear()

# Unknown error happens - cancel the transaction
if len(self._unknown_error_list):
self._unknown_error_list.clear()
if not self._is_canceled:
self._cancel()
return

# There is no more retries to send transactions
if self._retry_idx == RETRY_ON_FAIL:
if not self._is_canceled:
Expand Down
7 changes: 2 additions & 5 deletions proxy/indexer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def get_accounts_from_storage(client, storage_account, *, logger):
data = base64.b64decode(info['data'][0])

tag = data[0]
if tag == 0:
if tag in (0, 1, 4):
logger.debug("Empty")
return None
elif tag == 3:
else:
logger.debug("Not empty storage")

acc_list = []
Expand All @@ -84,9 +84,6 @@ def get_accounts_from_storage(client, storage_account, *, logger):
offset += 32

return acc_list
else:
logger.debug("Not empty other")
return None


@logged_group("neon.Indexer")
Expand Down

0 comments on commit c696a26

Please sign in to comment.