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. when moving from the deprecatedleveldbtorocksdb. -
--import: This indicates that the block database should be imported from published bootstrap data instead of being synced from peers. 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. when moving from the deprecatedleveldbtorocksdb.Import erases the database every time it runsA node started with import enabled deletes its database directory and downloads the bootstrap data again, even if it was fully synced a minute earlier. Run it as a one-off on the command line, and never leave
database.import.enabled = truein a configuration file.Reading the bootstrap data published today requires RSKj
VETIVER-9.0.4or later. For the full procedure, see Bootstrap a node using Import Sync.
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…