mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
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
This commit is contained in:
parent
4fea1a5fe7
commit
baf101ef4a
7 changed files with 18 additions and 17 deletions
|
@ -75,11 +75,12 @@
|
|||
#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_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
|
||||
|
|
|
@ -674,8 +674,8 @@ difficulty_type Blockchain::get_difficulty_for_next_block()
|
|||
m_timestamps = timestamps;
|
||||
m_difficulties = difficulties;
|
||||
}
|
||||
|
||||
return next_difficulty(timestamps, difficulties);
|
||||
size_t target = get_current_hard_fork_version() < 2 ? DIFFICULTY_TARGET_V1 : DIFFICULTY_TARGET;
|
||||
return next_difficulty(timestamps, difficulties, target);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
// 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
|
||||
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
|
||||
|
@ -2194,7 +2197,7 @@ bool Blockchain::is_tx_spendtime_unlocked(uint64_t unlock_time) const
|
|||
{
|
||||
//interpret as time
|
||||
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;
|
||||
else
|
||||
return false;
|
||||
|
|
|
@ -160,6 +160,8 @@ namespace cryptonote
|
|||
HardFork::State get_hard_fork_state() const;
|
||||
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(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 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);
|
||||
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)
|
||||
|
@ -571,7 +571,7 @@ difficulty_type blockchain_storage::get_next_difficulty_for_alternative_chain(co
|
|||
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
|
||||
|
@ -1505,7 +1505,7 @@ bool blockchain_storage::is_tx_spendtime_unlocked(uint64_t unlock_time) const
|
|||
{
|
||||
//interpret as time
|
||||
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;
|
||||
else
|
||||
return false;
|
||||
|
|
|
@ -157,8 +157,4 @@ namespace cryptonote {
|
|||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace
|
|||
for (size_t i = 0; i < new_block_count; ++i)
|
||||
{
|
||||
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,
|
||||
test_generator::bf_timestamp | test_generator::bf_diffic, 0, 0, blk_prev.timestamp, crypto::hash(), diffic))
|
||||
return false;
|
||||
|
@ -175,7 +175,7 @@ bool gen_block_invalid_nonce::generate(std::vector<test_event_entry>& events) co
|
|||
return false;
|
||||
|
||||
// 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);
|
||||
const block& blk_last = boost::get<block>(events.back());
|
||||
uint64_t timestamp = blk_last.timestamp;
|
||||
|
@ -570,7 +570,7 @@ bool gen_block_invalid_binary_format::generate(std::vector<test_event_entry>& ev
|
|||
do
|
||||
{
|
||||
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))
|
||||
return false;
|
||||
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;
|
||||
tx_hashes.push_back(get_transaction_hash(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,
|
||||
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))
|
||||
|
|
Loading…
Reference in a new issue