cfx_parameters/
lib.rs

1// Copyright 2020 Conflux Foundation. All rights reserved.
2// Conflux is free software and distributed under GNU General Public License.
3// See http://www.gnu.org/licenses/
4
5#[macro_use]
6extern crate lazy_static;
7
8use cfx_types::U256;
9
10pub mod genesis;
11pub mod internal_contract_addresses;
12
13pub mod consensus {
14    pub const DEFERRED_STATE_EPOCH_COUNT: u64 = 5;
15    pub const EPOCH_SET_PERSISTENCE_DELAY: u64 = DEFERRED_STATE_EPOCH_COUNT;
16
17    pub const ADAPTIVE_WEIGHT_DEFAULT_BETA: u64 = 1000;
18    pub const HEAVY_BLOCK_DEFAULT_DIFFICULTY_RATIO: u64 = 250;
19    pub const TIMER_CHAIN_BLOCK_DEFAULT_DIFFICULTY_RATIO: u64 = 180;
20    pub const TIMER_CHAIN_DEFAULT_BETA: u64 = 240;
21    // The number of epochs per era. Each era is a potential checkpoint
22    // position. The parent_edge checking and adaptive checking are defined
23    // relative to the era start blocks.
24    pub const ERA_DEFAULT_EPOCH_COUNT: u64 = 20000;
25
26    // At Conflux MainNet Launch there are approximately 2 blocks per epoch,
27    // with 1k TPS, and 2 blocks per second, a DeltaMPT contains data for
28    // around 2 million transaction.
29    pub const SNAPSHOT_EPOCHS_CAPACITY: u32 = 2000;
30
31    pub const NULL: usize = !0;
32    pub const NULLU64: u64 = !0;
33
34    pub const MAX_BLAME_RATIO_FOR_TRUST: f64 = 0.4;
35
36    pub const TRANSACTION_DEFAULT_EPOCH_BOUND: u64 = 100000;
37
38    pub const GENESIS_GAS_LIMIT: u64 = 30_000_000;
39
40    pub const ONE_CFX_IN_DRIP: u64 = 1_000_000_000_000_000_000;
41
42    pub const ONE_UCFX_IN_DRIP: u64 = 1_000_000_000_000;
43
44    pub const ONE_GDRIP_IN_DRIP: u64 = 1_000_000_000;
45
46    /// About 2020.12.11-15:30 for both the height and the block number.
47    pub const TANZANITE_HEIGHT: u64 = 3_615_000;
48    pub const BN128_ENABLE_NUMBER: u64 = 7_600_000;
49
50    pub const TANZANITE_HEADER_CUSTOM_FIRST_ELEMENT: [u8; 1] = [1];
51    pub const DAO_VOTE_HEADER_CUSTOM_FIRST_ELEMENT: [u8; 1] = [2];
52    pub const CIP112_HEADER_CUSTOM_FIRST_ELEMENT: [u8; 1] = [3];
53    pub const NEXT_HARDFORK_HEADER_CUSTOM_FIRST_ELEMENT: [u8; 1] = [4];
54}
55
56pub mod consensus_internal {
57    use crate::consensus::{ONE_CFX_IN_DRIP, ONE_GDRIP_IN_DRIP};
58
59    /// `REWARD_EPOCH_COUNT` needs to be larger than
60    /// `ANTICONE_PENALTY_UPPER_EPOCH_COUNT`. If we cannot cache receipts of
61    /// recent `REWARD_EPOCH_COUNT` epochs, the receipts will be loaded from
62    /// db, which may lead to performance downgrade
63    pub const REWARD_EPOCH_COUNT: u64 = 12;
64    pub const ANTICONE_PENALTY_UPPER_EPOCH_COUNT: u64 = 10;
65    pub const ANTICONE_PENALTY_RATIO: u64 = 100;
66    /// The maximum number of blocks to be executed in each epoch
67    pub const EPOCH_EXECUTED_BLOCK_BOUND: usize = 200;
68    // The initial base mining reward in uCFX.
69    pub const INITIAL_BASE_MINING_REWARD_IN_UCFX: u64 = 7_000_000;
70    // The average number of blocks mined per quarter.
71    pub const MINED_BLOCK_COUNT_PER_QUARTER: u64 = 15_768_000;
72
73    pub const MINING_REWARD_TANZANITE_IN_UCFX: u64 = 2_000_000;
74    pub const GENESIS_TOKEN_COUNT_IN_CFX: u64 = 5_000_000_000;
75    pub const TWO_YEAR_UNLOCK_TOKEN_COUNT_IN_CFX: u64 = 800_000_000;
76
77    // How many quarters that the mining reward keep decaying.
78    pub const MINING_REWARD_DECAY_PERIOD_IN_QUARTER: usize = 32;
79
80    /// This is the cap of the size of the anticone barrier. If we have more
81    /// than this number we will use the brute_force O(n) algorithm instead.
82    pub const ANTICONE_BARRIER_CAP: usize = 100;
83    /// Here is the delay for us to recycle those orphaned blocks in the
84    /// boundary of eras and large epochs.
85    pub const RECYCLE_TRANSACTION_DELAY: u64 = 20;
86    /// This is the cap of the size of `blockset_in_own_view_of_epoch`. If we
87    /// have more than this number, we will not store it in memory
88    pub const BLOCKSET_IN_OWN_VIEW_OF_EPOCH_CAP: u64 = 1000;
89
90    /// This is the minimum risk that the confirmation meter tries to maintain.
91    pub const CONFIRMATION_METER_MIN_MAINTAINED_RISK: f64 = 0.00000001;
92    /// The maximum number of epochs that the confirmation meter tries to
93    /// maintain internally.
94    pub const CONFIRMATION_METER_MAX_NUM_MAINTAINED_RISK: usize = 100;
95    /// The minimum timer diff value for the adaptive test in confirmation meter
96    /// to consider
97    pub const CONFIRMATION_METER_ADAPTIVE_TEST_TIMER_DIFF: u64 = 140;
98    /// The batch step in the confirmation meter to do the adaptive test
99    pub const CONFIRMATION_METER_PSI: u64 = 30;
100    /// The maximum value of adaptive block generation risk that a confirmation
101    /// meter is going to consider safe to assume no adaptive blocks in the
102    /// near future.
103    pub const CONFIRMATION_METER_MAXIMUM_ADAPTIVE_RISK: f64 = 0.0000001;
104    /// This controls how often the confirmation meter updates. The default is
105    /// to update the meter every 20 blocks. Note that confirmation meter
106    /// update is CPU intensive if the tree graph is in a unstable state.
107    pub const CONFIRMATION_METER_UPDATE_FREQUENCY: usize = 20;
108
109    // The number of blocks to settle a DAO parameter vote.
110    // It's set to two months now.
111    pub const DAO_PARAMETER_VOTE_PERIOD: u64 =
112        super::staking::BLOCKS_PER_DAY * 30 * 2;
113    // DAO votes are only effective if the total vote count reaches this minimal
114    // percentage of pos staking tokens.
115    // The condition is checked against each voted parameter separately.
116    pub const DAO_MIN_VOTE_PERCENTAGE: u64 = 5;
117
118    /// The initial storage point proportion after CIP107 is enabled.
119    pub const CIP107_STORAGE_POINT_PROP_INIT: u64 = ONE_CFX_IN_DRIP;
120
121    /// The initial base price share proportion after CIP137 is enabled.
122    pub const CIP137_BASEFEE_PROP_INIT: u64 = ONE_CFX_IN_DRIP;
123
124    /// The initial and minimum base price
125    pub const INITIAL_1559_CORE_BASE_PRICE: u64 = ONE_GDRIP_IN_DRIP;
126
127    pub const INITIAL_1559_ETH_BASE_PRICE: u64 = 20 * ONE_GDRIP_IN_DRIP;
128
129    // Parameter specified in EIP-1559
130    pub const ELASTICITY_MULTIPLIER: usize = 2;
131}
132
133pub mod rpc {
134    pub const GAS_PRICE_BLOCK_SAMPLE_SIZE: usize = 100;
135    pub const EVM_GAS_PRICE_BLOCK_SAMPLE_SIZE: usize = 20;
136    pub const GAS_PRICE_TRANSACTION_SAMPLE_SIZE: usize = 10000;
137    pub const EVM_GAS_PRICE_TRANSACTION_SAMPLE_SIZE: usize = 1000;
138    pub const TRANSACTION_COUNT_PER_BLOCK_WATER_LINE_LOW: usize = 100;
139    pub const TRANSACTION_COUNT_PER_BLOCK_WATER_LINE_MEDIUM: usize = 600;
140    pub const GAS_PRICE_DEFAULT_VALUE: usize = 1_000_000_000;
141}
142
143pub mod sync {
144    use std::time::Duration;
145
146    /// The threshold controlling whether a node is in catch-up mode.
147    /// A node is in catch-up mode if its local best epoch number is
148    /// CATCH_UP_EPOCH_LAG_THRESHOLD behind the median of the epoch
149    /// numbers of peers.
150    pub const CATCH_UP_EPOCH_LAG_THRESHOLD: u64 = 20;
151    /// This threshold controlling whether a node should request missing
152    /// terminals from peers when the node is in catch-up mode.
153    pub const REQUEST_TERMINAL_EPOCH_LAG_THRESHOLD: u64 = 40;
154
155    /// The max number of headers that are to be sent for header
156    /// block request.
157    pub const MAX_HEADERS_TO_SEND: u64 = 512;
158    /// The max number of blocks that are to be sent for compact block request.
159    pub const MAX_BLOCKS_TO_SEND: u64 = 128;
160    /// The max number of epochs whose hashes are to be responded
161    /// for request GetBlockHashesByEpoch
162    pub const MAX_EPOCHS_TO_SEND: u64 = 128;
163    pub const MAX_PACKET_SIZE: usize = 15 * 1024 * 1024 + 512 * 1024; // 15.5 MB
164
165    /// The threshold controlling whether we should query local_block_info in
166    /// disk when requesting block header or block. If the difference
167    /// between height of the block and current best height is less than
168    /// LOCAL_BLOCK_INFO_QUERY_THRESHOLD, we can request block directly through
169    /// network, otherwise we should check disk first.
170    pub const LOCAL_BLOCK_INFO_QUERY_THRESHOLD: u64 = 5;
171
172    /// Measured block propagation delay in *seconds*. This will determine the
173    /// conservative window when we measure confirmation risk internally in
174    /// the consensus layer.
175    pub const BLOCK_PROPAGATION_DELAY: u64 = 10;
176
177    lazy_static! {
178        // The waiting time duration that will be accumulated for resending a
179        // timeout request.
180        pub static ref REQUEST_START_WAITING_TIME: Duration =
181            Duration::from_secs(1);
182
183        // The waiting time duration before resending a request which failed
184        // due to sending error.
185        pub static ref FAILED_REQUEST_RESEND_WAIT: Duration =
186            Duration::from_millis(50);
187    }
188    //const REQUEST_WAITING_TIME_BACKOFF: u32 = 2;
189    pub const DEFAULT_CHUNK_SIZE: u64 = 256 * 1024;
190}
191
192pub mod pow {
193    // This factor N controls the bound of each difficulty adjustment.
194    // The new difficulty should be in the range of [(1-1/N)*D, (1+1/N)*D],
195    // where D is the old difficulty.
196    pub const DIFFICULTY_ADJUSTMENT_FACTOR: usize = 2;
197    pub const DIFFICULTY_ADJUSTMENT_EPOCH_PERIOD: u64 = 5000;
198    pub const DIFFICULTY_ADJUSTMENT_EPOCH_PERIOD_CIP: u64 = 250;
199    // Time unit is micro-second (usec)
200    // We target two blocks per second. This strikes a good balance between the
201    // growth of the metadata, the memory consumption of the consensus graph,
202    // and the confirmation speed
203    pub const TARGET_AVERAGE_BLOCK_GENERATION_PERIOD: u64 = 500000;
204    pub const INITIAL_DIFFICULTY: u64 = 20_000_000_000;
205}
206
207pub mod tx_pool {
208    pub const TXPOOL_DEFAULT_NONCE_BITS: usize = 128;
209}
210
211pub mod block {
212    use crate::consensus::GENESIS_GAS_LIMIT;
213    use cfx_types::U256;
214
215    // The maximum block size limit in bytes
216    // Consider that the simple payment transaction consumes only 100 bytes per
217    // second. This would allow us to have 2000 simple payment transactions
218    // per block. With two blocks per second, we will have 4000TPS at the
219    // peak with only simple payment, which is good enough for now.
220    pub const MAX_BLOCK_SIZE_IN_BYTES: usize = 200 * 1024;
221    // The maximum number of transactions to be packed in a block given
222    // `MAX_BLOCK_SIZE_IN_BYTES`, assuming 50-byte transactions.
223    pub const ESTIMATED_MAX_BLOCK_SIZE_IN_TRANSACTION_COUNT: usize = 4096;
224    // The maximum number of referees allowed for each block
225    pub const REFEREE_DEFAULT_BOUND: usize = 200;
226    // The maximal length of custom data in block header
227    pub const HEADER_CUSTOM_LENGTH_BOUND: usize = 64;
228    // If a new block is more than valid_time_drift ahead of the current system
229    // timestamp, it will be discarded (but may get received again) and the
230    // peer will be disconnected.
231    pub const VALID_TIME_DRIFT: u64 = 10 * 60;
232    // A new block has to be less than this drift to send to the consensus
233    // graph. Otherwise, it will be queued at the synchronization layer.
234    pub const ACCEPTABLE_TIME_DRIFT: u64 = 5 * 60;
235    // FIXME: a block generator parameter only. We should remove this later
236    pub const MAX_TRANSACTION_COUNT_PER_BLOCK: usize = 20000;
237    pub const DEFAULT_TARGET_BLOCK_GAS_LIMIT: u64 = GENESIS_GAS_LIMIT;
238    // The following parameter controls how many blocks are allowed to
239    // contain EVM Space transactions. Setting it to N means that one block
240    // must has a height of the multiple of N to contain EVM transactions.
241    pub const EVM_TRANSACTION_BLOCK_RATIO: u64 = 5;
242    // The following parameter controls the ratio of gas limit allowed for
243    // EVM space transactions. Setting it to N means that only 1/N of th
244    // block gas limit can be used for EVM transaction enabled blocks.
245    pub const EVM_TRANSACTION_GAS_RATIO: u64 = 2;
246    // The following parameter controls the ratio of gas can be passed to EVM
247    // space in the cross space call. Setting it to N means that only 1/N of gas
248    // left can be passed to the cross space call.
249    pub const CROSS_SPACE_GAS_RATIO: u64 = 10;
250    // The following parameter controls the ratio of block gas limit for the
251    // core space after CIP1559 is enabled. Setting it to N means that only N/10
252    // of the block gas limit can be used for core space transactions.
253    pub const CIP1559_CORE_TRANSACTION_GAS_RATIO: u64 = 9;
254    // The following parameter controls the ratio of block gas limit for the
255    // espace after CIP1559 is enabled. Setting it to N means that only N/10
256    // of the block gas limit can be used for  espace transactions.
257    pub const CIP1559_ESPACE_TRANSACTION_GAS_RATIO: u64 = 5;
258
259    pub fn espace_block_gas_limit(
260        can_pack_espace_tx: bool, block_gas_limit: U256,
261    ) -> U256 {
262        if can_pack_espace_tx {
263            espace_block_gas_limit_of_enabled_block(block_gas_limit)
264        } else {
265            U256::zero()
266        }
267    }
268
269    pub fn espace_block_gas_limit_of_enabled_block(
270        block_gas_limit: U256,
271    ) -> U256 {
272        block_gas_limit * CIP1559_ESPACE_TRANSACTION_GAS_RATIO
273            / super::RATIO_BASE_TEN
274    }
275
276    pub fn cspace_block_gas_limit(
277        cip1559_enabled: bool, block_gas_limit: U256,
278    ) -> U256 {
279        if cip1559_enabled {
280            cspace_block_gas_limit_after_cip1559(block_gas_limit)
281        } else {
282            block_gas_limit
283        }
284    }
285
286    pub fn cspace_block_gas_limit_after_cip1559(block_gas_limit: U256) -> U256 {
287        block_gas_limit * CIP1559_CORE_TRANSACTION_GAS_RATIO
288            / super::RATIO_BASE_TEN
289    }
290}
291
292pub mod staking {
293    use super::pow::TARGET_AVERAGE_BLOCK_GENERATION_PERIOD;
294    use crate::consensus::ONE_CFX_IN_DRIP;
295    use cfx_types::U256;
296
297    /// This is the number of blocks per second.
298    pub const BLOCKS_PER_SECOND: u64 =
299        1000000 / TARGET_AVERAGE_BLOCK_GENERATION_PERIOD;
300    /// This is the number of blocks per hour.
301    pub const BLOCKS_PER_HOUR: u64 = BLOCKS_PER_SECOND * 60 * 60;
302    /// This is the number of blocks per day.
303    pub const BLOCKS_PER_DAY: u64 = BLOCKS_PER_SECOND * 60 * 60 * 24;
304    /// This is the number of blocks per year.
305    pub const BLOCKS_PER_YEAR: u64 = BLOCKS_PER_DAY * 365;
306    /// The inverse of interest rate
307    pub const INVERSE_INTEREST_RATE: u64 = 25;
308
309    /// This is the storage collateral units for each KiB of code, amount in
310    /// COLLATERAL_UNITs. Code collateral is calculated by each whole KiB
311    /// rounding upwards.
312    pub const CODE_COLLATERAL_UNITS_PER_KI_BYTES: u64 = 512;
313    /// This is the storage collateral units to deposit for one key/value pair
314    /// in storage. 1 CFX for 16 key value entries.
315    pub const COLLATERAL_UNITS_PER_STORAGE_KEY: u64 = 64;
316
317    lazy_static! {
318        /// This is the unit of storage collateral to deposit
319        pub static ref DRIPS_PER_STORAGE_COLLATERAL_UNIT: U256 =
320            (ONE_CFX_IN_DRIP / 1024).into();
321        /// The collaterals in drips for one key/value pair in storage.
322        pub static ref COLLATERAL_DRIPS_PER_STORAGE_KEY: U256 =
323            *DRIPS_PER_STORAGE_COLLATERAL_UNIT
324            * COLLATERAL_UNITS_PER_STORAGE_KEY;
325        /// This is the scale factor for accumulated interest rate:
326        /// `BLOCKS_PER_YEAR * 2 ^ 80`.
327        /// The actual accumulate interest rate stored will be
328        /// `accumulate_interest_rate / INTEREST_RATE_SCALE`.
329        pub static ref ACCUMULATED_INTEREST_RATE_SCALE: U256 =
330            U256::from(BLOCKS_PER_YEAR) << 80;
331        /// The initial annual interest is 4%, which means the initial interest
332        /// rate per block will be
333        /// `4% / BLOCKS_PER_YEAR`. We will multiply it with scale factor and
334        /// store it as an integer.
335        /// This is the scale factor of initial interest rate per block.
336        pub static ref INTEREST_RATE_PER_BLOCK_SCALE: U256 =
337            U256::from(BLOCKS_PER_YEAR * 1000000);
338        /// This is the initial interest rate per block with scale:
339        /// `4% / BLOCKS_PER_YEAR * INTEREST_RATE_PER_BLOCK_SCALE`.
340        pub static ref INITIAL_INTEREST_RATE_PER_BLOCK: U256 =
341            U256::from(40000);
342        /// This is the service charge rate for withdraw,
343        /// `SERVICE_CHARGE_RATE /
344        /// SERVICE_CHARGE_RATE_SCALE = 0.05%`
345        pub static ref SERVICE_CHARGE_RATE: U256 = U256::from(5);
346        pub static ref SERVICE_CHARGE_RATE_SCALE: U256 = U256::from(10000);
347        /// This controls the tokens required for one PoS vote
348        pub static ref POS_VOTE_PRICE: U256 = U256::from(1000)*ONE_CFX_IN_DRIP;
349    }
350
351    pub fn code_collateral_units(len: usize) -> u64 {
352        (len as u64 + 1023) / 1024 * CODE_COLLATERAL_UNITS_PER_KI_BYTES
353    }
354}
355
356pub mod light {
357    use std::time::Duration;
358
359    lazy_static! {
360        /// Frequency of re-triggering sync.
361        pub static ref SYNC_PERIOD: Duration = Duration::from_secs(1);
362
363        /// Frequency of checking request timeouts.
364        pub static ref CLEANUP_PERIOD: Duration = Duration::from_secs(1);
365
366        /// Frequency of sending StatusPing message to peers.
367        pub static ref HEARTBEAT_PERIOD: Duration = Duration::from_secs(30);
368
369        /// Request timeouts.
370        pub static ref EPOCH_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
371        pub static ref HEADER_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
372        pub static ref WITNESS_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
373        pub static ref BLOOM_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
374        pub static ref RECEIPT_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
375        pub static ref BLOCK_TX_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
376        pub static ref STATE_ROOT_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
377        pub static ref STATE_ENTRY_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
378        pub static ref TX_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
379        pub static ref TX_INFO_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
380        pub static ref STORAGE_ROOT_REQUEST_TIMEOUT: Duration = Duration::from_secs(2);
381
382        /// Maximum time period we wait for a response for an on-demand query.
383        /// After this timeout has been reached, we try another peer or give up.
384        pub static ref MAX_POLL_TIME: Duration = Duration::from_secs(4);
385
386        /// Items not accessed for this amount of time are removed from the cache.
387        pub static ref CACHE_TIMEOUT: Duration = Duration::from_secs(5 * 60);
388    }
389
390    /// The threshold controlling whether a node is in catch-up mode.
391    /// A node is in catch-up mode if its local best epoch number is
392    /// `CATCH_UP_EPOCH_LAG_THRESHOLD` behind the median of the epoch
393    /// numbers of peers.
394    pub const CATCH_UP_EPOCH_LAG_THRESHOLD: u64 = 3;
395
396    /// (Maximum) number of items requested in a single request.
397    pub const EPOCH_REQUEST_BATCH_SIZE: usize = 100;
398    pub const HEADER_REQUEST_BATCH_SIZE: usize = 30;
399    pub const BLOOM_REQUEST_BATCH_SIZE: usize = 30;
400    pub const WITNESS_REQUEST_BATCH_SIZE: usize = 50;
401    pub const RECEIPT_REQUEST_BATCH_SIZE: usize = 30;
402    pub const BLOCK_TX_REQUEST_BATCH_SIZE: usize = 30;
403    pub const STATE_ROOT_REQUEST_BATCH_SIZE: usize = 30;
404    pub const STATE_ENTRY_REQUEST_BATCH_SIZE: usize = 30;
405    pub const TX_REQUEST_BATCH_SIZE: usize = 30;
406    pub const TX_INFO_REQUEST_BATCH_SIZE: usize = 30;
407    pub const STORAGE_ROOT_REQUEST_BATCH_SIZE: usize = 30;
408
409    /// Maximum number of in-flight items at any given time.
410    /// If we reach this limit, we will not request any more.
411    pub const MAX_HEADERS_IN_FLIGHT: usize = 1000;
412    pub const MAX_WITNESSES_IN_FLIGHT: usize = 500;
413    pub const MAX_BLOOMS_IN_FLIGHT: usize = 500;
414    pub const MAX_RECEIPTS_IN_FLIGHT: usize = 100;
415    pub const MAX_BLOCK_TXS_IN_FLIGHT: usize = 100;
416    pub const MAX_STATE_ROOTS_IN_FLIGHT: usize = 100;
417    pub const MAX_STATE_ENTRIES_IN_FLIGHT: usize = 100;
418    pub const MAX_TXS_IN_FLIGHT: usize = 100;
419    pub const MAX_TX_INFOS_IN_FLIGHT: usize = 100;
420    pub const MAX_STORAGE_ROOTS_IN_FLIGHT: usize = 100;
421
422    /// Maximum number of in-flight epoch requests at any given time.
423    /// Similar to `MAX_HEADERS_IN_FLIGHT`. However, it is hard to match
424    /// hash responses to epoch requests, so we count the requests instead.
425    pub const MAX_PARALLEL_EPOCH_REQUESTS: usize = 10;
426
427    /// Number of epochs to request in one round (in possibly multiple batches).
428    pub const NUM_EPOCHS_TO_REQUEST: usize = 200;
429
430    /// Minimum number of missing items in the sync pipeline.
431    /// If we have fewer, we will try to request some more.
432    pub const NUM_WAITING_HEADERS_THRESHOLD: usize = 1000;
433
434    /// Max number of epochs/headers/txs to send to a light peer in a response.
435    pub const MAX_EPOCHS_TO_SEND: usize = 128;
436    pub const MAX_HEADERS_TO_SEND: usize = 512;
437    pub const MAX_TXS_TO_SEND: usize = 1024;
438    pub const MAX_WITNESSES_TO_SEND: usize = 100;
439    pub const MAX_ITEMS_TO_SEND: usize = 50;
440
441    /// During syncing, we might transiently have enough malicious blaming
442    /// blocks to consider a correct header incorrect. For this reason, we
443    /// first wait for enough header to accumulate before checking blaming.
444    /// TODO(thegaram): review value and expose this as a parameter
445    pub const BLAME_CHECK_OFFSET: u64 = 20;
446
447    /// During log filtering, we stream a set of items (blooms, receipts, txs)
448    /// to match against. To make the process faster, we need to make sure that
449    /// there's always plenty of items in flight. This way, we can reduce idle
450    /// time when we're waiting to receive an item.
451    pub const LOG_FILTERING_LOOKAHEAD: usize = 100;
452
453    // Number of blocks to sample for cfx_gasPrice.
454    pub const GAS_PRICE_BLOCK_SAMPLE_SIZE: usize = 30;
455
456    // Maximum number of transactions to sample for cfx_gasPrice.
457    pub const GAS_PRICE_TRANSACTION_SAMPLE_SIZE: usize = 1000;
458
459    pub const TRANSACTION_COUNT_PER_BLOCK_WATER_LINE_LOW: usize = 100;
460    pub const TRANSACTION_COUNT_PER_BLOCK_WATER_LINE_MEDIUM: usize = 600;
461
462    // Number of blocks we retrieve in parallel for the gas price sample.
463    pub const GAS_PRICE_BATCH_SIZE: usize = 30;
464}
465
466pub const WORKER_COMPUTATION_PARALLELISM: usize = 8;
467pub const RATIO_BASE_TEN: u64 = 10;
468pub const RATIO_BASE_HUNDRED: u64 = 100;
469
470pub struct DaoControlParameters {
471    pub pow_base_reward: U256,
472    pub pos_annual_interest_rate: U256,
473}