From c507f409a5e6e077f202e6ed2e91a258110923e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Thu, 24 Sep 2020 14:06:34 +0100 Subject: [PATCH] remove driver from tvx; use lotus driver. --- tvx/examine.go | 3 +- tvx/exec_lotus.go | 6 ++-- tvx/extract_msg.go | 10 +++--- tvx/go.sum | 11 ++++++ tvx/lotus/driver.go | 83 --------------------------------------------- tvx/lotus/stubs.go | 55 ------------------------------ tvx/state/store.go | 8 ----- 7 files changed, 21 insertions(+), 155 deletions(-) delete mode 100644 tvx/lotus/driver.go delete mode 100644 tvx/lotus/stubs.go diff --git a/tvx/examine.go b/tvx/examine.go index 559dfd32b..703919bd6 100644 --- a/tvx/examine.go +++ b/tvx/examine.go @@ -14,8 +14,9 @@ import ( init_ "github.com/filecoin-project/specs-actors/actors/builtin/init" "github.com/filecoin-project/specs-actors/actors/util/adt" - "github.com/filecoin-project/oni/tvx/state" "github.com/filecoin-project/test-vectors/schema" + + "github.com/filecoin-project/oni/tvx/state" ) func trimQuotes(s string) string { diff --git a/tvx/exec_lotus.go b/tvx/exec_lotus.go index d702ddb8c..69438ad7b 100644 --- a/tvx/exec_lotus.go +++ b/tvx/exec_lotus.go @@ -12,11 +12,11 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/vm" + "github.com/filecoin-project/lotus/conformance" "github.com/filecoin-project/lotus/lib/blockstore" "github.com/ipld/go-car" "github.com/urfave/cli/v2" - "github.com/filecoin-project/oni/tvx/lotus" "github.com/filecoin-project/test-vectors/schema" ) @@ -102,7 +102,7 @@ func executeTestVector(tv schema.TestVector) error { fmt.Println("roots: ", header.Roots) - driver := lotus.NewDriver(ctx) + driver := conformance.NewDriver(ctx, tv.Selector) for i, m := range tv.ApplyMessages { fmt.Printf("decoding message %v\n", i) @@ -118,7 +118,7 @@ func executeTestVector(tv schema.TestVector) error { fmt.Printf("executing message %v\n", i) var ret *vm.ApplyRet - ret, root, err = driver.ExecuteMessage(msg, root, bs, abi.ChainEpoch(epoch)) + ret, root, err = driver.ExecuteMessage(bs, root, abi.ChainEpoch(epoch), msg) if err != nil { return err } diff --git a/tvx/extract_msg.go b/tvx/extract_msg.go index eca62993e..4509dc9ba 100644 --- a/tvx/extract_msg.go +++ b/tvx/extract_msg.go @@ -9,11 +9,11 @@ import ( "os" "github.com/filecoin-project/lotus/chain/types" + "github.com/filecoin-project/lotus/conformance" "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/ipfs/go-cid" "github.com/urfave/cli/v2" - "github.com/filecoin-project/oni/tvx/lotus" "github.com/filecoin-project/oni/tvx/state" "github.com/filecoin-project/test-vectors/schema" ) @@ -160,12 +160,12 @@ func runExtractMsg(c *cli.Context) error { fmt.Println("getting the _before_ filtered state tree") tree, err := g.GetStateTreeRootFromTipset(includedTs.Parents()) - driver := lotus.NewDriver(ctx) + driver := conformance.NewDriver(ctx, schema.Selector{}) for _, pm := range neededPrecursorMsgs { - _, tree, err = driver.ExecuteMessage(pm, tree, pst.Blockstore, execTs.Height()) + _, tree, err = driver.ExecuteMessage(pst.Blockstore, tree, execTs.Height(), pm) if err != nil { - return fmt.Errorf("Failed to execute preceding message: %w", err) + return fmt.Errorf("failed to execute preceding message: %w", err) } } @@ -174,7 +174,7 @@ func runExtractMsg(c *cli.Context) error { return err } - _, postroot, err := driver.ExecuteMessage(msg, preroot, pst.Blockstore, execTs.Height()) + _, postroot, err := driver.ExecuteMessage(pst.Blockstore, preroot, execTs.Height(), msg) if err != nil { return fmt.Errorf("failed to execute message: %w", err) } diff --git a/tvx/go.sum b/tvx/go.sum index aba062c1a..1a171d346 100644 --- a/tvx/go.sum +++ b/tvx/go.sum @@ -154,10 +154,12 @@ github.com/dgraph-io/badger v1.6.1 h1:w9pSFNSdq/JPM1N12Fz/F/bzo993Is1W+Q7HjPzi7y github.com/dgraph-io/badger v1.6.1/go.mod h1:FRmFw3uxvcpa8zG3Rxs0th+hCLIuaQg8HlNV5bjgnuU= github.com/dgraph-io/badger/v2 v2.0.3 h1:inzdf6VF/NZ+tJ8RwwYMjJMvsOALTHYdozn0qSl6XJI= github.com/dgraph-io/badger/v2 v2.0.3/go.mod h1:3KY8+bsP8wI0OEnQJAKpd4wIJW/Mm32yw2j/9FUVnIM= +github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= github.com/dgraph-io/ristretto v0.0.2-0.20200115201040-8f368f2f2ab3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po= github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de h1:t0UHb5vdojIDUqktM6+xJAfScFBsVpXZmqC9dsgJmeA= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -309,6 +311,7 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -453,14 +456,18 @@ github.com/ipfs/go-ds-badger v0.0.7/go.mod h1:qt0/fWzZDoPW6jpQeqUjR5kBfhDNB65jd9 github.com/ipfs/go-ds-badger v0.2.1/go.mod h1:Tx7l3aTph3FMFrRS838dcSJh+jjA7cX9DrGVwx/NOwE= github.com/ipfs/go-ds-badger v0.2.3/go.mod h1:pEYw0rgg3FIrywKKnL+Snr+w/LjJZVMTBRn4FS6UHUk= github.com/ipfs/go-ds-badger2 v0.1.0/go.mod h1:pbR1p817OZbdId9EvLOhKBgUVTM3BMCSTan78lDDVaw= +github.com/ipfs/go-ds-badger2 v0.1.1-0.20200708190120-187fc06f714e h1:Xi1nil8K2lBOorBS6Ys7+hmUCzH8fr3U9ipdL/IrcEI= github.com/ipfs/go-ds-badger2 v0.1.1-0.20200708190120-187fc06f714e/go.mod h1:lJnws7amT9Ehqzta0gwMrRsURU04caT0iRPr1W8AsOU= github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc= github.com/ipfs/go-ds-leveldb v0.1.0/go.mod h1:hqAW8y4bwX5LWcCtku2rFNX3vjDZCy5LZCg+cSZvYb8= github.com/ipfs/go-ds-leveldb v0.4.1/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s= +github.com/ipfs/go-ds-leveldb v0.4.2 h1:QmQoAJ9WkPMUfBLnu1sBVy0xWWlJPg0m4kRAiJL9iaw= github.com/ipfs/go-ds-leveldb v0.4.2/go.mod h1:jpbku/YqBSsBc1qgME8BkWS4AxzF2cEu1Ii2r79Hh9s= +github.com/ipfs/go-ds-measure v0.1.0 h1:vE4TyY4aeLeVgnnPBC5QzKIjKrqzha0NCujTfgvVbVQ= github.com/ipfs/go-ds-measure v0.1.0/go.mod h1:1nDiFrhLlwArTME1Ees2XaBOl49OoCgd2A3f8EchMSY= github.com/ipfs/go-filestore v1.0.0 h1:QR7ekKH+q2AGiWDc7W2Q0qHuYSRZGUJqUn0GsegEPb0= github.com/ipfs/go-filestore v1.0.0/go.mod h1:/XOCuNtIe2f1YPbiXdYvD0BKLA0JR1MgPiFOdcuu9SM= +github.com/ipfs/go-fs-lock v0.0.6 h1:sn3TWwNVQqSeNjlWy6zQ1uUGAZrV3hPOyEA6y1/N2a0= github.com/ipfs/go-fs-lock v0.0.6/go.mod h1:OTR+Rj9sHiRubJh3dRhD15Juhd/+w6VPOY28L7zESmM= github.com/ipfs/go-graphsync v0.1.0/go.mod h1:jMXfqIEDFukLPZHqDPp8tJMbHO9Rmeb9CEGevngQbmE= github.com/ipfs/go-graphsync v0.2.0 h1:x94MvHLNuRwBlZzVal7tR1RYK7T7H6bqQLPopxDbIF0= @@ -615,6 +622,7 @@ github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfV github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kabukky/httpscerts v0.0.0-20150320125433-617593d7dcb3/go.mod h1:BYpt4ufZiIGv2nXn4gMxnfKV306n3mWXgNu/d2TqdTU= github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0= +github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= github.com/kilic/bls12-381 v0.0.0-20200607163746-32e1441c8a9f/go.mod h1:XXfR6YFCRSrkEXbNlIyDsgXVNJWVUV30m/ebkVy9n6s= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= @@ -1255,6 +1263,7 @@ github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/supranational/blst v0.1.2-alpha.1/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/texttheater/golang-levenshtein v0.0.0-20180516184445-d188e65d659e/go.mod h1:XDKHRm5ThF8YJjx001LtgelzsoaEcvnA7lVWz9EeX3g= @@ -1314,6 +1323,7 @@ github.com/whyrusleeping/mdns v0.0.0-20180901202407-ef14215e6b30/go.mod h1:j4l84 github.com/whyrusleeping/mdns v0.0.0-20190826153040-b9b60ed33aa9/go.mod h1:j4l84WPFclQPj320J9gp0XwNKBb3U0zt5CBqjPp22G4= github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7 h1:E9S12nwJwEOXe2d6gT6qxdvqMnNq+VnSsKPgm2ZZNds= github.com/whyrusleeping/multiaddr-filter v0.0.0-20160516205228-e903e4adabd7/go.mod h1:X2c0RVCI1eSUFI8eLcY3c0423ykwiUdxLJtkDvruhjI= +github.com/whyrusleeping/pubsub v0.0.0-20131020042734-02de8aa2db3d h1:wnjWu1N8UTNf2zzF5FWlEyNNbNw5GMVHaHaaLdvdTdA= github.com/whyrusleeping/pubsub v0.0.0-20131020042734-02de8aa2db3d/go.mod h1:g7ckxrjiFh8mi1AY7ox23PZD0g6QU/TxW3U3unX7I3A= github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee h1:lYbXeSvJi5zk5GLKVuid9TVjS9a0OmLIDKTfoZBL6Ow= github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee/go.mod h1:m2aV4LZI4Aez7dP5PMyVKEHhUyEJ/RjmPEDOpDvudHg= @@ -1371,6 +1381,7 @@ go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go.uber.org/zap v1.15.0 h1:ZZCA22JRF2gQE5FoNmhmrf7jeJJ2uhqDUNRYKm8dvmM= go.uber.org/zap v1.15.0/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= +go4.org v0.0.0-20200411211856-f5505b9728dd h1:BNJlw5kRTzdmyfh5U8F93HA2OwkP7ZGwA51eJ/0wKOU= go4.org v0.0.0-20200411211856-f5505b9728dd/go.mod h1:CIiUVy99QCPfoE13bO4EZaz5GZMZXMSBGhxRdsvzbkg= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= diff --git a/tvx/lotus/driver.go b/tvx/lotus/driver.go deleted file mode 100644 index c3b03eb3a..000000000 --- a/tvx/lotus/driver.go +++ /dev/null @@ -1,83 +0,0 @@ -package lotus - -import ( - "context" - "log" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/network" - "github.com/filecoin-project/lotus/chain/state" - "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/vm" - "github.com/filecoin-project/lotus/conformance/chaos" - "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" - "github.com/filecoin-project/lotus/lib/blockstore" - "github.com/ipfs/go-cid" - cbor "github.com/ipfs/go-ipld-cbor" -) - -var ( - BaseFee = abi.NewTokenAmount(100) // TODO make parametrisable through vector. -) - -type Driver struct { - ctx context.Context -} - -func NewDriver(ctx context.Context) *Driver { - return &Driver{ctx: ctx} -} - -func (d *Driver) ExecuteMessage(msg *types.Message, preroot cid.Cid, bs blockstore.Blockstore, epoch abi.ChainEpoch) (*vm.ApplyRet, cid.Cid, error) { - log.Println("execution sanity check") - cst := cbor.NewCborStore(bs) - st, err := state.LoadStateTree(cst, preroot) - if err != nil { - return nil, cid.Undef, err - } - - actor, err := st.GetActor(msg.From) - if err != nil { - log.Println("from actor not found: ", msg.From) - } else { - log.Println("from actor found: ", actor) - } - - log.Println("creating vm") - vmOpts := &vm.VMOpts{ - StateBase: preroot, - Epoch: epoch, - Rand: &vmRand{}, - Bstore: bs, - Syscalls: mkFakedSigSyscalls(vm.Syscalls(ffiwrapper.ProofVerifier)), - CircSupplyCalc: nil, - BaseFee: BaseFee, - NtwkVersion: func(context.Context, abi.ChainEpoch) network.Version { - // TODO: Network upgrade. - return network.Version0 - }, - } - lvm, err := vm.NewVM(context.Background(), vmOpts) - if err != nil { - return nil, cid.Undef, err - } - // need to modify the VM invoker to add the chaos actor - chainValInvoker := vm.NewInvoker() - chainValInvoker.Register(chaos.ChaosActorCodeCID, chaos.Actor{}, chaos.State{}) - lvm.SetInvoker(chainValInvoker) - if err != nil { - return nil, cid.Undef, err - } - - log.Println("applying message") - ret, err := lvm.ApplyMessage(d.ctx, msg) - if err != nil { - return nil, cid.Undef, err - } - - log.Printf("applied message: %+v\n", ret) - - log.Println("flushing") - root, err := lvm.Flush(d.ctx) - return ret, root, err -} diff --git a/tvx/lotus/stubs.go b/tvx/lotus/stubs.go deleted file mode 100644 index a8de24068..000000000 --- a/tvx/lotus/stubs.go +++ /dev/null @@ -1,55 +0,0 @@ -package lotus - -import ( - "context" - - "github.com/filecoin-project/go-address" - "github.com/filecoin-project/lotus/chain/state" - "github.com/filecoin-project/lotus/chain/vm" - - "github.com/filecoin-project/go-state-types/abi" - "github.com/filecoin-project/go-state-types/crypto" - "github.com/filecoin-project/specs-actors/actors/runtime" - "github.com/filecoin-project/specs-actors/actors/runtime/proof" - - cbor "github.com/ipfs/go-ipld-cbor" -) - -type vmRand struct{} - -var _ vm.Rand = (*vmRand)(nil) - -func (r *vmRand) GetChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { - return []byte("i_am_random_____i_am_random_____"), nil // 32 bytes. -} - -func (r *vmRand) GetBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) { - return []byte("i_am_random_____i_am_random_____"), nil // 32 bytes. -} - -type fakedSigSyscalls struct { - runtime.Syscalls -} - -// TODO VerifySignature this will always succeed; but we want to be able to test failures too. -func (fss *fakedSigSyscalls) VerifySignature(_ crypto.Signature, _ address.Address, _ []byte) error { - return nil -} - -// TODO VerifySeal this will always succeed; but we want to be able to test failures too. -func (fss *fakedSigSyscalls) VerifySeal(_ proof.SealVerifyInfo) error { - return nil -} - -// TODO VerifyPoSt this will always succeed; but we want to be able to test failures too. -func (fss *fakedSigSyscalls) VerifyPoSt(_ proof.WindowPoStVerifyInfo) error { - return nil -} - -func mkFakedSigSyscalls(base vm.SyscallBuilder) vm.SyscallBuilder { - return func(ctx context.Context, cstate *state.StateTree, cst cbor.IpldStore) runtime.Syscalls { - return &fakedSigSyscalls{ - base(ctx, cstate, cst), - } - } -} diff --git a/tvx/state/store.go b/tvx/state/store.go index 536ac6989..d0d32609a 100644 --- a/tvx/state/store.go +++ b/tvx/state/store.go @@ -52,14 +52,6 @@ func newStores(ctx context.Context, ds ds.Batching, bs blockstore.Blockstore) *S } } -// NewLocalStores creates a Stores object that operates entirely in-memory with -// no read-through remote fetch fallback. -func NewLocalStores(ctx context.Context) *Stores { - ds := ds.NewMapDatastore() - bs := blockstore.NewBlockstore(ds) - return newStores(ctx, ds, bs) -} - type proxyingBlockstore struct { ctx context.Context api api.FullNode