Skip to content

Commit 310f0cc

Browse files
cryptonemovmxmagik6karajaseksnadrus
authored
Synthetic PoRep (#400) (#418)
* feat: add various new APIs for Lotus Those new APIs are about: - decoding a range of an updated empty sector - generating TreeRLast - generating TreeC - running SDR * docs: document the new APIs Add API documentation to the new APIs. Also change one parameter name for more consistency. * wip Go bindings for new proving APIs * Add nicer wrapper for GenerateSDR * feat: update proofs to the latest release * cleanup comments in proofs.go * feat: update dependencies to WIP synthetic-porep code * feat: add example of using SynthPoRep in existing test * feat: wire in new APIs * feat: add clear_layer_data API and more robustly use synth-porep in test * feat: go-wrapper for ClearSyntheticProofs * merged synth work * Update deps after (messy) rebase * missing v21 engine mapping * newer cargo lock * feat: point to fvm master after synthporep changes landed * update the fvm & bls-signatures (to match the fvm) --------- Co-authored-by: Volker Mische <[email protected]> Co-authored-by: Łukasz Magiera <[email protected]> Co-authored-by: Aayush <[email protected]> Co-authored-by: Andrew Jackson (Ajax) <[email protected]> Co-authored-by: Steven Allen <[email protected]>
1 parent bf5edd5 commit 310f0cc

File tree

9 files changed

+605
-789
lines changed

9 files changed

+605
-789
lines changed

cgo/const.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ 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
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
2934
)
3035

3136
const (

cgo/proofs.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,39 @@ func ClearCache(sectorSize uint64, cacheDirPath SliceRefUint8) error {
224224
return CheckErr(resp)
225225
}
226226

227+
func ClearSyntheticProofs(sectorSize uint64, cacheDirPath SliceRefUint8) error {
228+
resp := C.clear_synthetic_proofs(C.uint64_t(sectorSize), cacheDirPath)
229+
defer resp.destroy()
230+
return CheckErr(resp)
231+
}
232+
func ClearLayerData(sectorSize uint64, cacheDirPath SliceRefUint8) error {
233+
resp := C.clear_layer_data(C.uint64_t(sectorSize), cacheDirPath)
234+
defer resp.destroy()
235+
return CheckErr(resp)
236+
}
237+
238+
func GenerateSynthProofs(
239+
registered_proof RegisteredSealProof,
240+
comm_r, comm_d ByteArray32,
241+
cache_dir_path, replica_path SliceRefUint8,
242+
sector_id uint64,
243+
prover_id, ticket ByteArray32,
244+
pieces SliceRefPublicPieceInfo,
245+
) error {
246+
resp := C.generate_synth_proofs(registered_proof,
247+
&comm_r,
248+
&comm_d,
249+
cache_dir_path,
250+
replica_path,
251+
C.uint64_t(sector_id),
252+
&prover_id,
253+
&ticket,
254+
pieces,
255+
)
256+
defer resp.destroy()
257+
return CheckErr(resp)
258+
}
259+
227260
func Fauxrep(registeredProf RegisteredSealProof, cacheDirPath SliceRefUint8, sealedSectorPath SliceRefUint8) ([]byte, error) {
228261
resp := C.fauxrep(registeredProf, cacheDirPath, sealedSectorPath)
229262
defer resp.destroy()

go.mod

Lines changed: 1 addition & 1 deletion
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.11.1
8+
github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540
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

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ github.com/filecoin-project/go-state-types v0.0.0-20200903145444-247639ffa6ad/go
2828
github.com/filecoin-project/go-state-types v0.0.0-20200904021452-1883f36ca2f4/go.mod h1:IQ0MBPnonv35CJHtWSN3YY1Hz2gkPru1Q9qoaYLxx9I=
2929
github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc/go.mod h1:ezYnPf0bNkTsDibL/psSz5dy4B5awOJ/E7P2Saeep8g=
3030
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
31-
github.com/filecoin-project/go-state-types v0.11.1 h1:GDtCN9V18bYVwXDZe+vJXc6Ck+qY9OUaQqpoVlp1FAk=
32-
github.com/filecoin-project/go-state-types v0.11.1/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8=
31+
github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540 h1:v0fbEnBrMIjlxLve1sJTJE0YNGg58SNiP5sxQtr3trc=
32+
github.com/filecoin-project/go-state-types v0.11.2-0.20230712101859-8f37624fa540/go.mod h1:SyNPwTsU7I22gL2r0OAPcImvLoTVfgRwdK/Y5rR1zz8=
3333
github.com/filecoin-project/specs-actors v0.9.4/go.mod h1:BStZQzx5x7TmCkLv0Bpa07U6cPKol6fd3w9KjMPZ6Z4=
3434
github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps=
3535
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=

proofs.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,53 @@ func ClearCache(sectorSize uint64, cacheDirPath string) error {
661661
return cgo.ClearCache(sectorSize, cgo.AsSliceRefUint8([]byte(cacheDirPath)))
662662
}
663663

664+
// ClearSyntheticProofs
665+
func ClearSyntheticProofs(sectorSize uint64, cacheDirPath string) error {
666+
return cgo.ClearSyntheticProofs(sectorSize, cgo.AsSliceRefUint8([]byte(cacheDirPath)))
667+
}
668+
669+
func ClearLayerData(sectorSize abi.SectorSize, cacheDirPath string) error {
670+
return cgo.ClearLayerData(uint64(sectorSize), cgo.AsSliceRefUint8([]byte(cacheDirPath)))
671+
}
672+
673+
func GenerateSynthProofs(
674+
proofType abi.RegisteredSealProof,
675+
sealedCID, unsealedCID cid.Cid,
676+
cacheDirPath, replicaPath string,
677+
sector_id abi.SectorNumber,
678+
minerID abi.ActorID,
679+
ticket []byte,
680+
pieces []abi.PieceInfo,
681+
) error {
682+
sp, err := toFilRegisteredSealProof(proofType)
683+
if err != nil {
684+
return err
685+
}
686+
filPublicPieceInfos, err := toFilPublicPieceInfos(pieces)
687+
if err != nil {
688+
return err
689+
}
690+
commR, err := to32ByteCommR(sealedCID)
691+
if err != nil {
692+
return err
693+
}
694+
695+
commD, err := to32ByteCommD(unsealedCID)
696+
if err != nil {
697+
return err
698+
}
699+
proverID, err := toProverID(minerID)
700+
if err != nil {
701+
return err
702+
}
703+
return cgo.GenerateSynthProofs(sp,
704+
commR, commD,
705+
cgo.AsSliceRefUint8([]byte(cacheDirPath)), cgo.AsSliceRefUint8([]byte(replicaPath)),
706+
uint64(sector_id),
707+
proverID, cgo.AsByteArray32(ticket),
708+
cgo.AsSliceRefPublicPieceInfo(filPublicPieceInfos))
709+
}
710+
664711
func FauxRep(proofType abi.RegisteredSealProof, cacheDirPath string, sealedSectorPath string) (cid.Cid, error) {
665712
sp, err := toFilRegisteredSealProof(proofType)
666713
if err != nil {
@@ -975,6 +1022,18 @@ func toFilRegisteredSealProof(p abi.RegisteredSealProof) (cgo.RegisteredSealProo
9751022
return cgo.RegisteredSealProofStackedDrg32GiBV11, nil
9761023
case abi.RegisteredSealProof_StackedDrg64GiBV1_1:
9771024
return cgo.RegisteredSealProofStackedDrg64GiBV11, nil
1025+
1026+
case abi.RegisteredSealProof_StackedDrg2KiBV1_1_Feat_SyntheticPoRep:
1027+
return cgo.RegisteredSealProofStackedDrg2KiBV11_Feat_SyntheticPoRep, nil
1028+
case abi.RegisteredSealProof_StackedDrg8MiBV1_1_Feat_SyntheticPoRep:
1029+
return cgo.RegisteredSealProofStackedDrg8MiBV11_Feat_SyntheticPoRep, nil
1030+
case abi.RegisteredSealProof_StackedDrg512MiBV1_1_Feat_SyntheticPoRep:
1031+
return cgo.RegisteredSealProofStackedDrg512MiBV11_Feat_SyntheticPoRep, nil
1032+
case abi.RegisteredSealProof_StackedDrg32GiBV1_1_Feat_SyntheticPoRep:
1033+
return cgo.RegisteredSealProofStackedDrg32GiBV11_Feat_SyntheticPoRep, nil
1034+
case abi.RegisteredSealProof_StackedDrg64GiBV1_1_Feat_SyntheticPoRep:
1035+
return cgo.RegisteredSealProofStackedDrg64GiBV11_Feat_SyntheticPoRep, nil
1036+
9781037
default:
9791038
return 0, errors.Errorf("no mapping to C.FFIRegisteredSealProof value available for: %v", p)
9801039
}

0 commit comments

Comments
 (0)