mirror of https://github.com/oxen-io/oxen-core.git
Remove hard-forking code on the boundary of 12 and 13 (#919)
This commit is contained in:
parent
efe0080a47
commit
e949e15c6e
|
@ -4044,20 +4044,8 @@ leave:
|
|||
|
||||
// TODO(loki): Temporary forking code.
|
||||
{
|
||||
uint64_t block_height = get_block_height(bl);
|
||||
// We have invalid checkpoints from the soft forking period we should cull
|
||||
{
|
||||
uint64_t hf13_height = m_hardfork->get_earliest_ideal_height_for_version(network_version_13_enforce_checkpoints);
|
||||
uint64_t hf12_height = m_hardfork->get_earliest_ideal_height_for_version(network_version_12_checkpointing);
|
||||
if (hf13_height == get_block_height(bl))
|
||||
{
|
||||
std::vector<checkpoint_t> checkpoints = m_db->get_checkpoints_range(hf13_height - 1, hf12_height);
|
||||
for (cryptonote::checkpoint_t const &checkpoint : checkpoints)
|
||||
m_db->remove_block_checkpoint(checkpoint.height);
|
||||
}
|
||||
}
|
||||
|
||||
// Rescan difficulty every N block we have a reocurring difficulty bug that causes daemons to miscalculate difficulty
|
||||
uint64_t block_height = get_block_height(bl);
|
||||
if (nettype() == MAINNET && (block_height % BLOCKS_EXPECTED_IN_DAYS(1) == 0))
|
||||
{
|
||||
cryptonote::BlockchainDB::fixup_context context = {};
|
||||
|
|
|
@ -1710,16 +1710,6 @@ namespace cryptonote
|
|||
b = &lb;
|
||||
}
|
||||
|
||||
// TODO(loki): Temporary to make hf12 checkpoints play nicely, but, hf12 checkpoints will be deleted on hf13
|
||||
if (checkpoint && b->major_version < network_version_12_checkpointing)
|
||||
{
|
||||
std::sort(checkpoint->signatures.begin(),
|
||||
checkpoint->signatures.end(),
|
||||
[](service_nodes::voter_to_signature const &lhs, service_nodes::voter_to_signature const &rhs) {
|
||||
return lhs.voter_index < rhs.voter_index;
|
||||
});
|
||||
}
|
||||
|
||||
add_new_block(*b, bvc, checkpoint);
|
||||
if(update_miner_blocktemplate && bvc.m_added_to_main_chain)
|
||||
m_miner.on_block_chain_update();
|
||||
|
|
|
@ -1248,20 +1248,11 @@ namespace service_nodes
|
|||
if (nettype == cryptonote::TESTNET && state.height < 85357)
|
||||
total_nodes = active_snode_list.size() + decomm_snode_list.size();
|
||||
|
||||
|
||||
// TODO(loki): We can remove after switching to V13 since we delete all V12 and below checkpoints where we introduced this kind of quorum
|
||||
if (hf_version >= cryptonote::network_version_13_enforce_checkpoints && total_nodes < CHECKPOINT_QUORUM_SIZE)
|
||||
{
|
||||
// NOTE: Although insufficient nodes, generate the empty quorum so we can distinguish between a height with
|
||||
// insufficient service nodes for a quorum VS a height that shouldn't generate a quorum so that we can report
|
||||
// an error to the user if they're missing a quorum
|
||||
}
|
||||
else
|
||||
if (total_nodes >= CHECKPOINT_QUORUM_SIZE)
|
||||
{
|
||||
pub_keys_indexes = generate_shuffled_service_node_index_list(total_nodes, state.block_hash, type);
|
||||
num_validators = std::min(pub_keys_indexes.size(), CHECKPOINT_QUORUM_SIZE);
|
||||
}
|
||||
|
||||
result.checkpointing = quorum;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -261,17 +261,10 @@ namespace service_nodes
|
|||
cryptonote::block const &block = blocks[0];
|
||||
if (start_time < static_cast<ptrdiff_t>(block.timestamp)) // NOTE: If we started up before receiving the block, we likely have the voting information, if not we probably don't.
|
||||
{
|
||||
// TODO(loki): Temporary HF13 code, remove when we hit HF13 because we delete all HF12 checkpoints
|
||||
// and don't need conditionals for HF12/HF13 checkpointing code
|
||||
std::vector<crypto::public_key> const &quorum_keys =
|
||||
(obligations_height_hf_version >= cryptonote::network_version_13_enforce_checkpoints)
|
||||
? quorum->validators
|
||||
: quorum->workers;
|
||||
|
||||
uint64_t quorum_height = offset_testing_quorum_height(checkpoint_type, m_obligations_height);
|
||||
for (size_t index_in_quorum = 0; index_in_quorum < quorum_keys.size(); index_in_quorum++)
|
||||
for (size_t index_in_quorum = 0; index_in_quorum < quorum->validators.size(); index_in_quorum++)
|
||||
{
|
||||
crypto::public_key const &key = quorum_keys[index_in_quorum];
|
||||
crypto::public_key const &key = quorum->validators[index_in_quorum];
|
||||
m_core.record_checkpoint_vote(
|
||||
key,
|
||||
quorum_height,
|
||||
|
@ -452,12 +445,7 @@ namespace service_nodes
|
|||
continue;
|
||||
}
|
||||
|
||||
// TODO(loki): Temporary HF13 code, remove when we hit HF13 because we delete all HF12 checkpoints and don't need conditionals for HF12/HF13 checkpointing code
|
||||
std::vector<crypto::public_key> const &quorum_keys =
|
||||
(checkpointed_height_hf_version >= cryptonote::network_version_13_enforce_checkpoints)
|
||||
? quorum->validators
|
||||
: quorum->workers;
|
||||
int index_in_group = find_index_in_quorum_group(quorum_keys, my_keys->pub);
|
||||
int index_in_group = find_index_in_quorum_group(quorum->validators, my_keys->pub);
|
||||
if (index_in_group <= -1) continue;
|
||||
|
||||
//
|
||||
|
|
|
@ -103,10 +103,8 @@ namespace service_nodes {
|
|||
|
||||
inline quorum_type max_quorum_type_for_hf(uint8_t hf_version)
|
||||
{
|
||||
// TODO(loki): After switching to V13, we can change checkpointing quorums to activate on V13 since we delete all
|
||||
// v12 checkpoints so we don't need quorum data for it and save some space
|
||||
quorum_type result = (hf_version <= cryptonote::network_version_11_infinite_staking) ? quorum_type::obligations
|
||||
: quorum_type::checkpointing;
|
||||
quorum_type result = (hf_version <= cryptonote::network_version_12_checkpointing) ? quorum_type::obligations
|
||||
: quorum_type::checkpointing;
|
||||
assert(result != quorum_type::count);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -270,19 +270,8 @@ namespace service_nodes
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(loki): Temporary HF13 code, remove when we hit HF13 because we delete all HF12 checkpoints and don't need conditionals for HF12/HF13 checkpointing code
|
||||
std::vector<crypto::public_key> const &quorum_keys =
|
||||
(hf_version >= cryptonote::network_version_13_enforce_checkpoints) ? quorum.validators : quorum.workers;
|
||||
if (hf_version >= cryptonote::network_version_13_enforce_checkpoints)
|
||||
{
|
||||
if (!bounds_check_validator_index(quorum, voter_to_signature.voter_index, nullptr)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bounds_check_worker_index(quorum, voter_to_signature.voter_index, nullptr)) return false;
|
||||
}
|
||||
|
||||
crypto::public_key const &key = quorum_keys[voter_to_signature.voter_index];
|
||||
if (!bounds_check_validator_index(quorum, voter_to_signature.voter_index, nullptr)) return false;
|
||||
crypto::public_key const &key = quorum.validators[voter_to_signature.voter_index];
|
||||
if (unique_vote_set[voter_to_signature.voter_index]++)
|
||||
{
|
||||
LOG_PRINT_L1("Voter: " << epee::string_tools::pod_to_hex(key) << ", quorum index is duplicated: " << voter_to_signature.voter_index << ", checkpoint failed verification at height: " << checkpoint.height);
|
||||
|
@ -327,8 +316,7 @@ namespace service_nodes
|
|||
result.type = quorum_type::checkpointing;
|
||||
result.checkpoint.block_hash = block_hash;
|
||||
result.block_height = block_height;
|
||||
// TODO(loki): Temporary HF13 code, remove when we hit HF13 because we delete all HF12 checkpoints and don't need conditionals for HF12/HF13 checkpointing code
|
||||
result.group = (hf_version >= cryptonote::network_version_13_enforce_checkpoints) ? quorum_group::validator : quorum_group::worker;
|
||||
result.group = quorum_group::validator;
|
||||
result.index_in_group = index_in_quorum;
|
||||
result.signature = make_signature_from_vote(result, keys);
|
||||
return result;
|
||||
|
@ -428,10 +416,7 @@ namespace service_nodes
|
|||
|
||||
case quorum_type::checkpointing:
|
||||
{
|
||||
// TODO(loki): Temporary HF13 code, remove when we hit HF13 because we delete all HF12 checkpoints and don't need conditionals for HF12/HF13 checkpointing code
|
||||
quorum_group expected_group =
|
||||
(hf_version >= cryptonote::network_version_13_enforce_checkpoints) ? quorum_group::validator : quorum_group::worker;
|
||||
if (vote.group != expected_group)
|
||||
if (vote.group != quorum_group::validator)
|
||||
{
|
||||
LOG_PRINT_L1("Vote received specifies incorrect voting group");
|
||||
vvc.m_incorrect_voting_group = true;
|
||||
|
@ -439,8 +424,7 @@ namespace service_nodes
|
|||
}
|
||||
else
|
||||
{
|
||||
std::vector<crypto::public_key> const &quorum_keys = (hf_version >= cryptonote::network_version_13_enforce_checkpoints) ? quorum.validators : quorum.workers;
|
||||
key = quorum_keys[vote.index_in_group];
|
||||
key = quorum.validators[vote.index_in_group];
|
||||
hash = vote.checkpoint.block_hash;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1180,19 +1180,8 @@ namespace cryptonote
|
|||
continue;
|
||||
|
||||
std::vector<service_nodes::service_node_pubkey_info> service_node_array = service_node_list.get_service_node_list_state({service_node_pubkey});
|
||||
|
||||
// TODO(loki): Temporary HF12 code. We want to use HF13 code for
|
||||
// detecting if a service node can change state for pruning from the
|
||||
// pool, because changing the pool code here is not consensus, but we
|
||||
// want this logic so as to improve the network behaviour regarding
|
||||
// multiple queued up state changes without a hard fork.
|
||||
|
||||
// Once we hard fork to v13 we can just use the blk major version
|
||||
// whole sale.
|
||||
uint8_t enforce_hf_version = std::max((uint8_t)cryptonote::network_version_13_enforce_checkpoints, blk.major_version);
|
||||
|
||||
if (service_node_array.empty() ||
|
||||
!service_node_array[0].info->can_transition_to_state(enforce_hf_version, state_change.block_height, state_change.state))
|
||||
!service_node_array[0].info->can_transition_to_state(blk.major_version, state_change.block_height, state_change.state))
|
||||
{
|
||||
transaction tx;
|
||||
cryptonote::blobdata blob;
|
||||
|
|
|
@ -38,11 +38,6 @@
|
|||
|
||||
TEST(service_nodes, staking_requirement)
|
||||
{
|
||||
// TODO(loki): The current reference values here for the staking requirement
|
||||
// at certain heights has been derived from excel, so we have to use an
|
||||
// epsilon for dust amounts as amounts are off by a bit. When we switch to
|
||||
// integer math we can remove the need for this. Doyle - 2018-08-28
|
||||
|
||||
// NOTE: Thanks for the values @Sonofotis
|
||||
const uint64_t atomic_epsilon = config::DEFAULT_DUST_THRESHOLD;
|
||||
|
||||
|
|
Loading…
Reference in New Issue