From 6f779f580d25c891551f1275c440dead696f1e39 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 10 Dec 2025 19:41:37 +0100 Subject: [PATCH 1/5] Add substrate_postDispatchWeight rpc methods Adding a new method to return the post-dispatch weight of a transaction --- substrate/frame/revive/rpc/src/apis.rs | 3 ++ .../revive/rpc/src/apis/substrate_api.rs | 47 +++++++++++++++++++ substrate/frame/revive/rpc/src/cli.rs | 6 ++- substrate/frame/revive/rpc/src/client.rs | 11 +++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 substrate/frame/revive/rpc/src/apis/substrate_api.rs diff --git a/substrate/frame/revive/rpc/src/apis.rs b/substrate/frame/revive/rpc/src/apis.rs index ae85246c55b39..c57bf584b4c55 100644 --- a/substrate/frame/revive/rpc/src/apis.rs +++ b/substrate/frame/revive/rpc/src/apis.rs @@ -22,3 +22,6 @@ pub use execution_apis::*; mod health_api; pub use health_api::*; + +mod substrate_api; +pub use substrate_api::*; diff --git a/substrate/frame/revive/rpc/src/apis/substrate_api.rs b/substrate/frame/revive/rpc/src/apis/substrate_api.rs new file mode 100644 index 0000000000000..5d9e2707a5145 --- /dev/null +++ b/substrate/frame/revive/rpc/src/apis/substrate_api.rs @@ -0,0 +1,47 @@ +// This file is part of Substrate. + +// Copyright (C) Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//! Substrate-specific JSON-RPC methods. + +use crate::*; +use sp_runtime::Weight; +use jsonrpsee::{core::RpcResult, proc_macros::rpc}; + +#[rpc(server, client)] +pub trait SubstrateRpc { + /// Get the post dispatch weight for a given transaction hash. + #[method(name = "substrate_postDispatchWeight")] + async fn post_dispatch_weight(&self, transaction_hash: H256) -> RpcResult>; +} + +pub struct SubstrateRpcServerImpl { + client: client::Client, +} + +impl SubstrateRpcServerImpl { + pub fn new(client: client::Client) -> Self { + Self { client } + } +} + +#[async_trait] +impl SubstrateRpcServer for SubstrateRpcServerImpl { + async fn post_dispatch_weight(&self, transaction_hash: H256) -> RpcResult> { + let weight = self.client.post_dispatch_weight(&transaction_hash).await; + Ok(weight) + } +} + diff --git a/substrate/frame/revive/rpc/src/cli.rs b/substrate/frame/revive/rpc/src/cli.rs index 6016215a32f2d..0a559eab59f79 100644 --- a/substrate/frame/revive/rpc/src/cli.rs +++ b/substrate/frame/revive/rpc/src/cli.rs @@ -20,6 +20,8 @@ use crate::{ DebugRpcServer, DebugRpcServerImpl, EthRpcServer, EthRpcServerImpl, ReceiptExtractor, ReceiptProvider, SubxtBlockInfoProvider, SystemHealthRpcServer, SystemHealthRpcServerImpl, LOG_TARGET, + SubstrateRpcServer, + SubstrateRpcServerImpl, }; use clap::Parser; use futures::{future::BoxFuture, pin_mut, FutureExt}; @@ -266,11 +268,13 @@ fn rpc_module(is_dev: bool, client: Client) -> Result, sc_service: .into_rpc(); let health_api = SystemHealthRpcServerImpl::new(client.clone()).into_rpc(); - let debug_api = DebugRpcServerImpl::new(client).into_rpc(); + let debug_api = DebugRpcServerImpl::new(client.clone()).into_rpc(); + let substrate_api = SubstrateRpcServerImpl::new(client).into_rpc(); let mut module = RpcModule::new(()); module.merge(eth_api).map_err(|e| sc_service::Error::Application(e.into()))?; module.merge(health_api).map_err(|e| sc_service::Error::Application(e.into()))?; module.merge(debug_api).map_err(|e| sc_service::Error::Application(e.into()))?; + module.merge(substrate_api).map_err(|e| sc_service::Error::Application(e.into()))?; Ok(module) } diff --git a/substrate/frame/revive/rpc/src/client.rs b/substrate/frame/revive/rpc/src/client.rs index f193c2529ad31..908adebd3e2a5 100644 --- a/substrate/frame/revive/rpc/src/client.rs +++ b/substrate/frame/revive/rpc/src/client.rs @@ -475,6 +475,17 @@ impl Client { self.receipt_provider.receipt_by_hash(tx_hash).await } + /// Get The post dispatch weight associated with this Ethereum transaction hash. + pub async fn post_dispatch_weight(&self, tx_hash: &H256) -> Option { + use crate::subxt_client::system::events::ExtrinsicSuccess; + let ReceiptInfo { block_hash, transaction_index, .. } = self.receipt(tx_hash).await?; + let block_hash = self.resolve_substrate_hash(&block_hash).await?; + let block = self.block_provider.block_by_hash(&block_hash).await.ok()??; + let ext = block.extrinsics().await.ok()?.iter().nth(transaction_index.as_u32() as _)?; + let event = ext.events().await.ok()?.find_first::().ok()??; + Some(event.dispatch_info.weight.0) + } + pub async fn sync_state( &self, ) -> Result, ClientError> { From 4f8da3870255104cac3b547c35a86fb382168c0e Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Dec 2025 18:47:52 +0000 Subject: [PATCH 2/5] Update from github-actions[bot] running command 'prdoc --audience runtime_dev --bump patch' --- prdoc/pr_10612.prdoc | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 prdoc/pr_10612.prdoc diff --git a/prdoc/pr_10612.prdoc b/prdoc/pr_10612.prdoc new file mode 100644 index 0000000000000..d80b3d18b11c2 --- /dev/null +++ b/prdoc/pr_10612.prdoc @@ -0,0 +1,8 @@ +title: revive eth-rpc Add substrate_postDispatchWeight rpc methods +doc: +- audience: Runtime Dev + description: "Add a new RPC method to return the post-dispatch weight of a transaction\r\ + \n" +crates: +- name: pallet-revive-eth-rpc + bump: patch From 4dd9eec9f78939a32e69eaf88b9d4601783b8d9b Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 11 Dec 2025 20:06:47 +0000 Subject: [PATCH 3/5] Update from github-actions[bot] running command 'fmt' --- substrate/frame/revive/rpc/src/apis/substrate_api.rs | 3 +-- substrate/frame/revive/rpc/src/cli.rs | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/substrate/frame/revive/rpc/src/apis/substrate_api.rs b/substrate/frame/revive/rpc/src/apis/substrate_api.rs index 5d9e2707a5145..5c9b2d14e4aa3 100644 --- a/substrate/frame/revive/rpc/src/apis/substrate_api.rs +++ b/substrate/frame/revive/rpc/src/apis/substrate_api.rs @@ -17,8 +17,8 @@ //! Substrate-specific JSON-RPC methods. use crate::*; -use sp_runtime::Weight; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; +use sp_runtime::Weight; #[rpc(server, client)] pub trait SubstrateRpc { @@ -44,4 +44,3 @@ impl SubstrateRpcServer for SubstrateRpcServerImpl { Ok(weight) } } - diff --git a/substrate/frame/revive/rpc/src/cli.rs b/substrate/frame/revive/rpc/src/cli.rs index 0a559eab59f79..e755f3378c1de 100644 --- a/substrate/frame/revive/rpc/src/cli.rs +++ b/substrate/frame/revive/rpc/src/cli.rs @@ -18,10 +18,8 @@ use crate::{ client::{connect, Client, SubscriptionType, SubstrateBlockNumber}, DebugRpcServer, DebugRpcServerImpl, EthRpcServer, EthRpcServerImpl, ReceiptExtractor, - ReceiptProvider, SubxtBlockInfoProvider, SystemHealthRpcServer, SystemHealthRpcServerImpl, - LOG_TARGET, - SubstrateRpcServer, - SubstrateRpcServerImpl, + ReceiptProvider, SubstrateRpcServer, SubstrateRpcServerImpl, SubxtBlockInfoProvider, + SystemHealthRpcServer, SystemHealthRpcServerImpl, LOG_TARGET, }; use clap::Parser; use futures::{future::BoxFuture, pin_mut, FutureExt}; @@ -275,6 +273,8 @@ fn rpc_module(is_dev: bool, client: Client) -> Result, sc_service: module.merge(eth_api).map_err(|e| sc_service::Error::Application(e.into()))?; module.merge(health_api).map_err(|e| sc_service::Error::Application(e.into()))?; module.merge(debug_api).map_err(|e| sc_service::Error::Application(e.into()))?; - module.merge(substrate_api).map_err(|e| sc_service::Error::Application(e.into()))?; + module + .merge(substrate_api) + .map_err(|e| sc_service::Error::Application(e.into()))?; Ok(module) } From 03b76eae36e5363dac7dfcc19e386c504298717a Mon Sep 17 00:00:00 2001 From: pgherveou Date: Sat, 13 Dec 2025 00:09:05 +0000 Subject: [PATCH 4/5] Rename substrate to polkadot in RPC methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per review feedback, rename `substrate` to `polkadot` throughout the newly added RPC methods since substrate is a legacy name. Changes: - Renamed substrate_api.rs to polkadot_api.rs - Renamed trait SubstrateRpc to PolkadotRpc - Renamed method substrate_postDispatchWeight to polkadot_postDispatchWeight - Renamed struct SubstrateRpcServerImpl to PolkadotRpcServerImpl - Updated prdoc title 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- prdoc/pr_10612.prdoc | 2 +- substrate/frame/revive/rpc/src/apis.rs | 4 ++-- .../apis/{substrate_api.rs => polkadot_api.rs} | 12 ++++++------ .../frame/revive/rpc/src/block_info_provider.rs | 2 +- substrate/frame/revive/rpc/src/cli.rs | 8 ++++---- substrate/frame/revive/rpc/src/client.rs | 17 ++++++++++------- .../frame/revive/rpc/src/client/runtime_api.rs | 5 +++-- substrate/frame/revive/rpc/src/example.rs | 2 +- .../revive/rpc/src/fee_history_provider.rs | 2 +- substrate/frame/revive/rpc/src/lib.rs | 2 +- .../frame/revive/rpc/src/receipt_provider.rs | 15 +++++++++------ substrate/frame/revive/rpc/src/tests.rs | 11 ++++++----- 12 files changed, 45 insertions(+), 37 deletions(-) rename substrate/frame/revive/rpc/src/apis/{substrate_api.rs => polkadot_api.rs} (84%) diff --git a/prdoc/pr_10612.prdoc b/prdoc/pr_10612.prdoc index d80b3d18b11c2..9cb9c409df6d3 100644 --- a/prdoc/pr_10612.prdoc +++ b/prdoc/pr_10612.prdoc @@ -1,4 +1,4 @@ -title: revive eth-rpc Add substrate_postDispatchWeight rpc methods +title: revive eth-rpc Add polkadot_postDispatchWeight rpc methods doc: - audience: Runtime Dev description: "Add a new RPC method to return the post-dispatch weight of a transaction\r\ diff --git a/substrate/frame/revive/rpc/src/apis.rs b/substrate/frame/revive/rpc/src/apis.rs index c57bf584b4c55..0d3366f5d501c 100644 --- a/substrate/frame/revive/rpc/src/apis.rs +++ b/substrate/frame/revive/rpc/src/apis.rs @@ -23,5 +23,5 @@ pub use execution_apis::*; mod health_api; pub use health_api::*; -mod substrate_api; -pub use substrate_api::*; +mod polkadot_api; +pub use polkadot_api::*; diff --git a/substrate/frame/revive/rpc/src/apis/substrate_api.rs b/substrate/frame/revive/rpc/src/apis/polkadot_api.rs similarity index 84% rename from substrate/frame/revive/rpc/src/apis/substrate_api.rs rename to substrate/frame/revive/rpc/src/apis/polkadot_api.rs index 5c9b2d14e4aa3..bf683b5e4d989 100644 --- a/substrate/frame/revive/rpc/src/apis/substrate_api.rs +++ b/substrate/frame/revive/rpc/src/apis/polkadot_api.rs @@ -14,31 +14,31 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -//! Substrate-specific JSON-RPC methods. +//! Polkadot-specific JSON-RPC methods. use crate::*; use jsonrpsee::{core::RpcResult, proc_macros::rpc}; use sp_runtime::Weight; #[rpc(server, client)] -pub trait SubstrateRpc { +pub trait PolkadotRpc { /// Get the post dispatch weight for a given transaction hash. - #[method(name = "substrate_postDispatchWeight")] + #[method(name = "polkadot_postDispatchWeight")] async fn post_dispatch_weight(&self, transaction_hash: H256) -> RpcResult>; } -pub struct SubstrateRpcServerImpl { +pub struct PolkadotRpcServerImpl { client: client::Client, } -impl SubstrateRpcServerImpl { +impl PolkadotRpcServerImpl { pub fn new(client: client::Client) -> Self { Self { client } } } #[async_trait] -impl SubstrateRpcServer for SubstrateRpcServerImpl { +impl PolkadotRpcServer for PolkadotRpcServerImpl { async fn post_dispatch_weight(&self, transaction_hash: H256) -> RpcResult> { let weight = self.client.post_dispatch_weight(&transaction_hash).await; Ok(weight) diff --git a/substrate/frame/revive/rpc/src/block_info_provider.rs b/substrate/frame/revive/rpc/src/block_info_provider.rs index 5c0689b84a5d0..1755ce58a5829 100644 --- a/substrate/frame/revive/rpc/src/block_info_provider.rs +++ b/substrate/frame/revive/rpc/src/block_info_provider.rs @@ -40,7 +40,7 @@ pub trait BlockInfoProvider: Send + Sync { /// Return the latest block number async fn latest_block_number(&self) -> SubstrateBlockNumber { - return self.latest_block().await.number() + return self.latest_block().await.number(); } /// Get block by block_number. diff --git a/substrate/frame/revive/rpc/src/cli.rs b/substrate/frame/revive/rpc/src/cli.rs index e755f3378c1de..4607b6f14e1e2 100644 --- a/substrate/frame/revive/rpc/src/cli.rs +++ b/substrate/frame/revive/rpc/src/cli.rs @@ -17,8 +17,8 @@ //! The Ethereum JSON-RPC server. use crate::{ client::{connect, Client, SubscriptionType, SubstrateBlockNumber}, - DebugRpcServer, DebugRpcServerImpl, EthRpcServer, EthRpcServerImpl, ReceiptExtractor, - ReceiptProvider, SubstrateRpcServer, SubstrateRpcServerImpl, SubxtBlockInfoProvider, + DebugRpcServer, DebugRpcServerImpl, EthRpcServer, EthRpcServerImpl, PolkadotRpcServer, + PolkadotRpcServerImpl, ReceiptExtractor, ReceiptProvider, SubxtBlockInfoProvider, SystemHealthRpcServer, SystemHealthRpcServerImpl, LOG_TARGET, }; use clap::Parser; @@ -267,14 +267,14 @@ fn rpc_module(is_dev: bool, client: Client) -> Result, sc_service: let health_api = SystemHealthRpcServerImpl::new(client.clone()).into_rpc(); let debug_api = DebugRpcServerImpl::new(client.clone()).into_rpc(); - let substrate_api = SubstrateRpcServerImpl::new(client).into_rpc(); + let polkadot_api = PolkadotRpcServerImpl::new(client).into_rpc(); let mut module = RpcModule::new(()); module.merge(eth_api).map_err(|e| sc_service::Error::Application(e.into()))?; module.merge(health_api).map_err(|e| sc_service::Error::Application(e.into()))?; module.merge(debug_api).map_err(|e| sc_service::Error::Application(e.into()))?; module - .merge(substrate_api) + .merge(polkadot_api) .map_err(|e| sc_service::Error::Application(e.into()))?; Ok(module) } diff --git a/substrate/frame/revive/rpc/src/client.rs b/substrate/frame/revive/rpc/src/client.rs index 908adebd3e2a5..5c3ab3dc0380a 100644 --- a/substrate/frame/revive/rpc/src/client.rs +++ b/substrate/frame/revive/rpc/src/client.rs @@ -141,9 +141,10 @@ impl From for ErrorObjectOwned { match err { ClientError::SubxtError(subxt::Error::Rpc(subxt::error::RpcError::ClientError( subxt::ext::subxt_rpcs::Error::User(err), - ))) | - ClientError::RpcError(subxt::ext::subxt_rpcs::Error::User(err)) => - ErrorObjectOwned::owned::>(err.code, err.message, None), + ))) + | ClientError::RpcError(subxt::ext::subxt_rpcs::Error::User(err)) => { + ErrorObjectOwned::owned::>(err.code, err.message, None) + }, ClientError::TransactError(EthTransactError::Data(data)) => { let msg = match decode_revert_reason(&data) { Some(reason) => format!("execution reverted: {reason}"), @@ -153,10 +154,12 @@ impl From for ErrorObjectOwned { let data = format!("0x{}", hex::encode(data)); ErrorObjectOwned::owned::(REVERT_CODE, msg, Some(data)) }, - ClientError::TransactError(EthTransactError::Message(msg)) => - ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, msg, None), - _ => - ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, err.to_string(), None), + ClientError::TransactError(EthTransactError::Message(msg)) => { + ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, msg, None) + }, + _ => { + ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, err.to_string(), None) + }, } } } diff --git a/substrate/frame/revive/rpc/src/client/runtime_api.rs b/substrate/frame/revive/rpc/src/client/runtime_api.rs index 20a787c4d0479..e90cbc524c321 100644 --- a/substrate/frame/revive/rpc/src/client/runtime_api.rs +++ b/substrate/frame/revive/rpc/src/client/runtime_api.rs @@ -73,8 +73,9 @@ impl RuntimeApi { block: BlockNumberOrTagOrHash, ) -> Result, ClientError> { let timestamp_override = match block { - BlockNumberOrTagOrHash::BlockTag(BlockTag::Pending) => - Some(Timestamp::current().as_millis()), + BlockNumberOrTagOrHash::BlockTag(BlockTag::Pending) => { + Some(Timestamp::current().as_millis()) + }, _ => None, }; diff --git a/substrate/frame/revive/rpc/src/example.rs b/substrate/frame/revive/rpc/src/example.rs index dbe0dcf2d6332..7503d6f91d7e8 100644 --- a/substrate/frame/revive/rpc/src/example.rs +++ b/substrate/frame/revive/rpc/src/example.rs @@ -65,7 +65,7 @@ impl SubmittedTransaction { self.gas() > receipt.gas_used, "Gas used should be less than gas estimated." ); - return Ok(receipt) + return Ok(receipt); } else { anyhow::bail!("Transaction failed receipt: {receipt:?}") } diff --git a/substrate/frame/revive/rpc/src/fee_history_provider.rs b/substrate/frame/revive/rpc/src/fee_history_provider.rs index 3ed6f63bf7e69..b12f8e1e7df65 100644 --- a/substrate/frame/revive/rpc/src/fee_history_provider.rs +++ b/substrate/frame/revive/rpc/src/fee_history_provider.rs @@ -102,7 +102,7 @@ impl FeeHistoryProvider { base_fee_per_gas: vec![], gas_used_ratio: vec![], reward: vec![], - }) + }); }; let lowest = highest.saturating_sub(block_count.saturating_sub(1)).max(lowest_in_cache); diff --git a/substrate/frame/revive/rpc/src/lib.rs b/substrate/frame/revive/rpc/src/lib.rs index 5bfa00c57149c..b7f2dc3f2bec2 100644 --- a/substrate/frame/revive/rpc/src/lib.rs +++ b/substrate/frame/revive/rpc/src/lib.rs @@ -440,7 +440,7 @@ impl EthRpcServerImpl { ) .await else { - return Ok(None) + return Ok(None); }; let Some(signed_tx) = self.client.signed_tx_by_hash(&receipt.transaction_hash).await else { return Ok(None); diff --git a/substrate/frame/revive/rpc/src/receipt_provider.rs b/substrate/frame/revive/rpc/src/receipt_provider.rs index cacbf064e188f..dea20cf4f8614 100644 --- a/substrate/frame/revive/rpc/src/receipt_provider.rs +++ b/substrate/frame/revive/rpc/src/receipt_provider.rs @@ -225,8 +225,9 @@ impl ReceiptProvider { /// Check if the block is before the earliest block. pub fn is_before_earliest_block(&self, at: &BlockNumberOrTag) -> bool { match at { - BlockNumberOrTag::U256(block_number) => - self.receipt_extractor.is_before_earliest_block(block_number.as_u32()), + BlockNumberOrTag::U256(block_number) => { + self.receipt_extractor.is_before_earliest_block(block_number.as_u32()) + }, BlockNumberOrTag::BlockTag(_) => false, } } @@ -617,15 +618,17 @@ mod tests { async fn count(pool: &SqlitePool, table: &str, block_hash: Option) -> usize { let count: i64 = match block_hash { - None => + None => { sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {table}")) .fetch_one(pool) - .await, - Some(hash) => + .await + }, + Some(hash) => { sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {table} WHERE block_hash = ?")) .bind(hash.as_ref()) .fetch_one(pool) - .await, + .await + }, } .unwrap(); diff --git a/substrate/frame/revive/rpc/src/tests.rs b/substrate/frame/revive/rpc/src/tests.rs index 10fd42534e9e2..a205efaeacdc1 100644 --- a/substrate/frame/revive/rpc/src/tests.rs +++ b/substrate/frame/revive/rpc/src/tests.rs @@ -53,7 +53,7 @@ async fn ws_client_with_retry(url: &str) -> WsClient { tokio::time::timeout(timeout, async { loop { if let Ok(client) = WsClientBuilder::default().build(url).await { - return client + return client; } else { tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; } @@ -208,8 +208,8 @@ async fn submit_substrate_transactions( log::trace!(target: LOG_TARGET, "Substrate tx {i} submitted"); while let Some(status) = progress.next().await { match status { - Ok(TxStatus::InFinalizedBlock(block)) | - Ok(TxStatus::InBestBlock(block)) => { + Ok(TxStatus::InFinalizedBlock(block)) + | Ok(TxStatus::InBestBlock(block)) => { log::trace!(target: LOG_TARGET, "Substrate tx {i} included in block {:?}", block.block_hash() @@ -249,8 +249,9 @@ async fn verify_transactions_in_single_block( let block_tx_hashes = match &block.transactions { HashesOrTransactionInfos::Hashes(hashes) => hashes.clone(), - HashesOrTransactionInfos::TransactionInfos(infos) => - infos.iter().map(|info| info.hash).collect(), + HashesOrTransactionInfos::TransactionInfos(infos) => { + infos.iter().map(|info| info.hash).collect() + }, }; if let Some(missing_hash) = From 834ccfa5338cd4b70de40ab7c3856ceb46ac00c9 Mon Sep 17 00:00:00 2001 From: "cmd[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 15 Dec 2025 08:44:02 +0000 Subject: [PATCH 5/5] Update from github-actions[bot] running command 'fmt' --- substrate/frame/revive/rpc/src/client.rs | 17 +++++++---------- .../frame/revive/rpc/src/client/runtime_api.rs | 5 ++--- .../frame/revive/rpc/src/receipt_provider.rs | 15 ++++++--------- substrate/frame/revive/rpc/src/tests.rs | 9 ++++----- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/substrate/frame/revive/rpc/src/client.rs b/substrate/frame/revive/rpc/src/client.rs index 5c3ab3dc0380a..908adebd3e2a5 100644 --- a/substrate/frame/revive/rpc/src/client.rs +++ b/substrate/frame/revive/rpc/src/client.rs @@ -141,10 +141,9 @@ impl From for ErrorObjectOwned { match err { ClientError::SubxtError(subxt::Error::Rpc(subxt::error::RpcError::ClientError( subxt::ext::subxt_rpcs::Error::User(err), - ))) - | ClientError::RpcError(subxt::ext::subxt_rpcs::Error::User(err)) => { - ErrorObjectOwned::owned::>(err.code, err.message, None) - }, + ))) | + ClientError::RpcError(subxt::ext::subxt_rpcs::Error::User(err)) => + ErrorObjectOwned::owned::>(err.code, err.message, None), ClientError::TransactError(EthTransactError::Data(data)) => { let msg = match decode_revert_reason(&data) { Some(reason) => format!("execution reverted: {reason}"), @@ -154,12 +153,10 @@ impl From for ErrorObjectOwned { let data = format!("0x{}", hex::encode(data)); ErrorObjectOwned::owned::(REVERT_CODE, msg, Some(data)) }, - ClientError::TransactError(EthTransactError::Message(msg)) => { - ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, msg, None) - }, - _ => { - ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, err.to_string(), None) - }, + ClientError::TransactError(EthTransactError::Message(msg)) => + ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, msg, None), + _ => + ErrorObjectOwned::owned::(CALL_EXECUTION_FAILED_CODE, err.to_string(), None), } } } diff --git a/substrate/frame/revive/rpc/src/client/runtime_api.rs b/substrate/frame/revive/rpc/src/client/runtime_api.rs index e90cbc524c321..20a787c4d0479 100644 --- a/substrate/frame/revive/rpc/src/client/runtime_api.rs +++ b/substrate/frame/revive/rpc/src/client/runtime_api.rs @@ -73,9 +73,8 @@ impl RuntimeApi { block: BlockNumberOrTagOrHash, ) -> Result, ClientError> { let timestamp_override = match block { - BlockNumberOrTagOrHash::BlockTag(BlockTag::Pending) => { - Some(Timestamp::current().as_millis()) - }, + BlockNumberOrTagOrHash::BlockTag(BlockTag::Pending) => + Some(Timestamp::current().as_millis()), _ => None, }; diff --git a/substrate/frame/revive/rpc/src/receipt_provider.rs b/substrate/frame/revive/rpc/src/receipt_provider.rs index dea20cf4f8614..cacbf064e188f 100644 --- a/substrate/frame/revive/rpc/src/receipt_provider.rs +++ b/substrate/frame/revive/rpc/src/receipt_provider.rs @@ -225,9 +225,8 @@ impl ReceiptProvider { /// Check if the block is before the earliest block. pub fn is_before_earliest_block(&self, at: &BlockNumberOrTag) -> bool { match at { - BlockNumberOrTag::U256(block_number) => { - self.receipt_extractor.is_before_earliest_block(block_number.as_u32()) - }, + BlockNumberOrTag::U256(block_number) => + self.receipt_extractor.is_before_earliest_block(block_number.as_u32()), BlockNumberOrTag::BlockTag(_) => false, } } @@ -618,17 +617,15 @@ mod tests { async fn count(pool: &SqlitePool, table: &str, block_hash: Option) -> usize { let count: i64 = match block_hash { - None => { + None => sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {table}")) .fetch_one(pool) - .await - }, - Some(hash) => { + .await, + Some(hash) => sqlx::query_scalar(&format!("SELECT COUNT(*) FROM {table} WHERE block_hash = ?")) .bind(hash.as_ref()) .fetch_one(pool) - .await - }, + .await, } .unwrap(); diff --git a/substrate/frame/revive/rpc/src/tests.rs b/substrate/frame/revive/rpc/src/tests.rs index a205efaeacdc1..5a6c19c9239f6 100644 --- a/substrate/frame/revive/rpc/src/tests.rs +++ b/substrate/frame/revive/rpc/src/tests.rs @@ -208,8 +208,8 @@ async fn submit_substrate_transactions( log::trace!(target: LOG_TARGET, "Substrate tx {i} submitted"); while let Some(status) = progress.next().await { match status { - Ok(TxStatus::InFinalizedBlock(block)) - | Ok(TxStatus::InBestBlock(block)) => { + Ok(TxStatus::InFinalizedBlock(block)) | + Ok(TxStatus::InBestBlock(block)) => { log::trace!(target: LOG_TARGET, "Substrate tx {i} included in block {:?}", block.block_hash() @@ -249,9 +249,8 @@ async fn verify_transactions_in_single_block( let block_tx_hashes = match &block.transactions { HashesOrTransactionInfos::Hashes(hashes) => hashes.clone(), - HashesOrTransactionInfos::TransactionInfos(infos) => { - infos.iter().map(|info| info.hash).collect() - }, + HashesOrTransactionInfos::TransactionInfos(infos) => + infos.iter().map(|info| info.hash).collect(), }; if let Some(missing_hash) =