forked from lthn/blockchain
moved htlc from hardfork 2 to hardfork 3
This commit is contained in:
parent
6fea62ddf7
commit
38aab2c61c
9 changed files with 41 additions and 71 deletions
|
|
@ -3331,9 +3331,9 @@ bool blockchain_storage::push_transaction_to_global_outs_index(const transaction
|
|||
{
|
||||
m_db_outputs.push_back_item(ot.amount, global_output_entry::construct(tx_id, i));
|
||||
global_indexes.push_back(m_db_outputs.get_item_size(ot.amount) - 1);
|
||||
if (ot.target.type() == typeid(txout_htlc) && !is_after_hardfork_2_zone())
|
||||
if (ot.target.type() == typeid(txout_htlc) && !is_after_hardfork_3_zone())
|
||||
{
|
||||
LOG_ERROR("Error: Transaction with txout_htlc before is_after_hardfork_2_zone(before height " << m_core_runtime_config.hard_fork_02_starts_after_height <<")");
|
||||
LOG_ERROR("Error: Transaction with txout_htlc before is_after_hardfork_3_zone(before height " << m_core_runtime_config.hard_fork_03_starts_after_height <<")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -3849,9 +3849,9 @@ namespace currency
|
|||
}
|
||||
bool operator()(const txin_htlc& in) const
|
||||
{
|
||||
if (!m_bcs.is_after_hardfork_2_zone())
|
||||
if (!m_bcs.is_after_hardfork_3_zone())
|
||||
{
|
||||
LOG_ERROR("Error: Transaction with txin_htlc before is_after_hardfork_2_zone(before height " << m_bcs.get_core_runtime_config().hard_fork_02_starts_after_height << ")");
|
||||
LOG_ERROR("Error: Transaction with txin_htlc before is_after_hardfork_3_zone(before height " << m_bcs.get_core_runtime_config().hard_fork_03_starts_after_height << ")");
|
||||
return false;
|
||||
}
|
||||
return this->operator()(static_cast<const txin_to_key&>(in));
|
||||
|
|
@ -4272,9 +4272,9 @@ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::ha
|
|||
}
|
||||
else if (txin.type() == typeid(txin_htlc))
|
||||
{
|
||||
if (!is_after_hardfork_2_zone())
|
||||
if (!is_after_hardfork_3_zone())
|
||||
{
|
||||
LOG_ERROR("Error: Transaction with txin_htlc before is_after_hardfork_2_zone(before height " << m_core_runtime_config.hard_fork_02_starts_after_height << ")");
|
||||
LOG_ERROR("Error: Transaction with txin_htlc before is_after_hardfork_3_zone(before height " << m_core_runtime_config.hard_fork_03_starts_after_height << ")");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -4919,34 +4919,6 @@ void blockchain_storage::get_pos_mining_estimate(uint64_t amount_coins,
|
|||
estimate_result = current_amount;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
// bool check_tx_fit_hardfork(const transaction& tx);
|
||||
|
||||
/*
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::check_tx_fit_hardfork(const transaction& tx)
|
||||
{
|
||||
//inputs
|
||||
for (const auto in : tx.vin)
|
||||
{
|
||||
if (in.type() == typeid(txin_htlc))
|
||||
{
|
||||
if (!is_after_hardfork_2_zone())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//outputs
|
||||
for (const auto out : tx.vout)
|
||||
{
|
||||
if (out.target.type() == typeid(txout_htlc))
|
||||
{
|
||||
if (!is_after_hardfork_2_zone())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transaction& tx, const crypto::hash& tx_id) const
|
||||
{
|
||||
uint64_t block_height = m_db_blocks.size();
|
||||
|
|
@ -4955,38 +4927,6 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
|
|||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transaction& tx, const crypto::hash& tx_id, uint64_t block_height) const
|
||||
{
|
||||
// if (block_height <= m_core_runtime_config.hard_fork_01_starts_after_height)
|
||||
// {
|
||||
// // before hardfork 1
|
||||
//
|
||||
// for (const auto& el : tx.extra)
|
||||
// {
|
||||
// // etc_tx_details_unlock_time2 is not allowed in txs in blocks prior to hardfork 1
|
||||
// CHECK_AND_ASSERT_MES(el.type() != typeid(etc_tx_details_unlock_time2), false, "tx " << tx_id << " contains etc_tx_details_unlock_time2 which is not allowed on height " << block_height);
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// if (block_height <= m_core_runtime_config.hard_fork_02_starts_after_height)
|
||||
// {
|
||||
// // before hardfork 2
|
||||
//
|
||||
// auto check_lambda = [&](const std::vector<payload_items_v>& container) -> bool
|
||||
// {
|
||||
// for (const auto& el : container)
|
||||
// {
|
||||
// const auto& type = el.type();
|
||||
// CHECK_AND_ASSERT_MES(type != typeid(tx_payer), false, "tx " << tx_id << " contains tx_payer which is not allowed on height " << block_height);
|
||||
// CHECK_AND_ASSERT_MES(type != typeid(tx_receiver), false, "tx " << tx_id << " contains tx_receiver which is not allowed on height " << block_height);
|
||||
// CHECK_AND_ASSERT_MES(type != typeid(extra_alias_entry), false, "tx " << tx_id << " contains extra_alias_entry which is not allowed on height " << block_height);
|
||||
// }
|
||||
// return true;
|
||||
// };
|
||||
//
|
||||
// return check_lambda(tx.extra) && check_lambda(tx.attachment);
|
||||
// }
|
||||
|
||||
|
||||
auto is_allowed_before_hardfork2 = [&](const payload_items_v& el) -> bool
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(el.type() != typeid(tx_payer), false, "tx " << tx_id << " contains tx_payer which is not allowed on height " << block_height);
|
||||
|
|
@ -5003,13 +4943,14 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
|
|||
|
||||
bool var_is_after_hardfork_1_zone = is_after_hardfork_1_zone(block_height);
|
||||
bool var_is_after_hardfork_2_zone = is_after_hardfork_2_zone(block_height);
|
||||
bool var_is_after_hardfork_3_zone = is_after_hardfork_3_zone(block_height);
|
||||
|
||||
//inputs
|
||||
for (const auto in : tx.vin)
|
||||
{
|
||||
if (in.type() == typeid(txin_htlc))
|
||||
{
|
||||
if (!var_is_after_hardfork_2_zone)
|
||||
if (!var_is_after_hardfork_3_zone)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -5018,7 +4959,7 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
|
|||
{
|
||||
if (out.target.type() == typeid(txout_htlc))
|
||||
{
|
||||
if (!var_is_after_hardfork_2_zone)
|
||||
if (!var_is_after_hardfork_3_zone)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -5805,6 +5746,11 @@ bool blockchain_storage::is_after_hardfork_2_zone()const
|
|||
return is_after_hardfork_2_zone(m_db_blocks.size());
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::is_after_hardfork_3_zone()const
|
||||
{
|
||||
return is_after_hardfork_3_zone(m_db_blocks.size());
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::is_after_hardfork_2_zone(uint64_t height)const
|
||||
{
|
||||
if (height > m_core_runtime_config.hard_fork_02_starts_after_height)
|
||||
|
|
@ -5812,6 +5758,13 @@ bool blockchain_storage::is_after_hardfork_2_zone(uint64_t height)const
|
|||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::is_after_hardfork_3_zone(uint64_t height)const
|
||||
{
|
||||
if (height > m_core_runtime_config.hard_fork_03_starts_after_height)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::prevalidate_block(const block& bl)
|
||||
{
|
||||
if (bl.major_version == BLOCK_MAJOR_VERSION_INITAL && get_block_height(bl) <= m_core_runtime_config.hard_fork_01_starts_after_height)
|
||||
|
|
@ -5819,7 +5772,7 @@ bool blockchain_storage::prevalidate_block(const block& bl)
|
|||
|
||||
if (bl.major_version == HF1_BLOCK_MAJOR_VERSION
|
||||
&& get_block_height(bl) > m_core_runtime_config.hard_fork_01_starts_after_height
|
||||
&& get_block_height(bl) <= m_core_runtime_config.hard_fork_02_starts_after_height
|
||||
&& get_block_height(bl) <= m_core_runtime_config.hard_fork_03_starts_after_height
|
||||
)
|
||||
{
|
||||
return true;
|
||||
|
|
@ -5832,7 +5785,7 @@ bool blockchain_storage::prevalidate_block(const block& bl)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (is_after_hardfork_2_zone() && bl.minor_version > CURRENT_BLOCK_MINOR_VERSION)
|
||||
if (is_after_hardfork_3_zone() && bl.minor_version > CURRENT_BLOCK_MINOR_VERSION)
|
||||
{
|
||||
//this means that binary block is compatible, but semantics got changed due to hardfork, daemon should be updated
|
||||
LOG_PRINT_MAGENTA("Block's MINOR_VERSION is: " << bl.minor_version
|
||||
|
|
|
|||
|
|
@ -663,6 +663,8 @@ namespace currency
|
|||
bool is_after_hardfork_1_zone(uint64_t height)const;
|
||||
bool is_after_hardfork_2_zone()const;
|
||||
bool is_after_hardfork_2_zone(uint64_t height)const;
|
||||
bool is_after_hardfork_3_zone()const;
|
||||
bool is_after_hardfork_3_zone(uint64_t height)const;
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ namespace currency
|
|||
|
||||
uint64_t hard_fork_01_starts_after_height;
|
||||
uint64_t hard_fork_02_starts_after_height;
|
||||
uint64_t hard_fork_03_starts_after_height;
|
||||
|
||||
static uint64_t _default_core_time_function()
|
||||
{
|
||||
|
|
@ -42,6 +43,7 @@ namespace currency
|
|||
|
||||
pc.hard_fork_01_starts_after_height = ZANO_HARDFORK_01_AFTER_HEIGHT;
|
||||
pc.hard_fork_02_starts_after_height = ZANO_HARDFORK_02_AFTER_HEIGHT;
|
||||
pc.hard_fork_03_starts_after_height = ZANO_HARDFORK_03_AFTER_HEIGHT;
|
||||
|
||||
pc.get_core_time = &core_runtime_config::_default_core_time_function;
|
||||
bool r = epee::string_tools::hex_to_pod(ALIAS_SHORT_NAMES_VALIDATION_PUB_KEY, pc.alias_validation_pubkey);
|
||||
|
|
|
|||
|
|
@ -236,9 +236,11 @@
|
|||
#ifndef TESTNET
|
||||
#define ZANO_HARDFORK_01_AFTER_HEIGHT 194624
|
||||
#define ZANO_HARDFORK_02_AFTER_HEIGHT 999999
|
||||
#define ZANO_HARDFORK_03_AFTER_HEIGHT 100000000
|
||||
#else
|
||||
#define ZANO_HARDFORK_01_AFTER_HEIGHT 1440
|
||||
#define ZANO_HARDFORK_02_AFTER_HEIGHT 1800
|
||||
#define ZANO_HARDFORK_03_AFTER_HEIGHT 1801
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ bool atomic_base_test::configure_core(currency::core& c, size_t ev_index, const
|
|||
pc.min_coinstake_age = TESTS_POS_CONFIG_MIN_COINSTAKE_AGE; //four blocks
|
||||
pc.pos_minimum_heigh = TESTS_POS_CONFIG_POS_MINIMUM_HEIGH; //four blocks
|
||||
pc.hard_fork_01_starts_after_height = 10;
|
||||
pc.hard_fork_02_starts_after_height = 12;
|
||||
pc.hard_fork_02_starts_after_height = 11;
|
||||
pc.hard_fork_03_starts_after_height = 12;
|
||||
c.get_blockchain_storage().set_core_runtime_config(pc);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ test_generator::test_generator()
|
|||
, m_last_found_timestamp(0)
|
||||
, m_hardfork_01_after_heigh(CURRENCY_MAX_BLOCK_NUMBER)
|
||||
, m_hardfork_02_after_heigh(CURRENCY_MAX_BLOCK_NUMBER)
|
||||
, m_hardfork_03_after_heigh(CURRENCY_MAX_BLOCK_NUMBER)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -63,6 +64,7 @@ void test_generator::set_hardfork_height(size_t hardfork_id, uint64_t h)
|
|||
{
|
||||
case 1: m_hardfork_01_after_heigh = h; break;
|
||||
case 2: m_hardfork_02_after_heigh = h; break;
|
||||
case 3: m_hardfork_03_after_heigh = h; break;
|
||||
default: CHECK_AND_ASSERT_THROW_MES(false, "invalid hardfork id: " << hardfork_id)
|
||||
}
|
||||
}
|
||||
|
|
@ -422,6 +424,7 @@ bool test_generator::build_wallets(const blockchain_vector& blocks,
|
|||
pc.pos_minimum_heigh = TESTS_POS_CONFIG_POS_MINIMUM_HEIGH;
|
||||
pc.hard_fork_01_starts_after_height = m_hardfork_01_after_heigh;
|
||||
pc.hard_fork_02_starts_after_height = m_hardfork_02_after_heigh;
|
||||
pc.hard_fork_03_starts_after_height = m_hardfork_03_after_heigh;
|
||||
wallets.back()->set_core_runtime_config(pc);
|
||||
}
|
||||
|
||||
|
|
@ -2075,6 +2078,7 @@ test_chain_unit_enchanced::test_chain_unit_enchanced()
|
|||
, m_unverifiable_tx_index(std::numeric_limits<size_t>::max())
|
||||
, m_hardfork_01_height(CURRENCY_MAX_BLOCK_NUMBER)
|
||||
, m_hardfork_02_height(CURRENCY_MAX_BLOCK_NUMBER)
|
||||
, m_hardfork_03_height(CURRENCY_MAX_BLOCK_NUMBER)
|
||||
{
|
||||
REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, configure_core);
|
||||
REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, mark_invalid_tx);
|
||||
|
|
@ -2097,6 +2101,7 @@ bool test_chain_unit_enchanced::configure_core(currency::core& c, size_t ev_inde
|
|||
pc.pos_minimum_heigh = TESTS_POS_CONFIG_POS_MINIMUM_HEIGH;
|
||||
pc.hard_fork_01_starts_after_height = m_hardfork_01_height;
|
||||
pc.hard_fork_02_starts_after_height = m_hardfork_02_height;
|
||||
pc.hard_fork_03_starts_after_height = m_hardfork_03_height;
|
||||
|
||||
c.get_blockchain_storage().set_core_runtime_config(pc);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -324,6 +324,7 @@ protected:
|
|||
|
||||
uint64_t m_hardfork_01_height;
|
||||
uint64_t m_hardfork_02_height;
|
||||
uint64_t m_hardfork_03_height;
|
||||
};
|
||||
|
||||
struct wallet_test_core_proxy;
|
||||
|
|
@ -536,6 +537,7 @@ private:
|
|||
|
||||
uint64_t m_hardfork_01_after_heigh;
|
||||
uint64_t m_hardfork_02_after_heigh;
|
||||
uint64_t m_hardfork_03_after_heigh;
|
||||
|
||||
std::unordered_map<crypto::hash, block_info> m_blocks_info;
|
||||
static test_gentime_settings m_test_gentime_settings;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ hard_fork_2_base_test::hard_fork_2_base_test(size_t hardfork_02_height)
|
|||
hard_fork_2_base_test::hard_fork_2_base_test(size_t hardfork_01_height, size_t hardfork_02_height)
|
||||
: m_hardfork_01_height(hardfork_01_height)
|
||||
, m_hardfork_02_height(hardfork_02_height)
|
||||
, m_hardfork_03_height(CURRENCY_MAX_BLOCK_NUMBER)
|
||||
{
|
||||
REGISTER_CALLBACK_METHOD(hard_fork_2_base_test, configure_core);
|
||||
}
|
||||
|
|
@ -29,6 +30,7 @@ bool hard_fork_2_base_test::configure_core(currency::core& c, size_t ev_index, c
|
|||
pc.pos_minimum_heigh = TESTS_POS_CONFIG_POS_MINIMUM_HEIGH;
|
||||
pc.hard_fork_01_starts_after_height = m_hardfork_01_height;
|
||||
pc.hard_fork_02_starts_after_height = m_hardfork_02_height;
|
||||
pc.hard_fork_03_starts_after_height = m_hardfork_03_height;
|
||||
c.get_blockchain_storage().set_core_runtime_config(pc);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ struct hard_fork_2_base_test : virtual public test_chain_unit_enchanced
|
|||
|
||||
size_t m_hardfork_01_height;
|
||||
size_t m_hardfork_02_height;
|
||||
size_t m_hardfork_03_height;
|
||||
};
|
||||
|
||||
struct hard_fork_2_tx_payer_in_wallet : public wallet_test, public hard_fork_2_base_test
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue