Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions prdoc/pr_10065.prdoc
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions substrate/frame/revive/rpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,14 @@ impl Client {
pub async fn submit(
&self,
call: subxt::tx::DefaultPayload<EthTransact>,
) -> Result<(), ClientError> {
) -> Result<H256, ClientError> {
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.
Expand Down
9 changes: 6 additions & 3 deletions substrate/frame/revive/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ impl EthRpcServer for EthRpcServerImpl {
transaction: GenericTransaction,
block: Option<BlockNumberOrTag>,
) -> RpcResult<U256> {
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)
}

Expand All @@ -164,18 +166,19 @@ impl EthRpcServer for EthRpcServerImpl {

async fn send_raw_transaction(&self, transaction: Bytes) -> RpcResult<H256> {
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 {
Expand Down
Loading