Skip to content

Commit

Permalink
Refactor Taiko specific re-exports for improved code readability and …
Browse files Browse the repository at this point in the history
…maintainability
  • Loading branch information
johntaiko committed Aug 14, 2024
1 parent 966cbf9 commit 95bb990
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 40 deletions.
9 changes: 0 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/taiko/consensus/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use reth_chainspec::{Chain, ChainSpec, Hardfork};
use reth_chainspec::ChainSpec;
use reth_consensus::{Consensus, ConsensusError, PostExecutionInput};
use reth_consensus_common::validation::{
validate_4844_header_standalone, validate_against_parent_4844,
Expand Down
10 changes: 0 additions & 10 deletions crates/taiko/consensus/proposer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,20 @@ workspace = true
[dependencies]
# reth
reth-chainspec.workspace = true
reth-beacon-consensus.workspace = true
reth-primitives.workspace = true
reth-execution-errors.workspace = true
reth-execution-types.workspace = true
reth-network-p2p.workspace = true
reth-provider.workspace = true
reth-stages-api.workspace = true
reth-revm.workspace = true
reth-transaction-pool.workspace = true
reth-evm.workspace = true
reth-engine-primitives.workspace = true
reth-consensus.workspace = true
reth-rpc-types.workspace = true
reth-network-peers.workspace = true
reth-tokio-util.workspace = true
reth-rpc-types-compat.workspace = true

# taiko
taiko-reth-evm.workspace = true

# async
futures-util.workspace = true
tokio = { workspace = true, features = ["sync", "time"] }
tokio-stream.workspace = true
tracing.workspace = true

# misc
Expand Down
10 changes: 5 additions & 5 deletions crates/taiko/consensus/proposer/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This includes download client implementations for auto sealing miners.
use crate::{TriggerArgs, TriggerResult};
use crate::{TaskArgs, TaskResult};
use reth_execution_errors::BlockExecutionError;
use reth_primitives::Address;
use std::fmt::Debug;
Expand All @@ -13,11 +13,11 @@ use tokio::sync::{mpsc::UnboundedSender, oneshot};
/// blocks in memory.
#[derive(Debug, Clone)]
pub struct ProposerClient {
trigger_args_tx: UnboundedSender<TriggerArgs>,
trigger_args_tx: UnboundedSender<TaskArgs>,
}

impl ProposerClient {
pub(crate) const fn new(trigger_args_tx: UnboundedSender<TriggerArgs>) -> Self {
pub(crate) const fn new(trigger_args_tx: UnboundedSender<TaskArgs>) -> Self {
Self { trigger_args_tx }
}

Expand All @@ -32,10 +32,10 @@ impl ProposerClient {
local_accounts: Vec<Address>,
max_transactions_lists: u64,
min_tip: u64,
) -> Result<Vec<TriggerResult>, BlockExecutionError> {
) -> Result<Vec<TaskResult>, BlockExecutionError> {
let (tx, rx) = oneshot::channel();
self.trigger_args_tx
.send(TriggerArgs {
.send(TaskArgs {
beneficiary,
base_fee,
block_max_gas_limit,
Expand Down
16 changes: 8 additions & 8 deletions crates/taiko/consensus/proposer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where

/// Arguments for the trigger
#[derive(Debug)]
pub struct TriggerArgs {
pub struct TaskArgs {
/// Address of the beneficiary
pub beneficiary: Address,
/// Base fee
Expand All @@ -155,12 +155,12 @@ pub struct TriggerArgs {
/// Minimum tip
pub min_tip: u64,

tx: oneshot::Sender<Result<Vec<TriggerResult>, BlockExecutionError>>,
tx: oneshot::Sender<Result<Vec<TaskResult>, BlockExecutionError>>,
}

/// Result of the trigger
#[derive(Debug)]
pub struct TriggerResult {
pub struct TaskResult {
/// Transactions
pub txs: Vec<Transaction>,
/// Estimated gas used
Expand Down Expand Up @@ -266,7 +266,7 @@ impl Storage {
max_bytes_per_tx_list: u64,
max_transactions_lists: u64,
base_fee: u64,
) -> Result<Vec<TriggerResult>, BlockExecutionError>
) -> Result<Vec<TaskResult>, BlockExecutionError>
where
Executor: BlockExecutorProvider,
Provider: StateProviderFactory + BlockReaderIdExt,
Expand Down Expand Up @@ -320,14 +320,14 @@ impl Storage {
if idx - chunk_start >= max_transactions_lists as usize
|| compressed_buf.len() > max_bytes_per_tx_list as usize
{
// the first transaction is too large, so we need to split it
// the first transaction in chunk is too large, so we need to skip it
if idx == chunk_start {
gas_used_start = receipts[idx].cumulative_gas_used;
chunk_start += 1;
None
} else {
// next chunk if reach the max_transactions_lists or max_bytes_per_tx_list
// and use previous transaction's status
// current chunk reaches the max_transactions_lists or max_bytes_per_tx_list
// and use previous transaction's data
let estimated_gas_used =
receipts[idx - 1].cumulative_gas_used - gas_used_start;
gas_used_start = receipts[idx - 1].cumulative_gas_used;
Expand All @@ -340,7 +340,7 @@ impl Storage {
None
}
} {
tx_lists.push(TriggerResult {
tx_lists.push(TaskResult {
txs: body[txs_range]
.iter()
.cloned()
Expand Down
10 changes: 5 additions & 5 deletions crates/taiko/consensus/proposer/src/task.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Storage, TriggerArgs};
use crate::{Storage, TaskArgs};
use futures_util::{future::BoxFuture, FutureExt};
use reth_chainspec::ChainSpec;
use reth_evm::execute::BlockExecutorProvider;
Expand Down Expand Up @@ -27,12 +27,12 @@ pub struct ProposerTask<Client, Pool: TransactionPool, Executor> {
/// backlog of sets of transactions ready to be mined
#[allow(clippy::type_complexity)]
queued: VecDeque<(
TriggerArgs,
TaskArgs,
Vec<Arc<ValidPoolTransaction<<Pool as TransactionPool>::Transaction>>>,
)>,
/// The type used for block execution
block_executor: Executor,
trigger_args_rx: UnboundedReceiver<TriggerArgs>,
trigger_args_rx: UnboundedReceiver<TaskArgs>,
}

// === impl MiningTask ===
Expand All @@ -45,7 +45,7 @@ impl<Executor, Client, Pool: TransactionPool> ProposerTask<Client, Pool, Executo
client: Client,
pool: Pool,
block_executor: Executor,
trigger_args_rx: UnboundedReceiver<TriggerArgs>,
trigger_args_rx: UnboundedReceiver<TaskArgs>,
) -> Self {
Self {
chain_spec,
Expand Down Expand Up @@ -113,7 +113,7 @@ where
.collect();
let ommers = vec![];

let TriggerArgs {
let TaskArgs {
tx,
beneficiary,
block_max_gas_limit,
Expand Down
2 changes: 1 addition & 1 deletion crates/taiko/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ workspace = true
reth-chainspec = { workspace = true, features = ["taiko"] }
reth-evm.workspace = true
reth-primitives = { workspace = true, features = ["taiko"] }
reth-revm.workspace = true
reth-revm = { workspace = true, features = ["taiko"] }
reth-prune-types.workspace = true
reth-execution-types.workspace = true

Expand Down
2 changes: 1 addition & 1 deletion crates/taiko/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use reth_evm::{
BatchExecutor, BlockExecutionError, BlockExecutionInput, BlockExecutionOutput,
BlockExecutorProvider, BlockValidationError, Executor, ProviderError,
},
ConfigureEvm, ConfigureEvmEnv,
ConfigureEvm,
};
use reth_execution_types::ExecutionOutcome;
use reth_primitives::{
Expand Down

0 comments on commit 95bb990

Please sign in to comment.