fixed issue with Hardfork 2; removed PRs from HardFork 1 as unnecessary / slowing the chain down

This commit is contained in:
Some Random Crypto Guy
2024-05-16 10:58:02 +01:00
parent aee0f479c1
commit 9a37188885
8 changed files with 42 additions and 21 deletions
+2 -1
View File
@@ -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()
};
@@ -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;
+20 -10
View File
@@ -1819,15 +1819,25 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
}
std::map<std::string, uint64_t> 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<txpool_tx_meta_t> protocol_metadata;
std::vector<cryptonote::protocol_data_entry> 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();
+2 -2
View File
@@ -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;
+5 -5
View File
@@ -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]);
+3 -1
View File
@@ -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;
+2
View File
@@ -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;
+6 -1
View File
@@ -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