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

fix(anvil): update blockhash in db #2598

Merged
merged 2 commits into from
Aug 4, 2022

Conversation

mattsse
Copy link
Member

@mattsse mattsse commented Aug 3, 2022

Motivation

the test introduced in #2524 makes use of roll cheatcode, first by

vm.roll(block.number - numUpdates);

then simulates mining by

for(uint i = 0; i < numUpdates; i++) {
   vm.roll(block.number + 1);
   hashChecker.update();
}

which does blockhash(block.number - 1)

this highlighted a problem with block hashes in anvil that were not updated internally in the Db

this meant that if a tx requires a hash for a block that was already mined by anvil but is now missing in the DB's internal storage it will try to query it from the endpoint but if there's no new block it will return the 0 hash blockhash(block.number - 1)

Solution

manually insert the new blockhash in the db after mining a new block

@mattsse mattsse added T-bug Type: bug C-anvil Command: anvil labels Aug 3, 2022
@mattsse mattsse merged commit e5fa7fa into foundry-rs:master Aug 4, 2022
iFrostizz pushed a commit to iFrostizz/foundry that referenced this pull request Nov 9, 2022
* fix: pin fork block number in test

* fix(anvil): update new blockhashes in db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil T-bug Type: bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants