From 3cbe387cd67bea743fa496b86f349037f771f231 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Fri, 20 Dec 2024 16:20:00 -0500 Subject: [PATCH] Added a backward compatibility fix for aligning with Firehose 2.3 --- eth/tracers/firehose.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eth/tracers/firehose.go b/eth/tracers/firehose.go index 63b9893776..223edae42b 100644 --- a/eth/tracers/firehose.go +++ b/eth/tracers/firehose.go @@ -643,6 +643,13 @@ func (f *Firehose) completeTransaction(receipt *types.Receipt) *pbeth.Transactio f.removeLogBlockIndexOnStateRevertedCalls() f.assignOrdinalAndIndexToReceiptLogs() + if *f.applyBackwardCompatibility { + // Known Firehose issue: Failed call logging a log with no topics were not fixed in the old Firehose instrumentation + // leading to them to be rendered as `topics: [""]` instead of `topics: nil` like successful calls. + // Here we re-apply this bogus behavior. + f.noTopicsLogOnFailedCallSetToEmptyHash() + } + if *f.applyBackwardCompatibility { // Known Firehose issue: This field has never been populated in the old Firehose instrumentation } else { @@ -757,6 +764,18 @@ func (f *Firehose) assignOrdinalAndIndexToReceiptLogs() { } } +func (f *Firehose) noTopicsLogOnFailedCallSetToEmptyHash() { + for _, call := range f.transaction.Calls { + if call.StateReverted { + for _, log := range call.Logs { + if len(log.Topics) == 0 { + log.Topics = make([][]byte, 1) + } + } + } + } +} + // OnCallEnter implements the EVMLogger interface to initialize the tracing operation. func (f *Firehose) OnCallEnter(depth int, typ byte, from common.Address, to common.Address, input []byte, gas uint64, value *big.Int) { opCode := vm.OpCode(typ)