Electroneum
cryptonote_config.h
Go to the documentation of this file.
1 // Copyrights(c) 2017-2021, 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 60000
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_ETN_UNLOCK_WINDOW 18
46 #define ETN_MINED_ETN_UNLOCK_WINDOW_V8 5
47 #define CURRENT_TRANSACTION_VERSION 3
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 // ETN_SUPPLY - total number coins to be generated
57 #define ETN_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_BLOCK_GRANTED_FULL_REWARD_ZONE_V10 500000 //size of block (bytes) after which reward for block calculated using block size - fourth change, from v10
69 #define CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE 100000 // size in blocks of the long term block weight median window
70 #define CRYPTONOTE_SHORT_TERM_BLOCK_WEIGHT_SURGE_FACTOR 50
71 #define CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE 600
72 #define CRYPTONOTE_DISPLAY_DECIMAL_POINT 2
73 // COIN - number of smallest units in one coin. This definition is only used for tests.
74 #define COIN ((uint64_t)100) // pow(10, 2)
75 
76 #define FEE_PER_KB ((uint64_t)1) //Initial fee of 0.01/kb
77 #define FEE_PER_KB_V6 ((uint64_t)10) //Fee of 0.10/kb from HF V6
78 #define FEE_PER_KB_V11 ((uint64_t)0) // Fee of 0ETN/Kb from HF 11
79 
80 #define FEE_PER_BYTE ((uint64_t)30)
81 
82 #define DEFAULT_MIX 0
83 #define DEFAULT_RINGSIZE (DEFAULT_MIX + 1)
84 
85 #define DYNAMIC_FEE_PER_KB_BASE_FEE ((uint64_t)2000000000) // 2 * pow(10,9)
86 #define DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD ((uint64_t)10000000000000) // 10 * pow(10,12)
87 #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)
88 #define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT ((uint64_t)3000)
89 
90 #define ORPHANED_BLOCKS_MAX_COUNT 100
91 
92 #define DIFFICULTY_TARGET 60 // seconds
93 #define DIFFICULTY_TARGET_V6 120 // seconds
94 #define DIFFICULTY_WINDOW 720 // blocks
95 #define DIFFICULTY_WINDOW_V6 360 // blocks
96 #define DIFFICULTY_LAG 15 // !!!
97 #define DIFFICULTY_CUT 60 // timestamps to cut after sorting
98 #define DIFFICULTY_BLOCKS_COUNT DIFFICULTY_WINDOW + DIFFICULTY_LAG
99 #define DIFFICULTY_BLOCKS_COUNT_V6 DIFFICULTY_WINDOW_V6 + DIFFICULTY_LAG
100 
101 
102 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
103 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS DIFFICULTY_TARGET * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
104 #define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V6 DIFFICULTY_TARGET_V6 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
105 
106 
107 #define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN DIFFICULTY_TARGET //just alias; used by tests
108 #define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN_V6 DIFFICULTY_TARGET_V6 //just alias; used by tests
109 
110 
111 #define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
112 #define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT_PRE_V4 100 //by default, blocks count in blocks downloading
113 #define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 20 //by default, blocks count in blocks downloading
114 
115 #define CRYPTONOTE_MEMPOOL_TX_LIVETIME 86400 //seconds, one day
116 #define CRYPTONOTE_MEMPOOL_TX_LIVETIME_V6 (86400*3) //seconds, three days
117 #define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME 604800 //seconds, one week
118 
119 #define COMMAND_RPC_GET_BLOCKS_FAST_MAX_COUNT 1000
120 
121 #define P2P_LOCAL_WHITE_PEERLIST_LIMIT 1000
122 #define P2P_LOCAL_GRAY_PEERLIST_LIMIT 5000
123 
124 #define P2P_DEFAULT_CONNECTIONS_COUNT 8
125 #define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
126 #define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
127 #define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
128 #define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
129 #define P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT 45 // seconds
130 #define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
131 #define P2P_DEFAULT_INVOKE_TIMEOUT 60*2*1000 //2 minutes
132 #define P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT 5000 //5 seconds
133 #define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70
134 #define P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT 2
135 #define P2P_DEFAULT_SYNC_SEARCH_CONNECTIONS_COUNT 2
136 #define P2P_DEFAULT_LIMIT_RATE_UP 2048 // kB/s
137 #define P2P_DEFAULT_LIMIT_RATE_DOWN 8192 // kB/s
138 
139 #define P2P_FAILED_ADDR_FORGET_SECONDS (60*60) //1 hour
140 #define P2P_IP_BLOCKTIME (60*60*24) //24 hour
141 #define P2P_IP_FAILS_BEFORE_BLOCK 10
142 #define P2P_IDLE_CONNECTION_KILL_INTERVAL (5*60) //5 minutes
143 
144 #define P2P_SUPPORT_FLAG_FLUFFY_BLOCKS 0x01
145 #define P2P_SUPPORT_FLAGS P2P_SUPPORT_FLAG_FLUFFY_BLOCKS
146 
147 #define ALLOW_DEBUG_COMMANDS
148 
149 #define CRYPTONOTE_NAME "electroneum"
150 #define CRYPTONOTE_POOLDATA_FILENAME "poolstate.bin"
151 #define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "data.mdb"
152 #define CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME "lock.mdb"
153 #define P2P_NET_DATA_FILENAME "p2pstate.bin"
154 #define MINER_CONFIG_FILE_NAME "miner_conf.json"
155 
156 #define THREAD_STACK_SIZE 5 * 1024 * 1024
157 
158 #define CURRENT_HARDFORK_VERSION 11
159 #define HF_VERSION_FORBID_DUST_OUTPUTS 2
160 #define HF_VERSION_FORBID_INVALID_PUBKEYS 4
161 #define HF_VERSION_ENFORCE_0_DECOY_TXS 6
162 #define HF_VERSION_ENFORCE_0_DECOY_TXS_END 100
163 #define HF_VERSION_DYNAMIC_FEE 100
164 #define HF_VERSION_ZERO_FEE 11
165 #define HF_VERSION_MIN_MIXIN_2 2
166 #define HF_VERSION_MIN_MIXIN_4 100
167 #define HF_VERSION_MIN_MIXIN_6 100
168 #define HF_VERSION_MIN_MIXIN_10 100
169 #define HF_VERSION_MAX_RING_11 100
170 #define HF_VERSION_ENABLE_RCT 100
171 #define HF_VERSION_ENFORCE_RCT 100
172 #define HF_VERSION_PER_BYTE_FEE 100
173 #define HF_VERSION_SMALLER_BP 100
174 #define HF_VERSION_LONG_TERM_BLOCK_WEIGHT 100
175 #define HF_VERSION_ORDERED_TX_INPUTS 100
176 #define HF_VERSION_ALLOW_BULLETPROOF 100
177 #define HF_VERSION_FORBIT_BORROMEAN_RANGE_PROOFS HF_VERSION_ALLOW_BULLETPROOF + 1
178 #define HF_VERSION_PUBLIC_TX 10
179 
180 
181 #define PER_KB_FEE_QUANTIZATION_DECIMALS 2
182 
183 #define DEFAULT_TXPOOL_MAX_WEIGHT 648000000ull // 3 days at 300000, in bytes
184 
185 #define BULLETPROOF_MAX_OUTPUTS 16
186 
187 #define CRYPTONOTE_PRUNING_STRIPE_SIZE 4096 // the smaller, the smoother the increase
188 #define CRYPTONOTE_PRUNING_LOG_STRIPES 3 // the higher, the more space saved
189 #define CRYPTONOTE_PRUNING_TIP_BLOCKS 5500 // the smaller, the more space saved
190 //#define CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
191 
192 // New constants are intended to go here
193 namespace config
194 {
195  uint64_t const DEFAULT_FEE_ATOMIC_ETN_PER_KB = 500; // Just a placeholder! Change me!
198  uint64_t const BASE_REWARD_CLAMP_THRESHOLD = ((uint64_t)100000000); // pow(10, 8)
199  std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY = "0000000000000000000000000000000000000000000000000000000000000000";
200 
204  uint16_t const P2P_DEFAULT_PORT = 26967;
205  uint16_t const RPC_DEFAULT_PORT = 26968;
208  0x04, 0xF8, 0x23, 0xE1, 0x66, 0xC2, 0xE3, 0xA4, 0xEA, 0x5D, 0xD1, 0x2C, 0x85, 0x8E, 0xC8, 0x39
209  } };
210  std::string const GENESIS_TX = "011201ff00011e026bc5c7db8a664f652d78adb587ac4d759c6757258b64ef9cba3c0354e64fb2e42101abca6a39c561d0897be183eb0143990eba201aa7d2c652ab0555d28bb4b70728";
211  uint32_t const GENESIS_NONCE = 10000;
212 
213  namespace testnet
214  {
218  uint16_t const P2P_DEFAULT_PORT = 34567;
219  uint16_t const RPC_DEFAULT_PORT = 34568;
222  0x04, 0xF8, 0x23, 0xE1, 0x66, 0xC2, 0xE3, 0xA4, 0xEA, 0x5D, 0xD1, 0x2C, 0x85, 0x8E, 0xC8, 0x41
223  } };
224  std::string const GENESIS_TX = "011201ff000180bcf5dace2102a7957ab8394540efaa5bc93d747d6c56d8bf87b1c955574963dfbcf62ab13b5c210120d88af73976c98be9819df7e85bc21167d3194e242afd50601e398243c354b6";
225  uint32_t const GENESIS_NONCE = 10000;
226  }
227 
228  namespace stagenet
229  {
233  uint16_t const P2P_DEFAULT_PORT = 38080;
234  uint16_t const RPC_DEFAULT_PORT = 38081;
237  0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x12
238  } }; // Bender's daydream
239  std::string const GENESIS_TX = "013c01ff0001ffffffffffff0302df5d56da0c7d643ddd1ce61901c7bdc5fb1738bfe39fbe69c28a3a7032729c0f2101168d0c4ca86fb55a4cf6a36d31431be1c53a3bd7411bb24e8832410289fa6f3b";
240  uint32_t const GENESIS_NONCE = 10002;
241  }
242 }
243 
244 namespace cryptonote
245 {
247  {
248  MAINNET = 0,
252  UNDEFINED = 255
253  };
254  struct config_t
255  {
265  };
266  inline const config_t& get_config(network_type nettype)
267  {
268  static const config_t mainnet = {
278  };
279  static const config_t testnet = {
289  };
290  static const config_t stagenet = {
300  };
301  switch (nettype)
302  {
303  case MAINNET: return mainnet;
304  case TESTNET: return testnet;
305  case STAGENET: return stagenet;
306  case FAKECHAIN: return mainnet;
307  default: throw std::runtime_error("Invalid network type");
308  }
309  };
310 }
const config_t & get_config(network_type nettype)
uint16_t const P2P_DEFAULT_PORT
uint16_t const ZMQ_RPC_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
uint32_t const GENESIS_NONCE
boost::uuids::uuid uuid
uint16_t const P2P_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
::std::string string
Definition: gtest-port.h:1097
uint16_t const RPC_DEFAULT_PORT
uint64_t const DEFAULT_FEE_ATOMIC_ETN_PER_KB
std::string const P2P_REMOTE_DEBUG_TRUSTED_PUB_KEY
unsigned short uint16_t
Definition: stdint.h:125
uint16_t const P2P_DEFAULT_PORT
std::string const GENESIS_TX
boost::uuids::uuid const NETWORK_ID
unsigned char uint8_t
Definition: stdint.h:124
uint16_t const RPC_DEFAULT_PORT
Holds cryptonote related classes and helpers.
Definition: ban.cpp:40
boost::uuids::uuid const NETWORK_ID
uint32_t const GENESIS_NONCE
unsigned int uint32_t
Definition: stdint.h:126
uint16_t const ZMQ_RPC_DEFAULT_PORT
std::string const GENESIS_TX
unsigned __int64 uint64_t
Definition: stdint.h:136
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
uint16_t const ZMQ_RPC_DEFAULT_PORT
std::string const GENESIS_TX
uint16_t const ZMQ_RPC_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
uint16_t const RPC_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
uint64_t const BASE_REWARD_CLAMP_THRESHOLD
uint16_t const P2P_DEFAULT_PORT
uint64_t const DEFAULT_DUST_THRESHOLD
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
uint64_t const CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX
std::string const GENESIS_TX
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
uint32_t const GENESIS_NONCE
uint32_t const GENESIS_NONCE
boost::uuids::uuid const NETWORK_ID
uint16_t const RPC_DEFAULT_PORT
uint64_t const CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX
uint64_t const CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX
boost::uuids::uuid const NETWORK_ID
uint8_t const FEE_CALCULATION_MAX_RETRIES