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
f015e2ea
Commit
f015e2ea
authored
Oct 09, 2021
by
董子豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify rust-ffi
parent
c6ce771b
Changes
19
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
646 additions
and
598 deletions
+646
-598
pieces.go
build/pieces/pieces.go
+6
-6
proof.go
build/proof/proof.go
+45
-45
size_str.go
build/size_str.go
+22
-22
storage.go
build/storage/storage.go
+17
-17
util.go
build/util.go
+148
-148
main.go
cmd/bench/main.go
+21
-22
distributed.go
extern/filecoin-ffi/distributed.go
+6
-8
cgo_helpers.go
extern/filecoin-ffi/generated/cgo_helpers.go
+5
-8
generated.go
extern/filecoin-ffi/generated/generated.go
+4
-7
types.go
extern/filecoin-ffi/generated/types.go
+1
-2
proofs.go
extern/filecoin-ffi/proofs.go
+55
-21
api.rs
extern/filecoin-ffi/rust/src/proofs/api.rs
+60
-44
types.rs
extern/filecoin-ffi/rust/src/proofs/types.rs
+12
-4
post.rs
extern/rust-filecoin-proofs-api/src/post.rs
+12
-12
go.mod
go.mod
+32
-32
fs.go
seal/basicfs/fs.go
+1
-1
seal_api.go
seal/seal_api.go
+115
-114
test.go
seal/test.go
+71
-72
type.go
seal/type.go
+13
-13
No files found.
build/pieces/pieces.go
View file @
f015e2ea
package
pieces
import
(
"math/bits"
"github.com/minio/sha256-simd"
"math/bits"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-state-types/abi"
"fil_integrate/build/fr32"
"github.com/filecoin-project/go-state-types/abi"
)
const
NODE_SIZE
=
32
...
...
@@ -91,12 +91,12 @@ func MerkleTreeLoop(D []byte) ([]byte, error) {
h
:=
sha256
.
New
()
// write left child
trim_to_fr32
(
D
[
index
:
index
+
32
])
h
.
Write
(
D
[
index
:
index
+
32
])
trim_to_fr32
(
D
[
index
:
index
+
32
])
h
.
Write
(
D
[
index
:
index
+
32
])
index
+=
lenth
// write right child
trim_to_fr32
(
D
[
index
:
index
+
32
])
h
.
Write
(
D
[
index
:
index
+
32
])
trim_to_fr32
(
D
[
index
:
index
+
32
])
h
.
Write
(
D
[
index
:
index
+
32
])
index
+=
lenth
res
:=
h
.
Sum
(
nil
)
...
...
build/proof/proof.go
View file @
f015e2ea
package
proof
import
(
"github.com/ipfs/go-cid"
import
(
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
)
type
SectorInfo
struct
{
...
...
@@ -58,15 +58,15 @@ type WinningPoStVerifyInfo struct {
type
WindowPoStVerifyInfo
struct
{
Randomness
abi
.
PoStRandomness
Proofs
[]
PoStProof
Proof
PoStProof
ChallengedSectors
[]
SectorInfo
Prover
abi
.
ActorID
// used to derive 32-byte prover ID
}
type
AggregateWindowPostInfos
struct
{
type
AggregateWindowPostInfos
struct
{
PoStType
abi
.
RegisteredPoStProof
AggregateType
abi
.
RegisteredAggregationProof
AggregateProof
Proof
AggregateProof
PoSt
Proof
ChallengedSectors
[]
SectorInfo
SectorCount
[]
uint
Randomnesses
[]
abi
.
PoStRandomness
...
...
build/size_str.go
View file @
f015e2ea
build/storage/storage.go
View file @
f015e2ea
package
storage
import
(
"io"
"bytes"
"encoding/binary"
"io"
"golang.org/x/xerrors"
...
...
@@ -54,7 +54,7 @@ type DecodedData struct {
HashData
[]
byte
}
func
(
data
*
DecodedData
)
Serialize
()
([]
byte
,
error
)
{
func
(
data
*
DecodedData
)
Serialize
()
([]
byte
,
error
)
{
var
buf
[]
byte
MetaLen
:=
uint32
(
len
(
data
.
Data
))
CommLen
:=
uint32
(
len
(
data
.
HashData
))
...
...
@@ -62,22 +62,22 @@ func (data *DecodedData)Serialize() ([]byte, error) {
if
MetaLen
>
0
{
return
nil
,
xerrors
.
Errorf
(
""
)
}
buf
=
make
([]
byte
,
nextUppandedPowerOfTwo
(
40
+
CommLen
))
buf
=
make
([]
byte
,
nextUppandedPowerOfTwo
(
40
+
CommLen
))
binary
.
BigEndian
.
PutUint32
(
buf
[
:
4
],
0x80000000
)
binary
.
BigEndian
.
PutUint32
(
buf
[
4
:
8
],
CommLen
)
copy
(
buf
[
8
:
40
],
data
.
PreHash
[
:
])
copy
(
buf
[
40
:
],
data
.
HashData
[
:
])
}
else
{
buf
=
make
([]
byte
,
nextUppandedPowerOfTwo
(
8
+
MetaLen
+
CommLen
))
buf
=
make
([]
byte
,
nextUppandedPowerOfTwo
(
8
+
MetaLen
+
CommLen
))
binary
.
BigEndian
.
PutUint32
(
buf
[
:
4
],
MetaLen
)
binary
.
BigEndian
.
PutUint32
(
buf
[
4
:
8
],
CommLen
)
copy
(
buf
[
8
:
8
+
MetaLen
],
data
.
Data
[
:
])
copy
(
buf
[
8
+
MetaLen
:
],
data
.
HashData
[
:
])
copy
(
buf
[
8
:
8
+
MetaLen
],
data
.
Data
[
:
])
copy
(
buf
[
8
+
MetaLen
:
],
data
.
HashData
[
:
])
}
return
buf
,
nil
}
func
(
data
*
DecodedData
)
Deserialize
(
buf
[]
byte
)
error
{
func
(
data
*
DecodedData
)
Deserialize
(
buf
[]
byte
)
error
{
var
err
error
var
MetaLen
uint32
var
CommLen
uint32
...
...
@@ -92,7 +92,7 @@ func (data *DecodedData)Deserialize(buf []byte) error {
data
.
HasPre
=
(
MetaLen
>>
31
)
!=
0
MetaLen
=
MetaLen
&
0x7fffffff
rbuf
:=
buf
[
8
:
read
]
if
data
.
HasPre
{
if
data
.
HasPre
{
if
read
<
40
{
return
xerrors
.
Errorf
(
"can't read the pre-piece-hash"
)
}
...
...
@@ -102,7 +102,7 @@ func (data *DecodedData)Deserialize(buf []byte) error {
if
uint32
(
len
(
rbuf
))
<=
MetaLen
{
data
.
Data
=
rbuf
[
:
]
}
else
if
uint32
(
len
(
rbuf
))
<=
CommLen
+
MetaLen
{
}
else
if
uint32
(
len
(
rbuf
))
<=
CommLen
+
MetaLen
{
data
.
Data
=
rbuf
[
:
MetaLen
]
data
.
PieceHash
,
err
=
to32ByteHash
(
rbuf
[
MetaLen
:
])
if
err
!=
nil
{
...
...
@@ -110,7 +110,7 @@ func (data *DecodedData)Deserialize(buf []byte) error {
}
}
else
{
data
.
Data
=
rbuf
[
:
MetaLen
]
data
.
PieceHash
,
err
=
to32ByteHash
(
rbuf
[
MetaLen
:
CommLen
+
MetaLen
])
data
.
PieceHash
,
err
=
to32ByteHash
(
rbuf
[
MetaLen
:
CommLen
+
MetaLen
])
if
err
!=
nil
{
return
err
}
...
...
@@ -119,7 +119,7 @@ func (data *DecodedData)Deserialize(buf []byte) error {
}
func
to32ByteHash
(
in
[]
byte
)
([]
Hash
,
error
)
{
if
len
(
in
)
%
32
!=
0
{
if
len
(
in
)
%
32
!=
0
{
return
nil
,
xerrors
.
Errorf
(
"lenth of the hash arr must be multiple of 32"
)
}
hash
:=
make
([]
Hash
,
len
(
in
)
/
32
)
...
...
@@ -132,7 +132,7 @@ func to32ByteHash(in []byte) ([]Hash, error) {
func
nextUppandedPowerOfTwo
(
index
uint32
)
abi
.
UnpaddedPieceSize
{
index
--
power
:=
0
for
index
=
index
/
254
;
index
!=
0
;
power
+=
1
{
for
index
=
index
/
254
;
index
!=
0
;
power
+=
1
{
index
>>=
1
}
return
abi
.
UnpaddedPieceSize
(
254
*
(
1
<<
power
))
...
...
build/util.go
View file @
f015e2ea
cmd/bench/main.go
View file @
f015e2ea
package
main
import
(
import
(
"os"
"github.com/urfave/cli/v2"
"github.com/docker/go-units"
"github.com/filecoin-project/go-state-types/abi"
logging
"github.com/ipfs/go-log/v2"
"github.com/urfave/cli/v2"
"fil_integrate/seal"
)
var
log
=
logging
.
Logger
(
"bench"
)
...
...
extern/filecoin-ffi/distributed.go
View file @
f015e2ea
...
...
@@ -139,15 +139,15 @@ func GenerateWindowPoStWithVanilla(
minerID
abi
.
ActorID
,
randomness
abi
.
PoStRandomness
,
proofs
[][]
byte
,
)
(
[]
proof
.
PoStProof
,
error
)
{
)
(
proof
.
PoStProof
,
error
)
{
pp
,
err
:=
toFilRegisteredPoStProof
(
proofType
)
if
err
!=
nil
{
return
nil
,
err
return
proof
.
PoStProof
{}
,
err
}
proverID
,
err
:=
toProverID
(
minerID
)
if
err
!=
nil
{
return
nil
,
err
return
proof
.
PoStProof
{}
,
err
}
fproofs
,
discard
:=
toVanillaProofs
(
proofs
)
defer
discard
()
...
...
@@ -159,18 +159,16 @@ func GenerateWindowPoStWithVanilla(
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
())
return
proof
.
PoStProof
{}
,
errors
.
New
(
generated
.
RawString
(
resp
.
ErrorMsg
)
.
Copy
())
}
out
,
err
:=
fromFilPoStProof
s
(
resp
.
ProofsPtr
)
out
,
err
:=
fromFilPoStProof
(
resp
.
Proof
)
if
err
!=
nil
{
return
nil
,
err
return
proof
.
PoStProof
{}
,
err
}
return
out
,
nil
...
...
extern/filecoin-ffi/generated/cgo_helpers.go
View file @
f015e2ea
...
...
@@ -1805,13 +1805,9 @@ func (x *FilGenerateWindowPoStResponse) PassRef() (*C.fil_GenerateWindowPoStResp
ref2a5f3ba8
.
error_msg
,
cerror_msg_allocs
=
unpackPCharString
(
x
.
ErrorMsg
)
allocs2a5f3ba8
.
Borrow
(
cerror_msg_allocs
)
var
cproofs_len_allocs
*
cgoAllocMap
ref2a5f3ba8
.
proofs_len
,
cproofs_len_allocs
=
(
C
.
size_t
)(
x
.
ProofsLen
),
cgoAllocsUnknown
allocs2a5f3ba8
.
Borrow
(
cproofs_len_allocs
)
var
cproofs_ptr_allocs
*
cgoAllocMap
ref2a5f3ba8
.
proofs_ptr
,
cproofs_ptr_allocs
=
unpackSFilPoStProof
(
x
.
ProofsPtr
)
allocs2a5f3ba8
.
Borrow
(
cproofs_ptr_allocs
)
var
cproof_allocs
*
cgoAllocMap
ref2a5f3ba8
.
proof
,
cproof_allocs
=
x
.
Proof
.
PassValue
()
allocs2a5f3ba8
.
Borrow
(
cproof_allocs
)
var
cfaulty_sectors_len_allocs
*
cgoAllocMap
ref2a5f3ba8
.
faulty_sectors_len
,
cfaulty_sectors_len_allocs
=
(
C
.
size_t
)(
x
.
FaultySectorsLen
),
cgoAllocsUnknown
...
...
@@ -1848,7 +1844,8 @@ func (x *FilGenerateWindowPoStResponse) Deref() {
}
x
.
ErrorMsg
=
packPCharString
(
x
.
ref2a5f3ba8
.
error_msg
)
x
.
ProofsLen
=
(
uint
)(
x
.
ref2a5f3ba8
.
proofs_len
)
packSFilPoStProof
(
x
.
ProofsPtr
,
x
.
ref2a5f3ba8
.
proofs_ptr
)
x
.
Proof
=
*
NewFilPoStProofRef
(
unsafe
.
Pointer
(
&
x
.
ref2a5f3ba8
.
proofs_ptr
))
// packSFilPoStProof(x.ProofsPtr, x.ref2a5f3ba8.proofs_ptr)
x
.
FaultySectorsLen
=
(
uint
)(
x
.
ref2a5f3ba8
.
faulty_sectors_len
)
hxf0d18b7
:=
(
*
sliceHeader
)(
unsafe
.
Pointer
(
&
x
.
FaultySectorsPtr
))
hxf0d18b7
.
Data
=
unsafe
.
Pointer
(
x
.
ref2a5f3ba8
.
faulty_sectors_ptr
)
...
...
extern/filecoin-ffi/generated/generated.go
View file @
f015e2ea
...
...
@@ -889,18 +889,15 @@ func FilVerifySeal(registeredProof FilRegisteredSealProof, commR Fil32ByteArray,
}
// FilVerifyWindowPost function as declared in filecoin-ffi/filcrypto.h:817
func
FilVerifyWindowPoSt
(
randomness
Fil32ByteArray
,
replicasPtr
[]
FilPublicReplicaInfo
,
replicasLen
uint
,
proof
sPtr
[]
FilPoStProof
,
proofsLen
uint
,
proverId
Fil32ByteArray
)
*
FilVerifyWindowPoStResponse
{
func
FilVerifyWindowPoSt
(
randomness
Fil32ByteArray
,
replicasPtr
[]
FilPublicReplicaInfo
,
replicasLen
uint
,
proof
FilPoStProof
,
proverId
Fil32ByteArray
)
*
FilVerifyWindowPoStResponse
{
crandomness
,
crandomnessAllocMap
:=
randomness
.
PassValue
()
creplicasPtr
,
creplicasPtrAllocMap
:=
unpackArgSFilPublicReplicaInfo
(
replicasPtr
)
creplicasLen
,
creplicasLenAllocMap
:=
(
C
.
size_t
)(
replicasLen
),
cgoAllocsUnknown
cproofsPtr
,
cproofsPtrAllocMap
:=
unpackArgSFilPoStProof
(
proofsPtr
)
cproofsLen
,
cproofsLenAllocMap
:=
(
C
.
size_t
)(
proofsLen
),
cgoAllocsUnknown
cproof
,
cproofAllocMap
:=
proof
.
PassValue
()
cproverId
,
cproverIdAllocMap
:=
proverId
.
PassValue
()
__ret
:=
C
.
fil_verify_window_post
(
crandomness
,
creplicasPtr
,
creplicasLen
,
cproof
sPtr
,
cproofsLen
,
cproverId
)
__ret
:=
C
.
fil_verify_window_post
(
crandomness
,
creplicasPtr
,
creplicasLen
,
cproof
,
cproverId
)
runtime
.
KeepAlive
(
cproverIdAllocMap
)
runtime
.
KeepAlive
(
cproofsLenAllocMap
)
packSFilPoStProof
(
proofsPtr
,
cproofsPtr
)
runtime
.
KeepAlive
(
cproofsPtrAllocMap
)
runtime
.
KeepAlive
(
cproofAllocMap
)
runtime
.
KeepAlive
(
creplicasLenAllocMap
)
packSFilPublicReplicaInfo
(
replicasPtr
,
creplicasPtr
)
runtime
.
KeepAlive
(
creplicasPtrAllocMap
)
...
...
extern/filecoin-ffi/generated/types.go
View file @
f015e2ea
...
...
@@ -160,8 +160,7 @@ type FilPoStProof struct {
// FilGenerateWindowPoStResponse as declared in filecoin-ffi/filcrypto.h:177
type
FilGenerateWindowPoStResponse
struct
{
ErrorMsg
string
ProofsLen
uint
ProofsPtr
[]
FilPoStProof
Proof
FilPoStProof
FaultySectorsLen
uint
FaultySectorsPtr
[]
uint64
StatusCode
FCPResponseStatus
...
...
extern/filecoin-ffi/proofs.go
View file @
f015e2ea
...
...
@@ -160,11 +160,11 @@ func VerifyWindowPoSt(info spproof.WindowPoStVerifyInfo) (bool, error) {
return
false
,
errors
.
Wrap
(
err
,
"failed to create public replica info array for FFI"
)
}
filPoStProof
s
,
filPoStProofsLen
,
free
,
err
:=
toFilPoStProofs
(
info
.
Proofs
)
filPoStProof
,
_
,
err
:=
toFilPoStProof
(
info
.
Proof
)
if
err
!=
nil
{
return
false
,
errors
.
Wrap
(
err
,
"failed to create PoSt proofs array for FFI"
)
}
defer
free
()
//
defer free()
proverID
,
err
:=
toProverID
(
info
.
Prover
)
if
err
!=
nil
{
...
...
@@ -174,7 +174,7 @@ func VerifyWindowPoSt(info spproof.WindowPoStVerifyInfo) (bool, error) {
resp
:=
generated
.
FilVerifyWindowPoSt
(
to32ByteArray
(
info
.
Randomness
),
filPublicReplicaInfos
,
filPublicReplicaInfosLen
,
filPoStProof
s
,
filPoStProofsLen
,
filPoStProof
,
proverID
,
)
resp
.
Deref
()
...
...
@@ -225,8 +225,8 @@ func VerifyAggregateWindowPostProofs(aggregateInfo spproof.AggregateWindowPostIn
sp
,
rap
,
proverID
,
aggregateInfo
.
AggregateProof
,
uint
(
len
(
aggregateInfo
.
AggregateProof
)),
aggregateInfo
.
AggregateProof
.
ProofBytes
,
uint
(
len
(
aggregateInfo
.
AggregateProof
.
ProofBytes
)),
randomnesses
,
uint
(
len
(
randomnesses
)),
filPublicReplicaInfos
,
...
...
@@ -742,47 +742,46 @@ func GenerateWindowPoSt(
minerID
abi
.
ActorID
,
privateSectorInfo
SortedPrivateSectorInfo
,
randomness
abi
.
PoStRandomness
,
)
(
[]
spproof
.
PoStProof
,
[]
abi
.
SectorNumber
,
error
)
{
)
(
spproof
.
PoStProof
,
[]
abi
.
SectorNumber
,
error
)
{
filReplicas
,
filReplicasLen
,
free
,
err
:=
toFilPrivateReplicaInfos
(
privateSectorInfo
.
Values
(),
"window"
)
if
err
!=
nil
{
return
nil
,
nil
,
errors
.
Wrap
(
err
,
"failed to create private replica info array for FFI"
)
return
spproof
.
PoStProof
{}
,
nil
,
errors
.
Wrap
(
err
,
"failed to create private replica info array for FFI"
)
}
defer
free
()
proverID
,
err
:=
toProverID
(
minerID
)
if
err
!=
nil
{
return
nil
,
nil
,
err
return
spproof
.
PoStProof
{}
,
nil
,
err
}
resp
:=
generated
.
FilGenerateWindowPost
(
to32ByteArray
(
randomness
),
filReplicas
,
filReplicasLen
,
proverID
)
resp
.
Deref
()
resp
.
ProofsPtr
=
make
([]
generated
.
FilPoStProof
,
resp
.
ProofsLen
)
resp
.
Deref
()
resp
.
FaultySectorsPtr
=
resp
.
FaultySectorsPtr
[
:
resp
.
FaultySectorsLen
]
defer
generated
.
FilDestroyGenerateWindowPostResponse
(
resp
)
faultySectors
,
err
:=
fromFilPoStFaultySectors
(
resp
.
FaultySectorsPtr
,
resp
.
FaultySectorsLen
)
if
err
!=
nil
{
return
nil
,
nil
,
xerrors
.
Errorf
(
"failed to parse faulty sectors list: %w"
,
err
)
return
spproof
.
PoStProof
{}
,
nil
,
xerrors
.
Errorf
(
"failed to parse faulty sectors list: %w"
,
err
)
}
if
resp
.
StatusCode
!=
generated
.
FCPResponseStatusFCPNoError
{
return
nil
,
faultySectors
,
errors
.
New
(
generated
.
RawString
(
resp
.
ErrorMsg
)
.
Copy
())
return
spproof
.
PoStProof
{}
,
faultySectors
,
errors
.
New
(
generated
.
RawString
(
resp
.
ErrorMsg
)
.
Copy
())
}
proof
s
,
err
:=
fromFilPoStProofs
(
resp
.
ProofsPtr
)
proof
,
err
:=
fromFilPoStProof
(
resp
.
Proof
)
if
err
!=
nil
{
return
nil
,
nil
,
err
return
spproof
.
PoStProof
{}
,
nil
,
err
}
return
proof
s
,
faultySectors
,
nil
return
proof
,
faultySectors
,
nil
}
// GenerateWindowPoSt
func
AggregateWindowPoStProofs
(
aggregateInfo
spproof
.
AggregateWindowPostInfos
,
proofs
[]
spproof
.
PoStProof
)
(
[]
byte
,
error
)
{
func
AggregateWindowPoStProofs
(
aggregateInfo
spproof
.
AggregateWindowPostInfos
,
proofs
[]
spproof
.
PoStProof
)
(
spproof
.
PoStProof
,
error
)
{
rap
,
err
:=
toFilRegisteredAggregationProof
(
aggregateInfo
.
AggregateType
)
if
err
!=
nil
{
return
nil
,
err
return
spproof
.
PoStProof
{}
,
err
}
randomnesses
:=
make
([]
generated
.
Fil32ByteArray
,
len
(
aggregateInfo
.
Randomnesses
))
...
...
@@ -793,7 +792,7 @@ func AggregateWindowPoStProofs(aggregateInfo spproof.AggregateWindowPostInfos, p
filPoStProofs
,
filPoStProofsLen
,
free
,
err
:=
toFilPoStProofs
(
proofs
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to create PoSt proofs array for FFI"
)
return
spproof
.
PoStProof
{}
,
errors
.
Wrap
(
err
,
"failed to create PoSt proofs array for FFI"
)
}
defer
free
()
...
...
@@ -803,10 +802,14 @@ func AggregateWindowPoStProofs(aggregateInfo spproof.AggregateWindowPostInfos, p
defer
generated
.
FilDestroyAggregateProof
(
resp
)
if
resp
.
StatusCode
!=
generated
.
FCPResponseStatusFCPNoError
{
return
nil
,
errors
.
New
(
generated
.
RawString
(
resp
.
ErrorMsg
)
.
Copy
())
return
spproof
.
PoStProof
{}
,
errors
.
New
(
generated
.
RawString
(
resp
.
ErrorMsg
)
.
Copy
())
}
return
copyBytes
(
resp
.
ProofPtr
,
resp
.
ProofLen
),
nil
return
spproof
.
PoStProof
{
PoStProof
:
aggregateInfo
.
PoStType
,
ProofBytes
:
copyBytes
(
resp
.
ProofPtr
,
resp
.
ProofLen
),
},
nil
}
// GetGPUDevices produces a slice of strings, each representing the name of a
...
...
@@ -1061,9 +1064,24 @@ func fromFilPoStFaultySectors(ptr []uint64, l uint) ([]abi.SectorNumber, error)
return
snums
,
nil
}
func
fromFilPoStProof
(
src
generated
.
FilPoStProof
)
(
spproof
.
PoStProof
,
error
)
{
src
.
Deref
()
pp
,
err
:=
fromFilRegisteredPoStProof
(
src
.
RegisteredProof
)
if
err
!=
nil
{
return
spproof
.
PoStProof
{},
err
}
out
:=
spproof
.
PoStProof
{
PoStProof
:
pp
,
ProofBytes
:
copyBytes
(
src
.
ProofPtr
,
src
.
ProofLen
),
}
return
out
,
nil
}
func
fromFilPoStProofs
(
src
[]
generated
.
FilPoStProof
)
([]
spproof
.
PoStProof
,
error
)
{
out
:=
make
([]
spproof
.
PoStProof
,
len
(
src
))
for
idx
:=
range
out
{
src
[
idx
]
.
Deref
()
...
...
@@ -1081,6 +1099,22 @@ func fromFilPoStProofs(src []generated.FilPoStProof) ([]spproof.PoStProof, error
return
out
,
nil
}
func
toFilPoStProof
(
src
spproof
.
PoStProof
)
(
generated
.
FilPoStProof
,
func
(),
error
)
{
pp
,
err
:=
toFilRegisteredPoStProof
(
src
.
PoStProof
)
if
err
!=
nil
{
return
generated
.
FilPoStProof
{},
func
()
{},
err
}
out
:=
generated
.
FilPoStProof
{
RegisteredProof
:
pp
,
ProofLen
:
uint
(
len
(
src
.
ProofBytes
)),
ProofPtr
:
src
.
ProofBytes
,
}
_
,
allocs
:=
out
.
PassRef
()
return
out
,
allocs
.
Free
,
nil
}
func
toFilPoStProofs
(
src
[]
spproof
.
PoStProof
)
([]
generated
.
FilPoStProof
,
uint
,
func
(),
error
)
{
allocs
:=
make
([]
AllocationManager
,
len
(
src
))
...
...
extern/filecoin-ffi/rust/src/proofs/api.rs
View file @
f015e2ea
...
...
@@ -1075,26 +1075,36 @@ pub unsafe extern "C" fn fil_generate_window_post_with_vanilla(
match
result
{
Ok
(
output
)
=>
{
let
mapped
:
Vec
<
fil_PoStProof
>
=
output
.iter
()
.cloned
()
.map
(|(
t
,
proof
)|
{
let
out
=
fil_PoStProof
{
let
(
t
,
proof
)
=
output
;
let
postProof
=
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
);
response
.proof
=
postProof
;
// let mapped: Vec<fil_PoStProof> = 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
...
...
@@ -1143,26 +1153,36 @@ pub unsafe extern "C" fn fil_generate_window_post(
match
result
{
Ok
(
output
)
=>
{
let
mapped
:
Vec
<
fil_PoStProof
>
=
output
.iter
()
.cloned
()
.map
(|(
t
,
proof
)|
{
let
out
=
fil_PoStProof
{
let
(
t
,
proof
)
=
output
;
let
postProof
=
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
);
response
.proof
=
postProof
;
// let mapped: Vec<fil_PoStProof> = 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
...
...
@@ -1195,8 +1215,7 @@ pub unsafe extern "C" fn fil_verify_window_post(
randomness
:
fil_32ByteArray
,
replicas_ptr
:
*
const
fil_PublicReplicaInfo
,
replicas_len
:
libc
::
size_t
,
proofs_ptr
:
*
const
fil_PoStProof
,
proofs_len
:
libc
::
size_t
,
post_proof
:
fil_PoStProof
,
prover_id
:
fil_32ByteArray
,
)
->
*
mut
fil_VerifyWindowPoStResponse
{
catch_panic_response
(||
{
...
...
@@ -1209,16 +1228,13 @@ pub unsafe extern "C" fn fil_verify_window_post(
let
convert
=
super
::
helpers
::
to_public_replica_info_map
(
replicas_ptr
,
replicas_len
);
let
result
=
convert
.and_then
(|
replicas
|
{
let
post_proofs
=
c_to_rust_post_proofs
(
proofs_ptr
,
proofs_len
)
?
;
//
let post_proofs = c_to_rust_post_proofs(proofs_ptr, proofs_len)?;
let
proofs
:
Vec
<
(
RegisteredPoStProof
,
&
[
u8
])
>
=
post_proofs
.iter
()
.map
(|
x
|
(
x
.registered_proof
,
x
.proof
.as_ref
()))
.collect
();
let
proof
:
(
RegisteredPoStProof
,
&
[
u8
])
=
(
post_proof
.registered_proof
.into
(),
from_raw_parts
(
post_proof
.proof_ptr
,
post_proof
.proof_len
));
filecoin_proofs_api
::
post
::
verify_window_post
(
&
randomness
.inner
,
&
proof
s
,
&
proof
,
&
replicas
,
prover_id
.inner
,
)
...
...
extern/filecoin-ffi/rust/src/proofs/types.rs
View file @
f015e2ea
...
...
@@ -277,6 +277,16 @@ pub struct fil_PoStProof {
pub
proof_ptr
:
*
const
u8
,
}
impl
Default
for
fil_PoStProof
{
fn
default
()
->
fil_PoStProof
{
fil_PoStProof
{
registered_proof
:
fil_RegisteredPoStProof
::
StackedDrgWindow2KiBV1
,
proof_len
:
0
,
proof_ptr
:
ptr
::
null
(),
}
}
}
impl
Drop
for
fil_PoStProof
{
fn
drop
(
&
mut
self
)
{
let
_
=
unsafe
{
...
...
@@ -487,8 +497,7 @@ code_and_message_impl!(fil_GenerateWinningPoStResponse);
#[derive(DropStructMacro)]
pub
struct
fil_GenerateWindowPoStResponse
{
pub
error_msg
:
*
const
libc
::
c_char
,
pub
proofs_len
:
libc
::
size_t
,
pub
proofs_ptr
:
*
const
fil_PoStProof
,
pub
proof
:
fil_PoStProof
,
pub
faulty_sectors_len
:
libc
::
size_t
,
pub
faulty_sectors_ptr
:
*
const
u64
,
pub
status_code
:
FCPResponseStatus
,
...
...
@@ -498,8 +507,7 @@ impl Default for fil_GenerateWindowPoStResponse {
fn
default
()
->
fil_GenerateWindowPoStResponse
{
fil_GenerateWindowPoStResponse
{
error_msg
:
ptr
::
null
(),
proofs_len
:
0
,
proofs_ptr
:
ptr
::
null
(),
proof
:
fil_PoStProof
::
default
(),
faulty_sectors_len
:
0
,
faulty_sectors_ptr
:
ptr
::
null
(),
status_code
:
FCPResponseStatus
::
FCPNoError
,
...
...
extern/rust-filecoin-proofs-api/src/post.rs
View file @
f015e2ea
...
...
@@ -317,7 +317,7 @@ pub fn generate_window_post_with_vanilla(
randomness
:
&
ChallengeSeed
,
prover_id
:
ProverId
,
vanilla_proofs
:
&
[
VanillaProofBytes
],
)
->
Result
<
Vec
<
(
RegisteredPoStProof
,
SnarkProof
)
>
>
{
)
->
Result
<
(
RegisteredPoStProof
,
SnarkProof
)
>
{
with_shape!
(
u64
::
from
(
registered_post_proof_type
.sector_size
()),
generate_window_post_with_vanilla_inner
,
...
...
@@ -333,7 +333,7 @@ fn generate_window_post_with_vanilla_inner<Tree: 'static + MerkleTreeTrait>(
randomness
:
&
ChallengeSeed
,
prover_id
:
ProverId
,
vanilla_proofs
:
&
[
VanillaProofBytes
],
)
->
Result
<
Vec
<
(
RegisteredPoStProof
,
SnarkProof
)
>
>
{
)
->
Result
<
(
RegisteredPoStProof
,
SnarkProof
)
>
{
ensure!
(
!
vanilla_proofs
.is_empty
(),
"vanilla_proofs cannot be an empty list"
...
...
@@ -356,14 +356,14 @@ fn generate_window_post_with_vanilla_inner<Tree: 'static + MerkleTreeTrait>(
// once there are multiple versions, merge them before returning
Ok
(
vec!
[(
registered_post_proof_type
,
posts_v1
)]
)
Ok
(
(
registered_post_proof_type
,
posts_v1
)
)
}
pub
fn
generate_window_post
(
randomness
:
&
ChallengeSeed
,
replicas
:
&
BTreeMap
<
SectorId
,
PrivateReplicaInfo
>
,
prover_id
:
ProverId
,
)
->
Result
<
Vec
<
(
RegisteredPoStProof
,
SnarkProof
)
>
>
{
)
->
Result
<
(
RegisteredPoStProof
,
SnarkProof
)
>
{
ensure!
(
!
replicas
.is_empty
(),
"no replicas supplied"
);
let
registered_post_proof_type_v1
=
replicas
.values
()
...
...
@@ -390,7 +390,7 @@ fn generate_window_post_inner<Tree: 'static + MerkleTreeTrait>(
randomness
:
&
ChallengeSeed
,
replicas
:
&
BTreeMap
<
SectorId
,
PrivateReplicaInfo
>
,
prover_id
:
ProverId
,
)
->
Result
<
Vec
<
(
RegisteredPoStProof
,
SnarkProof
)
>
>
{
)
->
Result
<
(
RegisteredPoStProof
,
SnarkProof
)
>
{
let
mut
replicas_v1
=
BTreeMap
::
new
();
for
(
id
,
info
)
in
replicas
.iter
()
{
...
...
@@ -424,19 +424,19 @@ fn generate_window_post_inner<Tree: 'static + MerkleTreeTrait>(
// once there are multiple versions, merge them before returning
Ok
(
vec!
[(
registered_proof_v1
,
posts_v1
)]
)
Ok
(
(
registered_proof_v1
,
posts_v1
)
)
}
pub
fn
verify_window_post
(
randomness
:
&
ChallengeSeed
,
proof
s
:
&
[(
RegisteredPoStProof
,
&
[
u8
])]
,
proof
:
&
(
RegisteredPoStProof
,
&
[
u8
])
,
replicas
:
&
BTreeMap
<
SectorId
,
PublicReplicaInfo
>
,
prover_id
:
ProverId
,
)
->
Result
<
bool
>
{
ensure!
(
!
replicas
.is_empty
(),
"no replicas supplied"
);
ensure!
(
proofs
.len
()
==
1
,
"only one version of PoSt supported"
);
//
ensure!(proofs.len() == 1, "only one version of PoSt supported");
let
registered_post_proof_type_v1
=
proof
s
[
0
]
.
0
;
let
registered_post_proof_type_v1
=
proof
.
0
;
ensure!
(
registered_post_proof_type_v1
.typ
()
==
PoStType
::
Window
,
...
...
@@ -452,7 +452,7 @@ pub fn verify_window_post(
verify_window_post_inner
,
registered_post_proof_type_v1
,
randomness
,
proof
s
,
proof
,
replicas
,
prover_id
,
)
...
...
@@ -461,7 +461,7 @@ pub fn verify_window_post(
fn
verify_window_post_inner
<
Tree
:
'static
+
MerkleTreeTrait
>
(
registered_proof_v1
:
RegisteredPoStProof
,
randomness
:
&
ChallengeSeed
,
proof
s
:
&
[(
RegisteredPoStProof
,
&
[
u8
])]
,
proof
:
&
(
RegisteredPoStProof
,
&
[
u8
])
,
replicas
:
&
BTreeMap
<
SectorId
,
PublicReplicaInfo
>
,
prover_id
:
ProverId
,
)
->
Result
<
bool
>
{
...
...
@@ -487,7 +487,7 @@ fn verify_window_post_inner<Tree: 'static + MerkleTreeTrait>(
randomness
,
&
replicas_v1
,
prover_id
,
proof
s
[
0
]
.
1
,
proof
.
1
,
)
?
;
// once there are multiple versions, merge them before returning
...
...
go.mod
View file @
f015e2ea
seal/basicfs/fs.go
View file @
f015e2ea
seal/seal_api.go
View file @
f015e2ea
This diff is collapsed.
Click to expand it.
seal/test.go
View file @
f015e2ea
package
seal
import
(
import
(
"context"
"io"
"os"
"fmt"
"time"
"math/rand"
"io"
"io/ioutil"
"math/rand"
"os"
"path/filepath"
"time"
"golang.org/x/xerrors"
"github.com/mitchellh/go-homedir"
"github.com/minio/md5-simd"
"github.com/minio/blake2b-simd"
"github.com/filecoin-project/go-state-types/abi"
commcid
"github.com/filecoin-project/go-fil-commcid"
"github.com/filecoin-project/go-state-types/abi"
"github.com/minio/blake2b-simd"
"github.com/minio/md5-simd"
"github.com/mitchellh/go-homedir"
"golang.org/x/xerrors"
spproof
"fil_integrate/build/proof"
"fil_integrate/build/storage"
...
...
@@ -56,12 +56,12 @@ func TestSealAndUnseal() error {
sbfs
:=
&
basicfs
.
Manager
{
Root
:
tsdir
,
}
sb
,
err
:=
New
(
sbfs
)
if
err
!=
nil
{
sb
,
err
:=
New
(
sbfs
)
if
err
!=
nil
{
return
err
}
ctx
:=
context
.
TODO
()
sectorSize
:=
abi
.
SectorSize
(
8
*
1024
*
1024
)
sectorSize
:=
abi
.
SectorSize
(
8
*
1024
*
1024
)
sid
:=
storage
.
SectorRef
{
ID
:
abi
.
SectorID
{
Miner
:
1000
,
...
...
@@ -194,8 +194,8 @@ func TestSplitDataInToPieces(sectorSize abi.SectorSize, dataSize uint64) error {
sbfs
:=
&
basicfs
.
Manager
{
Root
:
tsdir
,
}
sb
,
err
:=
New
(
sbfs
)
if
err
!=
nil
{
sb
,
err
:=
New
(
sbfs
)
if
err
!=
nil
{
return
err
}
...
...
@@ -225,7 +225,7 @@ func TestSplitDataInToPieces(sectorSize abi.SectorSize, dataSize uint64) error {
start
=
time
.
Now
()
finalPiece
,
pieces
,
err
:=
sp
.
EncodeDataToPieces
(
ctx
,
sectorSize
,
in
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
}
fmt
.
Printf
(
"encode data using %s
\n
"
,
time
.
Now
()
.
Sub
(
start
))
...
...
@@ -236,7 +236,7 @@ func TestSplitDataInToPieces(sectorSize abi.SectorSize, dataSize uint64) error {
var
index
int
var
perr
error
var
piecesInfo
[]
abi
.
PieceInfo
for
{
for
{
sid
:=
storage
.
SectorRef
{
ID
:
abi
.
SectorID
{
Miner
:
minerID
,
...
...
@@ -256,7 +256,7 @@ func TestSplitDataInToPieces(sectorSize abi.SectorSize, dataSize uint64) error {
if
err
!=
nil
{
return
err
}
for
_
,
piece
:=
range
(
piecesInfo
)
{
for
_
,
piece
:=
range
piecesInfo
{
var
commitHash
storage
.
Hash
commit
,
err
:=
commcid
.
CIDToPieceCommitmentV1
(
piece
.
PieceCID
)
if
err
!=
nil
{
...
...
@@ -275,7 +275,7 @@ func TestSplitDataInToPieces(sectorSize abi.SectorSize, dataSize uint64) error {
index
++
}
for
i
,
finalPiece
:=
range
(
finalPieces
)
{
for
i
,
finalPiece
:=
range
finalPieces
{
filename
:=
filepath
.
Join
(
tsdir
,
fmt
.
Sprintf
(
"output-%d.dat"
,
i
))
if
_
,
err
=
os
.
Stat
(
filename
);
!
os
.
IsNotExist
(
err
)
{
os
.
Remove
(
filename
)
...
...
@@ -333,8 +333,8 @@ func TestSealAndWindowPoSt(sectorSize abi.SectorSize, numAggregate int) error {
sbfs
:=
&
basicfs
.
Manager
{
Root
:
tsdir
,
}
sb
,
err
:=
New
(
sbfs
)
if
err
!=
nil
{
sb
,
err
:=
New
(
sbfs
)
if
err
!=
nil
{
return
err
}
sp
:=
&
Encoder
{
...
...
@@ -356,7 +356,7 @@ func TestSealAndWindowPoSt(sectorSize abi.SectorSize, numAggregate int) error {
for
i
:=
0
;
i
<
numAggregate
;
i
++
{
filename
:=
filepath
.
Join
(
tsdir
,
fmt
.
Sprintf
(
"input-%d.dat"
,
i
))
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
Datasize
:=
(
r
.
Intn
(
1024
*
1024
)
+
1024
*
1024
)
*
32
Datasize
:=
(
r
.
Intn
(
1024
*
1024
)
+
1024
*
1024
)
*
32
b
,
err
=
generateRandomData
(
filename
,
uint64
(
Datasize
),
b
)
if
err
!=
nil
{
return
err
...
...
@@ -368,7 +368,7 @@ func TestSealAndWindowPoSt(sectorSize abi.SectorSize, numAggregate int) error {
defer
in
.
Close
()
finalPiece
,
pieces
,
err
:=
sp
.
EncodeDataToPieces
(
ctx
,
sectorSize
,
in
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
}
...
...
@@ -378,7 +378,7 @@ func TestSealAndWindowPoSt(sectorSize abi.SectorSize, numAggregate int) error {
}
var
perr
error
for
{
for
{
var
infos
[]
spproof
.
AggregateSealVerifyInfo
var
sealedSectors
[]
spproof
.
SectorInfo
var
sectors
[]
storage
.
SectorRef
...
...
@@ -419,7 +419,7 @@ func TestSealAndWindowPoSt(sectorSize abi.SectorSize, numAggregate int) error {
SealedCID
:
cids
.
Sealed
,
})
var
offset
abi
.
UnpaddedPieceSize
=
0
for
_
,
piece
:=
range
(
pieces
)
{
for
_
,
piece
:=
range
pieces
{
var
commitHash
storage
.
Hash
commit
,
err
:=
commcid
.
CIDToPieceCommitmentV1
(
piece
.
PieceCID
)
if
err
!=
nil
{
...
...
@@ -473,7 +473,7 @@ func TestSealAndWindowPoSt(sectorSize abi.SectorSize, numAggregate int) error {
randomnesses
=
append
(
randomnesses
,
seed
)
sectorCount
=
append
(
sectorCount
,
uint
(
len
(
sealedSectors
)))
sectorsInfo
=
append
(
sectorsInfo
,
sectors
)
postProofs
=
append
(
postProofs
,
postProof
...
)
postProofs
=
append
(
postProofs
,
postProof
)
}
proof
,
err
:=
sb
.
AggregateWindowPoStProofs
(
spproof
.
AggregateWindowPostInfos
{
...
...
@@ -527,10 +527,10 @@ func TestSealAndWindowPoSt(sectorSize abi.SectorSize, numAggregate int) error {
return
nil
}
func
Insert
(
sortedPieces
[]
storage
.
Piece
,
pieces
[]
storage
.
Piece
,
finalPiece
storage
.
Piece
)
([]
storage
.
Piece
)
{
func
Insert
(
sortedPieces
[]
storage
.
Piece
,
pieces
[]
storage
.
Piece
,
finalPiece
storage
.
Piece
)
[]
storage
.
Piece
{
var
i
int
var
res
[]
storage
.
Piece
for
i
=
len
(
sortedPieces
)
-
1
;
i
>=
0
;
i
--
{
for
i
=
len
(
sortedPieces
)
-
1
;
i
>=
0
;
i
--
{
if
sortedPieces
[
i
]
.
Size
>=
finalPiece
.
Size
{
break
}
...
...
@@ -545,10 +545,10 @@ func generateRandomData(filename string, dataSize uint64, b []byte) ([]byte, err
os
.
Remove
(
filename
)
}
r
:=
rand
.
New
(
rand
.
NewSource
(
time
.
Now
()
.
UnixNano
()))
Datasize
:=
(
r
.
Intn
(
1024
*
1024
)
+
1024
*
1024
)
*
32
var
i
uint64
Datasize
:=
(
r
.
Intn
(
1024
*
1024
)
+
1024
*
1024
)
*
32
//
var i uint64
buf
:=
make
([]
byte
,
Datasize
)
for
i
=
0
;
i
<
Datasize
;
i
+=
32
{
for
i
:=
0
;
i
<
Datasize
;
i
+=
32
{
tmp
:=
blake2b
.
Sum256
(
b
)
b
=
tmp
[
:
]
copy
(
buf
[
i
:
i
+
32
],
b
[
:
])
...
...
@@ -575,11 +575,11 @@ func decodePiecesToData(sb *Sealer, ctx context.Context, tsdir string, sectorSiz
}
piecesHash
:=
data
.
PieceHash
for
;
data
.
HasPre
;
{
for
data
.
HasPre
{
file
,
err
=
unseal
(
sb
,
ctx
,
data
.
PreHash
)
data
,
err
=
DecodePiece
(
ctx
,
sectorSize
,
file
)
file
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
}
piecesHash
=
append
(
data
.
PieceHash
,
piecesHash
...
)
...
...
@@ -595,12 +595,12 @@ func decodePiecesToData(sb *Sealer, ctx context.Context, tsdir string, sectorSiz
}
_
,
err
=
out
.
Write
(
data
.
Data
[
:
])
if
err
!=
nil
{
if
err
!=
nil
{
return
err
}
}
_
,
err
=
out
.
Write
(
buf
[
:
])
if
err
!=
nil
{
if
err
!=
nil
{
return
err
}
return
nil
...
...
@@ -655,21 +655,20 @@ func checkDecodedFile(root string, i int) (bool, error) {
h2
:=
server2
.
NewHash
()
defer
h2
.
Close
()
for
{
for
{
_
,
inerr
:=
in
.
Read
(
inBuf
[
:
])
if
err
!=
nil
&&
err
!=
io
.
EOF
{
if
err
!=
nil
&&
err
!=
io
.
EOF
{
return
false
,
err
}
_
,
outerr
:=
out
.
Read
(
outBuf
[
:
])
if
err
!=
nil
&&
err
!=
io
.
EOF
{
if
err
!=
nil
&&
err
!=
io
.
EOF
{
return
false
,
err
}
h1
.
Write
(
inBuf
)
h2
.
Write
(
outBuf
)
if
inerr
==
io
.
EOF
&&
outerr
==
io
.
EOF
{
hash1
:=
h1
.
Sum
(
nil
)
hash2
:=
h2
.
Sum
(
nil
)
...
...
seal/type.go
View file @
f015e2ea
package
seal
import
(
import
(
"context"
"io"
"github.com/minio/blake2b-simd"
"github.com/filecoin-project/go-state-types/abi"
"github.com/ipfs/go-cid"
"github.com/minio/blake2b-simd"
spproof
"fil_integrate/build/proof"
"fil_integrate/build/storage"
...
...
@@ -24,7 +24,7 @@ type PieceEncoder interface {
}
//interface
type
SectorSealer
interface
{
type
SectorSealer
interface
{
AddPiece
(
ctx
context
.
Context
,
sid
storage
.
SectorRef
,
sortedPieces
[]
storage
.
Piece
)
([]
abi
.
PieceInfo
,
[]
storage
.
Piece
,
error
)
// run pre-commit1 and pre-commit2 phase
...
...
@@ -32,25 +32,25 @@ type SectorSealer interface{
Sealed
(
ctx
context
.
Context
,
sid
storage
.
SectorRef
,
pieces
[]
abi
.
PieceInfo
)
(
storage
.
SectorCids
,
error
)
// run commit1 and commit2 phase
// generate the zk-proof of sealing
GenerateCommitProof
(
ctx
context
.
Context
,
sid
storage
.
SectorRef
,
seed
abi
.
InteractiveSealRandomness
,
pieces
[]
abi
.
PieceInfo
,
cids
storage
.
SectorCids
)
(
spproof
.
Proof
,
error
)
GenerateCommitProof
(
ctx
context
.
Context
,
sid
storage
.
SectorRef
,
seed
abi
.
InteractiveSealRandomness
,
pieces
[]
abi
.
PieceInfo
,
cids
storage
.
SectorCids
)
(
spproof
.
Proof
,
error
)
AggregateSealProofs
(
aggregateInfo
spproof
.
AggregateSealVerifyProofAndInfos
,
proofs
[]
spproof
.
Proof
)
(
spproof
.
Proof
,
error
)
UnsealedRange
(
ctx
context
.
Context
,
sid
storage
.
SectorRef
,
out
io
.
Writer
,
commd
cid
.
Cid
,
offset
storiface
.
UnpaddedByteIndex
,
size
abi
.
UnpaddedPieceSize
)
error
GenerateWindowPoStProofs
(
ctx
context
.
Context
,
minerID
abi
.
ActorID
,
sectorInfo
[]
spproof
.
SectorInfo
,
randomness
abi
.
PoStRandomness
)
(
[]
spproof
.
PoStProof
,
[]
abi
.
SectorID
,
error
)
AggregateWindowPoStProofs
(
aggregateInfo
spproof
.
AggregateWindowPostInfos
,
proofs
[]
spproof
.
PoStProof
)
(
spproof
.
Proof
,
error
)
GenerateWindowPoStProofs
(
ctx
context
.
Context
,
minerID
abi
.
ActorID
,
sectorInfo
[]
spproof
.
SectorInfo
,
randomness
abi
.
PoStRandomness
)
(
spproof
.
PoStProof
,
[]
abi
.
SectorID
,
error
)
AggregateWindowPoStProofs
(
aggregateInfo
spproof
.
AggregateWindowPostInfos
,
proofs
[]
spproof
.
PoStProof
)
(
spproof
.
P
oStP
roof
,
error
)
}
type
SectorVerifier
interface
{
type
SectorVerifier
interface
{
VerifySeal
(
info
spproof
.
SealVerifyInfo
)
(
bool
,
error
)
VerifyAggregateSeals
(
aggregate
spproof
.
AggregateSealVerifyProofAndInfos
)
(
bool
,
error
)
VerifyWindowPoSt
(
sectors
[]
storage
.
SectorRef
,
proof
s
[]
spproof
.
PoStProof
,
randomness
abi
.
PoStRandomness
,
proverID
abi
.
ActorID
)
(
bool
,
error
)
VerifyAggregateWindowPostProofs
(
sectors
[][]
storage
.
SectorRef
,
proof
spproof
.
Proof
,
randomnesses
[]
abi
.
PoStRandomness
,
proverID
abi
.
ActorID
)
(
bool
,
error
)
VerifyWindowPoSt
(
sectors
[]
storage
.
SectorRef
,
proof
spproof
.
PoStProof
,
randomness
abi
.
PoStRandomness
,
proverID
abi
.
ActorID
)
(
bool
,
error
)
VerifyAggregateWindowPostProofs
(
sectors
[][]
storage
.
SectorRef
,
proof
spproof
.
P
oStP
roof
,
randomnesses
[]
abi
.
PoStRandomness
,
proverID
abi
.
ActorID
)
(
bool
,
error
)
}
type
SectorManager
interface
{
GetRoot
()
(
string
)
GetRoot
()
string
// * returns storiface.ErrSectorNotFound if a requested existing sector doesn't exist
// * returns an error when allocate is set, and existing isn't, and the sector exists
AcquireUnsealed
(
ctx
context
.
Context
,
id
storage
.
SectorRef
,
existing
storiface
.
SectorFileType
,
allocate
storiface
.
SectorFileType
,
ptype
storiface
.
PathType
)
(
storiface
.
SectorPaths
,
func
(),
error
)
...
...
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