From c7e12ffd7a796e6c12373e90c6b0f4180de9d09e Mon Sep 17 00:00:00 2001 From: crystalin Date: Wed, 29 Nov 2023 12:48:38 +0100 Subject: [PATCH] Fixes support for authorizeUpgrade using checkVersion --- .../state-manipulator/authorize-upgrade-manipulator.ts | 4 ++-- src/libs/helpers/state-manipulator/genesis-parser.ts | 2 +- src/tools/export-state.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/helpers/state-manipulator/authorize-upgrade-manipulator.ts b/src/libs/helpers/state-manipulator/authorize-upgrade-manipulator.ts index 5a665ec..0294daf 100644 --- a/src/libs/helpers/state-manipulator/authorize-upgrade-manipulator.ts +++ b/src/libs/helpers/state-manipulator/authorize-upgrade-manipulator.ts @@ -24,11 +24,11 @@ export class AuthorizeUpgradeManipulator implements StateManipulator { if (key.startsWith(this.lastRelayChainBlockNumberKey)) { debug(`Adding Authorized Upgrade Hash: ${this.runtimeHash}`); return { - action: "keep" as Action, + action: "remove" as Action, extraLines: [ { key: this.storageKey, - value: this.runtimeHash, + value: `${this.runtimeHash}01`, // 01 for "true" check version }, ], }; diff --git a/src/libs/helpers/state-manipulator/genesis-parser.ts b/src/libs/helpers/state-manipulator/genesis-parser.ts index d0083b5..4d89d7e 100644 --- a/src/libs/helpers/state-manipulator/genesis-parser.ts +++ b/src/libs/helpers/state-manipulator/genesis-parser.ts @@ -40,7 +40,7 @@ export interface StateManipulator { // Will get executed for each line of the state file during the write phase // Can decide to remove/keep the original line and also add extra lines - processWrite: (line: StateLine) => { action: Action; extraLines?: StateLine[] } | undefined; + processWrite: (line: StateLine) => { action: Action; extraLines?: StateLine[] } | undefined | void; } export function encodeStorageKey(module, name) { diff --git a/src/tools/export-state.ts b/src/tools/export-state.ts index c58d0da..98d5787 100644 --- a/src/tools/export-state.ts +++ b/src/tools/export-state.ts @@ -99,7 +99,7 @@ async function main() { if (line.key.startsWith(storagePrefix)) { storageCount[storagePrefix] += 1n; storageKeySize[storagePrefix] = line.key.length / 2 - 1; - storageSize[storagePrefix] += BigInt(line.value.length / 2) - 1n; + storageSize[storagePrefix] += BigInt(line.key.length / 2) + BigInt(line.value.length / 2) - 2n; } } }