decode actually undecoded log entry values.

This commit is contained in:
Raúl Kripalani
2023-01-23 19:59:00 +00:00
parent 8f0193583a
commit d8df55b020
+16 -1
View File
@@ -1776,7 +1776,7 @@ func newEthTxReceipt(ctx context.Context, tx ethtypes.EthTx, lookup *api.MsgLook
}
for _, entry := range evt.Entries {
value := ethtypes.EthBytes(leftpad32(entry.Value)) // value has already been cbor-decoded but see https://github.com/filecoin-project/ref-fvm/issues/1345
value := ethtypes.EthBytes(leftpad32(decodeLogBytes(entry.Value)))
if entry.Key == ethtypes.EthTopic1 || entry.Key == ethtypes.EthTopic2 || entry.Key == ethtypes.EthTopic3 || entry.Key == ethtypes.EthTopic4 {
l.Topics = append(l.Topics, value)
} else {
@@ -1900,3 +1900,18 @@ func leftpad32(orig []byte) []byte {
copy(ret[needed:], orig)
return ret
}
// decodeLogBytes decodes a CBOR-serialized array into its original form.
//
// This function swallows errors and returns the original array if it failed
// to decode.
func decodeLogBytes(orig []byte) []byte {
if orig == nil {
return orig
}
decoded, err := cbg.ReadByteArray(bytes.NewReader(orig), uint64(len(orig)))
if err != nil {
return orig
}
return decoded
}