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

fix: resolve compile errors when feature optimism is on #5

Closed
wants to merge 1 commit into from
Closed
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
35 changes: 18 additions & 17 deletions crates/optimism/evm/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use reth_revm::{
batch::BlockBatchRecord, db::states::bundle_state::BundleRetention,
state_change::post_block_balance_increments, Evm, State,
};
use revm::DatabaseRef;
use revm_primitives::{
db::{Database, DatabaseCommit},
BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState,
db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg, ResultAndState,
};
use std::{fmt::Display, sync::Arc};
use tracing::trace;
Expand Down Expand Up @@ -56,7 +56,7 @@ where
{
fn op_executor<DB>(&self, db: DB) -> OpBlockExecutor<EvmConfig, DB>
where
DB: Database<Error: Into<ProviderError> + Display>,
DB: DatabaseRef<Error: Into<ProviderError> + Display>,
{
OpBlockExecutor::new(
self.chain_spec.clone(),
Expand All @@ -70,21 +70,21 @@ impl<EvmConfig> BlockExecutorProvider for OpExecutorProvider<EvmConfig>
where
EvmConfig: ConfigureEvm<Header = Header>,
{
type Executor<DB: Database<Error: Into<ProviderError> + Display>> =
type Executor<DB: DatabaseRef<Error: Into<ProviderError> + Display> + Send + Sync> =
OpBlockExecutor<EvmConfig, DB>;

type BatchExecutor<DB: Database<Error: Into<ProviderError> + Display>> =
type BatchExecutor<DB: DatabaseRef<Error: Into<ProviderError> + Display> + Send + Sync> =
OpBatchExecutor<EvmConfig, DB>;
fn executor<DB>(&self, db: DB) -> Self::Executor<DB>
where
DB: Database<Error: Into<ProviderError> + Display>,
DB: DatabaseRef<Error: Into<ProviderError> + Display> + Send + Sync,
{
self.op_executor(db)
}

fn batch_executor<DB>(&self, db: DB) -> Self::BatchExecutor<DB>
where
DB: Database<Error: Into<ProviderError> + Display>,
DB: DatabaseRef<Error: Into<ProviderError> + Display> + Send + Sync,
{
let executor = self.op_executor(db);
OpBatchExecutor { executor, batch_record: BlockBatchRecord::default() }
Expand Down Expand Up @@ -117,7 +117,7 @@ where
mut evm: Evm<'_, Ext, &mut State<DB>>,
) -> Result<(Vec<Receipt>, u64), BlockExecutionError>
where
DB: Database<Error: Into<ProviderError> + Display>,
DB: DatabaseRef<Error: Into<ProviderError> + Display>,
{
let mut system_caller = SystemCaller::new(&self.evm_config, &self.chain_spec);

Expand Down Expand Up @@ -146,19 +146,19 @@ where
// The sum of the transaction’s gas limit, Tg, and the gas utilized in this block prior,
// must be no greater than the block’s gasLimit.
let block_available_gas = block.header.gas_limit - cumulative_gas_used;
if transaction.gas_limit() > block_available_gas &&
(is_regolith || !transaction.is_system_transaction())
if transaction.gas_limit() > block_available_gas
&& (is_regolith || !transaction.is_system_transaction())
{
return Err(BlockValidationError::TransactionGasLimitMoreThanAvailableBlockGas {
transaction_gas_limit: transaction.gas_limit(),
block_available_gas,
}
.into())
.into());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nit but Reth actually uses nightly rustfmt with a specific rule to skip these dangling semicolons.

}

// An optimism block should never contain blob transactions.
if matches!(transaction.tx_type(), TxType::Eip4844) {
return Err(OptimismBlockExecutionError::BlobTransactionRejected.into())
return Err(OptimismBlockExecutionError::BlobTransactionRejected.into());
}

// Cache the depositor account prior to the state transition for the deposit nonce.
Expand Down Expand Up @@ -210,8 +210,9 @@ where
// The deposit receipt version was introduced in Canyon to indicate an update to how
// receipt hashes should be computed when set. The state transition process ensures
// this is only set for post-Canyon deposit transactions.
deposit_receipt_version: (transaction.is_deposit() &&
self.chain_spec
deposit_receipt_version: (transaction.is_deposit()
&& self
.chain_spec
.is_fork_active_at_timestamp(OptimismHardfork::Canyon, block.timestamp))
.then_some(1),
});
Expand Down Expand Up @@ -260,7 +261,7 @@ impl<EvmConfig, DB> OpBlockExecutor<EvmConfig, DB> {
impl<EvmConfig, DB> OpBlockExecutor<EvmConfig, DB>
where
EvmConfig: ConfigureEvm<Header = Header>,
DB: Database<Error: Into<ProviderError> + Display>,
DB: DatabaseRef<Error: Into<ProviderError> + Display> + Send + Sync,
{
/// Configures a new evm configuration and block environment for the given block.
///
Expand Down Expand Up @@ -333,7 +334,7 @@ where
impl<EvmConfig, DB> Executor<DB> for OpBlockExecutor<EvmConfig, DB>
where
EvmConfig: ConfigureEvm<Header = Header>,
DB: Database<Error: Into<ProviderError> + Display>,
DB: DatabaseRef<Error: Into<ProviderError> + Display> + Send + Sync,
{
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;
type Output = BlockExecutionOutput<Receipt>;
Expand Down Expand Up @@ -411,7 +412,7 @@ impl<EvmConfig, DB> OpBatchExecutor<EvmConfig, DB> {
impl<EvmConfig, DB> BatchExecutor<DB> for OpBatchExecutor<EvmConfig, DB>
where
EvmConfig: ConfigureEvm<Header = Header>,
DB: Database<Error: Into<ProviderError> + Display>,
DB: DatabaseRef<Error: Into<ProviderError> + Display> + Send + Sync,
{
type Input<'a> = BlockExecutionInput<'a, BlockWithSenders>;
type Output = ExecutionOutcome;
Expand Down
5 changes: 3 additions & 2 deletions crates/optimism/evm/src/l1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ impl RethL1BlockInfo for L1BlockInfo {
pub fn ensure_create2_deployer<DB>(
chain_spec: Arc<OpChainSpec>,
timestamp: u64,
db: &mut revm::State<DB>,
db: &mut revm::db::State<DB>,
) -> Result<(), DB::Error>
where
DB: revm::Database,
DB: revm::DatabaseRef,
{
// If the canyon hardfork is active at the current timestamp, and it was not active at the
// previous block timestamp (heuristically, block time is not perfectly constant at 2s), and the
Expand All @@ -284,6 +284,7 @@ where
let mut acc_info = acc.account_info().unwrap_or_default();
acc_info.code_hash = CREATE_2_DEPLOYER_CODEHASH;
acc_info.code = Some(Bytecode::new_raw(Bytes::from_static(&CREATE_2_DEPLOYER_BYTECODE)));
drop(acc);

// Convert the cache account back into a revm account and mark it as touched.
let mut revm_acc: revm::primitives::Account = acc_info.into();
Expand Down
2 changes: 1 addition & 1 deletion crates/optimism/payload/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ where
// calculate the state root
let hashed_state = HashedPostState::from_bundle_state(&execution_outcome.state().state);
let (state_root, trie_output) = {
let state_provider = db.database.0.inner.borrow_mut();
let state_provider = db.database.inner.borrow_mut();
state_provider.db.state_root_with_updates(hashed_state.clone()).inspect_err(|err| {
warn!(target: "payload_builder",
parent_hash=%parent_block.hash(),
Expand Down
Loading