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

Negative block number queried when forked network block number is near zero #4131

Conversation

ChristopherDedominici
Copy link
Contributor

The code line: const lastSafeBlock = latestBlock - maxReorg; could result in a negative value when maxReorg > latestBlock.
Fix: add check, when the difference is a negative number then use latestBlock.

@ChristopherDedominici ChristopherDedominici added type:bug Something isn't working no changeset needed This PR doesn't require a changeset labels Jul 11, 2023
@ChristopherDedominici ChristopherDedominici self-assigned this Jul 11, 2023
@changeset-bot
Copy link

changeset-bot bot commented Jul 11, 2023

🦋 Changeset detected

Latest commit: 092b771

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
hardhat Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Jul 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 13, 2023 3:33pm
hardhat-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 13, 2023 3:33pm

@ChristopherDedominici ChristopherDedominici marked this pull request as ready for review July 11, 2023 20:21
@fvictorio
Copy link
Member

@ChristopherDedominici can you add a changeset?

latestBlock: bigint,
maxReorg: bigint
): bigint {
// Design choice: if latestBlock - maxReorg gives a negative number than the newest block will be used
Copy link
Member

Choose a reason for hiding this comment

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

Let's explain that we do this because the forked network is almost surely a devnet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Jul 13, 2023
Merged via the queue into main with commit 93363c0 Jul 13, 2023
@ChristopherDedominici ChristopherDedominici deleted the bug/1568-negative-block-number-queried-when-forked-network-block-number-is-near-zero branch July 13, 2023 16:06
@ChristopherDedominici ChristopherDedominici removed no changeset needed This PR doesn't require a changeset status:triaging labels Jul 13, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Negative block number queried when forked network block number is near zero
2 participants