1
0
Fork 0
forked from lthn/blockchain

introducing tx_version(in progress, everything is broken so far)

This commit is contained in:
cryptozoidberg 2022-05-10 23:49:20 +02:00
parent 2707d1515d
commit 1cf6d337d3
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
27 changed files with 238 additions and 153 deletions

View file

@ -1147,7 +1147,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional(bool pos) con
wide_difficulty_type& dif = pos ? m_cached_next_pos_difficulty : m_cached_next_pow_difficulty;
TIME_MEASURE_FINISH_PD(target_calculating_enum_blocks);
TIME_MEASURE_START_PD(target_calculating_calc);
if (m_db_blocks.size() > m_core_runtime_config.hard_fork_01_starts_after_height)
if (m_db_blocks.size() > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
{
dif = next_difficulty_2(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET);
}
@ -1186,7 +1186,7 @@ wide_difficulty_type blockchain_storage::get_next_diff_conditional2(bool pos, co
enum_blockchain(cb, alt_chain, split_height);
wide_difficulty_type diff = 0;
if(abei.height > m_core_runtime_config.hard_fork_01_starts_after_height)
if(abei.height > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
diff = next_difficulty_2(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET);
else
diff = next_difficulty_1(timestamps, commulative_difficulties, pos ? DIFFICULTY_POS_TARGET : DIFFICULTY_POW_TARGET);
@ -1266,7 +1266,7 @@ bool blockchain_storage::prevalidate_miner_transaction(const block& b, uint64_t
CHECK_AND_ASSERT_MES(b.miner_tx.vin[1].type() == typeid(txin_to_key), false, "coinstake transaction in the block has the wrong type");
}
if (height > m_core_runtime_config.hard_fork_01_starts_after_height)
if (height > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
{
// new rules that allow different unlock time in coinbase outputs
uint64_t max_unlock_time = 0;
@ -1437,9 +1437,9 @@ bool blockchain_storage::create_block_template(const create_block_template_param
boost::multiprecision::uint128_t already_generated_coins;
CRITICAL_REGION_BEGIN(m_read_lock);
height = m_db_blocks.size();
if(height <= m_core_runtime_config.hard_fork_01_starts_after_height)
if(height <= m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
b.major_version = BLOCK_MAJOR_VERSION_INITIAL;
else if(height <= m_core_runtime_config.hard_fork_03_starts_after_height)
else if(height <= m_core_runtime_config.hard_forks.hard_fork_03_starts_after_height)
b.major_version = HF1_BLOCK_MAJOR_VERSION;
else
b.major_version = CURRENT_BLOCK_MAJOR_VERSION;
@ -1834,7 +1834,7 @@ bool blockchain_storage::handle_alternative_block(const block& b, const crypto::
if (abei.height >= m_core_runtime_config.pos_minimum_heigh)
cumulative_diff_delta = correct_difficulty_with_sequence_factor(sequence_factor, cumulative_diff_delta);
if (abei.height > BLOCKCHAIN_HEIGHT_FOR_POS_STRICT_SEQUENCE_LIMITATION && abei.height <= m_core_runtime_config.hard_fork_01_starts_after_height && pos_block && sequence_factor > BLOCK_POS_STRICT_SEQUENCE_LIMIT)
if (abei.height > BLOCKCHAIN_HEIGHT_FOR_POS_STRICT_SEQUENCE_LIMITATION && abei.height <= m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height && pos_block && sequence_factor > BLOCK_POS_STRICT_SEQUENCE_LIMIT)
{
LOG_PRINT_RED_L0("Alternative block " << id << " @ " << abei.height << " has too big sequence factor: " << sequence_factor << ", rejected");
bvc.m_verification_failed = true;
@ -1959,7 +1959,7 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_
const block_extended_info& alt_chain_bei = alt_chain.back()->second;
const block_extended_info& connection_point = alt_chain.front()->second;
if (connection_point.height <= m_core_runtime_config.hard_fork_01_starts_after_height)
if (connection_point.height <= m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
{
//use pre-hard fork, old-style comparing
if (main_chain_bei.cumulative_diff_adjusted < alt_chain_bei.cumulative_diff_adjusted)
@ -1980,7 +1980,7 @@ bool blockchain_storage::is_reorganize_required(const block_extended_info& main_
return true;
}
}
else if (alt_chain_bei.height > m_core_runtime_config.hard_fork_01_starts_after_height)
else if (alt_chain_bei.height > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
{
//new rules, applied after HARD_FORK_1
//to learn this algo please read https://github.com/hyle-team/docs/blob/master/zano/PoS_Analysis_and_improvements_proposal.pdf
@ -3335,7 +3335,7 @@ bool blockchain_storage::push_transaction_to_global_outs_index(const transaction
global_indexes.push_back(m_db_outputs.get_item_size(ot.amount) - 1);
if (ot.target.type() == typeid(txout_htlc) && !is_after_hardfork_3_zone())
{
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 <<")");
LOG_ERROR("Error: Transaction with txout_htlc before is_after_hardfork_3_zone(before height " << m_core_runtime_config.hard_forks.hard_fork_03_starts_after_height <<")");
return false;
}
}
@ -3856,7 +3856,7 @@ namespace currency
{
if (!m_bcs.is_after_hardfork_3_zone())
{
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 << ")");
LOG_ERROR("Error: Transaction with txin_htlc before is_after_hardfork_3_zone(before height " << m_bcs.get_core_runtime_config().hard_forks.hard_fork_03_starts_after_height << ")");
return false;
}
return this->operator()(static_cast<const txin_to_key&>(in));
@ -4286,7 +4286,7 @@ bool blockchain_storage::check_tx_inputs(const transaction& tx, const crypto::ha
{
if (!is_after_hardfork_3_zone())
{
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 << ")");
LOG_ERROR("Error: Transaction with txin_htlc before is_after_hardfork_3_zone(before height " << m_core_runtime_config.hard_forks.hard_fork_03_starts_after_height << ")");
return false;
}
@ -5008,7 +5008,7 @@ bool blockchain_storage::validate_pos_coinbase_outs_unlock_time(const transactio
return true;
}
CHECK_AND_ASSERT_MES(get_block_height(miner_tx) > m_core_runtime_config.hard_fork_01_starts_after_height, false, "error in block [" << get_block_height(miner_tx) << "] etc_tx_details_unlock_time2 can exist only after hard fork point : " << m_core_runtime_config.hard_fork_01_starts_after_height);
CHECK_AND_ASSERT_MES(get_block_height(miner_tx) > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height, false, "error in block [" << get_block_height(miner_tx) << "] etc_tx_details_unlock_time2 can exist only after hard fork point : " << m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height);
//etc_tx_details_unlock_time2 can be kept only after hard_fork_1 point
etc_tx_details_unlock_time2 ut2 = AUTO_VAL_INIT(ut2);
@ -5114,7 +5114,7 @@ bool blockchain_storage::validate_pos_block(const block& b,
r = check_tx_input(b.miner_tx, 1, coinstake_in, id, b.miner_tx.signatures[0], max_related_block_height, source_max_unlock_time_for_pos_coinbase);
CHECK_AND_ASSERT_MES(r, false, "Failed to validate coinstake input in miner tx, block_id = " << get_block_hash(b));
if (get_block_height(b) > m_core_runtime_config.hard_fork_01_starts_after_height)
if (get_block_height(b) > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
{
uint64_t last_pow_h = get_last_x_block_height(false);
CHECK_AND_ASSERT_MES(max_related_block_height <= last_pow_h, false, "Failed to validate coinbase in PoS block, condition failed: max_related_block_height(" << max_related_block_height << ") <= last_pow_h(" << last_pow_h << ")");
@ -5749,7 +5749,7 @@ bool blockchain_storage::is_after_hardfork_1_zone()const
//------------------------------------------------------------------
bool blockchain_storage::is_after_hardfork_1_zone(uint64_t height)const
{
if (height > m_core_runtime_config.hard_fork_01_starts_after_height)
if (height > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
return true;
return false;
}
@ -5766,14 +5766,14 @@ bool blockchain_storage::is_after_hardfork_3_zone()const
//------------------------------------------------------------------
bool blockchain_storage::is_after_hardfork_2_zone(uint64_t height)const
{
if (height > m_core_runtime_config.hard_fork_02_starts_after_height)
if (height > m_core_runtime_config.hard_forks.hard_fork_02_starts_after_height)
return true;
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)
if (height > m_core_runtime_config.hard_forks.hard_fork_03_starts_after_height)
return true;
return false;
}
@ -5781,13 +5781,13 @@ bool blockchain_storage::is_after_hardfork_3_zone(uint64_t height)const
bool blockchain_storage::prevalidate_block(const block& bl)
{
//before hard_fork1
if (bl.major_version == BLOCK_MAJOR_VERSION_INITIAL && get_block_height(bl) <= m_core_runtime_config.hard_fork_01_starts_after_height)
if (bl.major_version == BLOCK_MAJOR_VERSION_INITIAL && get_block_height(bl) <= m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
return true;
//after hard_fork1 and before hard_fork3
if ( get_block_height(bl) > m_core_runtime_config.hard_fork_01_starts_after_height &&
get_block_height(bl) <= m_core_runtime_config.hard_fork_03_starts_after_height
if ( get_block_height(bl) > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height &&
get_block_height(bl) <= m_core_runtime_config.hard_forks.hard_fork_03_starts_after_height
)
{
if (bl.major_version <= HF1_BLOCK_MAJOR_VERSION )

View file

@ -667,6 +667,8 @@ namespace currency
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;
// bool is_after_hardfork_4_zone()const;
// bool is_after_hardfork_4_zone(uint64_t height)const;

View file

@ -12,6 +12,14 @@ namespace currency
{
typedef uint64_t (*core_time_func_t)();
struct hard_forks_descriptor
{
uint64_t hard_fork_01_starts_after_height;
uint64_t hard_fork_02_starts_after_height;
uint64_t hard_fork_03_starts_after_height;
uint64_t hard_fork_04_starts_after_height;
};
struct core_runtime_config
{
uint64_t min_coinstake_age;
@ -22,18 +30,17 @@ namespace currency
crypto::public_key alias_validation_pubkey;
core_time_func_t get_core_time;
uint64_t hard_fork_01_starts_after_height;
uint64_t hard_fork_02_starts_after_height;
uint64_t hard_fork_03_starts_after_height;
hard_forks_descriptor hard_forks;
bool is_hardfork_active_for_height(size_t hardfork_id, uint64_t height) const
{
switch (hardfork_id)
{
case 0: return true;
case 1: return height > hard_fork_01_starts_after_height;
case 2: return height > hard_fork_02_starts_after_height;
case 3: return height > hard_fork_03_starts_after_height;
case 1: return height > hard_forks.hard_fork_01_starts_after_height;
case 2: return height > hard_forks.hard_fork_02_starts_after_height;
case 3: return height > hard_forks.hard_fork_03_starts_after_height;
case 4: return height > hard_forks.hard_fork_04_starts_after_height;
default: return false;
}
}
@ -53,9 +60,10 @@ namespace currency
pc.tx_default_fee = TX_DEFAULT_FEE;
pc.max_alt_blocks = CURRENCY_ALT_BLOCK_MAX_COUNT;
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.hard_forks.hard_fork_01_starts_after_height = ZANO_HARDFORK_01_AFTER_HEIGHT;
pc.hard_forks.hard_fork_02_starts_after_height = ZANO_HARDFORK_02_AFTER_HEIGHT;
pc.hard_forks.hard_fork_03_starts_after_height = ZANO_HARDFORK_03_AFTER_HEIGHT;
pc.hard_forks.hard_fork_04_starts_after_height = ZANO_HARDFORK_04_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);

View file

@ -26,8 +26,8 @@
#define CURRENCY_PUBLIC_AUDITABLE_ADDRESS_BASE58_PREFIX 0x98c8 // auditable addresses start with 'aZx'
#define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x8a49 // auditable integrated addresses start with 'aiZX'
#define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10
#define CURRENT_TRANSACTION_VERSION 1
#define CURRENT_TRANSACTION_VERSION_HF4 2
#define CURRENT_TRANSACTION_VERSION 2
#define TRANSACTION_VERSION_PRE_HF4 1
#define HF1_BLOCK_MAJOR_VERSION 1
#define CURRENT_BLOCK_MAJOR_VERSION 2
@ -243,10 +243,12 @@
#define ZANO_HARDFORK_01_AFTER_HEIGHT 194624
#define ZANO_HARDFORK_02_AFTER_HEIGHT 999999
#define ZANO_HARDFORK_03_AFTER_HEIGHT 1082577
#define ZANO_HARDFORK_04_AFTER_HEIGHT 999999999
#else
#define ZANO_HARDFORK_01_AFTER_HEIGHT 1440
#define ZANO_HARDFORK_02_AFTER_HEIGHT 1800
#define ZANO_HARDFORK_03_AFTER_HEIGHT 1801
#define ZANO_HARDFORK_04_AFTER_HEIGHT 999999999
#endif

View file

@ -89,6 +89,11 @@ namespace currency
return m_blockchain_storage.get_current_blockchain_size();
}
//-----------------------------------------------------------------------------------------------
uint64_t core::get_current_tx_version() const
{
return get_tx_version(m_blockchain_storage.get_current_blockchain_size(), m_blockchain_storage.get_core_runtime_config().hard_forks);
}
//-----------------------------------------------------------------------------------------------
uint64_t core::get_top_block_height() const
{
return m_blockchain_storage.get_top_block_height();
@ -504,9 +509,9 @@ namespace currency
{
uint64_t h = get_block_height(b);
auto& crc = m_blockchain_storage.get_core_runtime_config();
if (h == crc.hard_fork_01_starts_after_height + 1)
if (h == crc.hard_forks.hard_fork_01_starts_after_height + 1)
{ LOG_PRINT_GREEN("Hardfork 1 activated at height " << h, LOG_LEVEL_0); }
else if (h == crc.hard_fork_02_starts_after_height + 1)
else if (h == crc.hard_forks.hard_fork_02_starts_after_height + 1)
{ LOG_PRINT_GREEN("Hardfork 2 activated at height " << h, LOG_LEVEL_0); }
if (h == m_stop_after_height)

View file

@ -63,6 +63,7 @@ namespace currency
bool set_genesis_block(const block& b);
bool deinit();
uint64_t get_current_blockchain_size() const;
uint64_t get_current_tx_version() const;
uint64_t get_top_block_height() const;
std::string get_config_folder();
bool get_blockchain_top(uint64_t& heeight, crypto::hash& top_id) const;

View file

@ -741,15 +741,18 @@ namespace currency
eai.cnt = attachment.size();
}
//---------------------------------------------------------------
bool construct_tx(const account_keys& sender_account_keys, const std::vector<tx_source_entry>& sources,
bool construct_tx(const account_keys& sender_account_keys,
const std::vector<tx_source_entry>& sources,
const std::vector<tx_destination_entry>& destinations,
const std::vector<attachment_v>& attachments,
const std::vector<attachment_v>& attachments,
transaction& tx,
uint64_t tx_version,
uint64_t unlock_time,
uint8_t tx_outs_attr, bool shuffle)
uint8_t tx_outs_attr,
bool shuffle)
{
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key);
return construct_tx(sender_account_keys, sources, destinations, std::vector<extra_v>(), attachments, tx, one_time_secret_key, unlock_time, tx_outs_attr, shuffle);
return construct_tx(sender_account_keys, sources, destinations, std::vector<extra_v>(), attachments, tx, tx_version, one_time_secret_key, unlock_time, tx_outs_attr, shuffle);
}
//---------------------------------------------------------------
struct encrypt_attach_visitor : public boost::static_visitor<void>
@ -1174,6 +1177,7 @@ namespace currency
const std::vector<extra_v>& extra,
const std::vector<attachment_v>& attachments,
transaction& tx,
uint64_t tx_version,
crypto::secret_key& one_time_secret_key,
uint64_t unlock_time,
uint8_t tx_outs_attr,
@ -1186,7 +1190,7 @@ namespace currency
//in case if there is no real targets we use sender credentials to encrypt attachments
account_public_address crypt_destination_addr = get_crypt_address_from_destinations(sender_account_keys, destinations);
return construct_tx(sender_account_keys, sources, destinations, extra, attachments, tx, one_time_secret_key, unlock_time,
return construct_tx(sender_account_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, unlock_time,
crypt_destination_addr,
0,
tx_outs_attr,
@ -1199,6 +1203,7 @@ namespace currency
const std::vector<extra_v>& extra,
const std::vector<attachment_v>& attachments,
transaction& tx,
uint64_t tx_version,
crypto::secret_key& one_time_secret_key,
uint64_t unlock_time,
const account_public_address& crypt_destination_addr,
@ -1220,6 +1225,7 @@ namespace currency
ftp.tx_outs_attr = tx_outs_attr;
ftp.shuffle = shuffle;
ftp.flags = flags;
ftp.tx_version;
finalized_tx ft = AUTO_VAL_INIT(ft);
ft.tx = tx;
@ -1434,7 +1440,6 @@ namespace currency
}
}
// "Shuffle" outs
std::vector<tx_destination_entry> shuffled_dsts(destinations);
if (shuffle)
@ -1562,6 +1567,15 @@ namespace currency
return true;
}
//---------------------------------------------------------------
uint64_t get_tx_version(uint64_t h, const hard_forks_descriptor& hfd)
{
if (h <= hfd.hard_fork_04_starts_after_height)
{
return TRANSACTION_VERSION_PRE_HF4;
}
return CURRENT_TRANSACTION_VERSION;
}
//---------------------------------------------------------------
uint64_t get_reward_from_miner_tx(const transaction& tx)
{
uint64_t income = 0;

View file

@ -229,6 +229,7 @@ namespace currency
const std::vector<tx_destination_entry>& destinations,
const std::vector<attachment_v>& attachments,
transaction& tx,
uint64_t tx_version,
uint64_t unlock_time,
uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED,
bool shuffle = true);
@ -238,6 +239,7 @@ namespace currency
const std::vector<extra_v>& extra,
const std::vector<attachment_v>& attachments,
transaction& tx,
uint64_t tx_version,
crypto::secret_key& one_time_secret_key,
uint64_t unlock_time,
uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED,
@ -250,6 +252,7 @@ namespace currency
const std::vector<extra_v>& extra,
const std::vector<attachment_v>& attachments,
transaction& tx,
uint64_t tx_version,
crypto::secret_key& one_time_secret_key,
uint64_t unlock_time,
const account_public_address& crypt_account,
@ -258,6 +261,7 @@ namespace currency
bool shuffle = true,
uint64_t flags = 0);
uint64_t get_tx_version(uint64_t h, const hard_forks_descriptor& hfd);
bool construct_tx(const account_keys& sender_account_keys, const finalize_tx_param& param, finalized_tx& result);
@ -701,7 +705,7 @@ namespace currency
template <typename container_t>
void create_and_add_tx_payer_to_container_from_address(container_t& container, const account_public_address& addr, uint64_t top_block_height, const core_runtime_config& crc)
{
if (top_block_height > crc.hard_fork_02_starts_after_height)
if (top_block_height > crc.hard_forks.hard_fork_02_starts_after_height)
{
// after hardfork 2
tx_payer result = AUTO_VAL_INIT(result);
@ -723,7 +727,7 @@ namespace currency
template <typename container_t>
void create_and_add_tx_receiver_to_container_from_address(container_t& container, const account_public_address& addr, uint64_t top_block_height, const core_runtime_config& crc)
{
if (top_block_height > crc.hard_fork_02_starts_after_height)
if (top_block_height > crc.hard_forks.hard_fork_02_starts_after_height)
{
// after hardfork 2
tx_receiver result = AUTO_VAL_INIT(result);

View file

@ -844,6 +844,7 @@ void wallet2::accept_proposal(const crypto::hash& contract_id, uint64_t b_accept
//build transaction
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
prepare_transaction(construct_param, ftp, tx);
mark_transfers_as_spent(ftp.selected_transfers, std::string("contract <") + epee::string_tools::pod_to_hex(contract_id) + "> has been accepted with tx <" + epee::string_tools::pod_to_hex(get_transaction_hash(tx)) + ">");
@ -862,7 +863,12 @@ void wallet2::accept_proposal(const crypto::hash& contract_id, uint64_t b_accept
if (p_acceptance_tx != nullptr)
*p_acceptance_tx = tx;
}
//---------------------------
//---------------------------------------------------------------------------------
uint64_t wallet2::get_current_tx_version()
{
return currency::get_tx_version(this->get_top_block_height(), this->m_core_runtime_config.hard_forks);
}
//---------------------------------------------------------------------------------
void wallet2::finish_contract(const crypto::hash& contract_id, const std::string& release_type, currency::transaction* p_release_tx /* = nullptr */)
{
auto contr_it = m_contracts.find(contract_id);
@ -974,6 +980,7 @@ void wallet2::request_cancel_contract(const crypto::hash& contract_id, uint64_t
construct_param.split_strategy_id = detail::ssi_digit;
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
prepare_transaction(construct_param, ftp);
currency::transaction tx = AUTO_VAL_INIT(tx);
crypto::secret_key sk = AUTO_VAL_INIT(sk);
@ -3696,7 +3703,7 @@ bool wallet2::is_transfer_unlocked(const transfer_details& td, bool for_pos_mini
uint64_t unlock_time = get_tx_unlock_time(td.m_ptx_wallet_info->m_tx, td.m_internal_output_index);
if (for_pos_mining && get_blockchain_current_size() > m_core_runtime_config.hard_fork_01_starts_after_height)
if (for_pos_mining && get_blockchain_current_size() > m_core_runtime_config.hard_forks.hard_fork_01_starts_after_height)
{
//allowed of staking locked coins with
stake_lock_time = unlock_time;
@ -3782,7 +3789,7 @@ void wallet2::update_offer_by_id(const crypto::hash& tx_id, uint64_t of_ind, con
//----------------------------------------------------------------------------------------------------
void wallet2::push_alias_info_to_extra_according_to_hf_status(const currency::extra_alias_entry& ai, std::vector<currency::extra_v>& extra)
{
if (get_top_block_height() > m_core_runtime_config.hard_fork_02_starts_after_height)
if (get_top_block_height() > m_core_runtime_config.hard_forks.hard_fork_02_starts_after_height)
{
// after HF2
extra.push_back(ai);
@ -3979,6 +3986,7 @@ void wallet2::build_escrow_release_templates(crypto::hash multisig_id,
construct_params.extra.push_back(tsa);
{
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
prepare_transaction(construct_params, ftp);
crypto::secret_key sk = AUTO_VAL_INIT(sk);
finalize_transaction(ftp, tx_release_template, sk, false);
@ -3995,6 +4003,7 @@ void wallet2::build_escrow_release_templates(crypto::hash multisig_id,
construct_params.extra.push_back(tsa);
{
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
prepare_transaction(construct_params, ftp);
crypto::secret_key sk = AUTO_VAL_INIT(sk);
finalize_transaction(ftp, tx_burn_template, sk, false);
@ -4015,6 +4024,7 @@ void wallet2::build_escrow_cancel_template(crypto::hash multisig_id,
construct_tx_param construct_params = AUTO_VAL_INIT(construct_params);
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
construct_params.fee = it->second.amount() - (ecrow_details.amount_a_pledge + ecrow_details.amount_to_pay + ecrow_details.amount_b_pledge);
construct_params.multisig_id = multisig_id;
construct_params.split_strategy_id = detail::ssi_digit;
@ -4097,6 +4107,7 @@ void wallet2::build_escrow_template(const bc_services::contract_private_details&
}
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
prepare_transaction(ctp, ftp, tx);
selected_transfers = ftp.selected_transfers;
@ -4229,6 +4240,7 @@ void wallet2::send_escrow_proposal(const bc_services::contract_private_details&
ctp.unlock_time = unlock_time;
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
try
{
prepare_transaction(ctp, ftp);
@ -5465,6 +5477,7 @@ void wallet2::transfer(construct_tx_param& ctp,
TIME_MEASURE_START(prepare_transaction_time);
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
prepare_transaction(ctp, ftp);
TIME_MEASURE_FINISH(prepare_transaction_time);
@ -5571,6 +5584,7 @@ void wallet2::sweep_below(size_t fake_outs_count, const currency::account_public
}
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
ftp.tx_version = this->get_current_tx_version();
if (!payment_id.empty())
set_payment_id_to_tx(ftp.attachments, payment_id);
// put encrypted payer info into the extra

View file

@ -956,7 +956,7 @@ private:
bool handle_cancel_proposal(wallet_public::wallet_transfer_info& wti, const bc_services::escrow_cancel_templates_body& ectb, const std::vector<currency::payload_items_v>& decrypted_attach);
bool handle_expiration_list(uint64_t tx_expiration_ts_median);
void handle_contract_expirations(uint64_t tx_expiration_ts_median);
uint64_t get_current_tx_version();
void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const wallet_public::wallet_transfer_info& wti) const;
void change_contract_state(wallet_public::escrow_contract_details_basic& contract, uint32_t new_state, const crypto::hash& contract_id, const std::string& reason = "internal intention") const;

View file

@ -94,8 +94,8 @@ gen_alias_tests::gen_alias_tests()
REGISTER_CALLBACK_METHOD(gen_alias_tests, check_height_changed);
REGISTER_CALLBACK_METHOD(gen_alias_tests, check_too_many_aliases_registration);
m_hardfork_01_height = 0;
m_hardfork_02_height = 0;
m_hardforks.hard_fork_01_starts_after_height = 0;
m_hardforks.hard_fork_02_starts_after_height = 0;
}
bool gen_alias_tests::generate(std::vector<test_event_entry>& events) const
@ -1112,7 +1112,8 @@ bool gen_alias_too_small_reward::make_tx_reg_alias(std::vector<test_event_entry>
destinations.push_back(tx_destination_entry(sources_amount - (alias_reward + TESTS_DEFAULT_FEE), miner_acc.get_public_address())); // change
crypto::secret_key stub;
r = construct_tx(miner_acc.get_keys(), sources, destinations, extra, empty_attachment, tx, stub, 0);
uint64_t tx_version = get_tx_version(get_block_height(prev_block), m_hardforks);
r = construct_tx(miner_acc.get_keys(), sources, destinations, extra, empty_attachment, tx, tx_version, stub, 0);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
events.push_back(tx);
@ -1322,7 +1323,8 @@ bool gen_alias_too_many_regs_in_block_template::generate(std::vector<test_event_
destinations.push_back(tx_destination_entry(sources_amount - total_alias_cost, preminer_acc.get_public_address())); // return the change in order to keep median_fee low
transaction tx_1 = AUTO_VAL_INIT(tx_1);
r = construct_tx(preminer_acc.get_keys(), sources, destinations, empty_attachment, tx_1, 0);
uint64_t tx_version = get_tx_version(get_block_height(blk_0r), m_hardforks);
r = construct_tx(preminer_acc.get_keys(), sources, destinations, empty_attachment, tx_1, tx_version, 0);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
events.push_back(tx_1);

View file

@ -72,9 +72,9 @@ bool atomic_base_test::configure_core(currency::core& c, size_t ev_index, const
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
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 = 11;
pc.hard_fork_03_starts_after_height = 12;
pc.hard_forks.hard_fork_01_starts_after_height = 10;
pc.hard_forks.hard_fork_02_starts_after_height = 11;
pc.hard_forks.hard_fork_03_starts_after_height = 12;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}
@ -635,9 +635,9 @@ bool atomic_test_check_hardfork_rules::configure_core(currency::core& c, size_t
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
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 = 10;
pc.hard_fork_03_starts_after_height = 10;
pc.hard_forks.hard_fork_01_starts_after_height = 10;
pc.hard_forks.hard_fork_02_starts_after_height = 10;
pc.hard_forks.hard_fork_03_starts_after_height = 10;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}
@ -668,9 +668,9 @@ bool atomic_test_check_hardfork_rules::c1(currency::core& c, size_t ev_index, co
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
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 = 10;
pc.hard_fork_03_starts_after_height = 30;
pc.hard_forks.hard_fork_01_starts_after_height = 10;
pc.hard_forks.hard_fork_02_starts_after_height = 10;
pc.hard_forks.hard_fork_03_starts_after_height = 30;
c.get_blockchain_storage().set_core_runtime_config(pc);
bool r = mine_next_pow_block_in_playtime(m_mining_accunt.get_public_address(), c);

View file

@ -327,7 +327,9 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events
transaction tmp_tx;
std::vector<currency::attachment_v> attachments;
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tmp_tx, 0))
uint64_t tx_version = get_tx_version(get_block_height(blk_0r), m_hardforks);
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tmp_tx, tx_version, 0))
return false;
MAKE_MINER_TX_MANUALLY(miner_tx, blk_0);
@ -370,7 +372,8 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>
transaction tmp_tx = AUTO_VAL_INIT(tmp_tx);
std::vector<currency::attachment_v> attachments;
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tmp_tx, 0))
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
if (!construct_tx(miner_account.get_keys(), sources, destinations, attachments, tmp_tx, tx_version, 0))
return false;
MAKE_MINER_TX_MANUALLY(miner_tx, blk_1);
@ -623,9 +626,9 @@ bool gen_block_wrong_version_agains_hardfork::c1(currency::core& c, size_t ev_in
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
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 = 10;
pc.hard_fork_03_starts_after_height = 10;
pc.hard_forks.hard_fork_01_starts_after_height = 10;
pc.hard_forks.hard_fork_02_starts_after_height = 10;
pc.hard_forks.hard_fork_03_starts_after_height = 10;
c.get_blockchain_storage().set_core_runtime_config(pc);
currency::account_base mining_accunt;
@ -642,9 +645,9 @@ bool gen_block_wrong_version_agains_hardfork::c1(currency::core& c, size_t ev_in
};
//between 1 and 2 hardforks
pc.hard_fork_01_starts_after_height = 1;
pc.hard_fork_02_starts_after_height = 10;
pc.hard_fork_03_starts_after_height = 20;
pc.hard_forks.hard_fork_01_starts_after_height = 1;
pc.hard_forks.hard_fork_02_starts_after_height = 10;
pc.hard_forks.hard_fork_03_starts_after_height = 20;
c.get_blockchain_storage().set_core_runtime_config(pc);
//major unknown
@ -660,9 +663,9 @@ bool gen_block_wrong_version_agains_hardfork::c1(currency::core& c, size_t ev_in
CHECK_TEST_CONDITION(r);
//between 1 and 2 hardforks
pc.hard_fork_01_starts_after_height = 1;
pc.hard_fork_02_starts_after_height = 1;
pc.hard_fork_03_starts_after_height = 1;
pc.hard_forks.hard_fork_01_starts_after_height = 1;
pc.hard_forks.hard_fork_02_starts_after_height = 1;
pc.hard_forks.hard_fork_03_starts_after_height = 1;
c.get_blockchain_storage().set_core_runtime_config(pc);

View file

@ -521,7 +521,8 @@ bool alt_blocks_validation_and_same_new_amount_in_two_txs::generate(std::vector<
std::vector<tx_destination_entry> destinations;
destinations.push_back(tx_destination_entry(new_amount, miner_acc.get_public_address())); // no cashback, just payment
transaction tx_1 = AUTO_VAL_INIT(tx_1);
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, 0);
uint64_t tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, tx_version, 0);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
events.push_back(tx_1);
@ -531,7 +532,8 @@ bool alt_blocks_validation_and_same_new_amount_in_two_txs::generate(std::vector<
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources failed");
transaction tx_2 = AUTO_VAL_INIT(tx_2);
// use the same destinations
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_2, 0);
tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_2, tx_version, 0);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
events.push_back(tx_2);

View file

@ -52,19 +52,27 @@ test_generator::test_generator()
, m_do_pos_to_low_timestamp(false)
, m_ignore_last_pow_in_wallets(false)
, 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)
{
m_hardforks.hard_fork_01_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
m_hardforks.hard_fork_02_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
m_hardforks.hard_fork_03_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
m_hardforks.hard_fork_04_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
}
void test_generator::set_hardforks(const currency::hard_forks_descriptor& hardforks)
{
m_hardforks = hardforks;
}
void test_generator::set_hardfork_height(size_t hardfork_id, uint64_t h)
{
switch (hardfork_id)
{
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;
case 1: m_hardforks.hard_fork_01_starts_after_height = h; break;
case 2: m_hardforks.hard_fork_02_starts_after_height = h; break;
case 3: m_hardforks.hard_fork_03_starts_after_height = h; break;
case 4: m_hardforks.hard_fork_04_starts_after_height = h; break;
default: CHECK_AND_ASSERT_THROW_MES(false, "invalid hardfork id: " << hardfork_id)
}
}
@ -224,9 +232,9 @@ bool test_generator::construct_block(currency::block& blk,
// else
// blk.major_version = BLOCK_MAJOR_VERSION_INITIAL;
if (height <= m_hardfork_01_after_heigh)
if (height <= m_hardforks.hard_fork_01_starts_after_height)
blk.major_version = BLOCK_MAJOR_VERSION_INITIAL;
else if (height <= m_hardfork_03_after_heigh)
else if (height <= m_hardforks.hard_fork_03_starts_after_height)
blk.major_version = HF1_BLOCK_MAJOR_VERSION;
else
blk.major_version = CURRENT_BLOCK_MAJOR_VERSION;
@ -429,9 +437,7 @@ bool test_generator::build_wallets(const blockchain_vector& blocks,
currency::core_runtime_config pc = cc;
pc.min_coinstake_age = TESTS_POS_CONFIG_MIN_COINSTAKE_AGE;
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;
pc.hard_forks = m_hardforks;
wallets.back()->set_core_runtime_config(pc);
}
@ -516,7 +522,7 @@ bool test_generator::find_kernel(const std::list<currency::account_base>& accs,
uint64_t& found_timestamp,
crypto::hash& found_kh)
{
bool is_after_hardfork_01 = blck_chain.size() > m_hardfork_01_after_heigh ? true : false;
bool is_after_hardfork_01 = blck_chain.size() > m_hardforks.hard_fork_01_starts_after_height ? true : false;
uint64_t median_timestamp = get_timestamps_median(blck_chain);
wide_difficulty_type basic_diff = 0;
@ -1513,6 +1519,7 @@ bool construct_tx_to_key(const std::vector<test_event_entry>& events,
std::vector<tx_destination_entry> destinations;
if (!fill_tx_sources_and_destinations(events, blk_head, from.get_keys(), to.get_public_address(), amount, fee, nmix, sources, destinations, check_for_spends, check_for_unlocktime))
return false;
uint64_t tx_version = currency::get_tx_version(get_block_height(blk_head), m_hardforks);
return construct_tx(from.get_keys(), sources, destinations, extr, att, tx, sk, 0, mix_attr);
}
@ -2098,10 +2105,13 @@ test_chain_unit_enchanced::test_chain_unit_enchanced()
, m_orphan_block_index(std::numeric_limits<size_t>::max())
, m_invalid_tx_index(std::numeric_limits<size_t>::max())
, 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)
{
m_hardforks.hard_fork_01_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
m_hardforks.hard_fork_01_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
m_hardforks.hard_fork_01_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
m_hardforks.hard_fork_01_starts_after_height = CURRENCY_MAX_BLOCK_NUMBER;
REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, configure_core);
REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, mark_invalid_tx);
REGISTER_CALLBACK_METHOD(test_chain_unit_enchanced, mark_unverifiable_tx);
@ -2122,19 +2132,14 @@ bool test_chain_unit_enchanced::configure_core(currency::core& c, size_t ev_inde
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
pc.min_coinstake_age = TESTS_POS_CONFIG_MIN_COINSTAKE_AGE;
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;
pc.hard_forks = m_hardforks;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}
void test_chain_unit_enchanced::set_hard_fork_heights_to_generator(test_generator& generator) const
{
generator.set_hardfork_height(1, m_hardfork_01_height);
generator.set_hardfork_height(2, m_hardfork_02_height);
generator.set_hardfork_height(3, m_hardfork_03_height);
generator.set_hardforks(m_hardforks);
}
bool test_chain_unit_enchanced::check_top_block(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)

View file

@ -324,9 +324,7 @@ protected:
size_t m_orphan_block_index;
// the following members is intended to be set by coretests with specific HF-related needs
uint64_t m_hardfork_01_height;
uint64_t m_hardfork_02_height;
uint64_t m_hardfork_03_height;
currency::hard_forks_descriptor m_hardforks;
};
struct wallet_test_core_proxy;
@ -530,15 +528,14 @@ public:
void set_pos_to_low_timestamp(bool do_pos_to_low_timestamp) { m_do_pos_to_low_timestamp = do_pos_to_low_timestamp; }
void set_ignore_last_pow_in_wallets(bool ignore_last_pow_in_wallets) { m_ignore_last_pow_in_wallets = ignore_last_pow_in_wallets; }
void set_hardfork_height(size_t hardfork_id, uint64_t h);
void set_hardforks(const currency::hard_forks_descriptor& hardforks);
private:
bool m_do_pos_to_low_timestamp;
bool m_ignore_last_pow_in_wallets;
uint64_t m_last_found_timestamp;
uint64_t m_hardfork_01_after_heigh;
uint64_t m_hardfork_02_after_heigh;
uint64_t m_hardfork_03_after_heigh;
currency::hard_forks_descriptor m_hardforks;
std::unordered_map<crypto::hash, block_info> m_blocks_info;
static test_gentime_settings m_test_gentime_settings;

View file

@ -166,6 +166,7 @@ enum escrow_custom_config_field
inline bool build_custom_escrow_template(const std::vector<test_event_entry>& events, const block& head, const account_keys& a_keys,
bc_services::contract_private_details& cpd, uint64_t unlock_time, uint64_t expiration_time, size_t nmix, uint64_t b_fee_release,
uint64_t custom_config_mask,
uint64_t tx_version,
transaction& escrow_template_tx, /* OUT */
crypto::secret_key& tx_key_sec, /* OUT */
std::vector<tx_source_entry>& used_sources /* IN/OUT */)
@ -230,7 +231,7 @@ inline bool build_custom_escrow_template(const std::vector<test_event_entry>& ev
if (custom_config_mask & eccf_template_additional_attach)
attachments.push_back(tx_comment({ get_random_text(1024) }));
r = construct_tx(a_keys, sources, destinations, extra, attachments, escrow_template_tx, tx_key_sec, unlock_time, crypt_addr, expiration_time, CURRENCY_TO_KEY_OUT_RELAXED, true, flags);
r = construct_tx(a_keys, sources, destinations, extra, attachments, escrow_template_tx, tx_version, tx_key_sec, unlock_time, crypt_addr, expiration_time, CURRENCY_TO_KEY_OUT_RELAXED, true, flags);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
if (custom_config_mask & eccf_template_no_tx_flags)
@ -264,6 +265,7 @@ inline bool build_custom_escrow_proposal(const std::vector<test_event_entry>& ev
bc_services::contract_private_details& cpd, uint64_t unlock_time, uint64_t expiration_time, uint64_t template_unlock_time, uint64_t template_expiration_time, size_t nmix,
uint64_t a_fee_proposal, uint64_t b_fee_release,
uint64_t custom_config_mask,
uint64_t tx_version,
transaction& escrow_proposal_tx, /* OUT */
std::vector<tx_source_entry>& used_sources,/* IN/OUT */
bc_services::proposal_body* p_pb = nullptr /* OUT */ )
@ -281,7 +283,7 @@ inline bool build_custom_escrow_proposal(const std::vector<test_event_entry>& ev
p_pb = &local_pb;
if (~custom_config_mask & eccf_proposal_sa_empty_body)
{
r = build_custom_escrow_template(events, head, a_keys, cpd, template_unlock_time, template_expiration_time, nmix, b_fee_release, custom_config_mask, p_pb->tx_template, p_pb->tx_onetime_secret_key, used_sources);
r = build_custom_escrow_template(events, head, a_keys, cpd, template_unlock_time, template_expiration_time, nmix, b_fee_release, custom_config_mask, tx_version, p_pb->tx_template, p_pb->tx_onetime_secret_key, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_template failed");
}
@ -307,7 +309,7 @@ inline bool build_custom_escrow_proposal(const std::vector<test_event_entry>& ev
account_public_address crypt_addr = cpd.b_addr;
crypto::secret_key tx_key_sec; // stub, not used
r = construct_tx(a_keys, sources, destinations, empty_extra, attachments, escrow_proposal_tx, tx_key_sec, unlock_time, crypt_addr, expiration_time, 0, true, (~custom_config_mask & eccf_proposal_inv_flags) ? 0 : TX_FLAG_SIGNATURE_MODE_SEPARATE);
r = construct_tx(a_keys, sources, destinations, empty_extra, attachments, escrow_proposal_tx, tx_version, tx_key_sec, unlock_time, crypt_addr, expiration_time, 0, true, (~custom_config_mask & eccf_proposal_inv_flags) ? 0 : TX_FLAG_SIGNATURE_MODE_SEPARATE);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
append_vector_by_another_vector(used_sources, sources);
@ -319,6 +321,7 @@ inline bool build_custom_escrow_release_template(
const account_keys& b_keys,
const bc_services::contract_private_details& cpd,
uint64_t unlock_time, uint64_t expiration_time,
uint64_t tx_version,
const transaction& escrow_template_tx, /* IN (needed for ms output, tx pub key) */
uint64_t custom_config_mask, /* IN */
transaction& tx /* OUT */
@ -417,7 +420,7 @@ inline bool build_custom_escrow_release_template(
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key);
account_public_address crypt_address = AUTO_VAL_INIT(crypt_address);
bool r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
bool r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
bool tx_fully_signed = false;
r = sign_multisig_input_in_tx(tx, 0, b_keys, escrow_template_tx, &tx_fully_signed);
@ -466,6 +469,7 @@ inline bool build_custom_escrow_accept_proposal(
uint64_t b_fee_accept, uint64_t b_fee_release,
uint64_t custom_config_mask, /* IN */
crypto::secret_key one_time_secret_key, /* IN */
uint64_t tx_version, /* IN */
transaction& tx, /* IN (escrow template), OUT */
std::vector<tx_source_entry>& used_sources /* IN/OUT */
)
@ -492,9 +496,9 @@ inline bool build_custom_escrow_accept_proposal(
// generate release templates
bc_services::escrow_relese_templates_body rtb = AUTO_VAL_INIT(rtb);
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_NORMAL, b_keys, cpd, release_unlock_time, release_expiration_time, tx, custom_config_mask, rtb.tx_normal_template);
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_NORMAL, b_keys, cpd, release_unlock_time, release_expiration_time, tx_version, tx, custom_config_mask, rtb.tx_normal_template);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_release_template(normal) failed");
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_BURN, b_keys, cpd, release_unlock_time, release_expiration_time, tx, custom_config_mask, rtb.tx_burn_template);
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_BURN, b_keys, cpd, release_unlock_time, release_expiration_time, tx_version, tx, custom_config_mask, rtb.tx_burn_template);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_release_template(burn) failed");
// put release templates into the extra
@ -525,7 +529,7 @@ inline bool build_custom_escrow_accept_proposal(
sources.back().separately_signed_tx_complete = true;
account_public_address crypt_address = AUTO_VAL_INIT(crypt_address);
r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, one_time_secret_key, 0, crypt_address, 0, 0, true, tx_flags); // see comment above regarding unlock_time and expiration_time
r = construct_tx(b_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, 0, crypt_address, 0, 0, true, tx_flags); // see comment above regarding unlock_time and expiration_time
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
return true;
@ -540,6 +544,7 @@ inline bool build_custom_escrow_cancel_proposal(
uint64_t a_fee_cancellation_request,
uint64_t custom_config_mask, /* IN */
const transaction& escrow_template_tx, /* IN */
uint64_t tx_version, /* IN */
transaction& tx, /* OUT */
std::vector<tx_source_entry>& used_sources /* IN/OUT */
)
@ -563,7 +568,7 @@ inline bool build_custom_escrow_cancel_proposal(
// generate cancel release template
bc_services::escrow_cancel_templates_body ctb = AUTO_VAL_INIT(ctb);
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_CANCEL, a_keys, cpd, release_unlock_time, release_expiration_time, escrow_template_tx, custom_config_mask, ctb.tx_cancel_template);
r = build_custom_escrow_release_template(BC_ESCROW_SERVICE_INSTRUCTION_RELEASE_CANCEL, a_keys, cpd, release_unlock_time, release_expiration_time, tx_version, escrow_template_tx, custom_config_mask, ctb.tx_cancel_template);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_release_template(cancel) failed");
// put release templates into the extra
@ -588,7 +593,7 @@ inline bool build_custom_escrow_cancel_proposal(
if (~custom_config_mask & eccf_cancellation_inv_crypt_address)
crypt_address = cpd.b_addr;
crypto::secret_key one_time_secret_key = AUTO_VAL_INIT(one_time_secret_key);
r = construct_tx(a_keys, sources, destinations, extra, attachments, tx, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
r = construct_tx(a_keys, sources, destinations, extra, attachments, tx, tx_version, one_time_secret_key, unlock_time, crypt_address, expiration_time, 0, true, tx_flags);
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
return true;

View file

@ -503,10 +503,10 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
// 1. create normal proposal and make sure it goes correctly through out the whole mechanism (test self-check)
// if it fails, it means build_custom_escrow_proposal() produced incorrect proposal
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
uint64_t normal_escrow_mask = eccf_proposal_additional_attach | eccf_template_additional_extra | eccf_template_additional_attach;
transaction normal_escrow_proposal_tx = AUTO_VAL_INIT(normal_escrow_proposal_tx);
r = build_custom_escrow_proposal(events, blk_1r, miner_acc.get_keys(), cpd, 0, 0, 0, blk_1r.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, normal_escrow_mask, normal_escrow_proposal_tx, used_sources);
r = build_custom_escrow_proposal(events, blk_1r, miner_acc.get_keys(), cpd, 0, 0, 0, blk_1r.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, normal_escrow_mask, tx_version, normal_escrow_proposal_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
events.push_back(normal_escrow_proposal_tx);
@ -550,8 +550,9 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
uint64_t config_mask = custom_config_masks[i].mask;
cpd.comment = "#" + std::to_string(i) + " " + custom_config_masks[i].name;
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, top_block.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, config_mask, escrow_proposal_tx, used_sources);
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, top_block.timestamp + 3600, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, config_mask, tx_version, escrow_proposal_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(escrow_proposal_tx) << " is built for mask: " << cpd.comment, LOG_LEVEL_0);
@ -579,8 +580,9 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
{
cpd.comment = "incorrect unlock time (past)";
transaction tx = AUTO_VAL_INIT(tx);
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
// set unlock time to the past (suppose it's incorrect for escrow proposals)
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, top_block.timestamp, 0, top_block.timestamp, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx, used_sources);
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, top_block.timestamp, 0, top_block.timestamp, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
events.push_back(tx);
@ -591,9 +593,10 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
{
cpd.comment = "incorrect unlock time (future)";
transaction tx = AUTO_VAL_INIT(tx);
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
// set unlock time to the future (suppose it's incorrect for escrow proposals)
uint64_t unlock_time = top_block.timestamp + 365 * 24 * 60 * 60;
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, unlock_time, 0, unlock_time, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx, used_sources);
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, unlock_time, 0, unlock_time, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
events.push_back(tx);
@ -604,7 +607,8 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
{
cpd.comment = "template zero expiration time";
transaction tx = AUTO_VAL_INIT(tx);
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx, used_sources);
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, 0, 0, 0, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
events.push_back(tx);
@ -615,9 +619,10 @@ bool escrow_incorrect_proposal::generate(std::vector<test_event_entry>& events)
{
cpd.comment = "proposal non-zero expiration time";
transaction tx = AUTO_VAL_INIT(tx);
tx_version = get_tx_version(get_block_height(top_block), m_hardforks);
uint64_t proposal_expiration_time = top_block.timestamp + 12 * 60 * 60;
uint64_t template_expiration_time = top_block.timestamp + 12 * 60 * 60;
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, proposal_expiration_time, 0, template_expiration_time, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx, used_sources);
r = build_custom_escrow_proposal(events, top_block, miner_acc.get_keys(), cpd, 0, proposal_expiration_time, 0, template_expiration_time, 0, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, eccf_normal, tx_version, tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
LOG_PRINT_YELLOW("proposal tx: " << get_transaction_hash(tx) << " is built for " << cpd.comment, LOG_LEVEL_0);
events.push_back(tx);
@ -1144,15 +1149,17 @@ bool escrow_incorrect_proposal_acceptance::generate(std::vector<test_event_entry
// create escrow proposal
bc_services::proposal_body prop = AUTO_VAL_INIT(prop);
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, escrow_proposal_tx, used_sources, &prop);
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, tx_version, escrow_proposal_tx, used_sources, &prop);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
events.push_back(escrow_proposal_tx);
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1r, miner_acc, escrow_proposal_tx);
// create normal acceptance
tx_version = get_tx_version(get_block_height(blk_2), m_hardforks);
transaction escrow_normal_acceptance_tx = prop.tx_template;
uint64_t normal_acceptance_mask = eccf_acceptance_no_tsa_compression;
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, escrow_normal_acceptance_tx, used_sources);
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, escrow_normal_acceptance_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
events.push_back(escrow_normal_acceptance_tx);
@ -1251,9 +1258,10 @@ bool escrow_incorrect_proposal_acceptance::generate(std::vector<test_event_entry
const auto &ccm_el = custom_config_masks[i];
uint64_t mask = ccm_el.mask;
tx_version = get_tx_version(get_block_height(prev_block), m_hardforks);
transaction incorrect_acceptance_tx = prop.tx_template;
r = build_custom_escrow_accept_proposal(events, prev_block, 0, bob_acc.get_keys(), m_cpd, ccm_el.unlock_time, ccm_el.expiration_time, ccm_el.release_unlock_time, ccm_el.release_expiration_time,
bob_fee_acceptance, m_bob_fee_release, mask, prop.tx_onetime_secret_key, incorrect_acceptance_tx, used_sources);
bob_fee_acceptance, m_bob_fee_release, mask, prop.tx_onetime_secret_key, tx_version, incorrect_acceptance_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
// In order to use the same escrow proposal to test different invalid acceptance we need to switch chains after each try
@ -1960,24 +1968,27 @@ bool escrow_incorrect_cancel_proposal::generate(std::vector<test_event_entry>& e
// create normal escrow proposal
bc_services::proposal_body prop = AUTO_VAL_INIT(prop);
uint64_t tx_version = get_tx_version(get_block_height(blk_1r), m_hardforks);
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, escrow_proposal_tx, used_sources, &prop);
r = build_custom_escrow_proposal(events, blk_1r, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_1r.timestamp + 36000, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, eccf_normal, tx_version, escrow_proposal_tx, used_sources, &prop);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
events.push_back(escrow_proposal_tx);
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1r, miner_acc, escrow_proposal_tx);
// create normal escrow proposal acceptance
transaction escrow_normal_acceptance_tx = prop.tx_template;
tx_version = get_tx_version(get_block_height(blk_2), m_hardforks);
uint64_t normal_acceptance_mask = eccf_acceptance_no_tsa_compression;
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, escrow_normal_acceptance_tx, used_sources);
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), m_cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, m_bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, escrow_normal_acceptance_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
events.push_back(escrow_normal_acceptance_tx);
MAKE_NEXT_BLOCK_TX1(events, blk_3, blk_2, miner_acc, escrow_normal_acceptance_tx);
// create normal cancel proposal
tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
transaction escrow_normal_cancel_proposal_tx = AUTO_VAL_INIT(escrow_normal_cancel_proposal_tx);
r = build_custom_escrow_cancel_proposal(events, blk_3, 0, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_3.timestamp + 3600, TESTS_DEFAULT_FEE, eccf_normal, prop.tx_template, escrow_normal_cancel_proposal_tx, used_sources);
r = build_custom_escrow_cancel_proposal(events, blk_3, 0, alice_acc.get_keys(), m_cpd, 0, 0, 0, blk_3.timestamp + 3600, TESTS_DEFAULT_FEE, eccf_normal, prop.tx_template, tx_version, escrow_normal_cancel_proposal_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_cancel_proposal failed");
events.push_back(escrow_normal_cancel_proposal_tx);
@ -2045,8 +2056,9 @@ bool escrow_incorrect_cancel_proposal::generate(std::vector<test_event_entry>& e
uint64_t mask = ccm_el.mask;
transaction incorrect_cancellation_proposal_tx = prop.tx_template;
uint64_t tx_version = get_tx_version(get_block_height(blk_3), m_hardforks);
r = build_custom_escrow_cancel_proposal(events, prev_block, 0, alice_acc.get_keys(), m_cpd, ccm_el.unlock_time, ccm_el.expiration_time, ccm_el.release_unlock_time, ccm_el.release_expiration_time,
TESTS_DEFAULT_FEE, mask, prop.tx_template, incorrect_cancellation_proposal_tx, used_sources);
TESTS_DEFAULT_FEE, mask, prop.tx_template, tx_version, incorrect_cancellation_proposal_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_cancel_proposal failed");
// In order to use the same escrow proposal to test different invalid cancellations we need to switch chains after each try
@ -2972,8 +2984,9 @@ bool escrow_proposal_acceptance_in_alt_chain::generate(std::vector<test_event_en
// escrow proposal
bc_services::proposal_body prop = AUTO_VAL_INIT(prop);
uint64_t tx_version = get_tx_version(get_block_height(blk_1), m_hardforks);
transaction escrow_proposal_tx = AUTO_VAL_INIT(escrow_proposal_tx);
r = build_custom_escrow_proposal(events, blk_1, alice_acc.get_keys(), cpd, 0, 0, 0, blk_1.timestamp + 36000, 0, TESTS_DEFAULT_FEE, bob_fee_release, eccf_normal, escrow_proposal_tx, used_sources, &prop);
r = build_custom_escrow_proposal(events, blk_1, alice_acc.get_keys(), cpd, 0, 0, 0, blk_1.timestamp + 36000, 0, TESTS_DEFAULT_FEE, bob_fee_release, eccf_normal, tx_version, escrow_proposal_tx, used_sources, &prop);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_proposal failed");
events.push_back(escrow_proposal_tx);
MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1, miner_acc, escrow_proposal_tx);
@ -2981,9 +2994,10 @@ bool escrow_proposal_acceptance_in_alt_chain::generate(std::vector<test_event_en
MAKE_NEXT_BLOCK(events, blk_3, blk_2, miner_acc);
// escrow proposal acceptance
tx_version = get_tx_version(get_block_height(blk_2), m_hardforks);
transaction escrow_normal_acceptance_tx = prop.tx_template;
uint64_t normal_acceptance_mask = eccf_normal; //eccf_acceptance_no_tsa_compression;
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, escrow_normal_acceptance_tx, used_sources);
r = build_custom_escrow_accept_proposal(events, blk_2, 0, bob_acc.get_keys(), cpd, 0, 0, 0, 0, TESTS_DEFAULT_FEE, bob_fee_release, normal_acceptance_mask, prop.tx_onetime_secret_key, tx_version, escrow_normal_acceptance_tx, used_sources);
CHECK_AND_ASSERT_MES(r, false, "build_custom_escrow_accept_proposal failed");
events.push_back(escrow_normal_acceptance_tx);

View file

@ -35,7 +35,7 @@ bool hard_fork_1_base_test::configure_core(currency::core& c, size_t ev_index, c
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
pc.min_coinstake_age = TESTS_POS_CONFIG_MIN_COINSTAKE_AGE;
pc.pos_minimum_heigh = TESTS_POS_CONFIG_POS_MINIMUM_HEIGH;
pc.hard_fork_01_starts_after_height = m_hardfork_height;
pc.hard_forks.hard_fork_01_starts_after_height = m_hardfork_height;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}

View file

@ -72,7 +72,7 @@ bool hard_fork_1_bad_pos_source::configure_core(currency::core& c, size_t ev_ind
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
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 = get_hardfork_height();
pc.hard_forks.hard_fork_01_starts_after_height = get_hardfork_height();
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;

View file

@ -62,7 +62,7 @@ bool hard_fork_1_cumulative_difficulty_base::configure_core(currency::core& c, s
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
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 = get_hardfork_height();
pc.hard_forks.hard_fork_01_starts_after_height = get_hardfork_height();
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;

View file

@ -103,7 +103,7 @@ bool hard_fork_1_locked_mining_test::configure_core(currency::core& c, size_t ev
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
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 = get_hardfork_height();
pc.hard_forks.hard_fork_01_starts_after_height = get_hardfork_height();
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;

View file

@ -20,6 +20,7 @@ hard_fork_2_base_test::hard_fork_2_base_test(size_t hardfork_01_height, size_t h
, 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);
}
@ -28,9 +29,9 @@ bool hard_fork_2_base_test::configure_core(currency::core& c, size_t ev_index, c
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
pc.min_coinstake_age = TESTS_POS_CONFIG_MIN_COINSTAKE_AGE;
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;
pc.hard_forks.hard_fork_01_starts_after_height = m_hardfork_01_height;
pc.hard_forks.hard_fork_02_starts_after_height = m_hardfork_02_height;
pc.hard_forks.hard_fork_03_starts_after_height = m_hardfork_03_height;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}

View file

@ -38,6 +38,7 @@ void transfer_multisig(tools::wallet2& w,
tools::detail::split_strategy_id_t split_strategy_id,
const tools::tx_dust_policy& dust_policy,
currency::transaction &tx,
uint64_t tx_version,
uint8_t tx_outs_attr = CURRENCY_TO_KEY_OUT_RELAXED,
uint64_t flags = 0,
bool shuffle = true,
@ -62,6 +63,9 @@ void transfer_multisig(tools::wallet2& w,
ctp.split_strategy_id = split_strategy_id;
ctp.tx_outs_attr = tx_outs_attr;
ctp.unlock_time = unlock_time;
ftp.tx_version = tx_version;
w.prepare_transaction(ctp, ftp, tx);
crypto::secret_key sk = AUTO_VAL_INIT(sk);
@ -185,6 +189,7 @@ bool multisig_wallet_test::c1(currency::core& c, size_t ev_index, const std::vec
wallet_b->get_multisig_transfers(ms_b);
CHECK_AND_ASSERT_MES(ms_a.size() == 1 && ms_b.size() == 1, false, "Multisig failed: ms_a.size() == 1 && ms_b.size() == 1");
uint64_t tx_version = currency::get_tx_version(c.get_current_blockchain_size(), c.get_blockchain_storage().get_core_runtime_config().hard_forks) ;
std::vector<tx_destination_entry> dst2(1);
dst2.back().addr.resize(1);
dst2.back().addr.back() = m_accunt_c.get_public_address();
@ -203,7 +208,8 @@ bool multisig_wallet_test::c1(currency::core& c, size_t ev_index, const std::vec
attachments,
tools::detail::ssi_digit,
tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD),
result_tx);
result_tx,
tx_version);
r = mine_next_pow_blocks_in_playtime(m_mining_accunt.get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
CHECK_AND_ASSERT_MES(r, false, "mine_next_pow_blocks_in_playtime failed");
@ -311,7 +317,7 @@ bool multisig_wallet_test_many_dst::c1(currency::core& c, size_t ev_index, const
tx_destination_entry de2(amount - TESTS_DEFAULT_FEE, m_accounts[ALICE_ACC_IDX].get_public_address());
transaction tx = AUTO_VAL_INIT(tx);
TMP_LOG_SILENT;
transfer_multisig(*w.get(), owner_keys, get_multisig_out_id(result_tx, multisig_index), std::vector<tx_destination_entry>({ de2 }), 0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx);
transfer_multisig(*w.get(), owner_keys, get_multisig_out_id(result_tx, multisig_index), std::vector<tx_destination_entry>({ de2 }), 0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, c.get_current_tx_version());
TMP_LOG_RESTORE;
r = mine_next_pow_blocks_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
@ -481,7 +487,7 @@ bool multisig_wallet_heterogenous_dst::c1(currency::core& c, size_t ev_index, co
currency::transaction tx = AUTO_VAL_INIT(tx);
transfer_multisig(*alice_wlt.get(), std::list<account_keys>({ m_accounts[BOB_ACC_IDX].get_keys() }), ms1_hash, std::vector<tx_destination_entry>({ tx_destination_entry(amount1, receiver_acc.get_public_address()) }),
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx);
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, c.get_current_tx_version());
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Incorrect txs count in the pool");
r = mine_next_pow_block_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c);
@ -515,7 +521,7 @@ bool multisig_wallet_heterogenous_dst::c1(currency::core& c, size_t ev_index, co
tx = AUTO_VAL_INIT(tx);
transfer_multisig(*carol_wlt.get(), std::list<account_keys>({ m_accounts[DAN_ACC_IDX].get_keys() }), ms2_hash, std::vector<tx_destination_entry>({ tx_destination_entry(amount2, receiver_acc.get_public_address()) }),
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx);
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, c.get_current_tx_version());
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Incorrect txs count in the pool");
@ -543,7 +549,7 @@ bool multisig_wallet_heterogenous_dst::c1(currency::core& c, size_t ev_index, co
// Re-try spending Carol-Dan multisig out on behalf of Dan. It should be OK now
transfer_multisig(*dan_wlt.get(), std::list<account_keys>({ m_accounts[CAROL_ACC_IDX].get_keys() }), ms2_hash, std::vector<tx_destination_entry>({ tx_destination_entry(amount2, receiver_acc.get_public_address()) }),
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx);
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, c.get_current_tx_version());
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Incorrect txs count in the pool");
r = mine_next_pow_block_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c);
@ -561,7 +567,7 @@ bool multisig_wallet_heterogenous_dst::c1(currency::core& c, size_t ev_index, co
tx = AUTO_VAL_INIT(tx);
transfer_multisig(*alice_wlt.get(), std::list<account_keys>({ m_accounts[DAN_ACC_IDX].get_keys() }), ms3_hash, std::vector<tx_destination_entry>({ tx_destination_entry(amount3, receiver_acc.get_public_address()) }),
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx);
0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, c.get_current_tx_version());
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Incorrect txs count in the pool");
@ -701,7 +707,7 @@ bool multisig_wallet_same_dst_addr::c1(currency::core& c, size_t ev_index, const
transaction tx = AUTO_VAL_INIT(tx);
transfer_multisig(*alice_wlt.get(), std::list<account_keys>({ m_accounts[ALICE_ACC_IDX].get_keys() }), ms_hash,
std::vector<tx_destination_entry>({ tx_destination_entry(amount, m_accounts[BOB_ACC_IDX].get_public_address()) }),
0, TESTS_DEFAULT_FEE, empty_extra, empty_attachment, tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx);
0, TESTS_DEFAULT_FEE, empty_extra, empty_attachment, tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, c.get_current_tx_version());
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Incorrect number of tx in the pool");
r = mine_next_pow_block_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c);
@ -795,7 +801,7 @@ bool multisig_wallet_ms_to_ms::c1(currency::core& c, size_t ev_index, const std:
transaction ms_tx2 = AUTO_VAL_INIT(ms_tx2);
transfer_multisig(*alice_wlt.get(), std::list<account_keys>({ m_accounts[BOB_ACC_IDX].get_keys() }), ms_hash,
std::vector<tx_destination_entry>({ de }),
0, TESTS_DEFAULT_FEE, empty_extra, empty_attachment, tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), ms_tx2);
0, TESTS_DEFAULT_FEE, empty_extra, empty_attachment, tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), ms_tx2, c.get_current_tx_version());
// check the pool and mine a block
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Incorrect number of tx in the pool");
@ -812,7 +818,7 @@ bool multisig_wallet_ms_to_ms::c1(currency::core& c, size_t ev_index, const std:
transaction tx = AUTO_VAL_INIT(tx);
transfer_multisig(*miner_wlt.get(), std::list<account_keys>({ m_accounts[BOB_ACC_IDX].get_keys() }), ms_hash2,
std::vector<tx_destination_entry>({ tx_destination_entry(amount - TESTS_DEFAULT_FEE, m_accounts[BOB_ACC_IDX].get_public_address()) }),
0, TESTS_DEFAULT_FEE, empty_extra, empty_attachment, tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx);
0, TESTS_DEFAULT_FEE, empty_extra, empty_attachment, tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), tx, c.get_current_tx_version());
CHECK_AND_ASSERT_MES(c.get_pool_transactions_count() == 1, false, "Incorrect number of tx in the pool");
r = mine_next_pow_block_in_playtime(m_accounts[MINER_ACC_IDX].get_public_address(), c);
@ -2549,7 +2555,7 @@ bool multisig_unconfirmed_transfer_and_multiple_scan_pool_calls::c1(currency::co
attachments,
tools::detail::ssi_digit,
tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD),
tx);
tx, c.get_current_tx_version());
LOG_PRINT_YELLOW("%%%%% tx " << get_transaction_hash(tx) << " is spending multisig output " << multisig_id, LOG_LEVEL_0);

View file

@ -775,8 +775,8 @@ gen_crypted_attachments::gen_crypted_attachments()
REGISTER_CALLBACK("check_offers_count_befor_cancel", gen_crypted_attachments::check_offers_count_befor_cancel);
REGISTER_CALLBACK("check_offers_count_after_cancel", gen_crypted_attachments::check_offers_count_after_cancel);
m_hardfork_01_height = 0;
m_hardfork_02_height = 0; // tx_payer is allowed only after HF2
m_hardforks.hard_fork_01_starts_after_height = 0;
m_hardforks.hard_fork_02_starts_after_height = 0; // tx_payer is allowed only after HF2
}
bool gen_crypted_attachments::generate(std::vector<test_event_entry>& events) const
@ -989,8 +989,8 @@ bool gen_tx_extra_double_entry::configure_core(currency::core& c, size_t ev_inde
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
pc.min_coinstake_age = TESTS_POS_CONFIG_MIN_COINSTAKE_AGE;
pc.pos_minimum_heigh = TESTS_POS_CONFIG_POS_MINIMUM_HEIGH;
pc.hard_fork_01_starts_after_height = 0;
pc.hard_fork_02_starts_after_height = 0;
pc.hard_forks.hard_fork_01_starts_after_height = 0;
pc.hard_forks.hard_fork_02_starts_after_height = 0;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}

View file

@ -216,9 +216,9 @@ bool wallet_rpc_transfer::generate(std::vector<test_event_entry>& events) const
bool wallet_rpc_transfer::configure_core(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
{
currency::core_runtime_config pc = c.get_blockchain_storage().get_core_runtime_config();
pc.hard_fork_01_starts_after_height = 1;
pc.hard_fork_02_starts_after_height = 1;
pc.hard_fork_03_starts_after_height = 1;
pc.hard_forks.hard_fork_01_starts_after_height = 1;
pc.hard_forks.hard_fork_02_starts_after_height = 1;
pc.hard_forks.hard_fork_03_starts_after_height = 1;
c.get_blockchain_storage().set_core_runtime_config(pc);
return true;
}

View file

@ -1381,8 +1381,8 @@ bool gen_wallet_transfers_and_chain_switch::generate(std::vector<test_event_entr
gen_wallet_decrypted_attachments::gen_wallet_decrypted_attachments()
: m_on_transfer2_called(false)
{
m_hardfork_01_height = 0;
m_hardfork_02_height = 0; // tx_payer requires HF2
m_hardforks.hard_fork_01_starts_after_height = 0;
m_hardforks.hard_fork_02_starts_after_height = 0; // tx_payer requires HF2
}
bool gen_wallet_decrypted_attachments::generate(std::vector<test_event_entry>& events) const
@ -1562,8 +1562,8 @@ void gen_wallet_decrypted_attachments::on_transfer2(const tools::wallet_public::
gen_wallet_alias_and_unconfirmed_txs::gen_wallet_alias_and_unconfirmed_txs()
{
m_hardfork_01_height = 0;
m_hardfork_02_height = 0;
m_hardforks.hard_fork_01_starts_after_height = 0;
m_hardforks.hard_fork_02_starts_after_height = 0;
REGISTER_CALLBACK_METHOD(gen_wallet_alias_and_unconfirmed_txs, c1);
REGISTER_CALLBACK_METHOD(gen_wallet_alias_and_unconfirmed_txs, c2);
@ -1711,8 +1711,8 @@ bool gen_wallet_alias_and_unconfirmed_txs::c3(currency::core& c, size_t ev_index
gen_wallet_alias_via_special_wallet_funcs::gen_wallet_alias_via_special_wallet_funcs()
{
// start hardfork from block 0 in order to use extra_alias_entry (allowed only since HF2)
m_hardfork_01_height = 0;
m_hardfork_02_height = 0;
m_hardforks.hard_fork_01_starts_after_height = 0;
m_hardforks.hard_fork_02_starts_after_height = 0;
REGISTER_CALLBACK_METHOD(gen_wallet_alias_via_special_wallet_funcs, c1);
}