38#include <boost/program_options.hpp>
39#include <boost/optional.hpp>
40#include <boost/serialization/vector.hpp>
41#include <boost/serialization/variant.hpp>
42#include <boost/serialization/optional.hpp>
43#include <boost/serialization/unordered_map.hpp>
44#include <boost/functional/hash.hpp>
60#undef MONERO_DEFAULT_LOG_CATEGORY
61#define MONERO_DEFAULT_LOG_CATEGORY "tests.core"
75 template<class Archive>
100 template<class Archive>
130 template<
class Archive>
147 template<
class Archive>
163typedef std::unordered_map<crypto::hash, const cryptonote::transaction*>
map_hash2tx_t;
172 bool verify(
const std::string& cb_name,
cryptonote::core& c,
size_t ev_index,
const std::vector<test_event_entry> &events);
208 template<
class Archive>
243 std::vector<size_t>& block_weights,
const std::list<cryptonote::transaction>& tx_list,
244 const boost::optional<uint8_t>& hf_ver = boost::none);
247 const std::list<cryptonote::transaction>& tx_list = std::list<cryptonote::transaction>(),
248 const boost::optional<uint8_t>& hf_ver = boost::none);
254 const std::vector<crypto::hash>& tx_hashes = std::vector<crypto::hash>(),
size_t txs_sizes = 0,
size_t max_outs = 999,
269 template<
class Archive>
279 std::ostringstream ss;
283 for(
int i = 0; i < 32; i++)
285 snprintf(buff, 10,
"0x%02x", ((
uint8_t)buff32[i] & 0xff));
334 std::stringstream ss;
336 ss <<
"output_index{blk_height=" <<
blk_height
337 <<
" tx_no=" <<
tx_no
342 <<
" spent=" <<
spent
363typedef std::unordered_map<crypto::hash, cryptonote::block>
map_block_t;
365typedef std::unordered_map<crypto::public_key, cryptonote::subaddress_index>
subaddresses_t;
368typedef boost::variant<cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry>
var_addr_t;
394 void dump_data(
const std::string & fname);
399 template<
class Archive>
420std::vector<cryptonote::tx_destination_entry>
build_dsts(std::initializer_list<dest_wrapper_t> inps);
421uint64_t sum_amount(
const std::vector<cryptonote::tx_destination_entry>& destinations);
438 std::vector<cryptonote::tx_source_entry> &sources,
442 std::vector<cryptonote::tx_source_entry> &sources,
450 std::vector<cryptonote::tx_source_entry>& sources,
451 const std::vector<cryptonote::tx_destination_entry>& destinations,
452 const boost::optional<cryptonote::account_public_address>& change_addr,
468 const std::vector<cryptonote::tx_source_entry> &sources,
469 std::vector<cryptonote::tx_destination_entry>& destinations,
bool always_change=
false);
473 const std::vector<cryptonote::tx_source_entry> &sources,
474 std::vector<cryptonote::tx_destination_entry>& destinations,
479 const std::vector<cryptonote::tx_source_entry> &sources,
480 std::vector<cryptonote::tx_destination_entry>& destinations,
481 std::vector<cryptonote::tx_destination_entry>& destinations_pure,
482 bool always_change=
false);
488 std::vector<cryptonote::tx_source_entry>& sources,
489 std::vector<cryptonote::tx_destination_entry>& destinations);
494 std::vector<cryptonote::tx_source_entry>& sources,
495 std::vector<cryptonote::tx_destination_entry>& destinations);
505template<
class t_test_
class>
570 size_t pool_size =
m_c.get_pool_transactions_count();
571 m_c.handle_incoming_tx(t_serializable_object_to_blob(
tx), tvc,
m_tx_relay,
false);
572 bool tx_added = pool_size + 1 ==
m_c.get_pool_transactions_count();
574 CHECK_AND_NO_ASSERT_MES(r,
false,
"tx verification context check failed");
578 bool operator()(
const std::vector<cryptonote::transaction>& txs)
const
582 std::vector<cryptonote::blobdata> tx_blobs;
583 std::vector<cryptonote::tx_verification_context> tvcs;
585 for (
const auto &
tx: txs)
587 tx_blobs.emplace_back(t_serializable_object_to_blob(
tx));
588 tvcs.push_back(tvc0);
590 size_t pool_size =
m_c.get_pool_transactions_count();
591 for (
size_t i = 0; i < tx_blobs.size(); ++i)
592 m_c.handle_incoming_tx(tx_blobs[i], tvcs[i],
m_tx_relay,
false);
593 size_t tx_added =
m_c.get_pool_transactions_count() - pool_size;
595 CHECK_AND_NO_ASSERT_MES(r,
false,
"tx verification context check failed");
605 std::vector<cryptonote::block> pblocks;
610 if (
m_c.prepare_handle_incoming_blocks(std::vector<cryptonote::block_complete_entry>(1, bce), pblocks))
612 m_c.handle_incoming_block(bd, &
b, bvc);
613 m_c.cleanup_handle_incoming_blocks();
618 CHECK_AND_NO_ASSERT_MES(r,
false,
"block verification context check failed");
639 std::vector<cryptonote::block> pblocks;
644 if (
m_c.prepare_handle_incoming_blocks(std::vector<cryptonote::block_complete_entry>(1, bce), pblocks))
646 m_c.handle_incoming_block(sr_block.
data, NULL, bvc);
647 m_c.cleanup_handle_incoming_blocks();
660 CHECK_AND_NO_ASSERT_MES(r,
false,
"block verification context check failed");
669 size_t pool_size =
m_c.get_pool_transactions_count();
671 bool tx_added = pool_size + 1 ==
m_c.get_pool_transactions_count();
682 CHECK_AND_NO_ASSERT_MES(r,
false,
"transaction verification context check failed");
689 MGINFO_YELLOW(
"=== EVENT # " <<
m_ev_index <<
": " << event_type);
693template<
class t_test_
class>
699template<
class t_test_
class>
707 "First event must be genesis block creation");
713 for(
size_t i = 1; i < events.size() && r; ++i)
716 r = boost::apply_visitor(visitor, events[i]);
721 CATCH_ENTRY_L0(
"replay_events_through_core",
false);
724template<
typename t_test_
class>
733template<
class t_test_
class>
736 boost::program_options::options_description desc(
"Allowed options");
738 boost::program_options::variables_map
vm;
741 boost::program_options::store(boost::program_options::basic_parsed_options<char>(&desc),
vm);
742 boost::program_options::notify(
vm);
760 test_options_tmp.
hard_forks = hardforks.data();
761 test_options_ = &test_options_tmp;
764 if (!c.init(
vm, test_options_))
766 MERROR(
"Failed to init core");
769 c.get_blockchain_storage().get_db().set_batch_transactions(
true);
772 std::vector<crypto::hash> pool_txs;
773 if (!c.get_pool_transaction_hashes(pool_txs))
775 MERROR(
"Failed to flush txpool");
778 c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
780 t_test_class validator;
787template<
class t_test_
class>
790 std::vector<crypto::hash> pool_txs;
791 if (!c.get_pool_transaction_hashes(pool_txs))
793 MERROR(
"Failed to flush txpool");
796 c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
798 t_test_class validator;
802template<
class t_test_
class>
811template<
class t_test_
class>
814 std::vector<test_event_entry> events;
817 MERROR(
"Failed to deserialize data from file: ");
824#define DEFAULT_HARDFORKS(HARDFORKS) do { \
825 HARDFORKS.push_back(std::make_pair((uint8_t)1, (uint64_t)0)); \
828#define ADD_HARDFORK(HARDFORKS, FORK, HEIGHT) HARDFORKS.push_back(std::make_pair((uint8_t)FORK, (uint64_t)HEIGHT))
830#define GENERATE_ACCOUNT(account) \
831 cryptonote::account_base account; \
834#define GENERATE_MULTISIG_ACCOUNT(account, threshold, total) \
835 CHECK_AND_ASSERT_MES(threshold >= 2 && threshold <= total, false, "Invalid multisig scheme"); \
836 std::vector<cryptonote::account_base> account(total); \
839 for (size_t msidx = 0; msidx < total; ++msidx) \
840 account[msidx].generate(); \
841 CHECK_AND_ASSERT_MES(make_multisig_accounts(account, threshold), false, "Failed to make multisig accounts."); \
844#define MAKE_ACCOUNT(VEC_EVENTS, account) \
845 cryptonote::account_base account; \
846 account.generate(); \
847 VEC_EVENTS.push_back(account);
849#define DO_CALLBACK(VEC_EVENTS, CB_NAME) \
851 callback_entry CALLBACK_ENTRY; \
852 CALLBACK_ENTRY.callback_name = CB_NAME; \
853 VEC_EVENTS.push_back(CALLBACK_ENTRY); \
856#define REGISTER_CALLBACK(CB_NAME, CLBACK) \
857 register_callback(CB_NAME, std::bind(&CLBACK, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
859#define REGISTER_CALLBACK_METHOD(CLASS, METHOD) \
860 register_callback(#METHOD, std::bind(&CLASS::METHOD, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
862#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS) \
863 test_generator generator; \
864 cryptonote::block BLK_NAME; \
865 generator.construct_block(BLK_NAME, MINER_ACC, TS); \
866 VEC_EVENTS.push_back(BLK_NAME);
868#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC) \
869 cryptonote::block BLK_NAME; \
870 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC); \
871 VEC_EVENTS.push_back(BLK_NAME);
873#define MAKE_NEXT_BLOCK_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF) \
874 cryptonote::block BLK_NAME; \
875 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, std::list<cryptonote::transaction>(), HF); \
876 VEC_EVENTS.push_back(BLK_NAME);
878#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1) \
879 cryptonote::block BLK_NAME; \
881 std::list<cryptonote::transaction> tx_list; \
882 tx_list.push_back(TX1); \
883 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list); \
885 VEC_EVENTS.push_back(BLK_NAME);
887#define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF) \
888 cryptonote::block BLK_NAME; \
890 std::list<cryptonote::transaction> tx_list; \
891 tx_list.push_back(TX1); \
892 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list, HF); \
894 VEC_EVENTS.push_back(BLK_NAME);
896#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST) \
897 cryptonote::block BLK_NAME; \
898 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST); \
899 VEC_EVENTS.push_back(BLK_NAME);
901#define MAKE_NEXT_BLOCK_TX_LIST_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF) \
902 cryptonote::block BLK_NAME; \
903 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF); \
904 VEC_EVENTS.push_back(BLK_NAME);
906#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF) \
907 cryptonote::block BLK_NAME; \
909 cryptonote::block blk_last = PREV_BLOCK; \
910 for (size_t i = 0; i < COUNT; ++i) \
912 MAKE_NEXT_BLOCK_HF(VEC_EVENTS, blk, blk_last, MINER_ACC, HF); \
915 BLK_NAME = blk_last; \
918#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT) REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, boost::none)
919#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC) REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW)
920#define REWIND_BLOCKS_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF) REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW, HF)
922#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
923 cryptonote::transaction TX_NAME; \
924 construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
925 VEC_EVENTS.push_back(TX_NAME);
927#define MAKE_TX_MIX_RCT(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
928 cryptonote::transaction TX_NAME; \
929 construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, rct::RangeProofPaddedBulletproof); \
930 VEC_EVENTS.push_back(TX_NAME);
932#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD) MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, 0, HEAD)
934#define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
936 cryptonote::transaction t; \
937 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
938 SET_NAME.push_back(t); \
939 VEC_EVENTS.push_back(t); \
942#define MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
943 MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
944#define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER) \
946 cryptonote::transaction t; \
947 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
948 SET_NAME.push_back(t); \
949 VEC_EVENTS.push_back(t); \
952#define MAKE_TX_MIX_DEST_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD) \
953 MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
954#define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER) \
956 cryptonote::transaction t; \
957 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
958 SET_NAME.push_back(t); \
959 VEC_EVENTS.push_back(t); \
962#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD) MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, 0, HEAD)
964#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD) \
965 std::list<cryptonote::transaction> SET_NAME; \
966 MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD);
968#define MAKE_TX_LIST_START_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
969 std::list<cryptonote::transaction> SET_NAME; \
970 MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD);
972#define MAKE_MINER_TX_AND_KEY_AT_HF_MANUALLY(TX, BLK, HF_VERSION, KEY) \
974 if (!construct_miner_tx_manually(get_block_height(BLK) + 1, generator.get_already_generated_coins(BLK), \
975 miner_account.get_keys().m_account_address, TX, 0, HF_VERSION, KEY)) \
978#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY) MAKE_MINER_TX_AND_KEY_AT_HF_MANUALLY(TX, BLK, 1, KEY)
980#define MAKE_MINER_TX_MANUALLY(TX, BLK) MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, 0)
982#define SET_EVENT_VISITOR_SETT(VEC_EVENTS, SETT) VEC_EVENTS.push_back(event_visitor_settings(SETT));
984#define GENERATE(filename, genclass) \
986 std::vector<test_event_entry> events; \
988 g.generate(events); \
989 if (!tools::serialize_obj_to_file(events, filename)) \
991 MERROR("Failed to serialize data to file: " << filename); \
992 throw std::runtime_error("Failed to serialize data to file"); \
997#define PLAY(filename, genclass) \
998 if(!do_replay_file<genclass>(filename)) \
1000 MERROR("Failed to pass test : " << #genclass); \
1004#define CATCH_REPLAY(genclass) \
1005 catch (const std::exception& ex) \
1007 MERROR(#genclass << " generation failed: what=" << ex.what()); \
1011 MERROR(#genclass << " generation failed: generic exception"); \
1014#define REPLAY_CORE(genclass) \
1015 if (generated && do_replay_events< genclass >(events)) \
1017 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
1021 MERROR("#TEST# Failed " << #genclass); \
1022 failed_tests.push_back(#genclass); \
1025#define REPLAY_WITH_CORE(genclass, CORE) \
1026 if (generated && replay_events_through_core_validate< genclass >(events, CORE)) \
1028 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
1032 MERROR("#TEST# Failed " << #genclass); \
1033 failed_tests.push_back(#genclass); \
1036#define CATCH_GENERATE_REPLAY(genclass) \
1037 CATCH_REPLAY(genclass); \
1038 REPLAY_CORE(genclass);
1040#define CATCH_GENERATE_REPLAY_CORE(genclass, CORE) \
1041 CATCH_REPLAY(genclass); \
1042 REPLAY_WITH_CORE(genclass, CORE);
1044#define GENERATE_AND_PLAY(genclass) \
1046 std::cout << #genclass << std::endl; \
1047 else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1049 std::vector<test_event_entry> events; \
1051 bool generated = false; \
1055 generated = g.generate(events); \
1057 CATCH_GENERATE_REPLAY(genclass); \
1060#define GENERATE_AND_PLAY_INSTANCE(genclass, ins, CORE) \
1061 if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1063 std::vector<test_event_entry> events; \
1065 bool generated = false; \
1068 generated = ins.generate(events); \
1070 CATCH_GENERATE_REPLAY_CORE(genclass, CORE); \
1073#define CALL_TEST(test_name, function) \
1077 MERROR("#TEST# Failed " << test_name); \
1082 MGINFO_GREEN("#TEST# Succeeded " << test_name); \
1086#define QUOTEME(x) #x
1087#define DEFINE_TESTS_ERROR_CONTEXT(text) const char* perr_context = text; (void) perr_context;
1088#define CHECK_TEST_CONDITION(cond) CHECK_AND_ASSERT_MES(cond, false, "[" << perr_context << "] failed: \"" << QUOTEME(cond) << "\"")
1089#define CHECK_EQ(v1, v2) CHECK_AND_ASSERT_MES(v1 == v2, false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " == " << QUOTEME(v2) << "\", " << v1 << " != " << v2)
1090#define CHECK_NOT_EQ(v1, v2) CHECK_AND_ASSERT_MES(!(v1 == v2), false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " != " << QUOTEME(v2) << "\", " << v1 << " == " << v2)
1091#define MK_COINS(amount) (UINT64_C(amount) * COIN)
1092#define TESTS_DEFAULT_FEE ((uint64_t)20000000000)
cryptonote::block b
Definition block.cpp:40
static boost::multiprecision::uint128_t fees
Definition blockchain_stats.cpp:58
binary_archive< false > ba
Definition bulletproof.cpp:40
boost::variant< cryptonote::block, cryptonote::transaction, std::vector< cryptonote::transaction >, cryptonote::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_replay_settings > test_event_entry
Definition chaingen.h:162
cryptonote::block get_head_block(const std::vector< test_event_entry > &events)
Definition chaingen.cpp:1234
std::vector< cryptonote::tx_destination_entry > build_dsts(const var_addr_t &to1, bool sub1=false, uint64_t am1=0)
bool replay_events_through_core_validate(std::vector< test_event_entry > &events, cryptonote::core &c)
Definition chaingen.h:788
void fill_tx_destinations(const var_addr_t &from, const cryptonote::account_public_address &to, uint64_t amount, uint64_t fee, const std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations, bool always_change=false)
void fill_tx_sources_and_destinations(const std::vector< test_event_entry > &events, const cryptonote::block &blk_head, const cryptonote::account_base &from, const cryptonote::account_public_address &to, uint64_t amount, uint64_t fee, size_t nmix, std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations)
Definition chaingen.cpp:927
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition chaingen.h:163
uint64_t current_difficulty_window(const boost::optional< uint8_t > &hf_ver=boost::none)
Definition chaingen.h:416
serialized_object< cryptonote::block > serialized_block
Definition chaingen.h:107
std::map< uint64_t, std::vector< output_index > > map_output_idx_t
Definition chaingen.h:362
bool extract_hard_forks_from_blocks(const std::vector< test_event_entry > &events, v_hardforks_t &hard_forks)
Definition chaingen.cpp:1135
boost::hash< output_hasher > output_hasher_hasher
Definition chaingen.h:360
std::vector< std::pair< uint8_t, uint64_t > > v_hardforks_t
Definition chaingen.h:137
serialized_object< cryptonote::transaction > serialized_transaction
Definition chaingen.h:108
uint64_t sum_amount(const std::vector< cryptonote::tx_destination_entry > &destinations)
Definition chaingen.cpp:852
bool find_block_chain(const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
Definition chaingen.cpp:1248
std::unordered_map< crypto::public_key, cryptonote::subaddress_index > subaddresses_t
Definition chaingen.h:365
cryptonote::transaction construct_tx_with_fee(std::vector< test_event_entry > &events, const cryptonote::block &blk_head, const cryptonote::account_base &acc_from, const var_addr_t &to, uint64_t amount, uint64_t fee)
Definition chaingen.cpp:1082
uint64_t num_blocks(const std::vector< test_event_entry > &events)
Definition chaingen.cpp:1220
bool construct_tx_to_key(const std::vector< test_event_entry > &events, cryptonote::transaction &tx, const cryptonote::block &blk_head, const cryptonote::account_base &from, const var_addr_t &to, uint64_t amount, uint64_t fee, size_t nmix, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
bool do_replay_events_get_core(std::vector< test_event_entry > &events, cryptonote::core *core)
Definition chaingen.h:734
std::unordered_map< output_hasher, output_index, output_hasher_hasher > map_txid_output_t
Definition chaingen.h:364
bool do_replay_events(std::vector< test_event_entry > &events)
Definition chaingen.h:803
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition chaingen.cpp:817
bool construct_tx_rct(const cryptonote::account_keys &sender_account_keys, std::vector< cryptonote::tx_source_entry > &sources, const std::vector< cryptonote::tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, std::vector< uint8_t > extra, cryptonote::transaction &tx, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
cryptonote::tx_destination_entry build_dst(const var_addr_t &to, bool is_subaddr=false, uint64_t amount=0)
boost::variant< cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entry > var_addr_t
Definition chaingen.h:368
std::pair< uint64_t, size_t > outloc_t
Definition chaingen.h:366
bool do_replay_file(const std::string &filename)
Definition chaingen.h:812
std::string dump_keys(T *buff32)
Definition chaingen.h:277
cryptonote::difficulty_type get_test_difficulty(const boost::optional< uint8_t > &hf_ver=boost::none)
Definition chaingen.h:415
bool trim_block_chain(std::vector< cryptonote::block > &blockchain, const crypto::hash &tail)
Definition chaingen.cpp:1180
std::tuple< uint64_t, crypto::public_key, rct::key > get_outs_entry
Definition chaingen.h:358
bool extract_hard_forks(const std::vector< test_event_entry > &events, v_hardforks_t &hard_forks)
Definition chaingen.cpp:1117
std::pair< crypto::hash, size_t > output_hasher
Definition chaingen.h:359
std::string dump_data(const cryptonote::transaction &tx)
Definition chaingen.cpp:769
uint64_t get_balance(const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
Definition chaingen.cpp:1091
bool replay_events_through_core_plain(cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator, bool reinit=true)
Definition chaingen.h:700
std::map< uint64_t, std::vector< size_t > > map_output_t
Definition chaingen.h:361
bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins, const cryptonote::account_public_address &miner_address, cryptonote::transaction &tx, uint64_t fee, uint8_t hf_version=1, cryptonote::keypair *p_txkey=nullptr)
Definition chaingen.cpp:975
void get_confirmed_txs(const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, map_hash2tx_t &confirmed_txs)
Definition chaingen.cpp:1160
std::unordered_map< crypto::hash, cryptonote::block > map_block_t
Definition chaingen.h:363
bool replay_events_through_core(cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator)
Definition chaingen.h:694
void serialize(Archive &ar, const unsigned int)
Definition chaingen.h:400
block_tracker(const block_tracker &bt)
Definition chaingen.h:384
void process(const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
Definition chaingen.cpp:623
void global_indices(const cryptonote::transaction *tx, std::vector< uint64_t > &indices)
Definition chaingen.cpp:686
void get_fake_outs(size_t num_outs, uint64_t amount, uint64_t global_index, uint64_t cur_height, std::vector< get_outs_entry > &outs)
Definition chaingen.cpp:698
map_output_idx_t m_outs
Definition chaingen.h:379
map_block_t m_blocks
Definition chaingen.h:381
std::string dump_data()
Definition chaingen.cpp:736
map_txid_output_t m_map_outs
Definition chaingen.h:380
friend class boost::serialization::access
Definition chaingen.h:397
map_txid_output_t::iterator find_out(const crypto::hash &txid, size_t out)
Definition chaingen.cpp:613
handles core cryptonote functionality
Definition cryptonote_core.h:87
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
Definition cryptonote_core.cpp:312
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition cryptonote_core.cpp:727
bool deinit()
performs safe shutdown steps for core and core components
Definition cryptonote_core.cpp:738
Definition cryptonote_basic.h:205
Definition chaingen.h:166
std::map< std::string, verify_callback > callbacks_map
Definition chaingen.h:169
bool check_tx_verification_context(const cryptonote::tx_verification_context &tvc, bool, size_t, const cryptonote::transaction &)
Definition chaingen.cpp:1334
boost::function< bool(cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)> verify_callback
Definition chaingen.h:168
void register_callback(const std::string &cb_name, verify_callback cb)
Definition chaingen.cpp:1314
bool check_block_verification_context(const cryptonote::block_verification_context &bvc, size_t event_idx, const cryptonote::block &)
Definition chaingen.cpp:1329
callbacks_map m_callbacks
Definition chaingen.h:178
bool check_tx_verification_context_array(const std::vector< cryptonote::tx_verification_context > &tvcs, size_t, size_t, const std::vector< cryptonote::transaction > &)
Definition chaingen.cpp:1339
bool verify(const std::string &cb_name, cryptonote::core &c, size_t ev_index, const std::vector< test_event_entry > &events)
Definition chaingen.cpp:1318
block_fields
Definition chaingen.h:218
@ bf_miner_tx
Definition chaingen.h:224
@ bf_timestamp
Definition chaingen.h:222
@ bf_tx_fees
Definition chaingen.h:229
@ bf_prev_id
Definition chaingen.h:223
@ bf_hf_version
Definition chaingen.h:228
@ bf_max_outs
Definition chaingen.h:227
@ bf_minor_ver
Definition chaingen.h:221
@ bf_tx_hashes
Definition chaingen.h:225
@ bf_major_ver
Definition chaingen.h:220
@ bf_diffic
Definition chaingen.h:226
@ bf_none
Definition chaingen.h:219
uint64_t get_already_generated_coins(const crypto::hash &blk_id) const
Definition chaingen.cpp:213
std::unordered_map< crypto::hash, block_info > m_blocks_info
Definition chaingen.h:263
const std::vector< test_event_entry > * m_events
Definition chaingen.h:264
bool construct_block_manually(cryptonote::block &blk, const cryptonote::block &prev_block, const cryptonote::account_base &miner_acc, int actual_params=bf_none, uint8_t major_ver=0, uint8_t minor_ver=0, uint64_t timestamp=0, const crypto::hash &prev_id=crypto::hash(), const cryptonote::difficulty_type &diffic=1, const cryptonote::transaction &miner_tx=cryptonote::transaction(), const std::vector< crypto::hash > &tx_hashes=std::vector< crypto::hash >(), size_t txs_sizes=0, size_t max_outs=999, uint8_t hf_version=1, uint64_t fees=0)
Definition chaingen.cpp:341
void get_last_n_block_weights(std::vector< size_t > &block_weights, const crypto::hash &head, size_t n) const
Definition chaingen.cpp:203
void fill_nonce(cryptonote::block &blk, const cryptonote::difficulty_type &diffic, uint64_t height)
Definition chaingen.cpp:393
test_generator(const test_generator &other)
Definition chaingen.h:233
void get_block_chain(std::vector< block_info > &blockchain, const crypto::hash &head, size_t n) const
Definition chaingen.cpp:185
bool construct_block(cryptonote::block &blk, uint64_t height, const crypto::hash &prev_id, const cryptonote::account_base &miner_acc, uint64_t timestamp, uint64_t already_generated_coins, std::vector< size_t > &block_weights, const std::list< cryptonote::transaction > &tx_list, const boost::optional< uint8_t > &hf_ver=boost::none)
Definition chaingen.cpp:235
void add_block(const cryptonote::block &blk, size_t tsx_size, std::vector< size_t > &block_weights, uint64_t already_generated_coins, uint64_t block_reward, uint8_t hf_version=1)
Definition chaingen.cpp:229
void set_events(const std::vector< test_event_entry > *events)
Definition chaingen.h:259
test_generator()
Definition chaingen.h:232
bool construct_block_manually_tx(cryptonote::block &blk, const cryptonote::block &prev_block, const cryptonote::account_base &miner_acc, const std::vector< crypto::hash > &tx_hashes, size_t txs_size)
Definition chaingen.cpp:386
friend class boost::serialization::access
Definition chaingen.h:267
cryptonote::network_type m_nettype
Definition chaingen.h:265
void serialize(Archive &ar, const unsigned int)
Definition chaingen.h:270
void set_network_type(const cryptonote::network_type nettype)
Definition chaingen.h:260
binary_archive< false > ar
Definition cold-outputs.cpp:54
#define DIFFICULTY_TARGET_V1
Definition cryptonote_config.h:81
#define DIFFICULTY_TARGET_V2
Definition cryptonote_config.h:80
#define BEGIN_SERIALIZE_OBJECT()
#define VARIANT_TAG(Archive, Type, Tag)
const char * inp
Definition hmac_keccak.cpp:41
#define const
Definition ipfrdr.c:80
#define AUTO_VAL_INIT(v)
Definition misc_language.h:36
Definition block_weight.py:1
Definition blockchain.py:1
Definition portable_binary_archive.hpp:29
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
Definition command_line.h:235
POD_CLASS hash
Definition hash.h:49
Holds cryptonote related classes and helpers.
Definition blockchain_db.cpp:45
boost::multiprecision::uint128_t difficulty_type
Definition difficulty.h:41
network_type
Definition cryptonote_config.h:302
boost::variant< txout_to_script, txout_to_scripthash, txout_to_key, txout_to_tagged_key > txout_target_v
Definition cryptonote_basic.h:154
relay_method
Methods tracking how a tx was received and relayed.
Definition enums.h:37
@ block
Received in block, takes precedence over others.
Definition enums.h:43
@ none
Received via RPC with do_not_relay set.
Definition enums.h:38
@ fluff
Received/sent over network using Dandelion++ fluff.
Definition enums.h:42
@ stem
Received/send over network using Dandelion++ stem.
Definition enums.h:41
@ local
Received via RPC; trying to send over i2p/tor, etc.
Definition enums.h:39
std::string blobdata
Definition blobdatatype.h:39
span< const T > strspan(const U &s) noexcept
make a span from a std::string
Definition span.h:183
Definition bulletproofs.cc:64
key commit(xmr_amount amount, const key &mask)
Definition rctOps.cpp:336
RangeProofType
Definition rctTypes.h:307
@ RangeProofBorromean
Definition rctTypes.h:307
key identity()
Definition rctOps.h:73
Definition binary_utils.h:36
bool serialize(Archive &ar, T &v)
Definition serialization.h:294
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Definition binary_archive.h:89
void serialize(Archive &ar, const unsigned int)
Definition chaingen.h:76
std::string callback_name
Definition chaingen.h:67
friend class boost::serialization::access
Definition chaingen.h:73
Definition cryptonote_basic.h:512
Definition cryptonote_protocol_defs.h:133
std::vector< tx_blob_entry > txs
Definition cryptonote_protocol_defs.h:137
bool pruned
Definition cryptonote_protocol_defs.h:134
blobdata block
Definition cryptonote_protocol_defs.h:135
Definition verification_context.h:66
bool m_verifivation_failed
Definition verification_context.h:68
Definition cryptonote_basic.h:475
Definition cryptonote_basic.h:539
Definition cryptonote_core.h:61
const std::pair< uint8_t, uint64_t > * hard_forks
Definition cryptonote_core.h:62
Definition cryptonote_tx_utils.h:75
Definition verification_context.h:41
Definition chaingen.h:369
const var_addr_t addr
Definition chaingen.h:370
uint64_t amount
Definition chaingen.h:372
bool is_subaddr
Definition chaingen.h:371
Definition chaingen.h:139
void serialize(Archive &ar, const unsigned int)
Definition chaingen.h:148
boost::optional< v_hardforks_t > hard_forks
Definition chaingen.h:140
friend class boost::serialization::access
Definition chaingen.h:145
event_replay_settings()=default
Definition chaingen.h:111
settings
Definition chaingen.h:115
@ set_txs_keeped_by_block
Definition chaingen.h:116
@ set_txs_stem
Definition chaingen.h:119
@ set_txs_do_not_relay
Definition chaingen.h:117
@ set_local_relay
Definition chaingen.h:118
void serialize(Archive &ar, const unsigned int)
Definition chaingen.h:131
friend class boost::serialization::access
Definition chaingen.h:128
int mask
Definition chaingen.h:112
event_visitor_settings(int a_mask=0)
Definition chaingen.h:122
Definition chaingen.h:725
const std::pair< uint8_t, uint64_t > hard_forks[2]
Definition chaingen.h:726
get_test_options()
Definition chaingen.h:730
const cryptonote::test_options test_options
Definition chaingen.h:727
uint64_t amount
Definition chaingen.h:296
const cryptonote::transaction * p_tx
Definition chaingen.h:307
const std::string toString() const
Definition chaingen.h:333
size_t blk_height
Definition chaingen.h:297
size_t out_no
Definition chaingen.h:299
bool is_coin_base
Definition chaingen.h:302
const cryptonote::block * p_blk
Definition chaingen.h:306
bool spent
Definition chaingen.h:303
size_t tx_no
Definition chaingen.h:298
output_index(const cryptonote::txout_target_v &_out, uint64_t _a, size_t _h, size_t tno, size_t ono, const cryptonote::block *_pb, const cryptonote::transaction *_pt)
Definition chaingen.h:309
rct::key commitment() const
Definition chaingen.h:329
const cryptonote::txout_target_v out
Definition chaingen.h:295
output_index & operator=(const output_index &other)
Definition chaingen.h:351
output_index(const output_index &other)
Definition chaingen.h:316
size_t idx
Definition chaingen.h:300
uint64_t unlock_time
Definition chaingen.h:301
rct::key comm
Definition chaingen.h:305
void set_rct(bool arct)
Definition chaingen.h:321
Definition chaingen.h:507
bool operator()(const callback_entry &cb) const
Definition chaingen.h:622
t_test_class & m_validator
Definition chaingen.h:511
push_core_event_visitor(cryptonote::core &c, const std::vector< test_event_entry > &events, t_test_class &validator)
Definition chaingen.h:517
bool operator()(const cryptonote::block &b) const
Definition chaingen.h:599
bool operator()(const cryptonote::transaction &tx) const
Definition chaingen.h:565
bool operator()(const serialized_block &sr_block) const
Definition chaingen.h:634
bool operator()(const cryptonote::account_base &ab) const
Definition chaingen.h:628
void log_event(const std::string &event_type) const
Definition chaingen.h:687
bool operator()(const event_replay_settings &settings)
Definition chaingen.h:531
cryptonote::relay_method m_tx_relay
Definition chaingen.h:514
void event_index(size_t ev_index)
Definition chaingen.h:526
bool operator()(const std::vector< cryptonote::transaction > &txs) const
Definition chaingen.h:578
const std::vector< test_event_entry > & m_events
Definition chaingen.h:510
size_t m_ev_index
Definition chaingen.h:512
cryptonote::core & m_c
Definition chaingen.h:509
bool operator()(const serialized_transaction &sr_tx) const
Definition chaingen.h:664
bool operator()(const event_visitor_settings &settings)
Definition chaingen.h:537
serialized_object()
Definition chaingen.h:85
void serialize(Archive &ar, const unsigned int)
Definition chaingen.h:101
serialized_object(const cryptonote::blobdata &a_data)
Definition chaingen.h:87
friend class boost::serialization::access
Definition chaingen.h:98
cryptonote::blobdata data
Definition chaingen.h:92
uint64_t already_generated_coins
Definition chaingen.h:202
void serialize(Archive &ar, const unsigned int)
Definition chaingen.h:209
crypto::hash prev_id
Definition chaingen.h:201
block_info()
Definition chaingen.h:187
block_info(crypto::hash a_prev_id, uint64_t an_already_generated_coins, size_t a_block_weight)
Definition chaingen.h:194
friend class boost::serialization::access
Definition chaingen.h:206
randomx_vm * vm
Definition tests.cpp:20
cryptonote::transaction tx
Definition transaction.cpp:40