Skip to content

Commit

Permalink
✨ Distinguish EVM tx halts from unknown reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
michprev committed Sep 27, 2024
1 parent 9d3fc53 commit 8e1f653
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions wake/development/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,16 @@ def error(self) -> Optional[TransactionRevertedError]:
raw_error = self.raw_error
assert raw_error is not None

if isinstance(raw_error, Halt):
self._error = raw_error
return self._error

self._error = self._chain._process_revert_data(self, raw_error.data)
return self._error

@property
@_fetch_tx_receipt
def raw_error(self) -> Optional[UnknownTransactionRevertedError]:
def raw_error(self) -> Optional[Union[UnknownTransactionRevertedError, Halt]]:
if self.status == TransactionStatusEnum.SUCCESS:
return None

Expand All @@ -462,9 +466,16 @@ def raw_error(self) -> Optional[UnknownTransactionRevertedError]:
chain_interface = self._chain.chain_interface

assert self._tx_receipt is not None

if isinstance(chain_interface, AnvilChainInterface):
self._fetch_trace_transaction()
assert self._trace_transaction is not None

if self._trace_transaction[0]["result"] is None:
return Halt(self._trace_transaction[0]["error"])

# due to a bug, Anvil does not return revert data for failed contract creations
if isinstance(chain_interface, AnvilChainInterface) and self.to is not None:
self._fetch_trace_transaction()
assert self._trace_transaction is not None
output = self._trace_transaction[0]["result"]["output"]
if output.startswith("0x"):
Expand Down Expand Up @@ -778,6 +789,11 @@ class Error(TransactionRevertedError):
message: str


@dataclass
class Halt(TransactionRevertedError):
message: str


class PanicCodeEnum(IntEnum):
GENERIC = 0
"Generic compiler panic"
Expand Down

0 comments on commit 8e1f653

Please sign in to comment.