diff --git a/model/messages/receipt.go b/model/messages/receipt.go index 5fba50574..5eb97efd8 100644 --- a/model/messages/receipt.go +++ b/model/messages/receipt.go @@ -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 { diff --git a/schemas/v1/29_add_parsed_return_to_receipt_returns.go b/schemas/v1/29_add_parsed_return_to_receipt_returns.go new file mode 100644 index 000000000..97dffd6c7 --- /dev/null +++ b/schemas/v1/29_add_parsed_return_to_receipt_returns.go @@ -0,0 +1,14 @@ +package v1 + +func init() { + patches.Register( + 29, + ` + 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; +`, + ) +} diff --git a/tasks/messages/receipt/task.go b/tasks/messages/receipt/task.go index ec86bb92a..870c3f5e3 100644 --- a/tasks/messages/receipt/task.go +++ b/tasks/messages/receipt/task.go @@ -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" @@ -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)) @@ -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) }