Skip to content

Conversation

@jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jul 3, 2025

When invoking debug_setHead to an old block, which is below the first stored state in ancient/state, it will panic the node:

DEBUG[07-02|03:47:07.813] Truncating freezer table                 database=/data/geth/chaindata/ancient/state table=account.data items=12113 limit=12112
DEBUG[07-02|03:47:07.816] Recovered state                          root=91407a..75d38d elapsed=25.012ms
INFO [07-02|03:47:07.816] Rewound to block with state              number=718,987 hash=38e13f..f90373
INFO [07-02|03:47:07.816] Disabled trie database due to state sync
DEBUG[07-02|03:47:07.816] Backfilling with the network             mode=snap
CRIT [07-02|03:47:07.816] Failed to rollback state                 err="waiting for sync"

after the fix, now it won't let debug_setHead to rewind to an older block:

> debug.setHead('0x1')
WARN [07-03|10:23:34.893] Served debug_setHead                     reqid=10 duration="143.792µs" err="cannot rewind to block 1, oldest available state is at block 446"
Error: cannot rewind to block 1, oldest available state is at block 446
	at web3.js:6020:9(39)
	at send (web3.js:5105:62(29))
	at <eval>:1:14(3)

@rjl493456442 rjl493456442 self-assigned this Jul 3, 2025
@rjl493456442
Copy link
Member

it will panic the node:

Can you provide more logs before the panic?

@jsvisa jsvisa force-pushed the setHead-block-check branch from 60a3902 to ddc42b8 Compare September 11, 2025 16:19
@jsvisa
Copy link
Contributor Author

jsvisa commented Sep 11, 2025

@rjl493456442 sorry for the delay response.

If we reset head to a block older than the state freezer's tail state, seems it will not panic currently(maybe fixed in recent pathdb updates), but it will reset the chain to stateless, here is an example.

  1. run geth --dev --history.state=1000
  2. debug set Head to latest block - 1100
INFO [09-11|16:11:06.976] Truncating from head                     ohead=3963 tail=3961 nhead=3962
INFO [09-11|16:11:06.988] Rewound to block with state              number=3961 hash=47c7c0..0f16ef
INFO [09-11|16:11:06.989] Truncating from head                     ohead=3962 tail=3961 nhead=3961
INFO [09-11|16:11:07.002] Rewound to block with state              number=3960 hash=08fafb..486fa0
INFO [09-11|16:11:07.053] Genesis block reached                    number=0    hash=d560b1..c69f8f
INFO [09-11|16:11:07.053] Chain is stateless, wait state sync      number=0    hash=d560b1..c69f8f
WARN [09-11|16:11:07.053] Force rewinding till ancient limit       head=0
ERROR[09-11|16:11:07.199] Missing block in the middle, resetting to genesis number=18,446,744,073,709,551,615 hash=000000..000000
INFO [09-11|16:11:07.199] Chain is stateless, wait state sync      number=0                          hash=d560b1..c69f8f
WARN [09-11|16:11:07.209] Truncating freezer table                 database=/md1/geth-dev/geth/chaindata/ancient/chain table=hashes items=4501 limit=1
WARN [09-11|16:11:07.212] Truncating freezer table                 database=/md1/geth-dev/geth/chaindata/ancient/chain table=bodies items=4501 limit=1
WARN [09-11|16:11:07.215] Truncating freezer table                 database=/md1/geth-dev/geth/chaindata/ancient/chain table=receipts items=4501 limit=1
WARN [09-11|16:11:07.217] Truncating freezer table                 database=/md1/geth-dev/geth/chaindata/ancient/chain table=headers items=4501 limit=1
WARN [09-11|16:11:07.220] SetHead invalidated safe block
ERROR[09-11|16:11:07.220] SetHead invalidated finalized block
INFO [09-11|16:11:07.221] Loaded most recent local block           number=0                          hash=d560b1..c69f8f age=56y6mo2d
ERROR[09-11|16:11:07.221] Failed to reset txpool state             err="missing trie node 20d8452ff7af5031fcea768ce6814cf2b0927efb8dc40fc5ab7194ced0724061 (path ) state 0x20d8452ff7af5031fcea768ce6814cf2b0927efb8dc40fc5ab7194ced0724061 is not available"
null
> ERROR[09-11|16:11:07.221] Failed to reset txpool state             err="missing trie node 20d8452ff7af5031fcea768ce6814cf2b0927efb8dc40fc5ab7194ced0724061 (path ) state 0x20d8452ff7af5031fcea768ce6814cf2b0927efb8dc40fc5ab7194ced0724061 is not available"
ERROR[09-11|16:11:07.221] Failed to reset blobpool state           err="missing trie node 20d8452ff7af5031fcea768ce6814cf2b0927efb8dc40fc5ab7194ced0724061 (path ) state 0x20d8452ff7af5031fcea768ce6814cf2b0927efb8dc40fc5ab7194ced0724061 is not available"
> eth.blockNumber
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants