Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
interface-test
Commits
bd2eb1aa
Commit
bd2eb1aa
authored
Aug 23, 2021
by
董子豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test aggregation
parent
77e3ef77
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
372 additions
and
175 deletions
+372
-175
seal_api.go
seal/seal_api.go
+26
-175
test_seal.go
seal/test_seal.go
+346
-0
No files found.
seal/seal_api.go
View file @
bd2eb1aa
...
@@ -3,18 +3,13 @@ package seal
...
@@ -3,18 +3,13 @@ package seal
import
(
import
(
"context"
"context"
"io"
"io"
"io/ioutil"
"os"
"os"
// "bytes"
// "bytes"
"math/rand"
saproof2
"github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
"golang.org/x/xerrors"
"golang.org/x/xerrors"
proof5
"github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
proof5
"github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
logging
"github.com/ipfs/go-log/v2"
logging
"github.com/ipfs/go-log/v2"
"github.com/mitchellh/go-homedir"
// commcid "github.com/filecoin-project/go-fil-commcid"
// commcid "github.com/filecoin-project/go-fil-commcid"
ffi
"github.com/filecoin-project/filecoin-ffi"
ffi
"github.com/filecoin-project/filecoin-ffi"
"fil_integrate/extern/sector-storage/ffiwrapper"
"fil_integrate/extern/sector-storage/ffiwrapper"
...
@@ -25,8 +20,6 @@ import(
...
@@ -25,8 +20,6 @@ import(
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/network"
"github.com/filecoin-project/go-state-types/network"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-cid"
"github.com/minio/blake2b-simd"
"fil_integrate/build"
)
)
var
log
=
logging
.
Logger
(
"sealing"
)
var
log
=
logging
.
Logger
(
"sealing"
)
...
@@ -35,9 +28,31 @@ var log = logging.Logger("sealing")
...
@@ -35,9 +28,31 @@ var log = logging.Logger("sealing")
//[has_pre][MetaLen1..MetaLen4][PieceLen1..PieceLen4]
//[has_pre][MetaLen1..MetaLen4][PieceLen1..PieceLen4]
const
TagLen
int
=
8
const
TagLen
int
=
8
const
arp
=
abi
.
RegisteredAggregationProof_SnarkPackV1
const
NewestNetworkVersion
=
network
.
Version13
const
NewestNetworkVersion
=
network
.
Version13
func
DefaultAggregationType
()
abi
.
RegisteredAggregationProof
{
return
arp
;
}
func
GetCommRFromDir
(
sb
*
ffiwrapper
.
Sealer
,
ctx
context
.
Context
,
sectorID
abi
.
SectorID
,
)
(
cid
.
Cid
,
error
)
{
return
sb
.
GetCommRFromDir
(
ctx
,
sectorID
)
}
func
PutCommRIntoDir
(
sb
*
ffiwrapper
.
Sealer
,
ctx
context
.
Context
,
sectorID
abi
.
SectorID
,
sealedCID
cid
.
Cid
,
)
error
{
return
sb
.
PutCommRIntoDir
(
ctx
,
sectorID
,
sealedCID
)
}
func
AddPiece
(
func
AddPiece
(
sb
*
ffiwrapper
.
Sealer
,
sb
*
ffiwrapper
.
Sealer
,
ctx
context
.
Context
,
ctx
context
.
Context
,
...
@@ -195,8 +210,8 @@ func AddPiece(
...
@@ -195,8 +210,8 @@ func AddPiece(
func
AggregateWindowPoStProofs
(
func
AggregateWindowPoStProofs
(
sb
*
ffiwrapper
.
Sealer
,
sb
*
ffiwrapper
.
Sealer
,
ctx
context
.
Context
,
ctx
context
.
Context
,
randomnesses
[]
abi
.
SealRandomness
,
aggregate
abi
.
RegisteredAggregationProof
,
aggregate
abi
.
RegisteredAggregationProof
,
randomnesses
[]
abi
.
PoStRandomness
,
windowPoStProofs
[]
proof5
.
PoStProof
,
windowPoStProofs
[]
proof5
.
PoStProof
,
sectorCountArr
[]
uint
,
sectorCountArr
[]
uint
,
)
([]
byte
,
error
)
{
)
([]
byte
,
error
)
{
...
@@ -224,7 +239,7 @@ func VerifyAggregateWindowPostProofs(
...
@@ -224,7 +239,7 @@ func VerifyAggregateWindowPostProofs(
aggregateType
abi
.
RegisteredAggregationProof
,
aggregateType
abi
.
RegisteredAggregationProof
,
miner
abi
.
ActorID
,
miner
abi
.
ActorID
,
aggregateProof
[]
byte
,
aggregateProof
[]
byte
,
randomnesses
[]
abi
.
Seal
Randomness
,
randomnesses
[]
abi
.
PoSt
Randomness
,
sealedSectors
[][]
proof5
.
SectorInfo
,
sealedSectors
[][]
proof5
.
SectorInfo
,
)
(
bool
,
error
)
{
)
(
bool
,
error
)
{
var
sectorInfos
[]
proof5
.
SectorInfo
var
sectorInfos
[]
proof5
.
SectorInfo
...
@@ -308,7 +323,7 @@ func GenProofForC2(
...
@@ -308,7 +323,7 @@ func GenProofForC2(
return
sb
.
SealCommit2
(
ctx
,
sid
,
c1Out
)
return
sb
.
SealCommit2
(
ctx
,
sid
,
c1Out
)
}
}
func
GenProofForWindowPo
s
t
(
func
GenProofForWindowPo
S
t
(
sb
*
ffiwrapper
.
Sealer
,
sb
*
ffiwrapper
.
Sealer
,
ctx
context
.
Context
,
ctx
context
.
Context
,
minerID
abi
.
ActorID
,
minerID
abi
.
ActorID
,
...
@@ -360,167 +375,3 @@ func UnsealedRange(
...
@@ -360,167 +375,3 @@ func UnsealedRange(
return
nil
return
nil
}
}
\ No newline at end of file
func
spt
(
ssize
abi
.
SectorSize
)
abi
.
RegisteredSealProof
{
spt
,
err
:=
build
.
SealProofTypeFromSectorSize
(
ssize
,
NewestNetworkVersion
)
if
err
!=
nil
{
panic
(
err
)
}
return
spt
}
func
TestSealAndUnseal
()
error
{
//********************need (sb,ctx,sid,sectorSize,file,seed,ticket,challenge)****************//
sdir
,
err
:=
homedir
.
Expand
(
"~/tmp"
)
if
err
!=
nil
{
return
err
}
err
=
os
.
MkdirAll
(
sdir
,
0775
)
//nolint:gosec
if
err
!=
nil
{
return
xerrors
.
Errorf
(
"creating sectorbuilder dir: %w"
,
err
)
}
tsdir
,
err
:=
ioutil
.
TempDir
(
sdir
,
"bench"
)
if
err
!=
nil
{
return
err
}
// defer func() {
// if err := os.RemoveAll(tsdir); err != nil {
// log.Warn("remove all: ", err)
// }
// }()
// TODO: pretty sure this isnt even needed?
if
err
:=
os
.
MkdirAll
(
tsdir
,
0775
);
err
!=
nil
{
return
err
}
sbfs
:=
&
basicfs
.
Provider
{
Root
:
tsdir
,
}
sb
,
err
:=
ffiwrapper
.
New
(
sbfs
)
if
err
!=
nil
{
return
err
}
ctx
:=
context
.
TODO
()
sectorSize
:=
abi
.
SectorSize
(
8
*
1024
*
1024
)
sid
:=
storage
.
SectorRef
{
ID
:
abi
.
SectorID
{
Miner
:
1000
,
Number
:
0
,
},
ProofType
:
spt
(
sectorSize
),
}
file
:=
rand
.
New
(
rand
.
NewSource
(
1587
))
seed
:=
[]
byte
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
255
}
trand
:=
blake2b
.
Sum256
([]
byte
(
"ticket-preimage"
))
ticket
:=
abi
.
SealRandomness
(
trand
[
:
])
var
challenge
[
32
]
byte
rand
.
Read
(
challenge
[
:
])
//ADD PIECES
var
existingPieceSizes
[]
abi
.
UnpaddedPieceSize
var
pieces
[]
abi
.
PieceInfo
var
sealedSectors
[]
saproof2
.
SectorInfo
piece
,
err
:=
AddPiece
(
sb
,
ctx
,
sid
,
existingPieceSizes
,
abi
.
PaddedPieceSize
(
sectorSize
/
2
)
.
Unpadded
(),
file
)
if
err
!=
nil
{
return
err
}
existingPieceSizes
=
append
(
existingPieceSizes
,
piece
.
Size
.
Unpadded
())
pieces
=
append
(
pieces
,
piece
)
piece
,
err
=
AddPiece
(
sb
,
ctx
,
sid
,
existingPieceSizes
,
abi
.
PaddedPieceSize
(
sectorSize
/
2
)
.
Unpadded
(),
file
)
if
err
!=
nil
{
return
err
}
existingPieceSizes
=
append
(
existingPieceSizes
,
piece
.
Size
.
Unpadded
())
pieces
=
append
(
pieces
,
piece
)
//SEAL
cids
,
proof1
,
c1o
,
err
:=
Sealed
(
sb
,
ctx
,
sid
,
seed
,
ticket
,
pieces
)
if
err
!=
nil
{
return
err
}
sealedSectors
=
append
(
sealedSectors
,
saproof2
.
SectorInfo
{
SealedCID
:
cids
.
Sealed
,
SectorNumber
:
sid
.
ID
.
Number
,
SealProof
:
sid
.
ProofType
,
})
proof2
,
err
:=
GenProofForC2
(
sb
,
ctx
,
sid
,
c1o
)
if
err
!=
nil
{
return
err
}
ok
,
err
:=
CheckPieceAndDataRoot
(
sid
,
cids
.
Unsealed
,
pieces
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
return
xerrors
.
Errorf
(
"commd and pieces info don't match"
)
}
//verify proof
svi1
:=
saproof2
.
SealVerifyInfo
{
SectorID
:
sid
.
ID
,
SealedCID
:
cids
.
Sealed
,
SealProof
:
sid
.
ProofType
,
Proof
:
proof1
,
DealIDs
:
nil
,
Randomness
:
ticket
,
InteractiveRandomness
:
seed
,
UnsealedCID
:
cids
.
Unsealed
,
}
svi2
:=
saproof2
.
SealVerifyInfo
{
SectorID
:
sid
.
ID
,
SealedCID
:
cids
.
Sealed
,
SealProof
:
sid
.
ProofType
,
Proof
:
proof2
,
DealIDs
:
nil
,
Randomness
:
ticket
,
InteractiveRandomness
:
seed
,
UnsealedCID
:
cids
.
Unsealed
,
}
ok
,
err
=
ffiwrapper
.
ProofVerifier
.
VerifySeal
(
svi1
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
return
xerrors
.
Errorf
(
"porep proof for sector %d was invalid"
,
sid
.
ID
.
Number
)
}
ok
,
err
=
ffiwrapper
.
ProofVerifier
.
VerifySeal
(
svi2
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
return
xerrors
.
Errorf
(
"porep proof for sector %d was invalid"
,
sid
.
ID
.
Number
)
}
proof
,
_
,
err
:=
GenProofForWindowPost
(
sb
,
ctx
,
sid
.
ID
.
Miner
,
sealedSectors
,
challenge
[
:
])
wpvi
:=
saproof2
.
WindowPoStVerifyInfo
{
Randomness
:
challenge
[
:
],
Proofs
:
proof
,
ChallengedSectors
:
sealedSectors
,
Prover
:
sid
.
ID
.
Miner
,
}
ok
,
err
=
ffiwrapper
.
ProofVerifier
.
VerifyWindowPoSt
(
ctx
,
wpvi
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
log
.
Error
(
"window post verification failed"
)
}
return
nil
}
\ No newline at end of file
seal/test_seal.go
0 → 100644
View file @
bd2eb1aa
package
seal
import
(
"context"
"fmt"
"io/ioutil"
"os"
"math/rand"
"time"
"golang.org/x/xerrors"
"github.com/mitchellh/go-homedir"
"github.com/minio/blake2b-simd"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-storage/storage"
saproof2
"github.com/filecoin-project/specs-actors/v2/actors/runtime/proof"
proof5
"github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
"fil_integrate/build"
"fil_integrate/extern/sector-storage/ffiwrapper"
"fil_integrate/extern/sector-storage/ffiwrapper/basicfs"
)
func
TestAggregateWindowPoSt
(
sectorSize
abi
.
SectorSize
,
numSectors
int
,
numAggregate
int
,
)
error
{
sdir
,
err
:=
homedir
.
Expand
(
"~/tmp"
)
if
err
!=
nil
{
return
err
}
err
=
os
.
MkdirAll
(
sdir
,
0775
)
//nolint:gosec
if
err
!=
nil
{
return
xerrors
.
Errorf
(
"creating sectorbuilder dir: %w"
,
err
)
}
tsdir
,
err
:=
ioutil
.
TempDir
(
sdir
,
"bench"
)
if
err
!=
nil
{
return
err
}
// defer func() {
// if err := os.RemoveAll(tsdir); err != nil {
// log.Warn("remove all: ", err)
// }
// }()
// TODO: pretty sure this isnt even needed?
if
err
:=
os
.
MkdirAll
(
tsdir
,
0775
);
err
!=
nil
{
return
err
}
sbfs
:=
&
basicfs
.
Provider
{
Root
:
tsdir
,
}
sb
,
err
:=
ffiwrapper
.
New
(
sbfs
)
if
err
!=
nil
{
return
err
}
ctx
:=
context
.
TODO
()
file
:=
rand
.
New
(
rand
.
NewSource
(
1587
))
trand
:=
blake2b
.
Sum256
([]
byte
(
"ticket-preimage"
))
ticket
:=
abi
.
SealRandomness
(
trand
[
:
])
var
challenge
[
32
]
byte
rand
.
Read
(
challenge
[
:
])
var
randomnesses
[]
abi
.
PoStRandomness
var
sealedSectorsinfo
[][]
saproof2
.
SectorInfo
var
sectorCount
[]
uint
var
proofs
[]
proof5
.
PoStProof
sealProofType
:=
spt
(
sectorSize
)
start
:=
time
.
Now
()
for
i
:=
0
;
i
<
numAggregate
;
i
++
{
for
j
:=
0
;
j
<
numSectors
;
j
++
{
var
pieces
[]
abi
.
PieceInfo
sid
:=
storage
.
SectorRef
{
ID
:
abi
.
SectorID
{
Miner
:
1000
,
Number
:
abi
.
SectorNumber
(
i
*
numSectors
+
j
),
},
ProofType
:
sealProofType
,
}
piece
,
err
:=
AddPiece
(
sb
,
ctx
,
sid
,
nil
,
abi
.
PaddedPieceSize
(
sectorSize
)
.
Unpadded
(),
file
)
if
err
!=
nil
{
return
err
}
pieces
=
append
(
pieces
,
piece
)
// log.Infof("[%d] Running replication(1)...", sid.ID.Number)
pc1out
,
err
:=
sb
.
SealPreCommit1
(
ctx
,
sid
,
ticket
,
pieces
)
if
err
!=
nil
{
return
xerrors
.
Errorf
(
"commit: %w"
,
err
)
}
// log.Infof("[%d] Running replication(2)...", sid.ID.Number)
cids
,
err
:=
sb
.
SealPreCommit2
(
ctx
,
sid
,
pc1out
)
if
err
!=
nil
{
return
xerrors
.
Errorf
(
"commit: %w"
,
err
)
}
comm_r
:=
cids
.
Sealed
PutCommRIntoDir
(
sb
,
ctx
,
sid
.
ID
,
comm_r
)
}
}
log
.
Infof
(
"Sealed [%d] Sectors Done"
,
numSectors
*
numAggregate
)
sealed
:=
time
.
Now
()
for
i
:=
0
;
i
<
numAggregate
;
i
++
{
var
sealedSectors
[]
saproof2
.
SectorInfo
for
j
:=
0
;
j
<
numSectors
;
j
++
{
sectorID
:=
abi
.
SectorID
{
Miner
:
1000
,
Number
:
abi
.
SectorNumber
(
i
*
numSectors
+
j
),
}
comm_r
,
err
:=
GetCommRFromDir
(
sb
,
ctx
,
sectorID
)
if
err
!=
nil
{
return
err
}
sealedSectors
=
append
(
sealedSectors
,
saproof2
.
SectorInfo
{
SealedCID
:
comm_r
,
SectorNumber
:
sectorID
.
Number
,
SealProof
:
sealProofType
,
})
}
sealedSectorsinfo
=
append
(
sealedSectorsinfo
,
sealedSectors
)
}
log
.
Infof
(
"Read [%d] Commitment Rplication Done"
,
numSectors
*
numAggregate
)
loadCommr
:=
time
.
Now
()
for
i
:=
0
;
i
<
numAggregate
;
i
++
{
log
.
Infof
(
"[%d] Generating Window-Post"
,
i
)
proof
,
_
,
err
:=
GenProofForWindowPoSt
(
sb
,
ctx
,
1000
,
sealedSectorsinfo
[
i
],
challenge
[
:
])
if
err
!=
nil
{
return
err
}
proofs
=
append
(
proofs
,
proof
...
)
randomnesses
=
append
(
randomnesses
,
challenge
[
:
])
sectorCount
=
append
(
sectorCount
,
uint
(
numSectors
))
}
log
.
Infof
(
"Generate [%d] Window-PoSt Done"
,
numAggregate
)
genWindowPoSt
:=
time
.
Now
()
aggregateProof
,
err
:=
AggregateWindowPoStProofs
(
sb
,
ctx
,
DefaultAggregationType
(),
randomnesses
,
proofs
,
sectorCount
)
if
err
!=
nil
{
return
err
}
aggregateProofs
:=
time
.
Now
()
PoStType
,
_
:=
sealProofType
.
RegisteredWindowPoStProof
()
ok
,
err
:=
VerifyAggregateWindowPostProofs
(
ctx
,
PoStType
,
DefaultAggregationType
(),
abi
.
ActorID
(
1000
),
aggregateProof
,
randomnesses
,
sealedSectorsinfo
,
)
if
err
!=
nil
{
return
err
}
if
ok
{
fmt
.
Println
(
"Aggregate proof is true"
)
}
else
{
fmt
.
Println
(
"Aggregate proof is false"
)
}
verifyProofs
:=
time
.
Now
()
fmt
.
Printf
(
"Seal %d sectors using %s
\n
"
,
numSectors
*
numAggregate
,
sealed
.
Sub
(
start
))
fmt
.
Printf
(
"Read %d comm_r using %s
\n
"
,
numAggregate
*
numSectors
,
loadCommr
.
Sub
(
sealed
))
fmt
.
Printf
(
"Generate %d window-post using %s
\n
"
,
numAggregate
,
genWindowPoSt
.
Sub
(
loadCommr
))
fmt
.
Printf
(
"Aggregate %d window-post Proofs using %s
\n
"
,
numAggregate
,
aggregateProofs
.
Sub
(
genWindowPoSt
))
fmt
.
Printf
(
"Verify Proofs using %s
\n
"
,
verifyProofs
.
Sub
(
aggregateProofs
))
return
nil
}
func
TestSealAndUnseal
()
error
{
//********************need (sb,ctx,sid,sectorSize,file,seed,ticket,challenge)****************//
sdir
,
err
:=
homedir
.
Expand
(
"~/tmp"
)
if
err
!=
nil
{
return
err
}
err
=
os
.
MkdirAll
(
sdir
,
0775
)
//nolint:gosec
if
err
!=
nil
{
return
xerrors
.
Errorf
(
"creating sectorbuilder dir: %w"
,
err
)
}
tsdir
,
err
:=
ioutil
.
TempDir
(
sdir
,
"bench"
)
if
err
!=
nil
{
return
err
}
// defer func() {
// if err := os.RemoveAll(tsdir); err != nil {
// log.Warn("remove all: ", err)
// }
// }()
// TODO: pretty sure this isnt even needed?
if
err
:=
os
.
MkdirAll
(
tsdir
,
0775
);
err
!=
nil
{
return
err
}
sbfs
:=
&
basicfs
.
Provider
{
Root
:
tsdir
,
}
sb
,
err
:=
ffiwrapper
.
New
(
sbfs
)
if
err
!=
nil
{
return
err
}
ctx
:=
context
.
TODO
()
sectorSize
:=
abi
.
SectorSize
(
8
*
1024
*
1024
)
sid
:=
storage
.
SectorRef
{
ID
:
abi
.
SectorID
{
Miner
:
1000
,
Number
:
0
,
},
ProofType
:
spt
(
sectorSize
),
}
file
:=
rand
.
New
(
rand
.
NewSource
(
1587
))
seed
:=
[]
byte
{
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
,
11
,
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
255
}
trand
:=
blake2b
.
Sum256
([]
byte
(
"ticket-preimage"
))
ticket
:=
abi
.
SealRandomness
(
trand
[
:
])
var
challenge
[
32
]
byte
rand
.
Read
(
challenge
[
:
])
//ADD PIECES
var
existingPieceSizes
[]
abi
.
UnpaddedPieceSize
var
pieces
[]
abi
.
PieceInfo
var
sealedSectors
[]
saproof2
.
SectorInfo
piece
,
err
:=
AddPiece
(
sb
,
ctx
,
sid
,
existingPieceSizes
,
abi
.
PaddedPieceSize
(
sectorSize
/
2
)
.
Unpadded
(),
file
)
if
err
!=
nil
{
return
err
}
existingPieceSizes
=
append
(
existingPieceSizes
,
piece
.
Size
.
Unpadded
())
pieces
=
append
(
pieces
,
piece
)
piece
,
err
=
AddPiece
(
sb
,
ctx
,
sid
,
existingPieceSizes
,
abi
.
PaddedPieceSize
(
sectorSize
/
2
)
.
Unpadded
(),
file
)
if
err
!=
nil
{
return
err
}
existingPieceSizes
=
append
(
existingPieceSizes
,
piece
.
Size
.
Unpadded
())
pieces
=
append
(
pieces
,
piece
)
//SEAL
cids
,
proof1
,
c1o
,
err
:=
Sealed
(
sb
,
ctx
,
sid
,
seed
,
ticket
,
pieces
)
if
err
!=
nil
{
return
err
}
sealedSectors
=
append
(
sealedSectors
,
saproof2
.
SectorInfo
{
SealedCID
:
cids
.
Sealed
,
SectorNumber
:
sid
.
ID
.
Number
,
SealProof
:
sid
.
ProofType
,
})
proof2
,
err
:=
GenProofForC2
(
sb
,
ctx
,
sid
,
c1o
)
if
err
!=
nil
{
return
err
}
ok
,
err
:=
CheckPieceAndDataRoot
(
sid
,
cids
.
Unsealed
,
pieces
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
return
xerrors
.
Errorf
(
"commd and pieces info don't match"
)
}
//verify proof
svi1
:=
saproof2
.
SealVerifyInfo
{
SectorID
:
sid
.
ID
,
SealedCID
:
cids
.
Sealed
,
SealProof
:
sid
.
ProofType
,
Proof
:
proof1
,
DealIDs
:
nil
,
Randomness
:
ticket
,
InteractiveRandomness
:
seed
,
UnsealedCID
:
cids
.
Unsealed
,
}
svi2
:=
saproof2
.
SealVerifyInfo
{
SectorID
:
sid
.
ID
,
SealedCID
:
cids
.
Sealed
,
SealProof
:
sid
.
ProofType
,
Proof
:
proof2
,
DealIDs
:
nil
,
Randomness
:
ticket
,
InteractiveRandomness
:
seed
,
UnsealedCID
:
cids
.
Unsealed
,
}
ok
,
err
=
ffiwrapper
.
ProofVerifier
.
VerifySeal
(
svi1
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
return
xerrors
.
Errorf
(
"porep proof for sector %d was invalid"
,
sid
.
ID
.
Number
)
}
ok
,
err
=
ffiwrapper
.
ProofVerifier
.
VerifySeal
(
svi2
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
return
xerrors
.
Errorf
(
"porep proof for sector %d was invalid"
,
sid
.
ID
.
Number
)
}
proof
,
_
,
err
:=
GenProofForWindowPoSt
(
sb
,
ctx
,
sid
.
ID
.
Miner
,
sealedSectors
,
challenge
[
:
])
wpvi
:=
saproof2
.
WindowPoStVerifyInfo
{
Randomness
:
challenge
[
:
],
Proofs
:
proof
,
ChallengedSectors
:
sealedSectors
,
Prover
:
sid
.
ID
.
Miner
,
}
ok
,
err
=
ffiwrapper
.
ProofVerifier
.
VerifyWindowPoSt
(
ctx
,
wpvi
)
if
err
!=
nil
{
return
err
}
if
!
ok
{
log
.
Error
(
"window post verification failed"
)
}
return
nil
}
func
spt
(
ssize
abi
.
SectorSize
)
abi
.
RegisteredSealProof
{
spt
,
err
:=
build
.
SealProofTypeFromSectorSize
(
ssize
,
NewestNetworkVersion
)
if
err
!=
nil
{
panic
(
err
)
}
return
spt
}
\ No newline at end of file
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