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 blocks with same timestamp as previous block #9142

Closed
domob1812 opened this issue Oct 19, 2024 · 4 comments · Fixed by #9160
Closed

feat(anvil): Support mining blocks with same timestamp as previous block #9142

domob1812 opened this issue Oct 19, 2024 · 4 comments · Fixed by #9160
Assignees
Labels
C-anvil Command: anvil T-feature Type: feature

Comments

@domob1812
Copy link

Component

Anvil

Describe the feature you would like

As far as I am aware, EVM chains can support that a block has the same timestamp as a previous block, as that is required to support sub-second block times. It seems that anvil does not allow me to mine a block with the same timestamp as the previous block's (with evm_mine), as it then complains with:

Timestamp error: 1600000100 is lower than or equal to previous block's timestamp

I think it would be helpful to support this, so that we can actually test smart contracts handle a situation like this correctly (in case there is subtle time-dependent logic contained in them).

Additional context

No response

@domob1812 domob1812 added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels Oct 19, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Oct 19, 2024
@grandizzy
Copy link
Collaborator

@domob1812 I think this scenario should be solved with #7931 and set --block-time to 0

@zerosnacks zerosnacks added C-anvil Command: anvil and removed T-needs-triage Type: this issue needs to be labelled labels Oct 21, 2024
@yash-atreya yash-atreya self-assigned this Oct 21, 2024
@yash-atreya yash-atreya moved this from Todo to Ready For Review in Foundry Oct 22, 2024
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Foundry Oct 23, 2024
@yash-atreya
Copy link
Member

@domob1812 This is now supported

@Rubilmax
Copy link
Contributor

Rubilmax commented Oct 24, 2024

I'm not sure it is related to this issue, but with the latest version of anvil, with auto mining, there are now some transactions that are mined in a new block with the same timestamp as the previous one (without tweaking anything in anvil)

EDIT: if I call setBlockTimestampInterval with interval 1 then it reverts to the expected behavior of block timestamp interval of 1s

@grandizzy
Copy link
Collaborator

@Rubilmax mind to open a ticket with a way to reproduce the problem you see? thank you!

@grandizzy grandizzy moved this from Done to Completed in Foundry Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil T-feature Type: feature
Projects
Status: Completed
5 participants