Skip to content

Commit

Permalink
fix(crate): disable std for all deps (#61)
Browse files Browse the repository at this point in the history
* fix(crate): disable std for all deps

This fixes an issue with the no-std PR, which did not properly disable std for all the other deps. This is blocked on revm/alloy implementing `core::error::Error` instead of `std` on the erroring types.

* chore: gate mod journal

* chore: feature gates

* chore: feature gates
  • Loading branch information
Evalir authored Oct 24, 2024
1 parent 5e49efb commit 5f8a86e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ option-if-let-else = "warn"
redundant-clone = "warn"

[dependencies]
alloy-rlp = "0.3"
alloy-rlp = { version = "0.3", default-features = false }

alloy-primitives = "=0.8.8"
alloy-sol-types = "=0.8.8"
alloy-primitives = { version = "=0.8.8", default-features = false }
alloy-sol-types = { version = "=0.8.8", default-features = false }

alloy = { version = "=0.5.2", default-features = false, features = ["consensus", "rpc-types-mev"] }
alloy = { version = "=0.5.2", default-features = false, features = ["consensus", "rpc-types-mev", "eips", "k256"] }

revm = { version = "16.0.0", default-features = false, features = ["std"] }
revm = { version = "16.0.0", default-features = false }

zenith-types = "0.10"
zenith-types = { version = "0.10", optional = true }

[dev-dependencies]
alloy-rlp = { version = "0.3", default-features = false }
Expand All @@ -63,7 +63,7 @@ default = [
"revm/secp256k1",
]

std = ["revm/std", "alloy/std", "alloy-rlp/std", "alloy-primitives/std", "alloy-sol-types/std"]
std = ["revm/std", "alloy/std", "alloy-rlp/std", "alloy-primitives/std", "alloy-sol-types/std", "dep:zenith-types"]

test-utils = ["revm/test-utils", "revm/std", "revm/serde-json", "revm/alloydb"]

Expand Down
6 changes: 4 additions & 2 deletions src/driver/alloy.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "std")]

use crate::{
trevm_bail, trevm_ensure, unwrap_or_trevm_err, Block, BundleDriver, DriveBundleResult,
};
Expand Down Expand Up @@ -76,8 +78,8 @@ impl<Db: revm::Database> From<EVMError<Db::Error>> for BundleError<Db> {
}
}

impl<Db: revm::Database> core::error::Error for BundleError<Db> {
fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
impl<Db: revm::Database> std::error::Error for BundleError<Db> {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::TransactionDecodingError(err) => Some(err),
Self::TransactionSenderRecoveryError(err) => Some(err),
Expand Down
1 change: 1 addition & 0 deletions src/driver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod alloy;
#[cfg(feature = "std")]
pub use alloy::{BundleError, BundleProcessor};

mod block;
Expand Down
2 changes: 2 additions & 0 deletions src/fill/zenith.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(feature = "std")]

use crate::Tx;
use alloc::vec;
use alloy_primitives::{Address, U256};
Expand Down
4 changes: 4 additions & 0 deletions src/journal/coder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ use revm::{
eof::EofDecodeError, AccountInfo, Bytecode, Eip7702Bytecode, Eip7702DecodeError, Eof,
},
};

#[cfg(feature = "std")]
use zenith_types::Zenith;

type Result<T, E = JournalDecodeError> = core::result::Result<T, E>;
Expand Down Expand Up @@ -411,6 +413,7 @@ impl JournalEncode for BundleState {
}
}

#[cfg(feature = "std")]
impl JournalEncode for Zenith::BlockHeader {
fn serialized_size(&self) -> usize {
ZENITH_HEADER_BYTES
Expand Down Expand Up @@ -636,6 +639,7 @@ impl JournalDecode for BundleState {
}
}

#[cfg(feature = "std")]
impl JournalDecode for Zenith::BlockHeader {
fn decode(buf: &mut &[u8]) -> Result<Self> {
Ok(Self {
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,11 @@ extern crate alloc;

mod driver;
pub use driver::{
BlockDriver, BundleDriver, BundleError, BundleProcessor, ChainDriver, DriveBlockResult,
DriveBundleResult, DriveChainResult, RunTxResult,
BlockDriver, BundleDriver, ChainDriver, DriveBlockResult, DriveBundleResult, DriveChainResult,
RunTxResult,
};
#[cfg(feature = "std")]
pub use driver::{BundleError, BundleProcessor};

mod evm;
pub use evm::Trevm;
Expand All @@ -378,6 +380,7 @@ pub use ext::EvmExtUnchecked;
mod fill;
pub use fill::{Block, Cfg, DisableGasChecks, DisableNonceCheck, NoopBlock, NoopCfg, Tx};

#[cfg(feature = "std")]
pub mod journal;

mod lifecycle;
Expand Down

0 comments on commit 5f8a86e

Please sign in to comment.