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

feat(anvil): support mining with same block.timestamp #9160

Merged
merged 3 commits into from
Oct 23, 2024

Conversation

yash-atreya
Copy link
Member

Motivation

Closes #9142 + Closes #7931

Solution

Replace the check next_timestamp <= last_timestamp with next_timestamp < last_timestamp.

Anvil can now mine blocks with the same timestamp as the previous block timestamp. This aids in running forks or testing chains that have sub-second block times, wherein block.timestamp stays constant until exactly one second has passed.

Added relevant tests.

@yash-atreya
Copy link
Member Author

yash-atreya commented Oct 22, 2024

@mattsse this effectively undos the fix for #6096. See here:

assert!(block.header.timestamp >= latest_block.header.timestamp);
.

If users expect the next_block_timestamp after revert to be always greater than block.timestamp the snapshot was taken at, we can probably just add 1s here

let reset_time = block.header.timestamp;
while resetting. wdyt?

@yash-atreya yash-atreya merged commit 4d7435e into master Oct 23, 2024
21 checks passed
@yash-atreya yash-atreya deleted the yash/support-same-timestamp branch October 23, 2024 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
2 participants