diff --git a/build.sh b/build.sh index 9a7d0470..eeaf37df 100755 --- a/build.sh +++ b/build.sh @@ -10,4 +10,5 @@ cargo install cbindgen cbindgen --clean --config cbindgen.toml --crate filcrypto --output ../include/filcrypto.h cd .. FFI_BUILD_FROM_SOURCE=1 make +make cgo-gen go mod tidy diff --git a/distributed.go b/distributed.go new file mode 100644 index 00000000..71a32183 --- /dev/null +++ b/distributed.go @@ -0,0 +1,176 @@ +//+build cgo + +package ffi + +import ( + "github.com/filecoin-project/filecoin-ffi/generated" + "github.com/filecoin-project/go-state-types/abi" + "github.com/filecoin-project/specs-actors/actors/runtime/proof" + "github.com/pkg/errors" +) + +type FallbackChallenges struct { + Sectors []abi.SectorNumber + Challenges map[abi.SectorNumber][]uint64 +} + +type VanillaProof []byte + +// GenerateWinningPoStSectorChallenge +func GeneratePoStFallbackSectorChallenges( + proofType abi.RegisteredPoStProof, + minerID abi.ActorID, + randomness abi.PoStRandomness, + sectorIds []abi.SectorNumber, +) (*FallbackChallenges, error) { + proverID, err := toProverID(minerID) + if err != nil { + return nil, err + } + + pp, err := toFilRegisteredPoStProof(proofType) + if err != nil { + return nil, err + } + + secIds := make([]uint64, len(sectorIds)) + for i, sid := range sectorIds { + secIds[i] = uint64(sid) + } + + resp := generated.FilGenerateFallbackSectorChallenges( + pp, to32ByteArray(randomness), secIds, uint(len(secIds)), + proverID, + ) + resp.Deref() + resp.IdsPtr = resp.IdsPtr[:resp.IdsLen] + resp.ChallengesPtr = resp.ChallengesPtr[:resp.ChallengesLen] + + defer generated.FilDestroyGenerateFallbackSectorChallengesResponse(resp) + + if resp.StatusCode != generated.FCPResponseStatusFCPNoError { + return nil, errors.New(generated.RawString(resp.ErrorMsg).Copy()) + } + + // copy from C memory space to Go + + var out FallbackChallenges + out.Sectors = make([]abi.SectorNumber, resp.IdsLen) + out.Challenges = make(map[abi.SectorNumber][]uint64) + stride := int(resp.ChallengesStride) + for idx := range resp.IdsPtr { + secNum := abi.SectorNumber(resp.IdsPtr[idx]) + out.Sectors[idx] = secNum + out.Challenges[secNum] = append([]uint64{}, resp.ChallengesPtr[idx*stride:(idx+1)*stride]...) + } + + return &out, nil +} + +func GenerateSingleVanillaProof( + replica PrivateSectorInfo, + challange []uint64, +) ([]byte, error) { + + rep, free, err := toFilPrivateReplicaInfo(replica) + if err != nil { + return nil, err + } + defer free() + + resp := generated.FilGenerateSingleVanillaProof(rep, challange, uint(len(challange))) + resp.Deref() + defer generated.FilDestroyGenerateSingleVanillaProofResponse(resp) + + if resp.StatusCode != generated.FCPResponseStatusFCPNoError { + return nil, errors.New(generated.RawString(resp.ErrorMsg).Copy()) + } + + resp.VanillaProof.Deref() + + return []byte(toGoStringCopy(resp.VanillaProof.ProofPtr, resp.VanillaProof.ProofLen)), nil +} + +func GenerateWinningPoStWithVanilla( + proofType abi.RegisteredPoStProof, + minerID abi.ActorID, + randomness abi.PoStRandomness, + proofs [][]byte, +) ([]proof.PoStProof, error) { + pp, err := toFilRegisteredPoStProof(proofType) + if err != nil { + return nil, err + } + + proverID, err := toProverID(minerID) + if err != nil { + return nil, err + } + fproofs, discard := toVanillaProofs(proofs) + defer discard() + + resp := generated.FilGenerateWinningPostWithVanilla( + pp, + to32ByteArray(randomness), + proverID, + fproofs, uint(len(proofs)), + ) + resp.Deref() + resp.ProofsPtr = make([]generated.FilPoStProof, resp.ProofsLen) + resp.Deref() + + defer generated.FilDestroyGenerateWinningPostResponse(resp) + + if resp.StatusCode != generated.FCPResponseStatusFCPNoError { + return nil, errors.New(generated.RawString(resp.ErrorMsg).Copy()) + } + + out, err := fromFilPoStProofs(resp.ProofsPtr) + if err != nil { + return nil, err + } + + return out, nil +} + +func GenerateWindowPoStWithVanilla( + proofType abi.RegisteredPoStProof, + minerID abi.ActorID, + randomness abi.PoStRandomness, + proofs [][]byte, +) ([]proof.PoStProof, error) { + pp, err := toFilRegisteredPoStProof(proofType) + if err != nil { + return nil, err + } + + proverID, err := toProverID(minerID) + if err != nil { + return nil, err + } + fproofs, discard := toVanillaProofs(proofs) + defer discard() + + resp := generated.FilGenerateWindowPostWithVanilla( + pp, + to32ByteArray(randomness), + proverID, + fproofs, uint(len(proofs)), + ) + resp.Deref() + resp.ProofsPtr = make([]generated.FilPoStProof, resp.ProofsLen) + resp.Deref() + + defer generated.FilDestroyGenerateWindowPostResponse(resp) + + if resp.StatusCode != generated.FCPResponseStatusFCPNoError { + return nil, errors.New(generated.RawString(resp.ErrorMsg).Copy()) + } + + out, err := fromFilPoStProofs(resp.ProofsPtr) + if err != nil { + return nil, err + } + + return out, nil +} diff --git a/generated/cgo_helpers.go b/generated/cgo_helpers.go index 2c3aeacc..0f7474f5 100644 --- a/generated/cgo_helpers.go +++ b/generated/cgo_helpers.go @@ -636,6 +636,131 @@ func (x *FilGenerateDataCommitmentResponse) Deref() { x.CommD = *(*[32]byte)(unsafe.Pointer(&x.ref87da7dd9.comm_d)) } +// allocFilGenerateFallbackSectorChallengesResponseMemory allocates memory for type C.fil_GenerateFallbackSectorChallengesResponse in C. +// The caller is responsible for freeing the this memory via C.free. +func allocFilGenerateFallbackSectorChallengesResponseMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFilGenerateFallbackSectorChallengesResponseValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfFilGenerateFallbackSectorChallengesResponseValue = unsafe.Sizeof([1]C.fil_GenerateFallbackSectorChallengesResponse{}) + +type sliceHeader struct { + Data unsafe.Pointer + Len int + Cap int +} + +// Ref returns the underlying reference to C object or nil if struct is nil. +func (x *FilGenerateFallbackSectorChallengesResponse) Ref() *C.fil_GenerateFallbackSectorChallengesResponse { + if x == nil { + return nil + } + return x.ref7047a3fa +} + +// Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. +// Does nothing if struct is nil or has no allocation map. +func (x *FilGenerateFallbackSectorChallengesResponse) Free() { + if x != nil && x.allocs7047a3fa != nil { + x.allocs7047a3fa.(*cgoAllocMap).Free() + x.ref7047a3fa = nil + } +} + +// NewFilGenerateFallbackSectorChallengesResponseRef creates a new wrapper struct with underlying reference set to the original C object. +// Returns nil if the provided pointer to C object is nil too. +func NewFilGenerateFallbackSectorChallengesResponseRef(ref unsafe.Pointer) *FilGenerateFallbackSectorChallengesResponse { + if ref == nil { + return nil + } + obj := new(FilGenerateFallbackSectorChallengesResponse) + obj.ref7047a3fa = (*C.fil_GenerateFallbackSectorChallengesResponse)(unsafe.Pointer(ref)) + return obj +} + +// PassRef returns the underlying C object, otherwise it will allocate one and set its values +// from this wrapping struct, counting allocations into an allocation map. +func (x *FilGenerateFallbackSectorChallengesResponse) PassRef() (*C.fil_GenerateFallbackSectorChallengesResponse, *cgoAllocMap) { + if x == nil { + return nil, nil + } else if x.ref7047a3fa != nil { + return x.ref7047a3fa, nil + } + mem7047a3fa := allocFilGenerateFallbackSectorChallengesResponseMemory(1) + ref7047a3fa := (*C.fil_GenerateFallbackSectorChallengesResponse)(mem7047a3fa) + allocs7047a3fa := new(cgoAllocMap) + allocs7047a3fa.Add(mem7047a3fa) + + var cerror_msg_allocs *cgoAllocMap + ref7047a3fa.error_msg, cerror_msg_allocs = unpackPCharString(x.ErrorMsg) + allocs7047a3fa.Borrow(cerror_msg_allocs) + + var cstatus_code_allocs *cgoAllocMap + ref7047a3fa.status_code, cstatus_code_allocs = (C.FCPResponseStatus)(x.StatusCode), cgoAllocsUnknown + allocs7047a3fa.Borrow(cstatus_code_allocs) + + var cids_ptr_allocs *cgoAllocMap + ref7047a3fa.ids_ptr, cids_ptr_allocs = (*C.uint64_t)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&x.IdsPtr)).Data)), cgoAllocsUnknown + allocs7047a3fa.Borrow(cids_ptr_allocs) + + var cids_len_allocs *cgoAllocMap + ref7047a3fa.ids_len, cids_len_allocs = (C.size_t)(x.IdsLen), cgoAllocsUnknown + allocs7047a3fa.Borrow(cids_len_allocs) + + var cchallenges_ptr_allocs *cgoAllocMap + ref7047a3fa.challenges_ptr, cchallenges_ptr_allocs = (*C.uint64_t)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&x.ChallengesPtr)).Data)), cgoAllocsUnknown + allocs7047a3fa.Borrow(cchallenges_ptr_allocs) + + var cchallenges_len_allocs *cgoAllocMap + ref7047a3fa.challenges_len, cchallenges_len_allocs = (C.size_t)(x.ChallengesLen), cgoAllocsUnknown + allocs7047a3fa.Borrow(cchallenges_len_allocs) + + var cchallenges_stride_allocs *cgoAllocMap + ref7047a3fa.challenges_stride, cchallenges_stride_allocs = (C.size_t)(x.ChallengesStride), cgoAllocsUnknown + allocs7047a3fa.Borrow(cchallenges_stride_allocs) + + x.ref7047a3fa = ref7047a3fa + x.allocs7047a3fa = allocs7047a3fa + return ref7047a3fa, allocs7047a3fa + +} + +// PassValue does the same as PassRef except that it will try to dereference the returned pointer. +func (x FilGenerateFallbackSectorChallengesResponse) PassValue() (C.fil_GenerateFallbackSectorChallengesResponse, *cgoAllocMap) { + if x.ref7047a3fa != nil { + return *x.ref7047a3fa, nil + } + ref, allocs := x.PassRef() + return *ref, allocs +} + +// Deref uses the underlying reference to C object and fills the wrapping struct with values. +// Do not forget to call this method whether you get a struct for C object and want to read its values. +func (x *FilGenerateFallbackSectorChallengesResponse) Deref() { + if x.ref7047a3fa == nil { + return + } + x.ErrorMsg = packPCharString(x.ref7047a3fa.error_msg) + x.StatusCode = (FCPResponseStatus)(x.ref7047a3fa.status_code) + hxfc4425b := (*sliceHeader)(unsafe.Pointer(&x.IdsPtr)) + hxfc4425b.Data = unsafe.Pointer(x.ref7047a3fa.ids_ptr) + hxfc4425b.Cap = 0x7fffffff + // hxfc4425b.Len = ? + + x.IdsLen = (uint)(x.ref7047a3fa.ids_len) + hxf95e7c8 := (*sliceHeader)(unsafe.Pointer(&x.ChallengesPtr)) + hxf95e7c8.Data = unsafe.Pointer(x.ref7047a3fa.challenges_ptr) + hxf95e7c8.Cap = 0x7fffffff + // hxf95e7c8.Len = ? + + x.ChallengesLen = (uint)(x.ref7047a3fa.challenges_len) + x.ChallengesStride = (uint)(x.ref7047a3fa.challenges_stride) +} + // allocFilGeneratePieceCommitmentResponseMemory allocates memory for type C.fil_GeneratePieceCommitmentResponse in C. // The caller is responsible for freeing the this memory via C.free. func allocFilGeneratePieceCommitmentResponseMemory(n int) unsafe.Pointer { @@ -732,17 +857,17 @@ func (x *FilGeneratePieceCommitmentResponse) Deref() { x.NumBytesAligned = (uint64)(x.ref4b00fda4.num_bytes_aligned) } -// allocFilPoStProofMemory allocates memory for type C.fil_PoStProof in C. +// allocFilVanillaProofMemory allocates memory for type C.fil_VanillaProof in C. // The caller is responsible for freeing the this memory via C.free. -func allocFilPoStProofMemory(n int) unsafe.Pointer { - mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFilPoStProofValue)) +func allocFilVanillaProofMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFilVanillaProofValue)) if mem == nil { panic(fmt.Sprintln("memory alloc error: ", err)) } return mem } -const sizeOfFilPoStProofValue = unsafe.Sizeof([1]C.fil_PoStProof{}) +const sizeOfFilVanillaProofValue = unsafe.Sizeof([1]C.fil_VanillaProof{}) // unpackPUint8TString represents the data from Go string as *C.uint8_t and avoids copying. func unpackPUint8TString(str string) (*C.uint8_t, *cgoAllocMap) { @@ -764,6 +889,183 @@ func packPUint8TString(p *C.uint8_t) (raw string) { return } +// Ref returns the underlying reference to C object or nil if struct is nil. +func (x *FilVanillaProof) Ref() *C.fil_VanillaProof { + if x == nil { + return nil + } + return x.refb3e7638c +} + +// Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. +// Does nothing if struct is nil or has no allocation map. +func (x *FilVanillaProof) Free() { + if x != nil && x.allocsb3e7638c != nil { + x.allocsb3e7638c.(*cgoAllocMap).Free() + x.refb3e7638c = nil + } +} + +// NewFilVanillaProofRef creates a new wrapper struct with underlying reference set to the original C object. +// Returns nil if the provided pointer to C object is nil too. +func NewFilVanillaProofRef(ref unsafe.Pointer) *FilVanillaProof { + if ref == nil { + return nil + } + obj := new(FilVanillaProof) + obj.refb3e7638c = (*C.fil_VanillaProof)(unsafe.Pointer(ref)) + return obj +} + +// PassRef returns the underlying C object, otherwise it will allocate one and set its values +// from this wrapping struct, counting allocations into an allocation map. +func (x *FilVanillaProof) PassRef() (*C.fil_VanillaProof, *cgoAllocMap) { + if x == nil { + return nil, nil + } else if x.refb3e7638c != nil { + return x.refb3e7638c, nil + } + memb3e7638c := allocFilVanillaProofMemory(1) + refb3e7638c := (*C.fil_VanillaProof)(memb3e7638c) + allocsb3e7638c := new(cgoAllocMap) + allocsb3e7638c.Add(memb3e7638c) + + var cproof_len_allocs *cgoAllocMap + refb3e7638c.proof_len, cproof_len_allocs = (C.size_t)(x.ProofLen), cgoAllocsUnknown + allocsb3e7638c.Borrow(cproof_len_allocs) + + var cproof_ptr_allocs *cgoAllocMap + refb3e7638c.proof_ptr, cproof_ptr_allocs = unpackPUint8TString(x.ProofPtr) + allocsb3e7638c.Borrow(cproof_ptr_allocs) + + x.refb3e7638c = refb3e7638c + x.allocsb3e7638c = allocsb3e7638c + return refb3e7638c, allocsb3e7638c + +} + +// PassValue does the same as PassRef except that it will try to dereference the returned pointer. +func (x FilVanillaProof) PassValue() (C.fil_VanillaProof, *cgoAllocMap) { + if x.refb3e7638c != nil { + return *x.refb3e7638c, nil + } + ref, allocs := x.PassRef() + return *ref, allocs +} + +// Deref uses the underlying reference to C object and fills the wrapping struct with values. +// Do not forget to call this method whether you get a struct for C object and want to read its values. +func (x *FilVanillaProof) Deref() { + if x.refb3e7638c == nil { + return + } + x.ProofLen = (uint)(x.refb3e7638c.proof_len) + x.ProofPtr = packPUint8TString(x.refb3e7638c.proof_ptr) +} + +// allocFilGenerateSingleVanillaProofResponseMemory allocates memory for type C.fil_GenerateSingleVanillaProofResponse in C. +// The caller is responsible for freeing the this memory via C.free. +func allocFilGenerateSingleVanillaProofResponseMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFilGenerateSingleVanillaProofResponseValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfFilGenerateSingleVanillaProofResponseValue = unsafe.Sizeof([1]C.fil_GenerateSingleVanillaProofResponse{}) + +// Ref returns the underlying reference to C object or nil if struct is nil. +func (x *FilGenerateSingleVanillaProofResponse) Ref() *C.fil_GenerateSingleVanillaProofResponse { + if x == nil { + return nil + } + return x.reff9d21b04 +} + +// Free invokes alloc map's free mechanism that cleanups any allocated memory using C free. +// Does nothing if struct is nil or has no allocation map. +func (x *FilGenerateSingleVanillaProofResponse) Free() { + if x != nil && x.allocsf9d21b04 != nil { + x.allocsf9d21b04.(*cgoAllocMap).Free() + x.reff9d21b04 = nil + } +} + +// NewFilGenerateSingleVanillaProofResponseRef creates a new wrapper struct with underlying reference set to the original C object. +// Returns nil if the provided pointer to C object is nil too. +func NewFilGenerateSingleVanillaProofResponseRef(ref unsafe.Pointer) *FilGenerateSingleVanillaProofResponse { + if ref == nil { + return nil + } + obj := new(FilGenerateSingleVanillaProofResponse) + obj.reff9d21b04 = (*C.fil_GenerateSingleVanillaProofResponse)(unsafe.Pointer(ref)) + return obj +} + +// PassRef returns the underlying C object, otherwise it will allocate one and set its values +// from this wrapping struct, counting allocations into an allocation map. +func (x *FilGenerateSingleVanillaProofResponse) PassRef() (*C.fil_GenerateSingleVanillaProofResponse, *cgoAllocMap) { + if x == nil { + return nil, nil + } else if x.reff9d21b04 != nil { + return x.reff9d21b04, nil + } + memf9d21b04 := allocFilGenerateSingleVanillaProofResponseMemory(1) + reff9d21b04 := (*C.fil_GenerateSingleVanillaProofResponse)(memf9d21b04) + allocsf9d21b04 := new(cgoAllocMap) + allocsf9d21b04.Add(memf9d21b04) + + var cerror_msg_allocs *cgoAllocMap + reff9d21b04.error_msg, cerror_msg_allocs = unpackPCharString(x.ErrorMsg) + allocsf9d21b04.Borrow(cerror_msg_allocs) + + var cvanilla_proof_allocs *cgoAllocMap + reff9d21b04.vanilla_proof, cvanilla_proof_allocs = x.VanillaProof.PassValue() + allocsf9d21b04.Borrow(cvanilla_proof_allocs) + + var cstatus_code_allocs *cgoAllocMap + reff9d21b04.status_code, cstatus_code_allocs = (C.FCPResponseStatus)(x.StatusCode), cgoAllocsUnknown + allocsf9d21b04.Borrow(cstatus_code_allocs) + + x.reff9d21b04 = reff9d21b04 + x.allocsf9d21b04 = allocsf9d21b04 + return reff9d21b04, allocsf9d21b04 + +} + +// PassValue does the same as PassRef except that it will try to dereference the returned pointer. +func (x FilGenerateSingleVanillaProofResponse) PassValue() (C.fil_GenerateSingleVanillaProofResponse, *cgoAllocMap) { + if x.reff9d21b04 != nil { + return *x.reff9d21b04, nil + } + ref, allocs := x.PassRef() + return *ref, allocs +} + +// Deref uses the underlying reference to C object and fills the wrapping struct with values. +// Do not forget to call this method whether you get a struct for C object and want to read its values. +func (x *FilGenerateSingleVanillaProofResponse) Deref() { + if x.reff9d21b04 == nil { + return + } + x.ErrorMsg = packPCharString(x.reff9d21b04.error_msg) + x.VanillaProof = *NewFilVanillaProofRef(unsafe.Pointer(&x.reff9d21b04.vanilla_proof)) + x.StatusCode = (FCPResponseStatus)(x.reff9d21b04.status_code) +} + +// allocFilPoStProofMemory allocates memory for type C.fil_PoStProof in C. +// The caller is responsible for freeing the this memory via C.free. +func allocFilPoStProofMemory(n int) unsafe.Pointer { + mem, err := C.calloc(C.size_t(n), (C.size_t)(sizeOfFilPoStProofValue)) + if mem == nil { + panic(fmt.Sprintln("memory alloc error: ", err)) + } + return mem +} + +const sizeOfFilPoStProofValue = unsafe.Sizeof([1]C.fil_PoStProof{}) + // Ref returns the underlying reference to C object or nil if struct is nil. func (x *FilPoStProof) Ref() *C.fil_PoStProof { if x == nil { @@ -855,12 +1157,6 @@ func allocFilGenerateWindowPoStResponseMemory(n int) unsafe.Pointer { const sizeOfFilGenerateWindowPoStResponseValue = unsafe.Sizeof([1]C.fil_GenerateWindowPoStResponse{}) -type sliceHeader struct { - Data unsafe.Pointer - Len int - Cap int -} - const sizeOfPtr = unsafe.Sizeof(&struct{}{}) // unpackSFilPoStProof transforms a sliced Go data structure into plain C format. @@ -991,10 +1287,10 @@ func (x *FilGenerateWindowPoStResponse) Deref() { x.ProofsLen = (uint)(x.ref2a5f3ba8.proofs_len) packSFilPoStProof(x.ProofsPtr, x.ref2a5f3ba8.proofs_ptr) x.FaultySectorsLen = (uint)(x.ref2a5f3ba8.faulty_sectors_len) - hxfc4425b := (*sliceHeader)(unsafe.Pointer(&x.FaultySectorsPtr)) - hxfc4425b.Data = unsafe.Pointer(x.ref2a5f3ba8.faulty_sectors_ptr) - hxfc4425b.Cap = 0x7fffffff - // hxfc4425b.Len = ? + hxff2234b := (*sliceHeader)(unsafe.Pointer(&x.FaultySectorsPtr)) + hxff2234b.Data = unsafe.Pointer(x.ref2a5f3ba8.faulty_sectors_ptr) + hxff2234b.Cap = 0x7fffffff + // hxff2234b.Len = ? x.StatusCode = (FCPResponseStatus)(x.ref2a5f3ba8.status_code) } @@ -1187,10 +1483,10 @@ func (x *FilGenerateWinningPoStSectorChallenge) Deref() { } x.ErrorMsg = packPCharString(x.ref69d2a405.error_msg) x.StatusCode = (FCPResponseStatus)(x.ref69d2a405.status_code) - hxf95e7c8 := (*sliceHeader)(unsafe.Pointer(&x.IdsPtr)) - hxf95e7c8.Data = unsafe.Pointer(x.ref69d2a405.ids_ptr) - hxf95e7c8.Cap = 0x7fffffff - // hxf95e7c8.Len = ? + hxff73280 := (*sliceHeader)(unsafe.Pointer(&x.IdsPtr)) + hxff73280.Data = unsafe.Pointer(x.ref69d2a405.ids_ptr) + hxff73280.Cap = 0x7fffffff + // hxff73280.Len = ? x.IdsLen = (uint)(x.ref69d2a405.ids_len) } @@ -3463,6 +3759,44 @@ func packSFilPrivateReplicaInfo(v []FilPrivateReplicaInfo, ptr0 *C.fil_PrivateRe } } +// unpackArgSFilVanillaProof transforms a sliced Go data structure into plain C format. +func unpackArgSFilVanillaProof(x []FilVanillaProof) (unpacked *C.fil_VanillaProof, allocs *cgoAllocMap) { + if x == nil { + return nil, nil + } + allocs = new(cgoAllocMap) + defer runtime.SetFinalizer(allocs, func(a *cgoAllocMap) { + go a.Free() + }) + + len0 := len(x) + mem0 := allocFilVanillaProofMemory(len0) + allocs.Add(mem0) + h0 := &sliceHeader{ + Data: mem0, + Cap: len0, + Len: len0, + } + v0 := *(*[]C.fil_VanillaProof)(unsafe.Pointer(h0)) + for i0 := range x { + allocs0 := new(cgoAllocMap) + v0[i0], allocs0 = x[i0].PassValue() + allocs.Borrow(allocs0) + } + h := (*sliceHeader)(unsafe.Pointer(&v0)) + unpacked = (*C.fil_VanillaProof)(h.Data) + return +} + +// packSFilVanillaProof reads sliced Go data structure out from plain C format. +func packSFilVanillaProof(v []FilVanillaProof, ptr0 *C.fil_VanillaProof) { + const m = 0x7fffffff + for i0 := range v { + ptr1 := (*(*[m / sizeOfFilVanillaProofValue]C.fil_VanillaProof)(unsafe.Pointer(ptr0)))[i0] + v[i0] = *NewFilVanillaProofRef(unsafe.Pointer(&ptr1)) + } +} + // unpackArgSFilPublicReplicaInfo transforms a sliced Go data structure into plain C format. func unpackArgSFilPublicReplicaInfo(x []FilPublicReplicaInfo) (unpacked *C.fil_PublicReplicaInfo, allocs *cgoAllocMap) { if x == nil { diff --git a/generated/customallocs.go b/generated/customallocs.go index 4c8d10dd..2cb9d346 100644 --- a/generated/customallocs.go +++ b/generated/customallocs.go @@ -52,3 +52,20 @@ func (x *FilPoStProof) AllocateProxy() func() { C.free(unsafe.Pointer(proxy)) } } + +// AllocateProxy allocates a FilVanillaProof proxy object in the C heap, +// returning a function which, when called, frees the allocated memory. +func (x *FilVanillaProof) AllocateProxy() func() { + mem := allocFilVanillaProofMemory(1) + proxy := (*C.fil_VanillaProof)(mem) + + proxy.proof_len = (C.size_t)(x.ProofLen) + proxy.proof_ptr = (*C.uchar)(unsafe.Pointer(C.CString(x.ProofPtr))) + + x.refb3e7638c = proxy + + return func() { + C.free(unsafe.Pointer(proxy.proof_ptr)) + C.free(unsafe.Pointer(proxy)) + } +} diff --git a/generated/dummy.go b/generated/dummy.go new file mode 100644 index 00000000..951c8800 --- /dev/null +++ b/generated/dummy.go @@ -0,0 +1 @@ +package generated diff --git a/generated/generated.go b/generated/generated.go index dbc5800f..627283f9 100644 --- a/generated/generated.go +++ b/generated/generated.go @@ -16,7 +16,7 @@ import ( "unsafe" ) -// FilAggregate function as declared in filecoin-ffi/filcrypto.h:289 +// FilAggregate function as declared in filecoin-ffi/filcrypto.h:310 func FilAggregate(flattenedSignaturesPtr string, flattenedSignaturesLen uint) *FilAggregateResponse { flattenedSignaturesPtr = safeString(flattenedSignaturesPtr) cflattenedSignaturesPtr, cflattenedSignaturesPtrAllocMap := unpackPUint8TString(flattenedSignaturesPtr) @@ -29,7 +29,7 @@ func FilAggregate(flattenedSignaturesPtr string, flattenedSignaturesLen uint) *F return __v } -// FilClearCache function as declared in filecoin-ffi/filcrypto.h:292 +// FilClearCache function as declared in filecoin-ffi/filcrypto.h:313 func FilClearCache(sectorSize uint64, cacheDirPath string) *FilClearCacheResponse { csectorSize, csectorSizeAllocMap := (C.uint64_t)(sectorSize), cgoAllocsUnknown cacheDirPath = safeString(cacheDirPath) @@ -42,189 +42,203 @@ func FilClearCache(sectorSize uint64, cacheDirPath string) *FilClearCacheRespons return __v } -// FilDestroyAggregateResponse function as declared in filecoin-ffi/filcrypto.h:294 +// FilDestroyAggregateResponse function as declared in filecoin-ffi/filcrypto.h:315 func FilDestroyAggregateResponse(ptr *FilAggregateResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_aggregate_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyClearCacheResponse function as declared in filecoin-ffi/filcrypto.h:296 +// FilDestroyClearCacheResponse function as declared in filecoin-ffi/filcrypto.h:317 func FilDestroyClearCacheResponse(ptr *FilClearCacheResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_clear_cache_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyFauxrepResponse function as declared in filecoin-ffi/filcrypto.h:298 +// FilDestroyFauxrepResponse function as declared in filecoin-ffi/filcrypto.h:319 func FilDestroyFauxrepResponse(ptr *FilFauxRepResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_fauxrep_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyFinalizeTicketResponse function as declared in filecoin-ffi/filcrypto.h:300 +// FilDestroyFinalizeTicketResponse function as declared in filecoin-ffi/filcrypto.h:321 func FilDestroyFinalizeTicketResponse(ptr *FilFinalizeTicketResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_finalize_ticket_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyGenerateDataCommitmentResponse function as declared in filecoin-ffi/filcrypto.h:302 +// FilDestroyGenerateDataCommitmentResponse function as declared in filecoin-ffi/filcrypto.h:323 func FilDestroyGenerateDataCommitmentResponse(ptr *FilGenerateDataCommitmentResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_generate_data_commitment_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyGeneratePieceCommitmentResponse function as declared in filecoin-ffi/filcrypto.h:304 +// FilDestroyGenerateFallbackSectorChallengesResponse function as declared in filecoin-ffi/filcrypto.h:325 +func FilDestroyGenerateFallbackSectorChallengesResponse(ptr *FilGenerateFallbackSectorChallengesResponse) { + cptr, cptrAllocMap := ptr.PassRef() + C.fil_destroy_generate_fallback_sector_challenges_response(cptr) + runtime.KeepAlive(cptrAllocMap) +} + +// FilDestroyGeneratePieceCommitmentResponse function as declared in filecoin-ffi/filcrypto.h:327 func FilDestroyGeneratePieceCommitmentResponse(ptr *FilGeneratePieceCommitmentResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_generate_piece_commitment_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyGenerateWindowPostResponse function as declared in filecoin-ffi/filcrypto.h:306 +// FilDestroyGenerateSingleVanillaProofResponse function as declared in filecoin-ffi/filcrypto.h:329 +func FilDestroyGenerateSingleVanillaProofResponse(ptr *FilGenerateSingleVanillaProofResponse) { + cptr, cptrAllocMap := ptr.PassRef() + C.fil_destroy_generate_single_vanilla_proof_response(cptr) + runtime.KeepAlive(cptrAllocMap) +} + +// FilDestroyGenerateWindowPostResponse function as declared in filecoin-ffi/filcrypto.h:331 func FilDestroyGenerateWindowPostResponse(ptr *FilGenerateWindowPoStResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_generate_window_post_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyGenerateWinningPostResponse function as declared in filecoin-ffi/filcrypto.h:308 +// FilDestroyGenerateWinningPostResponse function as declared in filecoin-ffi/filcrypto.h:333 func FilDestroyGenerateWinningPostResponse(ptr *FilGenerateWinningPoStResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_generate_winning_post_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyGenerateWinningPostSectorChallenge function as declared in filecoin-ffi/filcrypto.h:310 +// FilDestroyGenerateWinningPostSectorChallenge function as declared in filecoin-ffi/filcrypto.h:335 func FilDestroyGenerateWinningPostSectorChallenge(ptr *FilGenerateWinningPoStSectorChallenge) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_generate_winning_post_sector_challenge(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyGpuDeviceResponse function as declared in filecoin-ffi/filcrypto.h:312 +// FilDestroyGpuDeviceResponse function as declared in filecoin-ffi/filcrypto.h:337 func FilDestroyGpuDeviceResponse(ptr *FilGpuDeviceResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_gpu_device_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyHashResponse function as declared in filecoin-ffi/filcrypto.h:314 +// FilDestroyHashResponse function as declared in filecoin-ffi/filcrypto.h:339 func FilDestroyHashResponse(ptr *FilHashResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_hash_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyInitLogFdResponse function as declared in filecoin-ffi/filcrypto.h:316 +// FilDestroyInitLogFdResponse function as declared in filecoin-ffi/filcrypto.h:341 func FilDestroyInitLogFdResponse(ptr *FilInitLogFdResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_init_log_fd_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyPrivateKeyGenerateResponse function as declared in filecoin-ffi/filcrypto.h:318 +// FilDestroyPrivateKeyGenerateResponse function as declared in filecoin-ffi/filcrypto.h:343 func FilDestroyPrivateKeyGenerateResponse(ptr *FilPrivateKeyGenerateResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_private_key_generate_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyPrivateKeyPublicKeyResponse function as declared in filecoin-ffi/filcrypto.h:320 +// FilDestroyPrivateKeyPublicKeyResponse function as declared in filecoin-ffi/filcrypto.h:345 func FilDestroyPrivateKeyPublicKeyResponse(ptr *FilPrivateKeyPublicKeyResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_private_key_public_key_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyPrivateKeySignResponse function as declared in filecoin-ffi/filcrypto.h:322 +// FilDestroyPrivateKeySignResponse function as declared in filecoin-ffi/filcrypto.h:347 func FilDestroyPrivateKeySignResponse(ptr *FilPrivateKeySignResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_private_key_sign_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroySealCommitPhase1Response function as declared in filecoin-ffi/filcrypto.h:324 +// FilDestroySealCommitPhase1Response function as declared in filecoin-ffi/filcrypto.h:349 func FilDestroySealCommitPhase1Response(ptr *FilSealCommitPhase1Response) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_seal_commit_phase1_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroySealCommitPhase2Response function as declared in filecoin-ffi/filcrypto.h:326 +// FilDestroySealCommitPhase2Response function as declared in filecoin-ffi/filcrypto.h:351 func FilDestroySealCommitPhase2Response(ptr *FilSealCommitPhase2Response) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_seal_commit_phase2_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroySealPreCommitPhase1Response function as declared in filecoin-ffi/filcrypto.h:328 +// FilDestroySealPreCommitPhase1Response function as declared in filecoin-ffi/filcrypto.h:353 func FilDestroySealPreCommitPhase1Response(ptr *FilSealPreCommitPhase1Response) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_seal_pre_commit_phase1_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroySealPreCommitPhase2Response function as declared in filecoin-ffi/filcrypto.h:330 +// FilDestroySealPreCommitPhase2Response function as declared in filecoin-ffi/filcrypto.h:355 func FilDestroySealPreCommitPhase2Response(ptr *FilSealPreCommitPhase2Response) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_seal_pre_commit_phase2_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyStringResponse function as declared in filecoin-ffi/filcrypto.h:332 +// FilDestroyStringResponse function as declared in filecoin-ffi/filcrypto.h:357 func FilDestroyStringResponse(ptr *FilStringResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_string_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyUnsealRangeResponse function as declared in filecoin-ffi/filcrypto.h:334 +// FilDestroyUnsealRangeResponse function as declared in filecoin-ffi/filcrypto.h:359 func FilDestroyUnsealRangeResponse(ptr *FilUnsealRangeResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_unseal_range_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyVerifySealResponse function as declared in filecoin-ffi/filcrypto.h:340 +// FilDestroyVerifySealResponse function as declared in filecoin-ffi/filcrypto.h:365 func FilDestroyVerifySealResponse(ptr *FilVerifySealResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_verify_seal_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyVerifyWindowPostResponse function as declared in filecoin-ffi/filcrypto.h:342 +// FilDestroyVerifyWindowPostResponse function as declared in filecoin-ffi/filcrypto.h:367 func FilDestroyVerifyWindowPostResponse(ptr *FilVerifyWindowPoStResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_verify_window_post_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyVerifyWinningPostResponse function as declared in filecoin-ffi/filcrypto.h:348 +// FilDestroyVerifyWinningPostResponse function as declared in filecoin-ffi/filcrypto.h:373 func FilDestroyVerifyWinningPostResponse(ptr *FilVerifyWinningPoStResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_verify_winning_post_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyWriteWithAlignmentResponse function as declared in filecoin-ffi/filcrypto.h:350 +// FilDestroyWriteWithAlignmentResponse function as declared in filecoin-ffi/filcrypto.h:375 func FilDestroyWriteWithAlignmentResponse(ptr *FilWriteWithAlignmentResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_write_with_alignment_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilDestroyWriteWithoutAlignmentResponse function as declared in filecoin-ffi/filcrypto.h:352 +// FilDestroyWriteWithoutAlignmentResponse function as declared in filecoin-ffi/filcrypto.h:377 func FilDestroyWriteWithoutAlignmentResponse(ptr *FilWriteWithoutAlignmentResponse) { cptr, cptrAllocMap := ptr.PassRef() C.fil_destroy_write_without_alignment_response(cptr) runtime.KeepAlive(cptrAllocMap) } -// FilFauxrep function as declared in filecoin-ffi/filcrypto.h:354 +// FilFauxrep function as declared in filecoin-ffi/filcrypto.h:379 func FilFauxrep(registeredProof FilRegisteredSealProof, cacheDirPath string, sealedSectorPath string) *FilFauxRepResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown cacheDirPath = safeString(cacheDirPath) @@ -241,7 +255,7 @@ func FilFauxrep(registeredProof FilRegisteredSealProof, cacheDirPath string, sea return __v } -// FilFauxrep2 function as declared in filecoin-ffi/filcrypto.h:358 +// FilFauxrep2 function as declared in filecoin-ffi/filcrypto.h:383 func FilFauxrep2(registeredProof FilRegisteredSealProof, cacheDirPath string, existingPAuxPath string) *FilFauxRepResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown cacheDirPath = safeString(cacheDirPath) @@ -258,7 +272,7 @@ func FilFauxrep2(registeredProof FilRegisteredSealProof, cacheDirPath string, ex return __v } -// FilGenerateDataCommitment function as declared in filecoin-ffi/filcrypto.h:365 +// FilGenerateDataCommitment function as declared in filecoin-ffi/filcrypto.h:390 func FilGenerateDataCommitment(registeredProof FilRegisteredSealProof, piecesPtr []FilPublicPieceInfo, piecesLen uint) *FilGenerateDataCommitmentResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown cpiecesPtr, cpiecesPtrAllocMap := unpackArgSFilPublicPieceInfo(piecesPtr) @@ -272,7 +286,24 @@ func FilGenerateDataCommitment(registeredProof FilRegisteredSealProof, piecesPtr return __v } -// FilGeneratePieceCommitment function as declared in filecoin-ffi/filcrypto.h:373 +// FilGenerateFallbackSectorChallenges function as declared in filecoin-ffi/filcrypto.h:398 +func FilGenerateFallbackSectorChallenges(registeredProof FilRegisteredPoStProof, randomness Fil32ByteArray, sectorIdsPtr []uint64, sectorIdsLen uint, proverId Fil32ByteArray) *FilGenerateFallbackSectorChallengesResponse { + cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown + crandomness, crandomnessAllocMap := randomness.PassValue() + csectorIdsPtr, csectorIdsPtrAllocMap := (*C.uint64_t)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(§orIdsPtr)).Data)), cgoAllocsUnknown + csectorIdsLen, csectorIdsLenAllocMap := (C.size_t)(sectorIdsLen), cgoAllocsUnknown + cproverId, cproverIdAllocMap := proverId.PassValue() + __ret := C.fil_generate_fallback_sector_challenges(cregisteredProof, crandomness, csectorIdsPtr, csectorIdsLen, cproverId) + runtime.KeepAlive(cproverIdAllocMap) + runtime.KeepAlive(csectorIdsLenAllocMap) + runtime.KeepAlive(csectorIdsPtrAllocMap) + runtime.KeepAlive(crandomnessAllocMap) + runtime.KeepAlive(cregisteredProofAllocMap) + __v := NewFilGenerateFallbackSectorChallengesResponseRef(unsafe.Pointer(__ret)) + return __v +} + +// FilGeneratePieceCommitment function as declared in filecoin-ffi/filcrypto.h:408 func FilGeneratePieceCommitment(registeredProof FilRegisteredSealProof, pieceFdRaw int32, unpaddedPieceSize uint64) *FilGeneratePieceCommitmentResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown cpieceFdRaw, cpieceFdRawAllocMap := (C.int)(pieceFdRaw), cgoAllocsUnknown @@ -285,7 +316,20 @@ func FilGeneratePieceCommitment(registeredProof FilRegisteredSealProof, pieceFdR return __v } -// FilGenerateWindowPost function as declared in filecoin-ffi/filcrypto.h:381 +// FilGenerateSingleVanillaProof function as declared in filecoin-ffi/filcrypto.h:416 +func FilGenerateSingleVanillaProof(replica FilPrivateReplicaInfo, challengesPtr []uint64, challengesLen uint) *FilGenerateSingleVanillaProofResponse { + creplica, creplicaAllocMap := replica.PassValue() + cchallengesPtr, cchallengesPtrAllocMap := (*C.uint64_t)(unsafe.Pointer((*sliceHeader)(unsafe.Pointer(&challengesPtr)).Data)), cgoAllocsUnknown + cchallengesLen, cchallengesLenAllocMap := (C.size_t)(challengesLen), cgoAllocsUnknown + __ret := C.fil_generate_single_vanilla_proof(creplica, cchallengesPtr, cchallengesLen) + runtime.KeepAlive(cchallengesLenAllocMap) + runtime.KeepAlive(cchallengesPtrAllocMap) + runtime.KeepAlive(creplicaAllocMap) + __v := NewFilGenerateSingleVanillaProofResponseRef(unsafe.Pointer(__ret)) + return __v +} + +// FilGenerateWindowPost function as declared in filecoin-ffi/filcrypto.h:424 func FilGenerateWindowPost(randomness Fil32ByteArray, replicasPtr []FilPrivateReplicaInfo, replicasLen uint, proverId Fil32ByteArray) *FilGenerateWindowPoStResponse { crandomness, crandomnessAllocMap := randomness.PassValue() creplicasPtr, creplicasPtrAllocMap := unpackArgSFilPrivateReplicaInfo(replicasPtr) @@ -301,7 +345,25 @@ func FilGenerateWindowPost(randomness Fil32ByteArray, replicasPtr []FilPrivateRe return __v } -// FilGenerateWinningPost function as declared in filecoin-ffi/filcrypto.h:390 +// FilGenerateWindowPostWithVanilla function as declared in filecoin-ffi/filcrypto.h:433 +func FilGenerateWindowPostWithVanilla(registeredProof FilRegisteredPoStProof, randomness Fil32ByteArray, proverId Fil32ByteArray, vanillaProofsPtr []FilVanillaProof, vanillaProofsLen uint) *FilGenerateWindowPoStResponse { + cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown + crandomness, crandomnessAllocMap := randomness.PassValue() + cproverId, cproverIdAllocMap := proverId.PassValue() + cvanillaProofsPtr, cvanillaProofsPtrAllocMap := unpackArgSFilVanillaProof(vanillaProofsPtr) + cvanillaProofsLen, cvanillaProofsLenAllocMap := (C.size_t)(vanillaProofsLen), cgoAllocsUnknown + __ret := C.fil_generate_window_post_with_vanilla(cregisteredProof, crandomness, cproverId, cvanillaProofsPtr, cvanillaProofsLen) + runtime.KeepAlive(cvanillaProofsLenAllocMap) + packSFilVanillaProof(vanillaProofsPtr, cvanillaProofsPtr) + runtime.KeepAlive(cvanillaProofsPtrAllocMap) + runtime.KeepAlive(cproverIdAllocMap) + runtime.KeepAlive(crandomnessAllocMap) + runtime.KeepAlive(cregisteredProofAllocMap) + __v := NewFilGenerateWindowPoStResponseRef(unsafe.Pointer(__ret)) + return __v +} + +// FilGenerateWinningPost function as declared in filecoin-ffi/filcrypto.h:443 func FilGenerateWinningPost(randomness Fil32ByteArray, replicasPtr []FilPrivateReplicaInfo, replicasLen uint, proverId Fil32ByteArray) *FilGenerateWinningPoStResponse { crandomness, crandomnessAllocMap := randomness.PassValue() creplicasPtr, creplicasPtrAllocMap := unpackArgSFilPrivateReplicaInfo(replicasPtr) @@ -317,7 +379,7 @@ func FilGenerateWinningPost(randomness Fil32ByteArray, replicasPtr []FilPrivateR return __v } -// FilGenerateWinningPostSectorChallenge function as declared in filecoin-ffi/filcrypto.h:399 +// FilGenerateWinningPostSectorChallenge function as declared in filecoin-ffi/filcrypto.h:452 func FilGenerateWinningPostSectorChallenge(registeredProof FilRegisteredPoStProof, randomness Fil32ByteArray, sectorSetLen uint64, proverId Fil32ByteArray) *FilGenerateWinningPoStSectorChallenge { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown crandomness, crandomnessAllocMap := randomness.PassValue() @@ -332,14 +394,32 @@ func FilGenerateWinningPostSectorChallenge(registeredProof FilRegisteredPoStProo return __v } -// FilGetGpuDevices function as declared in filecoin-ffi/filcrypto.h:407 +// FilGenerateWinningPostWithVanilla function as declared in filecoin-ffi/filcrypto.h:461 +func FilGenerateWinningPostWithVanilla(registeredProof FilRegisteredPoStProof, randomness Fil32ByteArray, proverId Fil32ByteArray, vanillaProofsPtr []FilVanillaProof, vanillaProofsLen uint) *FilGenerateWinningPoStResponse { + cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown + crandomness, crandomnessAllocMap := randomness.PassValue() + cproverId, cproverIdAllocMap := proverId.PassValue() + cvanillaProofsPtr, cvanillaProofsPtrAllocMap := unpackArgSFilVanillaProof(vanillaProofsPtr) + cvanillaProofsLen, cvanillaProofsLenAllocMap := (C.size_t)(vanillaProofsLen), cgoAllocsUnknown + __ret := C.fil_generate_winning_post_with_vanilla(cregisteredProof, crandomness, cproverId, cvanillaProofsPtr, cvanillaProofsLen) + runtime.KeepAlive(cvanillaProofsLenAllocMap) + packSFilVanillaProof(vanillaProofsPtr, cvanillaProofsPtr) + runtime.KeepAlive(cvanillaProofsPtrAllocMap) + runtime.KeepAlive(cproverIdAllocMap) + runtime.KeepAlive(crandomnessAllocMap) + runtime.KeepAlive(cregisteredProofAllocMap) + __v := NewFilGenerateWinningPoStResponseRef(unsafe.Pointer(__ret)) + return __v +} + +// FilGetGpuDevices function as declared in filecoin-ffi/filcrypto.h:470 func FilGetGpuDevices() *FilGpuDeviceResponse { __ret := C.fil_get_gpu_devices() __v := NewFilGpuDeviceResponseRef(unsafe.Pointer(__ret)) return __v } -// FilGetMaxUserBytesPerStagedSector function as declared in filecoin-ffi/filcrypto.h:413 +// FilGetMaxUserBytesPerStagedSector function as declared in filecoin-ffi/filcrypto.h:476 func FilGetMaxUserBytesPerStagedSector(registeredProof FilRegisteredSealProof) uint64 { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_max_user_bytes_per_staged_sector(cregisteredProof) @@ -348,7 +428,7 @@ func FilGetMaxUserBytesPerStagedSector(registeredProof FilRegisteredSealProof) u return __v } -// FilGetPostCircuitIdentifier function as declared in filecoin-ffi/filcrypto.h:419 +// FilGetPostCircuitIdentifier function as declared in filecoin-ffi/filcrypto.h:482 func FilGetPostCircuitIdentifier(registeredProof FilRegisteredPoStProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_post_circuit_identifier(cregisteredProof) @@ -357,7 +437,7 @@ func FilGetPostCircuitIdentifier(registeredProof FilRegisteredPoStProof) *FilStr return __v } -// FilGetPostParamsCid function as declared in filecoin-ffi/filcrypto.h:425 +// FilGetPostParamsCid function as declared in filecoin-ffi/filcrypto.h:488 func FilGetPostParamsCid(registeredProof FilRegisteredPoStProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_post_params_cid(cregisteredProof) @@ -366,7 +446,7 @@ func FilGetPostParamsCid(registeredProof FilRegisteredPoStProof) *FilStringRespo return __v } -// FilGetPostParamsPath function as declared in filecoin-ffi/filcrypto.h:432 +// FilGetPostParamsPath function as declared in filecoin-ffi/filcrypto.h:495 func FilGetPostParamsPath(registeredProof FilRegisteredPoStProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_post_params_path(cregisteredProof) @@ -375,7 +455,7 @@ func FilGetPostParamsPath(registeredProof FilRegisteredPoStProof) *FilStringResp return __v } -// FilGetPostVerifyingKeyCid function as declared in filecoin-ffi/filcrypto.h:438 +// FilGetPostVerifyingKeyCid function as declared in filecoin-ffi/filcrypto.h:501 func FilGetPostVerifyingKeyCid(registeredProof FilRegisteredPoStProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_post_verifying_key_cid(cregisteredProof) @@ -384,7 +464,7 @@ func FilGetPostVerifyingKeyCid(registeredProof FilRegisteredPoStProof) *FilStrin return __v } -// FilGetPostVerifyingKeyPath function as declared in filecoin-ffi/filcrypto.h:445 +// FilGetPostVerifyingKeyPath function as declared in filecoin-ffi/filcrypto.h:508 func FilGetPostVerifyingKeyPath(registeredProof FilRegisteredPoStProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_post_verifying_key_path(cregisteredProof) @@ -393,7 +473,7 @@ func FilGetPostVerifyingKeyPath(registeredProof FilRegisteredPoStProof) *FilStri return __v } -// FilGetPostVersion function as declared in filecoin-ffi/filcrypto.h:451 +// FilGetPostVersion function as declared in filecoin-ffi/filcrypto.h:514 func FilGetPostVersion(registeredProof FilRegisteredPoStProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredPoStProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_post_version(cregisteredProof) @@ -402,7 +482,7 @@ func FilGetPostVersion(registeredProof FilRegisteredPoStProof) *FilStringRespons return __v } -// FilGetSealCircuitIdentifier function as declared in filecoin-ffi/filcrypto.h:457 +// FilGetSealCircuitIdentifier function as declared in filecoin-ffi/filcrypto.h:520 func FilGetSealCircuitIdentifier(registeredProof FilRegisteredSealProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_seal_circuit_identifier(cregisteredProof) @@ -411,7 +491,7 @@ func FilGetSealCircuitIdentifier(registeredProof FilRegisteredSealProof) *FilStr return __v } -// FilGetSealParamsCid function as declared in filecoin-ffi/filcrypto.h:463 +// FilGetSealParamsCid function as declared in filecoin-ffi/filcrypto.h:526 func FilGetSealParamsCid(registeredProof FilRegisteredSealProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_seal_params_cid(cregisteredProof) @@ -420,7 +500,7 @@ func FilGetSealParamsCid(registeredProof FilRegisteredSealProof) *FilStringRespo return __v } -// FilGetSealParamsPath function as declared in filecoin-ffi/filcrypto.h:470 +// FilGetSealParamsPath function as declared in filecoin-ffi/filcrypto.h:533 func FilGetSealParamsPath(registeredProof FilRegisteredSealProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_seal_params_path(cregisteredProof) @@ -429,7 +509,7 @@ func FilGetSealParamsPath(registeredProof FilRegisteredSealProof) *FilStringResp return __v } -// FilGetSealVerifyingKeyCid function as declared in filecoin-ffi/filcrypto.h:476 +// FilGetSealVerifyingKeyCid function as declared in filecoin-ffi/filcrypto.h:539 func FilGetSealVerifyingKeyCid(registeredProof FilRegisteredSealProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_seal_verifying_key_cid(cregisteredProof) @@ -438,7 +518,7 @@ func FilGetSealVerifyingKeyCid(registeredProof FilRegisteredSealProof) *FilStrin return __v } -// FilGetSealVerifyingKeyPath function as declared in filecoin-ffi/filcrypto.h:483 +// FilGetSealVerifyingKeyPath function as declared in filecoin-ffi/filcrypto.h:546 func FilGetSealVerifyingKeyPath(registeredProof FilRegisteredSealProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_seal_verifying_key_path(cregisteredProof) @@ -447,7 +527,7 @@ func FilGetSealVerifyingKeyPath(registeredProof FilRegisteredSealProof) *FilStri return __v } -// FilGetSealVersion function as declared in filecoin-ffi/filcrypto.h:489 +// FilGetSealVersion function as declared in filecoin-ffi/filcrypto.h:552 func FilGetSealVersion(registeredProof FilRegisteredSealProof) *FilStringResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown __ret := C.fil_get_seal_version(cregisteredProof) @@ -456,7 +536,7 @@ func FilGetSealVersion(registeredProof FilRegisteredSealProof) *FilStringRespons return __v } -// FilHash function as declared in filecoin-ffi/filcrypto.h:499 +// FilHash function as declared in filecoin-ffi/filcrypto.h:562 func FilHash(messagePtr string, messageLen uint) *FilHashResponse { messagePtr = safeString(messagePtr) cmessagePtr, cmessagePtrAllocMap := unpackPUint8TString(messagePtr) @@ -469,7 +549,7 @@ func FilHash(messagePtr string, messageLen uint) *FilHashResponse { return __v } -// FilHashVerify function as declared in filecoin-ffi/filcrypto.h:513 +// FilHashVerify function as declared in filecoin-ffi/filcrypto.h:576 func FilHashVerify(signaturePtr string, flattenedMessagesPtr string, flattenedMessagesLen uint, messageSizesPtr []uint, messageSizesLen uint, flattenedPublicKeysPtr string, flattenedPublicKeysLen uint) int32 { signaturePtr = safeString(signaturePtr) csignaturePtr, csignaturePtrAllocMap := unpackPUint8TString(signaturePtr) @@ -496,7 +576,7 @@ func FilHashVerify(signaturePtr string, flattenedMessagesPtr string, flattenedMe return __v } -// FilInitLogFd function as declared in filecoin-ffi/filcrypto.h:530 +// FilInitLogFd function as declared in filecoin-ffi/filcrypto.h:593 func FilInitLogFd(logFd int32) *FilInitLogFdResponse { clogFd, clogFdAllocMap := (C.int)(logFd), cgoAllocsUnknown __ret := C.fil_init_log_fd(clogFd) @@ -505,14 +585,14 @@ func FilInitLogFd(logFd int32) *FilInitLogFdResponse { return __v } -// FilPrivateKeyGenerate function as declared in filecoin-ffi/filcrypto.h:535 +// FilPrivateKeyGenerate function as declared in filecoin-ffi/filcrypto.h:598 func FilPrivateKeyGenerate() *FilPrivateKeyGenerateResponse { __ret := C.fil_private_key_generate() __v := NewFilPrivateKeyGenerateResponseRef(unsafe.Pointer(__ret)) return __v } -// FilPrivateKeyGenerateWithSeed function as declared in filecoin-ffi/filcrypto.h:548 +// FilPrivateKeyGenerateWithSeed function as declared in filecoin-ffi/filcrypto.h:611 func FilPrivateKeyGenerateWithSeed(rawSeed Fil32ByteArray) *FilPrivateKeyGenerateResponse { crawSeed, crawSeedAllocMap := rawSeed.PassValue() __ret := C.fil_private_key_generate_with_seed(crawSeed) @@ -521,7 +601,7 @@ func FilPrivateKeyGenerateWithSeed(rawSeed Fil32ByteArray) *FilPrivateKeyGenerat return __v } -// FilPrivateKeyPublicKey function as declared in filecoin-ffi/filcrypto.h:559 +// FilPrivateKeyPublicKey function as declared in filecoin-ffi/filcrypto.h:622 func FilPrivateKeyPublicKey(rawPrivateKeyPtr string) *FilPrivateKeyPublicKeyResponse { rawPrivateKeyPtr = safeString(rawPrivateKeyPtr) crawPrivateKeyPtr, crawPrivateKeyPtrAllocMap := unpackPUint8TString(rawPrivateKeyPtr) @@ -532,7 +612,7 @@ func FilPrivateKeyPublicKey(rawPrivateKeyPtr string) *FilPrivateKeyPublicKeyResp return __v } -// FilPrivateKeySign function as declared in filecoin-ffi/filcrypto.h:572 +// FilPrivateKeySign function as declared in filecoin-ffi/filcrypto.h:635 func FilPrivateKeySign(rawPrivateKeyPtr string, messagePtr string, messageLen uint) *FilPrivateKeySignResponse { rawPrivateKeyPtr = safeString(rawPrivateKeyPtr) crawPrivateKeyPtr, crawPrivateKeyPtrAllocMap := unpackPUint8TString(rawPrivateKeyPtr) @@ -549,7 +629,7 @@ func FilPrivateKeySign(rawPrivateKeyPtr string, messagePtr string, messageLen ui return __v } -// FilSealCommitPhase1 function as declared in filecoin-ffi/filcrypto.h:580 +// FilSealCommitPhase1 function as declared in filecoin-ffi/filcrypto.h:643 func FilSealCommitPhase1(registeredProof FilRegisteredSealProof, commR Fil32ByteArray, commD Fil32ByteArray, cacheDirPath string, replicaPath string, sectorId uint64, proverId Fil32ByteArray, ticket Fil32ByteArray, seed Fil32ByteArray, piecesPtr []FilPublicPieceInfo, piecesLen uint) *FilSealCommitPhase1Response { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown ccommR, ccommRAllocMap := commR.PassValue() @@ -583,7 +663,7 @@ func FilSealCommitPhase1(registeredProof FilRegisteredSealProof, commR Fil32Byte return __v } -// FilSealCommitPhase2 function as declared in filecoin-ffi/filcrypto.h:592 +// FilSealCommitPhase2 function as declared in filecoin-ffi/filcrypto.h:655 func FilSealCommitPhase2(sealCommitPhase1OutputPtr string, sealCommitPhase1OutputLen uint, sectorId uint64, proverId Fil32ByteArray) *FilSealCommitPhase2Response { sealCommitPhase1OutputPtr = safeString(sealCommitPhase1OutputPtr) csealCommitPhase1OutputPtr, csealCommitPhase1OutputPtrAllocMap := unpackPUint8TString(sealCommitPhase1OutputPtr) @@ -600,7 +680,7 @@ func FilSealCommitPhase2(sealCommitPhase1OutputPtr string, sealCommitPhase1Outpu return __v } -// FilSealPreCommitPhase1 function as declared in filecoin-ffi/filcrypto.h:601 +// FilSealPreCommitPhase1 function as declared in filecoin-ffi/filcrypto.h:664 func FilSealPreCommitPhase1(registeredProof FilRegisteredSealProof, cacheDirPath string, stagedSectorPath string, sealedSectorPath string, sectorId uint64, proverId Fil32ByteArray, ticket Fil32ByteArray, piecesPtr []FilPublicPieceInfo, piecesLen uint) *FilSealPreCommitPhase1Response { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown cacheDirPath = safeString(cacheDirPath) @@ -632,7 +712,7 @@ func FilSealPreCommitPhase1(registeredProof FilRegisteredSealProof, cacheDirPath return __v } -// FilSealPreCommitPhase2 function as declared in filecoin-ffi/filcrypto.h:615 +// FilSealPreCommitPhase2 function as declared in filecoin-ffi/filcrypto.h:678 func FilSealPreCommitPhase2(sealPreCommitPhase1OutputPtr string, sealPreCommitPhase1OutputLen uint, cacheDirPath string, sealedSectorPath string) *FilSealPreCommitPhase2Response { sealPreCommitPhase1OutputPtr = safeString(sealPreCommitPhase1OutputPtr) csealPreCommitPhase1OutputPtr, csealPreCommitPhase1OutputPtrAllocMap := unpackPUint8TString(sealPreCommitPhase1OutputPtr) @@ -653,7 +733,7 @@ func FilSealPreCommitPhase2(sealPreCommitPhase1OutputPtr string, sealPreCommitPh return __v } -// FilUnsealRange function as declared in filecoin-ffi/filcrypto.h:623 +// FilUnsealRange function as declared in filecoin-ffi/filcrypto.h:686 func FilUnsealRange(registeredProof FilRegisteredSealProof, cacheDirPath string, sealedSectorFdRaw int32, unsealOutputFdRaw int32, sectorId uint64, proverId Fil32ByteArray, ticket Fil32ByteArray, commD Fil32ByteArray, unpaddedByteIndex uint64, unpaddedBytesAmount uint64) *FilUnsealRangeResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown cacheDirPath = safeString(cacheDirPath) @@ -682,7 +762,7 @@ func FilUnsealRange(registeredProof FilRegisteredSealProof, cacheDirPath string, return __v } -// FilVerify function as declared in filecoin-ffi/filcrypto.h:645 +// FilVerify function as declared in filecoin-ffi/filcrypto.h:708 func FilVerify(signaturePtr string, flattenedDigestsPtr string, flattenedDigestsLen uint, flattenedPublicKeysPtr string, flattenedPublicKeysLen uint) int32 { signaturePtr = safeString(signaturePtr) csignaturePtr, csignaturePtrAllocMap := unpackPUint8TString(signaturePtr) @@ -705,7 +785,7 @@ func FilVerify(signaturePtr string, flattenedDigestsPtr string, flattenedDigests return __v } -// FilVerifySeal function as declared in filecoin-ffi/filcrypto.h:655 +// FilVerifySeal function as declared in filecoin-ffi/filcrypto.h:718 func FilVerifySeal(registeredProof FilRegisteredSealProof, commR Fil32ByteArray, commD Fil32ByteArray, proverId Fil32ByteArray, ticket Fil32ByteArray, seed Fil32ByteArray, sectorId uint64, proofPtr string, proofLen uint) *FilVerifySealResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown ccommR, ccommRAllocMap := commR.PassValue() @@ -732,7 +812,7 @@ func FilVerifySeal(registeredProof FilRegisteredSealProof, commR Fil32ByteArray, return __v } -// FilVerifyWindowPost function as declared in filecoin-ffi/filcrypto.h:668 +// FilVerifyWindowPost function as declared in filecoin-ffi/filcrypto.h:731 func FilVerifyWindowPost(randomness Fil32ByteArray, replicasPtr []FilPublicReplicaInfo, replicasLen uint, proofsPtr []FilPoStProof, proofsLen uint, proverId Fil32ByteArray) *FilVerifyWindowPoStResponse { crandomness, crandomnessAllocMap := randomness.PassValue() creplicasPtr, creplicasPtrAllocMap := unpackArgSFilPublicReplicaInfo(replicasPtr) @@ -753,7 +833,7 @@ func FilVerifyWindowPost(randomness Fil32ByteArray, replicasPtr []FilPublicRepli return __v } -// FilVerifyWinningPost function as declared in filecoin-ffi/filcrypto.h:678 +// FilVerifyWinningPost function as declared in filecoin-ffi/filcrypto.h:741 func FilVerifyWinningPost(randomness Fil32ByteArray, replicasPtr []FilPublicReplicaInfo, replicasLen uint, proofsPtr []FilPoStProof, proofsLen uint, proverId Fil32ByteArray) *FilVerifyWinningPoStResponse { crandomness, crandomnessAllocMap := randomness.PassValue() creplicasPtr, creplicasPtrAllocMap := unpackArgSFilPublicReplicaInfo(replicasPtr) @@ -774,7 +854,7 @@ func FilVerifyWinningPost(randomness Fil32ByteArray, replicasPtr []FilPublicRepl return __v } -// FilWriteWithAlignment function as declared in filecoin-ffi/filcrypto.h:689 +// FilWriteWithAlignment function as declared in filecoin-ffi/filcrypto.h:752 func FilWriteWithAlignment(registeredProof FilRegisteredSealProof, srcFd int32, srcSize uint64, dstFd int32, existingPieceSizesPtr []uint64, existingPieceSizesLen uint) *FilWriteWithAlignmentResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown csrcFd, csrcFdAllocMap := (C.int)(srcFd), cgoAllocsUnknown @@ -793,7 +873,7 @@ func FilWriteWithAlignment(registeredProof FilRegisteredSealProof, srcFd int32, return __v } -// FilWriteWithoutAlignment function as declared in filecoin-ffi/filcrypto.h:700 +// FilWriteWithoutAlignment function as declared in filecoin-ffi/filcrypto.h:763 func FilWriteWithoutAlignment(registeredProof FilRegisteredSealProof, srcFd int32, srcSize uint64, dstFd int32) *FilWriteWithoutAlignmentResponse { cregisteredProof, cregisteredProofAllocMap := (C.fil_RegisteredSealProof)(registeredProof), cgoAllocsUnknown csrcFd, csrcFdAllocMap := (C.int)(srcFd), cgoAllocsUnknown diff --git a/generated/types.go b/generated/types.go index c73e7d74..7021cc8b 100644 --- a/generated/types.go +++ b/generated/types.go @@ -61,7 +61,20 @@ type FilGenerateDataCommitmentResponse struct { allocs87da7dd9 interface{} } -// FilGeneratePieceCommitmentResponse as declared in filecoin-ffi/filcrypto.h:97 +// FilGenerateFallbackSectorChallengesResponse as declared in filecoin-ffi/filcrypto.h:96 +type FilGenerateFallbackSectorChallengesResponse struct { + ErrorMsg string + StatusCode FCPResponseStatus + IdsPtr []uint64 + IdsLen uint + ChallengesPtr []uint64 + ChallengesLen uint + ChallengesStride uint + ref7047a3fa *C.fil_GenerateFallbackSectorChallengesResponse + allocs7047a3fa interface{} +} + +// FilGeneratePieceCommitmentResponse as declared in filecoin-ffi/filcrypto.h:107 type FilGeneratePieceCommitmentResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -71,7 +84,24 @@ type FilGeneratePieceCommitmentResponse struct { allocs4b00fda4 interface{} } -// FilPoStProof as declared in filecoin-ffi/filcrypto.h:103 +// FilVanillaProof as declared in filecoin-ffi/filcrypto.h:112 +type FilVanillaProof struct { + ProofLen uint + ProofPtr string + refb3e7638c *C.fil_VanillaProof + allocsb3e7638c interface{} +} + +// FilGenerateSingleVanillaProofResponse as declared in filecoin-ffi/filcrypto.h:118 +type FilGenerateSingleVanillaProofResponse struct { + ErrorMsg string + VanillaProof FilVanillaProof + StatusCode FCPResponseStatus + reff9d21b04 *C.fil_GenerateSingleVanillaProofResponse + allocsf9d21b04 interface{} +} + +// FilPoStProof as declared in filecoin-ffi/filcrypto.h:124 type FilPoStProof struct { RegisteredProof FilRegisteredPoStProof ProofLen uint @@ -80,7 +110,7 @@ type FilPoStProof struct { allocs3451bfa interface{} } -// FilGenerateWindowPoStResponse as declared in filecoin-ffi/filcrypto.h:112 +// FilGenerateWindowPoStResponse as declared in filecoin-ffi/filcrypto.h:133 type FilGenerateWindowPoStResponse struct { ErrorMsg string ProofsLen uint @@ -92,7 +122,7 @@ type FilGenerateWindowPoStResponse struct { allocs2a5f3ba8 interface{} } -// FilGenerateWinningPoStResponse as declared in filecoin-ffi/filcrypto.h:119 +// FilGenerateWinningPoStResponse as declared in filecoin-ffi/filcrypto.h:140 type FilGenerateWinningPoStResponse struct { ErrorMsg string ProofsLen uint @@ -102,7 +132,7 @@ type FilGenerateWinningPoStResponse struct { allocs1405b8ec interface{} } -// FilGenerateWinningPoStSectorChallenge as declared in filecoin-ffi/filcrypto.h:126 +// FilGenerateWinningPoStSectorChallenge as declared in filecoin-ffi/filcrypto.h:147 type FilGenerateWinningPoStSectorChallenge struct { ErrorMsg string StatusCode FCPResponseStatus @@ -112,7 +142,7 @@ type FilGenerateWinningPoStSectorChallenge struct { allocs69d2a405 interface{} } -// FilGpuDeviceResponse as declared in filecoin-ffi/filcrypto.h:133 +// FilGpuDeviceResponse as declared in filecoin-ffi/filcrypto.h:154 type FilGpuDeviceResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -122,21 +152,21 @@ type FilGpuDeviceResponse struct { allocs58f92915 interface{} } -// FilBLSDigest as declared in filecoin-ffi/filcrypto.h:137 +// FilBLSDigest as declared in filecoin-ffi/filcrypto.h:158 type FilBLSDigest struct { Inner [96]byte ref215fc78c *C.fil_BLSDigest allocs215fc78c interface{} } -// FilHashResponse as declared in filecoin-ffi/filcrypto.h:144 +// FilHashResponse as declared in filecoin-ffi/filcrypto.h:165 type FilHashResponse struct { Digest FilBLSDigest refc52a22ef *C.fil_HashResponse allocsc52a22ef interface{} } -// FilInitLogFdResponse as declared in filecoin-ffi/filcrypto.h:149 +// FilInitLogFdResponse as declared in filecoin-ffi/filcrypto.h:170 type FilInitLogFdResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -144,42 +174,42 @@ type FilInitLogFdResponse struct { allocs3c1a0a08 interface{} } -// FilBLSPrivateKey as declared in filecoin-ffi/filcrypto.h:153 +// FilBLSPrivateKey as declared in filecoin-ffi/filcrypto.h:174 type FilBLSPrivateKey struct { Inner [32]byte ref2f77fe3a *C.fil_BLSPrivateKey allocs2f77fe3a interface{} } -// FilPrivateKeyGenerateResponse as declared in filecoin-ffi/filcrypto.h:160 +// FilPrivateKeyGenerateResponse as declared in filecoin-ffi/filcrypto.h:181 type FilPrivateKeyGenerateResponse struct { PrivateKey FilBLSPrivateKey ref2dba09f *C.fil_PrivateKeyGenerateResponse allocs2dba09f interface{} } -// FilBLSPublicKey as declared in filecoin-ffi/filcrypto.h:164 +// FilBLSPublicKey as declared in filecoin-ffi/filcrypto.h:185 type FilBLSPublicKey struct { Inner [48]byte ref6d0cab13 *C.fil_BLSPublicKey allocs6d0cab13 interface{} } -// FilPrivateKeyPublicKeyResponse as declared in filecoin-ffi/filcrypto.h:171 +// FilPrivateKeyPublicKeyResponse as declared in filecoin-ffi/filcrypto.h:192 type FilPrivateKeyPublicKeyResponse struct { PublicKey FilBLSPublicKey refee14e59d *C.fil_PrivateKeyPublicKeyResponse allocsee14e59d interface{} } -// FilPrivateKeySignResponse as declared in filecoin-ffi/filcrypto.h:178 +// FilPrivateKeySignResponse as declared in filecoin-ffi/filcrypto.h:199 type FilPrivateKeySignResponse struct { Signature FilBLSSignature refcdf97b28 *C.fil_PrivateKeySignResponse allocscdf97b28 interface{} } -// FilSealCommitPhase1Response as declared in filecoin-ffi/filcrypto.h:185 +// FilSealCommitPhase1Response as declared in filecoin-ffi/filcrypto.h:206 type FilSealCommitPhase1Response struct { StatusCode FCPResponseStatus ErrorMsg string @@ -189,7 +219,7 @@ type FilSealCommitPhase1Response struct { allocs61ed8561 interface{} } -// FilSealCommitPhase2Response as declared in filecoin-ffi/filcrypto.h:192 +// FilSealCommitPhase2Response as declared in filecoin-ffi/filcrypto.h:213 type FilSealCommitPhase2Response struct { StatusCode FCPResponseStatus ErrorMsg string @@ -199,7 +229,7 @@ type FilSealCommitPhase2Response struct { allocs5860b9a4 interface{} } -// FilSealPreCommitPhase1Response as declared in filecoin-ffi/filcrypto.h:199 +// FilSealPreCommitPhase1Response as declared in filecoin-ffi/filcrypto.h:220 type FilSealPreCommitPhase1Response struct { ErrorMsg string StatusCode FCPResponseStatus @@ -209,7 +239,7 @@ type FilSealPreCommitPhase1Response struct { allocs132bbfd8 interface{} } -// FilSealPreCommitPhase2Response as declared in filecoin-ffi/filcrypto.h:207 +// FilSealPreCommitPhase2Response as declared in filecoin-ffi/filcrypto.h:228 type FilSealPreCommitPhase2Response struct { ErrorMsg string StatusCode FCPResponseStatus @@ -220,7 +250,7 @@ type FilSealPreCommitPhase2Response struct { allocs2aa6831d interface{} } -// FilStringResponse as declared in filecoin-ffi/filcrypto.h:216 +// FilStringResponse as declared in filecoin-ffi/filcrypto.h:237 type FilStringResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -229,7 +259,7 @@ type FilStringResponse struct { allocs4f413043 interface{} } -// FilUnsealRangeResponse as declared in filecoin-ffi/filcrypto.h:221 +// FilUnsealRangeResponse as declared in filecoin-ffi/filcrypto.h:242 type FilUnsealRangeResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -237,7 +267,7 @@ type FilUnsealRangeResponse struct { allocs61e219c9 interface{} } -// FilVerifySealResponse as declared in filecoin-ffi/filcrypto.h:227 +// FilVerifySealResponse as declared in filecoin-ffi/filcrypto.h:248 type FilVerifySealResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -246,7 +276,7 @@ type FilVerifySealResponse struct { allocsd4397079 interface{} } -// FilVerifyWindowPoStResponse as declared in filecoin-ffi/filcrypto.h:233 +// FilVerifyWindowPoStResponse as declared in filecoin-ffi/filcrypto.h:254 type FilVerifyWindowPoStResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -255,7 +285,7 @@ type FilVerifyWindowPoStResponse struct { allocs34c4d49f interface{} } -// FilVerifyWinningPoStResponse as declared in filecoin-ffi/filcrypto.h:239 +// FilVerifyWinningPoStResponse as declared in filecoin-ffi/filcrypto.h:260 type FilVerifyWinningPoStResponse struct { StatusCode FCPResponseStatus ErrorMsg string @@ -264,7 +294,7 @@ type FilVerifyWinningPoStResponse struct { allocsaca6860c interface{} } -// FilWriteWithAlignmentResponse as declared in filecoin-ffi/filcrypto.h:247 +// FilWriteWithAlignmentResponse as declared in filecoin-ffi/filcrypto.h:268 type FilWriteWithAlignmentResponse struct { CommP [32]byte ErrorMsg string @@ -275,7 +305,7 @@ type FilWriteWithAlignmentResponse struct { allocsa330e79 interface{} } -// FilWriteWithoutAlignmentResponse as declared in filecoin-ffi/filcrypto.h:254 +// FilWriteWithoutAlignmentResponse as declared in filecoin-ffi/filcrypto.h:275 type FilWriteWithoutAlignmentResponse struct { CommP [32]byte ErrorMsg string @@ -285,7 +315,7 @@ type FilWriteWithoutAlignmentResponse struct { allocsc8e1ed8 interface{} } -// FilPublicPieceInfo as declared in filecoin-ffi/filcrypto.h:259 +// FilPublicPieceInfo as declared in filecoin-ffi/filcrypto.h:280 type FilPublicPieceInfo struct { NumBytes uint64 CommP [32]byte @@ -293,14 +323,14 @@ type FilPublicPieceInfo struct { allocsd00025ac interface{} } -// Fil32ByteArray as declared in filecoin-ffi/filcrypto.h:263 +// Fil32ByteArray as declared in filecoin-ffi/filcrypto.h:284 type Fil32ByteArray struct { Inner [32]byte ref373ec61a *C.fil_32ByteArray allocs373ec61a interface{} } -// FilPrivateReplicaInfo as declared in filecoin-ffi/filcrypto.h:271 +// FilPrivateReplicaInfo as declared in filecoin-ffi/filcrypto.h:292 type FilPrivateReplicaInfo struct { RegisteredProof FilRegisteredPoStProof CacheDirPath string @@ -311,7 +341,7 @@ type FilPrivateReplicaInfo struct { allocs81a31e9b interface{} } -// FilPublicReplicaInfo as declared in filecoin-ffi/filcrypto.h:277 +// FilPublicReplicaInfo as declared in filecoin-ffi/filcrypto.h:298 type FilPublicReplicaInfo struct { RegisteredProof FilRegisteredPoStProof CommR [32]byte diff --git a/go.sum b/go.sum index df493496..b2396cc5 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,4 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Kubuxu/c-for-go v0.0.0-20200729154323-9d77fa534f6d h1:JghhdYRtonvueFGY1fvc5Nxj81abWk5D0dirvlo8OtQ= -github.com/Kubuxu/c-for-go v0.0.0-20200729154323-9d77fa534f6d/go.mod h1:h/1PEBwj7Ym/8kOuMWvO2ujZ6Lt+TMbySEXNhjjR87I= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -133,7 +131,6 @@ github.com/whyrusleeping/cbor-gen v0.0.0-20200715143311-227fab5a2377/go.mod h1:f github.com/whyrusleeping/cbor-gen v0.0.0-20200810223238-211df3b9e24c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= github.com/whyrusleeping/cbor-gen v0.0.0-20200812213548-958ddffe352c h1:otRnI08JoahNBxUFqX3372Ab9GnTj8L5J9iP5ImyxGU= github.com/whyrusleeping/cbor-gen v0.0.0-20200812213548-958ddffe352c/go.mod h1:fgkXqYy7bV2cFeIEOkVTZS/WjXARfBqSH6Q2qHL33hQ= -github.com/xlab/c-for-go v0.0.0-20200718154222-87b0065af829/go.mod h1:h/1PEBwj7Ym/8kOuMWvO2ujZ6Lt+TMbySEXNhjjR87I= github.com/xlab/c-for-go v0.0.0-20201002084316-c134bfab968f h1:nMhj+x/m7ZQsHBz0L3gpytp0v6ogokdbrQDnhB8Kh7s= github.com/xlab/c-for-go v0.0.0-20201002084316-c134bfab968f/go.mod h1:h/1PEBwj7Ym/8kOuMWvO2ujZ6Lt+TMbySEXNhjjR87I= github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 h1:Sw125DKxZhPUI4JLlWugkzsrlB50jR9v2khiD9FxuSo= diff --git a/proofs.go b/proofs.go index 2e3f9013..b2c8c7fe 100644 --- a/proofs.go +++ b/proofs.go @@ -574,6 +574,7 @@ func GenerateWindowPoSt( resp.Deref() resp.ProofsPtr = make([]generated.FilPoStProof, resp.ProofsLen) resp.Deref() + resp.FaultySectorsPtr = resp.FaultySectorsPtr[:resp.FaultySectorsLen] defer generated.FilDestroyGenerateWindowPostResponse(resp) @@ -769,6 +770,28 @@ func toFilPublicReplicaInfos(src []proof.SectorInfo, typ string) ([]generated.Fi return out, uint(len(out)), nil } +func toFilPrivateReplicaInfo(src PrivateSectorInfo) (generated.FilPrivateReplicaInfo, func(), error) { + commR, err := to32ByteCommR(src.SealedCID) + if err != nil { + return generated.FilPrivateReplicaInfo{}, func() {}, err + } + + pp, err := toFilRegisteredPoStProof(src.PoStProofType) + if err != nil { + return generated.FilPrivateReplicaInfo{}, func() {}, err + } + + out := generated.FilPrivateReplicaInfo{ + RegisteredProof: pp, + CacheDirPath: src.CacheDirPath, + CommR: commR.Inner, + ReplicaPath: src.SealedSectorPath, + SectorId: uint64(src.SectorNumber), + } + free := out.AllocateProxy() + return out, free, nil +} + func toFilPrivateReplicaInfos(src []PrivateSectorInfo, typ string) ([]generated.FilPrivateReplicaInfo, uint, func(), error) { frees := make([]func(), len(src)) @@ -992,3 +1015,23 @@ type stringHeader struct { Data unsafe.Pointer Len int } + +func toVanillaProofs(src [][]byte) ([]generated.FilVanillaProof, func()) { + frees := make([]func(), len(src)) + + out := make([]generated.FilVanillaProof, len(src)) + for idx := range out { + out[idx] = generated.FilVanillaProof{ + ProofLen: uint(len(src[idx])), + ProofPtr: string(src[idx]), + } + + frees[idx] = out[idx].AllocateProxy() + } + + return out, func() { + for idx := range frees { + frees[idx]() + } + } +} diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 3ce642cb..52565734 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1058,51 +1058,51 @@ checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "futures" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" +checksum = "4c7e4c2612746b0df8fed4ce0c69156021b704c9aefa360311c04e6e9e002eed" [[package]] name = "futures-channel" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +checksum = "a7a4d35f7401e948629c9c3d6638fb9bf94e0b2121e96c3b428cc4e631f3eb74" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "d674eaa0056896d5ada519900dbf97ead2e46a7b6621e8160d79e2f2e1e2784b" [[package]] name = "futures-io" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +checksum = "5fc94b64bb39543b4e432f1790b6bf18e3ee3b74653c5449f63310e9a74b123c" [[package]] name = "futures-sink" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +checksum = "0d8764258ed64ebc5d9ed185cf86a95db5cac810269c5d20ececb32e0088abbd" [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +checksum = "4dd26820a9f3637f1302da8bceba3ff33adbe53464b54ca24d4e2d4f1db30f94" dependencies = [ "once_cell", ] [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "8a894a0acddba51a2d49a6f4263b1e64b8c579ece8af50fa86503d52cd1eea34" dependencies = [ "futures-core", "futures-io", @@ -1212,9 +1212,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" dependencies = [ "libc", ] @@ -1451,9 +1451,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.78" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa7087f49d294270db4e1928fc110c976cd4b9e5a16348e0a1df09afa99e6c98" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" [[package]] name = "libloading" @@ -1929,18 +1929,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b9e280448854bd91559252582173b3bd1f8e094a0e644791c0628ca9b1f144f" +checksum = "13fbdfd6bdee3dc9be46452f86af4a4072975899cf8592466668620bebfbcc17" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8c8b352676bc6a4c3d71970560b913cea444a7a921cc2e2d920225e4b91edaa" +checksum = "c82fb1329f632c3552cf352d14427d57a511b1cf41db93b3a7d77906a82dcc8e" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.7", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 8f679615..fce6b2c7 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -34,7 +34,7 @@ neptune-triton = "=1.0.0" [dependencies.filecoin-proofs-api] package = "filecoin-proofs-api" -version = "5.1.1" +version = "5.2.0" [build-dependencies] cbindgen = "= 0.14.0" diff --git a/rust/src/proofs/api.rs b/rust/src/proofs/api.rs index 5062e0cb..028393b3 100644 --- a/rust/src/proofs/api.rs +++ b/rust/src/proofs/api.rs @@ -3,10 +3,11 @@ use ffi_toolkit::{ }; use filecoin_proofs_api::seal::SealPreCommitPhase2Output; use filecoin_proofs_api::{ - PieceInfo, RegisteredPoStProof, RegisteredSealProof, SectorId, UnpaddedByteIndex, - UnpaddedBytesAmount, + PieceInfo, PrivateReplicaInfo, RegisteredPoStProof, RegisteredSealProof, SectorId, + UnpaddedByteIndex, UnpaddedBytesAmount, }; -use log::info; + +use log::{error, info}; use std::mem; use std::path::PathBuf; use std::slice::from_raw_parts; @@ -15,6 +16,9 @@ use super::helpers::{c_to_rust_post_proofs, to_private_replica_info_map}; use super::types::*; use crate::util::api::init_log; +// A byte serialized representation of a vanilla proof. +pub type VanillaProof = Vec; + /// TODO: document /// #[no_mangle] @@ -513,6 +517,325 @@ pub unsafe extern "C" fn fil_verify_seal( }) } +/// TODO: document +/// +#[no_mangle] +pub unsafe extern "C" fn fil_generate_winning_post_sector_challenge( + registered_proof: fil_RegisteredPoStProof, + randomness: fil_32ByteArray, + sector_set_len: u64, + prover_id: fil_32ByteArray, +) -> *mut fil_GenerateWinningPoStSectorChallenge { + catch_panic_response(|| { + init_log(); + + info!("generate_winning_post_sector_challenge: start"); + + let mut response = fil_GenerateWinningPoStSectorChallenge::default(); + + let result = filecoin_proofs_api::post::generate_winning_post_sector_challenge( + registered_proof.into(), + &randomness.inner, + sector_set_len, + prover_id.inner, + ); + + match result { + Ok(output) => { + let mapped: Vec = output.into_iter().map(u64::from).collect(); + + response.status_code = FCPResponseStatus::FCPNoError; + response.ids_ptr = mapped.as_ptr(); + response.ids_len = mapped.len(); + + mem::forget(mapped); + } + Err(err) => { + response.status_code = FCPResponseStatus::FCPUnclassifiedError; + response.error_msg = rust_str_to_c_str(format!("{:?}", err)); + } + } + + info!("generate_winning_post_sector_challenge: finish"); + + raw_ptr(response) + }) +} + +/// TODO: document +/// +#[no_mangle] +pub unsafe extern "C" fn fil_generate_fallback_sector_challenges( + registered_proof: fil_RegisteredPoStProof, + randomness: fil_32ByteArray, + sector_ids_ptr: *const u64, + sector_ids_len: libc::size_t, + prover_id: fil_32ByteArray, +) -> *mut fil_GenerateFallbackSectorChallengesResponse { + catch_panic_response(|| { + init_log(); + + info!("generate_fallback_sector_challenges: start"); + + let pub_sectors: Vec = from_raw_parts(sector_ids_ptr, sector_ids_len) + .iter() + .cloned() + .map(Into::into) + .collect(); + + let result = filecoin_proofs_api::post::generate_fallback_sector_challenges( + registered_proof.into(), + &randomness.inner, + &pub_sectors, + prover_id.inner, + ); + + let mut response = fil_GenerateFallbackSectorChallengesResponse::default(); + + match result { + Ok(output) => { + response.status_code = FCPResponseStatus::FCPNoError; + + let sector_ids: Vec = output + .clone() + .into_iter() + .map(|(id, _challenges)| u64::from(id)) + .collect(); + let mut challenges_stride = 0; + let mut challenges_stride_mismatch = false; + let challenges: Vec = output + .into_iter() + .flat_map(|(_id, challenges)| { + if challenges_stride == 0 { + challenges_stride = challenges.len(); + } + + if !challenges_stride_mismatch && challenges_stride != challenges.len() { + error!( + "All challenge strides must be equal: {} != {}", + challenges_stride, + challenges.len() + ); + challenges_stride_mismatch = true; + } + + challenges + }) + .collect(); + + if challenges_stride_mismatch { + response.status_code = FCPResponseStatus::FCPUnclassifiedError; + response.error_msg = rust_str_to_c_str("Challenge stride mismatch".to_string()); + } else { + response.status_code = FCPResponseStatus::FCPNoError; + response.ids_ptr = sector_ids.as_ptr(); + response.ids_len = sector_ids.len(); + response.challenges_ptr = challenges.as_ptr(); + response.challenges_len = challenges.len(); + response.challenges_stride = challenges_stride; + + mem::forget(sector_ids); + mem::forget(challenges); + } + } + Err(err) => { + response.status_code = FCPResponseStatus::FCPUnclassifiedError; + response.error_msg = rust_str_to_c_str(format!("{:?}", err)); + } + }; + + info!("generate_fallback_sector_challenges: finish"); + + raw_ptr(response) + }) +} + +/// TODO: document +/// +#[no_mangle] +pub unsafe extern "C" fn fil_generate_single_vanilla_proof( + replica: fil_PrivateReplicaInfo, + challenges_ptr: *const u64, + challenges_len: libc::size_t, +) -> *mut fil_GenerateSingleVanillaProofResponse { + catch_panic_response(|| { + init_log(); + + info!("generate_single_vanilla_proof: start"); + + let challenges: Vec = from_raw_parts(challenges_ptr, challenges_len) + .iter() + .copied() + .collect(); + + let sector_id = SectorId::from(replica.sector_id); + let cache_dir_path = c_str_to_pbuf(replica.cache_dir_path); + let replica_path = c_str_to_pbuf(replica.replica_path); + + let replica_v1 = PrivateReplicaInfo::new( + replica.registered_proof.into(), + replica.comm_r, + cache_dir_path, + replica_path, + ); + + let result = filecoin_proofs_api::post::generate_single_vanilla_proof( + replica.registered_proof.into(), + sector_id, + &replica_v1, + &challenges, + ); + + let mut response = fil_GenerateSingleVanillaProofResponse::default(); + + match result { + Ok(output) => { + response.status_code = FCPResponseStatus::FCPNoError; + response.vanilla_proof.proof_len = output.len(); + response.vanilla_proof.proof_ptr = output.as_ptr(); + + mem::forget(output); + } + Err(err) => { + response.status_code = FCPResponseStatus::FCPUnclassifiedError; + response.error_msg = rust_str_to_c_str(format!("{:?}", err)); + } + }; + + info!("generate_single_vanilla_proof: finish"); + + raw_ptr(response) + }) +} + +/// TODO: document +/// +#[no_mangle] +pub unsafe extern "C" fn fil_generate_winning_post_with_vanilla( + registered_proof: fil_RegisteredPoStProof, + randomness: fil_32ByteArray, + prover_id: fil_32ByteArray, + vanilla_proofs_ptr: *const fil_VanillaProof, + vanilla_proofs_len: libc::size_t, +) -> *mut fil_GenerateWinningPoStResponse { + catch_panic_response(|| { + init_log(); + + info!("generate_winning_post_with_vanilla: start"); + + let vanilla_proofs: Vec = + from_raw_parts(vanilla_proofs_ptr, vanilla_proofs_len) + .iter() + .cloned() + .map(|vanilla_proof| { + from_raw_parts(vanilla_proof.proof_ptr, vanilla_proof.proof_len).to_vec() + }) + .collect(); + + let result = filecoin_proofs_api::post::generate_winning_post_with_vanilla( + registered_proof.into(), + &randomness.inner, + prover_id.inner, + &vanilla_proofs, + ); + + let mut response = fil_GenerateWinningPoStResponse::default(); + + match result { + Ok(output) => { + let mapped: Vec = output + .iter() + .cloned() + .map(|(t, proof)| { + let out = fil_PoStProof { + registered_proof: (t).into(), + proof_len: proof.len(), + proof_ptr: proof.as_ptr(), + }; + + mem::forget(proof); + + out + }) + .collect(); + + response.status_code = FCPResponseStatus::FCPNoError; + response.proofs_ptr = mapped.as_ptr(); + response.proofs_len = mapped.len(); + + mem::forget(mapped); + } + Err(err) => { + response.status_code = FCPResponseStatus::FCPUnclassifiedError; + response.error_msg = rust_str_to_c_str(format!("{:?}", err)); + } + } + + info!("generate_winning_post_with_vanilla: finish"); + + raw_ptr(response) + }) +} + +/// TODO: document +/// +#[no_mangle] +pub unsafe extern "C" fn fil_generate_winning_post( + randomness: fil_32ByteArray, + replicas_ptr: *const fil_PrivateReplicaInfo, + replicas_len: libc::size_t, + prover_id: fil_32ByteArray, +) -> *mut fil_GenerateWinningPoStResponse { + catch_panic_response(|| { + init_log(); + + info!("generate_winning_post: start"); + + let mut response = fil_GenerateWinningPoStResponse::default(); + + let result = to_private_replica_info_map(replicas_ptr, replicas_len).and_then(|rs| { + filecoin_proofs_api::post::generate_winning_post( + &randomness.inner, + &rs, + prover_id.inner, + ) + }); + + match result { + Ok(output) => { + let mapped: Vec = output + .iter() + .cloned() + .map(|(t, proof)| { + let out = fil_PoStProof { + registered_proof: (t).into(), + proof_len: proof.len(), + proof_ptr: proof.as_ptr(), + }; + + mem::forget(proof); + + out + }) + .collect(); + + response.status_code = FCPResponseStatus::FCPNoError; + response.proofs_ptr = mapped.as_ptr(); + response.proofs_len = mapped.len(); + mem::forget(mapped); + } + Err(err) => { + response.status_code = FCPResponseStatus::FCPUnclassifiedError; + response.error_msg = rust_str_to_c_str(format!("{:?}", err)); + } + } + + info!("generate_winning_post: finish"); + + raw_ptr(response) + }) +} + /// Verifies that a proof-of-spacetime is valid. #[no_mangle] pub unsafe extern "C" fn fil_verify_winning_post( @@ -560,6 +883,87 @@ pub unsafe extern "C" fn fil_verify_winning_post( }) } +/// TODO: document +/// +#[no_mangle] +pub unsafe extern "C" fn fil_generate_window_post_with_vanilla( + registered_proof: fil_RegisteredPoStProof, + randomness: fil_32ByteArray, + prover_id: fil_32ByteArray, + vanilla_proofs_ptr: *const fil_VanillaProof, + vanilla_proofs_len: libc::size_t, +) -> *mut fil_GenerateWindowPoStResponse { + catch_panic_response(|| { + init_log(); + + info!("generate_window_post_with_vanilla: start"); + + let vanilla_proofs: Vec = + from_raw_parts(vanilla_proofs_ptr, vanilla_proofs_len) + .iter() + .cloned() + .map(|vanilla_proof| { + from_raw_parts(vanilla_proof.proof_ptr, vanilla_proof.proof_len).to_vec() + }) + .collect(); + + let result = filecoin_proofs_api::post::generate_window_post_with_vanilla( + registered_proof.into(), + &randomness.inner, + prover_id.inner, + &vanilla_proofs, + ); + + let mut response = fil_GenerateWindowPoStResponse::default(); + + match result { + Ok(output) => { + let mapped: Vec = output + .iter() + .cloned() + .map(|(t, proof)| { + let out = fil_PoStProof { + registered_proof: (t).into(), + proof_len: proof.len(), + proof_ptr: proof.as_ptr(), + }; + + mem::forget(proof); + + out + }) + .collect(); + + response.status_code = FCPResponseStatus::FCPNoError; + response.proofs_ptr = mapped.as_ptr(); + response.proofs_len = mapped.len(); + mem::forget(mapped); + } + Err(err) => { + // If there were faulty sectors, add them to the response + if let Some(filecoin_proofs_api::StorageProofsError::FaultySectors(sectors)) = + err.downcast_ref::() + { + let sectors_u64 = sectors + .iter() + .map(|sector| u64::from(*sector)) + .collect::>(); + response.faulty_sectors_len = sectors_u64.len(); + response.faulty_sectors_ptr = sectors_u64.as_ptr(); + mem::forget(sectors_u64) + } + + response.status_code = FCPResponseStatus::FCPUnclassifiedError; + response.error_msg = rust_str_to_c_str(format!("{:?}", err)); + } + } + + info!("generate_window_post_with_vanilla: finish"); + + raw_ptr(response) + }) +} + /// TODO: document /// #[no_mangle] @@ -790,109 +1194,6 @@ pub unsafe extern "C" fn fil_clear_cache( }) } -/// TODO: document -/// -#[no_mangle] -pub unsafe extern "C" fn fil_generate_winning_post_sector_challenge( - registered_proof: fil_RegisteredPoStProof, - randomness: fil_32ByteArray, - sector_set_len: u64, - prover_id: fil_32ByteArray, -) -> *mut fil_GenerateWinningPoStSectorChallenge { - catch_panic_response(|| { - init_log(); - - info!("generate_winning_post_sector_challenge: start"); - - let mut response = fil_GenerateWinningPoStSectorChallenge::default(); - - let result = filecoin_proofs_api::post::generate_winning_post_sector_challenge( - registered_proof.into(), - &randomness.inner, - sector_set_len, - prover_id.inner, - ); - - match result { - Ok(output) => { - let mapped: Vec = output.into_iter().map(u64::from).collect(); - - response.status_code = FCPResponseStatus::FCPNoError; - response.ids_ptr = mapped.as_ptr(); - response.ids_len = mapped.len(); - mem::forget(mapped); - } - Err(err) => { - response.status_code = FCPResponseStatus::FCPUnclassifiedError; - response.error_msg = rust_str_to_c_str(format!("{:?}", err)); - } - } - - info!("generate_winning_post_sector_challenge: finish"); - - raw_ptr(response) - }) -} - -/// TODO: document -/// -#[no_mangle] -pub unsafe extern "C" fn fil_generate_winning_post( - randomness: fil_32ByteArray, - replicas_ptr: *const fil_PrivateReplicaInfo, - replicas_len: libc::size_t, - prover_id: fil_32ByteArray, -) -> *mut fil_GenerateWinningPoStResponse { - catch_panic_response(|| { - init_log(); - - info!("generate_winning_post: start"); - - let mut response = fil_GenerateWinningPoStResponse::default(); - - let result = to_private_replica_info_map(replicas_ptr, replicas_len).and_then(|rs| { - filecoin_proofs_api::post::generate_winning_post( - &randomness.inner, - &rs, - prover_id.inner, - ) - }); - - match result { - Ok(output) => { - let mapped: Vec = output - .iter() - .cloned() - .map(|(t, proof)| { - let out = fil_PoStProof { - registered_proof: (t).into(), - proof_len: proof.len(), - proof_ptr: proof.as_ptr(), - }; - - mem::forget(proof); - - out - }) - .collect(); - - response.status_code = FCPResponseStatus::FCPNoError; - response.proofs_ptr = mapped.as_ptr(); - response.proofs_len = mapped.len(); - mem::forget(mapped); - } - Err(err) => { - response.status_code = FCPResponseStatus::FCPUnclassifiedError; - response.error_msg = rust_str_to_c_str(format!("{:?}", err)); - } - } - - info!("generate_winning_post: finish"); - - raw_ptr(response) - }) -} - #[no_mangle] pub unsafe extern "C" fn fil_destroy_write_with_alignment_response( ptr: *mut fil_WriteWithAlignmentResponse, @@ -1173,6 +1474,20 @@ pub unsafe extern "C" fn fil_destroy_verify_window_post_response( let _ = Box::from_raw(ptr); } +#[no_mangle] +pub unsafe extern "C" fn fil_destroy_generate_fallback_sector_challenges_response( + ptr: *mut fil_GenerateFallbackSectorChallengesResponse, +) { + let _ = Box::from_raw(ptr); +} + +#[no_mangle] +pub unsafe extern "C" fn fil_destroy_generate_single_vanilla_proof_response( + ptr: *mut fil_GenerateSingleVanillaProofResponse, +) { + let _ = Box::from_raw(ptr); +} + #[no_mangle] pub unsafe extern "C" fn fil_destroy_generate_winning_post_response( ptr: *mut fil_GenerateWinningPoStResponse, @@ -1367,6 +1682,7 @@ pub mod tests { } #[test] + #[allow(clippy::cognitive_complexity)] fn test_sealing() -> Result<()> { let wrap = |x| fil_32ByteArray { inner: x }; @@ -1381,6 +1697,7 @@ pub mod tests { let prover_id = fil_32ByteArray { inner: [1u8; 32] }; let randomness = fil_32ByteArray { inner: [7u8; 32] }; let sector_id = 42; + let sector_id2 = 43; let seed = fil_32ByteArray { inner: [5u8; 32] }; let ticket = fil_32ByteArray { inner: [6u8; 32] }; @@ -1662,6 +1979,103 @@ pub mod tests { panic!("verify_winning_post rejected the provided proof as invalid"); } + ////////////////////////////////////////////// + // Winning PoSt using distributed API + // + // NOTE: This performs the winning post all over again, just using + // a different API. This is just for testing and would not normally + // be repeated like this in sequence. + // + ////////////////////////////////////////////// + + // First generate sector challenges. + let resp_sc = fil_generate_fallback_sector_challenges( + registered_proof_winning_post, + randomness, + sectors.as_ptr(), + sectors.len(), + prover_id, + ); + + if (*resp_sc).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_sc).error_msg); + panic!("fallback_sector_challenges failed: {:?}", msg); + } + + let sector_ids: Vec = + from_raw_parts((*resp_sc).ids_ptr, (*resp_sc).ids_len).to_vec(); + let sector_challenges: Vec = + from_raw_parts((*resp_sc).challenges_ptr, (*resp_sc).challenges_len).to_vec(); + let challenges_stride = (*resp_sc).challenges_stride; + let challenge_iterations = sector_challenges.len() / challenges_stride; + assert_eq!( + sector_ids.len(), + challenge_iterations, + "Challenge iterations must match the number of sector ids" + ); + + let mut vanilla_proofs: Vec = Vec::with_capacity(sector_ids.len()); + + // Gather up all vanilla proofs. + for i in 0..challenge_iterations { + let sector_id = sector_ids[i]; + let challenges: Vec<_> = sector_challenges + [i * challenges_stride..i * challenges_stride + challenges_stride] + .to_vec(); + let private_replica = private_replicas + .iter() + .find(|&replica| replica.sector_id == sector_id) + .expect("failed to find private replica info") + .clone(); + + let resp_vp = fil_generate_single_vanilla_proof( + private_replica, + challenges.as_ptr(), + challenges.len(), + ); + + if (*resp_vp).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_vp).error_msg); + panic!("generate_single_vanilla_proof failed: {:?}", msg); + } + + vanilla_proofs.push((*resp_vp).vanilla_proof.clone()); + fil_destroy_generate_single_vanilla_proof_response(resp_vp); + } + + let resp_wpwv = fil_generate_winning_post_with_vanilla( + registered_proof_winning_post, + randomness, + prover_id, + vanilla_proofs.as_ptr(), + vanilla_proofs.len(), + ); + + if (*resp_wpwv).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_wpwv).error_msg); + panic!("generate_winning_post_with_vanilla failed: {:?}", msg); + } + + // Verify the second winning post (generated by the + // distributed post API) + let resp_di = fil_verify_winning_post( + randomness, + public_replicas.as_ptr(), + public_replicas.len(), + (*resp_wpwv).proofs_ptr, + (*resp_wpwv).proofs_len, + prover_id, + ); + + if (*resp_di).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_di).error_msg); + panic!("verify_winning_post failed: {:?}", msg); + } + + if !(*resp_di).is_valid { + panic!("verify_winning_post rejected the provided proof as invalid"); + } + // window post let private_replicas = vec![fil_PrivateReplicaInfo { @@ -1708,6 +2122,132 @@ pub mod tests { panic!("verify_window_post rejected the provided proof as invalid"); } + ////////////////////////////////////////////// + // Window PoSt using distributed API + // + // NOTE: This performs the window post all over again, just using + // a different API. This is just for testing and would not normally + // be repeated like this in sequence. + // + ////////////////////////////////////////////// + + let sectors = vec![sector_id, sector_id2]; + let private_replicas = vec![ + fil_PrivateReplicaInfo { + registered_proof: registered_proof_window_post, + cache_dir_path: cache_dir_path_c_str, + comm_r: (*resp_b2).comm_r, + replica_path: replica_path_c_str, + sector_id, + }, + fil_PrivateReplicaInfo { + registered_proof: registered_proof_window_post, + cache_dir_path: cache_dir_path_c_str, + comm_r: (*resp_b2).comm_r, + replica_path: replica_path_c_str, + sector_id: sector_id2, + }, + ]; + let public_replicas = vec![ + fil_PublicReplicaInfo { + registered_proof: registered_proof_window_post, + sector_id, + comm_r: (*resp_b2).comm_r, + }, + fil_PublicReplicaInfo { + registered_proof: registered_proof_window_post, + sector_id: sector_id2, + comm_r: (*resp_b2).comm_r, + }, + ]; + + // Generate sector challenges. + let resp_sc2 = fil_generate_fallback_sector_challenges( + registered_proof_window_post, + randomness, + sectors.as_ptr(), + sectors.len(), + prover_id, + ); + + if (*resp_sc2).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_sc2).error_msg); + panic!("fallback_sector_challenges failed: {:?}", msg); + } + + let sector_ids: Vec = + from_raw_parts((*resp_sc2).ids_ptr, (*resp_sc2).ids_len).to_vec(); + let sector_challenges: Vec = + from_raw_parts((*resp_sc2).challenges_ptr, (*resp_sc2).challenges_len).to_vec(); + let challenges_stride = (*resp_sc2).challenges_stride; + let challenge_iterations = sector_challenges.len() / challenges_stride; + assert_eq!( + sector_ids.len(), + challenge_iterations, + "Challenge iterations must match the number of sector ids" + ); + + let mut vanilla_proofs: Vec = Vec::with_capacity(sector_ids.len()); + + // Gather up all vanilla proofs. + for i in 0..challenge_iterations { + let sector_id = sector_ids[i]; + let challenges: Vec<_> = sector_challenges + [i * challenges_stride..i * challenges_stride + challenges_stride] + .to_vec(); + + let private_replica = private_replicas + .iter() + .find(|&replica| replica.sector_id == sector_id) + .expect("failed to find private replica info") + .clone(); + + let resp_vp = fil_generate_single_vanilla_proof( + private_replica, + challenges.as_ptr(), + challenges.len(), + ); + + if (*resp_vp).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_vp).error_msg); + panic!("generate_single_vanilla_proof failed: {:?}", msg); + } + + vanilla_proofs.push((*resp_vp).vanilla_proof.clone()); + fil_destroy_generate_single_vanilla_proof_response(resp_vp); + } + + let resp_wpwv2 = fil_generate_window_post_with_vanilla( + registered_proof_window_post, + randomness, + prover_id, + vanilla_proofs.as_ptr(), + vanilla_proofs.len(), + ); + + if (*resp_wpwv2).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_wpwv2).error_msg); + panic!("generate_window_post_with_vanilla failed: {:?}", msg); + } + + let resp_k2 = fil_verify_window_post( + randomness, + public_replicas.as_ptr(), + public_replicas.len(), + (*resp_wpwv2).proofs_ptr, + (*resp_wpwv2).proofs_len, + prover_id, + ); + + if (*resp_k2).status_code != FCPResponseStatus::FCPNoError { + let msg = c_str_to_rust_str((*resp_k2).error_msg); + panic!("verify_window_post failed: {:?}", msg); + } + + if !(*resp_k2).is_valid { + panic!("verify_window_post rejected the provided proof as invalid"); + } + fil_destroy_write_without_alignment_response(resp_a1); fil_destroy_write_with_alignment_response(resp_a2); fil_destroy_generate_data_commitment_response(resp_x); @@ -1721,11 +2261,17 @@ pub mod tests { fil_destroy_unseal_range_response(resp_e); fil_destroy_generate_winning_post_sector_challenge(resp_f); + fil_destroy_generate_fallback_sector_challenges_response(resp_sc); fil_destroy_generate_winning_post_response(resp_h); + fil_destroy_generate_winning_post_response(resp_wpwv); fil_destroy_verify_winning_post_response(resp_i); + fil_destroy_verify_winning_post_response(resp_di); + fil_destroy_generate_fallback_sector_challenges_response(resp_sc2); fil_destroy_generate_window_post_response(resp_j); + fil_destroy_generate_window_post_response(resp_wpwv2); fil_destroy_verify_window_post_response(resp_k); + fil_destroy_verify_window_post_response(resp_k2); c_str_to_rust_str(cache_dir_path_c_str); c_str_to_rust_str(staged_path_c_str); diff --git a/rust/src/proofs/types.rs b/rust/src/proofs/types.rs index 377d0401..11715930 100644 --- a/rust/src/proofs/types.rs +++ b/rust/src/proofs/types.rs @@ -169,6 +169,38 @@ impl Drop for fil_PoStProof { } } +#[repr(C)] +pub struct fil_VanillaProof { + pub proof_len: libc::size_t, + pub proof_ptr: *const u8, +} + +impl Clone for fil_VanillaProof { + fn clone(&self) -> Self { + let slice: &[u8] = unsafe { std::slice::from_raw_parts(self.proof_ptr, self.proof_len) }; + let cloned: Vec = slice.to_vec(); + debug_assert_eq!(self.proof_len, cloned.len()); + + let proof_ptr = cloned.as_ptr(); + std::mem::forget(cloned); + + fil_VanillaProof { + proof_len: self.proof_len, + proof_ptr, + } + } +} + +impl Drop for fil_VanillaProof { + fn drop(&mut self) { + // Note that this operation also does the equivalent of + // libc::free(self.proof_ptr as *mut libc::c_void); + let _ = unsafe { + Vec::from_raw_parts(self.proof_ptr as *mut u8, self.proof_len, self.proof_len) + }; + } +} + #[derive(Clone, Debug)] pub struct PoStProof { pub registered_proof: RegisteredPoStProof, @@ -226,6 +258,57 @@ impl Default for fil_GenerateWinningPoStSectorChallenge { code_and_message_impl!(fil_GenerateWinningPoStSectorChallenge); +#[repr(C)] +#[derive(DropStructMacro)] +pub struct fil_GenerateFallbackSectorChallengesResponse { + pub error_msg: *const libc::c_char, + pub status_code: FCPResponseStatus, + pub ids_ptr: *const u64, + pub ids_len: libc::size_t, + pub challenges_ptr: *const u64, + pub challenges_len: libc::size_t, + pub challenges_stride: libc::size_t, +} + +impl Default for fil_GenerateFallbackSectorChallengesResponse { + fn default() -> fil_GenerateFallbackSectorChallengesResponse { + fil_GenerateFallbackSectorChallengesResponse { + challenges_len: 0, + challenges_stride: 0, + challenges_ptr: ptr::null(), + ids_len: 0, + ids_ptr: ptr::null(), + error_msg: ptr::null(), + status_code: FCPResponseStatus::FCPNoError, + } + } +} + +code_and_message_impl!(fil_GenerateFallbackSectorChallengesResponse); + +#[repr(C)] +#[derive(DropStructMacro)] +pub struct fil_GenerateSingleVanillaProofResponse { + pub error_msg: *const libc::c_char, + pub vanilla_proof: fil_VanillaProof, + pub status_code: FCPResponseStatus, +} + +impl Default for fil_GenerateSingleVanillaProofResponse { + fn default() -> fil_GenerateSingleVanillaProofResponse { + fil_GenerateSingleVanillaProofResponse { + error_msg: ptr::null(), + vanilla_proof: fil_VanillaProof { + proof_len: 0, + proof_ptr: ptr::null(), + }, + status_code: FCPResponseStatus::FCPNoError, + } + } +} + +code_and_message_impl!(fil_GenerateSingleVanillaProofResponse); + #[repr(C)] #[derive(DropStructMacro)] pub struct fil_GenerateWinningPoStResponse {