Merge branch 'master' into dev

This commit is contained in:
Doyle 2019-12-04 16:03:21 +11:00
commit 5bcb45aadc
4 changed files with 22 additions and 14 deletions

View file

@ -679,12 +679,10 @@ else()
add_cxx_flag_if_supported(-Wformat-security CXX_SECURITY_FLAGS)
# -fstack-protector
if (NOT WIN32 AND NOT IOS)
add_c_flag_if_supported(-fstack-protector C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-fstack-protector CXX_SECURITY_FLAGS)
add_c_flag_if_supported(-fstack-protector-strong C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-fstack-protector-strong CXX_SECURITY_FLAGS)
endif()
add_c_flag_if_supported(-fstack-protector C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-fstack-protector CXX_SECURITY_FLAGS)
add_c_flag_if_supported(-fstack-protector-strong C_SECURITY_FLAGS)
add_cxx_flag_if_supported(-fstack-protector-strong CXX_SECURITY_FLAGS)
# -fno-stack-check
if (IOS)

View file

@ -461,6 +461,7 @@ namespace service_nodes
}
bool service_node_list::state_t::process_state_change_tx(std::set<state_t> const &state_history,
std::set<state_t> const &state_archive,
std::unordered_map<crypto::hash, state_t> const &alt_states,
cryptonote::network_type nettype,
const cryptonote::block &block,
@ -481,9 +482,15 @@ namespace service_nodes
auto it = state_history.find(state_change.block_height);
if (it == state_history.end())
{
MERROR("Transaction: " << cryptonote::get_transaction_hash(tx) << " in block " << cryptonote::get_block_height(block) << " " << cryptonote::get_block_hash(block)
<< " references quorum height " << state_change.block_height << " but that height is not stored!");
return false;
it = state_archive.find(state_change.block_height);
if (it == state_archive.end())
{
MERROR("Transaction: " << cryptonote::get_transaction_hash(tx) << " in block "
<< cryptonote::get_block_height(block) << " " << cryptonote::get_block_hash(block)
<< " references quorum height " << state_change.block_height
<< " but that height is not stored!");
return false;
}
}
quorum_manager const *quorums = &it->quorums;
@ -1362,6 +1369,7 @@ namespace service_nodes
void service_node_list::state_t::update_from_block(cryptonote::BlockchainDB const &db,
cryptonote::network_type nettype,
std::set<state_t> const &state_history,
std::set<state_t> const &state_archive,
std::unordered_map<crypto::hash, state_t> const &alt_states,
const cryptonote::block &block,
const std::vector<cryptonote::transaction> &txs,
@ -1434,7 +1442,7 @@ namespace service_nodes
}
else if (tx.type == cryptonote::txtype::state_change)
{
need_swarm_update += process_state_change_tx(state_history, alt_states, nettype, block, tx, my_keys);
need_swarm_update += process_state_change_tx(state_history, state_archive, alt_states, nettype, block, tx, my_keys);
}
else if (tx.type == cryptonote::txtype::key_image_unlock)
{
@ -1533,7 +1541,7 @@ namespace service_nodes
cryptonote::network_type nettype = m_blockchain.nettype();
m_state_history.insert(m_state_history.end(), m_state);
m_state.update_from_block(*m_db, nettype, m_state_history, {} /*m_alt_state*/, block, txs, m_service_node_keys);
m_state.update_from_block(*m_db, nettype, m_state_history, m_state_archive, {}, block, txs, m_service_node_keys);
}
void service_node_list::blockchain_detached(uint64_t height, bool /*by_pop_blocks*/)
@ -1815,7 +1823,7 @@ namespace service_nodes
}
state_t alt_state = *starting_state;
alt_state.update_from_block(*m_db, m_blockchain.nettype(), m_state_history, m_alt_state, block, txs, m_service_node_keys);
alt_state.update_from_block(*m_db, m_blockchain.nettype(), m_state_history, m_state_archive, m_alt_state, block, txs, m_service_node_keys);
m_alt_state[block_hash] = std::move(alt_state);
if (checkpoint)
@ -2269,7 +2277,7 @@ namespace service_nodes
state_t long_term_state = entry;
cryptonote::block const &block = m_db->get_block_from_height(long_term_state.height + 1);
std::vector<cryptonote::transaction> txs = m_db->get_tx_list(block.tx_hashes);
long_term_state.update_from_block(*m_db, m_blockchain.nettype(), {} /*state_history*/, {} /*alt_states*/, block, txs, nullptr /*my_keys*/);
long_term_state.update_from_block(*m_db, m_blockchain.nettype(), {} /*state_history*/, {} /*state_archive*/, {} /*alt_states*/, block, txs, nullptr /*my_keys*/);
entry.service_nodes_infos = {};
entry.key_image_blacklist = {};

View file

@ -431,6 +431,7 @@ namespace service_nodes
cryptonote::BlockchainDB const &db,
cryptonote::network_type nettype,
std::set<state_t> const &state_history,
std::set<state_t> const &state_archive,
std::unordered_map<crypto::hash, state_t> const &alt_states,
const cryptonote::block& block,
const std::vector<cryptonote::transaction>& txs,
@ -443,6 +444,7 @@ namespace service_nodes
// Returns true if a service node changed state (deregistered, decommissioned, or recommissioned)
bool process_state_change_tx(
std::set<state_t> const &state_history,
std::set<state_t> const &state_archive,
std::unordered_map<crypto::hash, state_t> const &alt_states,
cryptonote::network_type nettype,
const cryptonote::block &block,

View file

@ -660,7 +660,7 @@ bool loki_chain_generator::create_block(loki_blockchain_entry &entry,
fill_nonce(blk, TEST_DEFAULT_DIFFICULTY, height);
entry.txs = tx_list;
entry.service_node_state = prev.service_node_state;
entry.service_node_state.update_from_block(db_, cryptonote::FAKECHAIN, state_history_, {} /*alt_states*/, entry.block, entry.txs, nullptr);
entry.service_node_state.update_from_block(db_, cryptonote::FAKECHAIN, state_history_, {} /*state_archive*/, {} /*alt_states*/, entry.block, entry.txs, nullptr);
uint64_t block_reward, block_reward_unpenalized;
cryptonote::get_base_block_reward(epee::misc_utils::median(block_weights), entry.block_weight, prev.already_generated_coins, block_reward, block_reward_unpenalized, hf_version, height);