Electroneum
cryptonote_config.h
Go to the documentation of this file.
1 // Copyrights(c) 2017-2020, The Electroneum Project
2 // Copyrights(c) 2014-2019, The Monero Project
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without modification, are
7 // permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice, this list of
10 // conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 // of conditions and the following disclaimer in the documentation and/or other
14 // materials provided with the distribution.
15 //
16 // 3. Neither the name of the copyright holder nor the names of its contributors may be
17 // used to endorse or promote products derived from this software without specific
18 // prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31 
32 #pragma once
33 
34 #include <stdexcept>
35 #include <string>
36 #include <boost/uuid/uuid.hpp>
37 
38 #define CRYPTONOTE_DNS_TIMEOUT_MS 20000
39 
40 #define CRYPTONOTE_MAX_BLOCK_NUMBER 500000000
41 #define CRYPTONOTE_GETBLOCKTEMPLATE_MAX_BLOCK_SIZE 196608 //size of block (bytes) that is the maximum that miners will produce
42 #define CRYPTONOTE_MAX_TX_SIZE 1000000
43 #define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000
44 #define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
45 #define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 18
46 #define ETN_MINED_MONEY_UNLOCK_WINDOW_V8 5
47 #define CURRENT_TRANSACTION_VERSION 2
48 #define CURRENT_BLOCK_MAJOR_VERSION 1
49 #define CURRENT_BLOCK_MINOR_VERSION 0
50 #define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT 60*60*2
51 #define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 10
52 #define ETN_DEFAULT_TX_SPENDABLE_AGE_V8 5
53 
54 #define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW 60
55 
56 // MONEY_SUPPLY - total number coins to be generated
57 #define MONEY_SUPPLY ((uint64_t)(2100000000000))
58 #define EMISSION_SPEED_FACTOR_PER_MINUTE (20)
59 #define EMISSION_SPEED_FACTOR_PER_MINUTE_V8 (22) // +=2 => Reduce emission by ~75%.
60 
61 #define FINAL_SUBSIDY_PER_MINUTE ((uint64_t) 25 * COIN) // 25etn tail emission after reaching max supply
62 
63 #define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
64 #define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V2 60000 //size of block (bytes) after which reward for block calculated using block size
65 #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
66 #define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V5 150000 //size of block (bytes) after which reward for block calculated using block size - second change, from v5
67 #define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V8 300000 //size of block (bytes) after which reward for block calculated using block size - third change, from v8
68 #define CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE 100000 // size in blocks of the long term block weight median window
69 #define CRYPTONOTE_SHORT_TERM_BLOCK_WEIGHT_SURGE_FACTOR 50
70 #define CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE 600
71 #define CRYPTONOTE_DISPLAY_DECIMAL_POINT 2
72 // COIN - number of smallest units in one coin. This definition is only used for tests.
73 #define COIN ((uint64_t)100) // pow(10, 2)
74 
75 #define FEE_PER_KB ((uint64_t)1) //Initial fee of 0.01/kb
76 #define FEE_PER_KB_V6 ((uint64_t)10) //Fee of 0.10/kb from HF V6
77 
78 #define FEE_PER_BYTE ((uint64_t)30)
79 
80 #define DEFAULT_MIX 0
81 #define DEFAULT_RINGSIZE (DEFAULT_MIX + 1)
82 
83 #define DYNAMIC_FEE_PER_KB_BASE_FEE ((uint64_t)2000000000) // 2 * pow(10,9)
84 #define DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD ((uint64_t)10000000000000) // 10 * pow(10,12)
85 #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)
86 #define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT ((uint64_t)3000)
87 
88 #define ORPHANED_BLOCKS_MAX_COUNT 100
89 
90 #define DIFFICULTY_TARGET 60 // seconds
91 #define DIFFICULTY_TARGET_V6 120 // seconds
92 #define DIFFICULTY_WINDOW 720 // blocks
93 #define DIFFICULTY_WINDOW_V6 360 // blocks
94 #define DIFFICULTY_LAG 15 // !!!
95 #define DIFFICULTY_CUT 60 // timestamps to cut after sorting
96 #define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
97 #define DIFFICULTY_BLOCKS_COUNT_V6 DIFFICULTY_WINDOW_V6 + DIFFICULTY_LAG
98 
99 
100 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
101 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS DIFFICULTY_TARGET * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
102 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V6 DIFFICULTY_TARGET_V6 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
103 
104 
105 #define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN DIFFICULTY_TARGET //just alias; used by tests
106 #define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN_V6 DIFFICULTY_TARGET_V6 //just alias; used by tests
107 
108 
109 #define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
110 #define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
111 #define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
112 
113 #define CRYPTONOTE_MEMPOOL_TX_LIVETIME 86400 //seconds, one day
114 #define CRYPTONOTE_MEMPOOL_TX_LIVETIME_V6 (86400*3) //seconds, three days
115 #define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME 604800 //seconds, one week
116 
117 #define COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT 1000
118 
119 #define P2P_LOCAL_WHITE_PEERLIST_LIMIT 1000
120 #define P2P_LOCAL_GRAY_PEERLIST_LIMIT 5000
121 
122 #define P2P_DEFAULT_CONNECTIONS_COUNT 8
123 #define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
124 #define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
125 #define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
126 #define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
127 #define P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT 45 // seconds
128 #define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
129 #define P2P_DEFAULT_INVOKE_TIMEOUT 60*2*1000 //2 minutes
130 #define P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT 5000 //5 seconds
131 #define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70
132 #define P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT 2
133 #define P2P_DEFAULT_SYNC_SEARCH_CONNECTIONS_COUNT 2
134 #define P2P_DEFAULT_LIMIT_RATE_UP 2048 // kB/s
135 #define P2P_DEFAULT_LIMIT_RATE_DOWN 8192 // kB/s
136 
137 #define P2P_FAILED_ADDR_FORGET_SECONDS (60*60) //1 hour
138 #define P2P_IP_BLOCKTIME (60*60*24) //24 hour
139 #define P2P_IP_FAILS_BEFORE_BLOCK 10
140 #define P2P_IDLE_CONNECTION_KILL_INTERVAL (5*60) //5 minutes
141 
142 #define P2P_SUPPORT_FLAG_FLUFFY_BLOCKS 0x01
143 #define P2P_SUPPORT_FLAGS P2P_SUPPORT_FLAG_FLUFFY_BLOCKS
144 
145 #define ALLOW_DEBUG_COMMANDS
146 
147 #define CRYPTONOTE_NAME "electroneum"
148 #define CRYPTONOTE_POOLDATA_FILENAME "poolstate.bin"
149 #define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "data.mdb"
150 #define CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME "lock.mdb"
151 #define P2P_NET_DATA_FILENAME "p2pstate.bin"
152 #define MINER_CONFIG_FILE_NAME "miner_conf.json"
153 
154 #define THREAD_STACK_SIZE 5 * 1024 * 1024
155 
156 #define CURRENT_HARDFORK_VERSION 8
157 #define HF_VERSION_FORBID_DUST_OUTPUTS 2
158 #define HF_VERSION_FORBID_INVALID_PUBKEYS 4
159 #define HF_VERSION_ENFORCE_0_DECOY_TXS 6
160 #define HF_VERSION_ENFORCE_0_DECOY_TXS_END 100
161 #define HF_VERSION_DYNAMIC_FEE 100
162 #define HF_VERSION_MIN_MIXIN_2 2
163 #define HF_VERSION_MIN_MIXIN_4 100
164 #define HF_VERSION_MIN_MIXIN_6 100
165 #define HF_VERSION_MIN_MIXIN_10 100
166 #define HF_VERSION_MAX_RING_11 100
167 #define HF_VERSION_ENABLE_RCT 100
168 #define HF_VERSION_ENFORCE_RCT 100
169 #define HF_VERSION_PER_BYTE_FEE 100
170 #define HF_VERSION_SMALLER_BP 100
171 #define HF_VERSION_LONG_TERM_BLOCK_WEIGHT 100
172 #define HF_VERSION_ORDERED_TX_INPUTS 100
173 #define HF_VERSION_ALLOW_BULLETPROOF 100
174 #define HF_VERSION_FORBIT_BORROMEAN_RANGE_PROOFS HF_VERSION_ALLOW_BULLETPROOF + 1
175 
176 
177 #define PER_KB_FEE_QUANTIZATION_DECIMALS 2
178 
179 #define DEFAULT_TXPOOL_MAX_WEIGHT 648000000ull // 3 days at 300000, in bytes
180 
181 #define BULLETPROOF_MAX_OUTPUTS 16
182 
183 #define CRYPTONOTE_PRUNING_STRIPE_SIZE 4096 // the smaller, the smoother the increase
184 #define CRYPTONOTE_PRUNING_LOG_STRIPES 3 // the higher, the more space saved
185 #define CRYPTONOTE_PRUNING_TIP_BLOCKS 5500 // the smaller, the more space saved
186 //#define CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
187 
188 // New constants are intended to go here
189 namespace config
190 {
191  uint64_t const DEFAULT_FEE_ATOMIC_ETN_PER_KB = 500; // Just a placeholder! Change me!
192  uint8_t const FEE_CALCULATION_MAX_RETRIES = 10;
193  uint64_t const DEFAULT_DUST_THRESHOLD = ((uint64_t)1);
194  uint64_t const BASE_REWARD_CLAMP_THRESHOLD = ((uint64_t)100000000); // pow(10, 8)
195  std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY = "0000000000000000000000000000000000000000000000000000000000000000";
196 
200  uint16_t const P2P_DEFAULT_PORT = 26967;
201  uint16_t const RPC_DEFAULT_PORT = 26968;
202  uint16_t const ZMQ_RPC_DEFAULT_PORT = 26982;
204  0x04, 0xF8, 0x23, 0xE1, 0x66, 0xC2, 0xE3, 0xA4, 0xEA, 0x5D, 0xD1, 0x2C, 0x85, 0x8E, 0xC8, 0x39
205  } };
206  std::string const GENESIS_TX = "011201ff00011e026bc5c7db8a664f652d78adb587ac4d759c6757258b64ef9cba3c0354e64fb2e42101abca6a39c561d0897be183eb0143990eba201aa7d2c652ab0555d28bb4b70728";
207  uint32_t const GENESIS_NONCE = 10000;
208 
209  namespace testnet
210  {
214  uint16_t const P2P_DEFAULT_PORT = 34567;
215  uint16_t const RPC_DEFAULT_PORT = 34568;
216  uint16_t const ZMQ_RPC_DEFAULT_PORT = 34582;
218  0x04, 0xF8, 0x23, 0xE1, 0x66, 0xC2, 0xE3, 0xA4, 0xEA, 0x5D, 0xD1, 0x2C, 0x85, 0x8E, 0xC8, 0x41
219  } };
220  std::string const GENESIS_TX = "011201ff000180bcf5dace2102a7957ab8394540efaa5bc93d747d6c56d8bf87b1c955574963dfbcf62ab13b5c210120d88af73976c98be9819df7e85bc21167d3194e242afd50601e398243c354b6";
221  uint32_t const GENESIS_NONCE = 10000;
222  }
223 
224  namespace stagenet
225  {
229  uint16_t const P2P_DEFAULT_PORT = 38080;
230  uint16_t const RPC_DEFAULT_PORT = 38081;
231  uint16_t const ZMQ_RPC_DEFAULT_PORT = 38082;
233  0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x12
234  } }; // Bender's daydream
235  std::string const GENESIS_TX = "013c01ff0001ffffffffffff0302df5d56da0c7d643ddd1ce61901c7bdc5fb1738bfe39fbe69c28a3a7032729c0f2101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b";
236  uint32_t const GENESIS_NONCE = 10002;
237  }
238 }
239 
240 namespace cryptonote
241 {
242  enum network_type : uint8_t
243  {
244  MAINNET = 0,
248  UNDEFINED = 255
249  };
250  struct config_t
251  {
255  uint16_t const P2P_DEFAULT_PORT;
256  uint16_t const RPC_DEFAULT_PORT;
257  uint16_t const ZMQ_RPC_DEFAULT_PORT;
259  std::string const GENESIS_TX;
260  uint32_t const GENESIS_NONCE;
261  };
262  inline const config_t& get_config(network_type nettype)
263  {
264  static const config_t mainnet = {
274  };
275  static const config_t testnet = {
285  };
286  static const config_t stagenet = {
296  };
297  switch (nettype)
298  {
299  case MAINNET: return mainnet;
300  case TESTNET: return testnet;
301  case STAGENET: return stagenet;
302  case FAKECHAIN: return mainnet;
303  default: throw std::runtime_error("Invalid network type");
304  }
305  };
306 }
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:232
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:236
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:228
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:231
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:226
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:227
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:229
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:230
std::string const GENESIS_TX
Definition: cryptonote_config.h:235
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:216
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:215
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:217
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:221
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:213
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:214
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:211
std::string const GENESIS_TX
Definition: cryptonote_config.h:220
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:212
Definition: cryptonote_config.h:190
std::string const GENESIS_TX
Definition: cryptonote_config.h:206
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:198
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:201
uint64_t const DEFAULT_DUST_THRESHOLD
Definition: cryptonote_config.h:193
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:203
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:207
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:202
uint8_t const FEE_CALCULATION_MAX_RETRIES
Definition: cryptonote_config.h:192
uint64_t const DEFAULT_FEE_ATOMIC_ETN_PER_KB
Definition: cryptonote_config.h:191
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:197
uint64_t const BASE_REWARD_CLAMP_THRESHOLD
Definition: cryptonote_config.h:194
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:200
std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY
Definition: cryptonote_config.h:195
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:199
Holds cryptonote related classes and helpers.
Definition: db_bdb.cpp:226
network_type
Definition: cryptonote_config.h:243
@ UNDEFINED
Definition: cryptonote_config.h:248
@ FAKECHAIN
Definition: cryptonote_config.h:247
@ TESTNET
Definition: cryptonote_config.h:245
@ MAINNET
Definition: cryptonote_config.h:244
@ STAGENET
Definition: cryptonote_config.h:246
const config_t & get_config(network_type nettype)
Definition: cryptonote_config.h:262
boost::uuids::uuid uuid
Definition: net_node_common.h:43
Definition: cryptonote_config.h:251
boost::uuids::uuid const NETWORK_ID
Definition: cryptonote_config.h:258
std::string const GENESIS_TX
Definition: cryptonote_config.h:259
uint16_t const ZMQ_RPC_DEFAULT_PORT
Definition: cryptonote_config.h:257
uint32_t const GENESIS_NONCE
Definition: cryptonote_config.h:260
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:254
uint16_t const RPC_DEFAULT_PORT
Definition: cryptonote_config.h:256
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:253
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
Definition: cryptonote_config.h:252
uint16_t const P2P_DEFAULT_PORT
Definition: cryptonote_config.h:255