mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add minimal protocol base fee (#2121)
This commit is contained in:
@ -1,11 +1,21 @@
|
||||
//! Ethereum protocol-related constants
|
||||
|
||||
use crate::H256;
|
||||
use crate::{H256, U256};
|
||||
use hex_literal::hex;
|
||||
|
||||
/// 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 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%.
|
||||
/// Once the base fee has dropped to `7` WEI it cannot decrease further because 12.5% of 7 is less
|
||||
/// than 1.
|
||||
pub const MIN_PROTOCOL_BASE_FEE: u128 = 7;
|
||||
|
||||
/// Same as [MIN_PROTOCOL_BASE_FEE] but as a U256.
|
||||
pub const MIN_PROTOCOL_BASE_FEE_U256: U256 = U256::from_limbs([7u64, 0, 0, 0]);
|
||||
|
||||
/// Initial base fee as defined in [EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)
|
||||
pub const EIP1559_INITIAL_BASE_FEE: u64 = 1_000_000_000;
|
||||
|
||||
@ -56,3 +66,13 @@ pub const EMPTY_TRANSACTIONS: H256 = EMPTY_SET_HASH;
|
||||
|
||||
/// Withdrawals root of empty withdrawals set.
|
||||
pub const EMPTY_WITHDRAWALS: H256 = EMPTY_SET_HASH;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn min_protocol_sanity() {
|
||||
assert_eq!(MIN_PROTOCOL_BASE_FEE_U256.to::<u128>(), MIN_PROTOCOL_BASE_FEE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use reth_primitives::{
|
||||
constants::MIN_PROTOCOL_BASE_FEE_U256,
|
||||
proofs::{self, EMPTY_LIST_HASH},
|
||||
Address, Block, Bloom, Bytes, Header, SealedBlock, TransactionSigned, UintTryTo, Withdrawal,
|
||||
H256, U256, U64,
|
||||
@ -79,7 +80,7 @@ impl TryFrom<ExecutionPayload> for SealedBlock {
|
||||
return Err(PayloadError::ExtraData(payload.extra_data))
|
||||
}
|
||||
|
||||
if payload.base_fee_per_gas == U256::ZERO {
|
||||
if payload.base_fee_per_gas < MIN_PROTOCOL_BASE_FEE_U256 {
|
||||
return Err(PayloadError::BaseFee(payload.base_fee_per_gas))
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ use crate::{
|
||||
ValidPoolTransaction, U256,
|
||||
};
|
||||
use fnv::FnvHashMap;
|
||||
use reth_primitives::{TxHash, H256};
|
||||
use reth_primitives::{constants::MIN_PROTOCOL_BASE_FEE, TxHash, H256};
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::{btree_map::Entry, hash_map, BTreeMap, HashMap},
|
||||
@ -26,13 +26,6 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
/// 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%.
|
||||
/// Once the base fee has dropped to `7` WEI it cannot decrease further because 12.5% of 7 is less
|
||||
/// than 1.
|
||||
pub(crate) const MIN_PROTOCOL_BASE_FEE: u128 = 7;
|
||||
|
||||
/// A pool that manages transactions.
|
||||
///
|
||||
/// This pool maintains the state of all transactions and stores them accordingly.
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::{
|
||||
identifier::{SenderIdentifiers, TransactionId},
|
||||
pool::txpool::{TxPool, MIN_PROTOCOL_BASE_FEE},
|
||||
pool::txpool::TxPool,
|
||||
traits::TransactionOrigin,
|
||||
PoolTransaction, TransactionOrdering, ValidPoolTransaction,
|
||||
};
|
||||
@ -12,8 +12,9 @@ use rand::{
|
||||
prelude::Distribution,
|
||||
};
|
||||
use reth_primitives::{
|
||||
Address, FromRecoveredTransaction, IntoRecoveredTransaction, Transaction, TransactionKind,
|
||||
TransactionSignedEcRecovered, TxEip1559, TxHash, TxLegacy, TxType, H256, U128, U256,
|
||||
constants::MIN_PROTOCOL_BASE_FEE, Address, FromRecoveredTransaction, IntoRecoveredTransaction,
|
||||
Transaction, TransactionKind, TransactionSignedEcRecovered, TxEip1559, TxHash, TxLegacy,
|
||||
TxType, H256, U128, U256,
|
||||
};
|
||||
use std::{ops::Range, sync::Arc, time::Instant};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user