Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add txpool RPC and impl new_pending_transaction_filter #1073

Merged
merged 18 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use sp_core::hashing
  • Loading branch information
boundless-forest committed Jun 8, 2023
commit d300cb9a53f1b7a850d2fb9a9254256ce60aab18
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion client/rpc-core/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

//! tx pool rpc interface

use crate::types::*;
// crates.io
use ethereum_types::U256;
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
// frontier
use crate::types::*;

/// TxPool rpc interface
#[rpc(server)]
Expand Down
1 change: 0 additions & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ rand = "0.8"
rlp = { workspace = true }
scale-codec = { package = "parity-scale-codec", workspace = true }
serde = { workspace = true }
sha3 = { version = "0.10" }
tokio = { version = "1.24", features = ["sync"] }

# Substrate
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/src/txpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use ethereum::TransactionV2;
use ethereum_types::{H160, H256, U256};
use jsonrpsee::core::RpcResult;
use serde::Serialize;
use sha3::{Digest, Keccak256};
// frontier
use crate::{internal_err, public_key};
use fc_rpc_core::{
Expand All @@ -35,6 +34,7 @@ use sc_transaction_pool::{ChainApi, Pool};
use sc_transaction_pool_api::InPoolTransaction;
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use sp_core::hashing::keccak_256;
use sp_runtime::traits::Block as BlockT;

pub struct TxPool<B: BlockT, C, A: ChainApi> {
Expand Down Expand Up @@ -81,7 +81,7 @@ where
TransactionV2::EIP1559(t) => t.nonce,
};
let from_address = match public_key(txn) {
Ok(pk) => H160::from(H256::from_slice(Keccak256::digest(&pk).as_slice())),
Ok(pk) => H160::from(H256::from_slice(keccak_256(&pk).as_slice())),
Err(_e) => H160::default(),
};
pending
Expand All @@ -98,7 +98,7 @@ where
TransactionV2::EIP1559(t) => t.nonce,
};
let from_address = match public_key(txn) {
Ok(pk) => H160::from(H256::from_slice(Keccak256::digest(&pk).as_slice())),
Ok(pk) => H160::from(H256::from_slice(keccak_256(&pk).as_slice())),
Err(_e) => H160::default(),
};
queued
Expand Down
4 changes: 3 additions & 1 deletion template/node/src/rpc/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ where
A: ChainApi<Block = B> + 'static,
CT: ConvertTransaction<<B as BlockT>::Extrinsic> + Send + Sync + 'static,
{
#[cfg(feature = "txpool")]
use fc_rpc::TxPoolApiServer;
use fc_rpc::{
Eth, EthApiServer, EthDevSigner, EthFilter, EthFilterApiServer, EthPubSub,
EthPubSubApiServer, EthSigner, Net, NetApiServer, TxPoolApiServer, Web3, Web3ApiServer,
EthPubSubApiServer, EthSigner, Net, NetApiServer, Web3, Web3ApiServer,
};

let EthDeps {
Expand Down