Skip to content

Commit

Permalink
feat: add human readable actor codes in fevm_traces (#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasteph authored Jul 20, 2023
1 parent 6409ebc commit 64f94e4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
6 changes: 5 additions & 1 deletion model/fevm/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type FEVMTrace struct {
Method uint64 `pg:",notnull,use_zero"`
// Method in readable name.
ParsedMethod string `pg:",notnull"`
// ActorCode of To (receiver).
// ActorCode of To (receiver) as a CID.
ActorCode string `pg:",notnull"`
// ExitCode of message execution.
ExitCode int64 `pg:",notnull,use_zero"`
Expand All @@ -56,6 +56,10 @@ type FEVMTrace struct {
ParamsCodec uint64 `pg:",notnull,use_zero"`
// Returns codec.
ReturnsCodec uint64 `pg:",notnull,use_zero"`
// Human-readable identifier of receiver (To).
ToActorName string `pg:",notnull"`
// Human-readable identifier of sender (From).
FromActorName string `pg:",notnull"`
}

func (f *FEVMTrace) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
Expand Down
17 changes: 17 additions & 0 deletions schemas/v1/28_add_actor_names_to_fevm_traces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package v1

func init() {
patches.Register(
28,
`
ALTER TABLE {{ .SchemaName | default "public"}}.fevm_traces
ADD COLUMN IF NOT EXISTS "to_actor_name" text NOT NULL;
ALTER TABLE {{ .SchemaName | default "public"}}.fevm_traces
ADD COLUMN IF NOT EXISTS "from_actor_name" text NOT NULL;
COMMENT ON COLUMN {{ .SchemaName | default "public"}}.fevm_traces.to_actor_name IS 'Fully-versioned human-readable identifier of receiver (To).';
COMMENT ON COLUMN {{ .SchemaName | default "public"}}.fevm_traces.from_actor_name IS 'Fully-versioned human-readable identifier of receiver (From).';
`,
)
}
23 changes: 19 additions & 4 deletions tasks/fevm/trace/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,24 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
continue
}
for _, child := range util.GetChildMessagesOf(parentMsg) {
toCode, _ := getActorCode(ctx, child.Message.To)
fromCode, _ := getActorCode(ctx, child.Message.From)
var fromActorCode string
if !fromCode.Equals(cid.Undef) {
fromActorCode, _, err = util.ActorNameAndFamilyFromCode(fromCode)
if err != nil {
errs = append(errs, err)
}
}

toActorCode := "<Unknown>"
toCode, _ := getActorCode(ctx, child.Message.To)
actorCode := "<Unknown>"
var toActorCode string
if !toCode.Equals(cid.Undef) {
toActorCode = toCode.String()
actorCode = toCode.String()
toActorCode, _, err = util.ActorNameAndFamilyFromCode(toCode)
if err != nil {
errs = append(errs, err)
}
}
fromEthAddress := getEthAddress(child.Message.From)
toEthAddress := getEthAddress(child.Message.To)
Expand All @@ -139,13 +152,15 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
To: toEthAddress,
Value: child.Message.Value.String(),
ExitCode: int64(child.Receipt.ExitCode),
ActorCode: toActorCode,
ActorCode: actorCode,
Method: uint64(child.Message.Method),
Index: child.Index,
Params: ethtypes.EthBytes(child.Message.Params).String(),
Returns: ethtypes.EthBytes(child.Receipt.Return).String(),
ParamsCodec: child.Message.ParamsCodec,
ReturnsCodec: child.Receipt.ReturnCodec,
ToActorName: toActorCode,
FromActorName: fromActorCode,
}

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

0 comments on commit 64f94e4

Please sign in to comment.