diff --git a/prdoc/pr_10065.prdoc b/prdoc/pr_10065.prdoc new file mode 100644 index 0000000000000..26cb5b15717ad --- /dev/null +++ b/prdoc/pr_10065.prdoc @@ -0,0 +1,7 @@ +title: eth-rpc add trace logs +doc: +- audience: Runtime Dev + description: 'Add extra tracing logs for estimate_gas and send_raw_transaction' +crates: +- name: pallet-revive-eth-rpc + bump: patch diff --git a/substrate/frame/revive/rpc/src/client.rs b/substrate/frame/revive/rpc/src/client.rs index 57c304dbc743b..72bf4486f3f60 100644 --- a/substrate/frame/revive/rpc/src/client.rs +++ b/substrate/frame/revive/rpc/src/client.rs @@ -430,14 +430,14 @@ impl Client { pub async fn submit( &self, call: subxt::tx::DefaultPayload, - ) -> Result<(), ClientError> { + ) -> Result { let ext = self.api.tx().create_unsigned(&call).map_err(ClientError::from)?; let hash: H256 = self .rpc_client .request("author_submitExtrinsic", rpc_params![to_hex(ext.encoded())]) .await?; log::debug!(target: LOG_TARGET, "Submitted transaction with substrate hash: {hash:?}"); - Ok(()) + Ok(hash) } /// Get an EVM transaction receipt by hash. diff --git a/substrate/frame/revive/rpc/src/lib.rs b/substrate/frame/revive/rpc/src/lib.rs index bcb9e9b388b2e..a6f373d41be4d 100644 --- a/substrate/frame/revive/rpc/src/lib.rs +++ b/substrate/frame/revive/rpc/src/lib.rs @@ -145,9 +145,11 @@ impl EthRpcServer for EthRpcServerImpl { transaction: GenericTransaction, block: Option, ) -> RpcResult { + log::trace!(target: LOG_TARGET, "estimate_gas transaction={transaction:?} block={block:?}"); let hash = self.client.block_hash_for_tag(block.unwrap_or_default().into()).await?; let runtime_api = self.client.runtime_api(hash); let dry_run = runtime_api.dry_run(transaction).await?; + log::trace!(target: LOG_TARGET, "estimate_gas result={dry_run:?}"); Ok(dry_run.eth_gas) } @@ -164,18 +166,19 @@ impl EthRpcServer for EthRpcServerImpl { async fn send_raw_transaction(&self, transaction: Bytes) -> RpcResult { let hash = H256(keccak_256(&transaction.0)); + log::trace!(target: LOG_TARGET, "send_raw_transaction transaction: {transaction:?} ethereum_hash: {hash:?}"); let call = subxt_client::tx().revive().eth_transact(transaction.0); // Subscribe to new block only when automine is enabled. let receiver = self.client.tx_notifier().map(|sender| sender.subscribe()); // Submit the transaction - self.client.submit(call).await.map_err(|err| { - log::debug!(target: LOG_TARGET, "submit call failed: {err:?}"); + let substrate_hash = self.client.submit(call).await.map_err(|err| { + log::trace!(target: LOG_TARGET, "send_raw_transaction ethereum_hash: {hash:?} failed: {err:?}"); err })?; - log::debug!(target: LOG_TARGET, "send_raw_transaction with hash: {hash:?}"); + log::trace!(target: LOG_TARGET, "send_raw_transaction ethereum_hash: {hash:?} substrate_hash: {substrate_hash:?}"); // Wait for the transaction to be included in a block if automine is enabled if let Some(mut receiver) = receiver {