Skip to content

Commit bf986d6

Browse files
Use an older flow with overrides based on polkadot-evm 1425 PR
1 parent 5b5fbf6 commit bf986d6

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/evm-tracing-rpc/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ ethereum = { workspace = true }
1313
fc-db = { workspace = true }
1414
fc-rpc = { workspace = true }
1515
fc-rpc-core = { workspace = true }
16+
fc-storage = { workspace = true }
1617
fp-rpc = { workspace = true }
1718
frame-support = { workspace = true }
1819
futures = { workspace = true }

crates/evm-tracing-rpc/src/debug/handler.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use evm_tracing_client::{
2020
single::{self, TransactionTrace},
2121
},
2222
};
23-
use fc_rpc::{frontier_backend_client, internal_err, StorageOverride};
23+
use fc_rpc::{frontier_backend_client, internal_err, OverrideHandle};
2424
use fp_rpc::EthereumRuntimeRPCApi;
2525
use futures::StreamExt;
2626
use jsonrpsee::core::RpcResult;
@@ -67,7 +67,7 @@ where
6767
backend: Arc<BE>,
6868
frontier_backend: Arc<dyn fc_db::BackendReader<B> + Send + Sync>,
6969
permit_pool: Arc<Semaphore>,
70-
overrides: Arc<dyn StorageOverride<B>>,
70+
overrides: Arc<OverrideHandle<B>>,
7171
raw_max_memory_usage: usize,
7272
) -> (impl Future<Output = ()>, DebugRequester) {
7373
let (tx, mut rx): (DebugRequester, _) =
@@ -244,7 +244,7 @@ where
244244
frontier_backend: Arc<dyn fc_db::BackendReader<B> + Send + Sync>,
245245
request_block_id: RequestBlockId,
246246
params: Option<TraceParams>,
247-
overrides: Arc<dyn StorageOverride<B>>,
247+
overrides: Arc<OverrideHandle<B>>,
248248
) -> RpcResult<Response> {
249249
let (tracer_input, trace_type) = Self::handle_params(params)?;
250250

@@ -290,6 +290,7 @@ where
290290
let parent_block_hash = *header.parent_hash();
291291

292292
let statuses = overrides
293+
.fallback
293294
.current_transaction_statuses(hash)
294295
.unwrap_or_default();
295296

@@ -461,7 +462,7 @@ where
461462
frontier_backend: Arc<dyn fc_db::BackendReader<B> + Send + Sync>,
462463
transaction_hash: H256,
463464
params: Option<TraceParams>,
464-
overrides: Arc<dyn StorageOverride<B>>,
465+
overrides: Arc<OverrideHandle<B>>,
465466
raw_max_memory_usage: usize,
466467
) -> RpcResult<Response> {
467468
let (tracer_input, trace_type) = Self::handle_params(params)?;
@@ -510,7 +511,14 @@ where
510511
.map_err(|e| internal_err(format!("Fail to read blockchain db: {:?}", e)))?
511512
.unwrap_or_default();
512513

513-
let reference_block = overrides.current_block(reference_hash);
514+
let reference_block = overrides
515+
.schemas
516+
.get(&fc_storage::onchain_storage_schema(
517+
client.as_ref(),
518+
reference_hash,
519+
))
520+
.unwrap_or(&overrides.fallback)
521+
.current_block(reference_hash);
514522

515523
// Get the actual ethereum transaction.
516524
if let Some(block) = reference_block {

crates/evm-tracing-rpc/src/trace/cache_task.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use evm_tracing_client::{
88
formatters::ResponseFormatter,
99
types::block::{self, TransactionTrace},
1010
};
11-
use fc_rpc::StorageOverride;
11+
use fc_rpc::OverrideHandle;
1212
use fp_rpc::EthereumRuntimeRPCApi;
1313
use futures::stream::FuturesUnordered;
1414
use futures::{select, FutureExt, StreamExt};
@@ -138,7 +138,7 @@ where
138138
backend: Arc<BE>,
139139
cache_duration: Duration,
140140
blocking_permits: Arc<Semaphore>,
141-
overrides: Arc<dyn StorageOverride<B>>,
141+
overrides: Arc<OverrideHandle<B>>,
142142
prometheus: Option<PrometheusRegistry>,
143143
) -> (impl Future<Output = ()>, CacheRequester) {
144144
// Communication with the outside world :
@@ -231,7 +231,7 @@ where
231231
blocking_tx: &mpsc::Sender<BlockingTaskMessage>,
232232
sender: oneshot::Sender<CacheBatchId>,
233233
blocks: Vec<H256>,
234-
overrides: Arc<dyn StorageOverride<B>>,
234+
overrides: Arc<OverrideHandle<B>>,
235235
) {
236236
tracing::trace!("Starting batch {}", self.next_batch_id);
237237
self.batches.insert(self.next_batch_id, blocks.clone());
@@ -488,7 +488,7 @@ where
488488
client: Arc<C>,
489489
backend: Arc<BE>,
490490
substrate_hash: H256,
491-
overrides: Arc<dyn StorageOverride<B>>,
491+
overrides: Arc<OverrideHandle<B>>,
492492
) -> TxsTraceRes {
493493
let api = client.runtime_api();
494494
let block_header = client
@@ -506,8 +506,17 @@ where
506506

507507
// Get Ethereum block data.
508508
let (eth_block, eth_transactions) = match (
509-
overrides.current_block(substrate_hash),
510-
overrides.current_transaction_statuses(substrate_hash),
509+
overrides
510+
.schemas
511+
.get(&fc_storage::onchain_storage_schema(
512+
client.as_ref(),
513+
substrate_hash,
514+
))
515+
.unwrap_or(&overrides.fallback)
516+
.current_block(substrate_hash),
517+
overrides
518+
.fallback
519+
.current_transaction_statuses(substrate_hash),
511520
) {
512521
(Some(a), Some(b)) => (a, b),
513522
_ => {

0 commit comments

Comments
 (0)