mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-23 21:57:46 +00:00
Merge pull request #490
baf101e
More changes for 2-min blocks Use the correct block time for realtime fuzz on locktime Use the correct block time to calculate next_difficulty on alt chains (will not work as-is with voting) Lock unit tests to original block time for now (Javier Smooth)4fea1a5
Adjust difficulty target (2 min) and full reward zone (60 kbytes) for block version 2 (Javier Smooth)
This commit is contained in:
commit
0d09e15a1c
12 changed files with 56 additions and 43 deletions
|
@ -51,11 +51,12 @@
|
||||||
|
|
||||||
// MONEY_SUPPLY - total number coins to be generated
|
// MONEY_SUPPLY - total number coins to be generated
|
||||||
#define MONEY_SUPPLY ((uint64_t)(-1))
|
#define MONEY_SUPPLY ((uint64_t)(-1))
|
||||||
#define EMISSION_SPEED_FACTOR (20)
|
#define EMISSION_SPEED_FACTOR_PER_MINUTE (20)
|
||||||
#define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)300000000000) // 3 * pow(10, 11)
|
#define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)300000000000) // 3 * pow(10, 11)
|
||||||
|
|
||||||
#define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
|
#define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
|
||||||
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE 20000 //size of block (bytes) after which reward for block calculated using block size
|
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE 60000 //size of block (bytes) after which reward for block calculated using block size
|
||||||
|
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 20000 //size of block (bytes) after which reward for block calculated using block size - before first fork
|
||||||
#define CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE 600
|
#define CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE 600
|
||||||
#define CRYPTONOTE_DISPLAY_DECIMAL_POINT 12
|
#define CRYPTONOTE_DISPLAY_DECIMAL_POINT 12
|
||||||
// COIN - number of smallest units in one coin
|
// COIN - number of smallest units in one coin
|
||||||
|
@ -66,18 +67,20 @@
|
||||||
#define ORPHANED_BLOCKS_MAX_COUNT 100
|
#define ORPHANED_BLOCKS_MAX_COUNT 100
|
||||||
|
|
||||||
|
|
||||||
#define DIFFICULTY_TARGET 60 // seconds
|
#define DIFFICULTY_TARGET 120 // seconds
|
||||||
|
#define DIFFICULTY_TARGET_V1 60 // seconds - before first fork
|
||||||
#define DIFFICULTY_WINDOW 720 // blocks
|
#define DIFFICULTY_WINDOW 720 // blocks
|
||||||
#define DIFFICULTY_LAG 15 // !!!
|
#define DIFFICULTY_LAG 15 // !!!
|
||||||
#define DIFFICULTY_CUT 60 // timestamps to cut after sorting
|
#define DIFFICULTY_CUT 60 // timestamps to cut after sorting
|
||||||
#define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
|
#define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
|
||||||
|
|
||||||
|
|
||||||
|
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 DIFFICULTY_TARGET_V1 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
|
||||||
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS DIFFICULTY_TARGET * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
|
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS DIFFICULTY_TARGET * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
|
||||||
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
|
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
|
||||||
|
|
||||||
|
|
||||||
#define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN DIFFICULTY_TARGET //just alias
|
#define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN DIFFICULTY_TARGET_V1 //just alias; used by tests
|
||||||
|
|
||||||
|
|
||||||
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
|
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
|
||||||
|
|
|
@ -674,8 +674,8 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
|
||||||
m_timestamps = timestamps;
|
m_timestamps = timestamps;
|
||||||
m_difficulties = difficulties;
|
m_difficulties = difficulties;
|
||||||
}
|
}
|
||||||
|
size_t target = get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET;
|
||||||
return next_difficulty(timestamps, difficulties);
|
return next_difficulty(timestamps, difficulties, target);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// This function removes blocks from the blockchain until it gets to the
|
// This function removes blocks from the blockchain until it gets to the
|
||||||
|
@ -865,8 +865,11 @@ difficulty_type Blockchain::get_next_difficulty_for_alternative_chain(const std:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: This will fail if fork activation heights are subject to voting
|
||||||
|
size_t target = get_ideal_hard_fork_version(bei.height) < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET;
|
||||||
|
|
||||||
// calculate the difficulty target for the block and return it
|
// calculate the difficulty target for the block and return it
|
||||||
return next_difficulty(timestamps, cumulative_difficulties);
|
return next_difficulty(timestamps, cumulative_difficulties, target);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
// This function does a sanity check on basic things that all miner
|
// This function does a sanity check on basic things that all miner
|
||||||
|
@ -910,7 +913,7 @@ bool Blockchain::validate_miner_transaction(const block& b, size_t cumulative_bl
|
||||||
|
|
||||||
std::vector<size_t> last_blocks_sizes;
|
std::vector<size_t> last_blocks_sizes;
|
||||||
get_last_n_blocks_sizes(last_blocks_sizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
get_last_n_blocks_sizes(last_blocks_sizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
||||||
if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward))
|
if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward, get_current_hard_fork_version()))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L1("block size " << cumulative_block_size << " is bigger than allowed for this blockchain");
|
LOG_PRINT_L1("block size " << cumulative_block_size << " is bigger than allowed for this blockchain");
|
||||||
return false;
|
return false;
|
||||||
|
@ -2194,7 +2197,7 @@ bool Blockchain::is_tx_spendtime_unlocked(uint64_t unlock_time) const
|
||||||
{
|
{
|
||||||
//interpret as time
|
//interpret as time
|
||||||
uint64_t current_time = static_cast<uint64_t>(time(NULL));
|
uint64_t current_time = static_cast<uint64_t>(time(NULL));
|
||||||
if(current_time + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS >= unlock_time)
|
if(current_time + (get_current_hard_fork_version() < 2 ? CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 : CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS) >= unlock_time)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -2604,11 +2607,12 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash&
|
||||||
|
|
||||||
TIME_MEASURE_FINISH(addblock);
|
TIME_MEASURE_FINISH(addblock);
|
||||||
|
|
||||||
update_next_cumulative_size_limit();
|
|
||||||
|
|
||||||
// this will not fail since check succeeded above
|
// this will not fail since check succeeded above
|
||||||
m_hardfork->add(bl, new_height - 1);
|
m_hardfork->add(bl, new_height - 1);
|
||||||
|
|
||||||
|
// do this after updating the hard fork state since the size limit may change due to fork
|
||||||
|
update_next_cumulative_size_limit();
|
||||||
|
|
||||||
LOG_PRINT_L1("+++++ BLOCK SUCCESSFULLY ADDED" << std::endl << "id:\t" << id << std::endl << "PoW:\t" << proof_of_work << std::endl << "HEIGHT " << new_height << ", difficulty:\t" << current_diffic << std::endl << "block reward: " << print_money(fee_summary + base_reward) << "(" << print_money(base_reward) << " + " << print_money(fee_summary) << "), coinbase_blob_size: " << coinbase_blob_size << ", cumulative size: " << cumulative_block_size << ", " << block_processing_time << "(" << target_calculating_time << "/" << longhash_calculating_time << ")ms");
|
LOG_PRINT_L1("+++++ BLOCK SUCCESSFULLY ADDED" << std::endl << "id:\t" << id << std::endl << "PoW:\t" << proof_of_work << std::endl << "HEIGHT " << new_height << ", difficulty:\t" << current_diffic << std::endl << "block reward: " << print_money(fee_summary + base_reward) << "(" << print_money(base_reward) << " + " << print_money(fee_summary) << "), coinbase_blob_size: " << coinbase_blob_size << ", cumulative size: " << cumulative_block_size << ", " << block_processing_time << "(" << target_calculating_time << "/" << longhash_calculating_time << ")ms");
|
||||||
if(m_show_time_stats)
|
if(m_show_time_stats)
|
||||||
{
|
{
|
||||||
|
@ -2630,13 +2634,15 @@ bool Blockchain::handle_block_to_main_chain(const block& bl, const crypto::hash&
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool Blockchain::update_next_cumulative_size_limit()
|
bool Blockchain::update_next_cumulative_size_limit()
|
||||||
{
|
{
|
||||||
|
uint64_t full_reward_zone = get_current_hard_fork_version() < 2 ? CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 : CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
|
||||||
|
|
||||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||||
std::vector<size_t> sz;
|
std::vector<size_t> sz;
|
||||||
get_last_n_blocks_sizes(sz, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
get_last_n_blocks_sizes(sz, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
||||||
|
|
||||||
uint64_t median = epee::misc_utils::median(sz);
|
uint64_t median = epee::misc_utils::median(sz);
|
||||||
if(median <= CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE)
|
if(median <= full_reward_zone)
|
||||||
median = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
|
median = full_reward_zone;
|
||||||
|
|
||||||
m_current_block_cumul_sz_limit = median*2;
|
m_current_block_cumul_sz_limit = median*2;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -160,6 +160,8 @@ namespace cryptonote
|
||||||
HardFork::State get_hard_fork_state() const;
|
HardFork::State get_hard_fork_state() const;
|
||||||
uint8_t get_current_hard_fork_version() const { return m_hardfork->get_current_version(); }
|
uint8_t get_current_hard_fork_version() const { return m_hardfork->get_current_version(); }
|
||||||
uint8_t get_ideal_hard_fork_version() const { return m_hardfork->get_ideal_version(); }
|
uint8_t get_ideal_hard_fork_version() const { return m_hardfork->get_ideal_version(); }
|
||||||
|
uint8_t get_ideal_hard_fork_version(uint64_t height) const { return m_hardfork->get_ideal_version(height); }
|
||||||
|
|
||||||
bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const;
|
bool get_hard_fork_voting_info(uint8_t version, uint32_t &window, uint32_t &votes, uint32_t &threshold, uint8_t &voting) const;
|
||||||
|
|
||||||
bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const;
|
bool for_all_key_images(std::function<bool(const crypto::key_image&)>) const;
|
||||||
|
|
|
@ -430,7 +430,7 @@ difficulty_type blockchain_storage::get_difficulty_for_next_block() const
|
||||||
timestamps.push_back(m_blocks[offset].bl.timestamp);
|
timestamps.push_back(m_blocks[offset].bl.timestamp);
|
||||||
commulative_difficulties.push_back(m_blocks[offset].cumulative_difficulty);
|
commulative_difficulties.push_back(m_blocks[offset].cumulative_difficulty);
|
||||||
}
|
}
|
||||||
return next_difficulty(timestamps, commulative_difficulties);
|
return next_difficulty(timestamps, commulative_difficulties,DIFFICULTY_TARGET_V1);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool blockchain_storage::rollback_blockchain_switching(std::list<block>& original_chain, size_t rollback_height)
|
bool blockchain_storage::rollback_blockchain_switching(std::list<block>& original_chain, size_t rollback_height)
|
||||||
|
@ -571,7 +571,7 @@ difficulty_type blockchain_storage::get_next_difficulty_for_alternative_chain(co
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return next_difficulty(timestamps, commulative_difficulties);
|
return next_difficulty(timestamps, commulative_difficulties,DIFFICULTY_TARGET_V1);
|
||||||
}
|
}
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
bool blockchain_storage::prevalidate_miner_transaction(const block& b, uint64_t height) const
|
bool blockchain_storage::prevalidate_miner_transaction(const block& b, uint64_t height) const
|
||||||
|
@ -606,7 +606,7 @@ bool blockchain_storage::validate_miner_transaction(const block& b, size_t cumul
|
||||||
|
|
||||||
std::vector<size_t> last_blocks_sizes;
|
std::vector<size_t> last_blocks_sizes;
|
||||||
get_last_n_blocks_sizes(last_blocks_sizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
get_last_n_blocks_sizes(last_blocks_sizes, CRYPTONOTE_REWARD_BLOCKS_WINDOW);
|
||||||
if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward)) {
|
if (!get_block_reward(epee::misc_utils::median(last_blocks_sizes), cumulative_block_size, already_generated_coins, base_reward,0)) {
|
||||||
LOG_PRINT_L1("block size " << cumulative_block_size << " is bigger than allowed for this blockchain");
|
LOG_PRINT_L1("block size " << cumulative_block_size << " is bigger than allowed for this blockchain");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1505,7 +1505,7 @@ bool blockchain_storage::is_tx_spendtime_unlocked(uint64_t unlock_time) const
|
||||||
{
|
{
|
||||||
//interpret as time
|
//interpret as time
|
||||||
uint64_t current_time = static_cast<uint64_t>(time(NULL));
|
uint64_t current_time = static_cast<uint64_t>(time(NULL));
|
||||||
if(current_time + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS >= unlock_time)
|
if(current_time + CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 >= unlock_time)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -73,16 +73,23 @@ namespace cryptonote {
|
||||||
return CRYPTONOTE_MAX_TX_SIZE;
|
return CRYPTONOTE_MAX_TX_SIZE;
|
||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------------------------
|
||||||
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward) {
|
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version) {
|
||||||
uint64_t base_reward = (MONEY_SUPPLY - already_generated_coins) >> EMISSION_SPEED_FACTOR;
|
static_assert(DIFFICULTY_TARGET%60==0&&DIFFICULTY_TARGET_V1%60==0,"difficulty targets must be a multiple of 60");
|
||||||
if (base_reward < FINAL_SUBSIDY_PER_MINUTE)
|
const int target = version < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET;
|
||||||
|
const int target_minutes = target / 60;
|
||||||
|
const int emission_speed_factor = EMISSION_SPEED_FACTOR_PER_MINUTE - (target_minutes-1);
|
||||||
|
|
||||||
|
uint64_t base_reward = (MONEY_SUPPLY - already_generated_coins) >> emission_speed_factor;
|
||||||
|
if (base_reward < FINAL_SUBSIDY_PER_MINUTE*target_minutes)
|
||||||
{
|
{
|
||||||
base_reward = FINAL_SUBSIDY_PER_MINUTE;
|
base_reward = FINAL_SUBSIDY_PER_MINUTE*target_minutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t full_reward_zone = version < 2 ? CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 : CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
|
||||||
|
|
||||||
//make it soft
|
//make it soft
|
||||||
if (median_size < CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE) {
|
if (median_size < full_reward_zone) {
|
||||||
median_size = CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
|
median_size = full_reward_zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_block_size <= median_size) {
|
if (current_block_size <= median_size) {
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace cryptonote {
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
size_t get_max_block_size();
|
size_t get_max_block_size();
|
||||||
size_t get_max_tx_size();
|
size_t get_max_tx_size();
|
||||||
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward);
|
bool get_block_reward(size_t median_size, size_t current_block_size, uint64_t already_generated_coins, uint64_t &reward, uint8_t version);
|
||||||
uint8_t get_account_address_checksum(const public_address_outer_blob& bl);
|
uint8_t get_account_address_checksum(const public_address_outer_blob& bl);
|
||||||
uint8_t get_account_integrated_address_checksum(const public_integrated_address_outer_blob& bl);
|
uint8_t get_account_integrated_address_checksum(const public_integrated_address_outer_blob& bl);
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ namespace cryptonote
|
||||||
in.height = height;
|
in.height = height;
|
||||||
|
|
||||||
uint64_t block_reward;
|
uint64_t block_reward;
|
||||||
if(!get_block_reward(median_size, current_block_size, already_generated_coins, block_reward))
|
if(!get_block_reward(median_size, current_block_size, already_generated_coins, block_reward, hard_fork_version))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Block is too big");
|
LOG_PRINT_L0("Block is too big");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -157,8 +157,4 @@ namespace cryptonote {
|
||||||
return (low + time_span - 1) / time_span;
|
return (low + time_span - 1) / time_span;
|
||||||
}
|
}
|
||||||
|
|
||||||
difficulty_type next_difficulty(vector<uint64_t> timestamps, vector<difficulty_type> cumulative_difficulties)
|
|
||||||
{
|
|
||||||
return next_difficulty(std::move(timestamps), std::move(cumulative_difficulties), DIFFICULTY_TARGET);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,5 @@ namespace cryptonote
|
||||||
typedef std::uint64_t difficulty_type;
|
typedef std::uint64_t difficulty_type;
|
||||||
|
|
||||||
bool check_hash(const crypto::hash &hash, difficulty_type difficulty);
|
bool check_hash(const crypto::hash &hash, difficulty_type difficulty);
|
||||||
difficulty_type next_difficulty(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties);
|
|
||||||
difficulty_type next_difficulty(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
|
difficulty_type next_difficulty(std::vector<std::uint64_t> timestamps, std::vector<difficulty_type> cumulative_difficulties, size_t target_seconds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace
|
||||||
for (size_t i = 0; i < new_block_count; ++i)
|
for (size_t i = 0; i < new_block_count; ++i)
|
||||||
{
|
{
|
||||||
block blk_next;
|
block blk_next;
|
||||||
difficulty_type diffic = next_difficulty(timestamps, cummulative_difficulties);
|
difficulty_type diffic = next_difficulty(timestamps, cummulative_difficulties,DIFFICULTY_TARGET_V1);
|
||||||
if (!generator.construct_block_manually(blk_next, blk_prev, miner_account,
|
if (!generator.construct_block_manually(blk_next, blk_prev, miner_account,
|
||||||
test_generator::bf_timestamp | test_generator::bf_diffic, 0, 0, blk_prev.timestamp, crypto::hash(), diffic))
|
test_generator::bf_timestamp | test_generator::bf_diffic, 0, 0, blk_prev.timestamp, crypto::hash(), diffic))
|
||||||
return false;
|
return false;
|
||||||
|
@ -175,7 +175,7 @@ bool gen_block_invalid_nonce::generate(std::vector<test_event_entry>& events) co
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create invalid nonce
|
// Create invalid nonce
|
||||||
difficulty_type diffic = next_difficulty(timestamps, commulative_difficulties);
|
difficulty_type diffic = next_difficulty(timestamps, commulative_difficulties,DIFFICULTY_TARGET_V1);
|
||||||
assert(1 < diffic);
|
assert(1 < diffic);
|
||||||
const block& blk_last = boost::get<block>(events.back());
|
const block& blk_last = boost::get<block>(events.back());
|
||||||
uint64_t timestamp = blk_last.timestamp;
|
uint64_t timestamp = blk_last.timestamp;
|
||||||
|
@ -570,7 +570,7 @@ bool gen_block_invalid_binary_format::generate(std::vector<test_event_entry>& ev
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
blk_last = boost::get<block>(events.back());
|
blk_last = boost::get<block>(events.back());
|
||||||
diffic = next_difficulty(timestamps, cummulative_difficulties);
|
diffic = next_difficulty(timestamps, cummulative_difficulties,DIFFICULTY_TARGET_V1);
|
||||||
if (!lift_up_difficulty(events, timestamps, cummulative_difficulties, generator, 1, blk_last, miner_account))
|
if (!lift_up_difficulty(events, timestamps, cummulative_difficulties, generator, 1, blk_last, miner_account))
|
||||||
return false;
|
return false;
|
||||||
std::cout << "Block #" << events.size() << ", difficulty: " << diffic << std::endl;
|
std::cout << "Block #" << events.size() << ", difficulty: " << diffic << std::endl;
|
||||||
|
@ -585,7 +585,7 @@ bool gen_block_invalid_binary_format::generate(std::vector<test_event_entry>& ev
|
||||||
std::vector<crypto::hash> tx_hashes;
|
std::vector<crypto::hash> tx_hashes;
|
||||||
tx_hashes.push_back(get_transaction_hash(tx_0));
|
tx_hashes.push_back(get_transaction_hash(tx_0));
|
||||||
size_t txs_size = get_object_blobsize(tx_0);
|
size_t txs_size = get_object_blobsize(tx_0);
|
||||||
diffic = next_difficulty(timestamps, cummulative_difficulties);
|
diffic = next_difficulty(timestamps, cummulative_difficulties,DIFFICULTY_TARGET_V1);
|
||||||
if (!generator.construct_block_manually(blk_test, blk_last, miner_account,
|
if (!generator.construct_block_manually(blk_test, blk_last, miner_account,
|
||||||
test_generator::bf_diffic | test_generator::bf_timestamp | test_generator::bf_tx_hashes, 0, 0, blk_last.timestamp,
|
test_generator::bf_diffic | test_generator::bf_timestamp | test_generator::bf_tx_hashes, 0, 0, blk_last.timestamp,
|
||||||
crypto::hash(), diffic, transaction(), tx_hashes, txs_size))
|
crypto::hash(), diffic, transaction(), tx_hashes, txs_size))
|
||||||
|
|
|
@ -98,7 +98,7 @@ void test_generator::add_block(const cryptonote::block& blk, size_t tsx_size, st
|
||||||
{
|
{
|
||||||
const size_t block_size = tsx_size + get_object_blobsize(blk.miner_tx);
|
const size_t block_size = tsx_size + get_object_blobsize(blk.miner_tx);
|
||||||
uint64_t block_reward;
|
uint64_t block_reward;
|
||||||
get_block_reward(misc_utils::median(block_sizes), block_size, already_generated_coins, block_reward);
|
get_block_reward(misc_utils::median(block_sizes), block_size, already_generated_coins, block_reward, 1);
|
||||||
m_blocks_info[get_block_hash(blk)] = block_info(blk.prev_id, already_generated_coins + block_reward, block_size);
|
m_blocks_info[get_block_hash(blk)] = block_info(blk.prev_id, already_generated_coins + block_reward, block_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
|
||||||
|
|
||||||
// This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
|
// This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
|
||||||
uint64_t block_reward;
|
uint64_t block_reward;
|
||||||
if (!get_block_reward(0, 0, already_generated_coins, block_reward))
|
if (!get_block_reward(0, 0, already_generated_coins, block_reward, 1))
|
||||||
{
|
{
|
||||||
LOG_PRINT_L0("Block is too big");
|
LOG_PRINT_L0("Block is too big");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace
|
||||||
};
|
};
|
||||||
|
|
||||||
#define TEST_ALREADY_GENERATED_COINS(already_generated_coins, expected_reward) \
|
#define TEST_ALREADY_GENERATED_COINS(already_generated_coins, expected_reward) \
|
||||||
m_block_not_too_big = get_block_reward(0, current_block_size, already_generated_coins, m_block_reward); \
|
m_block_not_too_big = get_block_reward(0, current_block_size, already_generated_coins, m_block_reward,1); \
|
||||||
ASSERT_TRUE(m_block_not_too_big); \
|
ASSERT_TRUE(m_block_not_too_big); \
|
||||||
ASSERT_EQ(m_block_reward, expected_reward);
|
ASSERT_EQ(m_block_reward, expected_reward);
|
||||||
|
|
||||||
|
@ -79,14 +79,14 @@ namespace
|
||||||
protected:
|
protected:
|
||||||
virtual void SetUp()
|
virtual void SetUp()
|
||||||
{
|
{
|
||||||
m_block_not_too_big = get_block_reward(0, 0, already_generated_coins, m_standard_block_reward);
|
m_block_not_too_big = get_block_reward(0, 0, already_generated_coins, m_standard_block_reward, 1);
|
||||||
ASSERT_TRUE(m_block_not_too_big);
|
ASSERT_TRUE(m_block_not_too_big);
|
||||||
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward);
|
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_test(size_t median_block_size, size_t current_block_size)
|
void do_test(size_t median_block_size, size_t current_block_size)
|
||||||
{
|
{
|
||||||
m_block_not_too_big = get_block_reward(median_block_size, current_block_size, already_generated_coins, m_block_reward);
|
m_block_not_too_big = get_block_reward(median_block_size, current_block_size, already_generated_coins, m_block_reward, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint64_t already_generated_coins = 0;
|
static const uint64_t already_generated_coins = 0;
|
||||||
|
@ -168,14 +168,14 @@ namespace
|
||||||
|
|
||||||
m_last_block_sizes_median = 7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
|
m_last_block_sizes_median = 7 * CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE;
|
||||||
|
|
||||||
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), 0, already_generated_coins, m_standard_block_reward);
|
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), 0, already_generated_coins, m_standard_block_reward, 1);
|
||||||
ASSERT_TRUE(m_block_not_too_big);
|
ASSERT_TRUE(m_block_not_too_big);
|
||||||
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward);
|
ASSERT_LT(CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE, m_standard_block_reward);
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_test(size_t current_block_size)
|
void do_test(size_t current_block_size)
|
||||||
{
|
{
|
||||||
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), current_block_size, already_generated_coins, m_block_reward);
|
m_block_not_too_big = get_block_reward(epee::misc_utils::median(m_last_block_sizes), current_block_size, already_generated_coins, m_block_reward, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint64_t already_generated_coins = 0;
|
static const uint64_t already_generated_coins = 0;
|
||||||
|
|
Loading…
Reference in a new issue