forked from mymonero/monero-core-custom
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcryptonote_config.h
512 lines (457 loc) · 27.1 KB
/
cryptonote_config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
// Copyright (c) 2014-2019, The Monero Project
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of
// conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other
// materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be
// used to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
#pragma once
#include <stdexcept>
#include <string>
#include <string_view>
#include <boost/uuid/uuid.hpp>
#include <stdexcept>
#include <chrono>
#include <array>
#include <ratio>
using namespace std::literals;
#define EMISSION_SPEED_FACTOR_PER_MINUTE (28)
#define CRYPTONOTE_MAX_BLOCK_NUMBER 500000000
#define CRYPTONOTE_MAX_TX_SIZE 1000000
#define CRYPTONOTE_MAX_TX_PER_BLOCK 0x10000000
#define CRYPTONOTE_PUBLIC_ADDRESS_TEXTBLOB_VER 0
#define CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW 60
#define CRYPTONOTE_BLOCK_FUTURE_TIME_LIMIT_V2 60*10
#define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE 10
#define CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE_V17 2
#define CRYPTONOTE_DEFAULT_TX_MIXIN 9
#define FINAL_SUBSIDY_PER_MINUTE ((uint64_t)500000000) // 3 * pow(10, 7)
#define STAKING_REQUIREMENT_LOCK_BLOCKS_EXCESS 20
#define STAKING_PORTIONS UINT64_C(0xfffffffffffffffc)
#define MAX_NUMBER_OF_CONTRIBUTORS 4
#define MIN_PORTIONS (STAKING_PORTIONS / MAX_NUMBER_OF_CONTRIBUTORS)
static_assert(STAKING_PORTIONS % 12 == 0, "Use a multiple of twelve, so that it divides evenly by two, three, or four contributors.");
#define STAKING_AUTHORIZATION_EXPIRATION_WINDOW (60*60*24*7*2) // 2 weeks
#define BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW 11
#define CRYPTONOTE_REWARD_BLOCKS_WINDOW 100
#define CRYPTONOTE_BLOCK_GRANTED_FULL_REWARD_ZONE_V1 20000 // NOTE(BDX): For testing suite, //size of block (bytes) after which reward for block calculated using block size - before first fork
#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
#define CRYPTONOTE_LONG_TERM_BLOCK_WEIGHT_WINDOW_SIZE 100000 // size in blocks of the long term block weight median window
#define CRYPTONOTE_SHORT_TERM_BLOCK_WEIGHT_SURGE_FACTOR 50
#define CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE 600
#define CRYPTONOTE_DISPLAY_DECIMAL_POINT 9
#define FEE_PER_KB ((uint64_t)2000000000) // 2 BDX (= 2 * pow(10, 9))
#define FEE_PER_BYTE ((uint64_t)215) // Fallback used in wallet if no fee is available from RPC
#define FEE_PER_BYTE_V12 ((uint64_t)17200) // Higher fee (and fallback) in v12 (only, v13 switches back)
#define FEE_PER_OUTPUT ((uint64_t)20000000) // 0.02 BDX per tx output (in addition to the per-byte fee), starting in v13
#define FEE_PER_OUTPUT_V17 ((uint64_t)100000) // 0.0001 BDX per tx output
#define DYNAMIC_FEE_PER_KB_BASE_BLOCK_REWARD ((uint64_t)10000000000) // 10 * pow(10,12)
#define DYNAMIC_FEE_PER_KB_BASE_FEE_V5 ((uint64_t)400000000)
#define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT ((uint64_t)300000)
#define DYNAMIC_FEE_REFERENCE_TRANSACTION_WEIGHT_V17 ((uint64_t)30000) // Only v17
#define DIFFICULTY_TARGET_V2 120 // seconds
#define DIFFICULTY_TARGET_V1 60 // seconds - before first fork
#define DIFFICULTY_TARGET_V17 30 //SEC
constexpr auto TARGET_BLOCK_TIME = 2min;
constexpr auto TARGET_BLOCK_TIME_V17 = 30s;
constexpr uint64_t DIFFICULTY_WINDOW = 59;
constexpr uint64_t DIFFICULTY_BLOCKS_COUNT(bool before_hf16)
{
// NOTE: We used to have a different setup here where,
// DIFFICULTY_WINDOW = 60
// DIFFICULTY_BLOCKS_COUNT = 61
// next_difficulty_v2's N = DIFFICULTY_WINDOW - 1
//
// And we resized timestamps/difficulties to (N+1) (chopping off the latest timestamp).
//
// Now we re-adjust DIFFICULTY_WINDOW to 59. To preserve the old behaviour we
// add +2. After HF16 we avoid trimming the top block and just add +1.
//
// Ideally, we just set DIFFICULTY_BLOCKS_COUNT to DIFFICULTY_WINDOW
// + 1 for before and after HF16 (having one unified constant) but this
// requires some more investigation to get it working with pre HF16 blocks and
// alt chain code without bugs.
uint64_t result = (before_hf16) ? DIFFICULTY_WINDOW + 2 : DIFFICULTY_WINDOW + 1;
return result;
}
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V2 TARGET_BLOCK_TIME * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_SECONDS_V3 TARGET_BLOCK_TIME_V17 * CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS
#define CRYPTONOTE_LOCKED_TX_ALLOWED_DELTA_BLOCKS 1
#define BLOCKS_IDS_SYNCHRONIZING_DEFAULT_COUNT 10000 //by default, blocks ids count in synchronizing
#define BLOCKS_SYNCHRONIZING_DEFAULT_COUNT 100 //by default, blocks count in blocks downloading
#define BLOCKS_SYNCHRONIZING_MAX_COUNT 2048 //must be a power of 2, greater than 128, equal to SEEDHASH_EPOCH_BLOCKS
#define CRYPTONOTE_MEMPOOL_TX_LIVETIME (86400*3) //seconds, three days
#define CRYPTONOTE_MEMPOOL_TX_FROM_ALT_BLOCK_LIVETIME (86400*7) //seconds, one week
#define MEMPOOL_PRUNE_NON_STANDARD_TX_LIFETIME (2 * 60 * 60) // seconds, 2 hours
// see src/cryptonote_protocol/levin_notify.cpp
#define CRYPTONOTE_NOISE_MIN_EPOCH 5 // minutes
#define CRYPTONOTE_NOISE_EPOCH_RANGE 30 // seconds
#define CRYPTONOTE_NOISE_MIN_DELAY 10 // seconds
#define CRYPTONOTE_NOISE_DELAY_RANGE 5 // seconds
#define CRYPTONOTE_NOISE_BYTES 3*1024 // 3 KiB
#define CRYPTONOTE_NOISE_CHANNELS 2 // Max outgoing connections per zone used for noise/covert sending
#define CRYPTONOTE_MAX_FRAGMENTS 20 // ~20 * NOISE_BYTES max payload size for covert/noise send
#define P2P_LOCAL_WHITE_PEERLIST_LIMIT 1000
#define P2P_LOCAL_GRAY_PEERLIST_LIMIT 5000
#define P2P_DEFAULT_CONNECTIONS_COUNT_OUT 8
#define P2P_DEFAULT_CONNECTIONS_COUNT_IN 32
#define P2P_DEFAULT_HANDSHAKE_INTERVAL 60 //secondes
#define P2P_DEFAULT_PACKET_MAX_SIZE 50000000 //50000000 bytes maximum packet size
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE 250
#define P2P_DEFAULT_CONNECTION_TIMEOUT 5000 //5 seconds
#define P2P_DEFAULT_SOCKS_CONNECT_TIMEOUT 45 // seconds
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT 2000 //2 seconds
#define P2P_DEFAULT_INVOKE_TIMEOUT 60*2*1000 //2 minutes
#define P2P_DEFAULT_HANDSHAKE_INVOKE_TIMEOUT 5000 //5 seconds
#define P2P_DEFAULT_WHITELIST_CONNECTIONS_PERCENT 70
#define P2P_DEFAULT_ANCHOR_CONNECTIONS_COUNT 2
#define P2P_DEFAULT_SYNC_SEARCH_CONNECTIONS_COUNT 2
#define P2P_DEFAULT_LIMIT_RATE_UP 2048 // kB/s
#define P2P_DEFAULT_LIMIT_RATE_DOWN 8192 // kB/s
#define P2P_FAILED_ADDR_FORGET_SECONDS (60*60) //1 hour
#define P2P_IP_BLOCKTIME (60*60*24) //24 hour
#define P2P_IP_FAILS_BEFORE_BLOCK 10
#define P2P_IDLE_CONNECTION_KILL_INTERVAL (5*60) //5 minutes
// TODO(doyle): Deprecate after checkpointing hardfork, remove notion of being
// able to sync non-fluffy blocks, keep here so we can still accept blocks
// pre-hardfork
#define P2P_SUPPORT_FLAG_FLUFFY_BLOCKS 0x01
#define P2P_SUPPORT_FLAGS P2P_SUPPORT_FLAG_FLUFFY_BLOCKS
#define CRYPTONOTE_NAME "beldex"
#define CRYPTONOTE_POOLDATA_FILENAME "poolstate.bin"
#define CRYPTONOTE_BLOCKCHAINDATA_FILENAME "data.mdb"
#define CRYPTONOTE_BLOCKCHAINDATA_LOCK_FILENAME "lock.mdb"
#define P2P_NET_DATA_FILENAME "p2pstate.bin"
#define MINER_CONFIG_FILE_NAME "miner_conf.json"
#define THREAD_STACK_SIZE 5 * 1024 * 1024
#define HF_VERSION_PER_BYTE_FEE cryptonote::network_version_10_bulletproofs
#define HF_VERSION_SMALLER_BP cryptonote::network_version_11_infinite_staking
#define HF_VERSION_LONG_TERM_BLOCK_WEIGHT cryptonote::network_version_11_infinite_staking
#define HF_VERSION_PER_OUTPUT_FEE cryptonote::network_version_14_enforce_checkpoints
#define HF_VERSION_ED25519_KEY cryptonote::network_version_14_enforce_checkpoints
#define HF_VERSION_FEE_BURNING cryptonote::network_version_15_flash
#define HF_VERSION_FLASH cryptonote::network_version_15_flash
#define HF_VERSION_REDUCE_FEE cryptonote::network_version_17_POS
#define HF_VERSION_MIN_2_OUTPUTS cryptonote::network_version_17_POS
#define HF_VERSION_REJECT_SIGS_IN_COINBASE cryptonote::network_version_17_POS
#define HF_VERSION_ENFORCE_MIN_AGE cryptonote::network_version_17_POS
#define HF_VERSION_EFFECTIVE_SHORT_TERM_MEDIAN_IN_PENALTY cryptonote::network_version_17_POS
#define HF_VERSION_POS cryptonote::network_version_17_POS
#define HF_VERSION_CLSAG cryptonote::network_version_15_flash
#define HF_VERSION_PROOF_BTENC cryptonote::network_version_18
#define PER_KB_FEE_QUANTIZATION_DECIMALS 8
#define HASH_OF_HASHES_STEP 256
#define VOTE_LIFETIME_HOURS 2
#define MINIMUM_CREDIT_HOURS 2
#define DEFAULT_TXPOOL_MAX_WEIGHT 648000000ull // 3 days at 300000, in bytes
#define BULLETPROOF_MAX_OUTPUTS 16
#define CRYPTONOTE_PRUNING_STRIPE_SIZE 4096 // the smaller, the smoother the increase
#define CRYPTONOTE_PRUNING_LOG_STRIPES 3 // the higher, the more space saved
#define CRYPTONOTE_PRUNING_TIP_BLOCKS 5500 // the smaller, the more space saved
//#define CRYPTONOTE_PRUNING_DEBUG_SPOOF_SEED
constexpr uint64_t PRE_POS_BLOCKS_EXPECTED_IN_HOURS(int hours) { return (1h / TARGET_BLOCK_TIME) * hours; }
constexpr uint64_t PRE_POS_BLOCKS_EXPECTED_IN_DAYS(int days) { return PRE_POS_BLOCKS_EXPECTED_IN_HOURS(24) * days; }
constexpr uint64_t PRE_POS_BLOCKS_EXPECTED_IN_YEARS(int years) { return PRE_POS_BLOCKS_EXPECTED_IN_DAYS(365) * years; }
// New constants are intended to go here
namespace config
{
inline constexpr auto DNS_TIMEOUT = 20s;
inline constexpr uint64_t DEFAULT_FEE_ATOMIC_XMR_PER_KB = 500; // Just a placeholder! Change me!
inline constexpr uint8_t FEE_CALCULATION_MAX_RETRIES = 10;
inline constexpr uint64_t DEFAULT_DUST_THRESHOLD = 2000000000; // 2 * pow(10, 9)
inline constexpr uint64_t BASE_REWARD_CLAMP_THRESHOLD = 100000000; // pow(10, 8)
// Maximum allowed stake contribution, as a fraction of the available contribution room. This
// should generally be slightly larger than 1. This is used to disallow large overcontributions
// which can happen when there are competing stakes submitted at the same time for the same
// master node.
using MAXIMUM_ACCEPTABLE_STAKE = std::ratio<101, 100>;
// Used to estimate the blockchain height from a timestamp, with some grace time. This can drift
// slightly over time (because average block time is not typically *exactly*
// DIFFICULTY_TARGET_V2).
inline constexpr uint64_t HEIGHT_ESTIMATE_HEIGHT = 582088;
inline constexpr time_t HEIGHT_ESTIMATE_TIMESTAMP = 1595359932;
inline constexpr uint64_t CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 0xd1;
inline constexpr uint64_t CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 19;
inline constexpr uint64_t CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = 42;
inline constexpr uint16_t P2P_DEFAULT_PORT = 19090;
inline constexpr uint16_t RPC_DEFAULT_PORT = 19091;
inline constexpr uint16_t ZMQ_RPC_DEFAULT_PORT = 19092;
inline constexpr uint16_t QNET_DEFAULT_PORT = 19095;
inline constexpr boost::uuids::uuid const NETWORK_ID = { {
0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x17, 0xA1, 0xB5, 0x90
} }; // Bender's nightmare
inline constexpr std::string_view GENESIS_TX = "013c01ff0005978c390224a302c019c844f7141f35bf7f0fc5b02ada055e4ba897557b17ac6ccf88f0a2c09fab030276d443549feee11fe325048eeea083fcb7535312572d255ede1ecb58f84253b480e89226023b7d7c5e6eff4da699393abf12b6e3d04eae7909ae21932520fb3166b8575bb180cab5ee0102e93beb645ce7d5574d6a5ed5d9b8aadec7368342d08a7ca7b342a428353a10df80e497d01202b6e6844c1e9a478d0e4f7f34e455b26077a51f0005357aa19a49ca16eb373f622101f7c2a3a2ed7011b61998b1cd4f45b4d3c1daaa82908a10ca191342297eef1cf8"sv;
inline constexpr uint32_t GENESIS_NONCE = 11011;
inline constexpr uint64_t GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS = PRE_POS_BLOCKS_EXPECTED_IN_DAYS(7);//Governance added from V17
inline constexpr std::array GOVERNANCE_WALLET_ADDRESS =
{
"bxcguQiBhYaDW5wAdPLSwRHA6saX1nCEYUF89SPKZfBY1BENdLQWjti59aEtAEgrVZjnCJEVFoCDrG1DCoz2HeeN2pxhxL9xa"sv, // <V17
"bxdwQ4ruRpW9QTfBpStRAMNKgdt7Rr39UcThNZ7mwsfxH7StmykPe9ah1KgJL2LwEAgqRXHLvZYBm1aaUVR8mLtB1u3WauV6P"sv, // V17
};
inline constexpr auto UPTIME_PROOF_TOLERANCE = 5min; // How much an uptime proof timestamp can deviate from our timestamp before we refuse it
inline constexpr auto UPTIME_PROOF_STARTUP_DELAY = 30s; // How long to wait after startup before broadcasting a proof
inline constexpr auto UPTIME_PROOF_CHECK_INTERVAL = 30s; // How frequently to check whether we need to broadcast a proof
inline constexpr auto UPTIME_PROOF_FREQUENCY = 1h; // How often to send proofs out to the network since the last proof we successfully sent. (Approximately; this can be up to CHECK_INTERFACE/2 off in either direction). The minimum accepted time between proofs is half of this.
inline constexpr auto UPTIME_PROOF_VALIDITY = 2h + 5min; // The maximum time that we consider an uptime proof to be valid (i.e. after this time since the last proof we consider the MN to be down)
inline constexpr auto REACHABLE_MAX_FAILURE_VALIDITY = 5min; // If we don't hear any SS ping/belnet bchat test failures for more than this long then we start considering the MN as passing for the purpose of obligation testing until we get another test result. This should be somewhat larger than SS/belnet's max re-test backoff (2min).
// Hash domain separators
inline constexpr std::string_view HASH_KEY_BULLETPROOF_EXPONENT = "bulletproof"sv;
inline constexpr std::string_view HASH_KEY_RINGDB = "ringdsb\0"sv;
inline constexpr std::string_view HASH_KEY_SUBADDRESS = "SubAddr\0"sv;
inline constexpr unsigned char HASH_KEY_ENCRYPTED_PAYMENT_ID = 0x8d;
inline constexpr unsigned char HASH_KEY_WALLET = 0x8c;
inline constexpr unsigned char HASH_KEY_WALLET_CACHE = 0x8d;
inline constexpr unsigned char HASH_KEY_RPC_PAYMENT_NONCE = 0x58;
inline constexpr unsigned char HASH_KEY_MEMORY = 'k';
inline constexpr std::string_view HASH_KEY_MULTISIG = "Multisig\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"sv;
inline constexpr std::string_view HASH_KEY_CLSAG_ROUND = "CLSAG_round"sv;
inline constexpr std::string_view HASH_KEY_CLSAG_AGG_0 = "CLSAG_agg_0"sv;
inline constexpr std::string_view HASH_KEY_CLSAG_AGG_1 = "CLSAG_agg_1"sv;
namespace testnet
{
inline constexpr uint64_t HEIGHT_ESTIMATE_HEIGHT = 339767;
inline constexpr time_t HEIGHT_ESTIMATE_TIMESTAMP = 1595360006;
inline constexpr uint64_t CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 53;
inline constexpr uint64_t CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 54;
inline constexpr uint64_t CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = 63;
inline constexpr uint16_t P2P_DEFAULT_PORT = 29090;
inline constexpr uint16_t RPC_DEFAULT_PORT = 29091;
inline constexpr uint16_t ZMQ_RPC_DEFAULT_PORT = 29092;
inline constexpr uint16_t QNET_DEFAULT_PORT = 29095;
inline constexpr boost::uuids::uuid const NETWORK_ID = { {
0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x17, 0xA1, 0xB6, 0x91
} }; // Bender's daydream
inline constexpr std::string_view GENESIS_TX = "023c01ff0001d7c1c4e81402a4b3be74714906edf0d798d22083d36983e80086d62436302684ca5bea0f312b420195937f9cb7005504052c96bf73d65d55f611c141876e5e519cef59fcb041d90872000000000000000000000000000000000000000000000000000000000000000000"sv;
inline constexpr uint32_t GENESIS_NONCE = 11012;
inline constexpr uint64_t GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS = 500;
inline constexpr std::array GOVERNANCE_WALLET_ADDRESS =
{
"A1cuNRow8sMLmKCwTWvBM2EsNUNLdkrVLLqjdagqA7XQbRcrVKNo1Cbedk1iK2b1rPFj36Jv6RKhV7J72Rs7SSL7HKFMwva"sv,
"9zjbG8Pcv3YGXxpRaDtmApCaNRHkTwizaDBS7SXtf9AndKfxVZhPki23sFTsnJcBhuKzBgTipNtMyFzzG13ax5MFUmmLmcW"sv, // hardfork >=V17
};
inline constexpr auto UPTIME_PROOF_FREQUENCY = 10min;
inline constexpr auto UPTIME_PROOF_VALIDITY = 21min;
}
namespace devnet
{
inline constexpr uint64_t HEIGHT_ESTIMATE_HEIGHT = 0;
inline constexpr time_t HEIGHT_ESTIMATE_TIMESTAMP = 1597170000;
inline constexpr uint64_t CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX = 24; // ~ dV1 .. dV3
inline constexpr uint64_t CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX = 25; // ~ dVA .. dVC
inline constexpr uint64_t CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX = 36; // ~dVa .. dVc
inline constexpr uint16_t P2P_DEFAULT_PORT = 39090;
inline constexpr uint16_t RPC_DEFAULT_PORT = 39091;
inline constexpr uint16_t ZMQ_RPC_DEFAULT_PORT = 39092;
inline constexpr uint16_t QNET_DEFAULT_PORT = 39095;
inline constexpr boost::uuids::uuid const NETWORK_ID = { {
0x12 ,0x30, 0xF1, 0x71 , 0x61, 0x04 , 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x17, 0xA1, 0xB7, 0x92
} };
inline constexpr std::string_view GENESIS_TX = "023c01ff0001d7c1c4e81402a25ba172ed7bca3b35e0be2f097b743973cf3c26777342032bed1036b19ab7a4420145706ec71eec5d57962c225b0615c172f8429984ec4954ba8b05bdad3f454f0472000000000000000000000000000000000000000000000000000000000000000000"sv;
inline constexpr uint32_t GENESIS_NONCE = 11013;
inline constexpr uint64_t GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS = PRE_POS_BLOCKS_EXPECTED_IN_DAYS(7);//governance added from V17
inline constexpr std::array GOVERNANCE_WALLET_ADDRESS =
{
"59XZKiAFwAKVyWN1CuuyFqMTTFLu9PEjpb3WhXfVuStgdoCZM1MtyJ2C41qijqfbdnY844F3boaW29geb8pT3mfrV9QQSRB"sv, // hardfork v7-9
"59XZKiAFwAKVyWN1CuuyFqMTTFLu9PEjpb3WhXfVuStgdoCZM1MtyJ2C41qijqfbdnY844F3boaW29geb8pT3mfrV9QQSRB"sv, // hardfork v10
};
inline constexpr auto UPTIME_PROOF_STARTUP_DELAY = 5s;
}
namespace fakechain {
// Fakechain uptime proofs are 60x faster than mainnet, because this really only runs on a
// hand-crafted, typically local temporary network.
inline constexpr auto UPTIME_PROOF_STARTUP_DELAY = 5s;
inline constexpr auto UPTIME_PROOF_CHECK_INTERVAL = 5s;
inline constexpr auto UPTIME_PROOF_FREQUENCY = 1min;
inline constexpr auto UPTIME_PROOF_VALIDITY = 2min + 5s;
}
}
namespace cryptonote
{
enum network_version
{
network_version_7 = 7,
network_version_8,
network_version_9_master_nodes, // Proof Of Stake w/ Service Nodes
network_version_10_bulletproofs, // Bulletproofs, Service Node Grace Registration Period, Batched Governance
network_version_11_infinite_staking, // Infinite Staking, CN-Turtle
network_version_12_security_signature,
network_version_13_checkpointing, // Checkpointing, Relaxed Deregistration, RandomXL, Beldex Storage Server
network_version_14_enforce_checkpoints,
network_version_15_flash,
network_version_16_bns,
network_version_17_POS,
network_version_18,
network_version_count,
};
enum network_type : uint8_t
{
MAINNET = 0,
TESTNET,
DEVNET,
FAKECHAIN,
UNDEFINED = 255
};
inline constexpr std::string_view network_type_str(network_type nettype)
{
switch(nettype)
{
case MAINNET: return "Mainnet"sv;
case TESTNET: return "Testnet"sv;
case DEVNET: return "Devnet"sv;
case FAKECHAIN: return "Fakenet"sv;
case UNDEFINED: return "Undefined Net"sv;
}
return "Unhandled Net"sv;
}
struct network_config
{
network_type NETWORK_TYPE;
uint64_t HEIGHT_ESTIMATE_HEIGHT;
time_t HEIGHT_ESTIMATE_TIMESTAMP;
uint64_t CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX;
uint64_t CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
uint64_t CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX;
uint16_t P2P_DEFAULT_PORT;
uint16_t RPC_DEFAULT_PORT;
uint16_t ZMQ_RPC_DEFAULT_PORT;
uint16_t QNET_DEFAULT_PORT;
boost::uuids::uuid NETWORK_ID;
std::string_view GENESIS_TX;
uint32_t GENESIS_NONCE;
uint64_t GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS;
std::array<std::string_view, 2> GOVERNANCE_WALLET_ADDRESS;
std::chrono::seconds UPTIME_PROOF_TOLERANCE;
std::chrono::seconds UPTIME_PROOF_STARTUP_DELAY;
std::chrono::seconds UPTIME_PROOF_CHECK_INTERVAL;
std::chrono::seconds UPTIME_PROOF_FREQUENCY;
std::chrono::seconds UPTIME_PROOF_VALIDITY;
inline constexpr std::string_view governance_wallet_address(int hard_fork_version) const {
return GOVERNANCE_WALLET_ADDRESS[hard_fork_version >= cryptonote::network_version_17_POS ? 1 : 0];
}
};
inline constexpr network_config mainnet_config{
MAINNET,
::config::HEIGHT_ESTIMATE_HEIGHT,
::config::HEIGHT_ESTIMATE_TIMESTAMP,
::config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX,
::config::CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX,
::config::CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX,
::config::P2P_DEFAULT_PORT,
::config::RPC_DEFAULT_PORT,
::config::ZMQ_RPC_DEFAULT_PORT,
::config::QNET_DEFAULT_PORT,
::config::NETWORK_ID,
::config::GENESIS_TX,
::config::GENESIS_NONCE,
::config::GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS,
::config::GOVERNANCE_WALLET_ADDRESS,
config::UPTIME_PROOF_TOLERANCE,
config::UPTIME_PROOF_STARTUP_DELAY,
config::UPTIME_PROOF_CHECK_INTERVAL,
config::UPTIME_PROOF_FREQUENCY,
config::UPTIME_PROOF_VALIDITY,
};
inline constexpr network_config testnet_config{
TESTNET,
::config::testnet::HEIGHT_ESTIMATE_HEIGHT,
::config::testnet::HEIGHT_ESTIMATE_TIMESTAMP,
::config::testnet::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX,
::config::testnet::CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX,
::config::testnet::CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX,
::config::testnet::P2P_DEFAULT_PORT,
::config::testnet::RPC_DEFAULT_PORT,
::config::testnet::ZMQ_RPC_DEFAULT_PORT,
::config::testnet::QNET_DEFAULT_PORT,
::config::testnet::NETWORK_ID,
::config::testnet::GENESIS_TX,
::config::testnet::GENESIS_NONCE,
::config::testnet::GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS,
::config::testnet::GOVERNANCE_WALLET_ADDRESS,
config::UPTIME_PROOF_TOLERANCE,
config::UPTIME_PROOF_STARTUP_DELAY,
config::UPTIME_PROOF_CHECK_INTERVAL,
config::testnet::UPTIME_PROOF_FREQUENCY,
config::testnet::UPTIME_PROOF_VALIDITY,
};
inline constexpr network_config devnet_config{
DEVNET,
::config::devnet::HEIGHT_ESTIMATE_HEIGHT,
::config::devnet::HEIGHT_ESTIMATE_TIMESTAMP,
::config::devnet::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX,
::config::devnet::CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX,
::config::devnet::CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX,
::config::devnet::P2P_DEFAULT_PORT,
::config::devnet::RPC_DEFAULT_PORT,
::config::devnet::ZMQ_RPC_DEFAULT_PORT,
::config::devnet::QNET_DEFAULT_PORT,
::config::devnet::NETWORK_ID,
::config::devnet::GENESIS_TX,
::config::devnet::GENESIS_NONCE,
::config::devnet::GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS,
::config::devnet::GOVERNANCE_WALLET_ADDRESS,
config::UPTIME_PROOF_TOLERANCE,
config::UPTIME_PROOF_STARTUP_DELAY,
config::UPTIME_PROOF_CHECK_INTERVAL,
config::testnet::UPTIME_PROOF_FREQUENCY,
config::testnet::UPTIME_PROOF_VALIDITY,
};
inline constexpr network_config fakenet_config{
FAKECHAIN,
::config::HEIGHT_ESTIMATE_HEIGHT,
::config::HEIGHT_ESTIMATE_TIMESTAMP,
::config::CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX,
::config::CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX,
::config::CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX,
::config::P2P_DEFAULT_PORT,
::config::RPC_DEFAULT_PORT,
::config::ZMQ_RPC_DEFAULT_PORT,
::config::QNET_DEFAULT_PORT,
::config::NETWORK_ID,
::config::GENESIS_TX,
::config::GENESIS_NONCE,
100, //::config::GOVERNANCE_REWARD_INTERVAL_IN_BLOCKS,
::config::GOVERNANCE_WALLET_ADDRESS,
config::UPTIME_PROOF_TOLERANCE,
config::fakechain::UPTIME_PROOF_STARTUP_DELAY,
config::fakechain::UPTIME_PROOF_CHECK_INTERVAL,
config::fakechain::UPTIME_PROOF_FREQUENCY,
config::fakechain::UPTIME_PROOF_VALIDITY,
};
inline constexpr const network_config& get_config(network_type nettype)
{
switch (nettype)
{
case MAINNET: return mainnet_config;
case TESTNET: return testnet_config;
case DEVNET: return devnet_config;
case FAKECHAIN: return fakenet_config;
default: throw std::runtime_error{"Invalid network type"};
}
}
}
constexpr uint64_t BLOCKS_EXPECTED_IN_HOURS(int hours, uint8_t hf_version) { return (1h / (hf_version>=cryptonote::network_version_17_POS?TARGET_BLOCK_TIME_V17:TARGET_BLOCK_TIME)) * hours; }
constexpr uint64_t BLOCKS_EXPECTED_IN_DAYS(int days, uint8_t hf_version) { return BLOCKS_EXPECTED_IN_HOURS(24,hf_version) * days; }
constexpr uint64_t BLOCKS_EXPECTED_IN_YEARS(int years, uint8_t hf_version) { return BLOCKS_EXPECTED_IN_DAYS(365,hf_version) * years; }
constexpr uint64_t BLOCKS_PER_CREDIT_EARNED = 30;