Added a backward compatibility fix for aligning with Firehose 2.3

This commit is contained in:
Matthieu Vachon 2024-12-20 16:20:00 -05:00
parent 2ff5f62b6f
commit 3cbe387cd6

View file

@ -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)