Skip to content

bug(anvil): persistent state seems to ignore timestamp changes #10331

Open
@pvgo80

Description

@pvgo80

Component

Anvil

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.3.0 (a5c5be5 2025-01-06T00:23:40.588668993Z)

What version of Foundryup are you on?

No response

What command(s) is the bug in?

anvil --fork-url https://mainnet.swell-rpc.com --state a --state-interval 10 --chain-id 7566690 --auto-impersonate --fork-block-number 5672511

Operating System

None

Describe the bug

Newer blocks after restarting anvil ignore the previous block timestamp.

Steps to reproduce:

# anvil --fork-url https://mainnet.swell-rpc.com --state a --state-interval 10 --chain-id 7566690 --auto-impersonate --fork-block-number 5672511

❯ cast age latest
Mon Apr  7 16:02:05 2025

❯ cast rpc evm_setNextBlockTimestamp $(date +%s)
null

❯ cast rpc anvil_mine
null

❯ cast age latest
Thu Apr 17 19:33:45 2025

❯ cast block

hash                 0xdf0ac0c25c0fb9887b1d4297fcc9137e08e80851ad062524b9b848ad7ffde33b
number               5672512
parentHash           0x232db3a3b42961dbada3599779554acd5c0514a03c17310b91461dca9a82457d
timestamp            1744918425 (Thu, 17 Apr 2025 19:33:45 +0000)

# (anvil restart) anvil --fork-url https://mainnet.swell-rpc.com --state a --state-interval 10 --chain-id 7566690 --auto-impersonate --fork-block-number 5672511

❯ cast block

hash                 0xdf0ac0c25c0fb9887b1d4297fcc9137e08e80851ad062524b9b848ad7ffde33b
number               5672512
parentHash           0x232db3a3b42961dbada3599779554acd5c0514a03c17310b91461dca9a82457d
timestamp            1744918425 (Thu, 17 Apr 2025 19:33:45 +0000)

❯ cast age latest
Thu Apr 17 19:33:45 2025

❯ cast rpc anvil_mine
null

❯ cast age latest
Mon Apr  7 16:02:34 2025

❯ cast block

hash                 0x211e24b15071c2e1a36d26287e05ed890fdf0138e8b99d1fd5140a5bbb39ae43
number               5672513
parentHash           0xdf0ac0c25c0fb9887b1d4297fcc9137e08e80851ad062524b9b848ad7ffde33b
timestamp            1744041754 (Mon, 7 Apr 2025 16:02:34 +0000)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions