Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
lint
  • Loading branch information
clabby committed Jul 2, 2024
1 parent 4458d41 commit 2c93be0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions crates/rpc/rpc-api/src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::collections::HashMap;

use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, B256};
use reth_rpc_types::{
Expand All @@ -9,6 +7,7 @@ use reth_rpc_types::{
},
Bundle, RichBlock, StateContext, TransactionRequest,
};
use std::collections::HashMap;

/// Debug rpc interface.
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "debug"))]
Expand Down
1 change: 0 additions & 1 deletion crates/rpc/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ reth-network-peers.workspace = true
reth-evm.workspace = true
reth-rpc-eth-types.workspace = true
reth-rpc-server-types.workspace = true
reth-trie.workspace = true
reth-evm-optimism = { workspace = true, optional = true }

# eth
Expand Down
53 changes: 24 additions & 29 deletions crates/rpc/rpc/src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::sync::Arc;

use alloy_rlp::{Decodable, Encodable};
use async_trait::async_trait;
use jsonrpsee::core::RpcResult;
Expand All @@ -11,9 +9,8 @@ use reth_primitives::{
B256, U256,
};
use reth_provider::{
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider,
HistoricalStateProviderRef, StateProvider, StateProviderFactory, StateRootProvider,
TransactionVariant,
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, HeaderProvider, StateProvider,
StateProviderFactory, TransactionVariant,
};
use reth_revm::database::StateProviderDatabase;
use reth_rpc_api::DebugApiServer;
Expand All @@ -29,16 +26,16 @@ use reth_rpc_types::{
BlockError, Bundle, RichBlock, StateContext, TransactionRequest,
};
use reth_tasks::pool::BlockingTaskGuard;
use reth_trie::{proof::Proof, HashedPostState};
use revm::{
db::{states::bundle_state::BundleRetention, CacheDB, State},
db::CacheDB,
primitives::{db::DatabaseCommit, BlockEnv, CfgEnvWithHandlerCfg, Env, EnvWithHandlerCfg},
};
use revm_inspectors::tracing::{
js::{JsInspector, TransactionContext},
FourByteInspector, MuxInspector, TracingInspector, TracingInspectorConfig,
};
use revm_primitives::{keccak256, HashMap};
use std::sync::Arc;
use tokio::sync::{AcquireError, OwnedSemaphorePermit};

/// `debug` API implementation.
Expand Down Expand Up @@ -91,7 +88,7 @@ where
) -> EthResult<Vec<TraceResult>> {
if transactions.is_empty() {
// nothing to trace
return Ok(Vec::new())
return Ok(Vec::new());
}

// replay all transactions of the block
Expand Down Expand Up @@ -303,7 +300,7 @@ where
Ok(inspector)
})
.await?;
return Ok(FourByteFrame::from(inspector).into())
return Ok(FourByteFrame::from(inspector).into());
}
GethDebugBuiltInTracerType::CallTracer => {
let call_config = tracer_config
Expand All @@ -325,7 +322,7 @@ where
Ok(frame.into())
})
.await?;
return Ok(frame)
return Ok(frame);
}
GethDebugBuiltInTracerType::PreStateTracer => {
let prestate_config = tracer_config
Expand All @@ -351,7 +348,7 @@ where
Ok(frame)
})
.await?;
return Ok(frame.into())
return Ok(frame.into());
}
GethDebugBuiltInTracerType::NoopTracer => Ok(NoopFrame::default().into()),
GethDebugBuiltInTracerType::MuxTracer => {
Expand All @@ -375,7 +372,7 @@ where
Ok(frame.into())
})
.await?;
return Ok(frame)
return Ok(frame);
}
},
GethDebugTracerType::JsTracer(code) => {
Expand All @@ -400,7 +397,7 @@ where

Ok(GethTrace::JS(res))
}
}
};
}

// default structlog tracer
Expand Down Expand Up @@ -433,7 +430,7 @@ where
opts: Option<GethDebugTracingCallOptions>,
) -> EthResult<Vec<Vec<GethTrace>>> {
if bundles.is_empty() {
return Err(EthApiError::InvalidParams(String::from("bundles are empty.")))
return Err(EthApiError::InvalidParams(String::from("bundles are empty.")));
}

let StateContext { transaction_index, block_number } = state_context.unwrap_or_default();
Expand Down Expand Up @@ -584,11 +581,8 @@ where
.accounts
.into_iter()
.map(|(addr, db_acc)| {
let storage_keys = db_acc
.storage
.into_iter()
.map(|(storage_key, _)| storage_key.into())
.collect::<Vec<_>>();
let storage_keys =
db_acc.storage.keys().copied().map(Into::into).collect::<Vec<_>>();

let account_proof = state.proof(addr, &storage_keys)?;
Ok(account_proof)
Expand All @@ -607,22 +601,23 @@ where
let mut witness = HashMap::with_capacity(total_nodes);
for proof in account_proofs {
// First, add all account proof nodes.
for node in proof.proof.into_iter() {
for node in proof.proof {
let hash = keccak256(node.as_ref());
witness.insert(hash, node);
}

// Next, add all storage proof nodes.
for storage_proof in proof.storage_proofs.into_iter() {
for node in storage_proof.proof.into_iter() {
for storage_proof in proof.storage_proofs {
for node in storage_proof.proof {
let hash = keccak256(node.as_ref());
witness.insert(hash, node);
}
}
}

// TODO: Also need blinded sibling nodes accessed during deletion, to allow for state root
// recomputation. As is, this is only sufficient for executing the block.
// TODO: Also need blinded sibling nodes accessed during deletion, to allow for
// state root recomputation. As is, this is only sufficient for
// executing the block.
Ok(witness)
})
.await
Expand Down Expand Up @@ -650,7 +645,7 @@ where
GethDebugBuiltInTracerType::FourByteTracer => {
let mut inspector = FourByteInspector::default();
let (res, _) = self.eth_api().inspect(db, env, &mut inspector)?;
return Ok((FourByteFrame::from(inspector).into(), res.state))
return Ok((FourByteFrame::from(inspector).into(), res.state));
}
GethDebugBuiltInTracerType::CallTracer => {
let call_config = tracer_config
Expand All @@ -667,7 +662,7 @@ where
.into_geth_builder()
.geth_call_traces(call_config, res.result.gas_used());

return Ok((frame.into(), res.state))
return Ok((frame.into(), res.state));
}
GethDebugBuiltInTracerType::PreStateTracer => {
let prestate_config = tracer_config
Expand All @@ -685,7 +680,7 @@ where
db,
)?;

return Ok((frame.into(), res.state))
return Ok((frame.into(), res.state));
}
GethDebugBuiltInTracerType::NoopTracer => {
Ok((NoopFrame::default().into(), Default::default()))
Expand All @@ -699,7 +694,7 @@ where

let (res, _) = self.eth_api().inspect(&mut *db, env, &mut inspector)?;
let frame = inspector.try_into_mux_frame(&res, db)?;
return Ok((frame.into(), res.state))
return Ok((frame.into(), res.state));
}
},
GethDebugTracerType::JsTracer(code) => {
Expand All @@ -715,7 +710,7 @@ where
let result = inspector.json_result(res, &env, db)?;
Ok((GethTrace::JS(result), state))
}
}
};
}

// default structlog tracer
Expand Down
2 changes: 1 addition & 1 deletion crates/storage/provider/src/providers/state/historical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use reth_primitives::{
StorageValue, B256,
};
use reth_storage_errors::provider::ProviderResult;
use reth_trie::{updates::TrieUpdates, AccountProof, HashedPostState};
use reth_trie::{proof::Proof, updates::TrieUpdates, AccountProof, HashedPostState};
use revm::db::BundleState;
use std::fmt::Debug;

Expand Down

0 comments on commit 2c93be0

Please sign in to comment.