feat: add constants for slot and epoch (#2229)

This commit is contained in:
Matthias Seitz
2023-04-13 15:54:52 +02:00
committed by GitHub
parent 26caa6d32f
commit 7bcd468ab6
2 changed files with 13 additions and 3 deletions

View File

@ -17,8 +17,8 @@ use reth_payload_builder::{
PayloadJobGenerator,
};
use reth_primitives::{
bloom::logs_bloom, bytes::Bytes, proofs, Block, ChainSpec, Hardfork, Head, Header,
IntoRecoveredTransaction, Receipt, SealedBlock, EMPTY_OMMER_ROOT, U256,
bloom::logs_bloom, bytes::Bytes, constants::SLOT_DURATION, proofs, Block, ChainSpec, Hardfork,
Head, Header, IntoRecoveredTransaction, Receipt, SealedBlock, EMPTY_OMMER_ROOT, U256,
};
use reth_provider::{BlockProvider, EvmEnvProvider, PostState, StateProviderFactory};
use reth_revm::{
@ -227,7 +227,7 @@ impl Default for BasicPayloadJobGeneratorConfig {
Self {
interval: Duration::from_secs(1),
// 12s slot time
deadline: Duration::from_secs(12),
deadline: SLOT_DURATION,
max_payload_tasks: 3,
}
}

View File

@ -2,10 +2,20 @@
use crate::{H256, U256};
use hex_literal::hex;
use std::time::Duration;
/// The first four bytes of the call data for a function call specifies the function to be called.
pub const SELECTOR_LEN: usize = 4;
/// The duration of a slot in seconds.
///
/// This is the time period of 12 seconds in which a randomly chosen validator has time to propose a
/// block.
pub const SLOT_DURATION: Duration = Duration::from_secs(12);
/// An EPOCH is a series of 32 slots (~6.4min).
pub const EPOCH_DURATION: Duration = Duration::from_secs(12 * 32);
/// The minimal value the basefee can decrease to.
///
/// The `BASE_FEE_MAX_CHANGE_DENOMINATOR` <https://eips.ethereum.org/EIPS/eip-1559> is `8`, or 12.5%.