mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: phase out Substate::new (#4957)
This commit is contained in:
@ -96,7 +96,7 @@ where
|
|||||||
.eth_api
|
.eth_api
|
||||||
.spawn_with_state_at_block(at, move |state| {
|
.spawn_with_state_at_block(at, move |state| {
|
||||||
let mut results = Vec::with_capacity(transactions.len());
|
let mut results = Vec::with_capacity(transactions.len());
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
let mut transactions = transactions.into_iter().peekable();
|
let mut transactions = transactions.into_iter().peekable();
|
||||||
while let Some(tx) = transactions.next() {
|
while let Some(tx) = transactions.next() {
|
||||||
@ -190,7 +190,7 @@ where
|
|||||||
// configure env for the target transaction
|
// configure env for the target transaction
|
||||||
let tx = transaction.into_recovered();
|
let tx = transaction.into_recovered();
|
||||||
|
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
// replay all transactions prior to the targeted transaction
|
// replay all transactions prior to the targeted transaction
|
||||||
replay_transactions_until(
|
replay_transactions_until(
|
||||||
&mut db,
|
&mut db,
|
||||||
@ -289,7 +289,7 @@ where
|
|||||||
// because JSTracer and all JS types are not Send
|
// because JSTracer and all JS types are not Send
|
||||||
let (_, _, at) = self.inner.eth_api.evm_env_at(at).await?;
|
let (_, _, at) = self.inner.eth_api.evm_env_at(at).await?;
|
||||||
let state = self.inner.eth_api.state_at(at)?;
|
let state = self.inner.eth_api.state_at(at)?;
|
||||||
let db = SubState::new(StateProviderDatabase::new(state));
|
let db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
let has_state_overrides = overrides.has_state();
|
let has_state_overrides = overrides.has_state();
|
||||||
|
|
||||||
// If the caller provided state overrides we need to clone the DB so the js
|
// If the caller provided state overrides we need to clone the DB so the js
|
||||||
@ -380,7 +380,7 @@ where
|
|||||||
.spawn_with_state_at_block(at.into(), move |state| {
|
.spawn_with_state_at_block(at.into(), move |state| {
|
||||||
// the outer vec for the bundles
|
// the outer vec for the bundles
|
||||||
let mut all_bundles = Vec::with_capacity(bundles.len());
|
let mut all_bundles = Vec::with_capacity(bundles.len());
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
if replay_block_txs {
|
if replay_block_txs {
|
||||||
// only need to replay the transactions in the block if not all transactions are
|
// only need to replay the transactions in the block if not all transactions are
|
||||||
|
|||||||
@ -17,9 +17,7 @@ use reth_provider::{
|
|||||||
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProvider, StateProviderFactory,
|
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProvider, StateProviderFactory,
|
||||||
};
|
};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
access_list::AccessListInspector,
|
access_list::AccessListInspector, database::StateProviderDatabase, env::tx_env_with_recovered,
|
||||||
database::{StateProviderDatabase, SubState},
|
|
||||||
env::tx_env_with_recovered,
|
|
||||||
};
|
};
|
||||||
use reth_rpc_types::{
|
use reth_rpc_types::{
|
||||||
state::StateOverride, BlockError, Bundle, CallRequest, EthCallResponse, StateContext,
|
state::StateOverride, BlockError, Bundle, CallRequest, EthCallResponse, StateContext,
|
||||||
@ -109,7 +107,7 @@ where
|
|||||||
|
|
||||||
self.spawn_with_state_at_block(at.into(), move |state| {
|
self.spawn_with_state_at_block(at.into(), move |state| {
|
||||||
let mut results = Vec::with_capacity(transactions.len());
|
let mut results = Vec::with_capacity(transactions.len());
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
if replay_block_txs {
|
if replay_block_txs {
|
||||||
// only need to replay the transactions in the block if not all transactions are
|
// only need to replay the transactions in the block if not all transactions are
|
||||||
@ -198,7 +196,7 @@ where
|
|||||||
|
|
||||||
// Configure the evm env
|
// Configure the evm env
|
||||||
let mut env = build_call_evm_env(cfg, block, request)?;
|
let mut env = build_call_evm_env(cfg, block, request)?;
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
// if the request is a simple transfer we can optimize
|
// if the request is a simple transfer we can optimize
|
||||||
if env.tx.data.is_empty() {
|
if env.tx.data.is_empty() {
|
||||||
@ -369,7 +367,7 @@ where
|
|||||||
// <https://github.com/ethereum/go-ethereum/blob/8990c92aea01ca07801597b00c0d83d4e2d9b811/internal/ethapi/api.go#L1476-L1476>
|
// <https://github.com/ethereum/go-ethereum/blob/8990c92aea01ca07801597b00c0d83d4e2d9b811/internal/ethapi/api.go#L1476-L1476>
|
||||||
env.cfg.disable_base_fee = true;
|
env.cfg.disable_base_fee = true;
|
||||||
|
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
if request.gas.is_none() && env.tx.gas_price > U256::ZERO {
|
if request.gas.is_none() && env.tx.gas_price > U256::ZERO {
|
||||||
// no gas limit was provided in the request, so we need to cap the request's gas limit
|
// no gas limit was provided in the request, so we need to cap the request's gas limit
|
||||||
|
|||||||
@ -20,13 +20,11 @@ use reth_primitives::{
|
|||||||
TransactionKind::{Call, Create},
|
TransactionKind::{Call, Create},
|
||||||
TransactionMeta, TransactionSigned, TransactionSignedEcRecovered, B256, U128, U256, U64,
|
TransactionMeta, TransactionSigned, TransactionSignedEcRecovered, B256, U128, U256, U64,
|
||||||
};
|
};
|
||||||
use reth_rpc_types_compat::from_recovered_with_block_context;
|
|
||||||
|
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProviderBox, StateProviderFactory,
|
BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProviderBox, StateProviderFactory,
|
||||||
};
|
};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
database::{StateProviderDatabase, SubState},
|
database::StateProviderDatabase,
|
||||||
env::{fill_block_env_with_coinbase, tx_env_with_recovered},
|
env::{fill_block_env_with_coinbase, tx_env_with_recovered},
|
||||||
tracing::{TracingInspector, TracingInspectorConfig},
|
tracing::{TracingInspector, TracingInspectorConfig},
|
||||||
};
|
};
|
||||||
@ -34,6 +32,7 @@ use reth_rpc_types::{
|
|||||||
CallRequest, Index, Log, Transaction, TransactionInfo, TransactionReceipt, TransactionRequest,
|
CallRequest, Index, Log, Transaction, TransactionInfo, TransactionReceipt, TransactionRequest,
|
||||||
TypedTransactionRequest,
|
TypedTransactionRequest,
|
||||||
};
|
};
|
||||||
|
use reth_rpc_types_compat::from_recovered_with_block_context;
|
||||||
use reth_transaction_pool::{TransactionOrigin, TransactionPool};
|
use reth_transaction_pool::{TransactionOrigin, TransactionPool};
|
||||||
use revm::{
|
use revm::{
|
||||||
db::CacheDB,
|
db::CacheDB,
|
||||||
@ -533,7 +532,7 @@ where
|
|||||||
.tracing_call_pool
|
.tracing_call_pool
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
let state = this.state_at(at)?;
|
let state = this.state_at(at)?;
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
let env = prepare_call_env(
|
let env = prepare_call_env(
|
||||||
cfg,
|
cfg,
|
||||||
@ -584,7 +583,7 @@ where
|
|||||||
F: FnOnce(TracingInspector, ResultAndState) -> EthResult<R>,
|
F: FnOnce(TracingInspector, ResultAndState) -> EthResult<R>,
|
||||||
{
|
{
|
||||||
self.with_state_at_block(at, |state| {
|
self.with_state_at_block(at, |state| {
|
||||||
let db = SubState::new(StateProviderDatabase::new(state));
|
let db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
let mut inspector = TracingInspector::new(config);
|
let mut inspector = TracingInspector::new(config);
|
||||||
let (res, _) = inspect(db, env, &mut inspector)?;
|
let (res, _) = inspect(db, env, &mut inspector)?;
|
||||||
@ -607,7 +606,7 @@ where
|
|||||||
R: Send + 'static,
|
R: Send + 'static,
|
||||||
{
|
{
|
||||||
self.spawn_with_state_at_block(at, move |state| {
|
self.spawn_with_state_at_block(at, move |state| {
|
||||||
let db = SubState::new(StateProviderDatabase::new(state));
|
let db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
let mut inspector = TracingInspector::new(config);
|
let mut inspector = TracingInspector::new(config);
|
||||||
let (res, _, db) = inspect_and_return_db(db, env, &mut inspector)?;
|
let (res, _, db) = inspect_and_return_db(db, env, &mut inspector)?;
|
||||||
|
|
||||||
@ -665,7 +664,7 @@ where
|
|||||||
let block_txs = block.body;
|
let block_txs = block.body;
|
||||||
|
|
||||||
self.spawn_with_state_at_block(parent_block.into(), move |state| {
|
self.spawn_with_state_at_block(parent_block.into(), move |state| {
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
// replay all transactions prior to the targeted transaction
|
// replay all transactions prior to the targeted transaction
|
||||||
replay_transactions_until(&mut db, cfg.clone(), block_env.clone(), block_txs, tx.hash)?;
|
replay_transactions_until(&mut db, cfg.clone(), block_env.clone(), block_txs, tx.hash)?;
|
||||||
|
|||||||
@ -15,7 +15,7 @@ use reth_provider::{
|
|||||||
BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderBox, StateProviderFactory,
|
BlockReader, ChainSpecProvider, EvmEnvProvider, StateProviderBox, StateProviderFactory,
|
||||||
};
|
};
|
||||||
use reth_revm::{
|
use reth_revm::{
|
||||||
database::{StateProviderDatabase, SubState},
|
database::StateProviderDatabase,
|
||||||
env::tx_env_with_recovered,
|
env::tx_env_with_recovered,
|
||||||
tracing::{
|
tracing::{
|
||||||
parity::populate_account_balance_nonce_diffs, TracingInspector, TracingInspectorConfig,
|
parity::populate_account_balance_nonce_diffs, TracingInspector, TracingInspectorConfig,
|
||||||
@ -144,7 +144,7 @@ where
|
|||||||
.eth_api
|
.eth_api
|
||||||
.spawn_with_state_at_block(at, move |state| {
|
.spawn_with_state_at_block(at, move |state| {
|
||||||
let mut results = Vec::with_capacity(calls.len());
|
let mut results = Vec::with_capacity(calls.len());
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
let mut calls = calls.into_iter().peekable();
|
let mut calls = calls.into_iter().peekable();
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ where
|
|||||||
.eth_api
|
.eth_api
|
||||||
.spawn_with_state_at_block(state_at.into(), move |state| {
|
.spawn_with_state_at_block(state_at.into(), move |state| {
|
||||||
let mut results = Vec::with_capacity(transactions.len());
|
let mut results = Vec::with_capacity(transactions.len());
|
||||||
let mut db = SubState::new(StateProviderDatabase::new(state));
|
let mut db = CacheDB::new(StateProviderDatabase::new(state));
|
||||||
|
|
||||||
let mut transactions = transactions.into_iter().enumerate().peekable();
|
let mut transactions = transactions.into_iter().enumerate().peekable();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user