network_version_16 += _pulse

This commit is contained in:
Jason Rhinelander 2020-09-18 16:39:50 -03:00
parent 9818bb1dd1
commit 3f67de11df
13 changed files with 40 additions and 40 deletions

View File

@ -440,7 +440,7 @@ void BlockchainDB::fill_timestamps_and_difficulties_for_pow(cryptonote::network_
return;
uint64_t const top_block_height = chain_height - 1;
static const uint64_t hf16_height = HardFork::get_hardcoded_hard_fork_height(nettype, cryptonote::network_version_16);
static const uint64_t hf16_height = HardFork::get_hardcoded_hard_fork_height(nettype, cryptonote::network_version_16_pulse);
bool const before_hf16 = chain_height < hf16_height;
uint64_t const block_count = DIFFICULTY_BLOCKS_COUNT(before_hf16);

View File

@ -4805,7 +4805,7 @@ void BlockchainLMDB::fixup(fixup_context const context)
bool use_next_difficulty_function = true;
uint8_t hf_version = get_hard_fork_version(curr_height);
if (hf_version >= cryptonote::network_version_16)
if (hf_version >= cryptonote::network_version_16_pulse)
{
block_header header = get_block_header_from_height(curr_height);
if (block_header_has_pulse_components(header))

View File

@ -465,7 +465,7 @@ namespace cryptonote
VARINT_FIELD(timestamp)
FIELD(prev_id)
FIELD(nonce)
if (major_version >= cryptonote::network_version_16)
if (major_version >= cryptonote::network_version_16_pulse)
FIELD(pulse)
END_SERIALIZE()
};
@ -503,7 +503,7 @@ namespace cryptonote
FIELD(tx_hashes)
if (tx_hashes.size() > CRYPTONOTE_MAX_TX_PER_BLOCK)
throw std::invalid_argument{"too many txs in block"};
if (major_version >= cryptonote::network_version_16)
if (major_version >= cryptonote::network_version_16_pulse)
FIELD(signatures)
END_SERIALIZE()
};

View File

@ -70,7 +70,7 @@ namespace cryptonote {
bool bitset = blk_header.pulse.validator_bitset > 0;
bool random_value = !(blk_header.pulse.random_value == empty_random_value);
uint8_t hf_version = blk_header.major_version;
bool result = hf_version >= cryptonote::network_version_16 && (bitset || random_value);
bool result = hf_version >= cryptonote::network_version_16_pulse && (bitset || random_value);
return result;
}
//-----------------------------------------------------------------------------------------------
@ -79,7 +79,7 @@ namespace cryptonote {
bool signatures = blk.signatures.size();
uint8_t hf_version = blk.major_version;
bool result =
(hf_version >= cryptonote::network_version_16 && signatures) || block_header_has_pulse_components(blk);
(hf_version >= cryptonote::network_version_16_pulse && signatures) || block_header_has_pulse_components(blk);
return result;
}
//-----------------------------------------------------------------------------------------------
@ -124,7 +124,7 @@ namespace cryptonote {
static_assert((TARGET_BLOCK_TIME % 1min) == 0s, "difficulty targets must be a multiple of a minute");
uint64_t base_reward =
version >= network_version_16 ? BLOCK_REWARD_HF16 :
version >= network_version_16_pulse ? BLOCK_REWARD_HF16 :
version >= network_version_15_lns ? BLOCK_REWARD_HF15 :
version >= network_version_8 ? block_reward_unpenalized_formula_v8(height) :
block_reward_unpenalized_formula_v7(already_generated_coins, height);

View File

@ -127,7 +127,7 @@ namespace cryptonote {
timestamps.push_back(timestamp);
difficulties.push_back(cumulative_difficulty);
static const uint64_t hf16_height = HardFork::get_hardcoded_hard_fork_height(nettype, cryptonote::network_version_16);
static const uint64_t hf16_height = HardFork::get_hardcoded_hard_fork_height(nettype, cryptonote::network_version_16_pulse);
bool const before_hf16 = chain_height < hf16_height;
// Trim down arrays

View File

@ -91,7 +91,7 @@ static constexpr HardFork::Params testnet_hard_forks[] =
static constexpr HardFork::Params devnet_hard_forks[] =
{
{ network_version_7, 1, 0, 1599848400 },
{ network_version_16, 2, 0, 1599848400 }, // 2020-09-11 18:20 UTC
{ network_version_16_pulse, 2, 0, 1599848400 }, // 2020-09-11 18:20 UTC
};
uint64_t HardFork::get_hardcoded_hard_fork_height(network_type nettype, cryptonote::network_version version)

View File

@ -188,11 +188,11 @@ constexpr uint64_t BLOCKS_EXPECTED_IN_YEARS(int years) { return BLOCKS_EXPECTED_
#define HF_VERSION_ED25519_KEY cryptonote::network_version_13_enforce_checkpoints
#define HF_VERSION_FEE_BURNING cryptonote::network_version_14_blink
#define HF_VERSION_BLINK cryptonote::network_version_14_blink
#define HF_VERSION_MIN_2_OUTPUTS cryptonote::network_version_16
#define HF_VERSION_REJECT_SIGS_IN_COINBASE cryptonote::network_version_16
#define HF_VERSION_ENFORCE_MIN_AGE cryptonote::network_version_16
#define HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY cryptonote::network_version_16
#define HF_VERSION_PULSE cryptonote::network_version_16
#define HF_VERSION_MIN_2_OUTPUTS cryptonote::network_version_16_pulse
#define HF_VERSION_REJECT_SIGS_IN_COINBASE cryptonote::network_version_16_pulse
#define HF_VERSION_ENFORCE_MIN_AGE cryptonote::network_version_16_pulse
#define HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY cryptonote::network_version_16_pulse
#define HF_VERSION_PULSE cryptonote::network_version_16_pulse
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
@ -324,7 +324,7 @@ namespace cryptonote
network_version_13_enforce_checkpoints,
network_version_14_blink,
network_version_15_lns,
network_version_16, // future fork
network_version_16_pulse,
network_version_count,
};

View File

@ -967,7 +967,7 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
// and it will be unlocked only when called from the getinfo RPC
if (top_hash == m_cache.m_difficulty_for_next_block_top_hash)
{
if (hf_version >= cryptonote::network_version_16 && pulse::clock::now() < m_cache.m_pulse_timings.miner_fallback_timestamp)
if (hf_version >= cryptonote::network_version_16_pulse && pulse::clock::now() < m_cache.m_pulse_timings.miner_fallback_timestamp)
return PULSE_FIXED_DIFFICULTY;
else
return m_cache.m_difficulty_for_next_block;
@ -980,7 +980,7 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
uint64_t chain_height = top_block_height + 1;
bool pulse_override_difficulty = false;
if (hf_version >= cryptonote::network_version_16)
if (hf_version >= cryptonote::network_version_16_pulse)
{
pulse::get_round_timings(*this, chain_height, m_db->get_block_timestamp(top_block_height), m_cache.m_pulse_timings);
pulse_override_difficulty = (pulse::clock::now() < m_cache.m_pulse_timings.miner_fallback_timestamp);
@ -1204,10 +1204,10 @@ difficulty_type Blockchain::get_difficulty_for_alternative_chain(const std::list
{
bool before_hf16 = true;
if (alt_chain.size())
before_hf16 = alt_chain.back().bl.major_version < network_version_16;
before_hf16 = alt_chain.back().bl.major_version < network_version_16_pulse;
else
{
static const uint64_t hf16_height = HardFork::get_hardcoded_hard_fork_height(m_nettype, cryptonote::network_version_16);
static const uint64_t hf16_height = HardFork::get_hardcoded_hard_fork_height(m_nettype, cryptonote::network_version_16_pulse);
before_hf16 = get_current_blockchain_height() < hf16_height;
}
@ -2055,7 +2055,7 @@ bool Blockchain::handle_alternative_block(const block& b, const crypto::hash& id
bool const alt_chain_has_more_checkpoints = (num_checkpoints_on_alt_chain > num_checkpoints_on_chain);
bool const alt_chain_has_equal_checkpoints = (num_checkpoints_on_alt_chain == num_checkpoints_on_chain);
if (b.major_version >= cryptonote::network_version_16)
if (b.major_version >= cryptonote::network_version_16_pulse)
{
// In Pulse, we move away from the concept of difficulty to solve ties
// between chains. We calculate the preferred chain using a simpler system.
@ -3979,7 +3979,7 @@ Blockchain::block_pow_verified Blockchain::verify_block_pow(cryptonote::block co
// Hence this hack: starting at that block until the next hard fork, we allow a slight grace
// (0.2%) on the required difficulty (but we don't *change* the actual difficulty value used for
// diff calculation).
if (cryptonote::get_block_height(blk) >= 526483 && m_hardfork->get_current_version() < network_version_16)
if (cryptonote::get_block_height(blk) >= 526483 && m_hardfork->get_current_version() < network_version_16_pulse)
difficulty = (difficulty * 998) / 1000;
CHECK_AND_ASSERT_MES(difficulty, result, "!!!!!!!!! difficulty overhead !!!!!!!!!");
@ -4962,7 +4962,7 @@ bool Blockchain::calc_batched_governance_reward(uint64_t height, uint64_t &rewar
if (hard_fork_version >= network_version_15_lns)
{
reward = num_blocks * (
hard_fork_version >= network_version_16 ? FOUNDATION_REWARD_HF16 : FOUNDATION_REWARD_HF15);
hard_fork_version >= network_version_16_pulse ? FOUNDATION_REWARD_HF16 : FOUNDATION_REWARD_HF15);
return true;
}

View File

@ -133,7 +133,7 @@ namespace cryptonote
uint64_t governance_reward_formula(uint64_t base_reward, uint8_t hf_version)
{
return hf_version >= network_version_16 ? FOUNDATION_REWARD_HF16 :
return hf_version >= network_version_16_pulse ? FOUNDATION_REWARD_HF16 :
hf_version >= network_version_15_lns ? FOUNDATION_REWARD_HF15 :
base_reward / 20;
}
@ -197,7 +197,7 @@ namespace cryptonote
uint64_t service_node_reward_formula(uint64_t base_reward, uint8_t hard_fork_version)
{
return
hard_fork_version >= network_version_16 ? SN_REWARD_HF16 :
hard_fork_version >= network_version_16_pulse ? SN_REWARD_HF16 :
hard_fork_version >= network_version_15_lns ? SN_REWARD_HF15 :
hard_fork_version >= network_version_9_service_nodes ? base_reward / 2 : // 50% of base reward up until HF15's fixed payout
0;
@ -337,7 +337,7 @@ namespace cryptonote
{
CHECK_AND_ASSERT_MES(miner_tx_context.pulse_block_producer.payouts.size(), false, "Constructing a reward for block produced by pulse but no payout entries specified");
CHECK_AND_ASSERT_MES(miner_tx_context.pulse_block_producer.key, false, "Null Key given for Pulse Block Producer");
CHECK_AND_ASSERT_MES(hard_fork_version >= cryptonote::network_version_16, false, "Pulse Block Producer is not valid until HF16, current HF" << hard_fork_version);
CHECK_AND_ASSERT_MES(hard_fork_version >= cryptonote::network_version_16_pulse, false, "Pulse Block Producer is not valid until HF16, current HF" << hard_fork_version);
uint64_t leader_reward = reward_parts.service_node_paid + reward_parts.base_miner;
if (miner_tx_context.block_leader.key == miner_tx_context.pulse_block_producer.key)

View File

@ -738,7 +738,7 @@ void pulse::handle_message(void *quorumnet_state, pulse::message const &msg)
bool pulse::get_round_timings(cryptonote::Blockchain const &blockchain, uint64_t block_height, uint64_t prev_timestamp, pulse::timings &times)
{
times = {};
static uint64_t const hf16_height = blockchain.get_earliest_ideal_height_for_version(cryptonote::network_version_16);
static uint64_t const hf16_height = blockchain.get_earliest_ideal_height_for_version(cryptonote::network_version_16_pulse);
if (hf16_height == std::numeric_limits<uint64_t>::max())
return false;
@ -1710,7 +1710,7 @@ void pulse::main(void *quorumnet_state, cryptonote::core &core)
//
// NOTE: Early exit if too early
//
static uint64_t const hf16_height = cryptonote::HardFork::get_hardcoded_hard_fork_height(blockchain.nettype(), cryptonote::network_version_16);
static uint64_t const hf16_height = cryptonote::HardFork::get_hardcoded_hard_fork_height(blockchain.nettype(), cryptonote::network_version_16_pulse);
if (hf16_height == cryptonote::HardFork::INVALID_HF_VERSION_HEIGHT)
{
for (static bool once = true; once; once = !once)

View File

@ -892,7 +892,7 @@ namespace service_nodes
return false;
}
if (hf_version >= cryptonote::network_version_16)
if (hf_version >= cryptonote::network_version_16_pulse)
{
// In HF16 we start enforcing three things that were always done but weren't actually enforced:
// 1. the staked amount in the tx must be a single output.
@ -977,7 +977,7 @@ namespace service_nodes
// In HF16 we require that the amount staked in the registration tx be at least the amount
// reserved for the operator. Before HF16 it only had to be >= 25%, even if the operator
// reserved amount was higher (though wallets would never actually do this).
if (hf_version >= cryptonote::network_version_16 && stake.transferred < info.contributors[0].reserved)
if (hf_version >= cryptonote::network_version_16_pulse && stake.transferred < info.contributors[0].reserved)
{
LOG_PRINT_L1("Register TX rejected: TX does not have sufficient operator stake");
return false;
@ -1123,7 +1123,7 @@ namespace service_nodes
other_reservations++;
}
if (hf_version >= cryptonote::network_version_16 && stake.locked_contributions.size() != 1)
if (hf_version >= cryptonote::network_version_16_pulse && stake.locked_contributions.size() != 1)
{
// Nothing has ever created stake txes with multiple stake outputs, but we start enforcing
// that in HF16.
@ -1134,7 +1134,7 @@ namespace service_nodes
// Check node contributor counts
{
bool too_many_contributions = false;
if (hf_version >= cryptonote::network_version_16)
if (hf_version >= cryptonote::network_version_16_pulse)
// Before HF16 we didn't properly take into account unfilled reservation spots
too_many_contributions = existing_contributions + other_reservations + 1 > MAX_NUMBER_OF_CONTRIBUTORS;
else if (hf_version >= cryptonote::network_version_11_infinite_staking)
@ -1160,7 +1160,7 @@ namespace service_nodes
{ // Follow-up contributions from an existing contributor could be any size before HF11
min_contribution = 1;
}
else if (hf_version < cryptonote::network_version_16)
else if (hf_version < cryptonote::network_version_16_pulse)
{
// The implementation before HF16 was a bit broken w.r.t. properly handling reserved amounts
min_contribution = get_min_node_contribution(hf_version, curinfo.staking_requirement, curinfo.total_reserved, existing_contributions);
@ -1484,7 +1484,7 @@ namespace service_nodes
//
pulse::timings timings = {};
uint64_t height = cryptonote::get_block_height(block);
if (block.major_version >= cryptonote::network_version_16)
if (block.major_version >= cryptonote::network_version_16_pulse)
{
uint64_t prev_timestamp = 0;
if (alt_block)
@ -1516,7 +1516,7 @@ namespace service_nodes
//
std::shared_ptr<const quorum> pulse_quorum;
std::vector<std::shared_ptr<const quorum>> alt_pulse_quorums;
bool pulse_hf = block.major_version >= cryptonote::network_version_16;
bool pulse_hf = block.major_version >= cryptonote::network_version_16_pulse;
if (pulse_hf)
{
@ -1582,7 +1582,7 @@ namespace service_nodes
static std::mt19937_64 quorum_rng(uint8_t hf_version, crypto::hash const &hash, quorum_type type)
{
std::mt19937_64 result;
if (hf_version >= cryptonote::network_version_16)
if (hf_version >= cryptonote::network_version_16_pulse)
{
std::array<uint32_t, (sizeof(hash) / sizeof(uint32_t)) + 1> src = {static_cast<uint32_t>(type)};
std::memcpy(&src[1], &hash, sizeof(hash));
@ -1651,7 +1651,7 @@ namespace service_nodes
{
cryptonote::block const &block = *it;
crypto::hash hash = {};
if (block.major_version >= cryptonote::network_version_16 &&
if (block.major_version >= cryptonote::network_version_16_pulse &&
cryptonote::block_has_pulse_components(block))
{
std::array<uint8_t, 1 + sizeof(block.pulse.random_value)> src = {pulse_round};
@ -1948,7 +1948,7 @@ namespace service_nodes
// i.e. before any deregistrations, registrations, decommissions, recommissions.
//
crypto::public_key winner_pubkey = cryptonote::get_service_node_winner_from_tx_extra(block.miner_tx.extra);
if (hf_version >= cryptonote::network_version_16)
if (hf_version >= cryptonote::network_version_16_pulse)
{
std::vector<crypto::hash> entropy = get_pulse_entropy_for_next_block(db, block.prev_id, block.pulse.round);
quorum pulse_quorum = generate_pulse_quorum(nettype, winner_pubkey, hf_version, active_service_nodes_infos(), entropy, block.pulse.round);
@ -2426,7 +2426,7 @@ namespace service_nodes
return false;
}
if (hf_version >= cryptonote::network_version_16)
if (hf_version >= cryptonote::network_version_16_pulse)
{
if (reward_parts.base_miner != 0)
{

View File

@ -150,7 +150,7 @@ static uint64_t get_min_node_contribution_pre_v11(uint64_t staking_requirement,
uint64_t get_max_node_contribution(uint8_t version, uint64_t staking_requirement, uint64_t total_reserved)
{
if (version >= cryptonote::network_version_16)
if (version >= cryptonote::network_version_16_pulse)
return (staking_requirement - total_reserved) * config::MAXIMUM_ACCEPTABLE_STAKE::num
/ config::MAXIMUM_ACCEPTABLE_STAKE::den;
return std::numeric_limits<uint64_t>::max();

View File

@ -244,7 +244,7 @@ namespace service_nodes {
return
hf_version <= cryptonote::network_version_12_checkpointing ? quorum_type::obligations :
hf_version < cryptonote::network_version_14_blink ? quorum_type::checkpointing :
hf_version < cryptonote::network_version_16 ? quorum_type::blink :
hf_version < cryptonote::network_version_16_pulse ? quorum_type::blink :
quorum_type::pulse;
}