diff --git a/cgo/const.go b/cgo/const.go index 05e84419..4710af40 100644 --- a/cgo/const.go +++ b/cgo/const.go @@ -16,21 +16,26 @@ const ( ) const ( - RegisteredSealProofStackedDrg2KiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1 - RegisteredSealProofStackedDrg8MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1 - RegisteredSealProofStackedDrg512MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1 - RegisteredSealProofStackedDrg32GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1 - RegisteredSealProofStackedDrg64GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1 - RegisteredSealProofStackedDrg2KiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1 - RegisteredSealProofStackedDrg8MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1 - RegisteredSealProofStackedDrg512MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1 - RegisteredSealProofStackedDrg32GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1 - RegisteredSealProofStackedDrg64GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1 - RegisteredSealProofStackedDrg2KiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1__FEAT__SYNTHETIC_PO_REP - RegisteredSealProofStackedDrg8MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP - RegisteredSealProofStackedDrg512MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP - RegisteredSealProofStackedDrg32GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP - RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP + RegisteredSealProofStackedDrg2KiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1 + RegisteredSealProofStackedDrg8MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1 + RegisteredSealProofStackedDrg512MiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1 + RegisteredSealProofStackedDrg32GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1 + RegisteredSealProofStackedDrg64GiBV1 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1 + RegisteredSealProofStackedDrg2KiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1 + RegisteredSealProofStackedDrg8MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1 + RegisteredSealProofStackedDrg512MiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1 + RegisteredSealProofStackedDrg32GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1 + RegisteredSealProofStackedDrg64GiBV11 = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1 + RegisteredSealProofStackedDrg2KiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_1__FEAT__SYNTHETIC_PO_REP + RegisteredSealProofStackedDrg8MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP + RegisteredSealProofStackedDrg512MiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_1__FEAT__SYNTHETIC_PO_REP + RegisteredSealProofStackedDrg32GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP + RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_1__FEAT__SYNTHETIC_PO_REP + RegisteredSealProofStackedDrg2KiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG2_KI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP + RegisteredSealProofStackedDrg8MiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG8_MI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP + RegisteredSealProofStackedDrg512MiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG512_MI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP + RegisteredSealProofStackedDrg32GiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG32_GI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP + RegisteredSealProofStackedDrg64GiBV1_2_Feat_NonInteractivePoRep = C.REGISTERED_SEAL_PROOF_STACKED_DRG64_GI_B_V1_2__FEAT__NON_INTERACTIVE_PO_REP ) const ( diff --git a/cgo/proofs.go b/cgo/proofs.go index a2a7f96c..3f4bc4d8 100644 --- a/cgo/proofs.go +++ b/cgo/proofs.go @@ -130,6 +130,15 @@ func SealCommitPhase2(sealCommitPhase1Output SliceRefUint8, sectorId uint64, pro return resp.value.copy(), nil } +func SealCommitPhase2CircuitProofs(sealCommitPhase1Output SliceRefUint8, sectorId uint64) ([]byte, error) { + resp := C.seal_commit_phase2_circuit_proofs(sealCommitPhase1Output, C.uint64_t(sectorId)) + defer resp.destroy() + if err := CheckErr(resp); err != nil { + return nil, err + } + return resp.value.copy(), nil +} + func AggregateSealProofs(registeredProof RegisteredSealProof, registeredAggregation RegisteredAggregationProof, commRs SliceRefByteArray32, seeds SliceRefByteArray32, sealCommitResponses SliceRefSliceBoxedUint8) ([]byte, error) { resp := C.aggregate_seal_proofs(registeredProof, registeredAggregation, commRs, seeds, sealCommitResponses) defer resp.destroy() diff --git a/go.mod b/go.mod index 7086e744..c92f0233 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/filecoin-project/go-address v1.1.0 github.com/filecoin-project/go-fil-commcid v0.1.0 - github.com/filecoin-project/go-state-types v0.13.1 + github.com/filecoin-project/go-state-types v0.14.0-dev.0.20240529001730-3bfff718e9cc github.com/ipfs/go-block-format v0.0.3 github.com/ipfs/go-cid v0.3.2 github.com/ipfs/go-ipfs-blockstore v1.2.0 diff --git a/go.sum b/go.sum index 63813a98..bfd44046 100644 --- a/go.sum +++ b/go.sum @@ -9,8 +9,8 @@ github.com/filecoin-project/go-crypto v0.0.1 h1:AcvpSGGCgjaY8y1az6AMfKQWreF/pWO2 github.com/filecoin-project/go-crypto v0.0.1/go.mod h1:+viYnvGtUTgJRdy6oaeF4MTFKAfatX071MPDPBL11EQ= github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88OqLYEo6roi+GiIeOh8= github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= -github.com/filecoin-project/go-state-types v0.13.1 h1:4CivvlcHAIoAtFFVVlZtokynaMQu5XLXGoTKhQkfG1I= -github.com/filecoin-project/go-state-types v0.13.1/go.mod h1:cHpOPup9H1g2T29dKHAjC2sc7/Ef5ypjuW9A3I+e9yY= +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/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= diff --git a/proofs.go b/proofs.go index 6e7ab3e3..3b63e6ea 100644 --- a/proofs.go +++ b/proofs.go @@ -414,6 +414,13 @@ func SealCommitPhase2( return cgo.SealCommitPhase2(cgo.AsSliceRefUint8(phase1Output), uint64(sectorNum), &proverID) } +// SealCommitPhase2CircuitProofs runs a non-interactive proof and returns the circuit proof bytes +// rather than the aggregated proof bytes. This is used to aggregate multiple non-interactive +// proofs as the aggregated single proof outputs can't further be aggregated. +func SealCommitPhase2CircuitProofs(phase1Output []byte, sectorNum abi.SectorNumber) ([]byte, error) { + return cgo.SealCommitPhase2CircuitProofs(cgo.AsSliceRefUint8(phase1Output), uint64(sectorNum)) +} + // TODO AggregateSealProofs it only needs InteractiveRandomness out of the aggregateInfo.Infos func AggregateSealProofs(aggregateInfo proof.AggregateSealVerifyProofAndInfos, proofs [][]byte) (out []byte, err error) { sp, err := toFilRegisteredSealProof(aggregateInfo.SealProof) @@ -1030,6 +1037,17 @@ func toFilRegisteredSealProof(p abi.RegisteredSealProof) (cgo.RegisteredSealProo case abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep: return cgo.RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep, nil + case abi.RegisteredSealProof_StackedDrg2KiBV1_2_Feat_NiPoRep: + return cgo.RegisteredSealProofStackedDrg2KiBV1_2_Feat_NonInteractivePoRep, nil + case abi.RegisteredSealProof_StackedDrg8MiBV1_2_Feat_NiPoRep: + return cgo.RegisteredSealProofStackedDrg8MiBV1_2_Feat_NonInteractivePoRep, nil + case abi.RegisteredSealProof_StackedDrg512MiBV1_2_Feat_NiPoRep: + return cgo.RegisteredSealProofStackedDrg512MiBV1_2_Feat_NonInteractivePoRep, nil + case abi.RegisteredSealProof_StackedDrg32GiBV1_2_Feat_NiPoRep: + return cgo.RegisteredSealProofStackedDrg32GiBV1_2_Feat_NonInteractivePoRep, nil + case abi.RegisteredSealProof_StackedDrg64GiBV1_2_Feat_NiPoRep: + return cgo.RegisteredSealProofStackedDrg64GiBV1_2_Feat_NonInteractivePoRep, nil + default: return 0, errors.Errorf("no mapping to C.FFIRegisteredSealProof value available for: %v", p) } diff --git a/rust/Cargo.lock b/rust/Cargo.lock index a7946af5..113a7de9 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1558,7 +1558,7 @@ dependencies = [ "derive_more", "filecoin-proofs-api 16.1.0", "fvm-wasm-instrument 0.2.0", - "fvm_ipld_amt", + "fvm_ipld_amt 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "fvm_ipld_blockstore", "fvm_ipld_encoding", "fvm_ipld_hamt 0.8.0", @@ -1593,7 +1593,7 @@ dependencies = [ "derive_more", "filecoin-proofs-api 16.1.0", "fvm-wasm-instrument 0.4.0", - "fvm_ipld_amt", + "fvm_ipld_amt 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "fvm_ipld_blockstore", "fvm_ipld_encoding", "fvm_ipld_hamt 0.8.0", @@ -1620,16 +1620,15 @@ dependencies = [ [[package]] name = "fvm" version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b31422270e0665c2f12f91a46e3bf1e164dcab41c7d5d44006418261c71def64" +source = "git+https://github.com/filecoin-project/ref-fvm.git?branch=rvagg/nlucic/niporep-temp-for-dep#c10b0f31bc2e1a6594448a61830c924a8c7139f2" dependencies = [ "ambassador", "anyhow", "cid", "derive_more", - "filecoin-proofs-api 16.1.0", + "filecoin-proofs-api 18.0.1", "fvm-wasm-instrument 0.4.0", - "fvm_ipld_amt", + "fvm_ipld_amt 0.6.2 (git+https://github.com/filecoin-project/ref-fvm.git?branch=rvagg/nlucic/niporep-temp-for-dep)", "fvm_ipld_blockstore", "fvm_ipld_encoding", "fvm_ipld_hamt 0.9.0", @@ -1689,6 +1688,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "fvm_ipld_amt" +version = "0.6.2" +source = "git+https://github.com/filecoin-project/ref-fvm.git?branch=rvagg/nlucic/niporep-temp-for-dep#c10b0f31bc2e1a6594448a61830c924a8c7139f2" +dependencies = [ + "anyhow", + "cid", + "fvm_ipld_blockstore", + "fvm_ipld_encoding", + "itertools 0.11.0", + "once_cell", + "serde", + "thiserror", +] + [[package]] name = "fvm_ipld_blockstore" version = "0.2.1" @@ -1740,8 +1754,7 @@ dependencies = [ [[package]] name = "fvm_ipld_hamt" version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c900736087ff87cc51f669eee2f8e000c80717472242eb3f712aaa059ac3b3" +source = "git+https://github.com/filecoin-project/ref-fvm.git?branch=rvagg/nlucic/niporep-temp-for-dep#c10b0f31bc2e1a6594448a61830c924a8c7139f2" dependencies = [ "anyhow", "byteorder", @@ -1820,8 +1833,7 @@ dependencies = [ [[package]] name = "fvm_shared" version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19de4747a883b0f1ed8b9200c188d87ebcc70f7c10c07f7f64d7fc5fb192d085" +source = "git+https://github.com/filecoin-project/ref-fvm.git?branch=rvagg/nlucic/niporep-temp-for-dep#c10b0f31bc2e1a6594448a61830c924a8c7139f2" dependencies = [ "anyhow", "bitflags 2.5.0", @@ -1830,7 +1842,7 @@ dependencies = [ "cid", "data-encoding", "data-encoding-macro", - "filecoin-proofs-api 16.1.0", + "filecoin-proofs-api 18.0.1", "fvm_ipld_encoding", "lazy_static", "libsecp256k1", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 32421433..d83a4635 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -31,8 +31,8 @@ rayon = "1.2.1" anyhow = "1.0.23" serde_json = "1.0.46" rust-gpu-tools = { version = "0.7", optional = true, default-features = false } -fvm4 = { package = "fvm", version = "~4.2.0", default-features = false, features = ["nv23-dev"] } -fvm4_shared = { package = "fvm_shared", version = "~4.2.0" } +fvm4 = { package = "fvm", version = "4", default-features = false, features = ["nv23-dev"], git = "https://github.com/filecoin-project/ref-fvm.git", branch="rvagg/nlucic/niporep-temp-for-dep" } +fvm4_shared = { package = "fvm_shared", version = "4", git = "https://github.com/filecoin-project/ref-fvm.git", branch="rvagg/nlucic/niporep-temp-for-dep" } fvm3 = { package = "fvm", version = "~3.9.0", default-features = false } fvm3_shared = { package = "fvm_shared", version = "~3.6.0" } fvm2 = { package = "fvm", version = "~2.7", default-features = false } @@ -45,7 +45,7 @@ lazy_static = "1.4.0" serde = "1.0.117" serde_tuple = "0.5" safer-ffi = { version = "0.0.7", features = ["proc_macros"] } -filecoin-proofs-api = { version = "18.0", default-features = false } +filecoin-proofs-api = { version = "18.0.1", default-features = false } yastl = "0.1.2" [dev-dependencies] diff --git a/rust/src/proofs/api.rs b/rust/src/proofs/api.rs index f07e9112..2b145e94 100644 --- a/rust/src/proofs/api.rs +++ b/rust/src/proofs/api.rs @@ -294,6 +294,36 @@ fn seal_commit_phase2( }) } +/// This function generates a variant of the circuit proof for the second phase of the sealing +/// process. It takes as input the output from the first phase of the sealing process +/// [`seal_commit_phase1`] and a sector ID. +/// +/// This variant of `seal_commit_phase2` is intended specifically for returning the circuit proofs +/// of a NonInteractivePoRep proof, such that it can later be aggregated with other +/// NonInteractivePoRep proofs. +/// +/// # Arguments +/// +/// * `seal_commit_phase1_output` - A reference to a slice of bytes representing the output from the +/// first phase of the sealing process. +/// * `sector_id` - A 64-bit integer representing the sector ID. +/// +/// # Returns +/// This function returns a `SealCommitPhase2Response` wrapped in a `repr_c::Box`. This response +/// includes the proof generated in this phase of the sealing process. +#[ffi_export] +fn seal_commit_phase2_circuit_proofs( + seal_commit_phase1_output: c_slice::Ref, + sector_id: u64, +) -> repr_c::Box { + catch_panic_response("seal_commit_phase2_circuit_proofs", || { + let scp1o = serde_json::from_slice(&seal_commit_phase1_output)?; + let result = seal::seal_commit_phase2_circuit_proofs(scp1o, SectorId::from(sector_id))?; + + Ok(result.proof.into_boxed_slice().into()) + }) +} + /// TODO: document #[ffi_export] fn generate_synth_proofs(