Skip to content

Conversation

@grandizzy
Copy link
Collaborator

Motivation

Closes #8168

Fork's block number and timestamp can be changed using vm.warp and vm.roll but they're not preserved in a multifork setup when a different fork is selected.

Solution

  • save current env block number and ts in active fork env

@grandizzy grandizzy marked this pull request as ready for review July 18, 2024 09:36
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

Comment on lines +305 to +312
/// Update fork block number and timestamp. Used to preserve values set by `roll` and `warp`
/// cheatcodes when new fork selected.
fn update_block(&mut self, fork_id: ForkId, block_number: U256, block_timestamp: U256) {
if let Some(fork) = self.forks.get_mut(&fork_id) {
fork.opts.env.block.number = block_number;
fork.opts.env.block.timestamp = block_timestamp;
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(forge): warp effect is reversed when switching back to original fork

2 participants