Electroneum
chaingen.h File Reference
#include <vector>
#include <iostream>
#include <stdint.h>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/program_options.hpp>
#include <boost/optional.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/variant.hpp>
#include <boost/serialization/optional.hpp>
#include <boost/serialization/unordered_map.hpp>
#include <boost/functional/hash.hpp>
#include "include_base_utils.h"
#include "common/boost_serialization_helper.h"
#include "common/command_line.h"
#include "cryptonote_basic/account_boost_serialization.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "cryptonote_basic/cryptonote_basic_impl.h"
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_basic/cryptonote_boost_serialization.h"
#include "misc_language.h"
Include dependency graph for chaingen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  callback_entry
 
struct  serialized_object< T >
 
struct  event_visitor_settings
 
struct  event_replay_settings
 
class  test_chain_unit_base
 
class  test_generator
 
struct  test_generator::block_info
 
struct  output_index
 
struct  dest_wrapper_t
 
class  block_tracker
 
struct  push_core_event_visitor< t_test_class >
 
struct  get_test_options< t_test_class >
 

Macros

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "tests.core"
 
#define DEFAULT_HARDFORKS(HARDFORKS)
 
#define ADD_HARDFORK(HARDFORKS, FORK, HEIGHT)   HARDFORKS.push_back(std::make_pair((uint8_t)FORK, (uint64_t)HEIGHT))
 
#define GENERATE_ACCOUNT(account)
 
#define GENERATE_MULTISIG_ACCOUNT(account, threshold, total)
 
#define MAKE_ACCOUNT(VEC_EVENTS, account)
 
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
 
#define REGISTER_CALLBACK(CB_NAME, CLBACK)   register_callback(CB_NAME, std::bind(&CLBACK, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
 
#define REGISTER_CALLBACK_METHOD(CLASS, METHOD)   register_callback(#METHOD, std::bind(&CLASS::METHOD, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
 
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
 
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
 
#define MAKE_NEXT_BLOCK_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, HF)
 
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
 
#define MAKE_NEXT_BLOCK_TX1_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1, HF)
 
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
 
#define MAKE_NEXT_BLOCK_TX_LIST_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF)
 
#define REWIND_BLOCKS_N_HF(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT, HF)
 
#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)
 
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)   REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW)
 
#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_ETN_UNLOCK_WINDOW, HF)
 
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
 
#define MAKE_TX_MIX_RCT(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
 
#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD)   MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, 0, HEAD)
 
#define MAKE_TX_MIX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
 
#define MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)   MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
 
#define MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, RCT_TYPE, BP_VER)
 
#define MAKE_TX_MIX_DEST_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD)   MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)
 
#define MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, RCT_TYPE, BP_VER)
 
#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)
 
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
 
#define MAKE_TX_LIST_START_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
 
#define MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, KEY)
 
#define MAKE_MINER_TX_MANUALLY(TX, BLK)   MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, 0)
 
#define SET_EVENT_VISITOR_SETT(VEC_EVENTS, SETT, VAL)   VEC_EVENTS.push_back(event_visitor_settings(SETT, VAL));
 
#define GENERATE(filename, genclass)
 
#define PLAY(filename, genclass)
 
#define CATCH_REPLAY(genclass)
 
#define REPLAY_CORE(genclass)
 
#define REPLAY_WITH_CORE(genclass, CORE)
 
#define CATCH_GENERATE_REPLAY(genclass)
 
#define CATCH_GENERATE_REPLAY_CORE(genclass, CORE)
 
#define GENERATE_AND_PLAY(genclass)
 
#define GENERATE_AND_PLAY_INSTANCE(genclass, ins, CORE)
 
#define CALL_TEST(test_name, function)
 
#define QUOTEME(x)   #x
 
#define DEFINE_TESTS_ERROR_CONTEXT(text)   const char* perr_context = text;
 
#define CHECK_TEST_CONDITION(cond)   CHECK_AND_ASSERT_MES(cond, false, "[" << perr_context << "] failed: \"" << QUOTEME(cond) << "\"")
 
#define CHECK_EQ(v1, v2)   CHECK_AND_ASSERT_MES(v1 == v2, false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " == " << QUOTEME(v2) << "\", " << v1 << " != " << v2)
 
#define CHECK_NOT_EQ(v1, v2)   CHECK_AND_ASSERT_MES(!(v1 == v2), false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " != " << QUOTEME(v2) << "\", " << v1 << " == " << v2)
 
#define MK_COINS(amount)   (UINT64_C(amount) * COIN)
 
#define TESTS_DEFAULT_FEE   ((uint64_t)10)
 

Typedefs

typedef serialized_object< cryptonote::blockserialized_block
 
typedef serialized_object< cryptonote::transactionserialized_transaction
 
typedef std::vector< std::pair< uint8_t, uint64_t > > v_hardforks_t
 
typedef boost::variant< cryptonote::block, cryptonote::transaction, std::vector< cryptonote::transaction >, cryptonote::account_base, callback_entry, serialized_block, serialized_transaction, event_visitor_settings, event_replay_settingstest_event_entry
 
typedef std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
 
typedef std::tuple< uint64_t, crypto::public_key, rct::keyget_outs_entry
 
typedef std::pair< crypto::hash, size_t > output_hasher
 
typedef boost::hash< output_hasheroutput_hasher_hasher
 
typedef std::map< uint64_t, std::vector< size_t > > map_output_t
 
typedef std::map< uint64_t, std::vector< output_index > > map_output_idx_t
 
typedef std::unordered_map< crypto::hash, cryptonote::blockmap_block_t
 
typedef std::unordered_map< output_hasher, output_index, output_hasher_hashermap_txid_output_t
 
typedef std::unordered_map< crypto::public_key, cryptonote::subaddress_indexsubaddresses_t
 
typedef std::pair< uint64_t, size_t > outloc_t
 
typedef boost::variant< cryptonote::account_public_address, cryptonote::account_keys, cryptonote::account_base, cryptonote::tx_destination_entryvar_addr_t
 

Functions

 VARIANT_TAG (binary_archive, callback_entry, 0xcb)
 
 VARIANT_TAG (binary_archive, cryptonote::account_base, 0xcc)
 
 VARIANT_TAG (binary_archive, serialized_block, 0xcd)
 
 VARIANT_TAG (binary_archive, serialized_transaction, 0xce)
 
 VARIANT_TAG (binary_archive, event_visitor_settings, 0xcf)
 
 VARIANT_TAG (binary_archive, event_replay_settings, 0xda)
 
template<typename T >
std::string dump_keys (T *buff32)
 
std::string dump_data (const cryptonote::transaction &tx)
 
cryptonote::account_public_address get_address (const var_addr_t &inp)
 
cryptonote::account_public_address get_address (const cryptonote::account_public_address &inp)
 
cryptonote::account_public_address get_address (const cryptonote::account_keys &inp)
 
cryptonote::account_public_address get_address (const cryptonote::account_base &inp)
 
cryptonote::account_public_address get_address (const cryptonote::tx_destination_entry &inp)
 
cryptonote::difficulty_type get_test_difficulty (const boost::optional< uint8_t > &hf_ver=boost::none)
 
uint64_t current_difficulty_window (const boost::optional< uint8_t > &hf_ver=boost::none)
 
void fill_nonce (cryptonote::block &blk, const cryptonote::difficulty_type &diffic, uint64_t height)
 
cryptonote::tx_destination_entry build_dst (const var_addr_t &to, bool is_subaddr=false, uint64_t amount=0)
 
std::vector< cryptonote::tx_destination_entrybuild_dsts (const var_addr_t &to1, bool sub1=false, uint64_t am1=0)
 
std::vector< cryptonote::tx_destination_entrybuild_dsts (std::initializer_list< dest_wrapper_t > inps)
 
uint64_t sum_amount (const std::vector< cryptonote::tx_destination_entry > &destinations)
 
uint64_t sum_amount (const std::vector< cryptonote::tx_source_entry > &sources)
 
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, cryptonote::keypair *p_txkey=nullptr)
 
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 construct_tx_to_key (const std::vector< test_event_entry > &events, cryptonote::transaction &tx, const cryptonote::block &blk_head, const cryptonote::account_base &from, std::vector< cryptonote::tx_destination_entry > destinations, uint64_t fee, size_t nmix, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
 
bool construct_tx_to_key (cryptonote::transaction &tx, const cryptonote::account_base &from, const var_addr_t &to, uint64_t amount, std::vector< cryptonote::tx_source_entry > &sources, uint64_t fee, bool rct=false, rct::RangeProofType range_proof_type=rct::RangeProofBorromean, int bp_version=0)
 
bool construct_tx_to_key (cryptonote::transaction &tx, const cryptonote::account_base &from, const std::vector< cryptonote::tx_destination_entry > &destinations, std::vector< cryptonote::tx_source_entry > &sources, uint64_t fee, bool rct, rct::RangeProofType range_proof_type, int bp_version=0)
 
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)
 
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)
 
uint64_t num_blocks (const std::vector< test_event_entry > &events)
 
cryptonote::block get_head_block (const std::vector< test_event_entry > &events)
 
void get_confirmed_txs (const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, map_hash2tx_t &confirmed_txs)
 
bool trim_block_chain (std::vector< cryptonote::block > &blockchain, const crypto::hash &tail)
 
bool trim_block_chain (std::vector< const cryptonote::block *> &blockchain, const crypto::hash &tail)
 
bool find_block_chain (const std::vector< test_event_entry > &events, std::vector< cryptonote::block > &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
 
bool find_block_chain (const std::vector< test_event_entry > &events, std::vector< const cryptonote::block *> &blockchain, map_hash2tx_t &mtx, const crypto::hash &head)
 
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_destinations (const var_addr_t &from, const std::vector< cryptonote::tx_destination_entry > &dests, uint64_t fee, const std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations, bool always_change)
 
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, std::vector< cryptonote::tx_destination_entry > &destinations_pure, 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)
 
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_base &to, uint64_t amount, uint64_t fee, size_t nmix, std::vector< cryptonote::tx_source_entry > &sources, std::vector< cryptonote::tx_destination_entry > &destinations)
 
uint64_t get_balance (const cryptonote::account_base &addr, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx)
 
bool extract_hard_forks (const std::vector< test_event_entry > &events, v_hardforks_t &hard_forks)
 
template<class t_test_class >
bool replay_events_through_core (cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator)
 
template<class t_test_class >
bool replay_events_through_core_plain (cryptonote::core &cr, const std::vector< test_event_entry > &events, t_test_class &validator, bool reinit=true)
 
template<class t_test_class >
bool do_replay_events_get_core (std::vector< test_event_entry > &events, cryptonote::core *core)
 
template<class t_test_class >
bool replay_events_through_core_validate (std::vector< test_event_entry > &events, cryptonote::core &c)
 
template<class t_test_class >
bool do_replay_events (std::vector< test_event_entry > &events)
 
template<class t_test_class >
bool do_replay_file (const std::string &filename)
 

Macro Definition Documentation

◆ ADD_HARDFORK

#define ADD_HARDFORK (   HARDFORKS,
  FORK,
  HEIGHT 
)    HARDFORKS.push_back(std::make_pair((uint8_t)FORK, (uint64_t)HEIGHT))

Definition at line 799 of file chaingen.h.

◆ CALL_TEST

#define CALL_TEST (   test_name,
  function 
)
Value:
{ \
if(!function()) \
{ \
MERROR("#TEST# Failed " << test_name); \
return 1; \
} \
else \
{ \
MGINFO_GREEN("#TEST# Succeeded " << test_name); \
} \
}

Definition at line 1042 of file chaingen.h.

◆ CATCH_GENERATE_REPLAY

#define CATCH_GENERATE_REPLAY (   genclass)
Value:
CATCH_REPLAY(genclass); \
REPLAY_CORE(genclass);
#define CATCH_REPLAY(genclass)
Definition: chaingen.h:973

Definition at line 1005 of file chaingen.h.

◆ CATCH_GENERATE_REPLAY_CORE

#define CATCH_GENERATE_REPLAY_CORE (   genclass,
  CORE 
)
Value:
CATCH_REPLAY(genclass); \
REPLAY_WITH_CORE(genclass, CORE);
#define CATCH_REPLAY(genclass)
Definition: chaingen.h:973

Definition at line 1009 of file chaingen.h.

◆ CATCH_REPLAY

#define CATCH_REPLAY (   genclass)
Value:
catch (const std::exception& ex) \
{ \
MERROR(#genclass << " generation failed: what=" << ex.what()); \
} \
catch (...) \
{ \
MERROR(#genclass << " generation failed: generic exception"); \
}

Definition at line 973 of file chaingen.h.

◆ CHECK_EQ

#define CHECK_EQ (   v1,
  v2 
)    CHECK_AND_ASSERT_MES(v1 == v2, false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " == " << QUOTEME(v2) << "\", " << v1 << " != " << v2)

Definition at line 1058 of file chaingen.h.

◆ CHECK_NOT_EQ

#define CHECK_NOT_EQ (   v1,
  v2 
)    CHECK_AND_ASSERT_MES(!(v1 == v2), false, "[" << perr_context << "] failed: \"" << QUOTEME(v1) << " != " << QUOTEME(v2) << "\", " << v1 << " == " << v2)

Definition at line 1059 of file chaingen.h.

◆ CHECK_TEST_CONDITION

#define CHECK_TEST_CONDITION (   cond)    CHECK_AND_ASSERT_MES(cond, false, "[" << perr_context << "] failed: \"" << QUOTEME(cond) << "\"")

Definition at line 1057 of file chaingen.h.

◆ DEFAULT_HARDFORKS

#define DEFAULT_HARDFORKS (   HARDFORKS)
Value:
do { \
HARDFORKS.push_back(std::make_pair((uint8_t)1, (uint64_t)0)); \
} while(0)
unsigned char uint8_t
Definition: stdint.h:124
unsigned __int64 uint64_t
Definition: stdint.h:136

Definition at line 795 of file chaingen.h.

◆ DEFINE_TESTS_ERROR_CONTEXT

#define DEFINE_TESTS_ERROR_CONTEXT (   text)    const char* perr_context = text;

Definition at line 1056 of file chaingen.h.

◆ DO_CALLBACK

#define DO_CALLBACK (   VEC_EVENTS,
  CB_NAME 
)
Value:
{ \
callback_entry CALLBACK_ENTRY; \
CALLBACK_ENTRY.callback_name = CB_NAME; \
VEC_EVENTS.push_back(CALLBACK_ENTRY); \
}

Definition at line 820 of file chaingen.h.

◆ ELECTRONEUM_DEFAULT_LOG_CATEGORY

#define ELECTRONEUM_DEFAULT_LOG_CATEGORY   "tests.core"

Definition at line 61 of file chaingen.h.

◆ GENERATE

#define GENERATE (   filename,
  genclass 
)
Value:
{ \
std::vector<test_event_entry> events; \
genclass g; \
g.generate(events); \
if (!tools::serialize_obj_to_file(events, filename)) \
{ \
MERROR("Failed to serialize data to file: " << filename); \
throw std::runtime_error("Failed to serialize data to file"); \
} \
}
bool serialize_obj_to_file(t_object &obj, const std::string &file_path)

Definition at line 953 of file chaingen.h.

◆ GENERATE_ACCOUNT

#define GENERATE_ACCOUNT (   account)
Value:
account.generate();
crypto::secret_key generate(const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false, bool two_random=false)
Definition: account.cpp:158

Definition at line 801 of file chaingen.h.

◆ GENERATE_AND_PLAY

#define GENERATE_AND_PLAY (   genclass)
Value:
if (list_tests) \
std::cout << #genclass << std::endl; \
else if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
{ \
std::vector<test_event_entry> events; \
++tests_count; \
bool generated = false; \
try \
{ \
genclass g; \
generated = g.generate(events); \
} \
CATCH_GENERATE_REPLAY(genclass); \
}
::std::string string
Definition: gtest-port.h:1097

Definition at line 1013 of file chaingen.h.

◆ GENERATE_AND_PLAY_INSTANCE

#define GENERATE_AND_PLAY_INSTANCE (   genclass,
  ins,
  CORE 
)
Value:
if (filter.empty() || boost::regex_match(std::string(#genclass), match, boost::regex(filter))) \
{ \
std::vector<test_event_entry> events; \
++tests_count; \
bool generated = false; \
try \
{ \
generated = ins.generate(events); \
} \
CATCH_GENERATE_REPLAY_CORE(genclass, CORE); \
}
::std::string string
Definition: gtest-port.h:1097

Definition at line 1029 of file chaingen.h.

◆ GENERATE_MULTISIG_ACCOUNT

#define GENERATE_MULTISIG_ACCOUNT (   account,
  threshold,
  total 
)
Value:
CHECK_AND_ASSERT_MES(threshold >= 2 && threshold <= total, false, "Invalid multisig scheme"); \
std::vector<cryptonote::account_base> account(total); \
do \
{ \
for (size_t msidx = 0; msidx < total; ++msidx) \
account[msidx].generate(); \
make_multisig_accounts(account, threshold); \
} while(0)
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:181
uint8_t threshold
Definition: blockchain.cpp:92

Definition at line 805 of file chaingen.h.

◆ MAKE_ACCOUNT

#define MAKE_ACCOUNT (   VEC_EVENTS,
  account 
)
Value:
account.generate(); \
VEC_EVENTS.push_back(account);
crypto::secret_key generate(const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false, bool two_random=false)
Definition: account.cpp:158

Definition at line 815 of file chaingen.h.

◆ MAKE_GENESIS_BLOCK

#define MAKE_GENESIS_BLOCK (   VEC_EVENTS,
  BLK_NAME,
  MINER_ACC,
  TS 
)
Value:
test_generator generator; \
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, MINER_ACC, TS); \
VEC_EVENTS.push_back(BLK_NAME);
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:112

Definition at line 833 of file chaingen.h.

◆ MAKE_MINER_TX_AND_KEY_MANUALLY

#define MAKE_MINER_TX_AND_KEY_MANUALLY (   TX,
  BLK,
  KEY 
)
Value:
transaction TX; \
if (!construct_miner_tx_manually(get_block_height(BLK) + 1, generator.get_already_generated_coins(BLK), \
miner_account.get_keys().m_account_address, TX, 0, KEY)) \
return false;
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, cryptonote::keypair *p_txkey=nullptr)
Definition: chaingen.cpp:830
uint64_t get_block_height(const block &b)

Definition at line 943 of file chaingen.h.

◆ MAKE_MINER_TX_MANUALLY

#define MAKE_MINER_TX_MANUALLY (   TX,
  BLK 
)    MAKE_MINER_TX_AND_KEY_MANUALLY(TX, BLK, 0)

Definition at line 949 of file chaingen.h.

◆ MAKE_NEXT_BLOCK

#define MAKE_NEXT_BLOCK (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC 
)
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 839 of file chaingen.h.

◆ MAKE_NEXT_BLOCK_HF

#define MAKE_NEXT_BLOCK_HF (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC,
  HF 
)
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, std::list<cryptonote::transaction>(), HF); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 844 of file chaingen.h.

◆ MAKE_NEXT_BLOCK_TX1

#define MAKE_NEXT_BLOCK_TX1 (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC,
  TX1 
)
Value:
cryptonote::block BLK_NAME; \
{ \
std::list<cryptonote::transaction> tx_list; \
tx_list.push_back(TX1); \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list); \
} \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 849 of file chaingen.h.

◆ MAKE_NEXT_BLOCK_TX1_HF

#define MAKE_NEXT_BLOCK_TX1_HF (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC,
  TX1,
  HF 
)
Value:
cryptonote::block BLK_NAME; \
{ \
std::list<cryptonote::transaction> tx_list; \
tx_list.push_back(TX1); \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, tx_list, HF); \
} \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 858 of file chaingen.h.

◆ MAKE_NEXT_BLOCK_TX_LIST

#define MAKE_NEXT_BLOCK_TX_LIST (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC,
  TXLIST 
)
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 867 of file chaingen.h.

◆ MAKE_NEXT_BLOCK_TX_LIST_HF

#define MAKE_NEXT_BLOCK_TX_LIST_HF (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC,
  TXLIST,
  HF 
)
Value:
cryptonote::block BLK_NAME; \
generator.construct_block(BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST, HF); \
VEC_EVENTS.push_back(BLK_NAME);

Definition at line 872 of file chaingen.h.

◆ MAKE_TX

#define MAKE_TX (   VEC_EVENTS,
  TX_NAME,
  FROM,
  TO,
  AMOUNT,
  HEAD 
)    MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, 0, HEAD)

Definition at line 903 of file chaingen.h.

◆ MAKE_TX_LIST

#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)

Definition at line 933 of file chaingen.h.

◆ MAKE_TX_LIST_START

#define MAKE_TX_LIST_START (   VEC_EVENTS,
  SET_NAME,
  FROM,
  TO,
  AMOUNT,
  HEAD 
)
Value:
std::list<cryptonote::transaction> SET_NAME; \
MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD);

Definition at line 935 of file chaingen.h.

◆ MAKE_TX_LIST_START_RCT

#define MAKE_TX_LIST_START_RCT (   VEC_EVENTS,
  SET_NAME,
  FROM,
  TO,
  AMOUNT,
  NMIX,
  HEAD 
)
Value:
std::list<cryptonote::transaction> SET_NAME; \
MAKE_TX_MIX_LIST_RCT(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD);

Definition at line 939 of file chaingen.h.

◆ MAKE_TX_MIX

#define MAKE_TX_MIX (   VEC_EVENTS,
  TX_NAME,
  FROM,
  TO,
  AMOUNT,
  NMIX,
  HEAD 
)
Value:
construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
VEC_EVENTS.push_back(TX_NAME);
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061

Definition at line 893 of file chaingen.h.

◆ MAKE_TX_MIX_DEST_LIST_RCT

#define MAKE_TX_MIX_DEST_LIST_RCT (   VEC_EVENTS,
  SET_NAME,
  FROM,
  TO,
  NMIX,
  HEAD 
)    MAKE_TX_MIX_DEST_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)

Definition at line 923 of file chaingen.h.

◆ MAKE_TX_MIX_DEST_LIST_RCT_EX

#define MAKE_TX_MIX_DEST_LIST_RCT_EX (   VEC_EVENTS,
  SET_NAME,
  FROM,
  TO,
  NMIX,
  HEAD,
  RCT_TYPE,
  BP_VER 
)
Value:
{ \
cryptonote::transaction t; \
construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
SET_NAME.push_back(t); \
VEC_EVENTS.push_back(t); \
}
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061

Definition at line 925 of file chaingen.h.

◆ MAKE_TX_MIX_LIST

#define MAKE_TX_MIX_LIST (   VEC_EVENTS,
  SET_NAME,
  FROM,
  TO,
  AMOUNT,
  NMIX,
  HEAD 
)
Value:
{ \
cryptonote::transaction t; \
construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX); \
SET_NAME.push_back(t); \
VEC_EVENTS.push_back(t); \
}
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061

Definition at line 905 of file chaingen.h.

◆ MAKE_TX_MIX_LIST_RCT

#define MAKE_TX_MIX_LIST_RCT (   VEC_EVENTS,
  SET_NAME,
  FROM,
  TO,
  AMOUNT,
  NMIX,
  HEAD 
)    MAKE_TX_MIX_LIST_RCT_EX(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, NMIX, HEAD, rct::RangeProofPaddedBulletproof, 1)

Definition at line 913 of file chaingen.h.

◆ MAKE_TX_MIX_LIST_RCT_EX

#define MAKE_TX_MIX_LIST_RCT_EX (   VEC_EVENTS,
  SET_NAME,
  FROM,
  TO,
  AMOUNT,
  NMIX,
  HEAD,
  RCT_TYPE,
  BP_VER 
)
Value:
{ \
cryptonote::transaction t; \
construct_tx_to_key(VEC_EVENTS, t, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, RCT_TYPE, BP_VER); \
SET_NAME.push_back(t); \
VEC_EVENTS.push_back(t); \
}
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061

Definition at line 915 of file chaingen.h.

◆ MAKE_TX_MIX_RCT

#define MAKE_TX_MIX_RCT (   VEC_EVENTS,
  TX_NAME,
  FROM,
  TO,
  AMOUNT,
  NMIX,
  HEAD 
)
Value:
construct_tx_to_key(VEC_EVENTS, TX_NAME, HEAD, FROM, TO, AMOUNT, TESTS_DEFAULT_FEE, NMIX, true, rct::RangeProofPaddedBulletproof); \
VEC_EVENTS.push_back(TX_NAME);
#define TESTS_DEFAULT_FEE
Definition: chaingen.h:1061

Definition at line 898 of file chaingen.h.

◆ MK_COINS

#define MK_COINS (   amount)    (UINT64_C(amount) * COIN)

Definition at line 1060 of file chaingen.h.

◆ PLAY

#define PLAY (   filename,
  genclass 
)
Value:
if(!do_replay_file<genclass>(filename)) \
{ \
MERROR("Failed to pass test : " << #genclass); \
return 1; \
}

Definition at line 966 of file chaingen.h.

◆ QUOTEME

#define QUOTEME (   x)    #x

Definition at line 1055 of file chaingen.h.

◆ REGISTER_CALLBACK

#define REGISTER_CALLBACK (   CB_NAME,
  CLBACK 
)    register_callback(CB_NAME, std::bind(&CLBACK, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

Definition at line 827 of file chaingen.h.

◆ REGISTER_CALLBACK_METHOD

#define REGISTER_CALLBACK_METHOD (   CLASS,
  METHOD 
)    register_callback(#METHOD, std::bind(&CLASS::METHOD, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));

Definition at line 830 of file chaingen.h.

◆ REPLAY_CORE

#define REPLAY_CORE (   genclass)
Value:
if (generated && do_replay_events< genclass >(events)) \
{ \
MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
} \
else \
{ \
MERROR("#TEST# Failed " << #genclass); \
failed_tests.push_back(#genclass); \
}

Definition at line 983 of file chaingen.h.

◆ REPLAY_WITH_CORE

#define REPLAY_WITH_CORE (   genclass,
  CORE 
)
Value:
if (generated && replay_events_through_core_validate< genclass >(events, CORE)) \
{ \
MGINFO_GREEN("#TEST# Succeeded " << #genclass); \
} \
else \
{ \
MERROR("#TEST# Failed " << #genclass); \
failed_tests.push_back(#genclass); \
}

Definition at line 994 of file chaingen.h.

◆ REWIND_BLOCKS

#define REWIND_BLOCKS (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC 
)    REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW)

Definition at line 890 of file chaingen.h.

◆ REWIND_BLOCKS_HF

#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_ETN_UNLOCK_WINDOW, HF)

Definition at line 891 of file chaingen.h.

◆ REWIND_BLOCKS_N

#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)

Definition at line 889 of file chaingen.h.

◆ REWIND_BLOCKS_N_HF

#define REWIND_BLOCKS_N_HF (   VEC_EVENTS,
  BLK_NAME,
  PREV_BLOCK,
  MINER_ACC,
  COUNT,
  HF 
)
Value:
cryptonote::block BLK_NAME; \
{ \
cryptonote::block blk_last = PREV_BLOCK; \
for (size_t i = 0; i < COUNT; ++i) \
{ \
MAKE_NEXT_BLOCK_HF(VEC_EVENTS, blk, blk_last, MINER_ACC, HF); \
blk_last = blk; \
} \
BLK_NAME = blk_last; \
}

Definition at line 877 of file chaingen.h.

◆ SET_EVENT_VISITOR_SETT

#define SET_EVENT_VISITOR_SETT (   VEC_EVENTS,
  SETT,
  VAL 
)    VEC_EVENTS.push_back(event_visitor_settings(SETT, VAL));

Definition at line 951 of file chaingen.h.

◆ TESTS_DEFAULT_FEE

#define TESTS_DEFAULT_FEE   ((uint64_t)10)

Definition at line 1061 of file chaingen.h.

Typedef Documentation

◆ get_outs_entry

Definition at line 352 of file chaingen.h.

◆ map_block_t

typedef std::unordered_map<crypto::hash, cryptonote::block> map_block_t

Definition at line 357 of file chaingen.h.

◆ map_hash2tx_t

typedef std::unordered_map<crypto::hash, const cryptonote::transaction*> map_hash2tx_t

Definition at line 163 of file chaingen.h.

◆ map_output_idx_t

typedef std::map<uint64_t, std::vector<output_index> > map_output_idx_t

Definition at line 356 of file chaingen.h.

◆ map_output_t

typedef std::map<uint64_t, std::vector<size_t> > map_output_t

Definition at line 355 of file chaingen.h.

◆ map_txid_output_t

Definition at line 358 of file chaingen.h.

◆ outloc_t

typedef std::pair<uint64_t, size_t> outloc_t

Definition at line 360 of file chaingen.h.

◆ output_hasher

typedef std::pair<crypto::hash, size_t> output_hasher

Definition at line 353 of file chaingen.h.

◆ output_hasher_hasher

typedef boost::hash<output_hasher> output_hasher_hasher

Definition at line 354 of file chaingen.h.

◆ serialized_block

Definition at line 107 of file chaingen.h.

◆ serialized_transaction

◆ subaddresses_t

Definition at line 359 of file chaingen.h.

◆ test_event_entry

◆ v_hardforks_t

typedef std::vector<std::pair<uint8_t, uint64_t> > v_hardforks_t

Definition at line 137 of file chaingen.h.

◆ var_addr_t

Function Documentation

◆ build_dst()

cryptonote::tx_destination_entry build_dst ( const var_addr_t to,
bool  is_subaddr = false,
uint64_t  amount = 0 
)

Definition at line 804 of file chaingen.cpp.

805 {
807  de.amount = amount;
808  de.addr = get_address(to);
809  de.is_subaddress = is_subaddr;
810  return de;
811 }
uint64_t amount
bool is_subaddress
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:665
account_public_address addr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ build_dsts() [1/2]

std::vector<cryptonote::tx_destination_entry> build_dsts ( const var_addr_t to1,
bool  sub1 = false,
uint64_t  am1 = 0 
)

Definition at line 813 of file chaingen.cpp.

814 {
815  std::vector<cryptonote::tx_destination_entry> res;
816  res.push_back(build_dst(to1, sub1, am1));
817  return res;
818 }
const char * res
Definition: hmac_keccak.cpp:41
cryptonote::tx_destination_entry build_dst(const var_addr_t &to, bool is_subaddr, uint64_t amount)
Definition: chaingen.cpp:804
Here is the call graph for this function:

◆ build_dsts() [2/2]

std::vector<cryptonote::tx_destination_entry> build_dsts ( std::initializer_list< dest_wrapper_t inps)

Definition at line 820 of file chaingen.cpp.

821 {
822  std::vector<cryptonote::tx_destination_entry> res;
823  res.reserve(inps.size());
824  for(auto & c : inps){
825  res.push_back(build_dst(c.addr, c.is_subaddr, c.amount));
826  }
827  return res;
828 }
const char * res
Definition: hmac_keccak.cpp:41
cryptonote::tx_destination_entry build_dst(const var_addr_t &to, bool is_subaddr, uint64_t amount)
Definition: chaingen.cpp:804
Here is the call graph for this function:

◆ construct_miner_tx_manually()

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,
cryptonote::keypair p_txkey = nullptr 
)

Definition at line 830 of file chaingen.cpp.

833 {
834  keypair txkey;
835  txkey = keypair::generate(hw::get_device("default"));
836  add_tx_pub_key_to_extra(tx, txkey.pub);
837 
838  if (0 != p_txkey)
839  *p_txkey = txkey;
840 
841  txin_gen in;
842  in.height = height;
843  tx.vin.push_back(in);
844 
845  // This will work, until size of constructed block is less then CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE
846  uint64_t block_reward;
847  //Deal with premine implementation.
848  if (height == 1){block_reward = 1260000000000;}
849  else if (!get_block_reward(0, 0, already_generated_coins, block_reward, 1, height))
850  {
851  LOG_PRINT_L0("Block is too big");
852  return false;
853  }
854  block_reward += fee;
855 
856  crypto::key_derivation derivation;
857  crypto::public_key out_eph_public_key;
858  crypto::generate_key_derivation(miner_address.m_view_public_key, txkey.sec, derivation);
859  crypto::derive_public_key(derivation, 0, miner_address.m_spend_public_key, out_eph_public_key);
860 
861  tx_out out;
862  out.amount = block_reward;
863  out.target = txout_to_key(out_eph_public_key);
864  tx.vout.push_back(out);
865 
866  tx.version = 1;
868 
869  return true;
870 }
crypto::public_key pub
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
crypto::secret_key sec
POD_CLASS key_derivation
Definition: crypto.h:98
uint64_t height
Definition: blockchain.cpp:91
#define LOG_PRINT_L0(x)
Definition: misc_log_ex.h:99
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
Definition: crypto.h:272
bool add_tx_pub_key_to_extra(transaction &tx, const crypto::public_key &tx_pub_key)
device & get_device(const std::string &device_descriptor)
Definition: device.cpp:95
unsigned __int64 uint64_t
Definition: stdint.h:136
POD_CLASS public_key
Definition: crypto.h:76
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
Definition: crypto.h:275
bool get_block_reward(size_t median_weight, size_t current_block_weight, uint64_t already_generated_coins, uint64_t &reward, uint8_t version, uint64_t current_block_height, network_type nettype)
Here is the call graph for this function:

◆ construct_tx_rct()

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 
)

◆ construct_tx_to_key() [1/4]

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 at line 872 of file chaingen.cpp.

875 {
876  vector<tx_source_entry> sources;
877  vector<tx_destination_entry> destinations;
878  fill_tx_sources_and_destinations(events, blk_head, from, get_address(to), amount, fee, nmix, sources, destinations);
879 
880  return construct_tx_rct(from.get_keys(), sources, destinations, from.get_keys().m_account_address, std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
881 }
void fill_tx_sources_and_destinations(const std::vector< test_event_entry > &events, const 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< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations)
Definition: chaingen.cpp:775
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, rct::RangeProofType range_proof_type, int bp_version)
Definition: chaingen.cpp:920
const account_keys & get_keys() const
Definition: account.cpp:264
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:665
account_public_address m_account_address
Definition: account.h:43
Here is the call graph for this function:
Here is the caller graph for this function:

◆ construct_tx_to_key() [2/4]

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,
std::vector< cryptonote::tx_destination_entry destinations,
uint64_t  fee,
size_t  nmix,
bool  rct = false,
rct::RangeProofType  range_proof_type = rct::RangeProofBorromean,
int  bp_version = 0 
)

Definition at line 883 of file chaingen.cpp.

886 {
887  vector<tx_source_entry> sources;
888  vector<tx_destination_entry> destinations_all;
889  uint64_t amount = sum_amount(destinations);
890 
891  if (!fill_tx_sources(sources, events, blk_head, from, amount + fee, nmix))
892  throw std::runtime_error("couldn't fill transaction sources");
893 
894  fill_tx_destinations(from, destinations, fee, sources, destinations_all, false);
895 
896  return construct_tx_rct(from.get_keys(), sources, destinations_all, get_address(from), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
897 }
bool fill_tx_sources(std::vector< tx_source_entry > &sources, const std::vector< test_event_entry > &events, const block &blk_head, const cryptonote::account_base &from, uint64_t amount, size_t nmix)
Definition: chaingen.cpp:396
uint64_t sum_amount(const std::vector< tx_destination_entry > &destinations)
Definition: chaingen.cpp:700
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, rct::RangeProofType range_proof_type, int bp_version)
Definition: chaingen.cpp:920
const account_keys & get_keys() const
Definition: account.cpp:264
void fill_tx_destinations(const var_addr_t &from, const std::vector< tx_destination_entry > &dests, uint64_t fee, const std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, bool always_change)
Definition: chaingen.cpp:720
unsigned __int64 uint64_t
Definition: stdint.h:136
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:665
Here is the call graph for this function:

◆ construct_tx_to_key() [3/4]

bool construct_tx_to_key ( cryptonote::transaction tx,
const cryptonote::account_base from,
const var_addr_t to,
uint64_t  amount,
std::vector< cryptonote::tx_source_entry > &  sources,
uint64_t  fee,
bool  rct = false,
rct::RangeProofType  range_proof_type = rct::RangeProofBorromean,
int  bp_version = 0 
)

Definition at line 899 of file chaingen.cpp.

903 {
904  vector<tx_destination_entry> destinations;
905  fill_tx_destinations(from, get_address(to), amount, fee, sources, destinations, rct);
906  return construct_tx_rct(from.get_keys(), sources, destinations, get_address(from), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
907 }
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, rct::RangeProofType range_proof_type, int bp_version)
Definition: chaingen.cpp:920
const account_keys & get_keys() const
Definition: account.cpp:264
void fill_tx_destinations(const var_addr_t &from, const std::vector< tx_destination_entry > &dests, uint64_t fee, const std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, bool always_change)
Definition: chaingen.cpp:720
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:665
Here is the call graph for this function:

◆ construct_tx_to_key() [4/4]

bool construct_tx_to_key ( cryptonote::transaction tx,
const cryptonote::account_base from,
const std::vector< cryptonote::tx_destination_entry > &  destinations,
std::vector< cryptonote::tx_source_entry > &  sources,
uint64_t  fee,
bool  rct,
rct::RangeProofType  range_proof_type,
int  bp_version = 0 
)

Definition at line 909 of file chaingen.cpp.

914 {
915  vector<tx_destination_entry> all_destinations;
916  fill_tx_destinations(from, destinations, fee, sources, all_destinations, rct);
917  return construct_tx_rct(from.get_keys(), sources, all_destinations, get_address(from), std::vector<uint8_t>(), tx, 0, rct, range_proof_type, bp_version);
918 }
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, rct::RangeProofType range_proof_type, int bp_version)
Definition: chaingen.cpp:920
const account_keys & get_keys() const
Definition: account.cpp:264
void fill_tx_destinations(const var_addr_t &from, const std::vector< tx_destination_entry > &dests, uint64_t fee, const std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, bool always_change)
Definition: chaingen.cpp:720
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:665
Here is the call graph for this function:

◆ construct_tx_with_fee()

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 at line 931 of file chaingen.cpp.

933 {
934  transaction tx;
935  construct_tx_to_key(events, tx, blk_head, acc_from, to, amount, fee, 0);
936  events.push_back(tx);
937  return tx;
938 }
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, rct::RangeProofType range_proof_type, int bp_version)
Definition: chaingen.cpp:872
Here is the call graph for this function:
Here is the caller graph for this function:

◆ current_difficulty_window()

uint64_t current_difficulty_window ( const boost::optional< uint8_t > &  hf_ver = boost::none)
inline

Definition at line 410 of file chaingen.h.

410 { return !hf_ver || hf_ver.get() <= 1 ? DIFFICULTY_TARGET : DIFFICULTY_TARGET_V6; }
#define DIFFICULTY_TARGET_V6
#define DIFFICULTY_TARGET
Here is the caller graph for this function:

◆ do_replay_events()

template<class t_test_class >
bool do_replay_events ( std::vector< test_event_entry > &  events)
inline

Definition at line 774 of file chaingen.h.

775 {
776  cryptonote::core core(nullptr);
777  bool ret = do_replay_events_get_core<t_test_class>(events, &core);
778  core.deinit();
779  return ret;
780 }
handles core cryptonote functionality
Here is the call graph for this function:

◆ do_replay_events_get_core()

template<class t_test_class >
bool do_replay_events_get_core ( std::vector< test_event_entry > &  events,
cryptonote::core core 
)
inline

Definition at line 706 of file chaingen.h.

707 {
708  boost::program_options::options_description desc("Allowed options");
710  boost::program_options::variables_map vm;
711  bool r = command_line::handle_error_helper(desc, [&]()
712  {
713  boost::program_options::store(boost::program_options::basic_parsed_options<char>(&desc), vm);
714  boost::program_options::notify(vm);
715  return true;
716  });
717  if (!r)
718  return false;
719 
720  auto & c = *core;
721 
722  // FIXME: make sure that vm has arg_testnet_on set to true or false if
723  // this test needs for it to be so.
725 
726  // Hardforks can be specified in events.
727  v_hardforks_t hardforks;
728  cryptonote::test_options test_options_tmp{nullptr, 0};
729  const cryptonote::test_options * test_options_ = &gto.test_options;
730  if (extract_hard_forks(events, hardforks)){
731  hardforks.push_back(std::make_pair((uint8_t)0, (uint64_t)0)); // terminator
732  test_options_tmp.hard_forks = hardforks.data();
733  test_options_ = &test_options_tmp;
734  }
735 
736  if (!c.init(vm, test_options_))
737  {
738  MERROR("Failed to init core");
739  return false;
740  }
741  c.get_blockchain_storage().get_db().set_batch_transactions(true);
742 
743  // start with a clean pool
744  std::vector<crypto::hash> pool_txs;
745  if (!c.get_pool_transaction_hashes(pool_txs))
746  {
747  MERROR("Failed to flush txpool");
748  return false;
749  }
750  c.get_blockchain_storage().flush_txes_from_pool(pool_txs);
751 
752  t_test_class validator;
753  bool ret = replay_events_through_core<t_test_class>(c, events, validator);
754 // c.deinit();
755  return ret;
756 }
#define MERROR(x)
Definition: misc_log_ex.h:73
bool extract_hard_forks(const std::vector< test_event_entry > &events, v_hardforks_t &hard_forks)
unsigned char uint8_t
Definition: stdint.h:124
bool handle_error_helper(const boost::program_options::options_description &desc, F parser)
Definition: command_line.h:237
unsigned __int64 uint64_t
Definition: stdint.h:136
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
const cryptonote::test_options test_options
Definition: chaingen.h:699
const std::pair< uint8_t, uint64_t > * hard_forks
std::vector< std::pair< uint8_t, uint64_t > > v_hardforks_t
Definition: chaingen.h:137
Here is the call graph for this function:

◆ do_replay_file()

template<class t_test_class >
bool do_replay_file ( const std::string &  filename)
inline

Definition at line 783 of file chaingen.h.

784 {
785  std::vector<test_event_entry> events;
786  if (!tools::unserialize_obj_from_file(events, filename))
787  {
788  MERROR("Failed to deserialize data from file: ");
789  return false;
790  }
791  return do_replay_events<t_test_class>(events);
792 }
#define MERROR(x)
Definition: misc_log_ex.h:73
bool unserialize_obj_from_file(t_object &obj, const std::string &file_path)
Here is the call graph for this function:

◆ dump_data()

std::string dump_data ( const cryptonote::transaction tx)

Definition at line 617 of file chaingen.cpp.

618 {
619  ostringstream ss;
620  ss << "msg: " << dump_keys(tx.rct_signatures.message.bytes)
621  << ", vin: ";
622 
623  for(auto & in : tx.vin){
624  if (typeid(txin_to_key) == in.type()){
625  auto tk = boost::get<txin_to_key>(in);
626  std::vector<uint64_t> full_off;
627  int64_t last = -1;
628 
629  ss << " i: " << tk.amount << " [";
630  for(auto ix : tk.key_offsets){
631  ss << ix << ", ";
632  if (last == -1){
633  last = ix;
634  full_off.push_back(ix);
635  } else {
636  last += ix;
637  full_off.push_back((uint64_t)last);
638  }
639  }
640 
641  ss << "], full: [";
642  for(auto ix : full_off){
643  ss << ix << ", ";
644  }
645  ss << "]; ";
646 
647  } else if (typeid(txin_gen) == in.type()){
648  ss << " h: " << boost::get<txin_gen>(in).height << ", ";
649  } else {
650  ss << " ?, ";
651  }
652  }
653 
654  ss << ", mixring: \n";
655  for (const auto & row : tx.rct_signatures.mixRing){
656  for(auto cur : row){
657  ss << " (" << dump_keys(cur.dest.bytes) << ", " << dump_keys(cur.mask.bytes) << ")\n ";
658  }
659  ss << "; ";
660  }
661 
662  return ss.str();
663 }
uint64_t height
Definition: blockchain.cpp:91
unsigned __int64 uint64_t
Definition: stdint.h:136
unsigned char bytes[32]
Definition: rctTypes.h:86
signed __int64 int64_t
Definition: stdint.h:135
std::string dump_keys(T *buff32)
Definition: chaingen.h:271
ctkeyM mixRing
Definition: rctTypes.h:243
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_keys()

template<typename T >
std::string dump_keys ( T buff32)

Definition at line 271 of file chaingen.h.

272 {
273  std::ostringstream ss;
274  char buff[10];
275 
276  ss << "[";
277  for(int i = 0; i < 32; i++)
278  {
279  snprintf(buff, 10, "0x%02x", ((uint8_t)buff32[i] & 0xff));
280  ss << buff;
281  if (i < 31)
282  ss << ",";
283  }
284  ss << "]";
285  return ss.str();
286 }
unsigned char uint8_t
Definition: stdint.h:124
Here is the caller graph for this function:

◆ extract_hard_forks()

bool extract_hard_forks ( const std::vector< test_event_entry > &  events,
v_hardforks_t hard_forks 
)
Here is the caller graph for this function:

◆ fill_nonce()

void fill_nonce ( cryptonote::block blk,
const cryptonote::difficulty_type diffic,
uint64_t  height 
)

Definition at line 797 of file chaingen.cpp.

798 {
799  blk.nonce = 0;
800  while (!miner::find_nonce_for_given_block(blk, diffic, height))
801  blk.timestamp++;
802 }
uint64_t height
Definition: blockchain.cpp:91
Here is the caller graph for this function:

◆ fill_tx_destinations() [1/3]

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 at line 766 of file chaingen.cpp.

770 {
771  std::vector<tx_destination_entry> destinations_pure;
772  fill_tx_destinations(from, to, amount, fee, sources, destinations, destinations_pure, always_change);
773 }
void fill_tx_destinations(const var_addr_t &from, const std::vector< tx_destination_entry > &dests, uint64_t fee, const std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, bool always_change)
Definition: chaingen.cpp:720
Here is the call graph for this function:

◆ fill_tx_destinations() [2/3]

void fill_tx_destinations ( const var_addr_t from,
const std::vector< cryptonote::tx_destination_entry > &  dests,
uint64_t  fee,
const std::vector< cryptonote::tx_source_entry > &  sources,
std::vector< cryptonote::tx_destination_entry > &  destinations,
bool  always_change 
)

Definition at line 720 of file chaingen.cpp.

726 {
727  destinations.clear();
728  uint64_t amount = sum_amount(dests);
729  std::copy(dests.begin(), dests.end(), std::back_inserter(destinations));
730 
731  tx_destination_entry de_change;
732  uint64_t cache_back = get_inputs_amount(sources) - (amount + fee);
733 
734  if (cache_back > 0 || always_change) {
735  if (!fill_tx_destination(de_change, get_address(from), cache_back <= 0 ? 0 : cache_back))
736  throw std::runtime_error("couldn't fill transaction cache back destination");
737  destinations.push_back(de_change);
738  }
739 }
uint64_t sum_amount(const std::vector< tx_destination_entry > &destinations)
Definition: chaingen.cpp:700
void copy(key &AA, const key &A)
Definition: rctOps.h:79
bool fill_tx_destination(tx_destination_entry &de, const cryptonote::account_public_address &to, uint64_t amount)
Definition: chaingen.cpp:456
unsigned __int64 uint64_t
Definition: stdint.h:136
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:665
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_tx_destinations() [3/3]

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,
std::vector< cryptonote::tx_destination_entry > &  destinations_pure,
bool  always_change = false 
)

Definition at line 741 of file chaingen.cpp.

747 {
748  destinations.clear();
749 
751  if (!fill_tx_destination(de, to, amount))
752  throw std::runtime_error("couldn't fill transaction destination");
753  destinations.push_back(de);
754  destinations_pure.push_back(de);
755 
756  tx_destination_entry de_change;
757  uint64_t cache_back = get_inputs_amount(sources) - (amount + fee);
758 
759  if (cache_back > 0 || always_change) {
760  if (!fill_tx_destination(de_change, get_address(from), cache_back <= 0 ? 0 : cache_back))
761  throw std::runtime_error("couldn't fill transaction cache back destination");
762  destinations.push_back(de_change);
763  }
764 }
bool fill_tx_destination(tx_destination_entry &de, const cryptonote::account_public_address &to, uint64_t amount)
Definition: chaingen.cpp:456
unsigned __int64 uint64_t
Definition: stdint.h:136
cryptonote::account_public_address get_address(const var_addr_t &inp)
Definition: chaingen.cpp:665
Here is the call graph for this function:

◆ fill_tx_sources_and_destinations() [1/2]

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 at line 775 of file chaingen.cpp.

779 {
780  sources.clear();
781  destinations.clear();
782 
783  if (!fill_tx_sources(sources, events, blk_head, from, amount + fee, nmix))
784  throw std::runtime_error("couldn't fill transaction sources");
785 
786  fill_tx_destinations(from, to, amount, fee, sources, destinations, false);
787 }
bool fill_tx_sources(std::vector< tx_source_entry > &sources, const std::vector< test_event_entry > &events, const block &blk_head, const cryptonote::account_base &from, uint64_t amount, size_t nmix)
Definition: chaingen.cpp:396
void fill_tx_destinations(const var_addr_t &from, const std::vector< tx_destination_entry > &dests, uint64_t fee, const std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, bool always_change)
Definition: chaingen.cpp:720
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_tx_sources_and_destinations() [2/2]

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_base 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 at line 789 of file chaingen.cpp.

793 {
794  fill_tx_sources_and_destinations(events, blk_head, from, to.get_keys().m_account_address, amount, fee, nmix, sources, destinations);
795 }
void fill_tx_sources_and_destinations(const std::vector< test_event_entry > &events, const 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< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations)
Definition: chaingen.cpp:775
const account_keys & get_keys() const
Definition: account.cpp:264
account_public_address m_account_address
Definition: account.h:43
Here is the call graph for this function:

◆ find_block_chain() [1/2]

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 at line 1072 of file chaingen.cpp.

1072  {
1073  std::unordered_map<crypto::hash, const block*> block_index;
1074  BOOST_FOREACH(const test_event_entry& ev, events)
1075  {
1076  if (typeid(block) == ev.type())
1077  {
1078  const block* blk = &boost::get<block>(ev);
1079  block_index[get_block_hash(*blk)] = blk;
1080  }
1081  else if (typeid(transaction) == ev.type())
1082  {
1083  const transaction& tx = boost::get<transaction>(ev);
1084  mtx[get_transaction_hash(tx)] = &tx;
1085  }
1086  }
1087 
1088  bool b_success = false;
1089  crypto::hash id = head;
1090  for (auto it = block_index.find(id); block_index.end() != it; it = block_index.find(id))
1091  {
1092  blockchain.push_back(*it->second);
1093  id = it->second->prev_id;
1094  if (null_hash == id)
1095  {
1096  b_success = true;
1097  break;
1098  }
1099  }
1100  reverse(blockchain.begin(), blockchain.end());
1101 
1102  return b_success;
1103 }
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
crypto::hash get_transaction_hash(const transaction &t)
struct rule_list head
crypto::hash get_block_hash(uint64_t height)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_block_chain() [2/2]

bool find_block_chain ( const std::vector< test_event_entry > &  events,
std::vector< const cryptonote::block *> &  blockchain,
map_hash2tx_t mtx,
const crypto::hash head 
)

Definition at line 1105 of file chaingen.cpp.

1105  {
1106  std::unordered_map<crypto::hash, const block*> block_index;
1107  BOOST_FOREACH(const test_event_entry& ev, events)
1108  {
1109  if (typeid(block) == ev.type())
1110  {
1111  const block* blk = &boost::get<block>(ev);
1112  block_index[get_block_hash(*blk)] = blk;
1113  }
1114  else if (typeid(transaction) == ev.type())
1115  {
1116  const transaction& tx = boost::get<transaction>(ev);
1117  mtx[get_transaction_hash(tx)] = &tx;
1118  }
1119  }
1120 
1121  bool b_success = false;
1122  crypto::hash id = head;
1123  for (auto it = block_index.find(id); block_index.end() != it; it = block_index.find(id))
1124  {
1125  blockchain.push_back(it->second);
1126  id = it->second->prev_id;
1127  if (null_hash == id)
1128  {
1129  b_success = true;
1130  break;
1131  }
1132  }
1133  reverse(blockchain.begin(), blockchain.end());
1134  return b_success;
1135 }
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
crypto::hash get_transaction_hash(const transaction &t)
struct rule_list head
crypto::hash get_block_hash(uint64_t height)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ get_address() [1/5]

cryptonote::account_public_address get_address ( const var_addr_t inp)

Definition at line 665 of file chaingen.cpp.

666 {
667  if (typeid(cryptonote::account_public_address) == inp.type()){
668  return boost::get<cryptonote::account_public_address>(inp);
669  } else if(typeid(cryptonote::account_keys) == inp.type()){
670  return boost::get<cryptonote::account_keys>(inp).m_account_address;
671  } else if (typeid(cryptonote::account_base) == inp.type()){
672  return boost::get<cryptonote::account_base>(inp).get_keys().m_account_address;
673  } else if (typeid(cryptonote::tx_destination_entry) == inp.type()){
674  return boost::get<cryptonote::tx_destination_entry>(inp).addr;
675  } else {
676  throw std::runtime_error("Unexpected type");
677  }
678 }
const char * inp
Definition: hmac_keccak.cpp:40
Here is the caller graph for this function:

◆ get_address() [2/5]

Definition at line 680 of file chaingen.cpp.

681 {
682  return inp;
683 }
const char * inp
Definition: hmac_keccak.cpp:40

◆ get_address() [3/5]

Definition at line 685 of file chaingen.cpp.

686 {
687  return inp.m_account_address;
688 }
const char * inp
Definition: hmac_keccak.cpp:40

◆ get_address() [4/5]

Definition at line 690 of file chaingen.cpp.

691 {
692  return inp.get_keys().m_account_address;
693 }
const char * inp
Definition: hmac_keccak.cpp:40

◆ get_address() [5/5]

Definition at line 695 of file chaingen.cpp.

696 {
697  return inp.addr;
698 }
const char * inp
Definition: hmac_keccak.cpp:40

◆ get_balance()

uint64_t get_balance ( const cryptonote::account_base addr,
const std::vector< cryptonote::block > &  blockchain,
const map_hash2tx_t mtx 
)

Definition at line 940 of file chaingen.cpp.

940  {
941  uint64_t res = 0;
942  std::map<uint64_t, std::vector<output_index> > outs;
943  std::map<uint64_t, std::vector<size_t> > outs_mine;
944 
945  map_hash2tx_t confirmed_txs;
946  get_confirmed_txs(blockchain, mtx, confirmed_txs);
947 
948  if (!init_output_indices(outs, outs_mine, blockchain, confirmed_txs, addr))
949  return false;
950 
951  if (!init_spent_output_indices(outs, outs_mine, blockchain, confirmed_txs, addr))
952  return false;
953 
954  BOOST_FOREACH (const map_output_t::value_type &o, outs_mine) {
955  for (size_t i = 0; i < o.second.size(); ++i) {
956  if (outs[o.first][o.second[i]].spent)
957  continue;
958 
959  res += outs[o.first][o.second[i]].amount;
960  }
961  }
962 
963  return res;
964 }
const char * res
Definition: hmac_keccak.cpp:41
bool init_output_indices(map_output_idx_t &outs, std::map< uint64_t, std::vector< size_t > > &outs_mine, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, const cryptonote::account_base &from)
Definition: chaingen.cpp:284
bool init_spent_output_indices(map_output_idx_t &outs, map_output_t &outs_mine, const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, const cryptonote::account_base &from)
Definition: chaingen.cpp:327
void get_confirmed_txs(const std::vector< cryptonote::block > &blockchain, const map_hash2tx_t &mtx, map_hash2tx_t &confirmed_txs)
Definition: chaingen.cpp:984
std::unordered_map< crypto::hash, const cryptonote::transaction * > map_hash2tx_t
Definition: chaingen.h:163
unsigned __int64 uint64_t
Definition: stdint.h:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_confirmed_txs()

void get_confirmed_txs ( const std::vector< cryptonote::block > &  blockchain,
const map_hash2tx_t mtx,
map_hash2tx_t confirmed_txs 
)

Definition at line 984 of file chaingen.cpp.

985 {
986  std::unordered_set<crypto::hash> confirmed_hashes;
987  BOOST_FOREACH(const block& blk, blockchain)
988  {
989  BOOST_FOREACH(const crypto::hash& tx_hash, blk.tx_hashes)
990  {
991  confirmed_hashes.insert(tx_hash);
992  }
993  }
994 
995  BOOST_FOREACH(const auto& tx_pair, mtx)
996  {
997  if (0 != confirmed_hashes.count(tx_pair.first))
998  {
999  confirmed_txs.insert(tx_pair);
1000  }
1001  }
1002 }
std::vector< crypto::hash > tx_hashes
POD_CLASS hash
Definition: hash.h:50
Here is the caller graph for this function:

◆ get_head_block()

cryptonote::block get_head_block ( const std::vector< test_event_entry > &  events)

Definition at line 1058 of file chaingen.cpp.

1059 {
1060  for(auto it = events.rbegin(); it != events.rend(); ++it)
1061  {
1062  auto &ev = *it;
1063  if (typeid(block) == ev.type())
1064  {
1065  return boost::get<block>(ev);
1066  }
1067  }
1068 
1069  throw std::runtime_error("No block event");
1070 }
Here is the caller graph for this function:

◆ get_test_difficulty()

cryptonote::difficulty_type get_test_difficulty ( const boost::optional< uint8_t > &  hf_ver = boost::none)
inline

Definition at line 409 of file chaingen.h.

409 {return !hf_ver || hf_ver.get() <= 1 ? 1 : 2;}
Here is the caller graph for this function:

◆ num_blocks()

uint64_t num_blocks ( const std::vector< test_event_entry > &  events)

Definition at line 1044 of file chaingen.cpp.

1045 {
1046  uint64_t res = 0;
1047  BOOST_FOREACH(const test_event_entry& ev, events)
1048  {
1049  if (typeid(block) == ev.type())
1050  {
1051  res += 1;
1052  }
1053  }
1054 
1055  return res;
1056 }
const char * res
Definition: hmac_keccak.cpp:41
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
unsigned __int64 uint64_t
Definition: stdint.h:136
Here is the caller graph for this function:

◆ replay_events_through_core()

template<class t_test_class >
bool replay_events_through_core ( cryptonote::core cr,
const std::vector< test_event_entry > &  events,
t_test_class &  validator 
)
inline

Definition at line 666 of file chaingen.h.

667 {
668  return replay_events_through_core_plain(cr, events, validator, true);
669 }
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:672
Here is the call graph for this function:

◆ replay_events_through_core_plain()

template<class t_test_class >
bool replay_events_through_core_plain ( cryptonote::core cr,
const std::vector< test_event_entry > &  events,
t_test_class &  validator,
bool  reinit = true 
)
inline

Definition at line 672 of file chaingen.h.

673 {
674  TRY_ENTRY();
675 
676  //init core here
677  if (reinit) {
678  CHECK_AND_ASSERT_MES(typeid(cryptonote::block) == events[0].type(), false,
679  "First event must be genesis block creation");
680  cr.set_genesis_block(boost::get<cryptonote::block>(events[0]));
681  }
682 
683  bool r = true;
684  push_core_event_visitor<t_test_class> visitor(cr, events, validator);
685  for(size_t i = 1; i < events.size() && r; ++i)
686  {
687  visitor.event_index(i);
688  r = boost::apply_visitor(visitor, events[i]);
689  }
690 
691  return r;
692 
693  CATCH_ENTRY_L0("replay_events_through_core", false);
694 }
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
Definition: misc_log_ex.h:181
#define TRY_ENTRY()
Definition: misc_log_ex.h:151
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
#define CATCH_ENTRY_L0(lacation, return_val)
Definition: misc_log_ex.h:165
Here is the call graph for this function:
Here is the caller graph for this function:

◆ replay_events_through_core_validate()

template<class t_test_class >
bool replay_events_through_core_validate ( std::vector< test_event_entry > &  events,
cryptonote::core c 
)
inline

Definition at line 759 of file chaingen.h.

760 {
761  std::vector<crypto::hash> pool_txs;
762  if (!c.get_pool_transaction_hashes(pool_txs))
763  {
764  MERROR("Failed to flush txpool");
765  return false;
766  }
768 
769  t_test_class validator;
770  return replay_events_through_core_plain<t_test_class>(c, events, validator, false);
771 }
#define MERROR(x)
Definition: misc_log_ex.h:73
bool flush_txes_from_pool(const std::vector< crypto::hash > &txids)
remove transactions from the transaction pool (if present)
Blockchain & get_blockchain_storage()
gets the Blockchain instance
bool get_pool_transaction_hashes(std::vector< crypto::hash > &txs, bool include_unrelayed_txes=true) const
get a list of all transactions in the pool
Here is the call graph for this function:

◆ sum_amount() [1/2]

uint64_t sum_amount ( const std::vector< cryptonote::tx_destination_entry > &  destinations)

Definition at line 700 of file chaingen.cpp.

701 {
702  uint64_t amount = 0;
703  for(auto & cur : destinations){
704  amount += cur.amount;
705  }
706 
707  return amount;
708 }
unsigned __int64 uint64_t
Definition: stdint.h:136
Here is the caller graph for this function:

◆ sum_amount() [2/2]

uint64_t sum_amount ( const std::vector< cryptonote::tx_source_entry > &  sources)

Definition at line 710 of file chaingen.cpp.

711 {
712  uint64_t amount = 0;
713  for(auto & cur : sources){
714  amount += cur.amount;
715  }
716 
717  return amount;
718 }
unsigned __int64 uint64_t
Definition: stdint.h:136

◆ trim_block_chain() [1/2]

bool trim_block_chain ( std::vector< cryptonote::block > &  blockchain,
const crypto::hash tail 
)

Definition at line 1004 of file chaingen.cpp.

1004  {
1005  size_t cut = 0;
1006  bool found = true;
1007 
1008  for(size_t i = 0; i < blockchain.size(); ++i){
1009  crypto::hash chash = get_block_hash(blockchain[i]);
1010  if (chash == tail){
1011  cut = i;
1012  found = true;
1013  break;
1014  }
1015  }
1016 
1017  if (found && cut > 0){
1018  blockchain.erase(blockchain.begin(), blockchain.begin() + cut);
1019  }
1020 
1021  return found;
1022 }
crypto::hash chash
Definition: main.cpp:47
crypto::hash get_block_hash(uint64_t height)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ trim_block_chain() [2/2]

bool trim_block_chain ( std::vector< const cryptonote::block *> &  blockchain,
const crypto::hash tail 
)

Definition at line 1024 of file chaingen.cpp.

1024  {
1025  size_t cut = 0;
1026  bool found = true;
1027 
1028  for(size_t i = 0; i < blockchain.size(); ++i){
1029  crypto::hash chash = get_block_hash(*blockchain[i]);
1030  if (chash == tail){
1031  cut = i;
1032  found = true;
1033  break;
1034  }
1035  }
1036 
1037  if (found && cut > 0){
1038  blockchain.erase(blockchain.begin(), blockchain.begin() + cut);
1039  }
1040 
1041  return found;
1042 }
crypto::hash chash
Definition: main.cpp:47
crypto::hash get_block_hash(uint64_t height)
POD_CLASS hash
Definition: hash.h:50
Here is the call graph for this function:

◆ VARIANT_TAG() [1/6]

VARIANT_TAG ( binary_archive  ,
callback_entry  ,
0xcb   
)

◆ VARIANT_TAG() [2/6]

VARIANT_TAG ( binary_archive  ,
cryptonote::account_base  ,
0xcc   
)

◆ VARIANT_TAG() [3/6]

VARIANT_TAG ( binary_archive  ,
serialized_block  ,
0xcd   
)

◆ VARIANT_TAG() [4/6]

VARIANT_TAG ( binary_archive  ,
serialized_transaction  ,
0xce   
)

◆ VARIANT_TAG() [5/6]

VARIANT_TAG ( binary_archive  ,
event_visitor_settings  ,
0xcf   
)

◆ VARIANT_TAG() [6/6]

VARIANT_TAG ( binary_archive  ,
event_replay_settings  ,
0xda   
)