Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate kzg setting in validator #4286

Merged
merged 3 commits into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions crates/transaction-pool/src/validate/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use crate::{
TransactionValidationOutcome, TransactionValidationTaskExecutor, TransactionValidator,
};
use reth_primitives::{
constants::ETHEREUM_BLOCK_GAS_LIMIT, ChainSpec, InvalidTransactionError, EIP1559_TX_TYPE_ID,
EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
constants::{eip4844::KZG_TRUSTED_SETUP, ETHEREUM_BLOCK_GAS_LIMIT},
kzg::KzgSettings,
ChainSpec, InvalidTransactionError, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID,
LEGACY_TX_TYPE_ID,
};
use reth_provider::{AccountReader, StateProviderFactory};
use reth_tasks::TaskSpawner;
Expand Down Expand Up @@ -49,6 +51,9 @@ pub struct EthTransactionValidatorInner<Client, T> {
minimum_priority_fee: Option<u128>,
/// Toggle to determine if a local transaction should be propagated
propagate_local_transactions: bool,
/// Stores the setup and parameters needed for validating KZG proofs.
#[allow(unused)]
kzg_settings: Arc<KzgSettings>,
/// Marker for the transaction type
_marker: PhantomData<T>,
}
Expand Down Expand Up @@ -173,7 +178,7 @@ where

// blob tx checks
if self.cancun {
// TODO: implement blob tx checks
// TODO: validate blob txs, if missing try load from blob store
}

let account = match self
Expand Down Expand Up @@ -256,6 +261,9 @@ pub struct EthTransactionValidatorBuilder {
additional_tasks: usize,
/// Toggle to determine if a local transaction should be propagated
propagate_local_transactions: bool,

/// Stores the setup and parameters needed for validating KZG proofs.
kzg_settings: Arc<KzgSettings>,
}

impl EthTransactionValidatorBuilder {
Expand All @@ -271,6 +279,7 @@ impl EthTransactionValidatorBuilder {
additional_tasks: 1,
// default to true, can potentially take this as a param in the future
propagate_local_transactions: true,
kzg_settings: Arc::clone(&KZG_TRUSTED_SETUP),

// TODO: can hard enable by default once transitioned
cancun: false,
Expand Down Expand Up @@ -321,6 +330,13 @@ impl EthTransactionValidatorBuilder {
self.eip1559 = eip1559;
self
}

/// Sets the [KzgSettings] to use for validating KZG proofs.
pub fn kzg_settings(mut self, kzg_settings: Arc<KzgSettings>) -> Self {
self.kzg_settings = kzg_settings;
self
}

/// Sets toggle to propagate transactions received locally by this client (e.g
/// transactions from eth_Sendtransaction to this nodes' RPC server)
///
Expand Down Expand Up @@ -378,6 +394,7 @@ impl EthTransactionValidatorBuilder {
minimum_priority_fee,
additional_tasks,
propagate_local_transactions,
kzg_settings,
} = self;

let inner = EthTransactionValidatorInner {
Expand All @@ -392,6 +409,7 @@ impl EthTransactionValidatorBuilder {
minimum_priority_fee,
propagate_local_transactions,
blob_store: Box::new(blob_store),
kzg_settings,
_marker: Default::default(),
};

Expand Down
Loading