From 2f113e58ca41a42f1030b5264111161fef5c03f3 Mon Sep 17 00:00:00 2001 From: Aayush Date: Tue, 22 Aug 2023 11:51:00 -0400 Subject: [PATCH] fix tvx --- cmd/tvx/extract_message.go | 17 +++++++++-------- cmd/tvx/main.go | 2 +- cmd/tvx/state.go | 11 ++++++----- cmd/tvx/stores.go | 6 +++--- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/cmd/tvx/extract_message.go b/cmd/tvx/extract_message.go index 8ff8a2b79..95711414b 100644 --- a/cmd/tvx/extract_message.go +++ b/cmd/tvx/extract_message.go @@ -15,7 +15,8 @@ import ( "github.com/filecoin-project/test-vectors/schema" "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/api/v0api" + lapi "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/api/v1api" "github.com/filecoin-project/lotus/chain/actors/builtin" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/actors/builtin/reward" @@ -207,7 +208,7 @@ func doExtractMessage(opts extractOpts) error { // TODO sometimes this returns a nil receipt and no error ¯\_(ツ)_/¯ // ex: https://filfox.info/en/message/bafy2bzacebpxw3yiaxzy2bako62akig46x3imji7fewszen6fryiz6nymu2b2 // This code is lenient and skips receipt comparison in case of a nil receipt. - rec, err := FullAPI.StateGetReceipt(ctx, mcid, execTs.Key()) + rec, err := FullAPI.StateSearchMsg(ctx, execTs.Key(), mcid, api.LookbackNoLimit, false) if err != nil { return fmt.Errorf("failed to find receipt on chain: %w", err) } @@ -217,9 +218,9 @@ func doExtractMessage(opts extractOpts) error { var receipt *schema.Receipt if rec != nil { receipt = &schema.Receipt{ - ExitCode: int64(rec.ExitCode), - ReturnValue: rec.Return, - GasUsed: rec.GasUsed, + ExitCode: int64(rec.Receipt.ExitCode), + ReturnValue: rec.Receipt.Return, + GasUsed: rec.Receipt.GasUsed, } reporter := new(conformance.LogReporter) @@ -326,7 +327,7 @@ func doExtractMessage(opts extractOpts) error { // resolveFromChain queries the chain for the provided message, using the block CID to // speed up the query, if provided -func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, block string) (msg *types.Message, execTs *types.TipSet, incTs *types.TipSet, err error) { +func resolveFromChain(ctx context.Context, api lapi.FullNode, mcid cid.Cid, block string) (msg *types.Message, execTs *types.TipSet, incTs *types.TipSet, err error) { // Extract the full message. msg, err = api.ChainGetMessage(ctx, mcid) if err != nil { @@ -339,7 +340,7 @@ func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, blo log.Printf("locating message in blockchain") // Locate the message. - msgInfo, err := api.StateSearchMsg(ctx, mcid) + msgInfo, err := api.StateSearchMsg(ctx, types.EmptyTSK, mcid, lapi.LookbackNoLimit, false) if err != nil { return nil, nil, nil, fmt.Errorf("failed to locate message: %w", err) } @@ -384,7 +385,7 @@ func resolveFromChain(ctx context.Context, api v0api.FullNode, mcid cid.Cid, blo // as the previous tipset. In the context of vector generation, the target // tipset is the one where a message was executed, and the previous tipset is // the one where the message was included. -func fetchThisAndPrevTipset(ctx context.Context, api v0api.FullNode, target types.TipSetKey) (targetTs *types.TipSet, prevTs *types.TipSet, err error) { +func fetchThisAndPrevTipset(ctx context.Context, api v1api.FullNode, target types.TipSetKey) (targetTs *types.TipSet, prevTs *types.TipSet, err error) { // get the tipset on which this message was "executed" on. // https://github.com/filecoin-project/lotus/issues/2847 targetTs, err = api.ChainGetTipSet(ctx, target) diff --git a/cmd/tvx/main.go b/cmd/tvx/main.go index ab3e37d55..5021dd64b 100644 --- a/cmd/tvx/main.go +++ b/cmd/tvx/main.go @@ -102,7 +102,7 @@ func initialize(c *cli.Context) error { // Make the API client. var err error - if FullAPI, Closer, err = lcli.GetFullNodeAPI(c); err != nil { + if FullAPI, Closer, err = lcli.GetFullNodeAPIV1(c); err != nil { err = fmt.Errorf("failed to locate Lotus node; err: %w", err) } return err diff --git a/cmd/tvx/state.go b/cmd/tvx/state.go index 120eddd6b..9674bf17e 100644 --- a/cmd/tvx/state.go +++ b/cmd/tvx/state.go @@ -14,7 +14,8 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/lotus/api/v0api" + "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/api/v1api" init_ "github.com/filecoin-project/lotus/chain/actors/builtin/init" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" @@ -24,13 +25,13 @@ import ( // StateSurgeon is an object used to fetch and manipulate state. type StateSurgeon struct { ctx context.Context - api v0api.FullNode + api v1api.FullNode stores *Stores } // NewSurgeon returns a state surgeon, an object used to fetch and manipulate // state. -func NewSurgeon(ctx context.Context, api v0api.FullNode, stores *Stores) *StateSurgeon { +func NewSurgeon(ctx context.Context, api v1api.FullNode, stores *Stores) *StateSurgeon { return &StateSurgeon{ ctx: ctx, api: api, @@ -86,9 +87,9 @@ func (sg *StateSurgeon) GetMaskedStateTree(previousRoot cid.Cid, retain []addres // GetAccessedActors identifies the actors that were accessed during the // execution of a message. -func (sg *StateSurgeon) GetAccessedActors(ctx context.Context, a v0api.FullNode, mid cid.Cid) ([]address.Address, error) { +func (sg *StateSurgeon) GetAccessedActors(ctx context.Context, a v1api.FullNode, mid cid.Cid) ([]address.Address, error) { log.Printf("calculating accessed actors during execution of message: %s", mid) - msgInfo, err := a.StateSearchMsg(ctx, mid) + msgInfo, err := a.StateSearchMsg(ctx, types.EmptyTSK, mid, api.LookbackNoLimit, false) if err != nil { return nil, err } diff --git a/cmd/tvx/stores.go b/cmd/tvx/stores.go index d4431a145..0ced44817 100644 --- a/cmd/tvx/stores.go +++ b/cmd/tvx/stores.go @@ -18,7 +18,7 @@ import ( format "github.com/ipfs/go-ipld-format" "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/api/v0api" + "github.com/filecoin-project/lotus/api/v1api" "github.com/filecoin-project/lotus/blockstore" "github.com/filecoin-project/lotus/chain/actors/adt" ) @@ -39,7 +39,7 @@ type Stores struct { // NewProxyingStores is a set of Stores backed by a proxying Blockstore that // proxies Get requests for unknown CIDs to a Filecoin node, via the // ChainReadObj RPC. -func NewProxyingStores(ctx context.Context, api v0api.FullNode) *Stores { +func NewProxyingStores(ctx context.Context, api v1api.FullNode) *Stores { ds := dssync.MutexWrap(ds.NewMapDatastore()) bs := &proxyingBlockstore{ ctx: ctx, @@ -84,7 +84,7 @@ type TracingBlockstore interface { // a Filecoin node via JSON-RPC. type proxyingBlockstore struct { ctx context.Context - api v0api.FullNode + api v1api.FullNode lk sync.Mutex tracing bool