Skip to content

Commit

Permalink
Merge pull request #229 from charles-cooper/feat/suppress-debug-tt
Browse files Browse the repository at this point in the history
add debug_tt suppression
  • Loading branch information
charles-cooper authored May 17, 2024
2 parents 83688de + 3e8b033 commit 69c68d6
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions boa/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def __init__(

self.tx_settings = TransactionSettings()
self.capabilities = Capabilities(rpc)
self._suppress_debug_tt = False

@cached_property
def _rpc_has_snapshot(self):
Expand Down Expand Up @@ -421,6 +422,30 @@ def _warn_no_tracer():

return call_tracer

def suppress_debug_tt(self, new_value=True):
self._suppress_debug_tt = new_value

def _debug_tt(self, tx_hash):
if self._tracer is None:
return None
try:
return self._rpc.fetch_uncached(
"debug_traceTransaction", [tx_hash, self._tracer]
)
except RPCError as e:
if self._suppress_debug_tt:
warnings.warn(f"Couldn't get a trace for {tx_hash}!", stacklevel=3)
else:
warnings.warn(
f"Couldn't get a trace for {tx_hash}! If you want to"
" suppress this error, call `boa.env.suppress_debug_tt()`"
" first.",
stacklevel=3,
)
raise e

return None

def _get_nonce(self, addr):
return self._rpc.fetch("eth_getTransactionCount", [addr, "latest"])

Expand Down Expand Up @@ -482,11 +507,7 @@ def _send_txn(self, from_, to=None, gas=None, value=None, data=None):

receipt = self._rpc.wait_for_tx_receipt(tx_hash, self.tx_settings.poll_timeout)

trace = None
if self._tracer is not None:
trace = self._rpc.fetch_uncached(
"debug_traceTransaction", [tx_hash, self._tracer]
)
trace = self._debug_tt(tx_hash)

print(f"{tx_hash} mined in block {receipt['blockHash']}!")

Expand Down

0 comments on commit 69c68d6

Please sign in to comment.