Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
👌 Apply review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sameersubudhi committed Oct 24, 2023
1 parent 0690da9 commit 9b29cd1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
33 changes: 21 additions & 12 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,27 @@ The Lisk Migrator v2 also allows users to download and start the Lisk Core v4.x
USAGE
$ lisk-migrator [-d <value>] [-m <value>] [-c <value>] [-o <value>] [-p <value>] [-p <value>] [--snapshot-time-gap <value>] [--auto-migrate-config] [--auto-start-lisk-core-v4] [--snapshot-path] [--network]
FLAGS
-c, --config=config Custom configuration file path.
-d, --lisk-core-v3-data-path=lisk-core-v3-data-path Path where the lisk-core v3.x instance is running. Current home directory will be considered the default if not provided.
-h, --help Shows CLI help.
-o, --output=output File path to write the genesis block json. If not provided, it will default to cwd/genesis_block.json.
-p, --page-size Maximum number of blocks to be iterated at once for computation. Default to 100000.
-s, --snapshot-height=snapshot-height (Required) The height at which the re-genesis block will be generated. Can be specified with the SNAPSHOT_HEIGHT as well.
-v, --version Shows the CLI version.
--auto-migrate-config Migrate user configuration automatically. Default to false.
--auto-start-lisk-core-v4 Start lisk-core v4 automatically. Default to false.
--snapshot-path Path where the state snapshot is available.
--network Network for the migration.
OPTIONS
-c, --config=config Custom configuration file path for Lisk Core v3.1.x.
-d, --lisk-core-v3-data-path=lisk-core-v3-data-path Path where the Lisk Core v3.x instance is running. When not supplied, defaults to the default data directory for Lisk Core.
-h, --help show CLI help
-n, --network=network Network to be considered for the migration. Only necessary when the snapshot-path flag is used.
-o, --output=output File path to write the genesis block. If not provided, it will default to cwd/output/{v3_networkIdentifier}/genesis_block.blob. Do not use any value
starting with the default data path reserved for Lisk Core: '~/.lisk/lisk-core'.
-p, --page-size=page-size [default: 100000] Maximum number of blocks to be iterated at once for computation. Defaults to 100000.
-s, --snapshot-height=snapshot-height (required) The height at which re-genesis block will be generated. Can be specified with SNAPSHOT_HEIGHT as well.
-v, --version show CLI version
--auto-migrate-config Migrate user configuration automatically. Defaults to false.
--auto-start-lisk-core-v4 Start Lisk Core v4 automatically. Defaults to false. When using this flag, kindly open another terminal window to stop Lisk Core v3.1.x for when the
migrator prompts.
--snapshot-path=snapshot-path Path to the state snapshot. It could point either to a directory containing the snapshot files or a tarball (tar.gz).
EXAMPLES
lisk-migrator --snapshot-height 20931763 --lisk-core-path /path/to/data-dir
Expand Down
21 changes: 11 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class LiskMigrator extends Command {
public static description = 'Migrate Lisk Core to latest version';

public static flags = {
// add --version flag to show CLI version
version: flagsParser.version({ char: 'v' }),
help: flagsParser.help({ char: 'h' }),

Expand Down Expand Up @@ -124,18 +123,20 @@ class LiskMigrator extends Command {
description:
'Maximum number of blocks to be iterated at once for computation. Defaults to 100000.',
}),
network: flagsParser.string({
char: 'n',
required: false,
env: 'NETWORK',
description: 'Network for the migration.',
}),
'snapshot-path': flagsParser.string({
required: false,
env: 'SNAPSHOT_PATH',
description: 'Path where the state snapshot is available.',
description:
'Path to the state snapshot. It could point either to a directory containing the snapshot files or a tarball (tar.gz).',
dependsOn: ['network'],
}),
network: flagsParser.string({
char: 'n',
required: false,
env: 'NETWORK',
description:
'Network to be considered for the migration. Only necessary when the snapshot-path flag is used.',
}),
};

public async run(): Promise<void> {
Expand Down Expand Up @@ -177,7 +178,7 @@ class LiskMigrator extends Command {
cli.action.start('Verifying if backup height from node config matches snapshot height');
if (snapshotHeight !== nodeInfo.backup.height) {
this.error(
`Lisk Core v3 backup height (${nodeInfo.backup.height}) does not match the expected snapshot height (${snapshotHeight}).`,
`Lisk Core v3 backup height mismatch. Actual: ${nodeInfo.backup.height}, Expected: ${snapshotHeight}.`,
);
}
cli.action.stop('Snapshot height matches backup height');
Expand Down Expand Up @@ -214,7 +215,7 @@ class LiskMigrator extends Command {

// Using 'gt' instead of 'gte' because the behavior is swapped
// i.e. 'gt' acts as 'gte' and vice-versa
if (semver.gt(`${MIN_SUPPORTED_LISK_CORE_VERSION}-rc.0`, appVersion)) {
if (semver.gt(MIN_SUPPORTED_LISK_CORE_VERSION, appVersion)) {
this.error(
`Lisk Migrator is not compatible with Lisk Core version ${appVersion}. Minimum supported version is ${MIN_SUPPORTED_LISK_CORE_VERSION}.`,
);
Expand Down

0 comments on commit 9b29cd1

Please sign in to comment.