Skip to content

Util DB

Petr Hanzl edited this page Oct 30, 2023 · 3 revisions

Util Db

Overview

Is a util tool to update, manage and generate AidaDb.

aida-db

AidaDb

AidaDb contains Substates, Update sets, Deleted accounts and State Hashes.

Classification

TODO

Requirements

You need a configured Go language environment to build the CLI application. Please check the Go documentation for the details of installing the language compiler on your system.

As of right now (July 17. 2023), AidaDb from block 0 to block 67884823 requires ~860Gb of free space.

Build

To build the util-db application, run make util-db.

Easiest way to download latest AidaDb is to use update tool like this:

./build/util-db update --aida-db /path/to/future/aida-db --db-tmp /path/to/tmp --chainid 250

Note that you need around 860 Gb of free space for whole Db

The build process downloads all the needed modules and libraries, you don't need to install these manually. The util-db executable application will be created in /build folder.

Run

To use Util DB, execute the compiled binary with the command and flags for the desired operation.

./build/util-db command [command options] [arguments...]
command description
autogen Autogen generates aida-db periodically
clone Clone can create aida-db copy or subset
generate Generates aida-db from given events
merge Merge source databases into aida-db
stats Prints statistics about AidaDb

Stats Command

Prints statistics about AidaDb. The stats command requires one argument: <blockNunLast> - the last block of aida-db.

Available subcommands

subcommand description
all List of all records in AidaDb
del-acc Prints info about given deleted account in AidaDb. Requires arguments <firstBlockNum> and <lastBlockNum>
info Prints information about AidaDb

All subcommand

List of all records in AidaDb.

Options

all subcommand:
    --aida-db   set substate, updateset and deleted accounts directory
    --log       level of the logging of the app action ("critical", "error", "warning", "notice", "info", "debug"; default: INFO)

DelAcc subcommand

Prints info about given deleted account in AidaDb.

The DelAcc subcommand requires two arguments: <blockNumFirst> <blockNumLast>

<blockNumFirst> and <blockNumLast> are the first and last block of the inclusive range of blocks.

Options

del-acc subcommand:
    --aida-db   set substate, updateset and deleted accounts directory
    --account   wanted account
    --detailed  prints detailed info with how many records is in each prefix
    --log       level of the logging of the app action ("critical", "error", "warning", "notice", "info", "debug"; default: INFO)

Clone Command

Creates clone of aida-db for desired block range

Options

clone:
    --aida-db     path to existing AidaDb
    --target-db   path to a new CloneDb that is going to be created
    --compact     compact target database
    --validate    enables validation
    --log         level of the logging of the app action ("critical", "error", "warning", "notice", "info", "debug"; default: INFO)

AutoGen Command

Autogen generates aida-db patches and handles second opera for event generation. Generates event file, which is supplied into generate to create aida-db patch.

Options

autogen:
    --aida-db   path where AidaDb is going to be saved
    --chainid   choose chain id
    --db        path where OperaDb is going to be saved
    --compact   compact target database
    --genesis   path to genesis
    --db-tmp    sets the temporary directory where to place DB data; uses system default if empty
    --cache     cache limit
    --output    output path (where patches are going to get saved)
    --log       level of the logging of the app action ("critical", "error", "warning", "notice", "info", "debug"; default: INFO)

Generate Command

The db generate command requires events as an argument: <events>

<events> are fed into the opera database (either existing or genesis needs to be specified), processing them generates updated aida-db.

Options

generate:
    --aida-db   set substate, updateset and deleted accounts directory
    --db        path to the database
    --genesis   does not stop the program when results do not match
    --keep-db   if set, statedb is not deleted after run
    --compact   compact target database
    --db-tmp    sets the temporary directory where to place DB data; uses system default if empty
    --chainid   choose chain id
    --cache     cache limit
    --log       level of the logging of the app action ("critical", "error", "warning", "notice", "info", "debug"; default: INFO)

Merge Command

Creates target aida-db by merging source databases from arguments: <db1> [<db2> <db3> ...]

Options

merge:
    --aida-db           set substate, updateset and deleted accounts directory
    --delete-source-dbs   delete source databases while merging into one database
    --compact           compact target database
    --log               level of the logging of the app action ("critical", "error", "warning", "notice", "info", "debug"; default: INFO)

Info Command

Prints info about target aida-db.

Available subcommands

subcommand description
metadata Prints all AidaDb metadata.
del-acc Prints info about given deleted account in AidaDb. Requires arguments <firstBlockNum> and <lastBlockNum>
count Prints count of records
db-hash Prints db-hash (md5) inside AidaDb. If this value is not present in metadata it iterates through all of data
state-hash Prints state hash for given block number. Requires <blockNumber> as an argument

Options

info:
    --aida-db           set substate, updateset and deleted accounts directory