mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: op-reth (#4377)
Co-authored-by: Roberto Bayardo <bayardo@alum.mit.edu> Co-authored-by: refcell.eth <abigger87@gmail.com> Co-authored-by: Roman Krasiuk <rokrassyuk@gmail.com> Co-authored-by: refcell <refcell@oplabs.co> Co-authored-by: nicolas <48695862+merklefruit@users.noreply.github.com>
This commit is contained in:
@ -56,3 +56,7 @@ rand.workspace = true
|
||||
|
||||
[features]
|
||||
test-utils = ["alloy-rlp"]
|
||||
optimism = [
|
||||
"reth-primitives/optimism",
|
||||
"reth-interfaces/optimism"
|
||||
]
|
||||
|
||||
@ -137,6 +137,8 @@ fn block1(number: BlockNumber) -> (SealedBlockWithSenders, BundleStateWithReceip
|
||||
topics: vec![B256::with_last_byte(1), B256::with_last_byte(2)],
|
||||
data: Bytes::default(),
|
||||
}],
|
||||
#[cfg(feature = "optimism")]
|
||||
deposit_nonce: None,
|
||||
})]]),
|
||||
number,
|
||||
);
|
||||
@ -192,6 +194,8 @@ fn block2(
|
||||
topics: vec![B256::with_last_byte(3), B256::with_last_byte(4)],
|
||||
data: Bytes::default(),
|
||||
}],
|
||||
#[cfg(feature = "optimism")]
|
||||
deposit_nonce: None,
|
||||
})]]),
|
||||
number,
|
||||
);
|
||||
|
||||
@ -4,7 +4,7 @@ use crate::{
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use reth_interfaces::executor::BlockExecutionError;
|
||||
use reth_primitives::{Address, Block, BlockNumber, ChainSpec, PruneModes, U256};
|
||||
use reth_primitives::{Address, Block, BlockNumber, ChainSpec, PruneModes, Receipt, U256};
|
||||
use std::sync::Arc;
|
||||
/// Test executor with mocked result.
|
||||
#[derive(Debug)]
|
||||
@ -35,6 +35,15 @@ impl BlockExecutor for TestExecutor {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn execute_transactions(
|
||||
&mut self,
|
||||
_block: &Block,
|
||||
_total_difficulty: U256,
|
||||
_senders: Option<Vec<Address>>,
|
||||
) -> Result<(Vec<Receipt>, u64), BlockExecutionError> {
|
||||
Err(BlockExecutionError::UnavailableForTest)
|
||||
}
|
||||
|
||||
fn take_output_state(&mut self) -> BundleStateWithReceipts {
|
||||
self.0.clone().unwrap_or_default()
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
use crate::{bundle_state::BundleStateWithReceipts, StateProvider};
|
||||
use reth_interfaces::executor::BlockExecutionError;
|
||||
use reth_primitives::{Address, Block, BlockNumber, ChainSpec, PruneModes, U256};
|
||||
use reth_primitives::{Address, Block, BlockNumber, ChainSpec, PruneModes, Receipt, U256};
|
||||
use std::time::Duration;
|
||||
use tracing::debug;
|
||||
|
||||
@ -45,6 +45,23 @@ pub trait BlockExecutor {
|
||||
senders: Option<Vec<Address>>,
|
||||
) -> Result<(), BlockExecutionError>;
|
||||
|
||||
/// Runs the provided transactions and commits their state to the run-time database.
|
||||
///
|
||||
/// The returned [BundleStateWithReceipts] can be used to persist the changes to disk, and
|
||||
/// contains the changes made by each transaction.
|
||||
///
|
||||
/// The changes in [BundleStateWithReceipts] have a transition ID associated with them: there is
|
||||
/// one transition ID for each transaction (with the first executed tx having transition ID
|
||||
/// 0, and so on).
|
||||
///
|
||||
/// The second returned value represents the total gas used by this block of transactions.
|
||||
fn execute_transactions(
|
||||
&mut self,
|
||||
block: &Block,
|
||||
total_difficulty: U256,
|
||||
senders: Option<Vec<Address>>,
|
||||
) -> Result<(Vec<Receipt>, u64), BlockExecutionError>;
|
||||
|
||||
/// Return bundle state. This is output of executed blocks.
|
||||
fn take_output_state(&mut self) -> BundleStateWithReceipts;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user