-
Notifications
You must be signed in to change notification settings - Fork 79
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
feat: support no_std #250
base: main
Are you sure you want to change the base?
feat: support no_std #250
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -30,19 +30,19 @@ clippy.lint_groups_priority = "allow" | |||
|
||||
[dependencies] | ||||
# eth | ||||
alloy-rpc-types-eth = "0.8" | ||||
alloy-rpc-types-trace = "0.8" | ||||
alloy-sol-types = "0.8" | ||||
alloy-primitives = { version = "0.8", features = ["map"] } | ||||
alloy-rpc-types-eth = { version = "0.8", default-features = false } | ||||
alloy-rpc-types-trace = {version = "0.8", default-features = false } | ||||
alloy-sol-types = {version = "0.8", default-features = false } | ||||
alloy-primitives = { version = "0.8", features = ["map"], default-features = false } | ||||
revm = { version = "18.0.0", default-features = false, features = ["std"] } | ||||
|
||||
anstyle = "1.0" | ||||
colorchoice = "1.0" | ||||
thiserror = "2.0" | ||||
anstyle = { version = "1.0", optional = true } | ||||
colorchoice = { version = "1.0", optional = true } | ||||
thiserror = { version = "2.0", default-features = false } | ||||
|
||||
# serde | ||||
serde = { version = "1", optional = true, features = ["derive"] } | ||||
serde_json = "1.0" | ||||
serde_json = { version = "1.0", optional = true } | ||||
|
||||
# js-tracer | ||||
boa_engine = { version = "0.20", optional = true } | ||||
|
@@ -52,5 +52,8 @@ boa_gc = { version = "0.20", optional = true } | |||
snapbox = { version = "0.6", features = ["term-svg"] } | ||||
|
||||
[features] | ||||
default = ["std"] | ||||
std = ["anstyle", "colorchoice", "serde_json"] | ||||
no_std = [] | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here we should also propagate std to everything There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't required because this is the same as no-default-features
Suggested change
|
||||
serde = ["dep:serde", "revm/serde"] | ||||
js-tracer = ["dep:boa_engine", "dep:boa_gc"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
//! | ||
//! - `js-tracer`: Enables a JavaScript tracer implementation. This pulls in extra dependencies | ||
//! (such as `boa`, `tokio` and `serde_json`). | ||
|
||
#![cfg_attr(not(feature = "std"), no_std)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to L17 |
||
#![doc = include_str!("../README.md")] | ||
#![doc( | ||
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", | ||
|
@@ -15,6 +15,11 @@ | |
#![deny(unused_must_use, rust_2018_idioms)] | ||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] | ||
|
||
extern crate alloc; | ||
|
||
#[cfg(feature = "std")] | ||
pub use colorchoice::ColorChoice; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move below mods again |
||
|
||
/// An inspector implementation for an EIP2930 Accesslist | ||
pub mod access_list; | ||
|
||
|
@@ -26,5 +31,3 @@ pub mod tracing; | |
|
||
/// An inspector for recording internal transfers. | ||
pub mod transfer; | ||
|
||
pub use colorchoice::ColorChoice; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please leave JS unchanged, it can never support no_std. It may look like it works because tests pass but that's because you're running on a target that has std, and it is used by dependencies regardless of the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
use crate::tracing::{FourByteInspector, TracingInspector, TracingInspectorConfig}; | ||
use alloc::vec::Vec; | ||
use alloy_primitives::{map::HashMap, Address, Log, U256}; | ||
use alloy_rpc_types_eth::TransactionInfo; | ||
use alloy_rpc_types_trace::geth::{ | ||
|
@@ -322,6 +323,10 @@ pub enum Error { | |
#[error("expected config is missing for tracer '{0:?}'")] | ||
MissingConfig(GethDebugBuiltInTracerType), | ||
/// Error when deserializing the config | ||
#[cfg(feature = "std")] | ||
#[error("error deserializing config: {0}")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this type works in no-std as long as the serde-json alloc feature is enabled |
||
InvalidConfig(#[from] serde_json::Error), | ||
#[cfg(not(feature = "std"))] | ||
#[error("error deserializing config")] | ||
InvalidConfigNoStd, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,14 @@ use super::{ | |
}, | ||
CallTraceArena, | ||
}; | ||
use alloy_primitives::{address, hex, Address, B256, U256}; | ||
use alloc::{format, string::String, vec::Vec}; | ||
use alloy_primitives::{address, hex, map::HashMap, Address, B256, U256}; | ||
#[cfg(feature = "std")] | ||
use anstyle::{AnsiColor, Color, Style}; | ||
#[cfg(feature = "std")] | ||
use colorchoice::ColorChoice; | ||
use std::{ | ||
collections::HashMap, | ||
io::{self, Write}, | ||
}; | ||
#[cfg(feature = "std")] | ||
use std::io::{self, Write}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here we should rather feature gate the code that depends on this I assume |
||
|
||
const CHEATCODE_ADDRESS: Address = address!("7109709ECfa91a80626fF3989D68f67F5b1DD12D"); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can use the
alloc
feature