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

Commit

Permalink
Merge pull request #193 from LiskHQ/191-add-support-to-use-existing-d…
Browse files Browse the repository at this point in the history
…atabase-snapshot

Add support to use existing database snapshot
  • Loading branch information
sameersubudhi authored Oct 25, 2023
2 parents 566854f + 1204b11 commit 56c29db
Show file tree
Hide file tree
Showing 24 changed files with 681 additions and 192 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ coverage
benchmark
.eslintrc.js
dist/
test/_setup.js
test/_setup.js
data/
5 changes: 3 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ browsertest.build/
*.SHA256
blockchain.db/*

# Output directory
output/
# Output and data directory
output/
data/
35 changes: 23 additions & 12 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,29 @@ 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] [--use-existing-snapshot]
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.
$ 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]
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=(mainnet|testnet) Network to be considered for the migration. Depends on the '--snapshot-path' flag.
-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 to run the migration offline. It could point either to a directory or a tarball (tar.gz).
--snapshot-url=snapshot-url URL to download the state snapshot from. Use to run the migration offline. URL must end with tar.gz.
EXAMPLES
lisk-migrator --snapshot-height 20931763 --lisk-core-path /path/to/data-dir
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@oclif/config": "1.14.0",
"@oclif/errors": "1.2.2",
"@oclif/plugin-help": "2.2.3",
"axios": "0.25.0",
"cli-ux": "5.5.1",
"debug": "4.3.1",
"fs-extra": "11.1.0",
Expand Down
18 changes: 0 additions & 18 deletions src/assets/pos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,6 @@ const ceiling = (a: number, b: number) => {
return Math.floor((a + b - 1) / b);
};

export const formatInt = (num: number | bigint): string => {
let buf: Buffer;
if (typeof num === 'bigint') {
if (num < BigInt(0)) {
throw new Error('Negative number cannot be formatted');
}
buf = Buffer.alloc(8);
buf.writeBigUInt64BE(num);
} else {
if (num < 0) {
throw new Error('Negative number cannot be formatted');
}
buf = Buffer.alloc(4);
buf.writeUInt32BE(num, 0);
}
return buf.toString('binary');
};

export const getValidatorKeys = async (
accounts: Account[],
db: Database,
Expand Down
Loading

0 comments on commit 56c29db

Please sign in to comment.