forked from lthn/blockchain
Merge branch 'multiassets' into cryptoassets
This commit is contained in:
commit
5230d062c8
13 changed files with 126 additions and 41 deletions
|
|
@ -204,6 +204,22 @@ namespace crypto
|
|||
DBG_PRINT("zarcanum_verify_proof");
|
||||
bool r = false;
|
||||
|
||||
//std::cout << "===== zarcanum_verify_proof =====" << ENDL
|
||||
// << "m: " << m << ENDL
|
||||
// << "kernel_hash: " << kernel_hash << ENDL
|
||||
// << "last_pow_block_id_hashed: " << last_pow_block_id_hashed << ENDL
|
||||
// << "stake_ki: " << stake_ki << ENDL
|
||||
// << "pos_difficulty: " << pos_difficulty << ENDL;
|
||||
//size_t ii = 0;
|
||||
//for(const auto& el : ring)
|
||||
//{
|
||||
// std::cout << "[" << ii << "]" << ENDL
|
||||
// << " amount_commitment: " << el.amount_commitment << ENDL
|
||||
// << " blinded_asset_id: " << el.blinded_asset_id << ENDL
|
||||
// << " concealing_point: " << el.concealing_point << ENDL
|
||||
// << " stealth_address: " << el.stealth_address << ENDL;
|
||||
//}
|
||||
|
||||
// make sure 0 < d <= l / floor(z * D)
|
||||
const mp::uint256_t l_div_z_D_mp = crypto::zarcanum_precalculate_l_div_z_D(pos_difficulty);
|
||||
const scalar_t l_div_z_D(l_div_z_D_mp);
|
||||
|
|
|
|||
|
|
@ -5591,30 +5591,35 @@ bool blockchain_storage::validate_pos_block(const block& b,
|
|||
const txin_zc_input& stake_input = boost::get<txin_zc_input>(b.miner_tx.vin[1]);
|
||||
CHECK_AND_ASSERT_MES(b.miner_tx.signatures.size() == 1, false, "incorrect number of stake input signatures: " << b.miner_tx.signatures.size());
|
||||
CHECK_AND_ASSERT_MES(b.miner_tx.signatures[0].type() == typeid(zarcanum_sig), false, "incorrect sig 0 type: " << b.miner_tx.signatures[0].type().name());
|
||||
const zarcanum_sig& sig = boost::get<zarcanum_sig>(b.miner_tx.signatures[0]);
|
||||
|
||||
if (!for_altchain)
|
||||
{
|
||||
// do general input check for main chain blocks only
|
||||
// TODO @#@#: txs in alternative PoS blocks (including miner_tx) must be validated by validate_alt_block_txs()
|
||||
const zarcanum_sig& sig = boost::get<zarcanum_sig>(b.miner_tx.signatures[0]);
|
||||
uint64_t max_related_block_height = 0;
|
||||
std::vector<crypto::public_key> dummy_output_keys; // won't be used
|
||||
uint64_t dummy_source_max_unlock_time_for_pos_coinbase_dummy = 0; // won't be used
|
||||
scan_for_keys_context scan_contex = AUTO_VAL_INIT(scan_contex);
|
||||
r = get_output_keys_for_input_with_checks(b.miner_tx, stake_input, dummy_output_keys, max_related_block_height, dummy_source_max_unlock_time_for_pos_coinbase_dummy, scan_contex);
|
||||
CHECK_AND_ASSERT_MES(r, false, "get_output_keys_for_input_with_checks failed for stake input");
|
||||
CHECK_AND_ASSERT_MES(scan_contex.zc_outs.size() == stake_input.key_offsets.size(), false, "incorrect number of referenced outputs found: " << scan_contex.zc_outs.size() << ", while " << stake_input.key_offsets.size() << " is expected.");
|
||||
// make sure that all referring inputs are either older then, or the same age as, the most resent PoW block.
|
||||
CHECK_AND_ASSERT_MES(max_related_block_height <= last_pow_block_height, false, "stake input refs' max related block height is " << max_related_block_height << " while last PoW block height is " << last_pow_block_height);
|
||||
|
||||
// TODO @#@# do general input check for main chain blocks only?
|
||||
uint64_t max_related_block_height = 0;
|
||||
std::vector<crypto::public_key> dummy_output_keys; // won't be used
|
||||
uint64_t dummy_source_max_unlock_time_for_pos_coinbase_dummy = 0; // won't be used
|
||||
scan_for_keys_context scan_contex = AUTO_VAL_INIT(scan_contex);
|
||||
r = get_output_keys_for_input_with_checks(b.miner_tx, stake_input, dummy_output_keys, max_related_block_height, dummy_source_max_unlock_time_for_pos_coinbase_dummy, scan_contex);
|
||||
CHECK_AND_ASSERT_MES(r, false, "get_output_keys_for_input_with_checks failed for stake input");
|
||||
CHECK_AND_ASSERT_MES(scan_contex.zc_outs.size() == stake_input.key_offsets.size(), false, "incorrect number of referenced outputs found: " << scan_contex.zc_outs.size() << ", while " << stake_input.key_offsets.size() << " is expected.");
|
||||
// make sure that all referring inputs are either older then, or the same age as, the most resent PoW block.
|
||||
CHECK_AND_ASSERT_MES(max_related_block_height <= last_pow_block_height, false, "stake input refs' max related block height is " << max_related_block_height << " while last PoW block height is " << last_pow_block_height);
|
||||
// build a ring of references
|
||||
vector<crypto::CLSAG_GGXXG_input_ref_t> ring;
|
||||
ring.reserve(scan_contex.zc_outs.size());
|
||||
for(auto& zc_out : scan_contex.zc_outs)
|
||||
ring.emplace_back(zc_out.stealth_address, zc_out.amount_commitment, zc_out.blinded_asset_id, zc_out.concealing_point);
|
||||
|
||||
// build a ring of references
|
||||
vector<crypto::CLSAG_GGXXG_input_ref_t> ring;
|
||||
ring.reserve(scan_contex.zc_outs.size());
|
||||
for(auto& zc_out : scan_contex.zc_outs)
|
||||
ring.emplace_back(zc_out.stealth_address, zc_out.amount_commitment, zc_out.blinded_asset_id, zc_out.concealing_point);
|
||||
crypto::scalar_t last_pow_block_id_hashed = crypto::hash_helper_t::hs(CRYPTO_HDS_ZARCANUM_LAST_POW_HASH, sm.last_pow_id);
|
||||
|
||||
crypto::scalar_t last_pow_block_id_hashed = crypto::hash_helper_t::hs(CRYPTO_HDS_ZARCANUM_LAST_POW_HASH, sm.last_pow_id);
|
||||
uint8_t err = 0;
|
||||
r = crypto::zarcanum_verify_proof(id, kernel_hash, ring, last_pow_block_id_hashed, stake_input.k_image, basic_diff, sig, &err);
|
||||
CHECK_AND_ASSERT_MES(r, false, "zarcanum_verify_proof failed with code " << (int)err);
|
||||
}
|
||||
|
||||
uint8_t err = 0;
|
||||
r = crypto::zarcanum_verify_proof(id, kernel_hash, ring, last_pow_block_id_hashed, stake_input.k_image, basic_diff, sig, &err);
|
||||
CHECK_AND_ASSERT_MES(r, false, "zarcanum_verify_proof failed with code " << (int)err);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
@ -7155,10 +7160,13 @@ bool blockchain_storage::validate_alt_block_input(const transaction& input_tx,
|
|||
}
|
||||
else
|
||||
{
|
||||
// TODO @#@# properly handle ZC inputs! check_tx_input below isn't working because of incorrectly assembled ring
|
||||
/*
|
||||
uint64_t max_related_block_height = 0;
|
||||
bool all_tx_ins_have_explicit_asset_ids = true; // stub for now, TODO @#@#
|
||||
r = check_tx_input(input_tx, input_index, input_zc, input_tx_hash, max_related_block_height, all_tx_ins_have_explicit_asset_ids);
|
||||
CHECK_AND_ASSERT_MES(r, false, "check_tx_input failed");
|
||||
*/
|
||||
}
|
||||
VARIANT_CASE_OTHER()
|
||||
LOG_ERROR("unexpected input type: " << input_v.type().name());
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@
|
|||
#define STRARUM_DEFAULT_PORT 51113
|
||||
#define P2P_NETWORK_ID_TESTNET_FLAG 1
|
||||
#define P2P_MAINTAINERS_PUB_KEY "aaa2d7aabc8d383fd53a3ae898697b28f236ceade6bafc1eecff413a6a02272a"
|
||||
#define DIFFICULTY_POS_STARTER 625000000000
|
||||
#define DIFFICULTY_POS_STARTER 1
|
||||
#endif
|
||||
|
||||
#define P2P_NETWORK_ID_VER (CURRENCY_FORMATION_VERSION+0)
|
||||
|
|
|
|||
|
|
@ -4064,6 +4064,11 @@ bool wallet2::prepare_and_sign_pos_block(const mining_context& cxt, currency::bl
|
|||
WLT_CHECK_AND_ASSERT_MES(r, false, "generate_tx_balance_proof failed");
|
||||
b.miner_tx.proofs.emplace_back(std::move(balance_proof));
|
||||
|
||||
// the following line are for debugging when necessary -- sowle
|
||||
//err = 0;
|
||||
//r = crypto::zarcanum_verify_proof(hash_for_zarcanum_sig, cxt.kernel_hash, ring, cxt.last_pow_block_id_hashed, cxt.sk.kimage, cxt.basic_diff, sig, &err);
|
||||
//WLT_CHECK_AND_ASSERT_MES(r, false, "zarcanum_verify_proof failed with code " << (int)err);
|
||||
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
|
@ -6403,7 +6408,7 @@ void wallet2::prepare_transaction(construct_tx_param& ctp, currency::finalize_tx
|
|||
TIME_MEASURE_START_MS(prepare_tx_sources_time);
|
||||
if (ctp.perform_packing)
|
||||
{
|
||||
prepare_tx_sources_for_packing(WALLET_DEFAULT_POS_MINT_PACKING_SIZE, 0, ftp.sources, ftp.selected_transfers, needed_money_map[currency::null_pkey].found_amount);
|
||||
prepare_tx_sources_for_packing(WALLET_DEFAULT_POS_MINT_PACKING_SIZE, 0, ftp.sources, ftp.selected_transfers, needed_money_map[currency::native_coin_asset_id].found_amount);
|
||||
}
|
||||
else if (ctp.htlc_tx_id != currency::null_hash)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,6 +52,10 @@ struct gen_block_accepted_base : public test_chain_unit_base
|
|||
{
|
||||
gen_block_accepted_base()
|
||||
{
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[1] = 1440;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[2] = 1800;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[3] = 1801;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[4] = 50000000000;
|
||||
REGISTER_CALLBACK("check_block_accepted", gen_block_accepted_base::check_block_accepted);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,10 +164,21 @@ void test_generator::add_block_info(const block_info& bi)
|
|||
m_blocks_info[block_hash] = bi;
|
||||
|
||||
std::stringstream ss_tx_hashes;
|
||||
auto it = bi.m_transactions.begin();
|
||||
for (auto& h : bi.b.tx_hashes)
|
||||
{
|
||||
ss_tx_hashes << " [tx]: " << h << ENDL;
|
||||
|
||||
if (it != bi.m_transactions.end())
|
||||
{
|
||||
if (log_space::get_set_log_detalisation_level() >= LOG_LEVEL_1)
|
||||
{
|
||||
ss_tx_hashes << obj_to_json_str(*it) << ENDL;
|
||||
}
|
||||
it++;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_PRINT_MAGENTA("ADDED_BLOCK[" << block_hash << "][" << (is_pos_block(bi.b)? "PoS":"PoW") <<"][" << get_block_height(bi.b) << "][cumul_diff:" << bi.cumul_difficulty << "]" << ENDL << ss_tx_hashes.str(), LOG_LEVEL_0);
|
||||
}
|
||||
|
||||
|
|
@ -631,10 +642,10 @@ bool test_generator::find_kernel(const std::list<currency::account_base>& accs,
|
|||
pe.tx_out_index = td.m_internal_output_index;
|
||||
pe.wallet_index = context.index;
|
||||
|
||||
LOG_PRINT_GREEN("Found kernel: amount=" << print_money_brief(pe.amount)
|
||||
<< ", gindex=" << pe.g_index
|
||||
<< ", key_image=" << pe.keyimage
|
||||
/*<< ", diff: " << this_coin_diff*/, LOG_LEVEL_1);
|
||||
LOG_PRINT_GREEN("Additional kernel info: source tx id: " << pe.tx_id
|
||||
<< ", key_image: " << pe.keyimage
|
||||
<< ", gindex: " << pe.g_index
|
||||
<< ", out's height: " << td.m_ptx_wallet_info->m_block_height, LOG_LEVEL_1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2276,6 +2287,13 @@ currency::core_runtime_config test_chain_unit_base::get_runtime_info_for_core()
|
|||
crc.hard_forks = m_hardforks;
|
||||
return crc;
|
||||
}
|
||||
|
||||
void test_chain_unit_base::set_hardforks_for_old_tests()
|
||||
{
|
||||
m_hardforks.set_hardfork_height(1, 1440);
|
||||
m_hardforks.set_hardfork_height(2, 1800);
|
||||
m_hardforks.set_hardfork_height(3, 1801);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
test_chain_unit_enchanced::test_chain_unit_enchanced()
|
||||
|
|
|
|||
|
|
@ -259,6 +259,8 @@ public:
|
|||
|
||||
currency::core_runtime_config get_runtime_info_for_core() const; // tests can override this for special initialization
|
||||
|
||||
void set_hardforks_for_old_tests();
|
||||
|
||||
private:
|
||||
callbacks_map m_callbacks;
|
||||
|
||||
|
|
|
|||
|
|
@ -1069,8 +1069,6 @@ int main(int argc, char* argv[])
|
|||
GENERATE_AND_PLAY(hard_fork_1_checkpoint_basic_test);
|
||||
GENERATE_AND_PLAY(hard_fork_1_pos_locked_height_vs_time);
|
||||
GENERATE_AND_PLAY(hard_fork_1_pos_and_locked_coins);
|
||||
|
||||
|
||||
|
||||
// Hardfork 2 tests
|
||||
GENERATE_AND_PLAY(hard_fork_2_tx_payer_in_wallet);
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ void remove_unlock_v2_entries_from_extra(extra_t& extra)
|
|||
hard_fork_1_base_test::hard_fork_1_base_test(size_t hardfork_height)
|
||||
: m_hardfork_height(hardfork_height)
|
||||
{
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[1] = 1440;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[2] = 1800;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[3] = 1801;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[4] = 50000000000;
|
||||
REGISTER_CALLBACK_METHOD(hard_fork_1_base_test, configure_core);
|
||||
}
|
||||
|
||||
|
|
@ -475,11 +479,12 @@ hard_fork_1_pos_and_locked_coins::hard_fork_1_pos_and_locked_coins()
|
|||
|
||||
bool hard_fork_1_pos_and_locked_coins::generate(std::vector<test_event_entry>& events) const
|
||||
{
|
||||
random_state_test_restorer::reset_random();
|
||||
bool r = false;
|
||||
GENERATE_ACCOUNT(miner_acc);
|
||||
GENERATE_ACCOUNT(alice_acc);
|
||||
GENERATE_ACCOUNT(bob_acc);
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, test_core_time::get_time());
|
||||
MAKE_GENESIS_BLOCK(events, blk_0, miner_acc, starter_timestamp);
|
||||
generator.set_hardfork_height(1, m_hardfork_height);
|
||||
DO_CALLBACK(events, "configure_core");
|
||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_0r, blk_0, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 3);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ struct hard_fork_1_pos_and_locked_coins : public hard_fork_1_base_test
|
|||
bool generate(std::vector<test_event_entry>& events) const;
|
||||
|
||||
bool check_outputs_with_unique_amount(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events);
|
||||
uint64_t starter_timestamp = 1564434640;
|
||||
};
|
||||
|
||||
struct hard_fork_1_pos_locked_height_vs_time : public hard_fork_1_base_test
|
||||
|
|
|
|||
|
|
@ -1632,14 +1632,17 @@ multisig_and_checkpoints::multisig_and_checkpoints()
|
|||
{
|
||||
// NOTE: This test is made deterministic to be able to correctly set up checkpoint.
|
||||
random_state_test_restorer::reset_random(); // random generator's state was previously stored, will be restore on dtor (see also m_random_state_test_restorer)
|
||||
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[1] = 1440;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[2] = 1800;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[3] = 1801;
|
||||
m_hardforks.m_height_the_hardfork_n_active_after[4] = 50000000000;
|
||||
REGISTER_CALLBACK_METHOD(multisig_and_checkpoints, set_cp);
|
||||
}
|
||||
|
||||
bool multisig_and_checkpoints::set_cp(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
|
||||
{
|
||||
currency::checkpoints checkpoints;
|
||||
checkpoints.add_checkpoint(15, "10521273decd310d17be7216c4bd1c0bb55d9adf70e068943d216878276dbe5a");
|
||||
checkpoints.add_checkpoint(15, "6f9194c144afd73077478e7f04e947c50160b5673558e6f696a4f662a3ca261e");
|
||||
c.set_checkpoints(std::move(checkpoints));
|
||||
|
||||
return true;
|
||||
|
|
@ -1689,7 +1692,7 @@ bool multisig_and_checkpoints::generate(std::vector<test_event_entry>& events) c
|
|||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), to_addrs, amount, TESTS_DEFAULT_FEE, 0, sources, destinations, true, true, 1);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, currency::get_tx_version(get_block_height(blk_0r), m_hardforks), 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx");
|
||||
|
||||
events.push_back(event_visitor_settings(event_visitor_settings::set_txs_kept_by_block, true)); // tx_1 goes with the block blk_1
|
||||
|
|
@ -1710,7 +1713,7 @@ bool multisig_and_checkpoints::generate(std::vector<test_event_entry>& events) c
|
|||
tx_destination_entry de(amount - TESTS_DEFAULT_FEE, bob_acc.get_public_address());
|
||||
|
||||
transaction tx_2 = AUTO_VAL_INIT(tx_2);
|
||||
r = construct_tx(alice_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_2, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(alice_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_2, currency::get_tx_version(get_block_height(blk_1), m_hardforks), 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
bool tx_fully_signed = false;
|
||||
r = sign_multisig_input_in_tx(tx_2, 0, alice_acc.get_keys(), tx_1, &tx_fully_signed);
|
||||
|
|
@ -1728,7 +1731,7 @@ bool multisig_and_checkpoints::generate(std::vector<test_event_entry>& events) c
|
|||
r = fill_tx_sources_and_destinations(events, blk_2, miner_acc.get_keys(), to_addrs, amount, TESTS_DEFAULT_FEE, 0, sources, destinations, true, true, 1);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_3 = AUTO_VAL_INIT(tx_3);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_3, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_3, currency::get_tx_version(get_block_height(blk_2), m_hardforks), 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx");
|
||||
|
||||
events.push_back(event_visitor_settings(event_visitor_settings::set_txs_kept_by_block, true)); // tx_3 goes with the block blk_3
|
||||
|
|
@ -1753,7 +1756,7 @@ bool multisig_and_checkpoints::generate(std::vector<test_event_entry>& events) c
|
|||
de = tx_destination_entry(amount - TESTS_DEFAULT_FEE, bob_acc.get_public_address());
|
||||
|
||||
transaction tx_4 = AUTO_VAL_INIT(tx_4);
|
||||
r = construct_tx(alice_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_4, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(alice_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_4, currency::get_tx_version(get_block_height(blk_3), m_hardforks), 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
r = sign_multisig_input_in_tx(tx_4, 0, alice_acc.get_keys(), tx_3, &tx_fully_signed);
|
||||
CHECK_AND_ASSERT_MES(r & tx_fully_signed, false, "sign_multisig_input_in_tx failed, tx_fully_signed: " << tx_fully_signed);
|
||||
|
|
@ -1766,7 +1769,7 @@ bool multisig_and_checkpoints::generate(std::vector<test_event_entry>& events) c
|
|||
r = fill_tx_sources_and_destinations(events, blk_4, miner_acc.get_keys(), to_addrs, amount, TESTS_DEFAULT_FEE, 0, sources, destinations, true, true, 1);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_5 = AUTO_VAL_INIT(tx_5);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_5, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_5, currency::get_tx_version(get_block_height(blk_4), m_hardforks), 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx");
|
||||
events.push_back(tx_5);
|
||||
|
||||
|
|
@ -1784,7 +1787,7 @@ bool multisig_and_checkpoints::generate(std::vector<test_event_entry>& events) c
|
|||
de = tx_destination_entry(amount - TESTS_DEFAULT_FEE, bob_acc.get_public_address());
|
||||
|
||||
transaction tx_6 = AUTO_VAL_INIT(tx_6);
|
||||
r = construct_tx(alice_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_6, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(alice_acc.get_keys(), std::vector<tx_source_entry>({ se }), std::vector<tx_destination_entry>({ de }), empty_attachment, tx_6, currency::get_tx_version(get_block_height(blk_5), m_hardforks), 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx failed");
|
||||
r = sign_multisig_input_in_tx(tx_6, 0, alice_acc.get_keys(), tx_5, &tx_fully_signed);
|
||||
CHECK_AND_ASSERT_MES(r & tx_fully_signed, false, "sign_multisig_input_in_tx failed, tx_fully_signed: " << tx_fully_signed);
|
||||
|
|
@ -1840,7 +1843,7 @@ bool multisig_and_checkpoints_bad_txs::generate(std::vector<test_event_entry>& e
|
|||
r = fill_tx_sources_and_destinations(events, blk_0r, miner_acc.get_keys(), to_addrs, amount, TESTS_DEFAULT_FEE, 0, sources, destinations, true, true, 1);
|
||||
CHECK_AND_ASSERT_MES(r, false, "fill_tx_sources_and_destinations failed");
|
||||
transaction tx_1 = AUTO_VAL_INIT(tx_1);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, 0, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
r = construct_tx(miner_acc.get_keys(), sources, destinations, empty_attachment, tx_1, TRANSACTION_VERSION_PRE_HF4, CURRENCY_TO_KEY_OUT_RELAXED, true);
|
||||
CHECK_AND_ASSERT_MES(r, false, "construct_tx");
|
||||
|
||||
events.push_back(event_visitor_settings(event_visitor_settings::set_txs_kept_by_block, true)); // tx_1 goes with the block blk_1
|
||||
|
|
|
|||
|
|
@ -849,6 +849,7 @@ bool pos_wallet_big_block_test::c1(currency::core& c, size_t ev_index, const std
|
|||
|
||||
pos_altblocks_validation::pos_altblocks_validation()
|
||||
{
|
||||
test_chain_unit_base::set_hardforks_for_old_tests();
|
||||
}
|
||||
|
||||
bool pos_altblocks_validation::configure_core(currency::core& c, size_t ev_index, const std::vector<test_event_entry>& events)
|
||||
|
|
|
|||
|
|
@ -636,7 +636,8 @@ bool zarcanum_in_alt_chain::generate(std::vector<test_event_entry>& events) cons
|
|||
// |
|
||||
// 0 10 11 21 22 23 | 24 34 35 36 <- blockchain height
|
||||
// (0 )..(0r)- (1 )..(1r)- !2 !- (3 )- (4 )..(4r)- (5 ) <- main chain
|
||||
// tx_0 tx_1 \ tx_2
|
||||
// tx_0 tx_1 \ tx_2a
|
||||
// \ tx_2b
|
||||
// -!5a!- (6a) <- alt chain
|
||||
|
||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_4r, blk_4, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
|
@ -648,27 +649,50 @@ bool zarcanum_in_alt_chain::generate(std::vector<test_event_entry>& events) cons
|
|||
MAKE_NEXT_BLOCK_TX_LIST(events, blk_5, blk_4r, miner_acc, std::list<transaction>({ tx_2a, tx_2b }));
|
||||
|
||||
// now in the main chain Bob has zero coins
|
||||
// check it
|
||||
// check it in gen time ...
|
||||
CREATE_TEST_WALLET(bob_wlt, bob_acc, blk_0);
|
||||
REFRESH_TEST_WALLET_AT_GEN_TIME(events, bob_wlt, blk_5, 3 * CURRENCY_MINED_MONEY_UNLOCK_WINDOW + 5);
|
||||
CHECK_TEST_WALLET_BALANCE_AT_GEN_TIME(bob_wlt, 0);
|
||||
// ... and in play time
|
||||
DO_CALLBACK_PARAMS(events, "check_balance", params_check_balance(BOB_ACC_IDX, 0));
|
||||
|
||||
// TODO: check PoS mining against already spent key image
|
||||
|
||||
// HF4
|
||||
// |
|
||||
// 0 .. 10 11 21 22 23 | 24 .. 34 35 36 .. 45 46 47 <- blockchain height
|
||||
// (0 )..(0r)- (1 )..(1r)- !2 !- (3 )- (4 )..(4r)- (5 )- <- alt chain
|
||||
// tx_0 tx_1 \ tx_2a
|
||||
// \ tx_2b
|
||||
// \ c1
|
||||
// -!5a!- (6a)- . . . (6ar)|(c1) <- main chain
|
||||
|
||||
std::list<currency::account_base> bob_stake_sources({ bob_acc });
|
||||
MAKE_NEXT_POS_BLOCK(events, blk_5a, blk_4r, bob_acc, bob_stake_sources); // NOTE: tx_2a and blk_5a spend the same Bob's output
|
||||
MAKE_NEXT_BLOCK(events, blk_6a, blk_5a, miner_acc);
|
||||
|
||||
DO_CALLBACK_PARAMS(events, "check_top_block", params_top_block(get_block_height(blk_6a), get_block_hash(blk_6a)));
|
||||
DO_CALLBACK_PARAMS(events, "check_top_block", params_top_block(blk_6a));
|
||||
|
||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_6ar, blk_6a, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
DO_CALLBACK(events, "c1");
|
||||
|
||||
// HF4
|
||||
// |
|
||||
// 0 .. 10 11 21 22 23 | 24 .. 34 35 36 .. 45 46 47 <- blockchain height
|
||||
// (0 )..(0r)- (1 )..(1r)- !2 !- (3 )- (4 )..(4r)- (5 )- . . . (5r)- !6 !- (7 ) <- main chain
|
||||
// tx_0 tx_1 \ tx_2a
|
||||
// \ tx_2b
|
||||
// \ c1
|
||||
// -!5a!- (6a)- . . . (6ar)|(c1) <- alt chain
|
||||
|
||||
REWIND_BLOCKS_N_WITH_TIME(events, blk_5r, blk_5, miner_acc, CURRENCY_MINED_MONEY_UNLOCK_WINDOW);
|
||||
|
||||
MAKE_NEXT_POS_BLOCK(events, blk_6, blk_5r, alice_acc, alice_stake_sources);
|
||||
MAKE_NEXT_BLOCK(events, blk_7, blk_6, miner_acc);
|
||||
MAKE_NEXT_BLOCK(events, blk_8, blk_7, miner_acc);
|
||||
|
||||
DO_CALLBACK_PARAMS(events, "check_top_block", params_top_block(blk_8));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue