Monero
cryptonote_core.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2022, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 
33 #include <ctime>
34 
35 #include <boost/function.hpp>
36 #include <boost/program_options/options_description.hpp>
37 #include <boost/program_options/variables_map.hpp>
38 
39 #include "cryptonote_basic/fwd.h"
43 #include "common/download.h"
44 #include "common/command_line.h"
45 #include "tx_pool.h"
46 #include "blockchain.h"
47 #include "cryptonote_basic/miner.h"
49 #include "warnings.h"
50 #include "crypto/hash.h"
51 #include "span.h"
52 #include "rpc/fwd.h"
53 
56 
58 
59 namespace cryptonote
60 {
61  struct test_options {
62  const std::pair<uint8_t, uint64_t> *hard_forks;
64  };
65 
74 
75  /************************************************************************/
76  /* */
77  /************************************************************************/
78 
86  class core final: public i_miner_handler, public i_core_events
87  {
88  public:
89 
97  core(i_cryptonote_protocol* pprotocol);
98 
106 
114  bool on_idle();
115 
129  bool handle_incoming_tx(const blobdata& tx_blob, tx_verification_context& tvc, relay_method tx_relay, bool relayed);
130 
151  bool handle_single_incoming_block(const blobdata& block_blob,
152  const block *b,
154  pool_supplement& extra_block_txs,
155  bool update_miner_blocktemplate = true);
156 
179  bool handle_incoming_block(const blobdata& block_blob, const block *b,
181  bool update_miner_blocktemplate = true);
182 
183  bool handle_incoming_block(const blobdata& block_blob, const block *b,
184  block_verification_context& bvc, pool_supplement& extra_block_txs,
185  bool update_miner_blocktemplate = true);
186 
192  bool prepare_handle_incoming_blocks(const std::vector<block_complete_entry> &blocks_entry, std::vector<block> &blocks);
193 
199  bool cleanup_handle_incoming_blocks(bool force_sync = false);
200 
208  bool check_incoming_block_size(const blobdata& block_blob) const;
209 
216 
217  //-------------------- i_miner_handler -----------------------
218 
231  virtual bool handle_block_found(block& b, block_verification_context &bvc) override;
232 
238  virtual bool get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash) override;
239  virtual bool get_block_template(block& b, const crypto::hash *prev_block, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash);
240 
246  bool get_miner_data(uint8_t& major_version, uint64_t& height, crypto::hash& prev_id, crypto::hash& seed_hash, difficulty_type& difficulty, uint64_t& median_weight, uint64_t& already_generated_coins, std::vector<tx_block_template_backlog_entry>& tx_backlog);
247 
253 
254 
260  miner& get_miner(){return m_miner;}
261 
267  const miner& get_miner()const{return m_miner;}
268 
277  static void init_options(boost::program_options::options_description& desc);
278 
292  bool init(const boost::program_options::variables_map& vm, const test_options *test_options = NULL, const GetCheckpointsCallback& get_checkpoints = nullptr, bool allow_dns = true);
293 
299  bool set_genesis_block(const block& b);
300 
308  bool deinit();
309 
313  void test_drop_download();
314 
320  void test_drop_download_height(uint64_t height);
321 
327  bool get_test_drop_download() const;
328 
337  bool get_test_drop_download_height() const;
338 
345 
352  void get_blockchain_top(uint64_t& height, crypto::hash& top_id) const;
353 
359  bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks, std::vector<cryptonote::blobdata>& txs) const;
360 
366  bool get_blocks(uint64_t start_offset, size_t count, std::vector<std::pair<cryptonote::blobdata,block>>& blocks) const;
367 
373  bool get_blocks(uint64_t start_offset, size_t count, std::vector<block>& blocks) const;
374 
380  template<class t_ids_container, class t_blocks_container, class t_missed_container>
381  bool get_blocks(const t_ids_container& block_ids, t_blocks_container& blocks, t_missed_container& missed_bs) const
382  {
383  return m_blockchain_storage.get_blocks(block_ids, blocks, missed_bs);
384  }
385 
392 
398  bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<cryptonote::blobdata>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
399 
405  bool get_split_transactions_blobs(const std::vector<crypto::hash>& txs_ids, std::vector<std::tuple<crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata>>& txs, std::vector<crypto::hash>& missed_txs) const;
406 
412  bool get_transactions(const std::vector<crypto::hash>& txs_ids, std::vector<transaction>& txs, std::vector<crypto::hash>& missed_txs, bool pruned = false) const;
413 
419  bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const;
420 
426  bool get_alternative_blocks(std::vector<block>& blocks) const;
427 
433  size_t get_alternative_blocks_count() const;
434 
441 
447  const checkpoints& get_checkpoints() const;
448 
454  void set_checkpoints(checkpoints&& chk_pts);
455 
461  void set_checkpoints_file_path(const std::string& path);
462 
468  void set_enforce_dns_checkpoints(bool enforce_dns);
469 
475  void disable_dns_checkpoints(bool disable = true) { m_disable_dns_checkpoints = disable; }
476 
482  bool pool_has_tx(const crypto::hash &txid) const;
483 
490  bool get_pool_transactions(std::vector<transaction>& txs, bool include_sensitive_txes = false) const;
491 
498  bool get_txpool_backlog(std::vector<tx_backlog_entry>& backlog, bool include_sensitive_txes = false) const;
499 
506  bool get_pool_transaction_hashes(std::vector<crypto::hash>& txs, bool include_sensitive_txes = false) const;
507 
514  bool get_pool_transactions_info(const std::vector<crypto::hash>& txids, std::vector<std::pair<crypto::hash, tx_memory_pool::tx_details>>& txs, bool include_sensitive_txes = false) const;
515 
523  bool get_pool_info(time_t start_time, bool include_sensitive_txes, size_t max_tx_count, std::vector<std::pair<crypto::hash, tx_memory_pool::tx_details>>& added_txs, std::vector<crypto::hash>& remaining_added_txids, std::vector<crypto::hash>& removed_txs, bool& incremental) const;
524 
531  bool get_pool_transaction_stats(struct txpool_stats& stats, bool include_sensitive_txes = false) const;
532 
538  bool get_pool_transaction(const crypto::hash& id, cryptonote::blobdata& tx, relay_category tx_category) const;
539 
546  bool get_pool_transactions_and_spent_keys_info(std::vector<tx_info>& tx_infos, std::vector<spent_key_image_info>& key_image_infos, bool include_sensitive_txes = false) const;
547 
553  bool get_pool_for_rpc(std::vector<cryptonote::rpc::tx_in_pool>& tx_infos, cryptonote::rpc::key_images_with_tx_hashes& key_image_infos) const;
554 
561  size_t get_pool_transactions_count(bool include_sensitive_txes = false) const;
562 
568  size_t get_blockchain_total_transactions() const;
569 
575  bool have_block_unlocked(const crypto::hash& id, int *where = NULL) const;
576  bool have_block(const crypto::hash& id, int *where = NULL) const;
577 
583  bool get_short_chain_history(std::list<crypto::hash>& ids) const;
584 
590  bool find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const;
591 
597  bool find_blockchain_supplement(const uint64_t req_start_block, const std::list<crypto::hash>& qblock_ids, std::vector<std::pair<std::pair<cryptonote::blobdata, crypto::hash>, std::vector<std::pair<crypto::hash, cryptonote::blobdata> > > >& blocks, uint64_t& total_height, uint64_t& start_height, bool pruned, bool get_miner_tx_hash, size_t max_block_count, size_t max_tx_count) const;
598 
604  bool get_tx_outputs_gindexs(const crypto::hash& tx_id, std::vector<uint64_t>& indexs) const;
605  bool get_tx_outputs_gindexs(const crypto::hash& tx_id, size_t n_txes, std::vector<std::vector<uint64_t>>& indexs) const;
606 
612  crypto::hash get_tail_id() const;
613 
620 
627 
633  bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, uint64_t &start_height, std::vector<uint64_t> &distribution, uint64_t &base) const;
634 
640  void pause_mine();
641 
647  void resume_mine();
648 
655 
662 
668  std::string print_pool(bool short_format) const;
669 
675  virtual bool is_synchronized() const final;
676 
682  void on_synchronized();
683 
689  void safesyncmode(const bool onoff);
690 
696  void set_target_blockchain_height(uint64_t target_blockchain_height);
697 
704 
711 
718 
725 
732 
737  std::time_t get_start_time() const;
738 
749  bool update_checkpoints(const bool skip_dns = false);
750 
757  void graceful_exit();
758 
764  void stop();
765 
772 
783  bool are_key_images_spent(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
784 
793  bool are_key_images_spent_in_pool(const std::vector<crypto::key_image>& key_im, std::vector<bool> &spent) const;
794 
800  size_t get_block_sync_size(uint64_t height) const;
801 
807  std::pair<boost::multiprecision::uint128_t, boost::multiprecision::uint128_t> get_coinbase_tx_sum(const uint64_t start_offset, const size_t count);
808 
814  network_type get_nettype() const { return m_nettype; };
815 
824  bool is_update_available() const { return m_update_available; }
825 
831  uint64_t prevalidate_block_hashes(uint64_t height, const std::vector<crypto::hash> &hashes, const std::vector<uint64_t> &weights);
832 
838  uint64_t get_free_space() const;
839 
845  bool offline() const { return m_offline; }
846 
853 
861  bool prune_blockchain(uint32_t pruning_seed = 0);
862 
869 
876 
882  bool is_within_compiled_block_hash_area(uint64_t height) const;
883 
887  bool has_block_weights(uint64_t height, uint64_t nblocks) const;
888 
892  void flush_invalid_blocks();
893 
901  bool get_txpool_complement(const std::vector<crypto::hash> &hashes, std::vector<cryptonote::blobdata> &txes);
902 
920  static bool check_tx_semantic(const transaction& tx, tx_verification_context& tvc,
921  uint8_t hf_version);
922 
930  static bool check_tx_inputs_keyimages_diff(const transaction& tx);
931 
940  static bool check_tx_inputs_ring_members_diff(const transaction& tx, const uint8_t hf_version);
941 
950  static bool check_tx_inputs_keyimages_domain(const transaction& tx);
951 
952  private:
953 
964  bool add_new_tx(transaction& tx, const crypto::hash& tx_hash, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context& tvc, relay_method tx_relay, bool relayed);
965 
981 
988  pool_supplement& extra_block_txs);
989 
997  bool load_state_data();
998 
1007 
1015  bool handle_command_line(const boost::program_options::variables_map& vm);
1016 
1023 
1029  bool notify_txpool_event(const epee::span<const cryptonote::blobdata> tx_blobs, epee::span<const crypto::hash> tx_hashes, epee::span<const cryptonote::transaction> txs, const std::vector<bool> &just_broadcasted) const;
1030 
1036  bool check_updates();
1037 
1043  bool check_disk_space();
1044 
1050  bool check_block_rate();
1051 
1057  bool recalculate_difficulties();
1058 
1059  bool m_test_drop_download = true;
1060 
1062 
1065 
1067 
1069 
1070  //m_miner and m_miner_addres are probably temporary here
1072 
1074 
1076 
1084 
1085  std::atomic<bool> m_starter_message_showed;
1086 
1088 
1090 
1091  std::atomic<bool> m_update_available;
1092 
1096 
1097  std::atomic_flag m_checkpoints_updating;
1099 
1101 
1102  time_t start_time;
1103 
1104  enum {
1110 
1113  boost::mutex m_update_mutex;
1114 
1116 
1117  std::shared_ptr<tools::Notify> m_block_rate_notify;
1118  };
1119 }
1120 
const char * res
Definition: hmac_keccak.cpp:42
const command_line::arg_descriptor< bool > arg_sync_pruned_blocks
Definition: cryptonote_core.cpp:126
bool get_test_drop_download() const
gets whether or not to drop blocks (for testing)
Definition: cryptonote_core.cpp:756
def difficulty()
Definition: gen_wide_data.py:11
bool have_block_unlocked(const crypto::hash &id, int *where=NULL) const
Definition: cryptonote_core.cpp:1478
uint8_t get_hard_fork_version(uint64_t height) const
return the hard fork version for a given block height
Definition: cryptonote_core.cpp:1609
void stop()
stops the daemon running
Definition: cryptonote_core.cpp:297
void pause_mine()
Definition: cryptonote_core.cpp:1246
bool get_pool_transaction(const crypto::hash &id, cryptonote::blobdata &tx, relay_category tx_category) const
get a specific transaction from the pool
Definition: cryptonote_core.cpp:1516
uint64_t m_test_drop_download_height
height under which to drop incoming blocks, if doing so
Definition: cryptonote_core.h:1061
Blockchain m_blockchain_storage
Blockchain instance.
Definition: cryptonote_core.h:1064
std::string m_config_folder
folder to look in for configs and other files
Definition: cryptonote_core.h:1073
void test_drop_download_height(uint64_t height)
sets to drop blocks downloaded below a certain height
Definition: cryptonote_core.cpp:751
PUSH_WARNINGS
Definition: hash-ops.h:53
crypto::hash get_tail_id() const
get the hash of the most recent block on the blockchain
Definition: cryptonote_core.cpp:1463
bool deinit()
performs safe shutdown steps for core and core components
Definition: cryptonote_core.cpp:738
epee::math_helper::once_a_time_seconds< 60 *60 *24 *7, false > m_diff_recalc_interval
interval for recalculating difficulties
Definition: cryptonote_core.h:1083
epee::math_helper::once_a_time_seconds< 60 *60 *12, true > m_check_updates_interval
interval for checking for new versions
Definition: cryptonote_core.h:1079
std::pair< boost::multiprecision::uint128_t, boost::multiprecision::uint128_t > get_coinbase_tx_sum(const uint64_t start_offset, const size_t count)
get the sum of coinbase tx amounts between blocks
Definition: cryptonote_core.cpp:983
bool get_pool_transactions(std::vector< transaction > &txs, bool include_sensitive_txes=false) const
get a list of all transactions in the pool
Definition: cryptonote_core.cpp:1493
uint32_t get_blockchain_pruning_seed() const
get the blockchain pruning seed
Definition: cryptonote_core.cpp:1880
bool handle_get_objects(NOTIFY_REQUEST_GET_OBJECTS::request &arg, NOTIFY_RESPONSE_GET_OBJECTS::request &rsp, cryptonote_connection_context &context)
retrieves a set of blocks and their transactions, and possibly other transactions ...
Definition: cryptonote_core.cpp:1541
virtual bool get_block_template(block &b, const account_public_address &adr, difficulty_type &diffic, uint64_t &height, uint64_t &expected_reward, const blobdata &ex_nonce, uint64_t &seed_height, crypto::hash &seed_hash) override
creates a new block to mine against
Definition: cryptonote_core.cpp:1201
const checkpoints & get_checkpoints() const
get a set of blockchain checkpoint hashes
Definition: cryptonote_core.cpp:249
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:1473
int * count
Definition: gmock_stress_test.cc:176
std::atomic_flag m_checkpoints_updating
set if checkpoints are currently updating to avoid multiple threads attempting to update at once ...
Definition: cryptonote_core.h:1097
void test_drop_download()
sets to drop blocks downloaded (for testing)
Definition: cryptonote_core.cpp:746
Definition: portable_binary_archive.hpp:29
Definition: cryptonote_protocol_handler_common.h:52
bool get_txpool_complement(const std::vector< crypto::hash > &hashes, std::vector< cryptonote::blobdata > &txes)
returns the set of transactions in the txpool which are not in the argument
Definition: cryptonote_core.cpp:1843
::std::string string
Definition: gtest-port.h:1097
const command_line::arg_descriptor< size_t > arg_block_download_max_size
Definition: cryptonote_core.cpp:121
Definition: cryptonote_basic.h:474
void on_synchronized()
Definition: cryptonote_core.cpp:1330
static bool check_tx_inputs_keyimages_diff(const transaction &tx)
verify that each input key image in a transaction is unique
Definition: cryptonote_core.cpp:1011
time_t m_last_json_checkpoints_update
time when json checkpoints were last updated
Definition: cryptonote_core.h:1095
bool update_checkpoints(const bool skip_dns=false)
tells the Blockchain to update its checkpoints
Definition: cryptonote_core.cpp:268
core(i_cryptonote_protocol *pprotocol)
constructor
Definition: cryptonote_core.cpp:222
bool find_blockchain_supplement(const std::list< crypto::hash > &qblock_ids, bool clip_pruned, NOTIFY_RESPONSE_CHAIN_ENTRY::request &resp) const
Definition: cryptonote_core.cpp:1216
time_t start_time
Definition: cryptonote_core.h:1102
std::string print_pool(bool short_format) const
get a string containing human-readable pool information
Definition: cryptonote_core.cpp:1556
bool get_short_chain_history(std::list< crypto::hash > &ids) const
gets the hashes for a subset of the blockchain
Definition: cryptonote_core.cpp:1536
bool are_key_images_spent_in_pool(const std::vector< crypto::key_image > &key_im, std::vector< bool > &spent) const
check if multiple key images are spent in the transaction pool
Definition: cryptonote_core.cpp:976
crypto namespace.
Definition: crypto.cpp:60
std::function< const epee::span< const unsigned char >cryptonote::network_type network)> GetCheckpointsCallback
Callback routine that returns checkpoints data for specific network type.
Definition: blockchain.h:93
Definition: enums.h:67
time_t m_last_dns_checkpoints_update
time when dns checkpoints were last updated
Definition: cryptonote_core.h:1094
bool get_pool_transaction_hashes(std::vector< crypto::hash > &txs, bool include_sensitive_txes=false) const
get a list of all transactions in the pool
Definition: cryptonote_core.cpp:1499
const command_line::arg_descriptor< bool, false > arg_stagenet_on
Definition: cryptonote_core.cpp:80
void disable_dns_checkpoints(bool disable=true)
set whether or not to enable or disable DNS checkpoints
Definition: cryptonote_core.h:475
Non-owning sequence of data. Does not deep copy.
Definition: span.h:54
uint64_t get_earliest_ideal_height_for_version(uint8_t version) const
return the earliest block a given version may activate
Definition: cryptonote_core.cpp:1614
Definition: connection_context.h:43
bool m_test_drop_download
whether or not to drop incoming blocks (for testing)
Definition: cryptonote_core.h:1059
crypto::hash get_block_id_by_height(uint64_t height) const
gets a block&#39;s hash given a height
Definition: cryptonote_core.cpp:1546
bool get_miner_data(uint8_t &major_version, uint64_t &height, crypto::hash &prev_id, crypto::hash &seed_hash, difficulty_type &difficulty, uint64_t &median_weight, uint64_t &already_generated_coins, std::vector< tx_block_template_backlog_entry > &tx_backlog)
gets data required to create a block template and start mining on it
Definition: cryptonote_core.cpp:1211
network_type get_nettype() const
get the network type we&#39;re on
Definition: cryptonote_core.h:814
Definition: blocks.cpp:12
Definition: verification_context.h:65
unsigned char uint8_t
Definition: stdint.h:124
difficulty_type get_block_cumulative_difficulty(uint64_t height) const
Definition: cryptonote_core.cpp:1468
bool pool_has_tx(const crypto::hash &txid) const
checks if the pool has a transaction with the given hash
Definition: cryptonote_core.cpp:1521
struct hash_func hashes[]
bool add_new_block(const block &b, block_verification_context &bvc, pool_supplement &extra_block_txs)
adds a block to the blockchain
Definition: cryptonote_core.cpp:1340
std::unordered_map< crypto::key_image, std::vector< crypto::hash > > key_images_with_tx_hashes
Definition: message_data_structs.h:107
bool m_offline
Definition: cryptonote_core.h:1115
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:1346
desc
Definition: pymoduletest.py:79
std::atomic< bool > m_update_available
Definition: cryptonote_core.h:1091
bool has_block_weights(uint64_t height, uint64_t nblocks) const
checks whether block weights are known for the given range
Definition: cryptonote_core.cpp:1895
std::atomic< bool > m_starter_message_showed
has the "daemon will sync now" message been shown?
Definition: cryptonote_core.h:1085
Definition: i_core_events.h:37
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
Definition: cryptonote_core.cpp:402
network_type m_nettype
which network are we on?
Definition: cryptonote_core.h:1089
Definition: cryptonote_core.h:1106
Holds cryptonote related classes and helpers.
Definition: blockchain_db.cpp:44
Definition: verification_context.h:40
bool get_pool_transactions_and_spent_keys_info(std::vector< tx_info > &tx_infos, std::vector< spent_key_image_info > &key_image_infos, bool include_sensitive_txes=false) const
Definition: cryptonote_core.cpp:1526
bool init(const boost::program_options::variables_map &vm, const test_options *test_options=NULL, const GetCheckpointsCallback &get_checkpoints=nullptr, bool allow_dns=true)
initializes the core as needed
Definition: cryptonote_core.cpp:453
bool get_output_distribution(uint64_t amount, uint64_t from_height, uint64_t to_height, uint64_t &start_height, std::vector< uint64_t > &distribution, uint64_t &base) const
gets per block distribution of outputs of a given amount
Definition: cryptonote_core.cpp:1231
static bool check_tx_inputs_keyimages_domain(const transaction &tx)
verify that each input key image in a transaction is in the valid domain
Definition: cryptonote_core.cpp:1038
const command_line::arg_descriptor< difficulty_type > arg_fixed_difficulty
Definition: cryptonote_core.cpp:95
epee::math_helper::once_a_time_seconds< 60 *60 *2, true > m_fork_moaner
interval for checking HardFork status
Definition: cryptonote_core.h:1078
tx_memory_pool m_mempool
transaction pool instance
Definition: cryptonote_core.h:1063
Definition: syncobj.h:81
bool cleanup_handle_incoming_blocks(bool force_sync=false)
incoming blocks post-processing, cleanup, and disk sync
Definition: cryptonote_core.cpp:1358
const command_line::arg_descriptor< bool, false > arg_testnet_on
Definition: cryptonote_core.cpp:75
Definition: cryptonote_core.h:57
void set_cryptonote_protocol(i_cryptonote_protocol *pprotocol)
set the pointer to the cryptonote protocol object to use
Definition: cryptonote_core.cpp:241
Definition: cryptonote_core.h:1105
epee::math_helper::once_a_time_seconds< 60 *60 *12, false > m_store_blockchain_interval
interval for manual storing of Blockchain, if enabled
Definition: cryptonote_core.h:1077
unsigned int uint32_t
Definition: stdint.h:126
#define POP_WARNINGS
Definition: warnings.h:17
bool relay_txpool_transactions()
attempts to relay any transactions in the mempool which need it
Definition: cryptonote_core.cpp:1097
size_t m_last_update_length
Definition: cryptonote_core.h:1112
bool m_disable_dns_checkpoints
Definition: cryptonote_core.h:1098
void set_enforce_dns_checkpoints(bool enforce_dns)
set whether or not we enforce DNS checkpoints
Definition: cryptonote_core.cpp:263
bool get_pool_info(time_t start_time, bool include_sensitive_txes, size_t max_tx_count, std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details >> &added_txs, std::vector< crypto::hash > &remaining_added_txids, std::vector< crypto::hash > &removed_txs, bool &incremental) const
get info necessary for update of pool-related info in a wallet, preferably incremental ...
Definition: cryptonote_core.cpp:1505
bool on_idle()
calls various idle routines
Definition: cryptonote_core.cpp:1567
i_cryptonote_protocol * get_protocol()
get the cryptonote protocol instance
Definition: cryptonote_core.h:215
virtual bool handle_block_found(block &b, block_verification_context &bvc) override
stores and relays a block found by a miner
Definition: cryptonote_core.cpp:1270
void set_checkpoints(checkpoints &&chk_pts)
assign a set of blockchain checkpoint hashes
Definition: cryptonote_core.cpp:253
void graceful_exit()
tells the daemon to wind down operations and stop running
Definition: cryptonote_core.cpp:1905
void get_blockchain_top(uint64_t &height, crypto::hash &top_id) const
get the hash and height of the most recent block
Definition: cryptonote_core.cpp:397
epee::math_helper::once_a_time_seconds< 60 *60 *5, true > m_blockchain_pruning_interval
interval for incremental blockchain pruning
Definition: cryptonote_core.h:1082
Definition: miner.h:60
uint64_t get_target_blockchain_height() const
gets the target blockchain height
Definition: cryptonote_core.cpp:1863
enum cryptonote::core::@89 check_updates_level
handles core cryptonote functionality
Definition: cryptonote_core.h:86
bool get_transactions(const std::vector< crypto::hash > &txs_ids, std::vector< cryptonote::blobdata > &txs, std::vector< crypto::hash > &missed_txs, bool pruned=false) const
Definition: cryptonote_core.cpp:422
unsigned __int64 uint64_t
Definition: stdint.h:136
bool check_blockchain_pruning()
checks the blockchain pruning if enabled
Definition: cryptonote_core.cpp:1853
bool get_test_drop_download_height() const
gets whether or not to drop blocks
Definition: cryptonote_core.cpp:761
const command_line::arg_descriptor< std::string, false, true, 2 > arg_data_dir
Definition: cryptonote_core.cpp:100
bool is_update_available() const
check whether an update is known to be available or not
Definition: cryptonote_core.h:824
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105
size_t get_block_sync_size(uint64_t height) const
get the number of blocks to sync in one go
Definition: cryptonote_core.cpp:935
std::string m_checkpoints_path
path to json checkpoints file
Definition: cryptonote_core.h:1093
bool check_block_rate()
checks block rate, and warns if it&#39;s too slow
Definition: cryptonote_core.cpp:1792
static void init_options(boost::program_options::options_description &desc)
adds command line options to the given options set
Definition: cryptonote_core.cpp:312
void flush_invalid_blocks()
flushes the invalid block cache
Definition: cryptonote_core.cpp:1838
epee::critical_section m_incoming_tx_lock
incoming transaction lock
Definition: cryptonote_core.h:1068
#define false
Definition: stdbool.h:37
void resume_mine()
Definition: cryptonote_core.cpp:1251
uint8_t get_ideal_hard_fork_version() const
returns the newest hardfork version known to the blockchain
Definition: cryptonote_core.cpp:1599
bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan=NULL) const
gets the block with a given hash
Definition: cryptonote_core.cpp:1551
void set_target_blockchain_height(uint64_t target_blockchain_height)
sets the target blockchain height
Definition: cryptonote_core.cpp:1858
boost::mutex m_update_mutex
Definition: cryptonote_core.h:1113
bool set_genesis_block(const block &b)
clears the blockchain and starts a new one
Definition: cryptonote_core.cpp:727
static bool check_tx_semantic(const transaction &tx, tx_verification_context &tvc, uint8_t hf_version)
validates some simple properties of a transaction
Definition: cryptonote_core.cpp:823
bool update_blockchain_pruning()
incrementally prunes blockchain
Definition: cryptonote_core.cpp:1848
Definition: misc_language.h:103
version
Supported socks variants.
Definition: socks.h:57
cryptonote_protocol_stub m_protocol_stub
cryptonote protocol stub instance
Definition: cryptonote_core.h:1075
relay_method tx_relay
Definition: levin_notify.cpp:549
Definition: cryptonote_core.h:61
bool handle_command_line(const boost::program_options::variables_map &vm)
act on a set of command line options given
Definition: cryptonote_core.cpp:347
uint64_t m_target_blockchain_height
blockchain height target
Definition: cryptonote_core.h:1087
const Blockchain & get_blockchain_storage() const
gets the Blockchain instance (const)
Definition: cryptonote_core.h:661
epee::math_helper::once_a_time_seconds< 90, false > m_block_rate_interval
interval for checking block rate
Definition: cryptonote_core.h:1081
bool handle_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, bool update_miner_blocktemplate=true)
handles an incoming block as part of a batch
Definition: cryptonote_core.cpp:1370
epee::math_helper::once_a_time_seconds< 60 *10, true > m_check_disk_space_interval
interval for checking for disk space
Definition: cryptonote_core.h:1080
const command_line::arg_descriptor< bool > arg_offline
Definition: cryptonote_core.cpp:113
bool is_key_image_spent(const crypto::key_image &key_im) const
check if a key image is already spent on the blockchain
Definition: cryptonote_core.cpp:920
Transaction pool, handles transactions which are not part of a block.
Definition: tx_pool.h:98
std::string blobdata
Definition: blobdatatype.h:39
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto
Definition: base.py:1
Definition: cryptonote_core.h:1107
bool offline() const
get whether the core is running offline
Definition: cryptonote_core.h:845
Definition: cryptonote_core.h:57
Definition: core_rpc_server_commands_defs.h:1680
bool handle_single_incoming_block(const blobdata &block_blob, const block *b, block_verification_context &bvc, pool_supplement &extra_block_txs, bool update_miner_blocktemplate=true)
handles a single incoming block
Definition: cryptonote_core.cpp:1414
network_type
Definition: cryptonote_config.h:301
randomx_vm * vm
Definition: tests.cpp:20
miner & get_miner()
gets the miner instance
Definition: cryptonote_core.h:260
Definition: cryptonote_basic.h:511
bool get_alternative_blocks(std::vector< block > &blocks) const
compiles a list of all blocks stored as alternative chains
Definition: cryptonote_core.cpp:443
Blockchain & get_blockchain_storage()
gets the Blockchain instance
Definition: cryptonote_core.h:654
void set_checkpoints_file_path(const std::string &path)
set the file path to read from when loading checkpoints
Definition: cryptonote_core.cpp:258
boost::multiprecision::uint128_t difficulty_type
Definition: difficulty.h:41
uint64_t get_free_space() const
get free disk space on the blockchain partition
Definition: cryptonote_core.cpp:1873
size_t get_alternative_blocks_count() const
returns the number of alternative blocks stored
Definition: cryptonote_core.cpp:448
size_t block_sync_size
Definition: cryptonote_core.h:1100
POD_CLASS key_image
Definition: crypto.h:92
Used to provide transaction info that skips the mempool to block handling code.
Definition: tx_verification_utils.h:100
bool get_tx_outputs_gindexs(const crypto::hash &tx_id, std::vector< uint64_t > &indexs) const
gets the global indices for outputs from a given transaction
Definition: cryptonote_core.cpp:1236
const miner & get_miner() const
gets the miner instance (const)
Definition: cryptonote_core.h:267
bool get_outs(const COMMAND_RPC_GET_OUTPUTS_BIN::request &req, COMMAND_RPC_GET_OUTPUTS_BIN::response &res) const
gets specific outputs to mix with
Definition: cryptonote_core.cpp:1226
void safesyncmode(const bool onoff)
Put DB in safe sync mode.
Definition: cryptonote_core.cpp:1335
bool load_state_data()
load any core state stored on disk
Definition: cryptonote_core.cpp:732
virtual void on_transactions_relayed(epee::span< const cryptonote::blobdata > tx_blobs, relay_method tx_relay) final
called when a transaction is relayed.
Definition: cryptonote_core.cpp:1172
cryptonote::transaction tx
Definition: transaction.cpp:40
miner m_miner
miner instance
Definition: cryptonote_core.h:1071
bool is_within_compiled_block_hash_area(uint64_t height) const
checks whether a given block height is included in the precompiled block hash area ...
Definition: cryptonote_core.cpp:1890
bool recalculate_difficulties()
recalculate difficulties after the last difficulty checklpoint to circumvent the annoying &#39;difficulty...
Definition: cryptonote_core.cpp:1832
uint64_t prevalidate_block_hashes(uint64_t height, const std::vector< crypto::hash > &hashes, const std::vector< uint64_t > &weights)
check a set of hashes against the precompiled hash set
Definition: cryptonote_core.cpp:1868
virtual bool is_synchronized() const final
gets the core synchronization status
Definition: cryptonote_core.cpp:1325
const command_line::arg_descriptor< bool > arg_regtest_on
Definition: cryptonote_core.cpp:85
bool get_blocks(uint64_t start_offset, size_t count, std::vector< std::pair< cryptonote::blobdata, block >> &blocks, std::vector< cryptonote::blobdata > &txs) const
get blocks and transactions from blocks based on start height and count
Definition: blockchain.cpp:2126
bool check_updates()
checks DNS versions
Definition: cryptonote_core.cpp:1619
tools::download_async_handle m_update_download
Definition: cryptonote_core.h:1111
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:36
POD_CLASS hash
Definition: hash.h:49
bool prune_blockchain(uint32_t pruning_seed=0)
prune the blockchain
Definition: cryptonote_core.cpp:1885
i_cryptonote_protocol * m_pprotocol
cryptonote protocol instance
Definition: cryptonote_core.h:1066
A container for blockchain checkpoints.
Definition: checkpoints.h:52
Definition: cryptonote_core.h:1108
Definition: cryptonote_core.h:57
bool are_key_images_spent(const std::vector< crypto::key_image > &key_im, std::vector< bool > &spent) const
check if multiple key images are spent
Definition: cryptonote_core.cpp:925
bool get_split_transactions_blobs(const std::vector< crypto::hash > &txs_ids, std::vector< std::tuple< crypto::hash, cryptonote::blobdata, crypto::hash, cryptonote::blobdata >> &txs, std::vector< crypto::hash > &missed_txs) const
Definition: cryptonote_core.cpp:427
bool handle_incoming_tx(const blobdata &tx_blob, tx_verification_context &tvc, relay_method tx_relay, bool relayed)
handles an incoming transaction
Definition: cryptonote_core.cpp:772
std::shared_ptr< download_thread_control > download_async_handle
Definition: download.h:35
std::shared_ptr< tools::Notify > m_block_rate_notify
Definition: cryptonote_core.h:1117
bool notify_txpool_event(const epee::span< const cryptonote::blobdata > tx_blobs, epee::span< const crypto::hash > tx_hashes, epee::span< const cryptonote::transaction > txs, const std::vector< bool > &just_broadcasted) const
sends notification of txpool events to subscribers
Definition: cryptonote_core.cpp:1142
major_version
Definition: versiongenerate.py:78
relay_category
Definition: blockchain_db.h:109
const std::pair< uint8_t, uint64_t > * hard_forks
Definition: cryptonote_core.h:62
bool get_pool_transaction_stats(struct txpool_stats &stats, bool include_sensitive_txes=false) const
get a list of all transactions in the pool
Definition: cryptonote_core.cpp:1510
bool get_pool_for_rpc(std::vector< cryptonote::rpc::tx_in_pool > &tx_infos, cryptonote::rpc::key_images_with_tx_hashes &key_image_infos) const
get information about all transactions and key images in the pool
Definition: cryptonote_core.cpp:1531
static bool check_tx_inputs_ring_members_diff(const transaction &tx, const uint8_t hf_version)
verify that each ring uses distinct members
Definition: cryptonote_core.cpp:1023
#define const
Definition: ipfrdr.c:80
bool check_incoming_block_size(const blobdata &block_blob) const
check the size of a block against the current maximum
Definition: cryptonote_core.cpp:1449
bool get_txpool_backlog(std::vector< tx_backlog_entry > &backlog, bool include_sensitive_txes=false) const
Definition: cryptonote_core.cpp:432
static uint64_t h
Definition: blockchain_stats.cpp:55
Definition: cryptonote_basic.h:204
bool have_block(const crypto::hash &id, int *where=NULL) const
Definition: cryptonote_core.cpp:1483
virtual uint64_t get_current_blockchain_height() const final
get the current height of the blockchain
Definition: cryptonote_core.cpp:392
const size_t long_term_block_weight_window
Definition: cryptonote_core.h:63
bool get_pool_transactions_info(const std::vector< crypto::hash > &txids, std::vector< std::pair< crypto::hash, tx_memory_pool::tx_details >> &txs, bool include_sensitive_txes=false) const
Definition: cryptonote_core.cpp:1488
Definition: miner.h:47
Definition: cryptonote_protocol_handler_common.h:41
cryptonote::block b
Definition: block.cpp:40
bool add_new_tx(transaction &tx, const crypto::hash &tx_hash, const cryptonote::blobdata &blob, size_t tx_weight, tx_verification_context &tvc, relay_method tx_relay, bool relayed)
Definition: cryptonote_core.cpp:1066
bool check_disk_space()
checks free disk space
Definition: cryptonote_core.cpp:1749
Definition: blockchain.h:102
weights
Definition: block_weight.py:18
size_t get_blockchain_total_transactions() const
gets the total number of transactions on the main chain
Definition: cryptonote_core.cpp:1061
std::time_t get_start_time() const
gets start_time
Definition: cryptonote_core.cpp:1900
bool update_miner_block_template()
Definition: cryptonote_core.cpp:1561