diff --git a/executor/src/task.rs b/executor/src/task.rs index 11b8bfe9..3b734cd6 100644 --- a/executor/src/task.rs +++ b/executor/src/task.rs @@ -128,10 +128,14 @@ pub async fn run_task(task: TaskCall) -> Result { let key = HexString(req.key().as_ref().to_vec()); let key = serde_wasm_bindgen::to_value(&key).map_err(|e| e.to_string())?; let value = get_storage(hash.clone(), key).await; - let value = serde_wasm_bindgen::from_value::(value) - .map(|x| x.0) - .map_err(|e| e.to_string())?; - let value = if value.is_empty() { None } else { Some(value) }; + let value = if value.is_string() { + let encoded = serde_wasm_bindgen::from_value::(value) + .map(|x| x.0) + .map_err(|e| e.to_string())?; + Some(encoded) + } else { + None + }; req.inject_value(value.map(iter::once)) } RuntimeHostVm::PrefixKeys(req) => { diff --git a/src/bindings.ts b/src/bindings.ts index d41462a6..89c5b2f8 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -10,8 +10,8 @@ export const setupBindings = (chain: Blockchain) => { getStorage: async function (blockHash: HexString, key: HexString) { const block = await chain.getBlock(blockHash) if (!block) throw Error(`Block not found ${blockHash}`) - const value = await block.get(key).then((x) => (x ? x : '0x')) - logger.trace({ blockHash, key, value: truncate(value) }, 'exec_storageGet') + const value = await block.get(key) + logger.trace({ blockHash, key, value: value && truncate(value) }, 'exec_storageGet') return value }, getPrefixKeys: async function (blockHash: HexString, key: HexString) { diff --git a/src/blockchain/txpool.ts b/src/blockchain/txpool.ts index 542693d3..201d5c6c 100644 --- a/src/blockchain/txpool.ts +++ b/src/blockchain/txpool.ts @@ -8,7 +8,7 @@ import { Blockchain } from '.' import { InherentProvider } from './inherents' import { ResponseError } from '../rpc/shared' import { compactHex } from '../utils' -import { defaultLogger, truncateStorageDiff } from '../logger' +import { defaultLogger, truncate, truncateStorageDiff } from '../logger' const logger = defaultLogger.child({ name: 'txpool' }) @@ -157,7 +157,7 @@ export class TxPool { const resp2 = await newBlock.call('BlockBuilder_finalize_block', '0x') newBlock.pushStorageLayer().setAll(resp2.storageDiff) - logger.trace(resp2.storageDiff, 'Finalize block') + logger.trace(truncateStorageDiff(resp2.storageDiff), 'Finalize block') const blockData = registry.createType('Block', { header, @@ -171,7 +171,10 @@ export class TxPool { }) const diff = await newBlock.storageDiff() - logger.trace(diff, 'Final block') + logger.trace( + Object.entries(diff).map(([key, value]) => [key, truncate(value)]), + 'Final block' + ) finalBlock.pushStorageLayer().setAll(diff) this.#chain.unregisterBlock(newBlock)