Skip to content

Commit

Permalink
gate WithContext implementation behind test-utils
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Edison <[email protected]>
  • Loading branch information
greged93 committed Nov 22, 2024
1 parent d6156e3 commit a8e5772
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/optimism/payload/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ optimism = [
"reth-execution-types/optimism",
"reth-optimism-consensus/optimism"
]
scroll = []
scroll = []
4 changes: 4 additions & 0 deletions crates/scroll/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ scroll = [
"reth-scroll-revm/scroll",
"reth-scroll-storage/scroll",
]
test-utils = [
"reth-scroll-revm/test-utils",
"reth-revm/test-utils"
]
16 changes: 11 additions & 5 deletions crates/scroll/execution/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use reth_revm::{database::StateProviderDatabase, db::CacheDB, Database, State};
use std::sync::LazyLock;
#[cfg(feature = "test-utils")]
use reth_revm::{database::StateProviderDatabase, db::CacheDB};
use reth_revm::{Database, State};

/// Finalize the execution of the type and return the output
pub trait FinalizeExecution<Output> {
Expand Down Expand Up @@ -34,7 +35,6 @@ pub trait WithContext {
type ExecutionContext = ();
#[cfg(feature = "scroll")]
type ExecutionContext = reth_scroll_primitives::ScrollPostExecutionContext;
static DEFAULT_CONTEXT: LazyLock<ExecutionContext> = LazyLock::new(Default::default);

#[cfg(feature = "scroll")]
impl<DB> WithContext for reth_scroll_storage::ScrollStateProviderDatabase<DB> {
Expand All @@ -45,15 +45,21 @@ impl<DB> WithContext for reth_scroll_storage::ScrollStateProviderDatabase<DB> {
}
}

impl<DB> WithContext for CacheDB<DB> {
#[cfg(feature = "test-utils")]
static DEFAULT_CONTEXT: std::sync::LazyLock<ExecutionContext> =
std::sync::LazyLock::new(Default::default);

#[cfg(feature = "test-utils")]
impl<DB> WithContext for StateProviderDatabase<DB> {
type Context = ExecutionContext;

fn context(&self) -> &Self::Context {
&DEFAULT_CONTEXT
}
}

impl<DB> WithContext for StateProviderDatabase<DB> {
#[cfg(feature = "test-utils")]
impl<DB> WithContext for CacheDB<DB> {
type Context = ExecutionContext;

fn context(&self) -> &Self::Context {
Expand Down

0 comments on commit a8e5772

Please sign in to comment.