From 6573cb21a53007d8ff06d209a77ab5e368bd8398 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Thu, 11 Jan 2024 21:20:43 -0500 Subject: [PATCH] Fixed KecakkPreimages to fit with legacy Firehose behavior that had a bug --- eth/tracers/firehose.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/eth/tracers/firehose.go b/eth/tracers/firehose.go index 1e13a66233..93cc19ea96 100644 --- a/eth/tracers/firehose.go +++ b/eth/tracers/firehose.go @@ -597,7 +597,20 @@ func (f *Firehose) CaptureKeccakPreimage(hash common.Hash, data []byte) { activeCall.KeccakPreimages = make(map[string]string) } - activeCall.KeccakPreimages[hex.EncodeToString(hash.Bytes())] = hex.EncodeToString(data) + // Known Firehose issue: It appears the old Firehose instrumentation have a bug + // where when the keccak256 preimage is empty, it is written as "." which is + // completely wrong. + // + // To keep the same behavior, we will write the preimage as a "." when the encoded + // data is an empty string. + // + // For new chain, this code should be remove so that we just keep `hex.EncodeToString(data)`. + encodedData := hex.EncodeToString(data) + if encodedData == "" { + encodedData = "." + } + + activeCall.KeccakPreimages[hex.EncodeToString(hash.Bytes())] = encodedData } func (f *Firehose) OnGenesisBlock(b *types.Block, alloc core.GenesisAlloc) {