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>
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::tx_blob_entry> tx_blobs;
583 std::vector<cryptonote::tx_verification_context> tvcs;
585 for (
const auto &
tx: txs)
587 tx_blobs.push_back({t_serializable_object_to_blob(
tx)});
588 tvcs.push_back(tvc0);
594 CHECK_AND_NO_ASSERT_MES(r,
false,
"tx verification context check failed");
604 std::vector<cryptonote::block> pblocks;
617 CHECK_AND_NO_ASSERT_MES(r,
false,
"block verification context check failed");
638 std::vector<cryptonote::block> pblocks;
659 CHECK_AND_NO_ASSERT_MES(r,
false,
"block verification context check failed");
681 CHECK_AND_NO_ASSERT_MES(r,
false,
"transaction verification context check failed");
688 MGINFO_YELLOW(
"=== EVENT # " <<
m_ev_index <<
": " << event_type);
692template<
class t_test_
class>
698template<
class t_test_
class>
706 "First event must be genesis block creation");
712 for(
size_t i = 1; i < events.size() && r; ++i)
715 r = boost::apply_visitor(visitor, events[i]);
720 CATCH_ENTRY_L0(
"replay_events_through_core",
false);
723template<
typename t_test_
class>
732template<
class t_test_
class>
735 boost::program_options::options_description desc(
"Allowed options");
737 boost::program_options::variables_map
vm;
740 boost::program_options::store(boost::program_options::basic_parsed_options<char>(&desc),
vm);
741 boost::program_options::notify(
vm);
759 test_options_tmp.
hard_forks = hardforks.data();
760 test_options_ = &test_options_tmp;
763 if (!c.init(
vm, test_options_))
765 MERROR(
"Failed to init core");
768 c.get_blockchain_storage().get_db().set_batch_transactions(
true);
771 std::vector<crypto::hash> pool_txs;
772 if (!c.get_pool_transaction_hashes(pool_txs))
774 MERROR(
"Failed to flush txpool");
777 c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
779 t_test_class validator;
780 bool ret = replay_events_through_core<t_test_class>(c, events, validator);
786template<
class t_test_
class>
789 std::vector<crypto::hash> pool_txs;
790 if (!c.get_pool_transaction_hashes(pool_txs))
792 MERROR(
"Failed to flush txpool");
795 c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
797 t_test_class validator;
798 return replay_events_through_core_plain<t_test_class>(c, events, validator,
false);
801template<
class t_test_
class>
805 bool ret = do_replay_events_get_core<t_test_class>(events, &core);
810template<
class t_test_
class>
813 std::vector<test_event_entry> events;
816 MERROR(
"Failed to deserialize data from file: ");
819 return do_replay_events<t_test_class>(events);
823#define DEFAULT_HARDFORKS(HARDFORKS) do { \
824 HARDFORKS.push_back(std::make_pair((uint8_t)1, (uint64_t)0)); \
827#define ADD_HARDFORK(HARDFORKS, FORK, HEIGHT) HARDFORKS.push_back(std::make_pair((uint8_t)FORK, (uint64_t)HEIGHT))
829#define GENERATE_ACCOUNT(account) \
830 cryptonote::account_base account; \
833#define GENERATE_MULTISIG_ACCOUNT(account, threshold, total) \
834 CHECK_AND_ASSERT_MES(threshold >= 2 && threshold <= total, false, "Invalid multisig scheme"); \
835 std::vector<cryptonote::account_base> account(total); \
838 for (size_t msidx = 0; msidx < total; ++msidx) \
839 account[msidx].generate(); \
840 CHECK_AND_ASSERT_MES(make_multisig_accounts(account, threshold), false, "Failed to make multisig accounts."); \
843#define MAKE_ACCOUNT(VEC_EVENTS, account) \
844 cryptonote::account_base account; \
845 account.generate(); \
846 VEC_EVENTS.push_back(account);
848#define DO_CALLBACK(VEC_EVENTS, CB_NAME) \
850 callback_entry CALLBACK_ENTRY; \
851 CALLBACK_ENTRY.callback_name = CB_NAME; \
852 VEC_EVENTS.push_back(CALLBACK_ENTRY); \
855#define REGISTER_CALLBACK(CB_NAME, CLBACK) \
856 register_callback(CB_NAME, std::bind(&CLBACK, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
858#define REGISTER_CALLBACK_METHOD(CLASS, METHOD) \
859 register_callback(#METHOD, std::bind(&CLASS::METHOD, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
861#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS) \
862 test_generator generator; \
863 cryptonote::block BLK_NAME; \
864 generator.construct_block(BLK_NAME, MINER_ACC, TS); \
865 VEC_EVENTS.push_back(BLK_NAME);
867#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC) \
868 cryptonote::block BLK_NAME; \
869 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC); \
870 VEC_EVENTS.push_back(BLK_NAME);
872#define MAKE_NEXT_BLOCK_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF) \
873 cryptonote::block BLK_NAME; \
874 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, std::list<cryptonote::transaction>(), HF); \
875 VEC_EVENTS.push_back(BLK_NAME);
877#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1) \
878 cryptonote::block BLK_NAME; \
880 std::list<cryptonote::transaction> tx_list; \
881 tx_list.push_back(TX1); \
882 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list); \
884 VEC_EVENTS.push_back(BLK_NAME);
886#define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF) \
887 cryptonote::block BLK_NAME; \
889 std::list<cryptonote::transaction> tx_list; \
890 tx_list.push_back(TX1); \
891 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list, HF); \
893 VEC_EVENTS.push_back(BLK_NAME);
895#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST) \
896 cryptonote::block BLK_NAME; \
897 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST); \
898 VEC_EVENTS.push_back(BLK_NAME);
900#define MAKE_NEXT_BLOCK_TX_LIST_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF) \
901 cryptonote::block BLK_NAME; \
902 generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF); \
903 VEC_EVENTS.push_back(BLK_NAME);
905#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF) \
906 cryptonote::block BLK_NAME; \
908 cryptonote::block blk_last = PREV_BLOCK; \
909 for (size_t i = 0; i < COUNT; ++i) \
911 MAKE_NEXT_BLOCK_HF(VEC_EVENTS, blk, blk_last, MINER_ACC, HF); \
914 BLK_NAME = blk_last; \
917#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)
918#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)
919#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)
921#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
922 cryptonote::transaction TX_NAME; \
923 construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
924 VEC_EVENTS.push_back(TX_NAME);
926#define MAKE_TX_MIX_RCT(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
927 cryptonote::transaction TX_NAME; \
928 construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, rct::RangeProofPaddedBulletproof); \
929 VEC_EVENTS.push_back(TX_NAME);
931#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD) MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, 0, HEAD)
933#define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
935 cryptonote::transaction t; \
936 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
937 SET_NAME.push_back(t); \
938 VEC_EVENTS.push_back(t); \
941#define MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
942 MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
943#define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER) \
945 cryptonote::transaction t; \
946 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
947 SET_NAME.push_back(t); \
948 VEC_EVENTS.push_back(t); \
951#define MAKE_TX_MIX_DEST_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD) \
952 MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
953#define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER) \
955 cryptonote::transaction t; \
956 construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
957 SET_NAME.push_back(t); \
958 VEC_EVENTS.push_back(t); \
961#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)
963#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD) \
964 std::list<cryptonote::transaction> SET_NAME; \
965 MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD);
967#define MAKE_TX_LIST_START_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD) \
968 std::list<cryptonote::transaction> SET_NAME; \
969 MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD);
971#define MAKE_MINER_TX_AND_KEY_AT_HF_MANUALLY(TX, BLK, HF_VERSION, KEY) \
973 if (!construct_miner_tx_manually(get_block_height(BLK) + 1, generator.get_already_generated_coins(BLK), \
974 miner_account.get_keys().m_account_address, TX, 0, HF_VERSION, KEY)) \
977#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY) MAKE_MINER_TX_AND_KEY_AT_HF_MANUALLY(TX, BLK, 1, KEY)
979#define MAKE_MINER_TX_MANUALLY(TX, BLK) MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, 0)
981#define SET_EVENT_VISITOR_SETT(VEC_EVENTS, SETT) VEC_EVENTS.push_back(event_visitor_settings(SETT));
983#define GENERATE(filename, genclass) \
985 std::vector<test_event_entry> events; \
987 g.generate(events); \
988 if (!tools::serialize_obj_to_file(events, filename)) \
990 MERROR("Failed to serialize data to file: " << filename); \
991 throw std::runtime_error("Failed to serialize data to file"); \
996#define PLAY(filename, genclass) \
997 if(!do_replay_file<genclass>(filename)) \
999 MERROR("Failed to pass test : " << #genclass); \
1003#define CATCH_REPLAY(genclass) \
1004 catch (const std::exception& ex) \
1006 MERROR(#genclass << " generation failed: what=" << ex.what()); \
1010 MERROR(#genclass << " generation failed: generic exception"); \
1013#define REPLAY_CORE(genclass) \
1014 if (generated && do_replay_events< genclass >(events)) \
1016 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
1020 MERROR("#TEST# Failed " << #genclass); \
1021 failed_tests.push_back(#genclass); \
1024#define REPLAY_WITH_CORE(genclass, CORE) \
1025 if (generated && replay_events_through_core_validate< genclass >(events, CORE)) \
1027 MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
1031 MERROR("#TEST# Failed " << #genclass); \
1032 failed_tests.push_back(#genclass); \
1035#define CATCH_GENERATE_REPLAY(genclass) \
1036 CATCH_REPLAY(genclass); \
1037 REPLAY_CORE(genclass);
1039#define CATCH_GENERATE_REPLAY_CORE(genclass, CORE) \
1040 CATCH_REPLAY(genclass); \
1041 REPLAY_WITH_CORE(genclass, CORE);
1043#define GENERATE_AND_PLAY(genclass) \
1045 std::cout << #genclass << std::endl; \
1046 else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1048 std::vector<test_event_entry> events; \
1050 bool generated = false; \
1054 generated = g.generate(events); \
1056 CATCH_GENERATE_REPLAY(genclass); \
1059#define GENERATE_AND_PLAY_INSTANCE(genclass, ins, CORE) \
1060 if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
1062 std::vector<test_event_entry> events; \
1064 bool generated = false; \
1067 generated = ins.generate(events); \
1069 CATCH_GENERATE_REPLAY_CORE(genclass, CORE); \
1072#define CALL_TEST(test_name, function) \
1076 MERROR("#TEST# Failed " << test_name); \
1081 MGINFO_GREEN("#TEST# Succeeded " << test_name); \
1085#define QUOTEME(x) #x
1086#define DEFINE_TESTS_ERROR_CONTEXT(text) const char* perr_context = text; (void) perr_context;
1087#define CHECK_TEST_CONDITION(cond) CHECK_AND_ASSERT_MES(cond, false, "[" << perr_context << "] failed: \"" << QUOTEME(cond) << "\"")
1088#define CHECK_EQ(v1, v2) CHECK_AND_ASSERT_MES(v1 == v2, false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " == " << QUOTEME(v2) << "\", " << v1 << " != " << v2)
1089#define CHECK_NOT_EQ(v1, v2) CHECK_AND_ASSERT_MES(!(v1 == v2), false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " != " << QUOTEME(v2) << "\", " << v1 << " == " << v2)
1090#define MK_COINS(amount) (UINT64_C(amount) * COIN)
1091#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)
Definition: chaingen.cpp:958
bool replay_events_through_core_validate(std::vector< test_event_entry > &events, cryptonote::core &c)
Definition: chaingen.h:787
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)
Definition: chaingen.cpp:918
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)
Definition: chaingen.cpp:1023
bool do_replay_events_get_core(std::vector< test_event_entry > &events, cryptonote::core *core)
Definition: chaingen.h:733
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:802
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:817
cryptonote::tx_destination_entry build_dst(const var_addr_t &to, bool is_subaddr=false, uint64_t amount=0)
Definition: chaingen.cpp:949
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, uint64_t unlock_time, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=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:811
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:699
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:693
Definition: chaingen.h:377
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
bool handle_incoming_tx(const tx_blob_entry &tx_blob, tx_verification_context &tvc, relay_method tx_relay, bool relayed)
handles an incoming transaction
Definition: cryptonote_core.cpp:1118
bool handle_incoming_txs(epee::span< const tx_blob_entry > tx_blobs, epee::span< tx_verification_context > tvc, relay_method tx_relay, bool relayed)
handles a list of incoming transactions
Definition: cryptonote_core.cpp:1002
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
Definition: cryptonote_core.cpp:325
bool prepare_handle_incoming_blocks(const std::vector< block_complete_entry > &blocks_entry, std::vector< block > &blocks)
performs some preprocessing on a group of incoming blocks to speed up verification
Definition: cryptonote_core.cpp:1620
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition: cryptonote_core.cpp:742
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
Definition: cryptonote_core.cpp:1632
bool deinit()
performs safe shutdown steps for core and core components
Definition: cryptonote_core.cpp:753
size_t get_pool_transactions_count(bool include_sensitive_txes=false) const
get the total number of transactions in the pool
Definition: cryptonote_core.cpp:1705
bool handle_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
handles an incoming block
Definition: cryptonote_core.cpp:1644
Definition: cryptonote_basic.h:205
rct::rctSig rct_signatures
Definition: cryptonote_basic.h:214
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
Definition: chaingen.h:183
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:80
#define DIFFICULTY_TARGET_V2
Definition: cryptonote_config.h:79
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:236
static constexpr crypto::hash null_hash
Definition: hash.h:92
POD_CLASS hash
Definition: hash.h:48
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:289
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.
@ none
Received via RPC with do_not_relay set.
@ fluff
Received/sent over network using Dandelion++ fluff.
@ stem
Received/send over network using Dandelion++ stem.
@ local
Received via RPC; trying to send over i2p/tor, etc.
std::string blobdata
Definition: blobdatatype.h:39
Definition: bulletproofs.cc:64
key commit(xmr_amount amount, const key &mask)
Definition: rctOps.cpp:336
RangeProofType
Definition: rctTypes.h:299
@ RangeProofBorromean
Definition: rctTypes.h:299
key identity()
Definition: rctOps.h:73
Definition: binary_utils.h:36
bool serialize(Archive &ar, T &v)
Definition: serialization.h:373
#define BEGIN_SERIALIZE_OBJECT()
begins the environment of the DSL \detailed for described the serialization of an object
Definition: serialization.h:184
#define FIELD(f)
tags the field with the variable name and then serializes it
Definition: serialization.h:237
#define END_SERIALIZE()
self-explanatory
Definition: serialization.h:208
#define VARIANT_TAG(Archive, Type, Tag)
Adds the tag \tag to the Archive of Type.
Definition: serialization.h:161
int bool
Definition: stdbool.h:35
#define false
Definition: stdbool.h:37
unsigned char uint8_t
Definition: stdint.h:124
unsigned __int64 uint64_t
Definition: stdint.h:136
bool good() const noexcept
Definition: binary_archive.h:99
Definition: binary_archive.h:89
Definition: chaingen.h:66
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:59
bool m_verifivation_failed
Definition: verification_context.h:61
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:724
const std::pair< uint8_t, uint64_t > hard_forks[2]
Definition: chaingen.h:725
get_test_options()
Definition: chaingen.h:729
const cryptonote::test_options test_options
Definition: chaingen.h:726
Definition: chaingen.h:294
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
bool rct
Definition: chaingen.h:304
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:621
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:598
bool operator()(const cryptonote::transaction &tx) const
Definition: chaingen.h:565
bool operator()(const serialized_block &sr_block) const
Definition: chaingen.h:633
bool operator()(const cryptonote::account_base &ab) const
Definition: chaingen.h:627
void log_event(const std::string &event_type) const
Definition: chaingen.h:686
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:663
bool operator()(const event_visitor_settings &settings)
Definition: chaingen.h:537
Definition: rctTypes.h:79
unsigned char bytes[32]
Definition: rctTypes.h:87
ctkeyV outPk
Definition: rctTypes.h:317
Definition: chaingen.h:84
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
Definition: chaingen.h:186
uint64_t already_generated_coins
Definition: chaingen.h:202
void serialize(Archive &ar, const unsigned int)
Definition: chaingen.h:209
size_t block_weight
Definition: chaingen.h:203
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