Do not compute message index as traces should be in message execution order

This commit is contained in:
Fridrik Asmundsson 2023-08-22 14:32:59 +00:00
parent a1b890c8c7
commit ef7bcfec06
2 changed files with 8 additions and 12 deletions

View File

@ -229,7 +229,7 @@ func BuildTraces(traces *[]*Trace, parent *Trace, addr []int, et types.Execution
return nil
}
func writePadded[T any](w io.Writer, data T, size int) error {
func writePadded(w io.Writer, data any, size int) error {
tmp := &bytes.Buffer{}
// first write data to tmp buffer to get the size

View File

@ -857,23 +857,19 @@ func (a *EthModule) TraceBlock(ctx context.Context, blkNum string) ([]*ethtypes.
}
allTraces := make([]*ethtypes.TraceBlock, 0, len(trace))
msgIdx := 0
for _, ir := range trace {
// ignore messages from system actor
if ir.Msg.From == builtinactors.SystemActorAddr {
continue
}
idx := -1
for msgIdx, msg := range msgs {
if ir.Msg.From == msg.Message.From {
idx = msgIdx
break
}
}
if idx == -1 {
log.Warnf("cannot resolve message index for cid: %s", ir.MsgCid)
continue
// as we include TransactionPosition in the results, lets do sanity checking that the
// traces are indeed in the message execution order
if ir.Msg.Cid() != msgs[msgIdx].Message.Cid() {
return nil, xerrors.Errorf("traces are not in message execution order")
}
msgIdx++
txHash, err := a.EthGetTransactionHashByCid(ctx, ir.MsgCid)
if err != nil {
@ -897,7 +893,7 @@ func (a *EthModule) TraceBlock(ctx context.Context, blkNum string) ([]*ethtypes.
BlockHash: blkHash,
BlockNumber: int64(ts.Height()),
TransactionHash: *txHash,
TransactionPosition: idx,
TransactionPosition: msgIdx,
})
}