From 5945f762b65ee32ab37f969be1c8ecdaa8841127 Mon Sep 17 00:00:00 2001 From: Sameer Kumar Subudhi <sameer.subudhi@lightcurve.io> Date: Mon, 13 Nov 2023 16:41:18 +0100 Subject: [PATCH 1/2] :hammer: Create the SHA256 for genesis_block blob/json --- src/constants.ts | 3 +++ src/utils/genesis_block.ts | 34 ++++++++++++++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 1521e7be..47106684 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -100,6 +100,9 @@ export const FILE_NAME = { COMMANDS_TO_EXEC: 'commandsToExecute.txt', FORGING_STATUS: 'forgingStatus.json', KEYS: 'keys.json', + GENESIS_ASSETS: 'genesis_assets.json', + GENESIS_BLOCK_JSON: 'genesis_block.json', + GENESIS_BLOCK_BLOB: 'genesis_block.blob', }; export const enum ERROR_CODE { diff --git a/src/utils/genesis_block.ts b/src/utils/genesis_block.ts index f5167264..d07b56e0 100644 --- a/src/utils/genesis_block.ts +++ b/src/utils/genesis_block.ts @@ -17,7 +17,7 @@ import path from 'path'; import { Command } from '@oclif/command'; import { BlockHeader } from '@liskhq/lisk-chain'; -import { ERROR_CODE, SNAPSHOT_TIME_GAP } from '../constants'; +import { ERROR_CODE, FILE_NAME, SNAPSHOT_TIME_GAP } from '../constants'; import { GenesisAssetEntry } from '../types'; import { execAsync } from './process'; import { copyFile, createTarball } from './fs'; @@ -84,7 +84,7 @@ export const writeGenesisAssets = async ( genesisAssets: GenesisAssetEntry[], outputDir: string, ): Promise<void> => { - const genesisAssetsJsonFilepath = path.resolve(outputDir, 'genesis_assets.json'); + const genesisAssetsJsonFilepath = path.resolve(outputDir, FILE_NAME.GENESIS_ASSETS); fs.writeFileSync( genesisAssetsJsonFilepath, JSON.stringify({ assets: genesisAssets }, null, '\t'), @@ -97,21 +97,35 @@ export const copyGenesisBlock = async ( ): Promise<boolean | Error> => copyFile(currGenesisBlockFilepath, liskCoreV4ConfigPath); export const writeGenesisBlock = async (outputDir: string): Promise<void> => { - const genesisBlockJsonFilepath = path.resolve(outputDir, 'genesis_block.json'); - await createTarball(genesisBlockJsonFilepath, outputDir); + // Genesis BLOB handling + const genesisBlockBlobFilepath = path.resolve(outputDir, FILE_NAME.GENESIS_BLOCK_BLOB); + + const genesisBlockBlobHash = await createChecksum(genesisBlockBlobFilepath); + fs.writeFileSync( + path.resolve(outputDir, `${FILE_NAME.GENESIS_BLOCK_BLOB}.SHA256`), + genesisBlockBlobHash, + ); - const genesisBlockBlobFilepath = path.resolve(outputDir, 'genesis_block.blob'); await createTarball(genesisBlockBlobFilepath, outputDir); + const genesisBlockBlobTarballHash = await createChecksum(`${genesisBlockBlobFilepath}.tar.gz`); + fs.writeFileSync( + path.resolve(outputDir, `${FILE_NAME.GENESIS_BLOCK_BLOB}.tar.gz.SHA256`), + genesisBlockBlobTarballHash, + ); + + // Genesis JSON handling + const genesisBlockJsonFilepath = path.resolve(outputDir, FILE_NAME.GENESIS_BLOCK_JSON); - const genesisBlockJsonHash = await createChecksum(`${genesisBlockJsonFilepath}.tar.gz`); + const genesisBlockJsonHash = await createChecksum(genesisBlockJsonFilepath); fs.writeFileSync( - path.resolve(outputDir, 'genesis_block.json.tar.gz.SHA256'), + path.resolve(outputDir, `${FILE_NAME.GENESIS_BLOCK_JSON}.SHA256`), genesisBlockJsonHash, ); - const genesisBlockBlobHash = await createChecksum(`${genesisBlockBlobFilepath}.tar.gz`); + await createTarball(genesisBlockJsonFilepath, outputDir); + const genesisBlockJsonTarBallHash = await createChecksum(`${genesisBlockJsonFilepath}.tar.gz`); fs.writeFileSync( - path.resolve(outputDir, 'genesis_block.blob.tar.gz.SHA256'), - genesisBlockBlobHash, + path.resolve(outputDir, `${FILE_NAME.GENESIS_BLOCK_JSON}.tar.gz.SHA256`), + genesisBlockJsonTarBallHash, ); }; From a9a78749a6adbfd233a2afbd536fc55972c9bf15 Mon Sep 17 00:00:00 2001 From: Sameer Kumar Subudhi <sameer.subudhi@lightcurve.io> Date: Mon, 13 Nov 2023 16:57:00 +0100 Subject: [PATCH 2/2] :arrow_up: Update README and bump version --- README.md | 7 +++++-- package.json | 2 +- yarn.lock | 18 +++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d71b461a..e2adb007 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ The following system requirements are recommended to run Lisk Migrator v2.0.0: ## Setup -Follow our Lisk Documentation guide for [setting up the Lisk migrator](https://lisk.com/documentation/lisk-core/management/migration.html#setting-up-the-lisk-migrator). +Follow our Lisk Documentation guide for [setting up the Lisk migrator](https://lisk.com/documentation/lisk-core/v4/management/migration.html#setting-up-the-lisk-migrator). ### Build Distributions (Linux, Darwin) from source @@ -77,10 +77,11 @@ $ export PATH="$PATH:$HOME/lisk-migrator-extract/lisk-migrator/bin" <!-- usage --> ```sh-session +$ npm install -g lisk-migrator $ lisk-migrator COMMAND running command... $ lisk-migrator (-v|--version|version) -lisk-migrator/2.0.0-rc.4 darwin-arm64 node-v18.16.1 +lisk-migrator/2.0.0 darwin-arm64 node-v18.16.1 $ lisk-migrator --help [COMMAND] USAGE $ lisk-migrator COMMAND @@ -89,6 +90,8 @@ USAGE <!-- usagestop --> +> **NOTE**: To verify the final results, please run the following command: `cat genesis_block.blob.SHA256` under the output directory and compare the results with other participants on [Discord](https://lisk.chat/). + <!-- commands --> # Command Topics diff --git a/package.json b/package.json index b86c0808..22ae2cae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lisk-migrator", - "version": "2.0.0-rc.5", + "version": "2.0.0", "description": "A command-line tool for migrating the blockchain state to the latest protocol after a hard fork", "author": "Lisk Foundation <admin@lisk.io>, lightcurve GmbH <admin@lightcurve.io>", "license": "Apache-2.0", diff --git a/yarn.lock b/yarn.lock index 54bfa612..ba4447cd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1280,9 +1280,9 @@ minipass "^4.0.0" "@types/tar@^6.1.4": - version "6.1.8" - resolved "https://registry.yarnpkg.com/@types/tar/-/tar-6.1.8.tgz#1432a625a86705788989a9d09cb6893b51e0f33f" - integrity sha512-p8Rc0vas9n+7cv0JiSdUMHiL42gOflrj3v0RMSbe8x5lauEygCEFpS0B/Rw9ZI62qrxlsvZqTggIEIas2gBQrA== + version "6.1.9" + resolved "https://registry.yarnpkg.com/@types/tar/-/tar-6.1.9.tgz#1f8f7033494224e61b97895070fafcdd6ec370f3" + integrity sha512-T3+O+OQd9cdGmOXuKQY9+B0ceZHRlGVPQ7M5QZqkaPyP/vWnxPXM2aCegq8GP/n1n9dBfq2EBUqCSKKjQAVOPA== dependencies: "@types/node" "*" minipass "^4.0.0" @@ -2666,9 +2666,9 @@ ed2curve@0.3.0: tweetnacl "1.x.x" electron-to-chromium@^1.4.535: - version "1.4.580" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.580.tgz#2f8f70f70733a6be1fb6f31de1224e6dc4bb196d" - integrity sha512-T5q3pjQon853xxxHUq3ZP68ZpvJHuSMY2+BZaW3QzjS4HvNuvsMmZ/+lU+nCrftre1jFZ+OSlExynXWBihnXzw== + version "1.4.581" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.581.tgz#23b684c67bf56d4284e95598c05a5d266653b6d8" + integrity sha512-6uhqWBIapTJUxgPTCHH9sqdbxIMPt7oXl0VcAL1kOtlU6aECdcMncCrX5Z7sHQ/invtrC9jUQUef7+HhO8vVFw== emittery@^0.8.1: version "0.8.1" @@ -3302,9 +3302,9 @@ find-versions@^4.0.0: semver-regex "^3.1.2" flat-cache@^3.0.4: - version "3.1.1" - resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.1.1.tgz#a02a15fdec25a8f844ff7cc658f03dd99eb4609b" - integrity sha512-/qM2b3LUIaIgviBQovTLvijfyOQXPtSRnRK26ksj2J7rzPIecePUIpJsZ4T02Qg+xiAEKIs5K8dsHEd+VaKa/Q== + version "3.2.0" + resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-3.2.0.tgz#2c0c2d5040c99b1632771a9d105725c0115363ee" + integrity sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw== dependencies: flatted "^3.2.9" keyv "^4.5.3"