forked from lthn/blockchain
get_actual_timestamp() -> get_block_timestamp_from_miner_tx_extra(), corresponding check in pos block validation has been adjusted
This commit is contained in:
parent
3804ecd4d6
commit
964968ded0
5 changed files with 17 additions and 16 deletions
|
|
@ -5705,15 +5705,19 @@ bool blockchain_storage::validate_pos_block(const block& b,
|
|||
CHECK_AND_ASSERT_MES(!have_tx_keyimg_as_spent(stake_key_image), false, "stake key image has been already spent in blockchain: " << stake_key_image);
|
||||
}
|
||||
|
||||
// the following check is de-facto not applicable since 2021-10, but left intact to avoid consensus issues
|
||||
// PoS blocks don't use etc_tx_time anymore to store actual timestamp; instead, they use tx_service_attachment in mining tx extra
|
||||
uint64_t actual_ts = get_actual_timestamp(b);
|
||||
if ((actual_ts > b.timestamp && actual_ts - b.timestamp > POS_MAX_ACTUAL_TIMESTAMP_TO_MINED) ||
|
||||
(actual_ts < b.timestamp && b.timestamp - actual_ts > POS_MAX_ACTUAL_TIMESTAMP_TO_MINED)
|
||||
)
|
||||
if (!is_hardfork_active(ZANO_HARDFORK_04_ZARCANUM))
|
||||
{
|
||||
LOG_PRINT_L0("PoS block actual timestamp " << actual_ts << " differs from b.timestamp " << b.timestamp << " by " << ((int64_t)actual_ts - (int64_t)b.timestamp) << " s, it's more than allowed " << POS_MAX_ACTUAL_TIMESTAMP_TO_MINED << " s.");
|
||||
return false;
|
||||
// the following check is de-facto not applicable since 2021-10, but left intact to avoid consensus issues
|
||||
// PoS blocks don't use etc_tx_time anymore to store actual timestamp; instead, they use tx_service_attachment in mining tx extra
|
||||
// TODO: remove this entire section after HF4 -- sowle
|
||||
uint64_t actual_ts = get_block_timestamp_from_miner_tx_extra(b);
|
||||
if ((actual_ts > b.timestamp && actual_ts - b.timestamp > POS_MAX_ACTUAL_TIMESTAMP_TO_MINED) ||
|
||||
(actual_ts < b.timestamp && b.timestamp - actual_ts > POS_MAX_ACTUAL_TIMESTAMP_TO_MINED)
|
||||
)
|
||||
{
|
||||
LOG_PRINT_L0("PoS block actual timestamp " << actual_ts << " differs from b.timestamp " << b.timestamp << " by " << ((int64_t)actual_ts - (int64_t)b.timestamp) << " s, it's more than allowed " << POS_MAX_ACTUAL_TIMESTAMP_TO_MINED << " s.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// build kernel and calculate hash
|
||||
|
|
|
|||
|
|
@ -3396,9 +3396,8 @@ namespace currency
|
|||
return median_fee * 10;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
// NOTE: this function is obsolete and depricated
|
||||
[[deprecated("PoS block real timestamp is set using a service attachment in mining tx extra since 2021-10")]]
|
||||
uint64_t get_actual_timestamp(const block& b)
|
||||
// TODO: remove this function after HF4 -- sowle
|
||||
uint64_t get_block_timestamp_from_miner_tx_extra(const block& b)
|
||||
{
|
||||
uint64_t tes_ts = b.timestamp;
|
||||
if (is_pos_block(b))
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ namespace currency
|
|||
|
||||
// prints amount in format "3.14", "0.0"
|
||||
std::string print_money_brief(uint64_t amount, size_t decimal_point = CURRENCY_DISPLAY_DECIMAL_POINT);
|
||||
uint64_t get_actual_timestamp(const block& b); // obsolete and depricated, use get_block_datetime
|
||||
uint64_t get_block_timestamp_from_miner_tx_extra(const block& b); // remove this function after HF4 -- sowle
|
||||
uint64_t get_block_datetime(const block& b);
|
||||
void set_block_datetime(uint64_t datetime, block& b);
|
||||
|
||||
|
|
@ -425,8 +425,6 @@ namespace currency
|
|||
bool does_tx_have_only_mixin_inputs(const transaction& tx);
|
||||
bool is_showing_sender_addres(const transaction& tx);
|
||||
bool check_native_coins_amount_burnt_in_outs(const transaction& tx, const uint64_t amount, uint64_t* p_amount_burnt = nullptr);
|
||||
[[deprecated("Use check_native_coins_amount_burnt_in_outs instead")]] uint64_t get_amount_for_zero_pubkeys(const transaction& tx);
|
||||
//std::string get_comment_from_tx(const transaction& tx);
|
||||
std::string print_stake_kernel_info(const stake_kernel& sk);
|
||||
std::string dump_ring_sig_data(const crypto::hash& hash_for_sig, const crypto::key_image& k_image, const std::vector<const crypto::public_key*>& output_keys_ptrs, const std::vector<crypto::signature>& sig);
|
||||
|
||||
|
|
|
|||
|
|
@ -1458,7 +1458,7 @@ bool fill_tx_sources(std::vector<currency::tx_source_entry>& sources, const std:
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t head_block_ts = get_actual_timestamp(blk_head);
|
||||
uint64_t head_block_ts = get_block_datetime(blk_head);
|
||||
uint64_t next_block_height = blockchain.size();
|
||||
|
||||
// Iterate in reverse is more efficiency
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ bool emission_test::c1(currency::core& c, size_t ev_index, const std::vector<tes
|
|||
|
||||
c.handle_incoming_block(t_serializable_object_to_blob(pb.m_block), bvc);
|
||||
CHECK_AND_NO_ASSERT_MES(!bvc.m_verification_failed && !bvc.m_marked_as_orphaned && !bvc.m_already_exists, false, "PoS block verification context check failed");
|
||||
//CHECK_AND_ASSERT_MES(get_actual_timestamp(pb.m_block) == timestamp, false, "Invalid PoS block ts: " << get_actual_timestamp(pb.m_block) << ", expected: " << timestamp);
|
||||
//CHECK_AND_ASSERT_MES(get_block_datetime(pb.m_block) == timestamp, false, "Invalid PoS block ts: " << get_block_datetime(pb.m_block) << ", expected: " << timestamp);
|
||||
gen_coins = get_outs_money_amount(pb.m_block.miner_tx) - boost::get<txin_to_key>(pb.m_block.miner_tx.vin[1]).amount;
|
||||
already_generated_coins += gen_coins;
|
||||
CHECK_AND_ASSERT_MES(already_generated_coins == bcs.total_coins(), false, "total coins missmatch: BCS has: " << bcs.total_coins() << ", expected: " << already_generated_coins);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue