Skip to content

Commit 0e3195d

Browse files
[pallet-revive] fix subxt submit & add debug statments (#10016)
- Fix subxt submit by default it's using `author_submitAndWatchExtrinsic` even though we just want to fire and forget - Add debug instructions to log the signer & nonce of new eth transactions when the node validate the transaction --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 1594cbd commit 0e3195d

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

prdoc/pr_10016.prdoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title: '[pallet-revive] fix subxt submit & add debug statments'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
- Fix subxt submit by default it's using `author_submitAndWatchExtrinsic` even though we just want to fire and forget
6+
- Add debug instructions to log the signer & nonce of new eth transactions when the node validate the transaction
7+
crates:
8+
- name: pallet-revive-eth-rpc
9+
bump: patch
10+
- name: pallet-revive
11+
bump: patch

substrate/frame/revive/rpc/src/client.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,14 @@ impl Client {
430430
pub async fn submit(
431431
&self,
432432
call: subxt::tx::DefaultPayload<EthTransact>,
433-
) -> Result<H256, ClientError> {
433+
) -> Result<(), ClientError> {
434434
let ext = self.api.tx().create_unsigned(&call).map_err(ClientError::from)?;
435-
let hash = ext.submit().await?;
436-
Ok(hash)
435+
let hash: H256 = self
436+
.rpc_client
437+
.request("author_submitExtrinsic", rpc_params![to_hex(ext.encoded())])
438+
.await?;
439+
log::debug!(target: LOG_TARGET, "Submitted transaction with substrate hash: {hash:?}");
440+
Ok(())
437441
}
438442

439443
/// Get an EVM transaction receipt by hash.
@@ -749,3 +753,7 @@ impl Client {
749753
get_automine(&self.rpc_client).await
750754
}
751755
}
756+
757+
fn to_hex(bytes: impl AsRef<[u8]>) -> String {
758+
format!("0x{}", hex::encode(bytes.as_ref()))
759+
}

substrate/frame/revive/rpc/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ impl EthRpcServer for EthRpcServerImpl {
175175
err
176176
})?;
177177

178+
log::debug!(target: LOG_TARGET, "send_raw_transaction with hash: {hash:?}");
179+
178180
// Wait for the transaction to be included in a block if automine is enabled
179181
if let Some(mut receiver) = receiver {
180182
if let Err(err) = tokio::time::timeout(Duration::from_millis(500), async {

substrate/frame/revive/src/evm/runtime.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ pub trait EthExtra {
299299
log::debug!(target: LOG_TARGET, "Failed to convert nonce");
300300
InvalidTransaction::Call
301301
})?;
302+
303+
log::debug!(target: LOG_TARGET, "Decoded Ethereum transaction with signer: {signer_addr:?} nonce: {nonce:?}");
302304
let call_info = create_call::<Self::Config>(tx, Some(encoded_len as u32))?;
303305
let storage_credit = <Self::Config as Config>::Currency::withdraw(
304306
&signer,

0 commit comments

Comments
 (0)