Skip to content

Conversation

@jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jun 18, 2025

allow write trie journal into a local file instead of disk, used when the trie jounral is >= 4GB, ref gballet#546 (comment)

@jsvisa jsvisa requested a review from rjl493456442 as a code owner June 18, 2025 08:01
@rjl493456442 rjl493456442 self-assigned this Jun 18, 2025
@fjl
Copy link
Contributor

fjl commented Jun 24, 2025

The idea is good, but the path should not be configurable. We should just resolve the path in the datadir and store the file there unconditionally.

@fjl fjl removed the status:triage label Jun 24, 2025
@jsvisa jsvisa force-pushed the journal-into-file branch from 9abf10a to 516c1b3 Compare June 25, 2025 07:04
@rjl493456442
Copy link
Member

rjl493456442 commented Jun 27, 2025

This pull request is backward-compatible:

  • Upgrade from old version, the journal will be resolved from database and persist into file
  • Downgrade to old version, Geth will attempt to resolve journal from database only and drop in-memory layers if not matched

The journal directory will be $DATADIR/triedb, with $DATADIR/triedb/merkle.journal for legacy merkle trie database and $DATADIR/triedb/verkle.journal for verkle respectively.

@rjl493456442
Copy link
Member

logs:

INFO [06-27|14:17:56.460] Load database journal from file          path=/home/gary/eth-sepolia/el/geth/triedb/merkle.journal

...

INFO [06-27|14:21:04.978] Persisting dirty state                   head=5,276,356 root=b0d1cb..19ba68 layers=1551
INFO [06-27|14:21:06.556] Persisted dirty state to file            path=/home/gary/eth-sepolia/el/geth/triedb/merkle.journal size=342.21MiB elapsed=1.578s

rjl493456442
rjl493456442 previously approved these changes Jun 27, 2025
Copy link
Member

@rjl493456442 rjl493456442 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

jsvisa and others added 15 commits July 1, 2025 10:09
* all: load/dump trie disklayer into file

Signed-off-by: jsvisa <delweng@gmail.com>

* cmd: set cache.trie.journal=trie-disklayer.rlp as default

Signed-off-by: jsvisa <delweng@gmail.com>

* journal: directly write into file

Signed-off-by: jsvisa <delweng@gmail.com>

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
Signed-off-by: jsvisa <delweng@gmail.com>
rjl493456442
rjl493456442 previously approved these changes Jul 1, 2025
@rjl493456442 rjl493456442 changed the title trie: write trie journal into disk triedb/pathdb: introduce file-based state journal Jul 1, 2025
@rjl493456442 rjl493456442 added this to the 1.16.1 milestone Jul 1, 2025
@fjl fjl modified the milestones: 1.16.1, 1.16.2 Jul 2, 2025
@rjl493456442 rjl493456442 merged commit 17903fe into ethereum:master Jul 15, 2025
2 of 3 checks passed
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 2025
Introduce file-based state journal in path database, fixing
the Pebble restriction when the journal size exceeds 4GB.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
rjl493456442 pushed a commit that referenced this pull request Sep 5, 2025
As in #32060 we introduced the file based journal path, for the other
sub command(eg: snapshot, db), we should also pass the directory to the
triedb, else the subcommand(eg: `geth snapshot`) failed to run:

```bash
geth snapshot verify-state --datadir /geth-data
...
INFO [09-02|02:12:29.493] Allocated cache and file handles         database=/geth-data/geth/chaindata cache=512.00MiB handles=524,288
INFO [09-02|02:12:32.746] Opened ancient database                  database=/geth-data/geth/chaindata/ancient/chain readonly=true
INFO [09-02|02:12:32.746] Opened Era store                         datadir=/geth-data/geth/chaindata/ancient/chain/era
INFO [09-02|02:12:32.758] State scheme set to already existing     scheme=path
INFO [09-02|02:12:32.760] Load database journal from disk
INFO [09-02|02:12:32.764] Failed to load journal, discard it       err="journal not found"
INFO [09-02|02:12:32.789] Opened ancient database                  database=/geth-data/geth/chaindata/ancient/state readonly=true
INFO [09-02|02:12:32.790] Initialized path database                readonly=true triecache=0.00B statecache=0.00B buffer=0.00B history="entire chain"
ERROR[09-02|02:12:32.791] Failed to verify state                   root=c5458d..4cc785 err="unknown layer: c5458d476da0136a67ef24a93b909aa5c29efa5c5b885dbd1fbaed4e784cc785"
```
gballet pushed a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
Introduce file-based state journal in path database, fixing
the Pebble restriction when the journal size exceeds 4GB.

---------

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Sahil-4555 pushed a commit to Sahil-4555/go-ethereum that referenced this pull request Oct 12, 2025
As in ethereum#32060 we introduced the file based journal path, for the other
sub command(eg: snapshot, db), we should also pass the directory to the
triedb, else the subcommand(eg: `geth snapshot`) failed to run:

```bash
geth snapshot verify-state --datadir /geth-data
...
INFO [09-02|02:12:29.493] Allocated cache and file handles         database=/geth-data/geth/chaindata cache=512.00MiB handles=524,288
INFO [09-02|02:12:32.746] Opened ancient database                  database=/geth-data/geth/chaindata/ancient/chain readonly=true
INFO [09-02|02:12:32.746] Opened Era store                         datadir=/geth-data/geth/chaindata/ancient/chain/era
INFO [09-02|02:12:32.758] State scheme set to already existing     scheme=path
INFO [09-02|02:12:32.760] Load database journal from disk
INFO [09-02|02:12:32.764] Failed to load journal, discard it       err="journal not found"
INFO [09-02|02:12:32.789] Opened ancient database                  database=/geth-data/geth/chaindata/ancient/state readonly=true
INFO [09-02|02:12:32.790] Initialized path database                readonly=true triecache=0.00B statecache=0.00B buffer=0.00B history="entire chain"
ERROR[09-02|02:12:32.791] Failed to verify state                   root=c5458d..4cc785 err="unknown layer: c5458d476da0136a67ef24a93b909aa5c29efa5c5b885dbd1fbaed4e784cc785"
```
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