Monero
cryptonote_config.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2018, 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 <string>
34 #include <boost/uuid/uuid.hpp>
35 
36 #define CRYPTONOTE_DNS_TIMEOUT_MS 20000
37 
38 #define CRYPTONOTE_MAX_BLOCK_NUMBER 500000000
39 #define CRYPTONOTE_MAX_BLOCK_SIZE 500000000 // block header blob limit, never used!
40 #define CRYPTONOTE_GETBLOCKTEMPLATE_MAX_BLOCK_SIZE 196608 //size of block (bytes) that is the maximum that miners will produce
41 #define CRYPTONOTE_MAX_TX_SIZE 1000000000
42 #define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
43 #define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60
44 #define CURRENT_TRANSACTION_VERSION 2
45 #define CURRENT_BLOCK_MAJOR_VERSION 1
46 #define CURRENT_BLOCK_MINOR_VERSION 0
47 #define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2
48 #define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 10
49 
50 #define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW 60
51 
52 // MONEY_SUPPLY - total number coins to be generated
53 #define MONEY_SUPPLY ((uint64_t)(-1))
54 #define EMISSION_SPEED_FACTOR_PER_MINUTE (20)
55 #define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)300000000000) // 3 * pow(10, 11)
56 
57 #define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
58 #define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 60000 //size of block (bytes) after which reward for block calculated using block size
59 #define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 20000 //size of block (bytes) after which reward for block calculated using block size - before first fork
60 #define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 300000 //size of block (bytes) after which reward for block calculated using block size - second change, from v5
61 #define CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE 600
62 #define CRYPTONOTE_DISPLAY_DECIMAL_POINT 12
63 // COIN - number of smallest units in one coin
64 #define COIN ((uint64_t)1000000000000) // pow(10, 12)
65 
66 #define FEE_PER_KB_OLD ((uint64_t)10000000000) // pow(10, 10)
67 #define FEE_PER_KB ((uint64_t)2000000000) // 2 * pow(10, 9)
68 #define FEE_PER_BYTE ((uint64_t)300000)
69 #define DYNAMIC_FEE_PER_KB_BASE_FEE ((uint64_t)2000000000) // 2 * pow(10,9)
70 #define DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD ((uint64_t)10000000000000) // 10 * pow(10,12)
71 #define DYNAMIC_FEE_PER_KB_BASE_FEE_V5 ((uint64_t)2000000000 * (uint64_t)CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 / CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5)
72 #define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT ((uint64_t)3000)
73 
74 #define ORPHANED_BLOCKS_MAX_COUNT 100
75 
76 
77 #define DIFFICULTY_TARGET_V2 120 // seconds
78 #define DIFFICULTY_TARGET_V1 60 // seconds - before first fork
79 #define DIFFICULTY_WINDOW 720 // blocks
80 #define DIFFICULTY_LAG 15 // !!!
81 #define DIFFICULTY_CUT 60 // timestamps to cut after sorting
82 #define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
83 
84 
85 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V1 DIFFICULTY_TARGET_V1 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
86 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 DIFFICULTY_TARGET_V2 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
87 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
88 
89 
90 #define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN DIFFICULTY_TARGET_V1 //just alias; used by tests
91 
92 
93 #define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
94 #define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
95 #define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
96 
97 #define CRYPTONOTE_MEMPOOL_TX_LIVETIME (86400*3) //seconds, three days
98 #define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME 604800 //seconds, one week
99 
100 #define COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT 1000
101 
102 #define P2P_LOCAL_WHITE_PEERLIST_LIMIT 1000
103 #define P2P_LOCAL_GRAY_PEERLIST_LIMIT 5000
104 
105 #define P2P_DEFAULT_CONNECTIONS_COUNT 8
106 #define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
107 #define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
108 #define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
109 #define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
110 #define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
111 #define P2P_DEFAULT_INVOKE_TIMEOUT 60*2*1000 //2 minutes
112 #define P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT 5000 //5 seconds
113 #define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70
114 #define P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT 2
115 
116 #define P2P_FAILED_ADDR_FORGET_SECONDS (60*60) //1 hour
117 #define P2P_IP_BLOCKTIME (60*60*24) //24 hour
118 #define P2P_IP_FAILS_BEFORE_BLOCK 10
119 #define P2P_IDLE_CONNECTION_KILL_INTERVAL (5*60) //5 minutes
120 
121 #define P2P_SUPPORT_FLAG_FLUFFY_BLOCKS 0x01
122 #define P2P_SUPPORT_FLAGS P2P_SUPPORT_FLAG_FLUFFY_BLOCKS
123 
124 #define ALLOW_DEBUG_COMMANDS
125 
126 #define CRYPTONOTE_NAME "bitmonero"
127 #define CRYPTONOTE_POOLDATA_FILENAME "poolstate.bin"
128 #define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "data.mdb"
129 #define CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME "lock.mdb"
130 #define P2P_NET_DATA_FILENAME "p2pstate.bin"
131 #define MINER_CONFIG_FILE_NAME "miner_conf.json"
132 
133 #define THREAD_STACK_SIZE 5 * 1024 * 1024
134 
135 #define HF_VERSION_DYNAMIC_FEE 4
136 #define HF_VERSION_MIN_MIXIN_4 6
137 #define HF_VERSION_MIN_MIXIN_6 7
138 #define HF_VERSION_MIN_MIXIN_10 8
139 #define HF_VERSION_ENFORCE_RCT 6
140 #define HF_VERSION_PER_BYTE_FEE 8
141 
142 #define PER_KB_FEE_QUANTIZATION_DECIMALS 8
143 
144 #define HASH_OF_HASHES_STEP 256
145 
146 #define DEFAULT_TXPOOL_MAX_WEIGHT 648000000ull // 3 days at 300000, in bytes
147 
148 #define BULLETPROOF_MAX_OUTPUTS 16
149 
150 // New constants are intended to go here
151 namespace config
152 {
153  uint64_t const DEFAULT_FEE_ATOMIC_XMR_PER_KB = 500; // Just a placeholder! Change me!
154  uint8_t const FEE_CALCULATION_MAX_RETRIES = 10;
155  uint64_t const DEFAULT_DUST_THRESHOLD = ((uint64_t)2000000000); // 2 * pow(10, 9)
156  uint64_t const BASE_REWARD_CLAMP_THRESHOLD = ((uint64_t)100000000); // pow(10, 8)
157  std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY = "0000000000000000000000000000000000000000000000000000000000000000";
158 
162  uint16_t const P2P_DEFAULT_PORT = 18080;
163  uint16_t const RPC_DEFAULT_PORT = 18081;
164  uint16_t const ZMQ_RPC_DEFAULT_PORT = 18082;
166  0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10
167  } }; // Bender's nightmare
168  std::string const GENESIS_TX = "013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1";
169  uint32_t const GENESIS_NONCE = 10000;
170 
171  namespace testnet
172  {
176  uint16_t const P2P_DEFAULT_PORT = 28080;
177  uint16_t const RPC_DEFAULT_PORT = 28081;
178  uint16_t const ZMQ_RPC_DEFAULT_PORT = 28082;
180  0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x11
181  } }; // Bender's daydream
182  std::string const GENESIS_TX = "013c01ff0001ffffffffffff03029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121017767aafcde9be00dcfd098715ebcf7f410daebc582fda69d24a28e9d0bc890d1";
183  uint32_t const GENESIS_NONCE = 10001;
184  }
185 
186  namespace stagenet
187  {
191  uint16_t const P2P_DEFAULT_PORT = 38080;
192  uint16_t const RPC_DEFAULT_PORT = 38081;
193  uint16_t const ZMQ_RPC_DEFAULT_PORT = 38082;
195  0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x12
196  } }; // Bender's daydream
197  std::string const GENESIS_TX = "013c01ff0001ffffffffffff0302df5d56da0c7d643ddd1ce61901c7bdc5fb1738bfe39fbe69c28a3a7032729c0f2101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b";
198  uint32_t const GENESIS_NONCE = 10002;
199  }
200 }
201 
202 namespace cryptonote
203 {
204  enum network_type : uint8_t
205  {
206  MAINNET = 0,
210  UNDEFINED = 255
211  };
212  struct config_t
213  {
217  uint16_t const P2P_DEFAULT_PORT;
218  uint16_t const RPC_DEFAULT_PORT;
219  uint16_t const ZMQ_RPC_DEFAULT_PORT;
221  std::string const GENESIS_TX;
222  uint32_t const GENESIS_NONCE;
223  };
224  inline const config_t& get_config(network_type nettype)
225  {
226  static const config_t mainnet = {
236  };
237  static const config_t testnet = {
247  };
248  static const config_t stagenet = {
258  };
259  switch (nettype)
260  {
261  case MAINNET: return mainnet;
262  case TESTNET: return testnet;
263  case STAGENET: return stagenet;
264  case FAKECHAIN: return mainnet;
265  default: throw std::runtime_error("Invalid network type");
266  }
267  };
268 }
const config_t & get_config(network_type nettype)
Definition: cryptonote_config.h:224
Definition: cryptonote_config.h:206
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:162
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:164
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:160
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:198
boost::uuids::uuid uuid
Definition: net_node_common.h:40
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:191
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:214
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:192
std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY
Definition: cryptonote_config.h:157
Definition: cryptonote_config.h:209
Definition: cryptonote_config.h:151
Definition: cryptonote_config.h:212
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:176
std::string const GENESIS_TX
Definition: cryptonote_config.h:182
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:179
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:218
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:224
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:165
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:183
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:193
std::string const GENESIS_TX
Definition: cryptonote_config.h:168
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:174
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:173
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:178
std::string const GENESIS_TX
Definition: cryptonote_config.h:197
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:219
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:161
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:177
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:159
uint64_t const BASE_REWARD_CLAMP_THRESHOLD
Definition: cryptonote_config.h:156
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:217
network_type
Definition: cryptonote_config.h:204
uint64_t const DEFAULT_DUST_THRESHOLD
Definition: cryptonote_config.h:155
Definition: cryptonote_config.h:210
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:175
Definition: cryptonote_config.h:207
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:189
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:188
std::string const GENESIS_TX
Definition: cryptonote_config.h:221
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:216
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:222
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:169
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:194
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:163
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:190
Definition: cryptonote_config.h:208
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:215
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:220
uint8_t const FEE_CALCULATION_MAX_RETRIES
Definition: cryptonote_config.h:154
uint64_t const DEFAULT_FEE_ATOMIC_XMR_PER_KB
Definition: cryptonote_config.h:153