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
Hide 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
"
"github.com/filecoin-project/go-state-types/abi
"
import
(
"github.com/filecoin-project/go-state-types/abi
"
"github.com/ipfs/go-cid
"
)
type
SectorInfo
struct
{
SealType
abi
.
RegisteredSealProof
// RegisteredProof used when sealing - needs to be mapped to PoSt registered proof when used to verify a PoSt
SectorNumber
abi
.
SectorNumber
SealedCID
cid
.
Cid
// CommR
SealType
abi
.
RegisteredSealProof
// RegisteredProof used when sealing - needs to be mapped to PoSt registered proof when used to verify a PoSt
SectorNumber
abi
.
SectorNumber
SealedCID
cid
.
Cid
// CommR
}
type
Proof
[]
byte
type
SealVerifyInfo
struct
{
SealType
abi
.
RegisteredSealProof
SectorID
abi
.
SectorID
DealIDs
[]
abi
.
DealID
Randomness
abi
.
SealRandomness
InteractiveRandomness
abi
.
InteractiveSealRandomness
SealProof
Proof
SealType
abi
.
RegisteredSealProof
SectorID
abi
.
SectorID
DealIDs
[]
abi
.
DealID
Randomness
abi
.
SealRandomness
InteractiveRandomness
abi
.
InteractiveSealRandomness
SealProof
Proof
// Safe because we get those from the miner actor
SealedCID
cid
.
Cid
`checked:"true"`
// CommR
UnsealedCID
cid
.
Cid
`checked:"true"`
// CommD
// Safe because we get those from the miner actor
SealedCID
cid
.
Cid
`checked:"true"`
// CommR
UnsealedCID
cid
.
Cid
`checked:"true"`
// CommD
}
type
AggregateSealVerifyInfo
struct
{
Number
abi
.
SectorNumber
Randomness
abi
.
SealRandomness
InteractiveRandomness
abi
.
InteractiveSealRandomness
Number
abi
.
SectorNumber
Randomness
abi
.
SealRandomness
InteractiveRandomness
abi
.
InteractiveSealRandomness
// Safe because we get those from the miner actor
SealedCID
cid
.
Cid
`checked:"true"`
// CommR
UnsealedCID
cid
.
Cid
`checked:"true"`
// CommD
// Safe because we get those from the miner actor
SealedCID
cid
.
Cid
`checked:"true"`
// CommR
UnsealedCID
cid
.
Cid
`checked:"true"`
// CommD
}
type
AggregateSealVerifyProofAndInfos
struct
{
Miner
abi
.
ActorID
SealType
abi
.
RegisteredSealProof
AggregateType
abi
.
RegisteredAggregationProof
AggregateProof
Proof
Infos
[]
AggregateSealVerifyInfo
Miner
abi
.
ActorID
SealType
abi
.
RegisteredSealProof
AggregateType
abi
.
RegisteredAggregationProof
AggregateProof
Proof
Infos
[]
AggregateSealVerifyInfo
}
type
PoStProof
struct
{
PoStProof
abi
.
RegisteredPoStProof
ProofBytes
Proof
PoStProof
abi
.
RegisteredPoStProof
ProofBytes
Proof
}
type
WinningPoStVerifyInfo
struct
{
Randomness
abi
.
PoStRandomness
Proofs
[]
PoStProof
ChallengedSectors
[]
SectorInfo
Prover
abi
.
ActorID
// used to derive 32-byte prover ID
Randomness
abi
.
PoStRandomness
Proofs
[]
PoStProof
ChallengedSectors
[]
SectorInfo
Prover
abi
.
ActorID
// used to derive 32-byte prover ID
}
type
WindowPoStVerifyInfo
struct
{
Randomness
abi
.
PoStRandomness
Proofs
[]
PoStProof
ChallengedSectors
[]
SectorInfo
Prover
abi
.
ActorID
// used to derive 32-byte prover ID
Randomness
abi
.
PoStRandomness
Proof
PoStProof
ChallengedSectors
[]
SectorInfo
Prover
abi
.
ActorID
// used to derive 32-byte prover ID
}
type
AggregateWindowPostInfos
struct
{
PoStType
abi
.
RegisteredPoStProof
AggregateType
abi
.
RegisteredAggregationProof
AggregateProof
Proof
ChallengedSectors
[]
SectorInfo
SectorCount
[]
uint
Randomnesses
[]
abi
.
PoStRandomness
Prover
abi
.
ActorID
}
\ No newline at end of file
type
AggregateWindowPostInfos
struct
{
PoStType
abi
.
RegisteredPoStProof
AggregateType
abi
.
RegisteredAggregationProof
AggregateProof
PoStProof
ChallengedSectors
[]
SectorInfo
SectorCount
[]
uint
Randomnesses
[]
abi
.
PoStRandomness
Prover
abi
.
ActorID
}
build/size_str.go
View file @
f015e2ea
package
build
import
(
"fmt"
"math/big"
)
var
byteSizeUnits
=
[]
string
{
"B"
,
"KiB"
,
"MiB"
,
"GiB"
,
"TiB"
,
"PiB"
,
"EiB"
,
"ZiB"
}
func
SizeStr
(
bi
*
big
.
Int
)
string
{
r
:=
new
(
big
.
Rat
)
.
SetInt
(
bi
)
den
:=
big
.
NewRat
(
1
,
1024
)
var
i
int
for
f
,
_
:=
r
.
Float64
();
f
>=
1024
&&
i
+
1
<
len
(
byteSizeUnits
);
f
,
_
=
r
.
Float64
()
{
i
++
r
=
r
.
Mul
(
r
,
den
)
}
f
,
_
:=
r
.
Float64
()
return
fmt
.
Sprintf
(
"%.4g %s"
,
f
,
byteSizeUnits
[
i
])
}
\ No newline at end of file
package
build
import
(
"fmt"
"math/big"
)
var
byteSizeUnits
=
[]
string
{
"B"
,
"KiB"
,
"MiB"
,
"GiB"
,
"TiB"
,
"PiB"
,
"EiB"
,
"ZiB"
}
func
SizeStr
(
bi
*
big
.
Int
)
string
{
r
:=
new
(
big
.
Rat
)
.
SetInt
(
bi
)
den
:=
big
.
NewRat
(
1
,
1024
)
var
i
int
for
f
,
_
:=
r
.
Float64
();
f
>=
1024
&&
i
+
1
<
len
(
byteSizeUnits
);
f
,
_
=
r
.
Float64
()
{
i
++
r
=
r
.
Mul
(
r
,
den
)
}
f
,
_
:=
r
.
Float64
()
return
fmt
.
Sprintf
(
"%.4g %s"
,
f
,
byteSizeUnits
[
i
])
}
build/storage/storage.go
View file @
f015e2ea
package
storage
import
(
"io"
"bytes"
"encoding/binary"
"io"
"golang.org/x/xerrors"
...
...
@@ -41,20 +41,20 @@ type SectorCids struct {
type
Piece
struct
{
Commitment
Hash
Size
abi
.
UnpaddedPieceSize
Size
abi
.
UnpaddedPieceSize
}
type
DecodedData
struct
{
HasPre
bool
PreHash
Hash
HasPre
bool
PreHash
Hash
Data
[]
byte
Data
[]
byte
PieceHash
[]
Hash
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,8 +132,8 @@ 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
))
}
\ No newline at end of file
}
build/util.go
View file @
f015e2ea
This diff is collapsed.
Click to expand it.
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"
)
...
...
@@ -37,18 +36,18 @@ func main() {
}
var
testSealAndWindowPoSt
=
&
cli
.
Command
{
Name
:
"test-all"
,
Usage
:
"Test Seal the sectors and generate window post"
,
Name
:
"test-all"
,
Usage
:
"Test Seal the sectors and generate window post"
,
Flags
:
[]
cli
.
Flag
{
&
cli
.
StringFlag
{
Name
:
"sector-size"
,
Value
:
"8MiB"
,
Usage
:
"size of the sectors in bytes"
,
Name
:
"sector-size"
,
Value
:
"8MiB"
,
Usage
:
"size of the sectors in bytes"
,
},
&
cli
.
IntFlag
{
Name
:
"num-agg"
,
Value
:
8
,
Usage
:
"How many window-post proofs used to aggregate"
,
Name
:
"num-agg"
,
Value
:
8
,
Usage
:
"How many window-post proofs used to aggregate"
,
},
},
Action
:
func
(
c
*
cli
.
Context
)
error
{
...
...
@@ -67,8 +66,8 @@ var testSealAndWindowPoSt = &cli.Command{
}
var
testSealCmd
=
&
cli
.
Command
{
Name
:
"test-seal"
,
Usage
:
"Test sealing the sectors"
,
Name
:
"test-seal"
,
Usage
:
"Test sealing the sectors"
,
Action
:
func
(
c
*
cli
.
Context
)
error
{
// Test 8MiB sector
err
:=
seal
.
TestSealAndUnseal
()
...
...
@@ -80,18 +79,18 @@ var testSealCmd = &cli.Command{
}
var
testSplitDataCmd
=
&
cli
.
Command
{
Name
:
"test-split"
,
Usage
:
"Test encode data into pieces"
,
Name
:
"test-split"
,
Usage
:
"Test encode data into pieces"
,
Flags
:
[]
cli
.
Flag
{
&
cli
.
StringFlag
{
Name
:
"sector-size"
,
Value
:
"8MiB"
,
Usage
:
"size of the sectors in bytes"
,
Name
:
"sector-size"
,
Value
:
"8MiB"
,
Usage
:
"size of the sectors in bytes"
,
},
&
cli
.
StringFlag
{
Name
:
"data-size"
,
Value
:
"256MiB"
,
Usage
:
"size of the input file in bytes"
,
Name
:
"data-size"
,
Value
:
"256MiB"
,
Usage
:
"size of the input file in bytes"
,
},
},
Action
:
func
(
c
*
cli
.
Context
)
error
{
...
...
@@ -111,4 +110,4 @@ var testSplitDataCmd = &cli.Command{
}
return
nil
},
}
\ No newline at end of file
}
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
{
registered_proof
:
(
t
)
.into
(),
proof_len
:
proof
.len
(),
proof_ptr
:
proof
.as_ptr
(),
};
mem
::
forget
(
proof
);
out
})
.collect
();
let
(
t
,
proof
)
=
output
;
let
postProof
=
fil_PoStProof
{
registered_proof
:
(
t
)
.into
(),
proof_len
:
proof
.len
(),
proof_ptr
:
proof
.as_ptr
(),
};
mem
::
forget
(
proof
);
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
{
registered_proof
:
(
t
)
.into
(),
proof_len
:
proof
.len
(),
proof_ptr
:
proof
.as_ptr
(),
};
mem
::
forget
(
proof
);
out
})
.collect
();
let
(
t
,
proof
)
=
output
;
let
postProof
=
fil_PoStProof
{
registered_proof
:
(
t
)
.into
(),
proof_len
:
proof
.len
(),
proof_ptr
:
proof
.as_ptr
(),
};
mem
::
forget
(
proof
);
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
module fil_integrate
go 1.16
require (
github.com/detailyang/go-fallocate v0.0.0-20180908115635-432fa640bd2e
github.com/docker/go-units v0.4.0
github.com/elastic/go-sysinfo v1.7.0
github.com/filecoin-project/filecoin-ffi v0.30.4-0.20200910194244-f640612a1a1f
github.com/filecoin-project/go-bitfield v0.2.4
github.com/filecoin-project/go-fil-commcid v0.1.0
github.com/filecoin-project/go-state-types v0.1.1-0.20210506134452-99b279731c48
github.com/google/uuid v1.2.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-multierror v1.1.1
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-datastore v0.4.5
github.com/ipfs/go-log/v2 v2.3.0
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/mitchellh/go-homedir v1.1.0
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
github.com/whyrusleeping/cbor-gen v0.0.0-20210422071115-ad5b82622e0f
go.opencensus.io v0.23.0
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
github.com/libp2p/go-libp2p-core v0.8.5
github.com/minio/sha256-simd v0.1.1
)
replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi
replace github.com/filecoin-project/go-state-types => ./extern/go-state-types
module fil_integrate
go 1.16
require (
github.com/detailyang/go-fallocate v0.0.0-20180908115635-432fa640bd2e
github.com/docker/go-units v0.4.0
github.com/elastic/go-sysinfo v1.7.0
github.com/filecoin-project/filecoin-ffi v0.30.4-0.20200910194244-f640612a1a1f
github.com/filecoin-project/go-bitfield v0.2.4
github.com/filecoin-project/go-fil-commcid v0.1.0
github.com/filecoin-project/go-state-types v0.1.1-0.20210506134452-99b279731c48
github.com/google/uuid v1.2.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-multierror v1.1.1
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-datastore v0.4.5
github.com/ipfs/go-log/v2 v2.3.0
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1
github.com/mitchellh/go-homedir v1.1.0
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
github.com/whyrusleeping/cbor-gen v0.0.0-20210422071115-ad5b82622e0f
go.opencensus.io v0.23.0
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
github.com/libp2p/go-libp2p-core v0.8.5
github.com/minio/sha256-simd v0.1.1
)
replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi
replace github.com/filecoin-project/go-state-types => ./extern/go-state-types
seal/basicfs/fs.go
View file @
f015e2ea
...
...
@@ -7,7 +7,7 @@ import (
"sync"
"github.com/filecoin-project/go-state-types/abi"
"fil_integrate/build/storage"
"fil_integrate/build/storiface"
)
...
...
seal/seal_api.go
View file @
f015e2ea
This diff is collapsed.
Click to expand it.
seal/test.go
View file @
f015e2ea
This diff is collapsed.
Click to expand it.
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,37 +24,37 @@ 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
// generate the sealed sector and sector commitment(commd, commr)
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
)
AcquireSector
(
ctx
context
.
Context
,
id
storage
.
SectorRef
,
existing
storiface
.
SectorFileType
,
allocate
storiface
.
SectorFileType
,
ptype
storiface
.
PathType
)
(
storiface
.
SectorPaths
,
func
(),
error
)
}
var
_
SectorManager
=
&
basicfs
.
Manager
{}
\ No newline at end of file
var
_
SectorManager
=
&
basicfs
.
Manager
{}
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