Skip to content

Commit

Permalink
fix: align the eth address in fevm trace (#1253)
Browse files Browse the repository at this point in the history
* Fix the ethaddress in fevm trace

* Refine the function usage

* refactor the get actor function
  • Loading branch information
Terryhung authored Aug 21, 2023
1 parent f77dccc commit 05bdf5b
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tasks/fevm/trace/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func getEthAddress(addr address.Address) string {
return to.String()
}

func (t *Task) getActorAddress(ctx context.Context, address address.Address, tsk types.TipSetKey) address.Address {
actor, _ := t.node.Actor(ctx, address, tsk)
if actor.Address != nil {
return *actor.Address
}
return address
}

func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, executed *types.TipSet) (model.Persistable, *visormodel.ProcessingReport, error) {
ctx, span := otel.Tracer("").Start(ctx, "ProcessTipSets")
if span.IsRecording() {
Expand Down Expand Up @@ -137,19 +145,21 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
errs = append(errs, err)
}
}
fromEthAddress := getEthAddress(child.Message.From)
toEthAddress := getEthAddress(child.Message.To)

// Get Actor Address
toAddress := t.getActorAddress(ctx, child.Message.To, current.Key())
fromAddress := t.getActorAddress(ctx, child.Message.From, current.Key())

traceObj := &fevm.FEVMTrace{
Height: int64(parentMsg.Height),
TransactionHash: transactionHash.String(),
MessageStateRoot: parentMsg.StateRoot.String(),
MessageCid: parentMsg.Cid.String(),
TraceCid: getMessageTraceCid(child.Message).String(),
ToFilecoinAddress: child.Message.To.String(),
FromFilecoinAddress: child.Message.From.String(),
From: fromEthAddress,
To: toEthAddress,
FromFilecoinAddress: fromAddress.String(),
ToFilecoinAddress: toAddress.String(),
From: getEthAddress(fromAddress),
To: getEthAddress(toAddress),
Value: child.Message.Value.String(),
ExitCode: int64(child.Receipt.ExitCode),
ActorCode: actorCode,
Expand Down

0 comments on commit 05bdf5b

Please sign in to comment.