diff --git a/chain/consensus/filcns/filecoin.go b/chain/consensus/filcns/filecoin.go index 6c9f28573ca..0806faa1c51 100644 --- a/chain/consensus/filcns/filecoin.go +++ b/chain/consensus/filcns/filecoin.go @@ -27,12 +27,12 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/reward" "github.com/filecoin-project/lotus/chain/beacon" "github.com/filecoin-project/lotus/chain/consensus" + "github.com/filecoin-project/lotus/chain/proofs" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/verifier" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/lib/async" "github.com/filecoin-project/lotus/lib/sigs" @@ -50,7 +50,7 @@ type FilecoinEC struct { // the state manager handles making state queries sm *stmgr.StateManager - verifier verifier.Verifier + verifier proofs.Verifier genesis *types.TipSet } @@ -94,7 +94,7 @@ var RewardFunc = func(ctx context.Context, vmi vm.Interface, em stmgr.ExecMonito return nil } -func NewFilecoinExpectedConsensus(sm *stmgr.StateManager, beacon beacon.Schedule, verifier verifier.Verifier, genesis chain.Genesis) consensus.Consensus { +func NewFilecoinExpectedConsensus(sm *stmgr.StateManager, beacon beacon.Schedule, verifier proofs.Verifier, genesis chain.Genesis) consensus.Consensus { if build.InsecurePoStValidation { log.Warn("*********************************************************************************************") log.Warn(" [INSECURE-POST-VALIDATION] Insecure test validation is enabled. If you see this outside of a test, it is a severe bug! ") @@ -367,8 +367,8 @@ func (filec *FilecoinEC) VerifyWinningPoStProof(ctx context.Context, nv network. } } - // TODO(rvagg): why is this using verifierffi.ProofVerifier.VerifyWinningPoSt directly and not filec.verifier.VerifyWinningPoSt? - ok, err := verifierffi.ProofVerifier.VerifyWinningPoSt(ctx, proof.WinningPoStVerifyInfo{ + // TODO(rvagg): why is this using proofsffi.ProofVerifier.VerifyWinningPoSt directly and not filec.verifier.VerifyWinningPoSt? + ok, err := proofsffi.ProofVerifier.VerifyWinningPoSt(ctx, proof.WinningPoStVerifyInfo{ Randomness: rand, Proofs: h.WinPoStProof, ChallengedSectors: sectors, diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 9c6b5c87e7d..ccae5d49b01 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -35,12 +35,12 @@ import ( "github.com/filecoin-project/lotus/chain/consensus/filcns" genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis" "github.com/filecoin-project/lotus/chain/index" + "github.com/filecoin-project/lotus/chain/proofs" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/verifier" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/chain/wallet" "github.com/filecoin-project/lotus/cmd/lotus-seed/seed" @@ -349,7 +349,7 @@ func CarWalkFunc(nd format.Node) (out []*format.Link, err error) { } func (cg *ChainGen) nextBlockProof(ctx context.Context, pts *types.TipSet, m address.Address, round abi.ChainEpoch) ([]types.BeaconEntry, *types.ElectionProof, *types.Ticket, error) { - mc := &mca{w: cg.w, sm: cg.sm, pv: verifierffi.ProofVerifier, bcn: cg.beacon} + mc := &mca{w: cg.w, sm: cg.sm, pv: proofsffi.ProofVerifier, bcn: cg.beacon} mbi, err := mc.MinerGetBaseInfo(ctx, m, round, pts.Key()) if err != nil { @@ -602,7 +602,7 @@ type MiningCheckAPI interface { type mca struct { w *wallet.LocalWallet sm *stmgr.StateManager - pv verifier.Verifier + pv proofs.Verifier bcn beacon.Schedule } @@ -684,7 +684,7 @@ func ComputeVRF(ctx context.Context, sign SignFunc, worker address.Address, sigI type genFakeVerifier struct{} -var _ verifier.Verifier = (*genFakeVerifier)(nil) +var _ proofs.Verifier = (*genFakeVerifier)(nil) func (m genFakeVerifier) VerifySeal(svi proof7.SealVerifyInfo) (bool, error) { return true, nil diff --git a/chain/proofs/ffi/proofs.go b/chain/proofs/ffi/proofs.go new file mode 100644 index 00000000000..6408eb6e1bd --- /dev/null +++ b/chain/proofs/ffi/proofs.go @@ -0,0 +1,72 @@ +package proofsffi + +import ( + "math/bits" + + "github.com/ipfs/go-cid" + + ffi "github.com/filecoin-project/filecoin-ffi" + "github.com/filecoin-project/go-commp-utils/zerocomm" + "github.com/filecoin-project/go-state-types/abi" +) + +func GenerateUnsealedCID(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) { + ssize, err := proofType.SectorSize() + if err != nil { + return cid.Undef, err + } + + pssize := abi.PaddedPieceSize(ssize) + allPieces := make([]abi.PieceInfo, 0, len(pieces)) + if len(pieces) == 0 { + allPieces = append(allPieces, abi.PieceInfo{ + Size: pssize, + PieceCID: zerocomm.ZeroPieceCommitment(pssize.Unpadded()), + }) + } else { + var sum abi.PaddedPieceSize + + padTo := func(pads []abi.PaddedPieceSize) { + for _, p := range pads { + allPieces = append(allPieces, abi.PieceInfo{ + Size: p, + PieceCID: zerocomm.ZeroPieceCommitment(p.Unpadded()), + }) + + sum += p + } + } + + for _, p := range pieces { + ps, _ := GetRequiredPadding(sum, p.Size) + padTo(ps) + + allPieces = append(allPieces, p) + sum += p.Size + } + + ps, _ := GetRequiredPadding(sum, pssize) + padTo(ps) + } + + return ffi.GenerateUnsealedCID(proofType, allPieces) +} + +func GetRequiredPadding(oldLength abi.PaddedPieceSize, newPieceLength abi.PaddedPieceSize) ([]abi.PaddedPieceSize, abi.PaddedPieceSize) { + padPieces := make([]abi.PaddedPieceSize, 0) + toFill := uint64(-oldLength % newPieceLength) + + n := bits.OnesCount64(toFill) + var sum abi.PaddedPieceSize + for i := 0; i < n; i++ { + next := bits.TrailingZeros64(toFill) + psize := uint64(1) << uint(next) + toFill ^= psize + + padded := abi.PaddedPieceSize(psize) + padPieces = append(padPieces, padded) + sum += padded + } + + return padPieces, sum +} diff --git a/chain/proofs/ffi/proofs_test.go b/chain/proofs/ffi/proofs_test.go new file mode 100644 index 00000000000..98bff77112a --- /dev/null +++ b/chain/proofs/ffi/proofs_test.go @@ -0,0 +1,117 @@ +package proofsffi_test + +import ( + "bytes" + "testing" + + "github.com/ipfs/go-cid" + "github.com/stretchr/testify/require" + + ffi "github.com/filecoin-project/filecoin-ffi" + commpffi "github.com/filecoin-project/go-commp-utils/ffiwrapper" + "github.com/filecoin-project/go-state-types/abi" + + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" +) + +func TestGenerateUnsealedCID(t *testing.T) { + pt := abi.RegisteredSealProof_StackedDrg2KiBV1 + ups := int(abi.PaddedPieceSize(2048).Unpadded()) + + commP := func(b []byte) cid.Cid { + pf, werr, err := commpffi.ToReadableFile(bytes.NewReader(b), int64(len(b))) + require.NoError(t, err) + + c, err := ffi.GeneratePieceCIDFromFile(pt, pf, abi.UnpaddedPieceSize(len(b))) + require.NoError(t, err) + + require.NoError(t, werr()) + + return c + } + + testCommEq := func(name string, in [][]byte, expect [][]byte) { + t.Run(name, func(t *testing.T) { + upi := make([]abi.PieceInfo, len(in)) + for i, b := range in { + upi[i] = abi.PieceInfo{ + Size: abi.UnpaddedPieceSize(len(b)).Padded(), + PieceCID: commP(b), + } + } + + sectorPi := []abi.PieceInfo{ + { + Size: 2048, + PieceCID: commP(bytes.Join(expect, nil)), + }, + } + + expectCid, err := proofsffi.GenerateUnsealedCID(pt, sectorPi) + require.NoError(t, err) + + actualCid, err := proofsffi.GenerateUnsealedCID(pt, upi) + require.NoError(t, err) + + require.Equal(t, expectCid, actualCid) + }) + } + + barr := func(b byte, den int) []byte { + return bytes.Repeat([]byte{b}, ups/den) + } + + // 0000 + testCommEq("zero", + nil, + [][]byte{barr(0, 1)}, + ) + + // 1111 + testCommEq("one", + [][]byte{barr(1, 1)}, + [][]byte{barr(1, 1)}, + ) + + // 11 00 + testCommEq("one|2", + [][]byte{barr(1, 2)}, + [][]byte{barr(1, 2), barr(0, 2)}, + ) + + // 1 0 00 + testCommEq("one|4", + [][]byte{barr(1, 4)}, + [][]byte{barr(1, 4), barr(0, 4), barr(0, 2)}, + ) + + // 11 2 0 + testCommEq("one|2-two|4", + [][]byte{barr(1, 2), barr(2, 4)}, + [][]byte{barr(1, 2), barr(2, 4), barr(0, 4)}, + ) + + // 1 0 22 + testCommEq("one|4-two|2", + [][]byte{barr(1, 4), barr(2, 2)}, + [][]byte{barr(1, 4), barr(0, 4), barr(2, 2)}, + ) + + // 1 0 22 0000 + testCommEq("one|8-two|4", + [][]byte{barr(1, 8), barr(2, 4)}, + [][]byte{barr(1, 8), barr(0, 8), barr(2, 4), barr(0, 2)}, + ) + + // 11 2 0 0000 + testCommEq("one|4-two|8", + [][]byte{barr(1, 4), barr(2, 8)}, + [][]byte{barr(1, 4), barr(2, 8), barr(0, 8), barr(0, 2)}, + ) + + // 1 0 22 3 0 00 4444 5 0 00 + testCommEq("one|16-two|8-three|16-four|4-five|16", + [][]byte{barr(1, 16), barr(2, 8), barr(3, 16), barr(4, 4), barr(5, 16)}, + [][]byte{barr(1, 16), barr(0, 16), barr(2, 8), barr(3, 16), barr(0, 16), barr(0, 8), barr(4, 4), barr(5, 16), barr(0, 16), barr(0, 8)}, + ) +} diff --git a/chain/verifier/ffi/verifier_cgo.go b/chain/proofs/ffi/verifier_cgo.go similarity index 93% rename from chain/verifier/ffi/verifier_cgo.go rename to chain/proofs/ffi/verifier_cgo.go index f598287dd0e..e9de85c5ef4 100644 --- a/chain/verifier/ffi/verifier_cgo.go +++ b/chain/proofs/ffi/verifier_cgo.go @@ -1,7 +1,7 @@ //go:build cgo // +build cgo -package verifierffi +package proofsffi import ( "context" @@ -12,10 +12,10 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/go-state-types/proof" - "github.com/filecoin-project/lotus/chain/verifier" + "github.com/filecoin-project/lotus/chain/proofs" ) -var _ verifier.Verifier = ProofVerifier +var _ proofs.Verifier = ProofVerifier type proofVerifier struct{} diff --git a/chain/verifier/mock/mock.go b/chain/proofs/mock/mock.go similarity index 97% rename from chain/verifier/mock/mock.go rename to chain/proofs/mock/mock.go index b51d65547cd..575df073b85 100644 --- a/chain/verifier/mock/mock.go +++ b/chain/proofs/mock/mock.go @@ -9,10 +9,10 @@ import ( "github.com/filecoin-project/go-state-types/abi" prooftypes "github.com/filecoin-project/go-state-types/proof" - "github.com/filecoin-project/lotus/chain/verifier" + "github.com/filecoin-project/lotus/chain/proofs" ) -var _ verifier.Verifier = MockVerifier +var _ proofs.Verifier = MockVerifier type mockVerifier struct{} diff --git a/chain/verifier/verifier.go b/chain/proofs/verifier.go similarity index 97% rename from chain/verifier/verifier.go rename to chain/proofs/verifier.go index cac00e64508..9ca5b3f0836 100644 --- a/chain/verifier/verifier.go +++ b/chain/proofs/verifier.go @@ -1,4 +1,4 @@ -package verifier +package proofs import ( "context" diff --git a/chain/stmgr/actors.go b/chain/stmgr/actors.go index ff72a1cd713..bf597ffbf38 100644 --- a/chain/stmgr/actors.go +++ b/chain/stmgr/actors.go @@ -23,9 +23,9 @@ import ( "github.com/filecoin-project/lotus/chain/actors/builtin/power" "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/chain/beacon" + "github.com/filecoin-project/lotus/chain/proofs" "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/verifier" "github.com/filecoin-project/lotus/chain/vm" ) @@ -118,7 +118,7 @@ func MinerSectorInfo(ctx context.Context, sm *StateManager, maddr address.Addres return mas.GetSector(sid) } -func GetSectorsForWinningPoSt(ctx context.Context, nv network.Version, pv verifier.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]builtin.ExtendedSectorInfo, error) { +func GetSectorsForWinningPoSt(ctx context.Context, nv network.Version, pv proofs.Verifier, sm *StateManager, st cid.Cid, maddr address.Address, rand abi.PoStRandomness) ([]builtin.ExtendedSectorInfo, error) { act, err := sm.LoadActorRaw(ctx, maddr, st) if err != nil { return nil, xerrors.Errorf("failed to load miner actor: %w", err) @@ -302,7 +302,7 @@ func ListMinerActors(ctx context.Context, sm *StateManager, ts *types.TipSet) ([ return powState.ListAllMiners() } -func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule, tsk types.TipSetKey, round abi.ChainEpoch, maddr address.Address, pv verifier.Verifier) (*api.MiningBaseInfo, error) { +func MinerGetBaseInfo(ctx context.Context, sm *StateManager, bcs beacon.Schedule, tsk types.TipSetKey, round abi.ChainEpoch, maddr address.Address, pv proofs.Verifier) (*api.MiningBaseInfo, error) { ts, err := sm.ChainStore().LoadTipSet(ctx, tsk) if err != nil { return nil, xerrors.Errorf("failed to load tipset for mining base: %w", err) diff --git a/chain/vm/syscalls.go b/chain/vm/syscalls.go index 73d93a128bf..fc59a0e5ee9 100644 --- a/chain/vm/syscalls.go +++ b/chain/vm/syscalls.go @@ -24,11 +24,11 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" + "github.com/filecoin-project/lotus/chain/proofs" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/verifier" "github.com/filecoin-project/lotus/lib/sigs" - "github.com/filecoin-project/lotus/storage/sealer/ffiwrapper" ) func init() { @@ -39,7 +39,7 @@ func init() { type SyscallBuilder func(ctx context.Context, rt *Runtime) runtime7.Syscalls -func Syscalls(verifier verifier.Verifier) SyscallBuilder { +func Syscalls(verifier proofs.Verifier) SyscallBuilder { return func(ctx context.Context, rt *Runtime) runtime7.Syscalls { return &syscallShim{ @@ -66,11 +66,11 @@ type syscallShim struct { actor address.Address cstate *state.StateTree cst cbor.IpldStore - verifier verifier.Verifier + verifier proofs.Verifier } func (ss *syscallShim) ComputeUnsealedSectorCID(st abi.RegisteredSealProof, pieces []abi.PieceInfo) (cid.Cid, error) { - commd, err := ffiwrapper.GenerateUnsealedCID(st, pieces) + commd, err := proofsffi.GenerateUnsealedCID(st, pieces) if err != nil { log.Errorf("generate data commitment failed: %s", err) return cid.Undef, err diff --git a/cmd/lotus-bench/caching_verifier.go b/cmd/lotus-bench/caching_verifier.go index 96f49aa6320..9b17bda66cb 100644 --- a/cmd/lotus-bench/caching_verifier.go +++ b/cmd/lotus-bench/caching_verifier.go @@ -12,12 +12,12 @@ import ( "github.com/filecoin-project/go-state-types/abi" prooftypes "github.com/filecoin-project/go-state-types/proof" - "github.com/filecoin-project/lotus/chain/verifier" + "github.com/filecoin-project/lotus/chain/proofs" ) type cachingVerifier struct { ds datastore.Datastore - backend verifier.Verifier + backend proofs.Verifier } const bufsize = 128 @@ -107,4 +107,4 @@ func (cv cachingVerifier) VerifyReplicaUpdate(update prooftypes.ReplicaUpdateInf return cv.backend.VerifyReplicaUpdate(update) } -var _ verifier.Verifier = (*cachingVerifier)(nil) +var _ proofs.Verifier = (*cachingVerifier)(nil) diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index 94e77e7ad4d..500ef4af3ed 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -36,11 +36,11 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + "github.com/filecoin-project/lotus/chain/proofs" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/verifier" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" lcli "github.com/filecoin-project/lotus/cli" _ "github.com/filecoin-project/lotus/lib/sigs/bls" @@ -207,7 +207,7 @@ var importBenchCmd = &cli.Command{ defer c.Close() //nolint:errcheck } - var verifier verifier.Verifier = verifierffi.ProofVerifier + var verifier proofs.Verifier = proofsffi.ProofVerifier if cctx.IsSet("syscall-cache") { scds, err := badger.NewDatastore(cctx.String("syscall-cache"), &badger.DefaultOptions) if err != nil { diff --git a/cmd/lotus-bench/main.go b/cmd/lotus-bench/main.go index 59c8c605f68..ccb131ae970 100644 --- a/cmd/lotus-bench/main.go +++ b/cmd/lotus-bench/main.go @@ -25,8 +25,8 @@ import ( lapi "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors/builtin/miner" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/genesis" "github.com/filecoin-project/lotus/storage/sealer/ffiwrapper" @@ -344,7 +344,7 @@ var sealBenchCmd = &cli.Command{ return err } - fcandidates, err := verifierffi.ProofVerifier.GenerateWinningPoStSectorChallenge(context.TODO(), wipt, mid, challenge[:], uint64(len(extendedSealedSectors))) + fcandidates, err := proofsffi.ProofVerifier.GenerateWinningPoStSectorChallenge(context.TODO(), wipt, mid, challenge[:], uint64(len(extendedSealedSectors))) if err != nil { return err } @@ -387,7 +387,7 @@ var sealBenchCmd = &cli.Command{ ChallengedSectors: candidates, Prover: mid, } - ok, err := verifierffi.ProofVerifier.VerifyWinningPoSt(context.TODO(), pvi1) + ok, err := proofsffi.ProofVerifier.VerifyWinningPoSt(context.TODO(), pvi1) if err != nil { return err } @@ -404,7 +404,7 @@ var sealBenchCmd = &cli.Command{ Prover: mid, } - ok, err = verifierffi.ProofVerifier.VerifyWinningPoSt(context.TODO(), pvi2) + ok, err = proofsffi.ProofVerifier.VerifyWinningPoSt(context.TODO(), pvi2) if err != nil { return err } @@ -445,7 +445,7 @@ var sealBenchCmd = &cli.Command{ ChallengedSectors: sealedSectors, Prover: mid, } - ok, err = verifierffi.ProofVerifier.VerifyWindowPoSt(context.TODO(), wpvi1) + ok, err = proofsffi.ProofVerifier.VerifyWindowPoSt(context.TODO(), wpvi1) if err != nil { return err } @@ -461,7 +461,7 @@ var sealBenchCmd = &cli.Command{ ChallengedSectors: sealedSectors, Prover: mid, } - ok, err = verifierffi.ProofVerifier.VerifyWindowPoSt(context.TODO(), wpvi2) + ok, err = proofsffi.ProofVerifier.VerifyWindowPoSt(context.TODO(), wpvi2) if err != nil { return err } @@ -679,7 +679,7 @@ func runSeals(sb *ffiwrapper.Sealer, sbfs *basicfs.Provider, numSectors int, par UnsealedCID: cids.Unsealed, } - ok, err := verifierffi.ProofVerifier.VerifySeal(svi) + ok, err := proofsffi.ProofVerifier.VerifySeal(svi) if err != nil { return err } diff --git a/cmd/lotus-seed/genesis.go b/cmd/lotus-seed/genesis.go index 204bf265833..ba0896fe804 100644 --- a/cmd/lotus-seed/genesis.go +++ b/cmd/lotus-seed/genesis.go @@ -22,8 +22,8 @@ import ( "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/gen" genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/genesis" "github.com/filecoin-project/lotus/journal" @@ -575,7 +575,7 @@ var genesisCarCmd = &cli.Command{ ofile := c.String("out") jrnl := journal.NilJournal() bstor := blockstore.WrapIDStore(blockstore.NewMemorySync()) - sbldr := vm.Syscalls(verifierffi.ProofVerifier) + sbldr := vm.Syscalls(proofsffi.ProofVerifier) _, err := testing.MakeGenesis(ofile, c.Args().First())(bstor, sbldr, jrnl)() return err diff --git a/cmd/lotus-shed/balances.go b/cmd/lotus-shed/balances.go index 0e6036e5665..ea135fc9a61 100644 --- a/cmd/lotus-shed/balances.go +++ b/cmd/lotus-shed/balances.go @@ -36,11 +36,11 @@ import ( "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/gen/genesis" "github.com/filecoin-project/lotus/chain/index" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/node/repo" @@ -514,7 +514,7 @@ var chainBalanceStateCmd = &cli.Command{ cst := cbor.NewCborStore(bs) store := adt.WrapStore(ctx, cst) - sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) + sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) if err != nil { return err } @@ -738,7 +738,7 @@ var chainPledgeCmd = &cli.Command{ cst := cbor.NewCborStore(bs) store := adt.WrapStore(ctx, cst) - sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) + sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) if err != nil { return err } diff --git a/cmd/lotus-shed/gas-estimation.go b/cmd/lotus-shed/gas-estimation.go index 734d91a886b..3b2281eeeda 100644 --- a/cmd/lotus-shed/gas-estimation.go +++ b/cmd/lotus-shed/gas-estimation.go @@ -20,10 +20,10 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/node/repo" @@ -107,7 +107,7 @@ var gasTraceCmd = &cli.Command{ cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil) defer cs.Close() //nolint:errcheck - sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), shd, mds, index.DummyMsgIndex) + sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), shd, mds, index.DummyMsgIndex) if err != nil { return err } @@ -203,7 +203,7 @@ var replayOfflineCmd = &cli.Command{ cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil) defer cs.Close() //nolint:errcheck - sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), shd, mds, index.DummyMsgIndex) + sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), shd, mds, index.DummyMsgIndex) if err != nil { return err } diff --git a/cmd/lotus-shed/invariants.go b/cmd/lotus-shed/invariants.go index 947a87e5acd..b749fad8aa9 100644 --- a/cmd/lotus-shed/invariants.go +++ b/cmd/lotus-shed/invariants.go @@ -29,10 +29,10 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/node/repo" @@ -126,7 +126,7 @@ var invariantsCmd = &cli.Command{ cs := store.NewChainStore(bs, bs, mds, filcns.Weight, nil) defer cs.Close() //nolint:errcheck - sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) + sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) if err != nil { return err } diff --git a/cmd/lotus-shed/migrations.go b/cmd/lotus-shed/migrations.go index e53d72f6bc5..b2f64ee77c1 100644 --- a/cmd/lotus-shed/migrations.go +++ b/cmd/lotus-shed/migrations.go @@ -61,11 +61,11 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/lib/must" @@ -176,7 +176,7 @@ var migrationsCmd = &cli.Command{ defer cs.Close() //nolint:errcheck // Note: we use a map datastore for the metadata to avoid writing / using cached migration results in the metadata store - sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, datastore.NewMapDatastore(), index.DummyMsgIndex) + sm, err := stmgr.NewStateManager(cs, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, datastore.NewMapDatastore(), index.DummyMsgIndex) if err != nil { return err } diff --git a/cmd/lotus-shed/state-stats.go b/cmd/lotus-shed/state-stats.go index 9789b805801..914fe1c0529 100644 --- a/cmd/lotus-shed/state-stats.go +++ b/cmd/lotus-shed/state-stats.go @@ -34,10 +34,10 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/node/repo" @@ -259,7 +259,7 @@ func loadChainStore(ctx context.Context, repoPath string) (*StoreHandle, error) } tsExec := consensus.NewTipSetExecutor(filcns.RewardFunc) - sm, err := stmgr.NewStateManager(cs, tsExec, vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) + sm, err := stmgr.NewStateManager(cs, tsExec, vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), nil, mds, index.DummyMsgIndex) if err != nil { return nil, fmt.Errorf("failed to open state manager: %w", err) } diff --git a/cmd/lotus-sim/simulation/mock/mock.go b/cmd/lotus-sim/simulation/mock/mock.go index 4d37b13f456..bc37b3aff48 100644 --- a/cmd/lotus-sim/simulation/mock/mock.go +++ b/cmd/lotus-sim/simulation/mock/mock.go @@ -15,7 +15,7 @@ import ( miner5 "github.com/filecoin-project/specs-actors/v5/actors/builtin/miner" tutils "github.com/filecoin-project/specs-actors/v5/support/testing" - "github.com/filecoin-project/lotus/chain/verifier" + "github.com/filecoin-project/lotus/chain/proofs" ) // Ideally, we'd use extern/sealer/mock. Unfortunately, those mocks are a bit _too_ accurate @@ -32,7 +32,7 @@ var log = logging.Logger("simulation-mock") // mockVerifier is a simple mock for verifying "fake" proofs. type mockVerifier struct{} -var Verifier verifier.Verifier = mockVerifier{} +var Verifier proofs.Verifier = mockVerifier{} func (mockVerifier) VerifySeal(proof prooftypes.SealVerifyInfo) (bool, error) { addr, err := address.NewIDAddress(uint64(proof.Miner)) diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index f2f24b2b1b8..01ef080c9a2 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -37,10 +37,10 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" lcli "github.com/filecoin-project/lotus/cli" "github.com/filecoin-project/lotus/journal" @@ -612,7 +612,7 @@ func ImportChain(ctx context.Context, r repo.Repo, fname string, snapshot bool) return xerrors.Errorf("failed to construct beacon schedule: %w", err) } - stm, err := stmgr.NewStateManager(cst, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(verifierffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), shd, mds, index.DummyMsgIndex) + stm, err := stmgr.NewStateManager(cst, consensus.NewTipSetExecutor(filcns.RewardFunc), vm.Syscalls(proofsffi.ProofVerifier), filcns.DefaultUpgradeSchedule(), shd, mds, index.DummyMsgIndex) if err != nil { return err } diff --git a/conformance/driver.go b/conformance/driver.go index d33b1f341bb..f0dd5cc2a4c 100644 --- a/conformance/driver.go +++ b/conformance/driver.go @@ -23,12 +23,12 @@ import ( "github.com/filecoin-project/lotus/chain/consensus" "github.com/filecoin-project/lotus/chain/consensus/filcns" "github.com/filecoin-project/lotus/chain/index" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/rand" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/conformance/chaos" _ "github.com/filecoin-project/lotus/lib/sigs/bls" // enable bls signatures @@ -106,7 +106,7 @@ type ExecuteTipsetParams struct { func (d *Driver) ExecuteTipset(bs blockstore.Blockstore, ds ds.Batching, params ExecuteTipsetParams) (*ExecuteTipsetResult, error) { var ( tipset = params.Tipset - syscalls = vm.Syscalls(verifierffi.ProofVerifier) + syscalls = vm.Syscalls(proofsffi.ProofVerifier) cs = store.NewChainStore(bs, bs, ds, filcns.Weight, nil) tse = consensus.NewTipSetExecutor(filcns.RewardFunc) @@ -252,7 +252,7 @@ func (d *Driver) ExecuteMessage(bs blockstore.Blockstore, params ExecuteMessageP Epoch: params.Epoch, Timestamp: params.Timestamp, Bstore: bs, - Syscalls: vm.Syscalls(verifierffi.ProofVerifier), + Syscalls: vm.Syscalls(proofsffi.ProofVerifier), CircSupplyCalc: func(_ context.Context, _ abi.ChainEpoch, _ *state.StateTree) (abi.TokenAmount, error) { return params.CircSupply, nil }, diff --git a/itests/kit/ensemble.go b/itests/kit/ensemble.go index 9ee7891eb9c..5a62d4eb12f 100644 --- a/itests/kit/ensemble.go +++ b/itests/kit/ensemble.go @@ -43,10 +43,10 @@ import ( "github.com/filecoin-project/lotus/chain/gen" genesis2 "github.com/filecoin-project/lotus/chain/gen/genesis" "github.com/filecoin-project/lotus/chain/messagepool" + "github.com/filecoin-project/lotus/chain/proofs" + proofsmock "github.com/filecoin-project/lotus/chain/proofs/mock" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/verifier" - verifiermock "github.com/filecoin-project/lotus/chain/verifier/mock" "github.com/filecoin-project/lotus/chain/wallet/key" "github.com/filecoin-project/lotus/cmd/curio/deps" "github.com/filecoin-project/lotus/cmd/curio/rpc" @@ -470,7 +470,7 @@ func (n *Ensemble) Start() *Ensemble { // Are we mocking proofs? if n.options.mockProofs { opts = append(opts, - node.Override(new(verifier.Verifier), verifiermock.MockVerifier), + node.Override(new(proofs.Verifier), proofsmock.MockVerifier), node.Override(new(storiface.Verifier), mock.MockVerifier), node.Override(new(storiface.Prover), mock.MockProver), ) @@ -794,7 +794,7 @@ func (n *Ensemble) Start() *Ensemble { node.Override(new(sectorstorage.Unsealer), node.From(new(*mock.SectorMgr))), node.Override(new(sectorstorage.PieceProvider), node.From(new(*mock.SectorMgr))), - node.Override(new(verifier.Verifier), verifiermock.MockVerifier), + node.Override(new(proofs.Verifier), proofsmock.MockVerifier), node.Override(new(storiface.Verifier), mock.MockVerifier), node.Override(new(storiface.Prover), mock.MockProver), node.Unset(new(*sectorstorage.Manager)), diff --git a/node/builder_chain.go b/node/builder_chain.go index 94a991d07e2..edc70705356 100644 --- a/node/builder_chain.go +++ b/node/builder_chain.go @@ -24,11 +24,11 @@ import ( "github.com/filecoin-project/lotus/chain/market" "github.com/filecoin-project/lotus/chain/messagepool" "github.com/filecoin-project/lotus/chain/messagesigner" + "github.com/filecoin-project/lotus/chain/proofs" + proofsffi "github.com/filecoin-project/lotus/chain/proofs/ffi" "github.com/filecoin-project/lotus/chain/stmgr" rpcstmgr "github.com/filecoin-project/lotus/chain/stmgr/rpc" "github.com/filecoin-project/lotus/chain/store" - "github.com/filecoin-project/lotus/chain/verifier" - verifierffi "github.com/filecoin-project/lotus/chain/verifier/ffi" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/chain/wallet" ledgerwallet "github.com/filecoin-project/lotus/chain/wallet/ledger" @@ -69,8 +69,8 @@ var ChainNode = Options( Override(new(dtypes.DrandBootstrap), modules.DrandBootstrap), // Consensus: crypto dependencies - Override(new(verifier.Verifier), ffiwrapper.ProofVerifier), - Override(new(storiface.Verifier), verifierffi.ProofVerifier), + Override(new(proofs.Verifier), ffiwrapper.ProofVerifier), + Override(new(storiface.Verifier), proofsffi.ProofVerifier), Override(new(storiface.Prover), ffiwrapper.ProofProver), // Consensus: LegacyVM diff --git a/node/impl/full/state.go b/node/impl/full/state.go index ef9fdbbd06a..58159fb6d70 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -42,11 +42,11 @@ import ( "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/beacon" "github.com/filecoin-project/lotus/chain/consensus" + "github.com/filecoin-project/lotus/chain/proofs" "github.com/filecoin-project/lotus/chain/state" "github.com/filecoin-project/lotus/chain/stmgr" "github.com/filecoin-project/lotus/chain/store" "github.com/filecoin-project/lotus/chain/types" - "github.com/filecoin-project/lotus/chain/verifier" "github.com/filecoin-project/lotus/chain/vm" "github.com/filecoin-project/lotus/chain/wallet" "github.com/filecoin-project/lotus/node/modules/dtypes" @@ -97,7 +97,7 @@ type StateAPI struct { StateModuleAPI - ProofVerifier verifier.Verifier + ProofVerifier proofs.Verifier StateManager *stmgr.StateManager Chain *store.ChainStore Beacon beacon.Schedule