Command Line Interface
Command line (CLI) arguments are arguments specified after the RSK start class. See Config Options
New entry points (Java classes with static public main method) have been included from the RSK Hop Release v4.3.0.
The CLI arguments have two forms; the parameter and the flag:
- Parameter
- Has a name and an associated value, separated by a space
- Starts with a dash
- Flag
- It's a single text, without spaces
- Starts with a double dash
Find below a list of CLI flags and parameters available:
Parameters and Flags
Network related
The following CLI flags determine which network the Rootstock (RSK) node will connect to.
--main: This indicates that the configuration for the Rootstock Mainnet (public network) should be used.--testnet: This indicates that the configuration for the Rootstock Testnet (public network) should be used.--regtest: This indicates that the configuration for the Rootstock Regtest (localhost network) should be used.- Example:
java -cp rsk-core-<VERSION>.jar co.rsk.start --regtest
- Example:
- Only one of these three CLI flags should be specified.
- When none of these are specified, Rootstock Mainnet is used by default.
Database related
The Rootstock (RSK) node stores transactions, blocks, and other blockchain state on disk. This is known as the Blockchain Database.
-
--reset: This indicates that the block database should be erased, and should start from scratch, i.e. from genesis block. This is typically expected to be used when connecting to Rootstock Regtest, or in select debugging scenarios. It is also used when switching between different databases, e.g. betweenleveldbandrocksdb. -
--import: This indicates that the block database should be imported from an external source. This is typically expected to be used when connecting to Rootstock Testnet or Rootstock Mainnet, and when a reduction in "initial sync time" is desired. It is also used when switching between different databases, e.g. betweenleveldbandrocksdb.
Configuration related
--verify-config: This indicates that the configuration file used by this run of the Rootstock node should be validated. By default this step is always performed.--print-system-info: This indicates that the system information of the computer that the Rootstock node is running on should be output. By default, this is always output.--skip-java-check: This indicates that the detection of the version of the Java Virtual Machine that the Rootstock node is running in is supported. By default, this check is always performed, to ensure that the Rootstock node is running in a compatible environment.-base-path: This specifies the value ofdatabase.dir, where the blockchain database is stored.
Example:
java -cp rsk-core-<VERSION>.jar co.rsk.start -base-path home/rsk/data
-rpccorsThis specifies the value ofrpc.providers.web.corsto controlcors configuration.
Example:
java -cp rsk-core-<VERSION>.jar co.rsk.start -rpccors *
Command Line Tools
It worth highlight that for some commands below that interacts with the database, you might and should set the network flag desired, like
--regtest, --testnet or --main. Otherwise, the default network will be used, which is the Rootstock Mainnet (public network).
Database related commands
ExportState
The ExportState command is a tool for exporting the state at a specific block in the Rootstock blockchain to a file.
Usage:
java -cp rsk.jar co.rsk.cli.tools.ExportState -b <block_number> -f <file_path> --<network_flag>
Options:
-
-b, --block: The block number to export the state from. -
-f, --file: The path to a file to export the state to.
Example:
In this example, the state information of block 2000 will be exported to the file “test.txt” on the regtest network.
java -cp rsk.jar co.rsk.cli.tools.ExportState -b 2000 -f test.txt --regtest
Output:
INFO [clitool] [main] ExportState started
INFO [o.e.d.CacheSnapshotHandler] [main] Loaded 194912 cache entries from 'unitrie/rskcache'
INFO [clitool] [main] ExportState finished
INFO [o.e.d.CacheSnapshotHandler] [main] Saved 194912 cache entries in 'unitrie/rskcache'
The “test.txt” should look like this:
5c0700caa04b0e28aa38d3d4a74a560332c38111cb1ac2292a89512d009658d2a7ed7d2cecc372b5c25799434b1cc5e49d795fc371db88e3d0c3635e273fc3c496b897fdc60c
4ce5c4861124fac10fdda43f62df4cf8137136e4c654305a8e9e3572f76b46c9fd9ce59676
…etc
ExportBlocks
The ExportBlocks command is a tool for exporting blocks from a specific block range to a file.
The tool retrieves the block range and exports each block in the range to a specified file.
Usage:
java -cp rsk.jar co.rsk.cli.tools.ExportBlocks -fb <from_block_number> -tb <to_block_number> -f <file_path>
Options:
-fb, --fromBlock: The block number to start exporting from.-tb, --toBlock: The block number to stop exporting.
Example:
In this example, the blocks from block 2000 to block 3000 will be exported to the specified file.
java -cp rsk.jar co.rsk.cli.tools.ExportBlocks -fb 2000 -tb 3000 -f test-blocks.txt
Output:
2023-04-24-16:23:25.0897 INFO [clitool] [main] ExportBlocks started
2023-04-24-16:23:26.0373 INFO [clitool] [main] ExportBlocks finished
Blocks.txt should show the following:
50,d6c7a4388337d931d9478e742c34c276cefe0976e12b2f7077bd6664b6ecc163,0629fdd6…
51,d4a9091304e64008f06c395b4f26da1c710bdd83f30f0d15666826b57c9b7a1e,0651fde4b…
…
99,92c333550ada4b2588d957155f1aa130ef0092b9499d575a3e4034e1f3f20926,0f271cc73…
100,b445214290eb98e1e066713aa8a76ff4282c7890d232471d62be5932d21f25b8,0f57a…
Configuration related commands
StartBootstrap
The StartBootcamp command starts a bootstrap node with one service, which only participates in the peer discovery protocol.
Example:
java -cp rsk.jar co.rsk.cli.tools.StartBootstrap
Output:
2023-04-24-15:51:14.0793 INFO [fullnoderunner] [main] Starting RSK
2023-04-24-15:51:14.0794 INFO [fullnoderunner] [main] Running orchid-testnet.json,
core version: 5.1.0-SNAPSHOT
....
RewindBlocks
The RewindBlocks command is used to rewind the Rootstock blockchain to a specific block. It can also be used to find and print the minimum inconsistent block (a block with missing state in the states database).
Example:
java -cp rsk.jar co.rsk.cli.tools.RewindBlocks [-b <BLOCK_NUMBER>] [-fmi] (or) [-rbc] --<network_flag>
Options:
-b, --block=BLOCK_NUMBER_TO_REWIND_TOblock number to rewind blocks to.-fmi, --findMinInconsistentBlockflag to find a min inconsistent block. The default value isfalse.-rbc, --rewindToBestConsistentBlockflag to rewind to the best consistent block. The default value isfalse.-
- An inconsistent block is the one with missing state in the states db (this can happen in case of improper node shutdown).
fmioption can be used for finding a minimum inconsistent block number and printing it to stdout. It will print -1, if no such block is found.rbcoption does two things: it looks for a minimum inconsistent block and, if there's such, rewinds blocks from top one till the found one.- Note that all three options are mutually exclusive, you can specify only one per call.
Example:
java -cp rsk.jar co.rsk.cli.tools.RewindBlocks -b 2000 —regtest
Output:
INFO [clitool] [main] RewindBlocks started
INFO [clitool] [main] Highest block number stored in db: 49703
INFO [clitool] [main] Block number to rewind to: 2000
INFO [clitool] [main] Rewinding...
INFO [clitool] [main] Done
INFO [clitool] [main] New highest block number stored in db: 2000
INFO [clitool] [main] RewindBlocks finished
DbMigrate
The DbMigrate command is a tool for migrating between different databases such as leveldb and rocksdb.
Usage:
java -cp rsk.jar co.rsk.cli.tools.DbMigrate -t <target_database>
Options:
-t, --targetDb: The target database to migrate to. (“leveldb” or “rocksdb”).
Example:
In this example, the current database will be migrated from leveldb to rocksdb.
java -cp rsk.jar co.rsk.cli.tools.DbMigrate -t rocksdb
Output:
INFO [clitool] [main] DbMigrate started
INFO [clitool] [main] DbMigrate finished
If the target database is the same as the one working on the node, the node will throw an error: Cannot migrate to the same database, current db is X_DB and target db is X_DB.