Skip to content

Commit

Permalink
test: niporep: use aggregate proofs for ni-porep
Browse files Browse the repository at this point in the history
  • Loading branch information
rvagg committed May 29, 2024
1 parent 003a581 commit 013b8d1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 22 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
65 changes: 44 additions & 21 deletions itests/manual_onboarding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -148,7 +156,7 @@ func TestManualCCOnboarding(t *testing.T) {
minerB.ActorAddr,
bSectorNum,
sealRandEpoch,
kit.TestSpt,
sealProofType,
)
}

Expand All @@ -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,
}},
Expand Down Expand Up @@ -190,7 +198,7 @@ func TestManualCCOnboarding(t *testing.T) {
sealedCid[bSectorNum],
unsealedCid[bSectorNum],
sealTickets[bSectorNum],
kit.TestSpt,
sealProofType,
)
}

Expand Down Expand Up @@ -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")
Expand All @@ -244,10 +256,10 @@ func TestManualCCOnboarding(t *testing.T) {
minerC.ActorAddr,
cSectorNum,
sealRandEpoch,
kit.TestSptNi,
nonInteractiveSealProofType,
)

sectorProof = manualOnboardingGenerateProveCommit(
sectorProofCircuits := manualOnboardingGenerateProveCommit(
ctx,
t,
client,
Expand All @@ -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,
Expand All @@ -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)
Expand All @@ -294,7 +316,7 @@ func TestManualCCOnboarding(t *testing.T) {
cacheDirPath[cSectorNum],
sealedSectorPath[cSectorNum],
sealedCid[cSectorNum],
kit.TestSptNi,
nonInteractiveSealProofType,
)

checkPostSchedulers := func() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 013b8d1

Please sign in to comment.