Skip to content

Commit

Permalink
perf: make always happen not just fork
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Aug 6, 2024
1 parent 2683fb8 commit bce1824
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
12 changes: 4 additions & 8 deletions src/ape_ethereum/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,17 +219,13 @@ def get_addresses_used(self, reverse: bool = False):

@cached_property
def return_value(self) -> Any:
if self._enriched_calltree or (
self.provider.network.is_local and not self.provider.network.is_fork
):
# For non-local network (including forks), only check enrichment
# output if was already enriched! Don't enrich ONLY for return value,
# as that is very bad performance for realistic contract interactions.
if self._enriched_calltree:
# Only check enrichment output if was already enriched!
# Don't enrich ONLY for return value, as that is very bad performance
# for realistic contract interactions.
return self._return_value_from_enriched_calltree

elif abi := self.root_method_abi:
# When using a fork or live network and we are not enriched yet, we always
# opt for the trace-logs parsing approach as it typically faster for realistic contracts.
return_data = self._return_data_from_trace_frames
try:
return self._ecosystem.decode_returndata(abi, return_data)
Expand Down
13 changes: 1 addition & 12 deletions tests/functional/geth/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,6 @@ def test_return_value(geth_contract, geth_account):
actual = trace.return_value[0]
assert actual == expected


@geth_process_test
def test_return_value_forked_network(geth_contract, geth_account, geth_provider):
network_name = geth_provider.network.name
geth_provider.network.name = "sepolia-fork"

try:
tx = geth_contract.getFilledArray.transact(sender=geth_account)
finally:
geth_provider.network.name = network_name

# NOTE: This is very important from a performance perspective!
# (VERY IMPORTANT). We should need to enrich anything.
assert tx.trace._enriched_calltree is None
assert trace._enriched_calltree is None

0 comments on commit bce1824

Please sign in to comment.