ethash: implement Progpow (#9762)
* ethash: initial implementation of progpow * progpow: use wrapping arithmetic * progpow: cleanup comments * progpow: fix keccak_f800 * progpow: reorder definitions * progpow: general fixing * progpow: add basic tests from geth * progpow: generate c_dag and add test * progpow: fix progpow_init and progpow_loop * progpow: fix and add new test * progpow: tabify * progpow: add shared testvectors from geth and aleth * progpow: add benchmarks * progpow: don't read bytes from dag * ethash: use criterion for progpow benchmarks * progpow: dont borrow hash on fnv1a_hash * progpow: don't borrow operand on progpow merge * progpow: hardcode dag lookup function we only support light verification anyway * progpow: read double words directly from the dag * progpow: inline some small functions * progpow: remove some bounds checking from the main loop * progpow: remove unreachable match cases * progpow: remove bounds check in keccak_f800_round * progpow: fix ptr::swap * progpow: force loop unroll in keccak_f800_round * progpow: remove unnecessary branching in progpow_loop * progpow: force loop unroll in fill_mix * progpow: silence unused warning * progpow: dont run last keccak_f800_round out of the loop rustc generates the same assembly, it unrolls the loop * progpow: fix output of keccak_f800_short * ethcore: support progpow in ethash engine * ethash: fix typo * ethcore, ethash: fix tests * json: fix ethash spec tests * ethash: update quick_get_difficulty for progpow * ethash: drop light cache on progpow transition block * ethash: fix quick_get_difficulty tests * progpow: update to spec v0.9.0 * progpow: update to spec v0.9.1 * progpow: update to spec v0.9.2 * ethash: rename progpow benchmarks * fix Cargo.lock bad merge * ethash: only export modules for benchmarks * ethash: progpow: remove unsafe unchecked indexing * ethash: create enum for pow algorithm * ethash: box the progpow cdag * ethash: skip slow progpow test vectors on ci * ethash: don't skip progpow test vectors they don't take too long when running in release mode which is the case for CI. * ethash: progpow: update copyright date Co-Authored-By: andresilva <andre.beat@gmail.com> * ethcore: remove verification of ci-skip-tests on non-test builds
This commit is contained in:
@@ -113,6 +113,8 @@ pub struct EthashParams {
|
||||
pub block_reward_contract: Option<BlockRewardContract>,
|
||||
/// Difficulty bomb delays.
|
||||
pub difficulty_bomb_delays: BTreeMap<BlockNumber, BlockNumber>,
|
||||
/// Block to transition to progpow
|
||||
pub progpow_transition: u64,
|
||||
}
|
||||
|
||||
impl From<ethjson::spec::EthashParams> for EthashParams {
|
||||
@@ -153,6 +155,7 @@ impl From<ethjson::spec::EthashParams> for EthashParams {
|
||||
}),
|
||||
expip2_transition: p.expip2_transition.map_or(u64::max_value(), Into::into),
|
||||
expip2_duration_limit: p.expip2_duration_limit.map_or(30, Into::into),
|
||||
progpow_transition: p.progpow_transition.map_or(u64::max_value(), Into::into),
|
||||
block_reward_contract_transition: p.block_reward_contract_transition.map_or(0, Into::into),
|
||||
block_reward_contract: match (p.block_reward_contract_code, p.block_reward_contract_address) {
|
||||
(Some(code), _) => Some(BlockRewardContract::new_from_code(Arc::new(code.into()))),
|
||||
@@ -182,10 +185,12 @@ impl Ethash {
|
||||
machine: EthereumMachine,
|
||||
optimize_for: T,
|
||||
) -> Arc<Self> {
|
||||
let progpow_transition = ethash_params.progpow_transition;
|
||||
|
||||
Arc::new(Ethash {
|
||||
ethash_params,
|
||||
machine,
|
||||
pow: EthashManager::new(cache_dir.as_ref(), optimize_for.into()),
|
||||
pow: EthashManager::new(cache_dir.as_ref(), optimize_for.into(), progpow_transition),
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -320,7 +325,8 @@ impl Engine<EthereumMachine> for Arc<Ethash> {
|
||||
let difficulty = ethash::boundary_to_difficulty(&H256(quick_get_difficulty(
|
||||
&header.bare_hash().0,
|
||||
seal.nonce.low_u64(),
|
||||
&seal.mix_hash.0
|
||||
&seal.mix_hash.0,
|
||||
header.number() >= self.ethash_params.progpow_transition
|
||||
)));
|
||||
|
||||
if &difficulty < header.difficulty() {
|
||||
@@ -523,6 +529,7 @@ mod tests {
|
||||
block_reward_contract: None,
|
||||
block_reward_contract_transition: 0,
|
||||
difficulty_bomb_delays: BTreeMap::new(),
|
||||
progpow_transition: u64::max_value(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,7 @@
|
||||
|
||||
use ethjson;
|
||||
|
||||
#[cfg(all(not(test), feature = "ci-skip-tests"))]
|
||||
compile_error!("ci-skip-tests can only be enabled for testing builds.");
|
||||
|
||||
#[cfg(feature="ci-skip-issue")]
|
||||
#[cfg(feature="ci-skip-tests")]
|
||||
lazy_static!{
|
||||
pub static ref SKIP_TEST_STATE: ethjson::test::SkipStates = {
|
||||
let skip_data = include_bytes!("../../res/ethereum/tests-issues/currents.json");
|
||||
@@ -29,7 +26,7 @@ lazy_static!{
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(feature="ci-skip-issue"))]
|
||||
#[cfg(not(feature="ci-skip-tests"))]
|
||||
lazy_static!{
|
||||
pub static ref SKIP_TEST_STATE: ethjson::test::SkipStates = {
|
||||
ethjson::test::SkipStates::empty()
|
||||
|
||||
Reference in New Issue
Block a user