Skip to content

Commit 47f7ed2

Browse files
authored
Fix the transaction hash mismatch error and simplify the logic in getting address (#1254)
1 parent 05bdf5b commit 47f7ed2

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

tasks/fevm/trace/task.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func getEthAddress(addr address.Address) string {
5555
}
5656

5757
func (t *Task) getActorAddress(ctx context.Context, address address.Address, tsk types.TipSetKey) address.Address {
58-
actor, _ := t.node.Actor(ctx, address, tsk)
59-
if actor.Address != nil {
58+
actor, err := t.node.Actor(ctx, address, tsk)
59+
if err == nil && actor != nil && actor.Address != nil {
6060
return *actor.Address
6161
}
6262
return address
@@ -119,12 +119,25 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
119119
if !util.IsEVMMessage(ctx, t.node, parentMsg.Message, current.Key()) {
120120
continue
121121
}
122-
transactionHash, err := ethtypes.EthHashFromCid(parentMsg.Cid)
122+
messageHash, err := ethtypes.EthHashFromCid(parentMsg.Cid)
123123
if err != nil {
124124
log.Errorf("Error at finding hash: [cid: %v] err: %v", parentMsg.Cid, err)
125125
errs = append(errs, err)
126126
continue
127127
}
128+
txn, err := t.node.EthGetTransactionByHash(ctx, &messageHash)
129+
if err != nil {
130+
log.Errorf("Error at getting transaction: [hash: %v] err: %v", messageHash, err)
131+
errs = append(errs, err)
132+
continue
133+
}
134+
135+
if txn == nil {
136+
log.Errorf("transaction: [hash: %v] is null", messageHash)
137+
continue
138+
}
139+
transactionHash := txn.Hash.String()
140+
128141
for _, child := range util.GetChildMessagesOf(parentMsg) {
129142
fromCode, _ := getActorCode(ctx, child.Message.From)
130143
var fromActorCode string
@@ -152,7 +165,7 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
152165

153166
traceObj := &fevm.FEVMTrace{
154167
Height: int64(parentMsg.Height),
155-
TransactionHash: transactionHash.String(),
168+
TransactionHash: transactionHash,
156169
MessageStateRoot: parentMsg.StateRoot.String(),
157170
MessageCid: parentMsg.Cid.String(),
158171
TraceCid: getMessageTraceCid(child.Message).String(),

0 commit comments

Comments
 (0)