Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new columns for receipts table #1248

Merged
merged 5 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions model/messages/receipt.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ type Receipt struct {
Idx int `pg:",use_zero"`
ExitCode int64 `pg:",use_zero"`
GasUsed int64 `pg:",use_zero"`

Return []byte
// Result returned from executing a message parsed and serialized as a JSON object.
ParsedReturn string `pg:",type:jsonb"`
}

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

func init() {
patches.Register(
29,
`
ALTER TABLE {{ .SchemaName | default "public"}}.receipts
ADD COLUMN IF NOT EXISTS "parsed_return" JSONB;

ALTER TABLE {{ .SchemaName | default "public"}}.receipts
ADD COLUMN IF NOT EXISTS "return" bytea;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reorder to match the model please, otherwise we might have issues (similar to the actors table..). Thanks!

Suggested change
ALTER TABLE {{ .SchemaName | default "public"}}.receipts
ADD COLUMN IF NOT EXISTS "parsed_return" JSONB;
ALTER TABLE {{ .SchemaName | default "public"}}.receipts
ADD COLUMN IF NOT EXISTS "return" bytea;
ALTER TABLE {{ .SchemaName | default "public"}}.receipts
ADD COLUMN IF NOT EXISTS "return" bytea;
ALTER TABLE {{ .SchemaName | default "public"}}.receipts
ADD COLUMN IF NOT EXISTS "parsed_return" JSONB;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

`,
)
}
11 changes: 11 additions & 0 deletions tasks/messages/receipt/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"

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

getActorCode, makeActorCodeRuncErr := util.MakeGetActorCodeFunc(ctx, t.node.Store(), current, executed)

var (
receiptResults = make(messagemodel.Receipts, 0, len(blkMsgRect))
errorsDetected = make([]*messages.MessageError, 0, len(blkMsgRect))
Expand Down Expand Up @@ -85,6 +88,14 @@ func (t *Task) ProcessTipSets(ctx context.Context, current *types.TipSet, execut
Idx: index,
ExitCode: int64(rec.ExitCode),
GasUsed: rec.GasUsed,
Return: rec.Return,
}
toCode, found := getActorCode(ctx, msg.VMMessage().To)
if found && rec.ExitCode.IsSuccess() && makeActorCodeRuncErr == nil {
parsedReturn, _, err := util.ParseReturn(rec.Return, msg.VMMessage().Method, toCode)
if err == nil {
rcpt.ParsedReturn = parsedReturn
}
}
receiptResults = append(receiptResults, rcpt)
}
Expand Down