mirror of
https://github.com/monero-project/monero.git
synced 2025-07-24 21:35:22 -04:00
Merge upstream updates into blockchain branch
This commit is contained in:
commit
5c0bc0050c
94 changed files with 8927 additions and 2324 deletions
|
@ -87,6 +87,7 @@ bool blockchain_storage::init(const std::string& config_folder, bool testnet)
|
|||
{
|
||||
CRITICAL_REGION_LOCAL(m_blockchain_lock);
|
||||
m_config_folder = config_folder;
|
||||
m_testnet = testnet;
|
||||
LOG_PRINT_L0("Loading blockchain...");
|
||||
const std::string filename = m_config_folder + "/" CRYPTONOTE_BLOCKCHAINDATA_FILENAME;
|
||||
if(tools::unserialize_obj_from_file(*this, filename))
|
||||
|
@ -1699,7 +1700,14 @@ bool blockchain_storage::handle_block_to_main_chain(const block& bl, const crypt
|
|||
bei.bl = bl;
|
||||
bei.block_cumulative_size = cumulative_block_size;
|
||||
bei.cumulative_difficulty = current_diffic;
|
||||
bei.already_generated_coins = already_generated_coins + base_reward;
|
||||
|
||||
// In the "tail" state when the minimum subsidy (implemented in get_block_reward) is in effect, the number of
|
||||
// coins will eventually exceed MONEY_SUPPLY and overflow a uint64. To prevent overflow, cap already_generated_coins
|
||||
// at MONEY_SUPPLY. already_generated_coins is only used to compute the block subsidy and MONEY_SUPPLY yields a
|
||||
// subsidy of 0 under the base formula and therefore the minimum subsidy >0 in the tail state.
|
||||
|
||||
bei.already_generated_coins = base_reward < (MONEY_SUPPLY-already_generated_coins) ? already_generated_coins + base_reward : MONEY_SUPPLY;
|
||||
|
||||
if(m_blocks.size())
|
||||
bei.cumulative_difficulty += m_blocks.back().cumulative_difficulty;
|
||||
|
||||
|
@ -1823,7 +1831,7 @@ bool blockchain_storage::update_checkpoints(const std::string& file_path, bool c
|
|||
else if (check_dns)
|
||||
{
|
||||
checkpoints dns_points;
|
||||
cryptonote::load_checkpoints_from_dns(dns_points);
|
||||
cryptonote::load_checkpoints_from_dns(dns_points, m_testnet);
|
||||
if (m_checkpoints.check_for_conflicts(dns_points))
|
||||
{
|
||||
check_against_checkpoints(dns_points, false);
|
||||
|
|
|
@ -223,6 +223,7 @@ namespace cryptonote
|
|||
std::atomic<bool> m_is_blockchain_storing;
|
||||
|
||||
bool m_enforce_dns_checkpoints;
|
||||
bool m_testnet;
|
||||
|
||||
bool switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::iterator>& alt_chain, bool discard_disconnected_chain);
|
||||
bool pop_block_from_blockchain();
|
||||
|
|
|
@ -76,6 +76,7 @@ bool create_checkpoints(cryptonote::checkpoints& checkpoints)
|
|||
ADD_CHECKPOINT(231350, "b5add137199b820e1ea26640e5c3e121fd85faa86a1e39cf7e6cc097bdeb1131");
|
||||
ADD_CHECKPOINT(232150, "955de8e6b6508af2c24f7334f97beeea651d78e9ade3ab18fec3763be3201aa8");
|
||||
ADD_CHECKPOINT(249380, "654fb0a81ce3e5caf7e3264a70f447d4bd07586c08fa50f6638cc54da0a52b2d");
|
||||
ADD_CHECKPOINT(460000, "75037a7aed3e765db96c75bcf908f59d690a5f3390baebb9edeafd336a1c4831");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -112,7 +113,7 @@ bool load_checkpoints_from_json(cryptonote::checkpoints& checkpoints, std::strin
|
|||
return true;
|
||||
}
|
||||
|
||||
bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints)
|
||||
bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints, bool testnet)
|
||||
{
|
||||
// All four MoneroPulse domains have DNSSEC on and valid
|
||||
static const std::vector<std::string> dns_urls = { "checkpoints.moneropulse.se"
|
||||
|
@ -120,6 +121,12 @@ bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints)
|
|||
, "checkpoints.moneropulse.net"
|
||||
, "checkpoints.moneropulse.co"
|
||||
};
|
||||
|
||||
static const std::vector<std::string> testnet_dns_urls = { "testpoints.moneropulse.se"
|
||||
, "testpoints.moneropulse.org"
|
||||
, "testpoints.moneropulse.net"
|
||||
, "testpoints.moneropulse.co"
|
||||
};
|
||||
bool avail, valid;
|
||||
std::vector<std::string> records;
|
||||
|
||||
|
@ -131,7 +138,14 @@ bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints)
|
|||
size_t cur_index = first_index;
|
||||
do
|
||||
{
|
||||
records = tools::DNSResolver::instance().get_txt_record(dns_urls[cur_index], avail, valid);
|
||||
if (testnet)
|
||||
{
|
||||
records = tools::DNSResolver::instance().get_txt_record(testnet_dns_urls[cur_index], avail, valid);
|
||||
}
|
||||
else
|
||||
{
|
||||
records = tools::DNSResolver::instance().get_txt_record(dns_urls[cur_index], avail, valid);
|
||||
}
|
||||
if (records.size() == 0 || (avail && !valid))
|
||||
{
|
||||
cur_index++;
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace cryptonote
|
|||
bool create_checkpoints(cryptonote::checkpoints& checkpoints);
|
||||
|
||||
bool load_checkpoints_from_json(cryptonote::checkpoints& checkpoints, std::string json_hashfile_fullpath);
|
||||
bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints);
|
||||
bool load_checkpoints_from_dns(cryptonote::checkpoints& checkpoints, bool testnet = false);
|
||||
bool load_new_checkpoints(cryptonote::checkpoints& checkpoints, std::string json_hashfile_fullpath);
|
||||
|
||||
} // namespace cryptonote
|
||||
|
|
|
@ -60,6 +60,10 @@ namespace cryptonote {
|
|||
//-----------------------------------------------------------------------------------------------
|
||||
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward) {
|
||||
uint64_t base_reward = (MONEY_SUPPLY - already_generated_coins) >> EMISSION_SPEED_FACTOR;
|
||||
if (base_reward < FINAL_SUBSIDY_PER_MINUTE)
|
||||
{
|
||||
base_reward = FINAL_SUBSIDY_PER_MINUTE;
|
||||
}
|
||||
|
||||
//make it soft
|
||||
if (median_size < CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE) {
|
||||
|
|
|
@ -42,6 +42,8 @@ using namespace epee;
|
|||
#include "cryptonote_format_utils.h"
|
||||
#include "misc_language.h"
|
||||
#include <csignal>
|
||||
#include "daemon/command_line_args.h"
|
||||
#include "cryptonote_core/checkpoints_create.h"
|
||||
|
||||
DISABLE_VS_WARNINGS(4355)
|
||||
|
||||
|
@ -112,14 +114,41 @@ namespace cryptonote
|
|||
return res;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
void core::stop()
|
||||
{
|
||||
graceful_exit();
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
void core::init_options(boost::program_options::options_description& /*desc*/)
|
||||
{
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::handle_command_line(const boost::program_options::variables_map& vm, bool testnet)
|
||||
bool core::handle_command_line(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
auto data_dir_arg = testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir;
|
||||
m_testnet = command_line::get_arg(vm, daemon_args::arg_testnet_on);
|
||||
|
||||
auto data_dir_arg = m_testnet ? command_line::arg_testnet_data_dir : command_line::arg_data_dir;
|
||||
m_config_folder = command_line::get_arg(vm, data_dir_arg);
|
||||
|
||||
auto data_dir = boost::filesystem::path(m_config_folder);
|
||||
|
||||
if (!m_testnet)
|
||||
{
|
||||
cryptonote::checkpoints checkpoints;
|
||||
if (!cryptonote::create_checkpoints(checkpoints))
|
||||
{
|
||||
throw std::runtime_error("Failed to initialize checkpoints");
|
||||
}
|
||||
set_checkpoints(std::move(checkpoints));
|
||||
|
||||
boost::filesystem::path json(JSON_HASH_FILE_NAME);
|
||||
boost::filesystem::path checkpoint_json_hashfile_fullpath = data_dir / json;
|
||||
|
||||
set_checkpoints_file_path(checkpoint_json_hashfile_fullpath.string());
|
||||
}
|
||||
|
||||
|
||||
set_enforce_dns_checkpoints(command_line::get_arg(vm, daemon_args::arg_dns_checkpoints));
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
@ -158,21 +187,21 @@ namespace cryptonote
|
|||
return m_blockchain_storage.get_alternative_blocks_count();
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::init(const boost::program_options::variables_map& vm, bool testnet)
|
||||
bool core::init(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
bool r = handle_command_line(vm, testnet);
|
||||
bool r = handle_command_line(vm);
|
||||
|
||||
r = m_mempool.init(m_config_folder);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize memory pool");
|
||||
|
||||
r = m_blockchain_storage.init(m_config_folder, testnet);
|
||||
r = m_blockchain_storage.init(m_config_folder, m_testnet);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
|
||||
|
||||
// load json & DNS checkpoints, and verify them
|
||||
// with respect to what blocks we already have
|
||||
CHECK_AND_ASSERT_MES(update_checkpoints(), false, "One or more checkpoints loaded from json or dns conflicted with existing checkpoints.");
|
||||
|
||||
r = m_miner.init(vm, testnet);
|
||||
r = m_miner.init(vm, m_testnet);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to initialize blockchain storage");
|
||||
|
||||
return load_state_data();
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace cryptonote
|
|||
|
||||
miner& get_miner(){return m_miner;}
|
||||
static void init_options(boost::program_options::options_description& desc);
|
||||
bool init(const boost::program_options::variables_map& vm, bool testnet);
|
||||
bool init(const boost::program_options::variables_map& vm);
|
||||
bool set_genesis_block(const block& b);
|
||||
bool deinit();
|
||||
uint64_t get_current_blockchain_height();
|
||||
|
@ -133,6 +133,8 @@ namespace cryptonote
|
|||
|
||||
bool update_checkpoints();
|
||||
|
||||
void stop();
|
||||
|
||||
private:
|
||||
bool add_new_tx(const transaction& tx, const crypto::hash& tx_hash, const crypto::hash& tx_prefix_hash, size_t blob_size, tx_verification_context& tvc, bool keeped_by_block);
|
||||
bool add_new_tx(const transaction& tx, tx_verification_context& tvc, bool keeped_by_block);
|
||||
|
@ -150,7 +152,7 @@ namespace cryptonote
|
|||
bool check_tx_ring_signature(const txin_to_key& tx, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig);
|
||||
bool is_tx_spendtime_unlocked(uint64_t unlock_time);
|
||||
bool update_miner_block_template();
|
||||
bool handle_command_line(const boost::program_options::variables_map& vm, bool testnet);
|
||||
bool handle_command_line(const boost::program_options::variables_map& vm);
|
||||
bool on_update_blocktemplate_interval();
|
||||
bool check_tx_inputs_keyimages_diff(const transaction& tx);
|
||||
void graceful_exit();
|
||||
|
@ -175,6 +177,7 @@ namespace cryptonote
|
|||
|
||||
uint64_t m_target_blockchain_height;
|
||||
|
||||
bool m_testnet;
|
||||
std::string m_checkpoints_path;
|
||||
time_t m_last_dns_checkpoints_update;
|
||||
time_t m_last_json_checkpoints_update;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue