Skip to content
Merged
Show file tree
Hide file tree
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
Fixes in estimate gas calculations
  • Loading branch information
afalaleev committed Oct 26, 2022
commit 168d7c1e5c803c5c9750cd8804c969c895e494bb
8 changes: 5 additions & 3 deletions proxy/common_neon/estimate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from ..common_neon.solana_interactor import SolInteractor
from ..common_neon.solana_alt_builder import ALTTxBuilder
from ..common_neon.neon_instruction import NeonIxBuilder
from ..common_neon.solana_tx import SolAccount, SolPubKey, SolAccountMeta, SolBlockhash
from ..common_neon.solana_tx import SolAccount, SolPubKey, SolAccountMeta, SolBlockhash, SolTxSizeError
from ..common_neon.solana_tx_legacy import SolLegacyTx
from ..common_neon.address import NeonAddress

Expand Down Expand Up @@ -121,8 +121,10 @@ def _tx_size_cost(self) -> int:
pass
elif self._execution_cost() < self._small_gas_limit:
return self._cached_tx_cost_size
except (Exception, ):
except SolTxSizeError:
pass
except BaseException as exc:
self.debug('Error during pack solana tx', exc_info=exc)

self._cached_tx_cost_size = self._holder_tx_cost(self._tx_builder.neon_tx_len())
return self._cached_tx_cost_size
Expand All @@ -138,7 +140,7 @@ def _emulated_step_cnt(self) -> int:

def _iterative_overhead_cost(self) -> int:
if self._cached_overhead_cost is not None:
return self._cached_tx_cost_size
return self._cached_overhead_cost

execution_cost = self._execution_cost()
tx_size_cost = self._tx_size_cost()
Expand Down
6 changes: 5 additions & 1 deletion proxy/common_neon/solana_tx.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
SolTxReceipt = Dict[str, Any]


class SolTxSizeError(Exception):
pass


class SolTx(abc.ABC):
_empty_blockhash = SolBlockhash(str(solders.hash.Hash.default()))

Expand Down Expand Up @@ -65,7 +69,7 @@ def serialize(self) -> bytes:
assert self._is_signed, "transaction has not been signed"
result = self._serialize()
if len(result) > solana.transaction.PACKET_DATA_SIZE:
raise ValueError('Transaction too big')
raise SolTxSizeError('Transaction too big')
return result

def sign(self, signer: SolAccount) -> None:
Expand Down