mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
chore: phase out reth-primitives from inspectors (#5552)
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -6281,7 +6281,6 @@ dependencies = [
|
||||
"alloy-sol-types",
|
||||
"boa_engine",
|
||||
"boa_gc",
|
||||
"reth-primitives",
|
||||
"reth-rpc-types",
|
||||
"revm",
|
||||
"serde",
|
||||
|
||||
@@ -10,7 +10,6 @@ description = "revm inspector implementations used by reth"
|
||||
|
||||
[dependencies]
|
||||
# reth
|
||||
reth-primitives.workspace = true
|
||||
reth-rpc-types.workspace = true
|
||||
|
||||
# eth
|
||||
|
||||
@@ -17,13 +17,12 @@ use boa_engine::{
|
||||
Context, JsArgs, JsError, JsNativeError, JsObject, JsResult, JsValue,
|
||||
};
|
||||
use boa_gc::{empty_trace, Finalize, Trace};
|
||||
use reth_primitives::Account;
|
||||
use revm::{
|
||||
interpreter::{
|
||||
opcode::{PUSH0, PUSH32},
|
||||
OpCode, SharedMemory, Stack,
|
||||
},
|
||||
primitives::{State, KECCAK_EMPTY},
|
||||
primitives::{AccountInfo, State, KECCAK_EMPTY},
|
||||
};
|
||||
use std::{cell::RefCell, rc::Rc, sync::mpsc::channel};
|
||||
use tokio::sync::mpsc;
|
||||
@@ -298,14 +297,8 @@ impl StateRef {
|
||||
(StateRef(inner), guard)
|
||||
}
|
||||
|
||||
fn get_account(&self, address: &Address) -> Option<Account> {
|
||||
self.0.with_inner(|state| {
|
||||
state.get(address).map(|acc| Account {
|
||||
nonce: acc.info.nonce,
|
||||
balance: acc.info.balance,
|
||||
bytecode_hash: Some(acc.info.code_hash),
|
||||
})
|
||||
})?
|
||||
fn get_account(&self, address: &Address) -> Option<AccountInfo> {
|
||||
self.0.with_inner(|state| state.get(address).map(|acc| acc.info.clone()))?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,7 +701,7 @@ impl EvmDbRef {
|
||||
(this, guard)
|
||||
}
|
||||
|
||||
fn read_basic(&self, address: JsValue, ctx: &mut Context<'_>) -> JsResult<Option<Account>> {
|
||||
fn read_basic(&self, address: JsValue, ctx: &mut Context<'_>) -> JsResult<Option<AccountInfo>> {
|
||||
let buf = from_buf(address, ctx)?;
|
||||
let address = bytes_to_address(buf);
|
||||
if let acc @ Some(_) = self.state.get_account(&address) {
|
||||
@@ -733,7 +726,7 @@ impl EvmDbRef {
|
||||
|
||||
fn read_code(&self, address: JsValue, ctx: &mut Context<'_>) -> JsResult<JsArrayBuffer> {
|
||||
let acc = self.read_basic(address, ctx)?;
|
||||
let code_hash = acc.and_then(|acc| acc.bytecode_hash).unwrap_or(KECCAK_EMPTY);
|
||||
let code_hash = acc.map(|acc| acc.code_hash).unwrap_or(KECCAK_EMPTY);
|
||||
if code_hash == KECCAK_EMPTY {
|
||||
return JsArrayBuffer::new(0, ctx)
|
||||
}
|
||||
|
||||
@@ -12,13 +12,12 @@ use crate::tracing::{
|
||||
};
|
||||
use alloy_primitives::{Address, Bytes, B256, U256};
|
||||
use boa_engine::{Context, JsError, JsObject, JsResult, JsValue, Source};
|
||||
use reth_primitives::Account;
|
||||
use revm::{
|
||||
interpreter::{
|
||||
return_revert, CallInputs, CallScheme, CreateInputs, Gas, InstructionResult, Interpreter,
|
||||
},
|
||||
precompile::Precompiles,
|
||||
primitives::{Env, ExecutionResult, Output, ResultAndState, TransactTo},
|
||||
primitives::{AccountInfo, Env, ExecutionResult, Output, ResultAndState, TransactTo},
|
||||
Database, EVMData, Inspector,
|
||||
};
|
||||
use tokio::sync::mpsc;
|
||||
@@ -484,7 +483,7 @@ pub enum JsDbRequest {
|
||||
/// The address of the account to be loaded
|
||||
address: Address,
|
||||
/// The response channel
|
||||
resp: std::sync::mpsc::Sender<Result<Option<Account>, String>>,
|
||||
resp: std::sync::mpsc::Sender<Result<Option<AccountInfo>, String>>,
|
||||
},
|
||||
/// Bindings for [Database::code_by_hash]
|
||||
Code {
|
||||
|
||||
@@ -19,7 +19,7 @@ use reth_primitives::{
|
||||
db::{DatabaseCommit, DatabaseRef},
|
||||
BlockEnv, CfgEnv,
|
||||
},
|
||||
Account, Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSigned, B256,
|
||||
Address, Block, BlockId, BlockNumberOrTag, Bytes, TransactionSigned, B256,
|
||||
};
|
||||
use reth_provider::{BlockReaderIdExt, HeaderProvider, StateProviderBox};
|
||||
use reth_revm::{
|
||||
@@ -610,16 +610,7 @@ where
|
||||
while let Some(req) = stream.next().await {
|
||||
match req {
|
||||
JsDbRequest::Basic { address, resp } => {
|
||||
let acc = db
|
||||
.basic_ref(address)
|
||||
.map(|maybe_acc| {
|
||||
maybe_acc.map(|acc| Account {
|
||||
nonce: acc.nonce,
|
||||
balance: acc.balance,
|
||||
bytecode_hash: Some(acc.code_hash),
|
||||
})
|
||||
})
|
||||
.map_err(|err| err.to_string());
|
||||
let acc = db.basic_ref(address).map_err(|err| err.to_string());
|
||||
let _ = resp.send(acc);
|
||||
}
|
||||
JsDbRequest::Code { code_hash, resp } => {
|
||||
|
||||
Reference in New Issue
Block a user