Skip to content

Commit c97a43a

Browse files
vmxStebalienrvaggcryptonemo
authored
feat: add support for Non-interactive PoRep (#459)
* feat: add support for Non-interactive PoRep This commit adds support for ni-porep. It's a combination of the indivdual PRs #453, #456 and #458. Thanks everyone involved working on those. The changes are for the Go side (actors and FVM) as well as the Rust side (proofs API). Changes on the CI are: - Makes it match the Rust version in the rust-toolchain.toml - Newer Go version (1.21) on all platforms - Larger instance for the testsas the Ni-PoRep synthesis phase takes more resources. Closes #453, #456, #458. --------- Co-authored-by: Steven Allen <[email protected]> Co-authored-by: Rod Vagg <[email protected]> Co-authored-by: nemo <[email protected]>
1 parent 03b9503 commit c97a43a

File tree

10 files changed

+610
-483
lines changed

10 files changed

+610
-483
lines changed

Diff for: .circleci/config.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ orbs:
66
executors:
77
golang:
88
docker:
9-
- image: cimg/go:1.20
9+
- image: cimg/go:1.21
1010
resource_class: small
1111
environment:
1212
# Build the kernel only for the single architecture. This should reduce
@@ -56,7 +56,7 @@ jobs:
5656
type: boolean
5757
default: true
5858
machine:
59-
image: ubuntu-2204:2023.07.2
59+
image: default
6060
resource_class: arm.large
6161
working_directory: ~/go/src/github.com/filecoin-project/filecoin-ffi
6262
steps:
@@ -78,7 +78,7 @@ jobs:
7878
type: boolean
7979
default: true
8080
executor: golang
81-
resource_class: medium
81+
resource_class: medium+
8282
working_directory: ~/go/src/github.com/filecoin-project/filecoin-ffi
8383
steps:
8484
- configure_environment_variables
@@ -232,7 +232,7 @@ commands:
232232
- run:
233233
name: Install Go
234234
command: |
235-
curl https://dl.google.com/go/go1.20.10.darwin-arm64.pkg -o /tmp/go.pkg && \
235+
curl https://dl.google.com/go/go1.21.11.darwin-arm64.pkg -o /tmp/go.pkg && \
236236
sudo installer -pkg /tmp/go.pkg -target /
237237
go version
238238
- run:
@@ -352,13 +352,13 @@ commands:
352352
no_output_timeout: 90m
353353
- run:
354354
name: Run the Go tests
355-
command: GODEBUG=cgocheck=2 RUST_LOG=info go test -p 1 -timeout 60m
355+
command: GOEXPERIMENT=cgocheck2 RUST_LOG=info go test -p 1 -timeout 60m
356356
no_output_timeout: 60m
357357
compile_tests:
358358
steps:
359359
- run:
360360
name: Build project and tests, but don't actually run the tests (used to verify that build/link works with Darwin)
361-
command: GODEBUG=cgocheck=2 RUST_LOG=info go test -run=^$
361+
command: GOEXPERIMENT=cgocheck2 RUST_LOG=info go test -run=^$
362362
restore_parameter_cache:
363363
steps:
364364
- restore_cache:

Diff for: cgo/const.go

+20-15
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,26 @@ const (
1616
)
1717

1818
const (
19-
RegisteredSealProofStackedDrg2KiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1
20-
RegisteredSealProofStackedDrg8MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1
21-
RegisteredSealProofStackedDrg512MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1
22-
RegisteredSealProofStackedDrg32GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1
23-
RegisteredSealProofStackedDrg64GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1
24-
RegisteredSealProofStackedDrg2KiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1
25-
RegisteredSealProofStackedDrg8MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1
26-
RegisteredSealProofStackedDrg512MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1
27-
RegisteredSealProofStackedDrg32GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1
28-
RegisteredSealProofStackedDrg64GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1
29-
RegisteredSealProofStackedDrg2KiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1__FEAT__SYNTHETIC_PO_REP
30-
RegisteredSealProofStackedDrg8MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
31-
RegisteredSealProofStackedDrg512MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
32-
RegisteredSealProofStackedDrg32GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
33-
RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
19+
RegisteredSealProofStackedDrg2KiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1
20+
RegisteredSealProofStackedDrg8MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1
21+
RegisteredSealProofStackedDrg512MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1
22+
RegisteredSealProofStackedDrg32GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1
23+
RegisteredSealProofStackedDrg64GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1
24+
RegisteredSealProofStackedDrg2KiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1
25+
RegisteredSealProofStackedDrg8MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1
26+
RegisteredSealProofStackedDrg512MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1
27+
RegisteredSealProofStackedDrg32GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1
28+
RegisteredSealProofStackedDrg64GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1
29+
RegisteredSealProofStackedDrg2KiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1__FEAT__SYNTHETIC_PO_REP
30+
RegisteredSealProofStackedDrg8MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
31+
RegisteredSealProofStackedDrg512MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP
32+
RegisteredSealProofStackedDrg32GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
33+
RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP
34+
RegisteredSealProofStackedDrg2KiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
35+
RegisteredSealProofStackedDrg8MiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
36+
RegisteredSealProofStackedDrg512MiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
37+
RegisteredSealProofStackedDrg32GiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
38+
RegisteredSealProofStackedDrg64GiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP
3439
)
3540

3641
const (

Diff for: cgo/proofs.go

+9
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ func SealCommitPhase2(sealCommitPhase1Output SliceRefUint8, sectorId uint64, pro
130130
return resp.value.copy(), nil
131131
}
132132

133+
func SealCommitPhase2CircuitProofs(sealCommitPhase1Output SliceRefUint8, sectorId uint64) ([]byte, error) {
134+
resp := C.seal_commit_phase2_circuit_proofs(sealCommitPhase1Output, C.uint64_t(sectorId))
135+
defer resp.destroy()
136+
if err := CheckErr(resp); err != nil {
137+
return nil, err
138+
}
139+
return resp.value.copy(), nil
140+
}
141+
133142
func AggregateSealProofs(registeredProof RegisteredSealProof, registeredAggregation RegisteredAggregationProof, commRs SliceRefByteArray32, seeds SliceRefByteArray32, sealCommitResponses SliceRefSliceBoxedUint8) ([]byte, error) {
134143
resp := C.aggregate_seal_proofs(registeredProof, registeredAggregation, commRs, seeds, sealCommitResponses)
135144
defer resp.destroy()

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.18
55
require (
66
github.com/filecoin-project/go-address v1.1.0
77
github.com/filecoin-project/go-fil-commcid v0.1.0
8-
github.com/filecoin-project/go-state-types v0.13.1
8+
github.com/filecoin-project/go-state-types v0.14.0-rc1
99
github.com/ipfs/go-block-format v0.0.3
1010
github.com/ipfs/go-cid v0.3.2
1111
github.com/ipfs/go-ipfs-blockstore v1.2.0

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ github.com/filecoin-project/go-crypto v0.0.1 h1:AcvpSGGCgjaY8y1az6AMfKQWreF/pWO2
99
github.com/filecoin-project/go-crypto v0.0.1/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ=
1010
github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88OqLYEo6roi+GiIeOh8=
1111
github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
12-
github.com/filecoin-project/go-state-types v0.13.1 h1:4CivvlcHAIoAtFFVVlZtokynaMQu5XLXGoTKhQkfG1I=
13-
github.com/filecoin-project/go-state-types v0.13.1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
12+
github.com/filecoin-project/go-state-types v0.14.0-rc1 h1:kWBGX/uqZmYotYMNmw+R/fIuot/k0KMcEtB7PKFy1SQ=
13+
github.com/filecoin-project/go-state-types v0.14.0-rc1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY=
1414
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
1515
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
1616
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=

Diff for: proofs.go

+18
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,13 @@ func SealCommitPhase2(
414414
return cgo.SealCommitPhase2(cgo.AsSliceRefUint8(phase1Output), uint64(sectorNum), &proverID)
415415
}
416416

417+
// SealCommitPhase2CircuitProofs runs a non-interactive proof and returns the circuit proof bytes
418+
// rather than the aggregated proof bytes. This is used to aggregate multiple non-interactive
419+
// proofs as the aggregated single proof outputs can't further be aggregated.
420+
func SealCommitPhase2CircuitProofs(phase1Output []byte, sectorNum abi.SectorNumber) ([]byte, error) {
421+
return cgo.SealCommitPhase2CircuitProofs(cgo.AsSliceRefUint8(phase1Output), uint64(sectorNum))
422+
}
423+
417424
// TODO AggregateSealProofs it only needs InteractiveRandomness out of the aggregateInfo.Infos
418425
func AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) (out []byte, err error) {
419426
sp, err := toFilRegisteredSealProof(aggregateInfo.SealProof)
@@ -1030,6 +1037,17 @@ func toFilRegisteredSealProof(p abi.RegisteredSealProof) (cgo.RegisteredSealProo
10301037
case abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep:
10311038
return cgo.RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep, nil
10321039

1040+
case abi.RegisteredSealProof_StackedDrg2KiBV1_2_Feat_NiPoRep:
1041+
return cgo.RegisteredSealProofStackedDrg2KiBV1_2_Feat_NonInteractivePoRep, nil
1042+
case abi.RegisteredSealProof_StackedDrg8MiBV1_2_Feat_NiPoRep:
1043+
return cgo.RegisteredSealProofStackedDrg8MiBV1_2_Feat_NonInteractivePoRep, nil
1044+
case abi.RegisteredSealProof_StackedDrg512MiBV1_2_Feat_NiPoRep:
1045+
return cgo.RegisteredSealProofStackedDrg512MiBV1_2_Feat_NonInteractivePoRep, nil
1046+
case abi.RegisteredSealProof_StackedDrg32GiBV1_2_Feat_NiPoRep:
1047+
return cgo.RegisteredSealProofStackedDrg32GiBV1_2_Feat_NonInteractivePoRep, nil
1048+
case abi.RegisteredSealProof_StackedDrg64GiBV1_2_Feat_NiPoRep:
1049+
return cgo.RegisteredSealProofStackedDrg64GiBV1_2_Feat_NonInteractivePoRep, nil
1050+
10331051
default:
10341052
return 0, errors.Errorf("no mapping to C.FFIRegisteredSealProof value available for: %v", p)
10351053
}

0 commit comments

Comments
 (0)