Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

ethash: implement Progpow #9762

Merged
merged 53 commits into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
2522e67
ethash: initial implementation of progpow
andresilva Sep 24, 2018
61f1922
progpow: use wrapping arithmetic
andresilva Oct 12, 2018
7c64f93
progpow: cleanup comments
andresilva Oct 12, 2018
4700ee8
progpow: fix keccak_f800
andresilva Oct 12, 2018
d252dd1
progpow: reorder definitions
andresilva Oct 12, 2018
fde1d2e
progpow: general fixing
andresilva Oct 12, 2018
3a37dc4
progpow: add basic tests from geth
andresilva Oct 15, 2018
2b14323
progpow: generate c_dag and add test
andresilva Oct 15, 2018
af1c0f6
progpow: fix progpow_init and progpow_loop
andresilva Oct 16, 2018
526daa6
progpow: fix and add new test
andresilva Oct 16, 2018
a19aa8d
progpow: tabify
andresilva Oct 16, 2018
7303491
progpow: add shared testvectors from geth and aleth
andresilva Oct 16, 2018
7630b33
progpow: add benchmarks
andresilva Oct 16, 2018
afe53ff
progpow: don't read bytes from dag
andresilva Oct 16, 2018
2fa0b3e
ethash: use criterion for progpow benchmarks
andresilva Oct 17, 2018
54a32a3
progpow: dont borrow hash on fnv1a_hash
andresilva Oct 17, 2018
025bc14
progpow: don't borrow operand on progpow merge
andresilva Oct 17, 2018
408d35e
progpow: hardcode dag lookup function
andresilva Oct 18, 2018
ae2d37e
progpow: read double words directly from the dag
andresilva Oct 18, 2018
e881d1f
progpow: inline some small functions
andresilva Oct 18, 2018
2f0c1a9
progpow: remove some bounds checking from the main loop
andresilva Oct 18, 2018
6c95cc8
progpow: remove unreachable match cases
andresilva Oct 18, 2018
2c28dc6
progpow: remove bounds check in keccak_f800_round
andresilva Oct 18, 2018
e22a9c3
progpow: fix ptr::swap
andresilva Oct 18, 2018
0e53756
progpow: force loop unroll in keccak_f800_round
andresilva Oct 18, 2018
7b77ab5
progpow: remove unnecessary branching in progpow_loop
andresilva Oct 18, 2018
9a9c710
progpow: force loop unroll in fill_mix
andresilva Oct 18, 2018
85c14cd
progpow: silence unused warning
andresilva Oct 18, 2018
a927d0b
progpow: dont run last keccak_f800_round out of the loop
andresilva Oct 19, 2018
2fc39b7
progpow: fix output of keccak_f800_short
andresilva Oct 19, 2018
e5c7d16
ethcore: support progpow in ethash engine
andresilva Oct 25, 2018
ecf937a
ethash: fix typo
andresilva Oct 25, 2018
04c5a8c
ethcore, ethash: fix tests
andresilva Oct 25, 2018
c5dc35a
json: fix ethash spec tests
andresilva Oct 26, 2018
a21993a
ethash: update quick_get_difficulty for progpow
andresilva Nov 8, 2018
9514419
ethash: drop light cache on progpow transition block
andresilva Nov 8, 2018
7c8873d
ethash: fix quick_get_difficulty tests
andresilva Nov 9, 2018
46aa1d4
progpow: update to spec v0.9.0
andresilva Dec 10, 2018
5f3c7be
progpow: update to spec v0.9.1
andresilva Dec 10, 2018
42b5194
progpow: update to spec v0.9.2
andresilva Dec 10, 2018
c8d074f
Merge branch 'master' into andre/progpow
andresilva Dec 10, 2018
af81890
ethash: rename progpow benchmarks
andresilva Dec 10, 2018
665e765
fix Cargo.lock bad merge
andresilva Dec 10, 2018
7afd3dc
Merge branch 'master' into andre/progpow
andresilva Dec 17, 2018
c7467b3
Merge branch 'master' into andre/progpow
andresilva Feb 18, 2019
4c00879
ethash: only export modules for benchmarks
andresilva Feb 18, 2019
89308fe
ethash: progpow: remove unsafe unchecked indexing
andresilva Feb 18, 2019
01bb1b5
ethash: create enum for pow algorithm
andresilva Feb 18, 2019
fea5b57
ethash: box the progpow cdag
andresilva Feb 19, 2019
0ca3119
ethash: skip slow progpow test vectors on ci
andresilva Feb 19, 2019
da02f9b
ethash: don't skip progpow test vectors
andresilva Feb 19, 2019
e30bd98
ethash: progpow: update copyright date
niklasad1 Feb 19, 2019
06551ce
ethcore: remove verification of ci-skip-tests on non-test builds
andresilva Feb 19, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
231 changes: 231 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ethash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ parking_lot = "0.6"
primal = "0.2.3"

[dev-dependencies]
criterion = "0.2"
rustc-hex = "1.0"
serde_json = "1.0"
tempdir = "0.3"

[features]
benches = []

[[bench]]
name = "ethash"
harness = false
87 changes: 87 additions & 0 deletions ethash/benches/ethash.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#[macro_use]
extern crate criterion;
extern crate ethash;
extern crate rustc_hex;
extern crate tempdir;

use criterion::Criterion;
use ethash::progpow;


use tempdir::TempDir;
use rustc_hex::FromHex;
use ethash::{NodeCacheBuilder, OptimizeFor};
use ethash::compute::light_compute;

fn bench_hashimoto_light(c: &mut Criterion) {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory);
let tempdir = TempDir::new("").unwrap();
let light = builder.light(&tempdir.path(), 1);
let h = FromHex::from_hex("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f").unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using hex! from hex_literal.

let mut hash = [0; 32];
hash.copy_from_slice(&h);

c.bench_function("hashimoto_light", move |b| {
b.iter(|| light_compute(&light, &hash, 0))
});
}

fn bench_progpow_light(c: &mut Criterion) {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory);
let tempdir = TempDir::new("").unwrap();
let cache = builder.new_cache(tempdir.into_path(), 0);

let h = FromHex::from_hex("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f").unwrap();
let mut hash = [0; 32];
hash.copy_from_slice(&h);

c.bench_function("progpow_light", move |b| {
b.iter(|| {
let c_dag = progpow::generate_cdag(cache.as_ref());
progpow::progpow(
hash,
0,
0,
cache.as_ref(),
&c_dag,
);
})
});
}

fn bench_progpow_optimal_light(c: &mut Criterion) {
let builder = NodeCacheBuilder::new(OptimizeFor::Memory);
let tempdir = TempDir::new("").unwrap();
let cache = builder.new_cache(tempdir.into_path(), 0);
let c_dag = progpow::generate_cdag(cache.as_ref());

let h = FromHex::from_hex("c9149cc0386e689d789a1c2f3d5d169a61a6218ed30e74414dc736e442ef3d1f").unwrap();
let mut hash = [0; 32];
hash.copy_from_slice(&h);

c.bench_function("progpow_optimal_light", move |b| {
b.iter(|| {
progpow::progpow(
hash,
0,
0,
cache.as_ref(),
&c_dag,
);
})
});
}

fn bench_keccak_f800_long(c: &mut Criterion) {
c.bench_function("keccak_f800_long(0, 0, 0)", |b| {
b.iter(|| progpow::keccak_f800_long([0; 32], 0, [0; 8]))
});
}

criterion_group!(benches,
bench_hashimoto_light,
bench_progpow_light,
bench_progpow_optimal_light,
bench_keccak_f800_long,
);
criterion_main!(benches);
Loading