Skip to content

Commit 144f1be

Browse files
feat: implement windowed porep
1 parent c063fa5 commit 144f1be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2217
-1086
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ jobs:
181181
- run:
182182
name: Ensure existence of Groth parameters and keys on remote host
183183
command: |
184-
./fil-proofs-tooling/scripts/paramcache-remote.sh "${CIRCLE_BRANCH}" "${BENCHMARK_SERVER_SSH_USERNAME}@${BENCHMARK_SERVER_IP_ADDR}" "-z=$((1024*1024*1024))"
184+
./fil-proofs-tooling/scripts/paramcache-remote.sh "${CIRCLE_BRANCH}" "${BENCHMARK_SERVER_SSH_USERNAME}@${BENCHMARK_SERVER_IP_ADDR}" "-z=$((1024*1024*1024)):$(((128*1024*1024)/32))"
185185
no_output_timeout: 60m
186186
- run:
187187
name: Run hash-constraints benchmarks on remote host
@@ -365,7 +365,8 @@ workflows:
365365
- cargo_fetch
366366
filters:
367367
branches:
368-
only: master
368+
only:
369+
- master
369370
- build_linux_release:
370371
requires:
371372
- cargo_fetch

fil-proofs-tooling/src/bin/benchy/election_post.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ impl Report {
5252
}
5353
}
5454

55-
pub fn run(sector_size: usize) -> Result<(), failure::Error> {
56-
info!("Benchy Election PoSt: sector-size={}", sector_size);
55+
pub fn run(sector_size: usize, window_size_nodes: usize) -> Result<(), failure::Error> {
56+
info!(
57+
"Benchy Election PoSt: sector-size={} - window_size={}",
58+
sector_size,
59+
window_size_nodes * 32
60+
);
5761

5862
let sector_size_unpadded_bytes_ammount =
5963
UnpaddedBytesAmount::from(PaddedBytesAmount(sector_size as u64));
@@ -95,7 +99,11 @@ pub fn run(sector_size: usize) -> Result<(), failure::Error> {
9599
let piece_infos = vec![piece_info];
96100

97101
// Replicate the staged sector, write the replica file to `sealed_path`.
98-
let porep_config = PoRepConfig(SectorSize(sector_size as u64), N_PARTITIONS);
102+
let porep_config = PoRepConfig {
103+
sector_size: SectorSize(sector_size as u64),
104+
partitions: N_PARTITIONS,
105+
window_size_nodes,
106+
};
99107
let cache_dir = tempfile::tempdir().unwrap();
100108
let sector_id = SectorId::from(SECTOR_ID);
101109
let ticket = [0u8; 32];
@@ -137,7 +145,10 @@ pub fn run(sector_size: usize) -> Result<(), failure::Error> {
137145
);
138146

139147
// Measure PoSt generation and verification.
140-
let post_config = PoStConfig(SectorSize(sector_size as u64));
148+
let post_config = PoStConfig {
149+
sector_size: SectorSize(sector_size as u64),
150+
window_size_nodes,
151+
};
141152

142153
let challenge_count = 1u64;
143154

fil-proofs-tooling/src/bin/benchy/main.rs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,27 @@ fn main() {
2020
.takes_value(true),
2121
)
2222
.arg(
23-
Arg::with_name("challenges")
24-
.long("challenges")
25-
.help("How many challenges to execute")
23+
Arg::with_name("window-size")
24+
.long("window-size")
25+
.help("The window size in bytes")
26+
.default_value("4096")
27+
.takes_value(true),
28+
)
29+
.arg(
30+
Arg::with_name("wrapper-challenges")
31+
.long("wrapper-challenges")
32+
.help("How many wrapper challenges to execute")
2633
.default_value("1")
2734
.takes_value(true),
2835
)
36+
.arg(
37+
Arg::with_name("window-challenges")
38+
.long("window-challenges")
39+
.help("How many window challenges to execute")
40+
.default_value("1")
41+
.takes_value(true),
42+
)
43+
2944
.arg(
3045
Arg::with_name("hasher")
3146
.long("hasher")
@@ -97,6 +112,13 @@ fn main() {
97112
.required(true)
98113
.help("The data size in KiB")
99114
.takes_value(true),
115+
)
116+
.arg(
117+
Arg::with_name("window-size")
118+
.long("window-size")
119+
.help("The window size in bytes")
120+
.default_value("4096")
121+
.takes_value(true),
100122
);
101123

102124
let hash_cmd = SubCommand::with_name("hash-constraints")
@@ -114,10 +136,16 @@ fn main() {
114136
Ok(())
115137
.and_then(|_| {
116138
let layers = value_t!(m, "layers", usize)?;
139+
let window_size_bytes = value_t!(m, "window-size", usize)
140+
.expect("could not convert `window-size` CLI argument to `usize`");
141+
let window_size_nodes = window_size_bytes / 32;
142+
117143
stacked::run(stacked::RunOpts {
118144
bench: m.is_present("bench"),
119145
bench_only: m.is_present("bench-only"),
120-
challenges: value_t!(m, "challenges", usize)?,
146+
window_size_nodes,
147+
window_challenges: value_t!(m, "window-challenges", usize)?,
148+
wrapper_challenges: value_t!(m, "wrapper-challenges", usize)?,
121149
circuit: m.is_present("circuit"),
122150
dump: m.is_present("dump"),
123151
extract: m.is_present("extract"),
@@ -136,7 +164,10 @@ fn main() {
136164
let sector_size_kibs = value_t!(m, "size", usize)
137165
.expect("could not convert `size` CLI argument to `usize`");
138166
let sector_size = sector_size_kibs * 1024;
139-
election_post::run(sector_size).expect("election-post failed");
167+
let window_size_bytes = value_t!(m, "window-size", usize)
168+
.expect("could not convert `window-size` CLI argument to `usize`");
169+
let window_size_nodes = window_size_bytes / 32;
170+
election_post::run(sector_size, window_size_nodes).expect("election-post failed");
140171
}
141172
("hash-constraints", Some(_m)) => {
142173
hash_fns::run().expect("hash-constraints failed");

fil-proofs-tooling/src/bin/benchy/stacked.rs

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ use storage_proofs::hasher::{Blake2sHasher, Domain, Hasher, PedersenHasher, Sha2
2121
use storage_proofs::porep::PoRep;
2222
use storage_proofs::proof::ProofScheme;
2323
use storage_proofs::stacked::{
24-
self, CacheKey, ChallengeRequirements, LayerChallenges, StackedDrg, TemporaryAuxCache,
25-
EXP_DEGREE,
24+
self, CacheKey, ChallengeRequirements, StackedConfig, StackedDrg, TemporaryAuxCache, EXP_DEGREE,
2625
};
2726
use tempfile::TempDir;
2827

@@ -46,7 +45,7 @@ fn file_backed_mmap_from_zeroes(n: usize, use_tmp: bool) -> Result<MmapMut, fail
4645
}
4746

4847
fn dump_proof_bytes<H: Hasher>(
49-
all_partition_proofs: &[Vec<stacked::Proof<H, Sha256Hasher>>],
48+
all_partition_proofs: &[stacked::Proof<H, Sha256Hasher>],
5049
) -> Result<(), failure::Error> {
5150
let file = OpenOptions::new()
5251
.write(true)
@@ -62,8 +61,9 @@ fn dump_proof_bytes<H: Hasher>(
6261
#[derive(Clone, Debug)]
6362
struct Params {
6463
samples: usize,
64+
window_size_nodes: usize,
6565
data_size: usize,
66-
layer_challenges: LayerChallenges,
66+
config: StackedConfig,
6767
partitions: usize,
6868
circuit: bool,
6969
groth: bool,
@@ -82,10 +82,10 @@ impl From<Params> for Inputs {
8282
partitions: p.partitions,
8383
hasher: p.hasher.clone(),
8484
samples: p.samples,
85-
layers: p.layer_challenges.layers(),
86-
partition_challenges: p.layer_challenges.challenges_count_all(),
87-
total_challenges: p.layer_challenges.challenges_count_all() * p.partitions,
88-
layer_challenges: p.layer_challenges,
85+
layers: p.config.layers(),
86+
partition_challenges: p.config.window_challenges.challenges_count_all(),
87+
total_challenges: p.config.window_challenges.challenges_count_all() * p.partitions,
88+
config: p.config,
8989
}
9090
}
9191
}
@@ -110,7 +110,7 @@ where
110110
let Params {
111111
samples,
112112
data_size,
113-
layer_challenges,
113+
config,
114114
partitions,
115115
circuit,
116116
groth,
@@ -119,12 +119,13 @@ where
119119
use_tmp,
120120
dump_proofs,
121121
bench_only,
122+
window_size_nodes,
122123
..
123124
} = &params;
124125

125126
// MT for original data is always named tree-d, and it will be
126127
// referenced later in the process as such.
127-
let config = StoreConfig::new(
128+
let store_config = StoreConfig::new(
128129
cache_dir.path(),
129130
CacheKey::CommDTree.to_string(),
130131
DEFAULT_CACHED_ABOVE_BASE_LAYER,
@@ -142,7 +143,8 @@ where
142143
degree: BASE_DEGREE,
143144
expansion_degree: EXP_DEGREE,
144145
seed: new_seed(),
145-
layer_challenges: layer_challenges.clone(),
146+
config: config.clone(),
147+
window_size_nodes: *window_size_nodes,
146148
};
147149

148150
let pp = StackedDrg::<H, Sha256Hasher>::setup(&sp)?;
@@ -163,7 +165,7 @@ where
163165
&replica_id,
164166
&mut data,
165167
None,
166-
Some(config.clone()),
168+
Some(store_config.clone()),
167169
)?;
168170

169171
let pb = stacked::PublicInputs::<H::Domain, <Sha256Hasher as Hasher>::Domain> {
@@ -292,7 +294,7 @@ where
292294
&pp,
293295
&replica_id,
294296
&data,
295-
Some(config.clone()),
297+
Some(store_config.clone()),
296298
)
297299
.map_err(|err| err.into())
298300
})?;
@@ -348,6 +350,7 @@ fn do_circuit_work<H: 'static + Hasher>(
348350
};
349351

350352
if *bench || *circuit {
353+
info!("Generating blank circuit");
351354
let mut cs = MetricCS::<Bls12>::new();
352355
<StackedCompound as CompoundProof<_, StackedDrg<H, Sha256Hasher>, _>>::blank_circuit(&pp)
353356
.synthesize(&mut cs)?;
@@ -357,6 +360,7 @@ fn do_circuit_work<H: 'static + Hasher>(
357360
}
358361

359362
if *groth {
363+
info!("Generating Groth Proof");
360364
let pub_inputs = pub_in.expect("missing public inputs");
361365
let priv_inputs = priv_in.expect("missing private inputs");
362366

@@ -438,7 +442,7 @@ struct Inputs {
438442
layers: usize,
439443
partition_challenges: usize,
440444
total_challenges: usize,
441-
layer_challenges: LayerChallenges,
445+
config: StackedConfig,
442446
}
443447

444448
#[derive(Serialize, Default)]
@@ -484,7 +488,9 @@ impl Report {
484488
pub struct RunOpts {
485489
pub bench: bool,
486490
pub bench_only: bool,
487-
pub challenges: usize,
491+
pub window_size_nodes: usize,
492+
pub window_challenges: usize,
493+
pub wrapper_challenges: usize,
488494
pub circuit: bool,
489495
pub dump: bool,
490496
pub extract: bool,
@@ -498,10 +504,10 @@ pub struct RunOpts {
498504
}
499505

500506
pub fn run(opts: RunOpts) -> Result<(), failure::Error> {
501-
let layer_challenges = LayerChallenges::new(opts.layers, opts.challenges);
507+
let config = StackedConfig::new(opts.layers, opts.window_challenges, opts.wrapper_challenges);
502508

503509
let params = Params {
504-
layer_challenges,
510+
config,
505511
data_size: opts.size * 1024,
506512
partitions: opts.partitions,
507513
use_tmp: !opts.no_tmp,
@@ -512,6 +518,7 @@ pub fn run(opts: RunOpts) -> Result<(), failure::Error> {
512518
circuit: opts.circuit,
513519
extract: opts.extract,
514520
hasher: opts.hasher,
521+
window_size_nodes: opts.window_size_nodes,
515522
samples: 5,
516523
};
517524

fil-proofs-tooling/src/bin/micro.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ fn parse_criterion_out(s: impl AsRef<str>) -> Result<Vec<CriterionResult>, failu
6666
let median_re = make_detail_re("median");
6767
let med_abs_dev_re = make_detail_re(r"med\. abs\. dev\.");
6868

69+
#[allow(clippy::type_complexity)]
6970
let mut current: Option<(
7071
String,
7172
Option<u32>,

filecoin-proofs/examples/stacked.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ use storage_proofs::hasher::{Blake2sHasher, Domain, Hasher, PedersenHasher, Sha2
3434
use storage_proofs::porep::PoRep;
3535
use storage_proofs::proof::ProofScheme;
3636
use storage_proofs::stacked::{
37-
self, CacheKey, ChallengeRequirements, LayerChallenges, StackedDrg, TemporaryAuxCache,
38-
EXP_DEGREE,
37+
self, CacheKey, ChallengeRequirements, StackedConfig, StackedDrg, TemporaryAuxCache, EXP_DEGREE,
3938
};
4039

4140
// We can only one of the profilers at a time, either CPU (`profile`)
@@ -129,7 +128,7 @@ pub fn file_backed_mmap_from(data: &[u8]) -> MmapMut {
129128
unsafe { MmapOptions::new().map_mut(&tmpfile).unwrap() }
130129
}
131130

132-
fn dump_proof_bytes<H: Hasher, G: Hasher>(all_partition_proofs: &[Vec<stacked::Proof<H, G>>]) {
131+
fn dump_proof_bytes<H: Hasher, G: Hasher>(all_partition_proofs: &[stacked::Proof<H, G>]) {
133132
let file = OpenOptions::new()
134133
.write(true)
135134
.create(true)
@@ -144,7 +143,7 @@ fn dump_proof_bytes<H: Hasher, G: Hasher>(all_partition_proofs: &[Vec<stacked::P
144143

145144
fn do_the_work<H: 'static>(
146145
data_size: usize,
147-
layer_challenges: LayerChallenges,
146+
config: StackedConfig,
148147
partitions: usize,
149148
circuit: bool,
150149
groth: bool,
@@ -164,8 +163,8 @@ fn do_the_work<H: 'static>(
164163
info!("data size: {}", prettyb(data_size));
165164
info!("m: {}", m);
166165
info!("expansion_degree: {}", expansion_degree);
167-
info!("layer_challenges: {:?}", layer_challenges);
168-
info!("layers: {}", layer_challenges.layers());
166+
info!("config: {:?}", config);
167+
info!("layers: {}", config.layers());
169168
info!("partitions: {}", partitions);
170169
info!("circuit: {:?}", circuit);
171170
info!("groth: {:?}", groth);
@@ -179,7 +178,8 @@ fn do_the_work<H: 'static>(
179178
degree: m,
180179
expansion_degree,
181180
seed: new_seed(),
182-
layer_challenges: layer_challenges.clone(),
181+
config: config.clone(),
182+
window_size_nodes: nodes / 4,
183183
};
184184

185185
info!("running setup");
@@ -494,7 +494,8 @@ fn main() {
494494
.get_matches();
495495

496496
let data_size = value_t!(matches, "size", usize).unwrap() * 1024;
497-
let challenge_count = value_t!(matches, "challenges", usize).unwrap();
497+
let window_challenge_count = value_t!(matches, "window-challenges", usize).unwrap();
498+
let wrapper_challenge_count = value_t!(matches, "wrapper-challenges", usize).unwrap();
498499
let hasher = value_t!(matches, "hasher", String).unwrap();
499500
let layers = value_t!(matches, "layers", usize).unwrap();
500501
let partitions = value_t!(matches, "partitions", usize).unwrap();
@@ -506,14 +507,14 @@ fn main() {
506507
let circuit = matches.is_present("circuit");
507508
let extract = matches.is_present("extract");
508509

509-
let challenges = LayerChallenges::new(layers, challenge_count);
510+
let config = StackedConfig::new(layers, window_challenge_count, wrapper_challenge_count);
510511

511512
info!("hasher: {}", hasher);
512513
match hasher.as_ref() {
513514
"pedersen" => {
514515
do_the_work::<PedersenHasher>(
515516
data_size,
516-
challenges,
517+
config,
517518
partitions,
518519
circuit,
519520
groth,
@@ -527,7 +528,7 @@ fn main() {
527528
"sha256" => {
528529
do_the_work::<Sha256Hasher>(
529530
data_size,
530-
challenges,
531+
config,
531532
partitions,
532533
circuit,
533534
groth,
@@ -541,7 +542,7 @@ fn main() {
541542
"blake2s" => {
542543
do_the_work::<Blake2sHasher>(
543544
data_size,
544-
challenges,
545+
config,
545546
partitions,
546547
circuit,
547548
groth,

0 commit comments

Comments
 (0)