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
9ced0107
Commit
9ced0107
authored
3 years ago
by
董子豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aggretion
parent
bd2eb1aa
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
100 additions
and
31 deletions
+100
-31
main.go
cmd/lotus-bench/main.go
+42
-3
proofs.go
extern/filecoin-ffi/proofs.go
+2
-2
types.go
extern/filecoin-ffi/types.go
+1
-1
aggregate_proof.rs
...oofs/fil-proofs-tooling/src/bin/benchy/aggregate_proof.rs
+2
-2
window_post.rs
...l-proofs/fil-proofs-tooling/src/bin/benchy/window_post.rs
+11
-22
fs.go
extern/sector-storage/ffiwrapper/basicfs/fs.go
+4
-0
sealer_cgo.go
extern/sector-storage/ffiwrapper/sealer_cgo.go
+36
-0
types.go
extern/sector-storage/ffiwrapper/types.go
+1
-0
filetype.go
extern/sector-storage/storiface/filetype.go
+1
-1
No files found.
cmd/lotus-bench/main.go
View file @
9ced0107
...
...
@@ -117,7 +117,8 @@ func main() {
Version
:
build
.
UserVersion
(),
Commands
:
[]
*
cli
.
Command
{
proveCmd
,
testCmd
,
testSealCmd
,
testAggregationCmd
,
sealBenchCmd
,
},
}
...
...
@@ -128,8 +129,8 @@ func main() {
}
}
var
testCmd
=
&
cli
.
Command
{
Name
:
"
interface-test
"
,
var
test
Seal
Cmd
=
&
cli
.
Command
{
Name
:
"
test-seal
"
,
Usage
:
"Test interface"
,
Action
:
func
(
c
*
cli
.
Context
)
error
{
err
:=
seal
.
TestSealAndUnseal
()
...
...
@@ -140,6 +141,44 @@ var testCmd = &cli.Command{
},
}
var
testAggregationCmd
=
&
cli
.
Command
{
Name
:
"test-aggregation"
,
Usage
:
"Test interface"
,
Flags
:
[]
cli
.
Flag
{
&
cli
.
StringFlag
{
Name
:
"sector-size"
,
Value
:
"2KiB"
,
Usage
:
"size of the sectors in bytes"
,
},
&
cli
.
IntFlag
{
Name
:
"num-sectors"
,
Value
:
4
,
Usage
:
"How many sectors used in single window post"
,
},
&
cli
.
IntFlag
{
Name
:
"num-agg"
,
Value
:
4
,
Usage
:
"How many window-post proofs used to aggregate"
,
},
},
Action
:
func
(
c
*
cli
.
Context
)
error
{
log
.
Info
(
"testing"
)
sectorSizeInt
,
err
:=
units
.
RAMInBytes
(
c
.
String
(
"sector-size"
))
if
err
!=
nil
{
return
err
}
sectorSize
:=
abi
.
SectorSize
(
sectorSizeInt
)
numSectors
:=
c
.
Int
(
"num-sectors"
)
numAggregate
:=
c
.
Int
(
"num-agg"
)
err
=
seal
.
TestAggregateWindowPoSt
(
sectorSize
,
numSectors
,
numAggregate
)
if
err
!=
nil
{
return
err
}
return
nil
},
}
var
sealBenchCmd
=
&
cli
.
Command
{
Name
:
"sealing"
,
Usage
:
"Benchmark seal and winning post and window post"
,
...
...
This diff is collapsed.
Click to expand it.
extern/filecoin-ffi/proofs.go
View file @
9ced0107
...
...
@@ -1263,12 +1263,12 @@ func to32ByteCommD(unsealedCID cid.Cid) (generated.Fil32ByteArray, error) {
}
func
to32ByteCommR
(
sealedCID
cid
.
Cid
)
(
generated
.
Fil32ByteArray
,
error
)
{
comm
D
,
err
:=
commcid
.
CIDToReplicaCommitmentV1
(
sealedCID
)
comm
R
,
err
:=
commcid
.
CIDToReplicaCommitmentV1
(
sealedCID
)
if
err
!=
nil
{
return
generated
.
Fil32ByteArray
{},
errors
.
Wrap
(
err
,
"failed to transform sealed CID to CommR"
)
}
return
to32ByteArray
(
comm
D
),
nil
return
to32ByteArray
(
comm
R
),
nil
}
func
to32ByteCommP
(
pieceCID
cid
.
Cid
)
(
generated
.
Fil32ByteArray
,
error
)
{
...
...
This diff is collapsed.
Click to expand it.
extern/filecoin-ffi/types.go
View file @
9ced0107
...
...
@@ -19,7 +19,7 @@ type AggregateWindowPostInfos struct{
ChallengedSectors
[]
proof5
.
SectorInfo
Arr
[]
uint
Proofs
[]
proof5
.
PoStProof
Randomnesses
[]
abi
.
Seal
Randomness
Randomnesses
[]
abi
.
PoSt
Randomness
SectorCount
uint
}
...
...
This diff is collapsed.
Click to expand it.
extern/rust-fil-proofs/fil-proofs-tooling/src/bin/benchy/aggregate_proof.rs
View file @
9ced0107
...
...
@@ -61,14 +61,14 @@ fn run_agg_proofs<Tree: 'static + MerkleTreeTrait>(
for
k
in
0
..
2
{
let
sector_id
=
(
index
*
2
+
k
)
%
2048
;
let
cache_dir
=
root_dir
.join
(
format!
(
"cache-{}"
,
sector_id
));
let
(
comm_
d
,
comm_r_last
)
=
{
let
(
comm_
c
,
comm_r_last
)
=
{
let
p_aux_path
=
cache_dir
.join
(
CacheKey
::
PAux
.to_string
());
let
p_aux_bytes
=
fs
::
read
(
&
p_aux_path
)
?
;
deserialize
(
&
p_aux_bytes
)
}
?
;
let
commr
:
<
Tree
::
Hasher
as
Hasher
>
::
Domain
=
<
Tree
::
Hasher
as
Hasher
>
::
Function
::
hash2
(
&
comm_
d
,
&
comm_r_last
);
<
Tree
::
Hasher
as
Hasher
>
::
Function
::
hash2
(
&
comm_
c
,
&
comm_r_last
);
let
comm_r
=
commitment_from_fr
(
commr
.into
());
let
sector_id
=
SectorId
::
from
(
sector_id
);
...
...
This diff is collapsed.
Click to expand it.
extern/rust-fil-proofs/fil-proofs-tooling/src/bin/benchy/window_post.rs
View file @
9ced0107
...
...
@@ -653,30 +653,19 @@ pub fn run_window_post_bench<Tree: 'static + MerkleTreeTrait>(
api_version
,
};
use
rayon
::
prelude
::
*
;
let
commit_inputs
:
Vec
<
Vec
<
Fr
>>
=
pub_replica_infos
.par_iter
()
.zip
(
randomnesses
.par_iter
())
.map
(|(
replica
,
randomness
)|
get_window_post_inputs
::
<
Tree
>
(
&
post_config
,
replica
,
randomness
,
PROVER_ID
))
.try_reduce
(
Vec
::
new
,
|
mut
acc
,
current
|
{
println!
(
"{:?}"
,
acc
);
acc
.extend
(
current
);
Ok
(
acc
)
})
?
;
// let start_time = Instant::now();
// let aggregate_proof = &aggregate_window_post_proofs::<Tree>(&post_config, randomnesses.as_slice(), proofs.as_slice(), 1)?;
// let aggregate_window_post_proofs_time = start_time.elapsed().as_millis();
let
start_time
=
Instant
::
now
();
let
aggregate_proof
=
&
aggregate_window_post_proofs
::
<
Tree
>
(
&
post_config
,
randomnesses
.as_slice
(),
proofs
.as_slice
(),
1
)
?
;
let
aggregate_window_post_proofs_time
=
start_time
.elapsed
()
.as_millis
();
//
let start_time = Instant::now();
//
let ok = verify_aggregate_window_post_proofs::<Tree>(&post_config, PROVER_ID, aggregate_proof.to_vec(), randomnesses.as_slice(), pub_replica_infos.as_slice())?;
//
let verify_aggregate_proofs_time = start_time.elapsed().as_millis();
let
start_time
=
Instant
::
now
();
let
ok
=
verify_aggregate_window_post_proofs
::
<
Tree
>
(
&
post_config
,
PROVER_ID
,
aggregate_proof
.to_vec
(),
randomnesses
.as_slice
(),
pub_replica_infos
.as_slice
())
?
;
let
verify_aggregate_proofs_time
=
start_time
.elapsed
()
.as_millis
();
//
if ok {
//
info!("aggregate proofs is true");
//
} else {
//
info!("aggregate proofs is false");
//
}
if
ok
{
info!
(
"aggregate proofs is true"
);
}
else
{
info!
(
"aggregate proofs is false"
);
}
// info!("#################################################");
// info!("generate {} window-post using {}", aggregate_count, generate_window_post_time);
...
...
This diff is collapsed.
Click to expand it.
extern/sector-storage/ffiwrapper/basicfs/fs.go
View file @
9ced0107
...
...
@@ -24,6 +24,10 @@ type Provider struct {
waitSector
map
[
sectorFile
]
chan
struct
{}
}
func
(
b
*
Provider
)
GetRoot
()
string
{
return
b
.
Root
}
func
(
b
*
Provider
)
AcquireSector
(
ctx
context
.
Context
,
id
storage
.
SectorRef
,
existing
storiface
.
SectorFileType
,
allocate
storiface
.
SectorFileType
,
ptype
storiface
.
PathType
,
numbers
...
int32
)
(
storiface
.
SectorPaths
,
func
(),
error
)
{
if
err
:=
os
.
Mkdir
(
filepath
.
Join
(
b
.
Root
,
storiface
.
FTUnsealed
.
String
()),
0755
);
err
!=
nil
&&
!
os
.
IsExist
(
err
)
{
// nolint
return
storiface
.
SectorPaths
{},
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
extern/sector-storage/ffiwrapper/sealer_cgo.go
View file @
9ced0107
...
...
@@ -10,6 +10,7 @@ import (
"math/bits"
"os"
"runtime"
"path/filepath"
"github.com/ipfs/go-cid"
"golang.org/x/xerrors"
...
...
@@ -40,7 +41,42 @@ func New(sectors SectorProvider) (*Sealer, error) {
func
(
sb
*
Sealer
)
NewSector
(
ctx
context
.
Context
,
sector
storage
.
SectorRef
)
error
{
// TODO: Allocate the sector here instead of in addpiece
return
nil
}
func
(
sb
*
Sealer
)
GetCommRFromDir
(
ctx
context
.
Context
,
sectorID
abi
.
SectorID
)
(
cid
.
Cid
,
error
)
{
commr
:=
make
([]
byte
,
32
)
path
:=
filepath
.
Join
(
sb
.
sectors
.
GetRoot
(),
"cache"
,
storiface
.
SectorName
(
sectorID
),
"commr"
)
out
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_RDONLY
,
0644
)
if
err
!=
nil
{
return
cid
.
Cid
{},
err
}
defer
out
.
Close
()
_
,
err
=
out
.
Read
(
commr
[
:
])
if
err
!=
nil
{
return
cid
.
Cid
{},
err
}
return
commcid
.
ReplicaCommitmentV1ToCID
(
commr
[
:
])
}
func
(
sb
*
Sealer
)
PutCommRIntoDir
(
ctx
context
.
Context
,
sectorID
abi
.
SectorID
,
sealedCID
cid
.
Cid
)
error
{
commr
,
err
:=
commcid
.
CIDToReplicaCommitmentV1
(
sealedCID
)
if
err
!=
nil
{
return
err
}
path
:=
filepath
.
Join
(
sb
.
sectors
.
GetRoot
(),
"cache"
,
storiface
.
SectorName
(
sectorID
),
"commr"
)
out
,
err
:=
os
.
OpenFile
(
path
,
os
.
O_CREATE
|
os
.
O_RDWR
,
0644
)
if
err
!=
nil
{
return
err
}
defer
out
.
Close
()
_
,
err
=
out
.
Write
(
commr
[
:
])
if
err
!=
nil
{
return
err
}
return
nil
}
...
...
This diff is collapsed.
Click to expand it.
extern/sector-storage/ffiwrapper/types.go
View file @
9ced0107
...
...
@@ -52,6 +52,7 @@ type Prover interface {
type
SectorProvider
interface
{
// * 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
GetRoot
()
(
string
)
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
,
numbers
...
int32
)
(
storiface
.
SectorPaths
,
func
(),
error
)
}
...
...
This diff is collapsed.
Click to expand it.
extern/sector-storage/storiface/filetype.go
View file @
9ced0107
...
...
@@ -112,7 +112,7 @@ func ParseSectorID(baseName string) (abi.SectorID, error) {
func
SectorName
(
sid
abi
.
SectorID
,
numbers
...
int32
)
string
{
out
:=
fmt
.
Sprintf
(
"s-t0%d-%d"
,
sid
.
Miner
,
sid
.
Number
)
for
_
,
number
:=
range
numbers
{
out
=
fmt
.
Sprintf
(
"%s-%d"
,
number
)
out
=
fmt
.
Sprintf
(
"%s-%d"
,
out
,
number
)
}
return
out
}
...
...
This diff is collapsed.
Click to expand it.
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