Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazily decode events from the trace #920

Merged
merged 1 commit into from
Jan 4, 2021
Merged
Changes from all commits
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
8 changes: 5 additions & 3 deletions brownie/network/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ def __hash__(self) -> int:

@trace_property
def events(self) -> Optional[EventDict]:
if not self.status:
if not self.status and self._events is None:
self._get_trace()
# get events from the trace - handled lazily so that other
# trace operations are not blocked in case of a decoding error
initial_address = str(self.receiver or self.contract_address)
self._events = _decode_trace(self._raw_trace, initial_address) # type: ignore
return self._events

@trace_property
Expand Down Expand Up @@ -603,8 +607,6 @@ def _confirmed_trace(self, trace: Sequence) -> None:

def _reverted_trace(self, trace: Sequence,) -> None:
self._modified_state = False
# get events from trace
self._events = _decode_trace(trace, str(self.receiver or self.contract_address))
if self.contract_address:
step = next((i for i in trace if i["op"] == "CODECOPY"), None)
if step is not None and int(step["stack"][-3], 16) > 24577:
Expand Down