From 7b6f6843a743c33f21ae051634072ca3a904caab Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 20 Apr 2023 13:27:44 -0700 Subject: [PATCH 1/2] fix: tvx: correctly lookup actor codes in extract-many --- cmd/tvx/extract_many.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/cmd/tvx/extract_many.go b/cmd/tvx/extract_many.go index 96ce2473b..7c8d306d8 100644 --- a/cmd/tvx/extract_many.go +++ b/cmd/tvx/extract_many.go @@ -7,18 +7,20 @@ import ( "log" "os" "path/filepath" + "regexp" "strconv" "strings" "github.com/fatih/color" "github.com/hashicorp/go-multierror" "github.com/ipfs/go-cid" - "github.com/multiformats/go-multihash" "github.com/urfave/cli/v2" "github.com/filecoin-project/go-state-types/abi" + actorstypes "github.com/filecoin-project/go-state-types/actors" "github.com/filecoin-project/go-state-types/exitcode" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/consensus" ) @@ -67,6 +69,8 @@ var extractManyCmd = &cli.Command{ }, } +var actorCodeRegex = regexp.MustCompile(`^fil/(?P\d+)/(?P\w+)$`) + func runExtractMany(c *cli.Context) error { // LOTUS_DISABLE_VM_BUF disables what's called "VM state tree buffering", // which stashes write operations in a BufferedBlockstore @@ -114,8 +118,6 @@ func runExtractMany(c *cli.Context) error { log.Println(color.GreenString("csv sanity check succeeded; header contains fields: %v", header)) } - codeCidBuilder := cid.V1Builder{Codec: cid.Raw, MhType: multihash.IDENTITY} - var ( generated []string merr = new(multierror.Error) @@ -153,9 +155,21 @@ func runExtractMany(c *cli.Context) error { return fmt.Errorf("invalid method number: %s", methodnumstr) } - codeCid, err := codeCidBuilder.Sum([]byte(actorcode)) - if err != nil { - return fmt.Errorf("failed to compute actor code CID") + // Lookup the code CID. + var codeCid cid.Cid + if matches := actorCodeRegex.FindStringSubmatch(actorcode); len(matches) == 3 { + av, err := strconv.Atoi(matches[1]) + if err != nil { + return fmt.Errorf("invalid actor version %q in actor code %q", matches[1], actorcode) + } + an := matches[2] + if k, ok := actors.GetActorCodeID(actorstypes.Version(av), an); ok { + codeCid = k + } else { + return fmt.Errorf("unknown actor code %q", actorcode) + } + } else { + return fmt.Errorf("invalid actor code %q", actorcode) } // Lookup the method in actor method table. From 54d8ddf3c1f723e071fb65fe874ca2a7cbd0fa2b Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Thu, 20 Apr 2023 13:50:16 -0700 Subject: [PATCH 2/2] fix: tvx: fvm vm.Flush --- conformance/driver.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conformance/driver.go b/conformance/driver.go index e0d56d074..eb5973f72 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -297,12 +297,12 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP } var root cid.Cid - if d.vmFlush { + if lvm, ok := vmi.(*vm.LegacyVM); ok && !d.vmFlush { + root, err = lvm.StateTree().(*state.StateTree).Flush(d.ctx) + } else { // flush the VM, committing the state tree changes and forcing a // recursive copy from the temporary blockstore to the real blockstore. root, err = vmi.Flush(d.ctx) - } else { - root, err = vmi.(*vm.LegacyVM).StateTree().(*state.StateTree).Flush(d.ctx) } return ret, root, err