Skip to content

Commit

Permalink
619 cancel simple tx (#623)
Browse files Browse the repository at this point in the history
* Remove canceled mode for simple traansaction sender. #619
* Execute tx with big number evm steps via holder. #620
  • Loading branch information
afalaleev authored Mar 7, 2022
1 parent e9cfb57 commit 09fb0a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
8 changes: 1 addition & 7 deletions proxy/common_neon/solana_interactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _send_rpc_batch_request(self, method: str, params_list: List[Any]) -> List[R
full_request_data.append(request)

# Protection from big payload
if len(request_data) == 30 or len(full_request_data) == len(params_list):
if len(request_data) >= 25 or len(full_request_data) == len(params_list):
raw_response = self._make_request(request_data)
response_data = cast(List[RPCResponse], raw_response.json())

Expand Down Expand Up @@ -587,12 +587,6 @@ def _on_post_send(self):
elif len(self._budget_exceeded_list):
raise RuntimeError(COMPUTATION_BUDGET_EXCEEDED)

# There is no more retries to send transactions
if self._retry_idx >= RETRY_ON_FAIL:
if not self._is_canceled:
self._cancel()
return

if len(self._blocked_account_list):
time.sleep(0.4) # one block time

Expand Down
34 changes: 16 additions & 18 deletions proxy/common_neon/transaction_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ def __init__(self, signer: SolanaAccount, ether: EthereumAddress, rid: int, idx:
self.rid = rid
self.idx = idx
self.ether_key: PublicKey = None
self.storage = None
self.holder = None
self.storage: PublicKey = None
self.holder: PublicKey = None

def public_key(self) -> PublicKey:
return self.signer.public_key()
Expand Down Expand Up @@ -274,9 +274,9 @@ def init_resource_info(self) -> OperatorResourceInfo:
self._s.clear_resource()
continue

rid = self._resource.rid
opkey = str(self._resource.public_key())
self.debug(f'Resource is selected: {opkey}:{rid}')
self.debug(f'Resource is selected: {str(self._resource.public_key())}:{self._resource.rid}, ' +
f'storage: {str(self._resource.storage)}, ' +
f'holder: {str(self._resource.holder)}')
return self._resource

raise RuntimeError('Timeout on waiting a free operator resource!')
Expand Down Expand Up @@ -341,8 +341,7 @@ def _create_ether_account(self) -> PublicKey:
self.debug(f"Use existing ether account for resource {opkey}:{rid}")
return solana_address


stage = NeonCreateAccountTxStage(self._s, { "address": ether_address })
stage = NeonCreateAccountTxStage(self._s, {"address": ether_address})
stage.balance = self._s.solana.get_multiple_rent_exempt_balances_for_size([stage.size])[0]
stage.build()

Expand Down Expand Up @@ -395,6 +394,7 @@ def free_resource_info(self):

self._free_resource_list_glob.append(resource.idx)


@logged_group("neon.Proxy")
class NeonTxSender:
def __init__(self, db: MemDB, solana: SolanaInteractor, eth_tx: EthTx, steps: int):
Expand Down Expand Up @@ -849,17 +849,19 @@ class IterativeNeonTxStrategy(BaseNeonTxStrategy, abc.ABC):

def __init__(self, *args, **kwargs):
BaseNeonTxStrategy.__init__(self, *args, **kwargs)
self.steps += 1

def _validate(self) -> bool:
return self._validate_notdeploy_tx() and self._validate_txsize()
return self._validate_notdeploy_tx() and self._validate_txsize() and self._validate_evm_steps()

def _validate_evm_steps(self):
if self.s.steps_emulated > (self.s.steps * 25):
self.error = 'Big number of EVM steps'
return False
return True

def build_tx(self) -> Transaction:
# generate unique tx
if self.steps < 50:
self.steps += 1
else:
self.steps -= 1
self.steps -= 1
return self.s.builder.make_partial_call_or_continue_transaction(self.steps)

def _build_preparation_txs(self) -> [Transaction]:
Expand Down Expand Up @@ -891,11 +893,7 @@ def _validate(self) -> bool:
return self._validate_txsize()

def build_tx(self) -> Transaction:
# generate unique tx
if self.steps < 50:
self.steps += 1
else:
self.steps -= 1
self._tx_idx += 1
return self.s.builder.make_partial_call_or_continue_from_account_data(self.steps, self._tx_idx)

def _build_preparation_txs(self) -> [Transaction]:
Expand Down

0 comments on commit 09fb0a1

Please sign in to comment.