From 6278bdc69a2fa614a38ac1a24f07460cf3550212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Mon, 17 May 2021 20:47:41 +0200 Subject: [PATCH] Make things build --- chain/actors/policy/policy.go | 4 ++++ chain/gen/gen.go | 2 +- cmd/lotus-bench/caching_verifier.go | 9 +++++++++ extern/sector-storage/ffiwrapper/sealer_test.go | 5 +++-- extern/sector-storage/ffiwrapper/types.go | 2 +- extern/sector-storage/ffiwrapper/verifier_cgo.go | 4 ++-- extern/sector-storage/mock/mock.go | 2 +- extern/storage-sealing/commit_batch.go | 14 ++++++-------- extern/storage-sealing/states_sealing.go | 1 - storage/wdpost_run_test.go | 9 +++++++++ 10 files changed, 36 insertions(+), 16 deletions(-) diff --git a/chain/actors/policy/policy.go b/chain/actors/policy/policy.go index 191ffb5f5..113544c05 100644 --- a/chain/actors/policy/policy.go +++ b/chain/actors/policy/policy.go @@ -302,6 +302,10 @@ func GetDefaultSectorSize() abi.SectorSize { return szs[0] } +func GetDefaultAggregationProof() abi.RegisteredAggregationProof { + return abi.RegisteredAggregationProof_SnarkPackV1 +} + func GetSectorMaxLifetime(proof abi.RegisteredSealProof, nwVer network.Version) abi.ChainEpoch { if nwVer <= network.Version10 { return builtin5.SealProofPoliciesV0[proof].SectorMaxLifetime diff --git a/chain/gen/gen.go b/chain/gen/gen.go index af2611676..32b238433 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -693,7 +693,7 @@ func (m genFakeVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVeri panic("not supported") } -func (m genFakeVerifier) AggregateSealProofs(proofType abi.RegisteredSealProof, proofs [][]byte) ([]byte, error) { +func (m genFakeVerifier) AggregateSealProofs(proofType abi.RegisteredSealProof, rap abi.RegisteredAggregationProof, proofs [][]byte) ([]byte, error) { panic("not supported") } diff --git a/cmd/lotus-bench/caching_verifier.go b/cmd/lotus-bench/caching_verifier.go index 5b434c762..55786c585 100644 --- a/cmd/lotus-bench/caching_verifier.go +++ b/cmd/lotus-bench/caching_verifier.go @@ -8,6 +8,7 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper" proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" + proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" "github.com/ipfs/go-datastore" "github.com/minio/blake2b-simd" cbg "github.com/whyrusleeping/cbor-gen" @@ -96,4 +97,12 @@ func (cv *cachingVerifier) GenerateWinningPoStSectorChallenge(ctx context.Contex return cv.backend.GenerateWinningPoStSectorChallenge(ctx, proofType, a, rnd, u) } +func (cv cachingVerifier) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) { + return cv.backend.VerifyAggregateSeals(aggregate) +} + +func (cv cachingVerifier) AggregateSealProofs(proofType abi.RegisteredSealProof, rap abi.RegisteredAggregationProof, proofs [][]byte) ([]byte, error) { + return cv.backend.AggregateSealProofs(proofType, rap, proofs) +} + var _ ffiwrapper.Verifier = (*cachingVerifier)(nil) diff --git a/extern/sector-storage/ffiwrapper/sealer_test.go b/extern/sector-storage/ffiwrapper/sealer_test.go index 5af6a78e7..a1b27cc87 100644 --- a/extern/sector-storage/ffiwrapper/sealer_test.go +++ b/extern/sector-storage/ffiwrapper/sealer_test.go @@ -32,6 +32,7 @@ import ( ffi "github.com/filecoin-project/filecoin-ffi" + "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/extern/sector-storage/ffiwrapper/basicfs" "github.com/filecoin-project/lotus/extern/sector-storage/storiface" "github.com/filecoin-project/lotus/extern/storage-sealing/lib/nullreader" @@ -538,12 +539,12 @@ func TestSealAndVerifyAggregate(t *testing.T) { aggStart := time.Now() - avi.Proof, err = ProofVerifier.AggregateSealProofs(sealProofType, toAggregate) + avi.Proof, err = ProofVerifier.AggregateSealProofs(sealProofType, policy.GetDefaultAggregationProof(), toAggregate) require.NoError(t, err) aggDone := time.Now() - _, err = ProofVerifier.AggregateSealProofs(sealProofType, toAggregate) + _, err = ProofVerifier.AggregateSealProofs(sealProofType, policy.GetDefaultAggregationProof(), toAggregate) require.NoError(t, err) aggHot := time.Now() diff --git a/extern/sector-storage/ffiwrapper/types.go b/extern/sector-storage/ffiwrapper/types.go index 9c84794bf..aa0658397 100644 --- a/extern/sector-storage/ffiwrapper/types.go +++ b/extern/sector-storage/ffiwrapper/types.go @@ -42,7 +42,7 @@ type Verifier interface { GenerateWinningPoStSectorChallenge(context.Context, abi.RegisteredPoStProof, abi.ActorID, abi.PoStRandomness, uint64) ([]uint64, error) // cheap, makes no sense to put this on the storage interface - AggregateSealProofs(proofType abi.RegisteredSealProof, proofs [][]byte) ([]byte, error) + AggregateSealProofs(proofType abi.RegisteredSealProof, rap abi.RegisteredAggregationProof, proofs [][]byte) ([]byte, error) } type SectorProvider interface { diff --git a/extern/sector-storage/ffiwrapper/verifier_cgo.go b/extern/sector-storage/ffiwrapper/verifier_cgo.go index b31903080..2650fba02 100644 --- a/extern/sector-storage/ffiwrapper/verifier_cgo.go +++ b/extern/sector-storage/ffiwrapper/verifier_cgo.go @@ -140,6 +140,6 @@ func (proofVerifier) GenerateWinningPoStSectorChallenge(ctx context.Context, pro return ffi.GenerateWinningPoStSectorChallenge(proofType, minerID, randomness, eligibleSectorCount) } -func (v proofVerifier) AggregateSealProofs(proofType abi.RegisteredSealProof, proofs [][]byte) ([]byte, error) { - return ffi.AggregateSealProofs(proofType, proofs) +func (v proofVerifier) AggregateSealProofs(proofType abi.RegisteredSealProof, rap abi.RegisteredAggregationProof, proofs [][]byte) ([]byte, error) { + return ffi.AggregateSealProofs(proofType, rap, proofs) } diff --git a/extern/sector-storage/mock/mock.go b/extern/sector-storage/mock/mock.go index ec6020010..8a70ed7bd 100644 --- a/extern/sector-storage/mock/mock.go +++ b/extern/sector-storage/mock/mock.go @@ -524,7 +524,7 @@ func (m mockVerif) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProo return bytes.Equal(aggregate.Proof, out), nil } -func (m mockVerif) AggregateSealProofs(proofType abi.RegisteredSealProof, proofs [][]byte) ([]byte, error) { +func (m mockVerif) AggregateSealProofs(proofType abi.RegisteredSealProof, rap abi.RegisteredAggregationProof, proofs [][]byte) ([]byte, error) { out := make([]byte, 200) // todo: figure out more real length for pi, proof := range proofs { for i := range proof[:32] { diff --git a/extern/storage-sealing/commit_batch.go b/extern/storage-sealing/commit_batch.go index 74f163010..8b5d9b543 100644 --- a/extern/storage-sealing/commit_batch.go +++ b/extern/storage-sealing/commit_batch.go @@ -28,13 +28,16 @@ var ( CommitBatchWait = 5 * time.Minute ) +const arp = abi.RegisteredAggregationProof_SnarkPackV1 + type CommitBatcherApi interface { SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, maxFee abi.TokenAmount, params []byte) (cid.Cid, error) StateMinerInfo(context.Context, address.Address, TipSetToken) (miner.MinerInfo, error) } type AggregateInput struct { - // TODO: Something changed in actors, I think this now needs to be AggregateSealVerifyProofAndInfos + spt abi.RegisteredSealProof + // TODO: Something changed in actors, I think this now needs to be AggregateSealVerifyProofAndInfos todo ?? info proof5.AggregateSealVerifyInfo proof []byte } @@ -137,20 +140,15 @@ func (b *CommitBatcher) processBatch(notif, after bool) (*cid.Cid, error) { return nil, nil } - spt := b.todo[0].info.SealProof + spt := b.todo[0].spt proofs := make([][]byte, total) for id, p := range b.todo { - if p.info.SealProof != spt { - // todo: handle when we'll have proof upgrade - return nil, xerrors.Errorf("different seal proof types in commit batch: %w", err) - } - params.SectorNumbers.Set(uint64(id)) proofs[id] = p.proof } - params.AggregateProof, err = b.verif.AggregateSealProofs(spt, proofs) + params.AggregateProof, err = b.verif.AggregateSealProofs(spt, arp, proofs) if err != nil { return nil, xerrors.Errorf("aggregating proofs: %w", err) } diff --git a/extern/storage-sealing/states_sealing.go b/extern/storage-sealing/states_sealing.go index 296d92b9c..9975b1a37 100644 --- a/extern/storage-sealing/states_sealing.go +++ b/extern/storage-sealing/states_sealing.go @@ -531,7 +531,6 @@ func (m *Sealing) handleSubmitCommitAggregate(ctx statemachine.Context, sector S mcid, err := m.commiter.AddCommit(ctx.Context(), sector.SectorNumber, AggregateInput{ info: proof.AggregateSealVerifyInfo{ Number: sector.SectorNumber, - DealIDs: sector.dealIDs(), Randomness: sector.TicketValue, InteractiveRandomness: sector.SeedValue, SealedCID: *sector.CommR, diff --git a/storage/wdpost_run_test.go b/storage/wdpost_run_test.go index 4bf30e3e9..2e412880a 100644 --- a/storage/wdpost_run_test.go +++ b/storage/wdpost_run_test.go @@ -23,6 +23,7 @@ import ( miner2 "github.com/filecoin-project/specs-actors/v2/actors/builtin/miner" proof2 "github.com/filecoin-project/specs-actors/v2/actors/runtime/proof" tutils "github.com/filecoin-project/specs-actors/v2/support/testing" + proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" @@ -144,6 +145,14 @@ func (m mockVerif) VerifyWindowPoSt(ctx context.Context, info proof2.WindowPoStV return true, nil } +func (m mockVerif) AggregateSealProofs(proofType abi.RegisteredSealProof, rap abi.RegisteredAggregationProof, proofs [][]byte) ([]byte, error) { + panic("implement me") +} + +func (m mockVerif) VerifyAggregateSeals(aggregate proof5.AggregateSealVerifyProofAndInfos) (bool, error) { + panic("implement me") +} + func (m mockVerif) VerifySeal(proof2.SealVerifyInfo) (bool, error) { panic("implement me") }