Nodeos provides various options for replaying blockchain blocks. This can be useful if, for example, a node has downloaded a blocks.log
file from the internet (as a faster alternative to synchronizing from the p2p network) and the node wants to use it to quickly catch up with the network, or if you want to know the chain state at specified points in a blockchain's life.
Replaying data can be done in two ways:
- From a
blocks.log
file:
Theblocks.log
file contains all irreversible transactions on the blockchain. All instances ofnodeos
write irreversible blocks to theblocks.log
file, which is located at thedata/blocks
directory relative to thenodeos
directory. Using ablocks.log
file to replay will allow you to start anodeos
instance, which recreates the entire history of the blockchain locally, without adding unnecessary load to the network. - From a snapshot file:
Snapshot files can be created from a runningnodeos
instance. The snapshot contains the chain state for the block referenced when created. It is recommended to use snapshot files created from blocks that are irreversible. Using a snapshot file to replay allows you to quickly start anodeos
instance which has a full and correct chain state at a specified block number, but not a full history of transactions up to that block number. From that point on thenodeos
instance will operate in the configured manner.
Replay How-Tos
- How To Generate a Blocks Log
- How To Generate a Snapshot
- How To Replay from a Blocks Log
- How to Replay from a Snapshot
Replay Snapshot-specific Options
Typing nodeos --help
on the command line will show you all the options available for running nodeos
. The snapshot and replay specific options are:
- --force-all-checks
The node operator may not trust the source of theblocks.log
file and may want to runnodeos
with--replay-blockchain --force-all-checks
the first time to make sure the blocks are good. The--force-all-checks
flag can be passed intonodeos
to tell it to not skip any checks during replay. - --disable-replay-opts
By default, during replay,nodeos
does not create a stack of chain state deltas (this stack is used to enable rollback of state for reversible blocks.) This is a replay performance optimization. Using this option turns off this replay optimization and creates a stack of chain state deltas. If you are using the state history plugin you must use this option. - --replay-blockchain
This option tellsnodeos
to replay from theblocks.log
file located in the data/blocks directory.nodeos
will clear the chain state and replay all blocks. - --hard-replay-blockchain
This option tellsnodeos
to replay from theblocks.log
file located in the data/blocks directory.nodeos
makes a backup of the existingblocks.log
file and will then clear the chain state and replay all blocks. This option assumes that the backupblocks.log
file may contain corrupted blocks, sonodeos
replays as many blocks as possible from the backup block log. Whennodeos
finds the first corrupted block while replying fromnodeos.log
it will synchronize the rest of the blockchain from the p2p network. - --delete-all-blocks
This tellsnodeos
to clear the local chain state and local theblocks.log
file, If you intend to then synchronize from the p2p network you would need to provide a correctgenesis.json
file. This option is not recommended. - --truncate-at-block
Default argument (=0), only used if the given value is non-zero. Using this option when replaying the blockchain will force the replay to stop at the specified block number. This option will only work if replaying with the--hard-replay-blockchain
option, or, when not replaying, the--fix-reversible-blocks
option. The localnodeos
process will contain the chain state for that block. This option may be useful for checking blockchain state at specific points in time. It is intended for testing/validation and is not intended to be used when creating a localnodeos
instance which is synchronized with the network. - --snapshot
Use this option to specify which snapshot file to use to recreate the chain state from a snapshot file. This option will not replay theblocks.log
file. Thenodeos
instance will not know the full transaction history of the blockchain. - --snapshots-dir
You can use this to specify the location of the snapshot file directory (absolute path or relative to application data dir.) - --blocks-dir
You can use this to specify the location of theblocks.log
file directory (absolute path or relative to application data dir)