From 013b8d196936cf65584c9ae57c08a966c7e70f8f Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 29 May 2024 16:20:11 +1000 Subject: [PATCH] test: niporep: use aggregate proofs for ni-porep --- go.mod | 2 +- go.sum | 2 + itests/manual_onboarding_test.go | 65 +++++++++++++++++++++----------- 3 files changed, 47 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 68f710fe80d..b3340b935cc 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/filecoin-project/go-jsonrpc v0.3.2 github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-paramfetch v0.0.4 - github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240529001730-3bfff718e9cc + github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240529052523-2d27210dc3cd github.com/filecoin-project/go-statemachine v1.0.3 github.com/filecoin-project/go-statestore v0.2.0 github.com/filecoin-project/go-storedcounter v0.1.0 diff --git a/go.sum b/go.sum index 7cf1628a291..04542b45b9e 100644 --- a/go.sum +++ b/go.sum @@ -301,6 +301,8 @@ github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/ github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q= github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240529001730-3bfff718e9cc h1:waUN6BYKWlun/O5fT1Fo5/7xtKv98tTG1UWdzZN8Lxk= github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240529001730-3bfff718e9cc/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= +github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240529052523-2d27210dc3cd h1:i341g+sCAYZFxNg+vLswxoQmAmOYeklVqUoPN8b3YBo= +github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240529052523-2d27210dc3cd/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= github.com/filecoin-project/go-statemachine v1.0.3 h1:N07o6alys+V1tNoSTi4WuuoeNC4erS/6jE74+NsgQuk= github.com/filecoin-project/go-statemachine v1.0.3/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54= github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZOinUJB4WARkRfNl10O7kTnI= diff --git a/itests/manual_onboarding_test.go b/itests/manual_onboarding_test.go index 4c6e5fe6490..9f36da21496 100644 --- a/itests/manual_onboarding_test.go +++ b/itests/manual_onboarding_test.go @@ -25,6 +25,7 @@ import ( "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" + "github.com/filecoin-project/lotus/chain/actors/builtin/miner" "github.com/filecoin-project/lotus/chain/actors/policy" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/itests/kit" @@ -104,6 +105,13 @@ func TestManualCCOnboarding(t *testing.T) { build.Clock.Sleep(time.Second) + nv, err := client.StateNetworkVersion(ctx, types.EmptyTSK) + req.NoError(err) + sealProofType, err := miner.SealProofTypeFromSectorSize(sectorSize, nv, miner.SealProofVariant_Standard) + req.NoError(err) + nonInteractiveSealProofType, err := miner.SealProofTypeFromSectorSize(sectorSize, nv, miner.SealProofVariant_NonInteractive) + req.NoError(err) + head, err := client.ChainHead(ctx) req.NoError(err) @@ -148,7 +156,7 @@ func TestManualCCOnboarding(t *testing.T) { minerB.ActorAddr, bSectorNum, sealRandEpoch, - kit.TestSpt, + sealProofType, ) } @@ -158,7 +166,7 @@ func TestManualCCOnboarding(t *testing.T) { Sectors: []miner14.SectorPreCommitInfo{{ Expiration: 2880 * 300, SectorNumber: bSectorNum, - SealProof: kit.TestSpt, + SealProof: sealProofType, SealedCID: sealedCid[bSectorNum], SealRandEpoch: sealRandEpoch, }}, @@ -190,7 +198,7 @@ func TestManualCCOnboarding(t *testing.T) { sealedCid[bSectorNum], unsealedCid[bSectorNum], sealTickets[bSectorNum], - kit.TestSpt, + sealProofType, ) } @@ -220,11 +228,15 @@ func TestManualCCOnboarding(t *testing.T) { cacheDirPath[bSectorNum], sealedSectorPath[bSectorNum], sealedCid[bSectorNum], - kit.TestSpt, + sealProofType, ) // NI-PoRep + actorIdNum, err := address.IDFromAddress(minerC.ActorAddr) + req.NoError(err) + actorId := abi.ActorID(actorIdNum) + if withMockProofs { sectorProof = []byte{0xde, 0xad, 0xbe, 0xef} sealedCid[cSectorNum] = cid.MustParse("bagboea4b5abcatlxechwbp7kjpjguna6r6q7ejrhe6mdp3lf34pmswn27pkkiekz") @@ -244,10 +256,10 @@ func TestManualCCOnboarding(t *testing.T) { minerC.ActorAddr, cSectorNum, sealRandEpoch, - kit.TestSptNi, + nonInteractiveSealProofType, ) - sectorProof = manualOnboardingGenerateProveCommit( + sectorProofCircuits := manualOnboardingGenerateProveCommit( ctx, t, client, @@ -258,16 +270,26 @@ func TestManualCCOnboarding(t *testing.T) { sealedCid[cSectorNum], unsealedCid[cSectorNum], sealTickets[cSectorNum], - kit.TestSptNi, + nonInteractiveSealProofType, ) + + sectorProof, err = ffi.AggregateSealProofs(proof.AggregateSealVerifyProofAndInfos{ + Miner: actorId, + SealProof: nonInteractiveSealProofType, + AggregateProof: abi.RegisteredAggregationProof_SnarkPackV2, + Infos: []proof.AggregateSealVerifyInfo{{ + Number: cSectorNum, + Randomness: sealTickets[cSectorNum], + InteractiveRandomness: nil, + SealedCID: sealedCid[cSectorNum], + UnsealedCID: unsealedCid[cSectorNum], + }}, + }, [][]byte{sectorProofCircuits}) + req.NoError(err) } t.Log("Submitting MinerC ProveCommitSectorsNI ...") - actorIdNum, err := address.IDFromAddress(minerC.ActorAddr) - req.NoError(err) - actorId := abi.ActorID(actorIdNum) - r, err = manualOnboardingSubmitMessage(ctx, client, minerC, &miner14.ProveCommitSectorsNIParams{ Sectors: []miner14.SectorNIActivationInfo{{ SealingNumber: cSectorNum, @@ -277,7 +299,7 @@ func TestManualCCOnboarding(t *testing.T) { SealRandEpoch: sealRandEpoch, Expiration: 2880 * 300, }}, - SealProofType: kit.TestSptNi, + SealProofType: nonInteractiveSealProofType, SectorProofs: [][]byte{sectorProof}, RequireActivationSuccess: true, }, 1, builtin.MethodsMiner.ProveCommitSectorsNI) @@ -294,7 +316,7 @@ func TestManualCCOnboarding(t *testing.T) { cacheDirPath[cSectorNum], sealedSectorPath[cSectorNum], sealedCid[cSectorNum], - kit.TestSptNi, + nonInteractiveSealProofType, ) checkPostSchedulers := func() { @@ -461,7 +483,7 @@ func manualOnboardingGenerateProveCommit( var seedRandomnessHeight abi.ChainEpoch - if proofType >= abi.RegisteredSealProof_StackedDrg2KiBV1_2_Feat_NiPoRep && proofType <= abi.RegisteredSealProof_StackedDrg64GiBV1_2_Feat_NiPoRep { + if proofType.IsNonInteractive() { // this just needs to be somewhere between 6 months and chain finality for NI-PoRep, // and there's no PreCommitInfo because it's non-interactive! seedRandomnessHeight = head.Height() - policy.ChainFinality @@ -500,16 +522,17 @@ func manualOnboardingGenerateProveCommit( t.Logf("Running proof type %d SealCommitPhase2 for sector %d...", proofType, sectorNumber) - sectorProof, err := ffi.SealCommitPhase2(scp1, sectorNumber, actorId) - req.NoError(err) + var sectorProof []byte + if proofType.IsNonInteractive() { + sectorProof, err = ffi.SealCommitPhase2CircuitProofs(scp1, sectorNumber) + req.NoError(err) + } else { + sectorProof, err = ffi.SealCommitPhase2(scp1, sectorNumber, actorId) + req.NoError(err) + } t.Logf("Got proof type %d sector proof of length %d", proofType, len(sectorProof)) - /* this variant would be used for aggregating NI-PoRep proofs - sectorProof, err := ffi.SealCommitPhase2CircuitProofs(scp1, sectorNumber) - req.NoError(err) - */ - return sectorProof }