From 7c4a65ef2a4e94dcfb09956ca2d168750a8f2c94 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Thu, 28 Mar 2019 22:07:55 +0100 Subject: [PATCH] changed progpow cpu implementation --- contrib/ethereum/libethash/ethash/ethash.h | 6 ++++++ contrib/ethereum/libethash/ethash/ethash.hpp | 9 +++++---- .../ethereum/libethash/ethash/hash_types.hpp | 2 +- contrib/ethereum/libethash/ethash/progpow.hpp | 11 ++++++++--- contrib/ethereum/libethash/ethash/version.h | 18 ++++++++++++++++++ contrib/ethereum/libethash/progpow.cpp | 2 +- 6 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 contrib/ethereum/libethash/ethash/version.h diff --git a/contrib/ethereum/libethash/ethash/ethash.h b/contrib/ethereum/libethash/ethash/ethash.h index fbcd3c85..b12f1aa9 100644 --- a/contrib/ethereum/libethash/ethash/ethash.h +++ b/contrib/ethereum/libethash/ethash/ethash.h @@ -19,6 +19,12 @@ extern "C" { #endif +/** + * The Ethash algorithm revision implemented as specified in the Ethash spec + * https://github.com/ethereum/wiki/wiki/Ethash. + */ +#define ETHASH_REVISION "23" + #define ETHASH_EPOCH_LENGTH 30000 #define ETHASH_LIGHT_CACHE_ITEM_SIZE 64 #define ETHASH_FULL_DATASET_ITEM_SIZE 128 diff --git a/contrib/ethereum/libethash/ethash/ethash.hpp b/contrib/ethereum/libethash/ethash/ethash.hpp index 532a8e4c..03f29afd 100644 --- a/contrib/ethereum/libethash/ethash/ethash.hpp +++ b/contrib/ethereum/libethash/ethash/ethash.hpp @@ -14,16 +14,17 @@ #pragma once +#include +#include + #include #include #include -#include "ethash/ethash.h" -#include "ethash/hash_types.hpp" - - namespace ethash { +constexpr auto revision = ETHASH_REVISION; + static constexpr int epoch_length = ETHASH_EPOCH_LENGTH; static constexpr int light_cache_item_size = ETHASH_LIGHT_CACHE_ITEM_SIZE; static constexpr int full_dataset_item_size = ETHASH_FULL_DATASET_ITEM_SIZE; diff --git a/contrib/ethereum/libethash/ethash/hash_types.hpp b/contrib/ethereum/libethash/ethash/hash_types.hpp index 21027ba2..cb9c3f10 100644 --- a/contrib/ethereum/libethash/ethash/hash_types.hpp +++ b/contrib/ethereum/libethash/ethash/hash_types.hpp @@ -4,7 +4,7 @@ #pragma once -#include "ethash/hash_types.h" +#include namespace ethash { diff --git a/contrib/ethereum/libethash/ethash/progpow.hpp b/contrib/ethereum/libethash/ethash/progpow.hpp index f7768778..81e6dbaa 100644 --- a/contrib/ethereum/libethash/ethash/progpow.hpp +++ b/contrib/ethereum/libethash/ethash/progpow.hpp @@ -14,11 +14,16 @@ namespace progpow { using namespace ethash; // Include ethash namespace. -constexpr int period_length = 10; + +/// The ProgPoW algorithm revision implemented as specified in the spec +/// https://github.com/ifdefelse/ProgPOW#change-history. +constexpr auto revision = "0.9.2"; + +constexpr int period_length = 50; constexpr uint32_t num_regs = 32; constexpr size_t num_lanes = 16; -constexpr int num_cache_accesses = 11; -constexpr int num_math_operations = 18; +constexpr int num_cache_accesses = 12; +constexpr int num_math_operations = 20; constexpr size_t l1_cache_size = 16 * 1024; constexpr size_t l1_cache_num_items = l1_cache_size / sizeof(uint32_t); diff --git a/contrib/ethereum/libethash/ethash/version.h b/contrib/ethereum/libethash/ethash/version.h new file mode 100644 index 00000000..ba45c734 --- /dev/null +++ b/contrib/ethereum/libethash/ethash/version.h @@ -0,0 +1,18 @@ +/* ethash: C/C++ implementation of Ethash, the Ethereum Proof of Work algorithm. + * Copyright 2019 Pawel Bylica. + * Licensed under the Apache License, Version 2.0. + */ + +#pragma once + +/** The ethash library version. */ +#define ETHASH_VERSION "0.5.0-alpha.0" + +#ifdef __cplusplus +namespace ethash +{ +/// The ethash library version. +constexpr auto version = ETHASH_VERSION; + +} // namespace ethash +#endif diff --git a/contrib/ethereum/libethash/progpow.cpp b/contrib/ethereum/libethash/progpow.cpp index e311f37e..fd709e8f 100644 --- a/contrib/ethereum/libethash/progpow.cpp +++ b/contrib/ethereum/libethash/progpow.cpp @@ -95,7 +95,7 @@ mix_rng_state::mix_rng_state(uint64_t seed) noexcept rng = kiss99{z, w, jsr, jcong}; // Create random permutations of mix destinations / sources. - // Uses Fisher–Yates shuffle. + // Uses Fisher-Yates shuffle. for (uint32_t i = 0; i < num_regs; ++i) { dst_seq[i] = i;