This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
/
config.hpp
138 lines (102 loc) · 7.71 KB
/
config.hpp
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
#pragma once
#include <eosio/chain/wasm_interface.hpp>
#include <fc/time.hpp>
#pragma GCC diagnostic ignored "-Wunused-variable"
namespace eosio { namespace chain { namespace config {
typedef __uint128_t uint128_t;
const static auto default_blocks_dir_name = "blocks";
const static auto reversible_blocks_dir_name = "reversible";
const static auto default_reversible_cache_size = 340*1024*1024ll;/// 1MB * 340 blocks based on 21 producer BFT delay
const static auto default_reversible_guard_size = 2*1024*1024ll;/// 1MB * 340 blocks based on 21 producer BFT delay
const static auto default_state_dir_name = "state";
const static auto forkdb_filename = "fork_db.dat";
const static auto default_state_size = 1*1024*1024*1024ll;
const static auto default_state_guard_size = 128*1024*1024ll;
const static name system_account_name { N(eosio) };
const static name null_account_name { N(eosio.null) };
const static name producers_account_name { N(eosio.prods) };
// Active permission of producers account requires greater than 2/3 of the producers to authorize
const static name majority_producers_permission_name { N(prod.major) }; // greater than 1/2 of producers needed to authorize
const static name minority_producers_permission_name { N(prod.minor) }; // greater than 1/3 of producers needed to authorize0
const static name eosio_auth_scope { N(eosio.auth) };
const static name eosio_all_scope { N(eosio.all) };
const static name active_name { N(active) };
const static name owner_name { N(owner) };
const static name eosio_any_name { N(eosio.any) };
const static name eosio_code_name { N(eosio.code) };
const static int block_interval_ms = 500;
const static int block_interval_us = block_interval_ms*1000;
const static uint64_t block_timestamp_epoch = 946684800000ll; // epoch is year 2000.
const static uint32_t genesis_num_supported_key_types = 2;
/** Percentages are fixed point with a denominator of 10,000 */
const static int percent_100 = 10000;
const static int percent_1 = 100;
static const uint32_t account_cpu_usage_average_window_ms = 24*60*60*1000l;
static const uint32_t account_net_usage_average_window_ms = 24*60*60*1000l;
static const uint32_t block_cpu_usage_average_window_ms = 60*1000l;
static const uint32_t block_size_average_window_ms = 60*1000l;
static const uint32_t maximum_elastic_resource_multiplier = 1000;
//const static uint64_t default_max_storage_size = 10 * 1024;
//const static uint32_t default_max_trx_runtime = 10*1000;
//const static uint32_t default_max_gen_trx_size = 64 * 1024;
const static uint32_t rate_limiting_precision = 1000*1000;
const static uint32_t default_max_block_net_usage = 1024 * 1024; /// at 500ms blocks and 200byte trx, this enables ~10,000 TPS burst
const static uint32_t default_target_block_net_usage_pct = 10 * percent_1; /// we target 1000 TPS
const static uint32_t default_max_transaction_net_usage = default_max_block_net_usage / 2;
const static uint32_t default_base_per_transaction_net_usage = 12; // 12 bytes (11 bytes for worst case of transaction_receipt_header + 1 byte for static_variant tag)
const static uint32_t default_net_usage_leeway = 500; // TODO: is this reasonable?
const static uint32_t default_context_free_discount_net_usage_num = 20; // TODO: is this reasonable?
const static uint32_t default_context_free_discount_net_usage_den = 100;
const static uint32_t transaction_id_net_usage = 32; // 32 bytes for the size of a transaction id
const static uint32_t default_max_block_cpu_usage = 200'000; /// max block cpu usage in microseconds
const static uint32_t default_target_block_cpu_usage_pct = 10 * percent_1;
const static uint32_t default_max_transaction_cpu_usage = 3*default_max_block_cpu_usage/4; /// max trx cpu usage in microseconds
const static uint32_t default_min_transaction_cpu_usage = 100; /// min trx cpu usage in microseconds (10000 TPS equiv)
const static uint32_t default_subjective_cpu_leeway_us = 31000; /// default subjective cpu leeway in microseconds
const static uint32_t default_max_trx_lifetime = 60*60; // 1 hour
const static uint32_t default_deferred_trx_expiration_window = 10*60; // 10 minutes
const static uint32_t default_max_trx_delay = 45*24*3600; // 45 days
const static uint32_t default_max_inline_action_size = 4 * 1024; // 4 KB
const static uint16_t default_max_inline_action_depth = 4;
const static uint16_t default_max_auth_depth = 6;
const static uint32_t default_sig_cpu_bill_pct = 50 * percent_1; // billable percentage of signature recovery
const static uint32_t default_block_cpu_effort_pct = 80 * percent_1; // percentage of block time used for producing block
const static uint16_t default_controller_thread_pool_size = 2;
const static uint32_t default_max_variable_signature_length = 16384u;
const static uint32_t min_net_usage_delta_between_base_and_max_for_trx = 10*1024;
// Should be large enough to allow recovery from badly set blockchain parameters without a hard fork
// (unless net_usage_leeway is set to 0 and so are the net limits of all accounts that can help with resetting blockchain parameters).
const static uint32_t fixed_net_overhead_of_packed_trx = 16; // TODO: is this reasonable?
const static uint32_t fixed_overhead_shared_vector_ram_bytes = 16; ///< overhead accounts for fixed portion of size of shared_vector field
const static uint32_t overhead_per_row_per_index_ram_bytes = 32; ///< overhead accounts for basic tracking structures in a row per index
const static uint32_t overhead_per_account_ram_bytes = 2*1024; ///< overhead accounts for basic account storage and pre-pays features like account recovery
const static uint32_t setcode_ram_bytes_multiplier = 10; ///< multiplier on contract size to account for multiple copies and cached compilation
const static uint32_t hashing_checktime_block_size = 10*1024; /// call checktime from hashing intrinsic once per this number of bytes
const static eosio::chain::wasm_interface::vm_type default_wasm_runtime = eosio::chain::wasm_interface::vm_type::wabt;
const static uint32_t default_abi_serializer_max_time_us = 15*1000; ///< default deadline for abi serialization methods
/**
* The number of sequential blocks produced by a single producer
*/
const static int producer_repetitions = 12;
const static int max_producers = 125;
const static size_t maximum_tracked_dpos_confirmations = 1024; ///<
static_assert(maximum_tracked_dpos_confirmations >= ((max_producers * 2 / 3) + 1) * producer_repetitions, "Settings never allow for DPOS irreversibility" );
/**
* The number of blocks produced per round is based upon all producers having a chance
* to produce all of their consecutive blocks.
*/
//const static int blocks_per_round = producer_count * producer_repetitions;
const static int irreversible_threshold_percent= 70 * percent_1;
const static uint64_t billable_alignment = 16;
template<typename T>
struct billable_size;
template<typename T>
constexpr uint64_t billable_size_v = ((billable_size<T>::value + billable_alignment - 1) / billable_alignment) * billable_alignment;
} } } // namespace eosio::chain::config
constexpr uint64_t EOS_PERCENT(uint64_t value, uint32_t percentage) {
return (value * percentage) / eosio::chain::config::percent_100;
}
template<typename Number>
Number EOS_PERCENT_CEIL(Number value, uint32_t percentage) {
return ((value * percentage) + eosio::chain::config::percent_100 - eosio::chain::config::percent_1) / eosio::chain::config::percent_100;
}