Appearance
Import state from reth
This page tells you how to build the first Cinder database from the database of a synced reth node. Cinder cannot sync from genesis. At the end you have a Cinder database with the state of one block.
Before you start
- A Cinder build. See Install Cinder.
- A synced reth 2.x node with the default "storage v2" database layout. Reth can continue to run during the import.
- The HTTP JSON-RPC API of that reth node, with the
ethanddebugnamespaces. The default URL ishttp://127.0.0.1:8545. - Free disk space for the Cinder database: an NVMe SSD of 2 TB is recommended. Read Disk for the size and the growth. The import stops if less than 64 GB of disk space stays free.
Steps
Check the import options.
bashbuild/release/bin/cinder-import --helpOutput
textusage: cinder-import --reth-db DIR --db OUT [--rpc URL] [--check-only] [--force] [--page-size BYTES]--reth-dbis thedbdirectory in the reth data directory.--dbis a new, empty directory for Cinder.--rpcis the HTTP JSON-RPC URL of the same reth node. For all options, see the command line reference.Do only the checks first. With
--check-only, the tool compares sample accounts with the answers of the reth RPC at the last block that reth finished, and then stops.bashbuild/release/bin/cinder-import --reth-db /path/to/reth/datadir/db --db ./cinder-data --rpc http://127.0.0.1:8545 --check-onlyOutput
If the tool cannot open the reth database, it prints this and stops:
textcannot open reth database at /path/to/reth/datadir/dbThis is a description, not captured output. If the path is right, the tool prints the snapshot block, its state root and the size of the reth tables. Then it prints one line for each sample account and this last line:
textpre-flight: N accounts, M slots checked against RPC at block B, 0 problemsIf the number of problems is not 0, do not import. Find the cause first.
Run the import.
bashbuild/release/bin/cinder-import --reth-db /path/to/reth/datadir/db --db ./cinder-data --rpc http://127.0.0.1:8545Output
Example. The format comes from the code. The values come from the v0.2 import record (block 26063014).
The tool prints a progress line at least every 30 seconds. At the end it prints one line for the imported block and one line for the check of the state root:
textreth snapshot: block 26063014 0x... state root 0x... 420909751 accounts, 1659034272 storage slots, 2798063 bytecodes ... state: 420909751 accounts, 1659034272 slots in ... s imported block 26063014: 420909751 accounts, 1659034272 slots, 2798063 bytecodes, 256 headers in ... s state root 0x... matches the headerThe import does these steps:
- It opens the reth database read-only, so reth can continue to run. It reads all of the state in one snapshot, at the last block that reth finished.
- It runs the checks of step 2. If a check fails, it stops.
- It compares the free disk space with an estimate of the database size. If the space is too small, it stops.
- It copies the accounts, storage slots and bytecodes, and builds the tries again.
- It computes the state root and compares it with the root in the block header. It writes the database head only if the two roots are equal.
On mainnet, the import took about 3 hours. While the import runs, the reth database file grows, because the import keeps its read snapshot open. To import again, delete the Cinder database directory first.
Check the database (optional)
Shadow mode follows the reth node over JSON-RPC. It executes each new block against the Cinder database and compares the result with the block header. With --receipts, it also compares each receipt with the receipts of reth. This check is optional. Do it to find a wrong import before you connect a consensus client.
Run shadow mode for three blocks.
bashbuild/release/bin/cinder --shadow --db ./cinder-data --rpc http://127.0.0.1:8545 --threads 8 --receipts --blocks 3Output
Example. The format comes from the code. The values are not from a captured run, so they show as
....The node prints one line for each block, then one summary line:
textblock B txs ... gas ...M exec ... ms root ... ms commit ... ms (N behind) block B+1 txs ... gas ...M exec ... ms root ... ms commit ... ms (N behind) block B+2 txs ... gas ...M exec ... ms root ... ms commit ... ms (N behind) 3 blocks, ... Mgas: exec ... ms/block, root ... ms/block, commit ... ms/block; ... s totalShadow mode stays two blocks behind reth. It writes each block to the Cinder database. It stops on the first difference and prints the block number and the cause. Without
--blocks, it runs until you press Ctrl-C. Press Ctrl-C between two blocks.
For more on shadow mode, see Engine mode and shadow mode.