From 3cc45e9324a402aee91e2f46861b2ca393d711aa Mon Sep 17 00:00:00 2001 From: NoodleDoodleNoodleDoodleNoodleDoodleNoo Date: Wed, 7 May 2014 11:15:45 -0700 Subject: [PATCH 01/76] Update slow-hash.c Fixed scratchpad initialization/finalization for faster looping. --- src/crypto/slow-hash.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index c7264bd96..6495e490e 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -95,12 +95,11 @@ void cn_slow_hash(const void *data, size_t length, char *hash) { memcpy(text, state.init, INIT_SIZE_BYTE); memcpy(aes_key, state.hs.b, AES_KEY_SIZE); aes_ctx = oaes_alloc(); + + oaes_key_import_data(aes_ctx, aes_key, AES_KEY_SIZE); for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { - for (j = 0; j < INIT_SIZE_BLK; j++) { - oaes_key_import_data(aes_ctx, aes_key, AES_KEY_SIZE); + for (j = 0; j < INIT_SIZE_BLK; j++) { oaes_pseudo_encrypt_ecb(aes_ctx, &text[AES_BLOCK_SIZE * j]); - /*memcpy(aes_key, &text[AES_BLOCK_SIZE * j], AES_KEY_SIZE);*/ - memcpy(aes_key, state.hs.b, AES_KEY_SIZE); } memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); } @@ -137,10 +136,9 @@ void cn_slow_hash(const void *data, size_t length, char *hash) { } memcpy(text, state.init, INIT_SIZE_BYTE); + oaes_key_import_data(aes_ctx, &state.hs.b[32], AES_KEY_SIZE); for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { for (j = 0; j < INIT_SIZE_BLK; j++) { - /*oaes_key_import_data(aes_ctx, &long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE], AES_KEY_SIZE);*/ - oaes_key_import_data(aes_ctx, &state.hs.b[32], AES_KEY_SIZE); xor_blocks(&text[j * AES_BLOCK_SIZE], &long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]); oaes_pseudo_encrypt_ecb(aes_ctx, &text[j * AES_BLOCK_SIZE]); } From b27f060815a5fc3dde224f42d5ba9c6f2db5d2c0 Mon Sep 17 00:00:00 2001 From: monero-project Date: Wed, 7 May 2014 19:55:34 -0400 Subject: [PATCH 02/76] added checkpoint @ 29556 --- src/cryptonote_core/checkpoints_create.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cryptonote_core/checkpoints_create.h b/src/cryptonote_core/checkpoints_create.h index 9088b092d..2aa67c90d 100644 --- a/src/cryptonote_core/checkpoints_create.h +++ b/src/cryptonote_core/checkpoints_create.h @@ -13,6 +13,7 @@ namespace cryptonote { inline bool create_checkpoints(cryptonote::checkpoints& checkpoints) { ADD_CHECKPOINT(22231, "7cb10e29d67e1c069e6e11b17d30b809724255fee2f6868dc14cfc6ed44dfb25"); + ADD_CHECKPOINT(29556, "53c484a8ed91e4da621bb2fa88106dbde426fe90d7ef07b9c1e5127fb6f3a7f6"); return true; } } From ed444b7175d8d9d62a7077aaf59e70d071d2fad6 Mon Sep 17 00:00:00 2001 From: NoodleDoodleNoodleDoodleNoodleDoodleNoo Date: Wed, 7 May 2014 17:15:43 -0700 Subject: [PATCH 03/76] Update cryptonote_format_utils.cpp Fixed problem with integer saturation when summing summary_amounts and out_amounts in a 32-bit platform. --- src/cryptonote_core/cryptonote_format_utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/cryptonote_format_utils.cpp b/src/cryptonote_core/cryptonote_format_utils.cpp index b2eaf18a2..2b38d001f 100644 --- a/src/cryptonote_core/cryptonote_format_utils.cpp +++ b/src/cryptonote_core/cryptonote_format_utils.cpp @@ -80,7 +80,7 @@ namespace cryptonote #endif block_reward += fee; - std::vector out_amounts; + std::vector out_amounts; decompose_amount_into_digits(block_reward, DEFAULT_FEE, [&out_amounts](uint64_t a_chunk) { out_amounts.push_back(a_chunk); }, [&out_amounts](uint64_t a_dust) { out_amounts.push_back(a_dust); }); @@ -92,7 +92,7 @@ namespace cryptonote out_amounts.resize(out_amounts.size() - 1); } - size_t summary_amounts = 0; + uint64_t summary_amounts = 0; for (size_t no = 0; no < out_amounts.size(); no++) { crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);; From 5ceffa8c8abb96bb8314939bf75c9b935ea7b5bc Mon Sep 17 00:00:00 2001 From: monero-project Date: Thu, 8 May 2014 11:12:54 -0400 Subject: [PATCH 04/76] disable checkpointing for security reasons Further investigation of fast sync security is required --- src/cryptonote_core/checkpoints_create.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cryptonote_core/checkpoints_create.h b/src/cryptonote_core/checkpoints_create.h index 2aa67c90d..32d15831f 100644 --- a/src/cryptonote_core/checkpoints_create.h +++ b/src/cryptonote_core/checkpoints_create.h @@ -12,8 +12,12 @@ namespace cryptonote { inline bool create_checkpoints(cryptonote::checkpoints& checkpoints) { - ADD_CHECKPOINT(22231, "7cb10e29d67e1c069e6e11b17d30b809724255fee2f6868dc14cfc6ed44dfb25"); - ADD_CHECKPOINT(29556, "53c484a8ed91e4da621bb2fa88106dbde426fe90d7ef07b9c1e5127fb6f3a7f6"); + // Checkpointing disabled until we can make the client not fast-sync + // without checking PoW at some point. Otherwise we may be exposed + // to blockchain corruption attacks. Need to investigate this further. + // 8-5-14 + // ADD_CHECKPOINT(22231, "7cb10e29d67e1c069e6e11b17d30b809724255fee2f6868dc14cfc6ed44dfb25"); + // ADD_CHECKPOINT(29556, "53c484a8ed91e4da621bb2fa88106dbde426fe90d7ef07b9c1e5127fb6f3a7f6"); return true; } } From 26c1a8569c2f30ae204bf5be83a66491ab719dfb Mon Sep 17 00:00:00 2001 From: NoodleDoodleNoodleDoodleNoodleDoodleNoo Date: Sun, 11 May 2014 14:10:24 -0700 Subject: [PATCH 05/76] Update simpleminer.cpp 1. Modified connection timeout from 1 second to 10 seconds 2. Modified behavior to retry instead of exiting when the miner fails to get a new job --- src/miner/simpleminer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner/simpleminer.cpp b/src/miner/simpleminer.cpp index 3af04954f..1d6f18410 100644 --- a/src/miner/simpleminer.cpp +++ b/src/miner/simpleminer.cpp @@ -109,7 +109,7 @@ namespace mining if(!m_http_client.is_connected()) { LOG_PRINT_L0("Connecting " << m_pool_ip << ":" << m_pool_port << "...."); - if(!m_http_client.connect(m_pool_ip, m_pool_port, 1000)) + if(!m_http_client.connect(m_pool_ip, m_pool_port, 10000)) { LOG_PRINT_L0("Failed to connect " << m_pool_ip << ":" << m_pool_port << ", sleep...."); epee::misc_utils::sleep_no_w(1000); @@ -198,7 +198,7 @@ namespace mining LOG_PRINT_L0("Can't get new job! Disconnect and sleep...."); m_http_client.disconnect(); epee::misc_utils::sleep_no_w(1000); - break; + continue; } if (getjob_response.blob.empty() && getjob_response.target.empty() && getjob_response.job_id.empty()) { From 9b2d1bc4c2697e0291e15176579c63e6f293d372 Mon Sep 17 00:00:00 2001 From: monero-project Date: Mon, 12 May 2014 21:30:00 -0400 Subject: [PATCH 06/76] 20s timeout for zone117x pool --- src/miner/simpleminer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner/simpleminer.cpp b/src/miner/simpleminer.cpp index 1d6f18410..a1c1ad5c6 100644 --- a/src/miner/simpleminer.cpp +++ b/src/miner/simpleminer.cpp @@ -109,7 +109,7 @@ namespace mining if(!m_http_client.is_connected()) { LOG_PRINT_L0("Connecting " << m_pool_ip << ":" << m_pool_port << "...."); - if(!m_http_client.connect(m_pool_ip, m_pool_port, 10000)) + if(!m_http_client.connect(m_pool_ip, m_pool_port, 20000)) { LOG_PRINT_L0("Failed to connect " << m_pool_ip << ":" << m_pool_port << ", sleep...."); epee::misc_utils::sleep_no_w(1000); From c0cf78a1d157605ab1a937d022ba03e130b1bca3 Mon Sep 17 00:00:00 2001 From: NoodleDoodleNoodleDoodleNoodleDoodleNoo Date: Tue, 13 May 2014 16:10:58 -0700 Subject: [PATCH 07/76] Update serialization.h 1. Added VARINT_FIELD_N(t,f) macro required for tx_extra_merge_mining_tag serialization. --- src/serialization/serialization.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/serialization/serialization.h b/src/serialization/serialization.h index 2d78baf3a..2e69ea0a3 100644 --- a/src/serialization/serialization.h +++ b/src/serialization/serialization.h @@ -93,7 +93,12 @@ inline bool do_serialize(Archive &ar, T &v) ar.serialize_varint(f); \ if (!ar.stream().good()) return false; \ } while(0); - +#define VARINT_FIELD_N(t, f) \ + do { \ + ar.tag(t); \ + ar.serialize_varint(f); \ + if (!ar.stream().good()) return false; \ + } while(0); namespace serialization { namespace detail { From b5b061e0e876fdbe7d82c9ba610d5c514961f1c1 Mon Sep 17 00:00:00 2001 From: NoodleDoodleNoodleDoodleNoodleDoodleNoo Date: Tue, 13 May 2014 17:53:20 -0700 Subject: [PATCH 08/76] Update tx_extra.h 1. Fixed bug where it's impossible to spend merge-mining blocks due to missing serialization support for "tx_etra_merge_mining_tag". --- src/cryptonote_core/tx_extra.h | 53 +++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/src/cryptonote_core/tx_extra.h b/src/cryptonote_core/tx_extra.h index 8cff085dc..254a6a2ff 100644 --- a/src/cryptonote_core/tx_extra.h +++ b/src/cryptonote_core/tx_extra.h @@ -11,6 +11,7 @@ #define TX_EXTRA_TAG_PADDING 0x00 #define TX_EXTRA_TAG_PUBKEY 0x01 #define TX_EXTRA_NONCE 0x02 +#define TX_EXTRA_MERGE_MINING_TAG 0x03 #define TX_EXTRA_NONCE_PAYMENT_ID 0x00 @@ -82,13 +83,63 @@ namespace cryptonote END_SERIALIZE() }; + struct tx_extra_merge_mining_tag + { + struct serialize_helper + { + tx_extra_merge_mining_tag& mm_tag; + + serialize_helper(tx_extra_merge_mining_tag& mm_tag_) : mm_tag(mm_tag_) + { + } + + BEGIN_SERIALIZE() + VARINT_FIELD_N("depth", mm_tag.depth) + FIELD_N("merkle_root", mm_tag.merkle_root) + END_SERIALIZE() + }; + + size_t depth; + crypto::hash merkle_root; + + // load + template