Skip to content

Commit a4d5020

Browse files
authored
feat: add new columns for receipts table (#1248)
* Add new columns for receipts
1 parent 6490d85 commit a4d5020

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

model/messages/receipt.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ type Receipt struct {
1818
Idx int `pg:",use_zero"`
1919
ExitCode int64 `pg:",use_zero"`
2020
GasUsed int64 `pg:",use_zero"`
21+
22+
Return []byte
23+
// Result returned from executing a message parsed and serialized as a JSON object.
24+
ParsedReturn string `pg:",type:jsonb"`
2125
}
2226

2327
func (r *Receipt) Persist(ctx context.Context, s model.StorageBatch, version model.Version) error {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package v1
2+
3+
func init() {
4+
patches.Register(
5+
29,
6+
`
7+
ALTER TABLE {{ .SchemaName | default "public"}}.receipts
8+
ADD COLUMN IF NOT EXISTS "return" bytea;
9+
10+
ALTER TABLE {{ .SchemaName | default "public"}}.receipts
11+
ADD COLUMN IF NOT EXISTS "parsed_return" JSONB;
12+
`,
13+
)
14+
}

tasks/messages/receipt/task.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"go.opentelemetry.io/otel"
1010
"go.opentelemetry.io/otel/attribute"
1111

12+
"github.com/filecoin-project/lily/lens/util"
1213
"github.com/filecoin-project/lily/model"
1314
messagemodel "github.com/filecoin-project/lily/model/messages"
1415
visormodel "github.com/filecoin-project/lily/model/visor"
@@ -50,6 +51,8 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
5051
return nil, report, nil
5152
}
5253

54+
getActorCode, makeActorCodeRuncErr := util.MakeGetActorCodeFunc(ctx, t.node.Store(), current, executed)
55+
5356
var (
5457
receiptResults = make(messagemodel.Receipts, 0, len(blkMsgRect))
5558
errorsDetected = make([]*messages.MessageError, 0, len(blkMsgRect))
@@ -85,6 +88,14 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
8588
Idx: index,
8689
ExitCode: int64(rec.ExitCode),
8790
GasUsed: rec.GasUsed,
91+
Return: rec.Return,
92+
}
93+
toCode, found := getActorCode(ctx, msg.VMMessage().To)
94+
if found && rec.ExitCode.IsSuccess() && makeActorCodeRuncErr == nil {
95+
parsedReturn, _, err := util.ParseReturn(rec.Return, msg.VMMessage().Method, toCode)
96+
if err == nil {
97+
rcpt.ParsedReturn = parsedReturn
98+
}
8899
}
89100
receiptResults = append(receiptResults, rcpt)
90101
}

0 commit comments

Comments
 (0)