mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: add some geth tracer ergonomics (#4952)
This commit is contained in:
@ -51,6 +51,20 @@ pub struct CallConfig {
|
|||||||
pub with_log: Option<bool>,
|
pub with_log: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CallConfig {
|
||||||
|
/// Sets the only top call flag
|
||||||
|
pub fn only_top_call(mut self) -> Self {
|
||||||
|
self.only_top_call = Some(true);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the with log flag
|
||||||
|
pub fn with_log(mut self) -> Self {
|
||||||
|
self.with_log = Some(true);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
use crate::{state::StateOverride, BlockOverrides};
|
use crate::{state::StateOverride, BlockOverrides};
|
||||||
use reth_primitives::{Bytes, B256, U256};
|
use reth_primitives::{Bytes, B256, U256};
|
||||||
use serde::{de::DeserializeOwned, ser::SerializeMap, Deserialize, Serialize, Serializer};
|
use serde::{de::DeserializeOwned, ser::SerializeMap, Deserialize, Serialize, Serializer};
|
||||||
use std::collections::BTreeMap;
|
use std::{collections::BTreeMap, time::Duration};
|
||||||
|
|
||||||
// re-exports
|
// re-exports
|
||||||
pub use self::{
|
pub use self::{
|
||||||
@ -186,6 +186,12 @@ pub enum GethDebugTracerType {
|
|||||||
JsTracer(String),
|
JsTracer(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<GethDebugBuiltInTracerType> for GethDebugTracerType {
|
||||||
|
fn from(value: GethDebugBuiltInTracerType) -> Self {
|
||||||
|
GethDebugTracerType::BuiltInTracer(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Configuration of the tracer
|
/// Configuration of the tracer
|
||||||
///
|
///
|
||||||
/// This is a simple wrapper around serde_json::Value.
|
/// This is a simple wrapper around serde_json::Value.
|
||||||
@ -264,6 +270,34 @@ pub struct GethDebugTracingOptions {
|
|||||||
pub timeout: Option<String>,
|
pub timeout: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GethDebugTracingOptions {
|
||||||
|
/// Sets the tracer to use
|
||||||
|
pub fn with_tracer(mut self, tracer: GethDebugTracerType) -> Self {
|
||||||
|
self.tracer = Some(tracer);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sets the timeout to use for tracing
|
||||||
|
pub fn with_timeout(mut self, duration: Duration) -> Self {
|
||||||
|
self.timeout = Some(format!("{}ms", duration.as_millis()));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configures a [CallConfig]
|
||||||
|
pub fn call_config(mut self, config: CallConfig) -> Self {
|
||||||
|
self.tracer_config =
|
||||||
|
GethDebugTracerConfig(serde_json::to_value(config).expect("is serializable"));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Configures a [PreStateConfig]
|
||||||
|
pub fn prestate_config(mut self, config: PreStateConfig) -> Self {
|
||||||
|
self.tracer_config =
|
||||||
|
GethDebugTracerConfig(serde_json::to_value(config).expect("is serializable"));
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Default tracing options for the struct looger.
|
/// Default tracing options for the struct looger.
|
||||||
///
|
///
|
||||||
/// These are all known general purpose tracer options that may or not be supported by a given
|
/// These are all known general purpose tracer options that may or not be supported by a given
|
||||||
|
|||||||
Reference in New Issue
Block a user