mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-28 16:48:13 -05:00
feat: add 4844 config and basic checks (#4245)
This commit is contained in:
@@ -20,11 +20,14 @@ pub enum InvalidTransactionError {
|
||||
#[error("Transaction's chain ID does not match.")]
|
||||
ChainIdMismatch,
|
||||
/// The transaction requires EIP-2930 which is not enabled currently.
|
||||
#[error("EIP-2930 transactions are not valid before Berlin.")]
|
||||
#[error("EIP-2930 transactions are disabled.")]
|
||||
Eip2930Disabled,
|
||||
/// The transaction requires EIP-1559 which is not enabled currently.
|
||||
#[error("EIP-1559 transactions are not valid before London.")]
|
||||
#[error("EIP-1559 transactions are disabled.")]
|
||||
Eip1559Disabled,
|
||||
/// The transaction requires EIP-4844 which is not enabled currently.
|
||||
#[error("EIP-4844 transactions are disabled.")]
|
||||
Eip4844Disabled,
|
||||
/// Thrown if a transaction is not supported in the current network configuration.
|
||||
#[error("Transaction type not supported")]
|
||||
TxTypeNotSupported,
|
||||
|
||||
@@ -381,10 +381,9 @@ impl From<reth_primitives::InvalidTransactionError> for RpcInvalidTransactionErr
|
||||
RpcInvalidTransactionError::OldLegacyChainId
|
||||
}
|
||||
InvalidTransactionError::ChainIdMismatch => RpcInvalidTransactionError::InvalidChainId,
|
||||
InvalidTransactionError::Eip2930Disabled => {
|
||||
RpcInvalidTransactionError::TxTypeNotSupported
|
||||
}
|
||||
InvalidTransactionError::Eip1559Disabled => {
|
||||
InvalidTransactionError::Eip2930Disabled |
|
||||
InvalidTransactionError::Eip1559Disabled |
|
||||
InvalidTransactionError::Eip4844Disabled => {
|
||||
RpcInvalidTransactionError::TxTypeNotSupported
|
||||
}
|
||||
InvalidTransactionError::TxTypeNotSupported => {
|
||||
|
||||
@@ -175,7 +175,8 @@ impl InvalidPoolTransactionError {
|
||||
false
|
||||
}
|
||||
InvalidTransactionError::Eip2930Disabled |
|
||||
InvalidTransactionError::Eip1559Disabled => {
|
||||
InvalidTransactionError::Eip1559Disabled |
|
||||
InvalidTransactionError::Eip4844Disabled => {
|
||||
// settings
|
||||
false
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
};
|
||||
use reth_primitives::{
|
||||
constants::ETHEREUM_BLOCK_GAS_LIMIT, ChainSpec, InvalidTransactionError, EIP1559_TX_TYPE_ID,
|
||||
EIP2930_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
|
||||
EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
|
||||
};
|
||||
use reth_provider::{AccountReader, StateProviderFactory};
|
||||
use reth_tasks::TaskSpawner;
|
||||
@@ -128,10 +128,14 @@ pub struct EthTransactionValidatorBuilder {
|
||||
chain_spec: Arc<ChainSpec>,
|
||||
/// Fork indicator whether we are in the Shanghai stage.
|
||||
shanghai: bool,
|
||||
/// Fork indicator whether we are in the Cancun hardfork.
|
||||
cancun: bool,
|
||||
/// Fork indicator whether we are using EIP-2718 type transactions.
|
||||
eip2718: bool,
|
||||
/// Fork indicator whether we are using EIP-1559 type transactions.
|
||||
eip1559: bool,
|
||||
/// Fork indicator whether we are using EIP-4844 blob transactions.
|
||||
eip4844: bool,
|
||||
/// The current max gas limit
|
||||
block_gas_limit: u64,
|
||||
/// Minimum priority fee to enforce for acceptance into the pool.
|
||||
@@ -157,9 +161,24 @@ impl EthTransactionValidatorBuilder {
|
||||
additional_tasks: 1,
|
||||
// default to true, can potentially take this as a param in the future
|
||||
propagate_local_transactions: true,
|
||||
|
||||
// TODO: can hard enable by default once transitioned
|
||||
cancun: false,
|
||||
eip4844: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Disables the Cancun fork.
|
||||
pub fn no_cancun(self) -> Self {
|
||||
self.set_cancun(false)
|
||||
}
|
||||
|
||||
/// Set the Cancun fork.
|
||||
pub fn set_cancun(mut self, cancun: bool) -> Self {
|
||||
self.cancun = cancun;
|
||||
self
|
||||
}
|
||||
|
||||
/// Disables the Shanghai fork.
|
||||
pub fn no_shanghai(self) -> Self {
|
||||
self.set_shanghai(false)
|
||||
@@ -238,8 +257,10 @@ impl EthTransactionValidatorBuilder {
|
||||
let Self {
|
||||
chain_spec,
|
||||
shanghai,
|
||||
cancun,
|
||||
eip2718,
|
||||
eip1559,
|
||||
eip4844,
|
||||
block_gas_limit,
|
||||
minimum_priority_fee,
|
||||
additional_tasks,
|
||||
@@ -252,6 +273,8 @@ impl EthTransactionValidatorBuilder {
|
||||
shanghai,
|
||||
eip2718,
|
||||
eip1559,
|
||||
cancun,
|
||||
eip4844,
|
||||
block_gas_limit,
|
||||
minimum_priority_fee,
|
||||
propagate_local_transactions,
|
||||
@@ -290,18 +313,22 @@ struct EthTransactionValidatorInner<Client, T> {
|
||||
client: Client,
|
||||
/// Fork indicator whether we are in the Shanghai stage.
|
||||
shanghai: bool,
|
||||
/// Fork indicator whether we are in the Cancun hardfork.
|
||||
cancun: bool,
|
||||
/// Fork indicator whether we are using EIP-2718 type transactions.
|
||||
eip2718: bool,
|
||||
/// Fork indicator whether we are using EIP-1559 type transactions.
|
||||
eip1559: bool,
|
||||
/// Fork indicator whether we are using EIP-4844 blob transactions.
|
||||
eip4844: bool,
|
||||
/// The current max gas limit
|
||||
block_gas_limit: u64,
|
||||
/// Minimum priority fee to enforce for acceptance into the pool.
|
||||
minimum_priority_fee: Option<u128>,
|
||||
/// Marker for the transaction type
|
||||
_marker: PhantomData<T>,
|
||||
/// Toggle to determine if a local transaction should be propagated
|
||||
propagate_local_transactions: bool,
|
||||
/// Marker for the transaction type
|
||||
_marker: PhantomData<T>,
|
||||
}
|
||||
|
||||
// === impl EthTransactionValidatorInner ===
|
||||
@@ -340,7 +367,6 @@ where
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
EIP1559_TX_TYPE_ID => {
|
||||
// Reject dynamic fee transactions until EIP-1559 activates.
|
||||
if !self.eip1559 {
|
||||
@@ -350,6 +376,15 @@ where
|
||||
)
|
||||
}
|
||||
}
|
||||
EIP4844_TX_TYPE_ID => {
|
||||
// Reject blob transactions.
|
||||
if !self.eip4844 {
|
||||
return TransactionValidationOutcome::Invalid(
|
||||
transaction,
|
||||
InvalidTransactionError::Eip4844Disabled.into(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
return TransactionValidationOutcome::Invalid(
|
||||
@@ -414,6 +449,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
// blob tx checks
|
||||
if self.cancun {
|
||||
// TODO: implement blob tx checks
|
||||
}
|
||||
|
||||
let account = match self
|
||||
.client
|
||||
.latest()
|
||||
|
||||
Reference in New Issue
Block a user