Skip to content

Commit

Permalink
call _reset_fork before txn simulation
Browse files Browse the repository at this point in the history
to minimize the chance of divergence between fork and reality
  • Loading branch information
charles-cooper committed Jul 23, 2024
1 parent f9798b6 commit ed798eb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions boa/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ def execute_code(
is_modifying=True,
ir_executor=None, # maybe just have **kwargs to collect extra kwargs
):
if is_modifying:
# reset to latest block for code simulation
self._reset_fork()

# 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
Expand Down Expand Up @@ -351,6 +355,10 @@ def execute_code(

# OVERRIDES
def deploy(self, sender=None, gas=None, value=0, bytecode=b"", **kwargs):
# reset to latest block for simulation
self._reset_fork()

# simulate the deployment
local_address, computation = super().deploy(
sender=sender, gas=gas, value=value, bytecode=bytecode
)
Expand Down

0 comments on commit ed798eb

Please sign in to comment.