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

chore: remove no-std support #70

Merged
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
18 changes: 1 addition & 17 deletions .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,4 @@ env:

jobs:
rust-base:
uses: init4tech/actions/.github/workflows/rust-base.yml@main

test-no-features:
name: Test Suite (no default features)
runs-on:
group: init4-runners
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run tests
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
run: |
cargo test --no-default-features
uses: init4tech/actions/.github/workflows/rust-base.yml@main
17 changes: 7 additions & 10 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 = { version = "0.3.10", default-features = false }
alloy-rlp = { version = "0.3.10", default-features = false, features = ["std"]}

alloy-primitives = { version = "0.8.11", default-features = false }
alloy-sol-types = { version = "0.8.11", default-features = false }
alloy-primitives = { version = "0.8.11", default-features = false, features = ["std"]}
alloy-sol-types = { version = "0.8.11", default-features = false, features = ["std"]}

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

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

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

dashmap = { version = "6.1.0", optional = true }

Expand All @@ -57,7 +57,6 @@ tokio = { version = "1.39", features = ["macros", "rt-multi-thread"] }

[features]
default = [
"std",
"concurrent-db",
"revm/std",
"revm/c-kzg",
Expand All @@ -66,9 +65,7 @@ default = [
"revm/secp256k1",
]

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

concurrent-db = ["std", "dep:dashmap"]
concurrent-db = ["dep:dashmap"]

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

Expand Down
2 changes: 1 addition & 1 deletion src/connect.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use alloc::format;
use core::convert::Infallible;
use revm::{
primitives::{EVMError, ResultAndState},
Database, DatabaseCommit,
};
use std::format;

use crate::{
Block, Cfg, EvmErrored, EvmNeedsBlock, EvmNeedsCfg, EvmNeedsTx, EvmReady, EvmTransacted, Tx,
Expand Down
6 changes: 4 additions & 2 deletions src/db/sync_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::db::ConcurrentCacheState;
use alloc::{collections::BTreeMap, vec::Vec};
use alloy_primitives::{Address, B256, U256};
use dashmap::mapref::one::RefMut;
use revm::{
Expand All @@ -10,7 +9,10 @@ use revm::{
primitives::{Account, AccountInfo, Bytecode},
Database, DatabaseCommit, DatabaseRef, TransitionAccount, TransitionState,
};
use std::{collections::hash_map, sync::RwLock};
use std::{
collections::{hash_map, BTreeMap},
sync::RwLock,
};

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

use crate::{
trevm_bail, trevm_ensure, unwrap_or_trevm_err, Block, BundleDriver, DriveBundleResult,
};
use alloc::vec::Vec;
use alloy::{
consensus::{Transaction, TxEip4844Variant, TxEnvelope},
eips::{eip2718::Decodable2718, BlockNumberOrTag},
Expand Down
1 change: 0 additions & 1 deletion src/driver/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod alloy;
#[cfg(feature = "std")]
pub use alloy::{BundleError, BundleProcessor};

mod block;
Expand Down
2 changes: 1 addition & 1 deletion src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
EvmNeedsCfg, EvmNeedsTx, EvmReady, EvmTransacted, HasBlock, HasCfg, HasTx, NeedsCfg, NeedsTx,
TransactedState, Tx,
};
use alloc::{boxed::Box, fmt};
use alloy_primitives::{Address, Bytes, U256};
use core::convert::Infallible;
use revm::{
Expand All @@ -15,6 +14,7 @@ use revm::{
},
Database, DatabaseCommit, DatabaseRef, Evm,
};
use std::fmt;

/// Trevm provides a type-safe interface to the EVM, using the typestate pattern.
///
Expand Down
3 changes: 0 additions & 3 deletions src/fill/zenith.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#![cfg(feature = "std")]

use crate::Tx;
use alloc::vec;
use alloy_primitives::{Address, U256};
use alloy_sol_types::SolCall;
use revm::primitives::{TransactTo, TxEnv};
Expand Down
18 changes: 7 additions & 11 deletions src/journal/coder.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
use crate::journal::{AcctDiff, BundleStateIndex, InfoOutcome};
use alloc::{
borrow::{Cow, ToOwned},
collections::BTreeMap,
fmt::Debug,
sync::Arc,
vec::Vec,
};
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rlp::{Buf, BufMut};
use revm::{
Expand All @@ -14,8 +7,14 @@ use revm::{
eof::EofDecodeError, AccountInfo, Bytecode, Eip7702Bytecode, Eip7702DecodeError, Eof,
},
};
use std::{
borrow::{Cow, ToOwned},
collections::BTreeMap,
fmt::Debug,
sync::Arc,
vec::Vec,
};

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

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

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

#[cfg(feature = "std")]
impl JournalDecode for Zenith::BlockHeader {
fn decode(buf: &mut &[u8]) -> Result<Self> {
Ok(Self {
Expand All @@ -655,7 +652,6 @@ impl JournalDecode for Zenith::BlockHeader {
#[cfg(test)]
mod test {
use super::*;
use alloc::vec;

fn roundtrip<T: JournalDecode + JournalEncode + PartialEq>(expected: &T) {
let enc = JournalEncode::encoded(expected);
Expand Down
2 changes: 1 addition & 1 deletion src/journal/index.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use alloc::{borrow::Cow, collections::BTreeMap};
use alloy_primitives::{Address, Sign, B256, I256, U256};
use revm::{
db::{states::StorageSlot, AccountStatus, BundleAccount, BundleState},
primitives::{AccountInfo, Bytecode, HashMap},
};
use std::{borrow::Cow, collections::BTreeMap};

/// Outcome of an account info after block execution.
///
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,6 @@
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![deny(unused_must_use, rust_2018_idioms)]
#![warn(missing_docs, missing_copy_implementations, missing_debug_implementations)]
#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

mod connect;
pub use connect::{DbConnect, EvmFactory};
Expand All @@ -375,7 +372,7 @@ pub use driver::{
BlockDriver, BundleDriver, ChainDriver, DriveBlockResult, DriveBundleResult, DriveChainResult,
RunTxResult,
};
#[cfg(feature = "std")]

pub use driver::{BundleError, BundleProcessor};

mod evm;
Expand All @@ -387,7 +384,6 @@ 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
1 change: 0 additions & 1 deletion src/lifecycle/output.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use alloc::vec::Vec;
use alloy::consensus::{ReceiptEnvelope, TxReceipt};
use alloy_primitives::{Address, Bloom, Bytes, Log};
use std::sync::OnceLock;
Expand Down
2 changes: 0 additions & 2 deletions src/system/eip6110.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use alloc::vec::Vec;
use alloy::consensus::ReceiptEnvelope;
use alloy_primitives::{Bytes, Log};
use alloy_rlp::BufMut;
Expand Down Expand Up @@ -147,7 +146,6 @@ where
#[cfg(test)]
mod tests {
use super::*;
use alloc::vec;
use alloy::consensus::{Receipt, ReceiptEnvelope};
use alloy_primitives::bytes;

Expand Down
2 changes: 0 additions & 2 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use revm::{
EvmBuilder, GetInspector,
};

#[cfg(feature = "std")]
use revm::inspectors::TracerEip3155;

pub use revm::test_utils as revm_test_utils;
Expand Down Expand Up @@ -115,7 +114,6 @@ pub fn test_state_trevm() -> EvmNeedsCfg<'static, (), State<EmptyDB>> {

/// Make a new [`Trevm`] with an in-memory database and a tracer inspector.
/// The tracer will print all EVM instructions to stdout.
#[cfg(feature = "std")]
pub fn test_trevm_tracing() -> EvmNeedsCfg<'static, TracerEip3155, CacheDB<EmptyDB>> {
test_trevm_with_inspector(TracerEip3155::new(Box::new(std::io::stdout())))
}
Loading