From bd52302092d5393012a100617541d533362ac927 Mon Sep 17 00:00:00 2001 From: kyscott18 <43524469+kyscott18@users.noreply.github.com> Date: Thu, 9 Jan 2025 15:36:32 -0500 Subject: [PATCH] fix: null bytes in `trace.error` and `trace.revertReason` (#1426) * null bytes for traces * chore: changeset * Update tricky-bees-switch.md --- .changeset/tricky-bees-switch.md | 5 +++++ packages/core/src/sync-store/encoding.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/tricky-bees-switch.md diff --git a/.changeset/tricky-bees-switch.md b/.changeset/tricky-bees-switch.md new file mode 100644 index 000000000..685770cb0 --- /dev/null +++ b/.changeset/tricky-bees-switch.md @@ -0,0 +1,5 @@ +--- +"ponder": patch +--- + +Fixed a bug with traces containing invalid byte sequences. diff --git a/packages/core/src/sync-store/encoding.ts b/packages/core/src/sync-store/encoding.ts index d18e3d03f..69307db40 100644 --- a/packages/core/src/sync-store/encoding.ts +++ b/packages/core/src/sync-store/encoding.ts @@ -316,8 +316,10 @@ export function encodeTrace({ input: trace.input, functionSelector: trace.input.slice(0, 10) as Hex, output: trace.output ?? null, - revertReason: trace.revertReason ?? null, - error: trace.error ?? null, + revertReason: trace.revertReason + ? trace.revertReason.replace(/\0/g, "") + : null, + error: trace.error ? trace.error.replace(/\0/g, "") : null, value: trace.value ? hexToBigInt(trace.value) : null, index: trace.index, subcalls: trace.subcalls,