[How-to] Convert Block level DB to ROCKS DB

This guide is intended for those who wish to convert from one DB format to another. The benefits are:
– You can use RocksDB as storage engine when you want to back up the database without the node application stopped,
– The Rocksdb engine has more tuning parameters for faster-synchronizing block and takes up less disk space when compared with the Block LevelDB.

Note:
You must only use one db engine (leveldb or rocksdb) throughout the life cycle of node because rocksdb’s data structure is incompatible with the leveldb’s. A convert tool is provided within Java-Tron to convert the leveldb data to rocksdb data and the usage of tool is described below. Please be aware that the conversion take time and the node is not syncing any blocks while this operation is ongoing.

1. First we need to clone the git and build it

git clone https://github.com/tronprotocol/java-tron
cd java-tron/
./gradlew build

Just wait until it’s built and tested. Go grab a cup of tee or a coffee.

2. Then we need to stop the node
3. Now we need to use this Java converter package (DBConvert.jar) to perform the conversion. It is located here: /java-tron/build/libs/

Sample syntax looks like this

java -jar build/libs/DBConvert.jar  your_database_dir/database  output-directory-dst/database

Example syntax looks like this

java -jar /home/userdir/java-tron/build/libs/DBConvert.jar /home/userdir/FullNode/output-directory/database /home/userdir/FullNode/output-directory2/database

According to tron documentation it should take about 10 hours to finish the conversion. Well on my node it took about 67800 seconds. This translates to 18.8 hours. The process is not CPU or Memory bound, both my CPU and Memory usage never exceeded 10% or the allocated resources.

Odyssey-v3.6.0 was released

On the 21st of June 2019 the latest Odyssey version 3.6 was released. This introduces new TVM instructions, API, protocol data check as well as optimizations.

New Features

  • #2070 Add create2 instruction for TVM, which returns a predictable contract address before deploy. TIP #26
  • #2069 Add bitwise shifting instructions for TVM to reduce energy consumption of shift. TIP #29
  • #2075 Add extcodehash instruction for TVM which returns the keccak256 hash of a contract’s code. TIP#30
  • #2125 Add triggerConstantContract API to support contracts which have no ABI. TIP #31
  • #2125 Add clearABI API including http and grpc, contract’s deployer can use this to clear his contract’s existed ABI. TIP #32
  • #2093 Add built-in message queue for event subscribe. TIP #28
  • #2047 Add protocol data check
  • #2154 Add the Permission_id field when returning the created transaction, compatible with multi-signature transactions

Changes

  • #2142 Support event subscription without abi
  • #2173 Optimize erengy deduction strategy in TVM when transfer 、sendor transferToken failed
  • #2141 Optimize the HTTP interface by adding the visible parameter to support the convenience type of addresses and strings, and add the AccountID related interface
  • #2182 Optimize http/grpc broadcast transaction interface
  • #2155 Optimize the process of block broadcasting
  • #2219 Fix the problem that the http interface parses the long type value for a long time.

Notices

  • Add built-in message queue config. See here
    use event.subscribe.native.useNativeQueue to control whether using built-in message queue . If true, use native message queue, else use event plugin.
    use event.subscribe.native.bindport to control bind port.
    use event.subscribe.native.sendqueuelength to control max length of send queue.
  • For smart contact without ABI (after clear ABI or deploy without ABI)
    If you want to call the constant method, you must use the triggerConstantContract interface instead of triggerContract . More details: TIP #31
    If you need event subscription, you need to subscribe to and upload ABI using version 3.6+. More details: tron-eventquery.md
    After clearABI, it is not possible to re-add ABI to the same contract address.
  • For create2 instruction
    If you want to use create2 to genertate a new address . More details: TIP #31
    After suicide, the storage of create2 addresses will be reset.
    If deployed on a normal address (created by transfer trx), the address will be modified to the contract address. The resources (bandwidth and energy) previously delegated to this address are cleared, and do not affect the unfreeze operation of the client.