Benchmark a Network Migration

Pre requisites

To benchmark a migration on your Lotus node, you need:

Benchmark migration in offline mode

  1. On your currently synced and running Lotus node, run:
lotus chain head | head -n1
bafy2bzaceb6qkvjzxx5qehiwyvlbma5oi3p5bolwh2p36imqbagr4ck6fnqua
  1. Stop the Lotus daemon
lotus daemon stop
  1. Run the migration
./lotus-shed migrate-state --repo=[path-to-your-.lotus-repo] [nv-version-to-migrate-to] [output-of-step-1]

In the above command, replace [nv-version-to-migrate-to] with the network version you want to migrate to. For example, if you want to test the migration to network version 21, you would replace [nv-version-to-migrate-to] with 21.

The last step will create the migration jobs and run through them. You should observe the time it starts, and when it finishes, as well as the system load during this migration.

Benchmark migration in online mode

Run this only on a node on which you can afford to stop syncing the chain. It can be cleaned up later.

  1. On your currently synced and running Lotus node, run:
lotus chain list | tail -n 1 | awk -F: '{print $1}'
4099620

This gives you the current Epoch your node is on.

  1. To run a migration in online mode (i.e., while it continues to sync the chain), we need to adjust the upgrade epoch manually in the code.

In the build/buildconstants/params_mainnet.go file, adjust the upgrade epoch to an epoch around 50 epochs ahead of your current epoch. Example:

var UpgradeWaffleHeight = abi.ChainEpoch(4099620+50)
  1. Stop your Lotus daemon
lotus daemon stop
  1. Rebuild Lotus
make all
  1. Restart your daemon
lotus daemon 

Then, wait for the epoch set in step 2 to arrive and confirm and benchmark the migration in online mode. You will have to revert/clean up the code changes you made in the repository before you can restart your node and catch up with the correct chain.