update filecoin-ffi to v18 params

This commit is contained in:
Łukasz Magiera 2019-11-27 16:00:04 +01:00
parent d2412f4f00
commit 1ccfe7d8f7
3 changed files with 22 additions and 6 deletions

View File

@ -19,6 +19,20 @@ var SectorSizes = []uint64{
1 << 30, 1 << 30,
} }
const nodeSize = 32
// sector size -> winSzNodes
//
// https://github.com/filecoin-project/rust-fil-proofs/blob/master/filecoin-proofs/src/constants.rs#L16-L20
var WindowSizeNodes = map[uint64]uint32{
1 << 10: 512 / nodeSize,
16 << 20: (4 << 20) / nodeSize,
256 << 20: (64 << 20) / nodeSize,
1 << 30: (128 << 20) / nodeSize,
}
func SupportedSectorSize(ssize uint64) bool { func SupportedSectorSize(ssize uint64) bool {
for _, ss := range SectorSizes { for _, ss := range SectorSizes {
if ssize == ss { if ssize == ss {

2
extern/filecoin-ffi vendored

@ -1 +1 @@
Subproject commit 3de4c1567da6cea906a95b87a179c85dbec16c6d Subproject commit dbe28c13b59755d7c004f33db9f71eee0e93b5be

View File

@ -222,6 +222,7 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece
rspco, err := sectorbuilder.SealPreCommit( rspco, err := sectorbuilder.SealPreCommit(
sb.ssize, sb.ssize,
build.WindowSizeNodes[sb.ssize],
PoRepProofPartitions, PoRepProofPartitions,
cacheDir, cacheDir,
stagedPath, stagedPath,
@ -249,6 +250,7 @@ func (sb *SectorBuilder) SealCommit(sectorID uint64, ticket SealTicket, seed Sea
proof, err = sectorbuilder.SealCommit( proof, err = sectorbuilder.SealCommit(
sb.ssize, sb.ssize,
build.WindowSizeNodes[sb.ssize],
PoRepProofPartitions, PoRepProofPartitions,
cacheDir, cacheDir,
sectorID, sectorID,
@ -290,7 +292,7 @@ func (sb *SectorBuilder) ComputeElectionPoSt(sectorInfo SortedPublicSectorInfo,
} }
proverID := addressToProverID(sb.Miner) proverID := addressToProverID(sb.Miner)
return sectorbuilder.GeneratePoSt(sb.ssize, proverID, privsects, cseed, winners) return sectorbuilder.GeneratePoSt(sb.ssize, build.WindowSizeNodes[sb.ssize], proverID, privsects, cseed, winners)
} }
func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]EPostCandidate, error) { func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorInfo, challengeSeed [CommLen]byte, faults []uint64) ([]EPostCandidate, error) {
@ -302,7 +304,7 @@ func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorIn
challengeCount := challangeCount(uint64(len(sectorInfo.Values()))) challengeCount := challangeCount(uint64(len(sectorInfo.Values())))
proverID := addressToProverID(sb.Miner) proverID := addressToProverID(sb.Miner)
return sectorbuilder.GenerateCandidates(sb.ssize, proverID, challengeSeed, challengeCount, privsectors) return sectorbuilder.GenerateCandidates(sb.ssize, build.WindowSizeNodes[sb.ssize], proverID, challengeSeed, challengeCount, privsectors)
} }
func (sb *SectorBuilder) pubSectorToPriv(sectorInfo SortedPublicSectorInfo) (SortedPrivateSectorInfo, error) { func (sb *SectorBuilder) pubSectorToPriv(sectorInfo SortedPublicSectorInfo) (SortedPrivateSectorInfo, error) {
@ -342,7 +344,7 @@ func VerifySeal(sectorSize uint64, commR, commD []byte, proverID address.Address
copy(seeda[:], seed) copy(seeda[:], seed)
proverIDa := addressToProverID(proverID) proverIDa := addressToProverID(proverID)
return sectorbuilder.VerifySeal(sectorSize, commRa, commDa, proverIDa, ticketa, seeda, sectorID, proof) return sectorbuilder.VerifySeal(sectorSize, build.WindowSizeNodes[sectorSize], commRa, commDa, proverIDa, ticketa, seeda, sectorID, proof)
} }
func NewSortedPrivateSectorInfo(sectors []sectorbuilder.PrivateSectorInfo) SortedPrivateSectorInfo { func NewSortedPrivateSectorInfo(sectors []sectorbuilder.PrivateSectorInfo) SortedPrivateSectorInfo {
@ -362,7 +364,7 @@ func VerifyPost(ctx context.Context, sectorSize uint64, sectorInfo SortedPublicS
_, span := trace.StartSpan(ctx, "VerifyPoSt") _, span := trace.StartSpan(ctx, "VerifyPoSt")
defer span.End() defer span.End()
prover := addressToProverID(proverID) prover := addressToProverID(proverID)
return sectorbuilder.VerifyPoSt(sectorSize, sectorInfo, challengeSeeda, challengeCount, proof, winners, prover) return sectorbuilder.VerifyPoSt(sectorSize, build.WindowSizeNodes[sectorSize], sectorInfo, challengeSeeda, challengeCount, proof, winners, prover)
} }
func GeneratePieceCommitment(piece io.Reader, pieceSize uint64) (commP [CommLen]byte, err error) { func GeneratePieceCommitment(piece io.Reader, pieceSize uint64) (commP [CommLen]byte, err error) {
@ -380,7 +382,7 @@ func GeneratePieceCommitment(piece io.Reader, pieceSize uint64) (commP [CommLen]
} }
func GenerateDataCommitment(ssize uint64, pieces []PublicPieceInfo) ([CommLen]byte, error) { func GenerateDataCommitment(ssize uint64, pieces []PublicPieceInfo) ([CommLen]byte, error) {
return sectorbuilder.GenerateDataCommitment(ssize, pieces) return sectorbuilder.GenerateDataCommitment(ssize, build.WindowSizeNodes[ssize], pieces)
} }
func challangeCount(sectors uint64) uint64 { func challangeCount(sectors uint64) uint64 {