Skip to content

Commit 3b0ad92

Browse files
authored
chore: remove no-std support (#69)
* fix: use `OnceLock` for Sync reqs on `BlockOutput` * chore: remove no-std support (#70) * chore: remove no-std action * chore: remove no std support
1 parent ccc744e commit 3b0ad92

File tree

14 files changed

+25
-62
lines changed

14 files changed

+25
-62
lines changed

Diff for: .github/workflows/rust-ci.yml

+1-17
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,4 @@ env:
1111

1212
jobs:
1313
rust-base:
14-
uses: init4tech/actions/.github/workflows/rust-base.yml@main
15-
16-
test-no-features:
17-
name: Test Suite (no default features)
18-
runs-on:
19-
group: init4-runners
20-
steps:
21-
- name: Checkout repository
22-
uses: actions/checkout@v4
23-
- name: Install Rust toolchain
24-
uses: dtolnay/rust-toolchain@stable
25-
- uses: Swatinem/rust-cache@v2
26-
- name: Run tests
27-
env:
28-
CARGO_NET_GIT_FETCH_WITH_CLI: true
29-
run: |
30-
cargo test --no-default-features
14+
uses: init4tech/actions/.github/workflows/rust-base.yml@main

Diff for: Cargo.toml

+7-10
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ option-if-let-else = "warn"
2727
redundant-clone = "warn"
2828

2929
[dependencies]
30-
alloy-rlp = { version = "0.3.10", default-features = false }
30+
alloy-rlp = { version = "0.3.10", default-features = false, features = ["std"]}
3131

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

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

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

39-
zenith-types = { version = "0.10", optional = true }
39+
zenith-types = { version = "0.11" }
4040

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

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

5858
[features]
5959
default = [
60-
"std",
6160
"concurrent-db",
6261
"revm/std",
6362
"revm/c-kzg",
@@ -66,9 +65,7 @@ default = [
6665
"revm/secp256k1",
6766
]
6867

69-
std = ["revm/std", "alloy/std", "alloy-rlp/std", "alloy-primitives/std", "alloy-sol-types/std", "dep:zenith-types"]
70-
71-
concurrent-db = ["std", "dep:dashmap"]
68+
concurrent-db = ["dep:dashmap"]
7269

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

Diff for: src/connect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use alloc::format;
21
use core::convert::Infallible;
32
use revm::{
43
primitives::{EVMError, ResultAndState},
54
Database, DatabaseCommit,
65
};
6+
use std::format;
77

88
use crate::{
99
Block, Cfg, EvmErrored, EvmNeedsBlock, EvmNeedsCfg, EvmNeedsTx, EvmReady, EvmTransacted, Tx,

Diff for: src/db/sync_state.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::db::ConcurrentCacheState;
2-
use alloc::{collections::BTreeMap, vec::Vec};
32
use alloy_primitives::{Address, B256, U256};
43
use dashmap::mapref::one::RefMut;
54
use revm::{
@@ -10,7 +9,10 @@ use revm::{
109
primitives::{Account, AccountInfo, Bytecode},
1110
Database, DatabaseCommit, DatabaseRef, TransitionAccount, TransitionState,
1211
};
13-
use std::{collections::hash_map, sync::RwLock};
12+
use std::{
13+
collections::{hash_map, BTreeMap},
14+
sync::RwLock,
15+
};
1416

1517
/// State of the blockchain.
1618
///

Diff for: src/driver/alloy.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
#![cfg(feature = "std")]
2-
31
use crate::{
42
trevm_bail, trevm_ensure, unwrap_or_trevm_err, Block, BundleDriver, DriveBundleResult,
53
};
6-
use alloc::vec::Vec;
74
use alloy::{
85
consensus::{Transaction, TxEip4844Variant, TxEnvelope},
96
eips::{eip2718::Decodable2718, BlockNumberOrTag},

Diff for: src/driver/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod alloy;
2-
#[cfg(feature = "std")]
32
pub use alloy::{BundleError, BundleProcessor};
43

54
mod block;

Diff for: src/evm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::{
44
EvmNeedsCfg, EvmNeedsTx, EvmReady, EvmTransacted, HasBlock, HasCfg, HasTx, NeedsCfg, NeedsTx,
55
TransactedState, Tx,
66
};
7-
use alloc::{boxed::Box, fmt};
87
use alloy_primitives::{Address, Bytes, U256};
98
use core::convert::Infallible;
109
use revm::{
@@ -15,6 +14,7 @@ use revm::{
1514
},
1615
Database, DatabaseCommit, DatabaseRef, Evm,
1716
};
17+
use std::fmt;
1818

1919
/// Trevm provides a type-safe interface to the EVM, using the typestate pattern.
2020
///

Diff for: src/fill/zenith.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
#![cfg(feature = "std")]
2-
31
use crate::Tx;
4-
use alloc::vec;
52
use alloy_primitives::{Address, U256};
63
use alloy_sol_types::SolCall;
74
use revm::primitives::{TransactTo, TxEnv};

Diff for: src/journal/coder.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
use crate::journal::{AcctDiff, BundleStateIndex, InfoOutcome};
2-
use alloc::{
3-
borrow::{Cow, ToOwned},
4-
collections::BTreeMap,
5-
fmt::Debug,
6-
sync::Arc,
7-
vec::Vec,
8-
};
92
use alloy_primitives::{Address, Bytes, B256, U256};
103
use alloy_rlp::{Buf, BufMut};
114
use revm::{
@@ -14,8 +7,14 @@ use revm::{
147
eof::EofDecodeError, AccountInfo, Bytecode, Eip7702Bytecode, Eip7702DecodeError, Eof,
158
},
169
};
10+
use std::{
11+
borrow::{Cow, ToOwned},
12+
collections::BTreeMap,
13+
fmt::Debug,
14+
sync::Arc,
15+
vec::Vec,
16+
};
1717

18-
#[cfg(feature = "std")]
1918
use zenith_types::Zenith;
2019

2120
type Result<T, E = JournalDecodeError> = core::result::Result<T, E>;
@@ -413,7 +412,6 @@ impl JournalEncode for BundleState {
413412
}
414413
}
415414

416-
#[cfg(feature = "std")]
417415
impl JournalEncode for Zenith::BlockHeader {
418416
fn serialized_size(&self) -> usize {
419417
ZENITH_HEADER_BYTES
@@ -639,7 +637,6 @@ impl JournalDecode for BundleState {
639637
}
640638
}
641639

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

660656
fn roundtrip<T: JournalDecode + JournalEncode + PartialEq>(expected: &T) {
661657
let enc = JournalEncode::encoded(expected);

Diff for: src/journal/index.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use alloc::{borrow::Cow, collections::BTreeMap};
21
use alloy_primitives::{Address, Sign, B256, I256, U256};
32
use revm::{
43
db::{states::StorageSlot, AccountStatus, BundleAccount, BundleState},
54
primitives::{AccountInfo, Bytecode, HashMap},
65
};
6+
use std::{borrow::Cow, collections::BTreeMap};
77

88
/// Outcome of an account info after block execution.
99
///

Diff for: src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,6 @@
359359
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
360360
#![deny(unused_must_use, rust_2018_idioms)]
361361
#![warn(missing_docs, missing_copy_implementations, missing_debug_implementations)]
362-
#![cfg_attr(not(feature = "std"), no_std)]
363-
364-
extern crate alloc;
365362

366363
mod connect;
367364
pub use connect::{DbConnect, EvmFactory};
@@ -375,7 +372,7 @@ pub use driver::{
375372
BlockDriver, BundleDriver, ChainDriver, DriveBlockResult, DriveBundleResult, DriveChainResult,
376373
RunTxResult,
377374
};
378-
#[cfg(feature = "std")]
375+
379376
pub use driver::{BundleError, BundleProcessor};
380377

381378
mod evm;
@@ -387,7 +384,6 @@ pub use ext::EvmExtUnchecked;
387384
mod fill;
388385
pub use fill::{Block, Cfg, DisableGasChecks, DisableNonceCheck, NoopBlock, NoopCfg, Tx};
389386

390-
#[cfg(feature = "std")]
391387
pub mod journal;
392388

393389
mod lifecycle;

Diff for: src/lifecycle/output.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use alloc::vec::Vec;
21
use alloy::consensus::{ReceiptEnvelope, TxReceipt};
32
use alloy_primitives::{Address, Bloom, Bytes, Log};
4-
use core::cell::OnceCell;
3+
use std::sync::OnceLock;
54

65
/// Information externalized during block execution.
76
///
@@ -16,7 +15,7 @@ pub struct BlockOutput<T: TxReceipt = ReceiptEnvelope> {
1615
senders: Vec<Address>,
1716

1817
/// The logs bloom of the block.
19-
bloom: OnceCell<Bloom>,
18+
bloom: OnceLock<Bloom>,
2019
}
2120

2221
impl Default for BlockOutput {

Diff for: src/system/eip6110.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use alloc::vec::Vec;
21
use alloy::consensus::ReceiptEnvelope;
32
use alloy_primitives::{Bytes, Log};
43
use alloy_rlp::BufMut;
@@ -147,7 +146,6 @@ where
147146
#[cfg(test)]
148147
mod tests {
149148
use super::*;
150-
use alloc::vec;
151149
use alloy::consensus::{Receipt, ReceiptEnvelope};
152150
use alloy_primitives::bytes;
153151

Diff for: src/test_utils.rs

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use revm::{
77
EvmBuilder, GetInspector,
88
};
99

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

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

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

0 commit comments

Comments
 (0)