ShipChain / hydra

Centralized network management for decentralized networks -- helping organize and publish sidechain connection details
https://docs.shipchain.io/docs/validatorGuide.html
Apache License 2.0
8 stars 2 forks source link

Jumpstart Files #25

Closed mlclay closed 5 years ago

mlclay commented 5 years ago

As the network block height continues to increase, the time to sync a new node continues to increase as well. We can provide jumpstart files to reduce the time required to fully sync, and Hydra and be used to handle the generate and application of these.

Setup

To generate a jumpstart file for a network, you need to have the SSH Key used in the provisioning of the network. Additionally, you will need to have the network bootstrapping information locally in your ${HYDRA_WORKDIR}/network.json file.

If you don't have the network bootstrap information, you can populate that from the S3 bucket via a new command.

hydra network pull-registry --name shipchain-testnet-beta

Generation

Once you have the bootstrap information local, you can continue with the generation of the jumpstart file. This requires a network to have more than 1 provisioned node; since this process stops one of the running nodes we don't want to stop the node that is also acting as the network's single Oracle.

hydra network generate-jumpstart --network shipchain-testnet-beta

This will ssh to the last bootstrapped node, create a remote tarfile containing the following contents:

genesis.json
app.db/*
receipts_db/*
chaindata/config/genesis.json
chaindata/data/blockstore.db/*
chaindata/data/evidence.db/*
chaindata/data/state.db/*
chaindata/data/tx_index.db/*

Upload that tarfile to the S3 bucket at jumpstart/<network>/<date>_<blockheight>_<network>.tar.gz

And create or update a metadata file jumpstart/<network>/jumps.json with the available jumpstart files for a network. The latest will always be updated to the most recent jumpstart tarfile, and a new entry for the specific blockheight will be added as well:

{
  "1407148": "2019-05-23_1407148_shipchain-testnet-beta.tar.gz",
  "latest": "2019-05-23_1407148_shipchain-testnet-beta.tar.gz"
}

Client Use

By default Hydra will now attempt to find and apply a jumpstart file automatically when joining a network. If no jumpstarts are found, then the joining continues as before and does a full sync from scratch. This behavior can be modified or disabled via arguments to join-network:

# Disable jumpstart
hydra client join-network --name shipchain-testnet-beta --jumpstart none

# This is the default behavior to use the latest jumpstart
hydra client join-network --name shipchain-testnet-beta --jumpstart latest

# Use a specific jumpstart file (must be defined in jumps.json)
hydra client join-network --name shipchain-testnet-beta --jumpstart 1407148

Additionally, if your node encounters corruption you may need to re-sync. You can apply jumpstart files on top of an existing node to sync from a known good point to prevent a full re-sync from scratch. This does not overwrite the node's private keys. However, we still recommend backing them up prior to this action.

hydra client apply-jumpstart --name shipchain-testnet-beta