Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,4 @@ prost-build = "0.13"
protox = "0.7"
criterion = "0.7.0"
jsonrpsee = { version = "0.26.0", features = ["server", "client", "macros"] }
futures = "0.3"
10 changes: 6 additions & 4 deletions crates/node/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ use reth_rpc_eth_api::FromEvmError;
use reth_rpc_eth_types::EthApiError;
use reth_tracing::tracing::{debug, info};
use reth_transaction_pool::{
EthPoolTransaction, EthTransactionPool, PoolTransaction, TransactionValidationTaskExecutor,
EthPoolTransaction, PoolTransaction, TransactionValidationTaskExecutor,
blobstore::DiskFileBlobStore,
};
use std::{default::Default, sync::Arc, time::SystemTime};
use tempo_chainspec::spec::{TEMPO_BASE_FEE, TempoChainSpec};
use tempo_evm::evm::TempoEvmFactory;
use tempo_transaction_pool::transaction::TempoPooledTransaction;
use tempo_transaction_pool::{
TempoTransactionPool, transaction::TempoPooledTransaction, validator::TempoTransactionValidator,
};

/// Type configuration for a regular Ethereum node.
#[derive(Debug, Default, Clone)]
Expand Down Expand Up @@ -358,7 +360,7 @@ where
Node: FullNodeTypes<Types: NodeTypes<ChainSpec: EthereumHardforks>>,
T: EthPoolTransaction<Consensus = TxTy<Node::Types>> + PoolTransaction,
{
type Pool = EthTransactionPool<Node::Provider, DiskFileBlobStore, T>;
type Pool = TempoTransactionPool<Node::Provider, DiskFileBlobStore, T>;

async fn build_pool(self, ctx: &BuilderContext<Node>) -> eyre::Result<Self::Pool> {
let mut pool_config = ctx.pool_config().clone();
Expand Down Expand Up @@ -408,7 +410,7 @@ where
});
}

// TODO: custom tempo tx validation
let validator = validator.map(|validator| TempoTransactionValidator::new(validator));
let transaction_pool = TxPoolBuilder::new(ctx)
.with_validator(validator)
.build_and_spawn_maintenance_task(blob_store, pool_config)?;
Expand Down
1 change: 1 addition & 0 deletions crates/precompiles/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ description = "TODO:"

[dependencies]
reth-evm.workspace = true
reth-storage-api.workspace = true
alloy = { workspace = true, features = ["contract", "sol-types", "rpc"] }
alloy-evm.workspace = true
alloy-consensus.workspace = true
Expand Down
1 change: 1 addition & 0 deletions crates/precompiles/src/contracts/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod provider;
pub mod roles;
pub mod storage;
pub mod tip20;
Expand Down
42 changes: 42 additions & 0 deletions crates/precompiles/src/contracts/provider.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
use alloy_primitives::{Address, U256};
use reth_evm::revm::interpreter::instructions::utility::IntoAddress;
use reth_storage_api::{StateProvider, errors::ProviderResult};

use crate::{
TIP_FEE_MANAGER_ADDRESS,
contracts::{storage::slots::mapping_slot, tip_fee_manager, tip20},
};

/// Provides access to TIPFeeManager storage to fetch fee token data and balances
pub trait TIPFeeStorageProvider {
/// Get fee token balance for a user.
///
/// Returns the user's balance in their configured fee token. Falls back to
/// validator token if user has no token set.
fn get_fee_token_balance(&self, user: Address) -> ProviderResult<U256>;
}

/// Implementation of TIPFeeManager storage operations for generic [`StateProvider`]
impl<T: StateProvider> TIPFeeStorageProvider for T {
fn get_fee_token_balance(&self, user: Address) -> ProviderResult<U256> {
// Look up user's configured fee token in TIPFeeManager storage
let user_token_slot = mapping_slot(user, tip_fee_manager::slots::USER_TOKENS);
let fee_token = self
.storage(TIP_FEE_MANAGER_ADDRESS, user_token_slot.into())?
.unwrap_or_default()
.into_address();

if fee_token.is_zero() {
// TODO: how to handle getting validator fee token? Should we get the next validator or
// default to some token?
}

// Query the user's balance in the determined fee token's TIP20 contract
let balance_slot = mapping_slot(user, tip20::slots::BALANCES);
let balance = self
.storage(fee_token, balance_slot.into())?
.unwrap_or_default();

Ok(balance)
}
}
10 changes: 10 additions & 0 deletions crates/transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@ rust-version.workspace = true
# workspace = true

[dependencies]
tempo-precompiles.workspace = true
reth-transaction-pool.workspace = true
reth-chainspec.workspace = true
reth-ethereum-primitives.workspace = true
reth-evm.workspace = true
reth-primitives-traits.workspace = true
reth-storage-api.workspace = true
alloy.workspace = true
alloy-consensus.workspace = true
alloy-primitives.workspace = true
alloy-eips.workspace = true
futures.workspace = true

[dev-dependencies]
reth-transaction-pool.workspace = true
alloy-eips.workspace = true
reth-provider = { workspace = true, features = ["test-utils"] }
tokio.workspace = true
12 changes: 12 additions & 0 deletions crates/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
use reth_transaction_pool::{
CoinbaseTipOrdering, EthPooledTransaction, Pool, TransactionValidationTaskExecutor,
};

use crate::validator::TempoTransactionValidator;

pub mod transaction;
pub mod validator;

pub type TempoTransactionPool<Client, S, T = EthPooledTransaction> = Pool<
TransactionValidationTaskExecutor<TempoTransactionValidator<Client, T>>,
CoinbaseTipOrdering<T>,
S,
>;
239 changes: 222 additions & 17 deletions crates/transaction-pool/src/validator.rs

Large diffs are not rendered by default.

Loading