From b250c7d045d862f6ff80bd890e53932baa3bf8ce Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 23 Oct 2024 15:42:12 +0200 Subject: [PATCH 1/4] 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. --- Cargo.toml | 14 +++++++------- src/fill/zenith.rs | 2 ++ src/journal/coder.rs | 4 ++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b808b83..7817d45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } @@ -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"] diff --git a/src/fill/zenith.rs b/src/fill/zenith.rs index 4d4dbe4..c1bd7c6 100644 --- a/src/fill/zenith.rs +++ b/src/fill/zenith.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "std")] + use crate::Tx; use alloc::vec; use alloy_primitives::{Address, U256}; diff --git a/src/journal/coder.rs b/src/journal/coder.rs index fcbd06f..0a4654f 100644 --- a/src/journal/coder.rs +++ b/src/journal/coder.rs @@ -14,6 +14,8 @@ use revm::{ eof::EofDecodeError, AccountInfo, Bytecode, Eip7702Bytecode, Eip7702DecodeError, Eof, }, }; + +#[cfg(feature = "std")] use zenith_types::Zenith; type Result = core::result::Result; @@ -411,6 +413,7 @@ impl JournalEncode for BundleState { } } +#[cfg(feature = "std")] impl JournalEncode for Zenith::BlockHeader { fn serialized_size(&self) -> usize { ZENITH_HEADER_BYTES @@ -636,6 +639,7 @@ impl JournalDecode for BundleState { } } +#[cfg(feature = "std")] impl JournalDecode for Zenith::BlockHeader { fn decode(buf: &mut &[u8]) -> Result { Ok(Self { From 8d0dbc2a5ddf1560d02fce2518bcf8f69442ee1e Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 23 Oct 2024 16:18:13 +0200 Subject: [PATCH 2/4] chore: gate mod journal --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index e05f017..9a55107 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -378,6 +378,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; From bb78214a6302eb00237c86cedaf5afef2553ecb9 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 23 Oct 2024 16:45:54 +0200 Subject: [PATCH 3/4] chore: feature gates --- src/driver/alloy.rs | 6 ++++-- src/driver/mod.rs | 1 + src/lib.rs | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/driver/alloy.rs b/src/driver/alloy.rs index dd84385..c164d6f 100644 --- a/src/driver/alloy.rs +++ b/src/driver/alloy.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "std")] + use crate::{ trevm_bail, trevm_ensure, unwrap_or_trevm_err, Block, BundleDriver, DriveBundleResult, }; @@ -76,8 +78,8 @@ impl From> for BundleError { } } -impl core::error::Error for BundleError { - fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { +impl std::error::Error for BundleError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { match self { Self::TransactionDecodingError(err) => Some(err), Self::TransactionSenderRecoveryError(err) => Some(err), diff --git a/src/driver/mod.rs b/src/driver/mod.rs index 1978a87..1749864 100644 --- a/src/driver/mod.rs +++ b/src/driver/mod.rs @@ -1,4 +1,5 @@ mod alloy; +#[cfg(feature = "std")] pub use alloy::{BundleError, BundleProcessor}; mod block; diff --git a/src/lib.rs b/src/lib.rs index 9a55107..8a7845d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -365,9 +365,11 @@ extern crate alloc; mod driver; pub use driver::{ - BlockDriver, BundleDriver, BundleError, BundleProcessor, ChainDriver, DriveBlockResult, + BlockDriver, BundleDriver, ChainDriver, DriveBlockResult, DriveBundleResult, DriveChainResult, RunTxResult, }; +#[cfg(feature = "std")] +pub use driver::{BundleError, BundleProcessor}; mod evm; pub use evm::Trevm; From a9429fa2bb0e19383e9cc256b5583e11a1bfb4a2 Mon Sep 17 00:00:00 2001 From: evalir Date: Wed, 23 Oct 2024 16:46:21 +0200 Subject: [PATCH 4/4] chore: feature gates --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8a7845d..418addb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -365,8 +365,8 @@ extern crate alloc; mod driver; pub use driver::{ - BlockDriver, BundleDriver, ChainDriver, DriveBlockResult, - DriveBundleResult, DriveChainResult, RunTxResult, + BlockDriver, BundleDriver, ChainDriver, DriveBlockResult, DriveBundleResult, DriveChainResult, + RunTxResult, }; #[cfg(feature = "std")] pub use driver::{BundleError, BundleProcessor};