Node Databases

This page will describe the databases used by the Node. These are simple key-value storage units that will hold different types of data, as described below.

Databases​

Nodes use simple Key-Value type databases.

Nodes use Serial LevelDB databases to persist processed blocks, transactions, and so on.

Data retention can be controlled in config.toml using pruning flags. There are two flags for the latest versions:

  • ValidatorCleanOldEpochsData

  • ObserverCleanOldEpochsData

For older configurations, the single flag is:

  • CleanOldEpochsData

Setting these flags to false prevents the deletion of old databases.

By default, validators only keep the last 4 epochs and delete older ones for freeing disk space.

The default databases directory is <node-working-directory>/db and it's content should match the following structure:

/db
└── <chain id>
    β”œβ”€β”€ Epoch_X
    β”‚  └── Shard_X -------->
    β”‚        β”œβ”€β”€ BlockHeaders
    β”‚        β”‚    β”œβ”€β”€ 000001.log
    β”‚        β”‚    β”œβ”€β”€ CURRENT
    β”‚        β”‚    β”œβ”€β”€ LOCK
    β”‚        β”‚    β”œβ”€β”€ LOG
    β”‚        β”‚    └── MANIFEST-000000
    β”‚        β”œβ”€β”€ BootstrapData
    β”‚        β”‚    β”œβ”€β”€ 000001.log
    |     .............
    └── Static
        └── Shard_X -------->
            β”œβ”€β”€ AccountsTrie
            β”‚     └── MainDB
            β”‚           β”œβ”€β”€ 000001.log
         .............

During startup, nodes check for an existing database and sync any missing data from the network to match the current network height.

Starting a Node with Existing Databases

When both the configuration and the database shard match, the node inherits the full database state and needs to sync only the remaining items. For example, if a node starts with a database at epoch 255 and the current epoch is 256, it will sync only the missing epoch data.

The configuration of the new node should mirror that of the predecessor, with the exception of the BLS key, which does not depend on the database.

To expedite synchronization, it's possible to copy the fully synced database from another node. This process involves transferring the entire db/ directory from the source to the target node.

Last updated