Skip to content

Commit

Permalink
set prefetch state default to true only in network mode
Browse files Browse the repository at this point in the history
default to false in regular fork mode (it introduces an overhead on
every call which might be worse than just fetching storage lazily)
  • Loading branch information
charles-cooper committed Oct 27, 2023
1 parent 0fbb34f commit b5e9fb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions boa/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ class Env:
_coverage_enabled = False
_fast_mode_enabled = False
_fork_mode = False
_fork_try_prefetch_state = True
_fork_try_prefetch_state = False

def __init__(self):
self.chain = _make_chain()
Expand Down Expand Up @@ -686,7 +686,7 @@ def execute_code(
ir_executor=ir_executor,
contract=contract,
)
if self._fork_mode:
if self._fork_mode and self._fork_try_prefetch_state:
self.vm.state._account_db.try_prefetch_state(msg)

origin = sender # XXX: consider making this parametrizable
Expand Down
5 changes: 5 additions & 0 deletions boa/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class NetworkEnv(Env):
mutable functions and contract creation via eth_sendRawTransaction.
"""

# always prefetch state in network mode
_fork_try_prefetch_state = True

def __init__(self, rpc_url, accounts=None):
super().__init__()

Expand Down Expand Up @@ -190,6 +193,8 @@ def execute_code(
ir_executor=None, # maybe just have **kwargs to collect extra kwargs
):
# call execute_code for tracing side effects
# note: we could get a perf improvement if we ran this in
# the background while waiting on RPC network calls
computation = super().execute_code(
to_address=to_address,
sender=sender,
Expand Down

0 comments on commit b5e9fb9

Please sign in to comment.