Skip to content

Commit 64f94e4

Browse files
authored
feat: add human readable actor codes in fevm_traces (#1240)
1 parent 6409ebc commit 64f94e4

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

model/fevm/trace.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type FEVMTrace struct {
3838
Method uint64 `pg:",notnull,use_zero"`
3939
// Method in readable name.
4040
ParsedMethod string `pg:",notnull"`
41-
// ActorCode of To (receiver).
41+
// ActorCode of To (receiver) as a CID.
4242
ActorCode string `pg:",notnull"`
4343
// ExitCode of message execution.
4444
ExitCode int64 `pg:",notnull,use_zero"`
@@ -56,6 +56,10 @@ type FEVMTrace struct {
5656
ParamsCodec uint64 `pg:",notnull,use_zero"`
5757
// Returns codec.
5858
ReturnsCodec uint64 `pg:",notnull,use_zero"`
59+
// Human-readable identifier of receiver (To).
60+
ToActorName string `pg:",notnull"`
61+
// Human-readable identifier of sender (From).
62+
FromActorName string `pg:",notnull"`
5963
}
6064

6165
func (f *FEVMTrace) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package v1
2+
3+
func init() {
4+
patches.Register(
5+
28,
6+
`
7+
ALTER TABLE {{ .SchemaName | default "public"}}.fevm_traces
8+
ADD COLUMN IF NOT EXISTS "to_actor_name" text NOT NULL;
9+
10+
ALTER TABLE {{ .SchemaName | default "public"}}.fevm_traces
11+
ADD COLUMN IF NOT EXISTS "from_actor_name" text NOT NULL;
12+
13+
COMMENT ON COLUMN {{ .SchemaName | default "public"}}.fevm_traces.to_actor_name IS 'Fully-versioned human-readable identifier of receiver (To).';
14+
COMMENT ON COLUMN {{ .SchemaName | default "public"}}.fevm_traces.from_actor_name IS 'Fully-versioned human-readable identifier of receiver (From).';
15+
`,
16+
)
17+
}

tasks/fevm/trace/task.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,24 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
118118
continue
119119
}
120120
for _, child := range util.GetChildMessagesOf(parentMsg) {
121-
toCode, _ := getActorCode(ctx, child.Message.To)
121+
fromCode, _ := getActorCode(ctx, child.Message.From)
122+
var fromActorCode string
123+
if !fromCode.Equals(cid.Undef) {
124+
fromActorCode, _, err = util.ActorNameAndFamilyFromCode(fromCode)
125+
if err != nil {
126+
errs = append(errs, err)
127+
}
128+
}
122129

123-
toActorCode := "<Unknown>"
130+
toCode, _ := getActorCode(ctx, child.Message.To)
131+
actorCode := "<Unknown>"
132+
var toActorCode string
124133
if !toCode.Equals(cid.Undef) {
125-
toActorCode = toCode.String()
134+
actorCode = toCode.String()
135+
toActorCode, _, err = util.ActorNameAndFamilyFromCode(toCode)
136+
if err != nil {
137+
errs = append(errs, err)
138+
}
126139
}
127140
fromEthAddress := getEthAddress(child.Message.From)
128141
toEthAddress := getEthAddress(child.Message.To)
@@ -139,13 +152,15 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
139152
To: toEthAddress,
140153
Value: child.Message.Value.String(),
141154
ExitCode: int64(child.Receipt.ExitCode),
142-
ActorCode: toActorCode,
155+
ActorCode: actorCode,
143156
Method: uint64(child.Message.Method),
144157
Index: child.Index,
145158
Params: ethtypes.EthBytes(child.Message.Params).String(),
146159
Returns: ethtypes.EthBytes(child.Receipt.Return).String(),
147160
ParamsCodec: child.Message.ParamsCodec,
148161
ReturnsCodec: child.Receipt.ReturnCodec,
162+
ToActorName: toActorCode,
163+
FromActorName: fromActorCode,
149164
}
150165

151166
// only parse params and return of successful messages since unsuccessful messages don't return a parseable value.

0 commit comments

Comments
 (0)