Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-sectorbuilder
Commits
4a500030
Unverified
Commit
4a500030
authored
Jan 07, 2020
by
Jakub Sztandera
Committed by
GitHub
Jan 07, 2020
Browse files
Merge pull request #64 from filecoin-project/fix/challange-count
Fix challange counts
parents
0cbb2c48
3361d30e
Changes
3
Hide whitespace changes
Inline
Side-by-side
params_shared.go
View file @
4a500030
...
@@ -9,10 +9,10 @@ const SectorChallengeRatioDiv = 25
...
@@ -9,10 +9,10 @@ const SectorChallengeRatioDiv = 25
const
MaxFallbackPostChallengeCount
=
10
const
MaxFallbackPostChallengeCount
=
10
// extracted from lotus/chain/types/blockheader
// extracted from lotus/chain/types/blockheader
func
ElectionPostChallengeCount
(
sectors
uint64
,
faults
int
)
uint64
{
func
ElectionPostChallengeCount
(
sectors
uint64
,
faults
u
int
64
)
uint64
{
if
sectors
==
0
{
if
sectors
-
faults
==
0
{
return
0
return
0
}
}
// ceil(sectors / SectorChallengeRatioDiv)
// ceil(sectors / SectorChallengeRatioDiv)
return
(
sectors
-
uint64
(
faults
)
-
1
)
/
SectorChallengeRatioDiv
+
1
return
(
sectors
-
faults
-
1
)
/
SectorChallengeRatioDiv
+
1
}
}
sectorbuilder.go
View file @
4a500030
...
@@ -636,7 +636,7 @@ func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorIn
...
@@ -636,7 +636,7 @@ func (sb *SectorBuilder) GenerateEPostCandidates(sectorInfo SortedPublicSectorIn
return
nil
,
err
return
nil
,
err
}
}
challengeCount
:=
ElectionPostChallengeCount
(
uint64
(
len
(
sectorInfo
.
Values
())),
len
(
faults
))
challengeCount
:=
ElectionPostChallengeCount
(
uint64
(
len
(
sectorInfo
.
Values
())),
uint64
(
len
(
faults
))
)
proverID
:=
addressToProverID
(
sb
.
Miner
)
proverID
:=
addressToProverID
(
sb
.
Miner
)
return
sectorbuilder
.
GenerateCandidates
(
sb
.
ssize
,
proverID
,
challengeSeed
,
challengeCount
,
privsectors
)
return
sectorbuilder
.
GenerateCandidates
(
sb
.
ssize
,
proverID
,
challengeSeed
,
challengeCount
,
privsectors
)
...
@@ -680,7 +680,7 @@ func (sb *SectorBuilder) GenerateFallbackPoSt(sectorInfo SortedPublicSectorInfo,
...
@@ -680,7 +680,7 @@ func (sb *SectorBuilder) GenerateFallbackPoSt(sectorInfo SortedPublicSectorInfo,
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
challengeCount
:=
fallbackPostChallengeCount
(
uint64
(
len
(
sectorInfo
.
Values
())),
len
(
faults
))
challengeCount
:=
fallbackPostChallengeCount
(
uint64
(
len
(
sectorInfo
.
Values
())),
uint64
(
len
(
faults
))
)
proverID
:=
addressToProverID
(
sb
.
Miner
)
proverID
:=
addressToProverID
(
sb
.
Miner
)
candidates
,
err
:=
sectorbuilder
.
GenerateCandidates
(
sb
.
ssize
,
proverID
,
challengeSeed
,
challengeCount
,
privsectors
)
candidates
,
err
:=
sectorbuilder
.
GenerateCandidates
(
sb
.
ssize
,
proverID
,
challengeSeed
,
challengeCount
,
privsectors
)
...
@@ -696,7 +696,7 @@ func (sb *SectorBuilder) Stop() {
...
@@ -696,7 +696,7 @@ func (sb *SectorBuilder) Stop() {
close
(
sb
.
stopping
)
close
(
sb
.
stopping
)
}
}
func
fallbackPostChallengeCount
(
sectors
uint64
,
faults
int
)
uint64
{
func
fallbackPostChallengeCount
(
sectors
uint64
,
faults
u
int
64
)
uint64
{
challengeCount
:=
ElectionPostChallengeCount
(
sectors
,
faults
)
challengeCount
:=
ElectionPostChallengeCount
(
sectors
,
faults
)
if
challengeCount
>
MaxFallbackPostChallengeCount
{
if
challengeCount
>
MaxFallbackPostChallengeCount
{
return
MaxFallbackPostChallengeCount
return
MaxFallbackPostChallengeCount
...
...
simple.go
View file @
4a500030
...
@@ -40,7 +40,7 @@ func VerifyElectionPost(ctx context.Context, sectorSize uint64, sectorInfo Sorte
...
@@ -40,7 +40,7 @@ func VerifyElectionPost(ctx context.Context, sectorSize uint64, sectorInfo Sorte
return
verifyPost
(
ctx
,
sectorSize
,
sectorInfo
,
challengeCount
,
challengeSeed
,
proof
,
candidates
,
proverID
)
return
verifyPost
(
ctx
,
sectorSize
,
sectorInfo
,
challengeCount
,
challengeSeed
,
proof
,
candidates
,
proverID
)
}
}
func
VerifyFallbackPost
(
ctx
context
.
Context
,
sectorSize
uint64
,
sectorInfo
SortedPublicSectorInfo
,
challengeSeed
[]
byte
,
proof
[]
byte
,
candidates
[]
EPostCandidate
,
proverID
address
.
Address
,
faults
int
)
(
bool
,
error
)
{
func
VerifyFallbackPost
(
ctx
context
.
Context
,
sectorSize
uint64
,
sectorInfo
SortedPublicSectorInfo
,
challengeSeed
[]
byte
,
proof
[]
byte
,
candidates
[]
EPostCandidate
,
proverID
address
.
Address
,
faults
u
int
64
)
(
bool
,
error
)
{
challengeCount
:=
fallbackPostChallengeCount
(
uint64
(
len
(
sectorInfo
.
Values
())),
faults
)
challengeCount
:=
fallbackPostChallengeCount
(
uint64
(
len
(
sectorInfo
.
Values
())),
faults
)
return
verifyPost
(
ctx
,
sectorSize
,
sectorInfo
,
challengeCount
,
challengeSeed
,
proof
,
candidates
,
proverID
)
return
verifyPost
(
ctx
,
sectorSize
,
sectorInfo
,
challengeCount
,
challengeSeed
,
proof
,
candidates
,
proverID
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment