diff --git a/src/cryptonote_basic/cryptonote_basic.h b/src/cryptonote_basic/cryptonote_basic.h index d885e8241..fc69062da 100644 --- a/src/cryptonote_basic/cryptonote_basic.h +++ b/src/cryptonote_basic/cryptonote_basic.h @@ -534,7 +534,8 @@ namespace cryptonote VARINT_FIELD(timestamp) FIELD(prev_id) FIELD(nonce) - FIELD(pricing_record) + if (major_version >= HF_VERSION_ENABLE_ORACLE) + FIELD(pricing_record) END_SERIALIZE() }; diff --git a/src/cryptonote_basic/cryptonote_boost_serialization.h b/src/cryptonote_basic/cryptonote_boost_serialization.h index 5d6cc13e8..bfa192bc5 100644 --- a/src/cryptonote_basic/cryptonote_boost_serialization.h +++ b/src/cryptonote_basic/cryptonote_boost_serialization.h @@ -255,7 +255,8 @@ namespace boost a & b.timestamp; a & b.prev_id; a & b.nonce; - a & b.pricing_record; + if (b.major_version >= HF_VERSION_ENABLE_ORACLE) + a & b.pricing_record; //------------------ a & b.miner_tx; a & b.protocol_tx; diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 8ab898d45..e859f3202 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -1819,15 +1819,25 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block, } std::map circ_supply = get_db().get_circulating_supply(); - - oracle::pricing_record pr; - if (!get_pricing_record(pr, circ_supply, b.timestamp)) { - LOG_ERROR("Creating block template: error: failed to get pricing record"); - return false; - } - // Copy the returned record - b.pricing_record = pr; + // Check if we are supposed to be obtaining PRs from the Oracle + if (b.major_version >= HF_VERSION_ENABLE_ORACLE) { + + // Yep - go get the pricing records + oracle::pricing_record pr; + if (!get_pricing_record(pr, circ_supply, b.timestamp)) { + LOG_ERROR("Creating block template: error: failed to get pricing record"); + return false; + } + + // Copy the returned record + b.pricing_record = pr; + + } else { + + // Nope - set it to an empty record - it won't get serialised anyway + b.pricing_record = oracle::pricing_record(); + } CHECK_AND_ASSERT_MES(diffic, false, "difficulty overhead."); @@ -1850,7 +1860,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block, */ std::vector protocol_metadata; std::vector protocol_entries; - if (!m_tx_pool.fill_block_template(b, median_weight, already_generated_coins, txs_weight, fee, expected_reward, b.major_version, pr, circ_supply, protocol_metadata)) + if (!m_tx_pool.fill_block_template(b, median_weight, already_generated_coins, txs_weight, fee, expected_reward, b.major_version, b.pricing_record, circ_supply, protocol_metadata)) { return false; } @@ -1906,7 +1916,7 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block, address_parse_info treasury_address_info; ok = cryptonote::get_account_address_from_str(treasury_address_info, m_nettype, get_config(m_nettype).TREASURY_ADDRESS); CHECK_AND_ASSERT_MES(ok, false, "Failed to obtain treasury address info"); - ok = construct_protocol_tx(height, protocol_fee, b.protocol_tx, protocol_entries, circ_supply, pr, miner_address, treasury_address_info.address, b.major_version); + ok = construct_protocol_tx(height, protocol_fee, b.protocol_tx, protocol_entries, circ_supply, b.pricing_record, miner_address, treasury_address_info.address, b.major_version); CHECK_AND_ASSERT_MES(ok, false, "Failed to construct protocol tx"); pool_cookie = m_tx_pool.cookie(); diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 9e1b97e7a..6aa116b4a 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -1860,7 +1860,7 @@ namespace cryptonote //----------------------------------------------------------------------------------------------- bool core::check_updates() { - static const char software[] = "monero"; + static const char software[] = "salvium"; #ifdef BUILD_TAG static const char buildtag[] = BOOST_PP_STRINGIZE(BUILD_TAG); static const char subdir[] = "cli"; // because it can never be simple @@ -1880,7 +1880,7 @@ namespace cryptonote if (!tools::check_updates(software, buildtag, version, hash)) return false; - if (tools::vercmp(version.c_str(), MONERO_VERSION) <= 0) + if (tools::vercmp(version.c_str(), SALVIUM_VERSION) <= 0) { m_update_available = false; return true; diff --git a/src/hardforks/hardforks.cpp b/src/hardforks/hardforks.cpp index e6d8e618c..5c7498454 100644 --- a/src/hardforks/hardforks.cpp +++ b/src/hardforks/hardforks.cpp @@ -36,26 +36,26 @@ const hardfork_t mainnet_hard_forks[] = { { 1, 1, 0, 1341378000 }, // version 2 starts from block 1000, which is on or around the 20th of March, 2016. Fork time finalised on 2015-09-20. No fork voting occurs for the v2 fork. - { 2, 1000, 0, 1442763710 }, + //{ 2, 1000, 0, 1442763710 }, }; const size_t num_mainnet_hard_forks = sizeof(mainnet_hard_forks) / sizeof(mainnet_hard_forks[0]); -const uint64_t mainnet_hard_fork_version_1_till = 1000; +const uint64_t mainnet_hard_fork_version_1_till = ((uint64_t)-1); const hardfork_t testnet_hard_forks[] = { // version 1 from the start of the blockchain { 1, 1, 0, 1341378000 }, // version 2 starts from block 1000, which is on or around the 23rd of November, 2015. Fork time finalised on 2015-11-20. No fork voting occurs for the v2 fork. - { 1, 1000, 0, 1445355000 }, + //{ 2, 1000, 0, 1445355000 }, }; const size_t num_testnet_hard_forks = sizeof(testnet_hard_forks) / sizeof(testnet_hard_forks[0]); -const uint64_t testnet_hard_fork_version_1_till = 1000; +const uint64_t testnet_hard_fork_version_1_till = ((uint64_t)-1); const hardfork_t stagenet_hard_forks[] = { // version 1 from the start of the blockchain { 1, 1, 0, 1341378000 }, // versions 2-7 in rapid succession from March 13th, 2018 - { 2, 1000, 0, 1521000000 }, + //{ 2, 1000, 0, 1521000000 }, }; const size_t num_stagenet_hard_forks = sizeof(stagenet_hard_forks) / sizeof(stagenet_hard_forks[0]); diff --git a/src/version.cpp.in b/src/version.cpp.in index 04631117d..f80281f85 100644 --- a/src/version.cpp.in +++ b/src/version.cpp.in @@ -1,5 +1,5 @@ #define DEF_SALVIUM_VERSION_TAG "7f6b8da" -#define DEF_SALVIUM_VERSION "0.0.1" +#define DEF_SALVIUM_VERSION "0.0.2" #define DEF_MONERO_VERSION_TAG "@VERSIONTAG@" #define DEF_MONERO_VERSION "0.18.2.2" #define DEF_MONERO_RELEASE_NAME "Zero" @@ -8,6 +8,8 @@ #include "version.h" +const char* const SALVIUM_VERSION_TAG = DEF_SALVIUM_VERSION_TAG; +const char* const SALVIUM_VERSION = DEF_SALVIUM_VERSION; const char* const MONERO_VERSION_TAG = DEF_MONERO_VERSION_TAG; const char* const MONERO_VERSION = DEF_MONERO_VERSION; const char* const MONERO_RELEASE_NAME = DEF_MONERO_RELEASE_NAME; diff --git a/src/version.h b/src/version.h index b740d3360..587e79dd8 100644 --- a/src/version.h +++ b/src/version.h @@ -1,5 +1,7 @@ #pragma once +extern const char* const SALVIUM_VERSION_TAG; +extern const char* const SALVIUM_VERSION; extern const char* const MONERO_VERSION_TAG; extern const char* const MONERO_VERSION; extern const char* const MONERO_RELEASE_NAME; diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index dc7c3e901..d0c36c17e 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -804,7 +804,7 @@ size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs, size_t extra size += n_inputs * (1+6+(mixin+1)*2+32); // vout - size += n_outputs * (6+32); + size += n_outputs * (1+32+4+8); // extra size += extra_size; @@ -839,6 +839,8 @@ size_t estimate_rct_tx_size(int n_inputs, int mixin, int n_outputs, size_t extra // pseudoOuts size += 32 * n_inputs; + // p_r + size += 32; // ecdhInfo size += 8 * n_outputs; // outPk - only commitment is saved @@ -2250,6 +2252,9 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote error::wallet_internal_error, "Failed to calculate uniqueness from origin TX"); + // At this point, we need to clear the "locked coins" count, because otherwise we will be counting yield stakes twice in our balance + m_locked_coins.erase(pk_change); + } else { // Get the uniqueness value