From a2c74d88cca14f20194039fe51f27e16c0a3af16 Mon Sep 17 00:00:00 2001 From: "crypro.zoidberg" Date: Mon, 15 Apr 2019 00:56:07 +0200 Subject: [PATCH] added more debug info --- binding.gyp | 10 ++++++++-- src/currency_core/basic_pow_helpers.cpp | 18 +++++++++++------- src/currency_core/basic_pow_helpers.h | 3 ++- src/main.cc | 23 ++++++++++++++++++++++- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/binding.gyp b/binding.gyp index d74a28b..f701ea7 100644 --- a/binding.gyp +++ b/binding.gyp @@ -18,9 +18,15 @@ "src/contrib/ethereum/libethash/ethash.cpp", "src/contrib/ethereum/libethash/keccak.c", "src/contrib/ethereum/libethash/keccakf800.c", - "src/contrib/ethereum/libethash/keccakf800.c", "src/contrib/ethereum/libethash/progpow.cpp", - "src/contrib/ethereum/libethash/managed.cpp" + "src/contrib/ethereum/libethash/managed.cpp", + "src/currency_core/currency_format_utils_transactions.cpp", + "src/currency_core/genesis.cpp", + "src/currency_core/genesis_acc.cpp", + "src/crypto/random.c", + "src/contrib/ethereum/libethash/keccakf1600.c", + "src/contrib/ethereum/libethash/managed.cpp", + "src/contrib/ethereum/libethash/primes.c" ], "include_dirs": [ "src", diff --git a/src/currency_core/basic_pow_helpers.cpp b/src/currency_core/basic_pow_helpers.cpp index 94af36d..6b3e53f 100644 --- a/src/currency_core/basic_pow_helpers.cpp +++ b/src/currency_core/basic_pow_helpers.cpp @@ -47,16 +47,24 @@ namespace currency return result; } //-------------------------------------------------------------- - crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_long_ash, uint64_t nonce) + crypto::hash get_block_longhash(uint64_t height, const crypto::hash& block_header_hash, uint64_t nonce) { int epoch = ethash_height_to_epoch(height); const auto& context = progpow::get_global_epoch_context_full(static_cast(epoch)); - auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_long_ash, nonce); + auto res_eth = progpow::hash(context, height, *(ethash::hash256*)&block_header_hash, nonce); crypto::hash result = currency::null_hash; memcpy(&result.data, &res_eth.final_hash, sizeof(res_eth.final_hash)); return result; } //--------------------------------------------------------------- + crypto::hash get_block_header_mining_hash(const block& b) + { + blobdata bd = get_block_hashing_blob(b); + + access_nonce_in_block_blob(bd) = 0; + return crypto::cn_fast_hash(bd.data(), bd.size()); + } + //--------------------------------------------------------------- void get_block_longhash(const block& b, crypto::hash& res) { /* @@ -65,11 +73,7 @@ namespace currency To achieve the same effect we make blob of data from block in normal way, but then set to zerro nonce inside serialized buffer, and then pass this nonce to ethash algo as a second argument, as it expected. */ - blobdata bd = get_block_hashing_blob(b); - - access_nonce_in_block_blob(bd) = 0; - crypto::hash bl_hash = crypto::cn_fast_hash(bd.data(), bd.size()); - + crypto::hash bl_hash = get_block_header_mining_hash(b); res = get_block_longhash(get_block_height(b), bl_hash, b.nonce); } //--------------------------------------------------------------- diff --git a/src/currency_core/basic_pow_helpers.h b/src/currency_core/basic_pow_helpers.h index 4bea271..32ded45 100644 --- a/src/currency_core/basic_pow_helpers.h +++ b/src/currency_core/basic_pow_helpers.h @@ -29,7 +29,8 @@ namespace currency { int ethash_height_to_epoch(uint64_t height); crypto::hash ethash_epoch_to_seed(int epoch); - crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_long_ash, uint64_t nonce); + crypto::hash get_block_header_mining_hash(const block& b); + crypto::hash get_block_longhash(uint64_t h, const crypto::hash& block_header_hash, uint64_t nonce); void get_block_longhash(const block& b, crypto::hash& res); crypto::hash get_block_longhash(const block& b); diff --git a/src/main.cc b/src/main.cc index f3a6810..26f8e82 100644 --- a/src/main.cc +++ b/src/main.cc @@ -199,8 +199,18 @@ void get_hash_from_block_template_with_extra(const Nan::FunctionCallbackInfo& ar crypto::hash h = currency::get_block_hash(b); + + //@#@ debug output + std::cout << "[get_blob_from_block_template]: " << ENDL + << "blob: [" << epee::string_tools::buff_to_hex_nodelimer(blob) << "]" << ENDL + << "extra: [" << epee::string_tools::buff_to_hex_nodelimer(extra) << "]" << ENDL + << "nonce: [" << *nonce_ptr << "]" << ENDL + << "header_mining_hash: [" << currency::get_block_header_mining_hash(b) << "]" << ENDL + << "res blob: [" << epee::string_tools::buff_to_hex_nodelimer(result_blob) << "]" << ENDL; + //@#@ + + SET_BUFFER_RETURN(result_blob.data(), result_blob.size()); }