From 88c2af83081a4fb934b6a69787cc1334bede1ba4 Mon Sep 17 00:00:00 2001 From: Ermal Kaleci Date: Mon, 26 Jun 2023 19:15:33 +0200 Subject: [PATCH] handle empty prefix --- packages/chopsticks/src/executor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/chopsticks/src/executor.ts b/packages/chopsticks/src/executor.ts index f4450c7e..3024132a 100644 --- a/packages/chopsticks/src/executor.ts +++ b/packages/chopsticks/src/executor.ts @@ -10,6 +10,7 @@ import { get_runtime_version, run_task, } from '@acala-network/chopsticks-executor' +import { PREFIX_LENGTH } from './utils/key-cache' import { Registry } from '@polkadot/types-codec/types' import { defaultLogger, truncate } from './logger' import _ from 'lodash' @@ -87,7 +88,11 @@ export const taskHandler = (block: Block): JsCallback => { return header.stateRoot.toHex() }, getNextKey: async function (prefix: HexString, key: HexString) { - const [nextKey] = await block.getKeysPaged({ prefix, pageSize: 1, startKey: key }) + const [nextKey] = await block.getKeysPaged({ + prefix: prefix.length === 2 /** 0x */ ? key.slice(0, PREFIX_LENGTH) : prefix, + pageSize: 1, + startKey: key, + }) return nextKey }, }