Skip to content

[r3.5] cmd/utils: fix allow snapshots reset on upgraded datadirs by restricting table config#22291

Merged
AskAlexSharov merged 1 commit into
erigontech:release/3.5from
Sahil-4555:fix/3.5-snapshots-reset-old-datadir
Jul 8, 2026
Merged

[r3.5] cmd/utils: fix allow snapshots reset on upgraded datadirs by restricting table config#22291
AskAlexSharov merged 1 commit into
erigontech:release/3.5from
Sahil-4555:fix/3.5-snapshots-reset-old-datadir

Conversation

@Sahil-4555

Copy link
Copy Markdown
Collaborator

cherry pick of #22281 in release/3.5

…config (erigontech#22281)

### Issue

Basically, when upgrading Erigon (for example, from v3.4.1 to v3.5.0),
we introduce new tables to the schema. The
[getChainNameFromChainData](https://github.com/erigontech/erigon/blob/main/cmd/utils/app/reset-datadir.go#L148)
helper is called by the `snapshots reset` command to automatically read
the chain name from the database. It opens the database with
`Accede(true)` and `Readonly(true)` options.

But since it was using the default `ChainDB` configuration, it tried to
validate the existence of all ~138 tables registered in the schema.
Because migrations have not run yet on the upgraded datadir, newly added
tables (like `BuilderPendingPayments` or `AccountHistoryKeys`) are
physically missing. In Accede mode, MDBX cannot create missing tables,
so the database open fails and the reset command crashes with a
misleading error about the chain flag not being set.

### Fix

To fix this, we need to decouple this simple metadata lookup from the
rest of the database schema. The helper only needs to read the genesis
canonical hash and the chain config JSON.

We have modified the database open call in
[getChainNameFromChainData](https://github.com/erigontech/erigon/blob/main/cmd/utils/app/reset-datadir.go#L148)
to use `WithTableCfg`. This allows us to pass a minimal table
configuration containing only the
[HeaderCanonical](https://github.com/erigontech/erigon/blob/main/db/kv/tables.go#L332)
and
[ConfigTable](https://github.com/erigontech/erigon/blob/main/db/kv/tables.go#L321)
tables. Now, it only checks for these two metadata tables and safely
ignores any other execution-layer tables.

Closes: erigontech#22275
@yperbasis yperbasis added this to the 3.5.1 milestone Jul 7, 2026
@AskAlexSharov AskAlexSharov merged commit 3dd6d56 into erigontech:release/3.5 Jul 8, 2026
87 checks passed
@Sahil-4555 Sahil-4555 deleted the fix/3.5-snapshots-reset-old-datadir branch July 8, 2026 03:31
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