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

DO NOT MERGE migrate codebase to jsonrpsee #534

Closed
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
1,983 changes: 926 additions & 1,057 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions client/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ repository = "https:/paritytech/frontier/"

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", features = ["derive"] }
sp-core = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-blockchain = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-runtime = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sc-client-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-block-builder = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-inherents = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-core = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-blockchain = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-runtime = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sc-client-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-block-builder = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-inherents = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
fp-consensus = { version = "2.0.0-dev", path = "../../primitives/consensus" }
fp-rpc = { version = "3.0.0-dev", path = "../../primitives/rpc" }
fc-db = { version = "2.0.0-dev", path = "../db" }
sp-consensus = { version = "0.10.0-dev", git = "https:/paritytech/substrate" }
sc-consensus = { version = "0.10.0-dev", git = "https:/paritytech/substrate" }
sp-consensus = { version = "0.10.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sc-consensus = { version = "0.10.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
log = "0.4.8"
futures = { version = "0.3.17", features = ["compat"] }
sp-timestamp = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-timestamp = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
derive_more = "0.99.2"
prometheus-endpoint = { version = "0.9.0", package = "substrate-prometheus-endpoint", git = "https:/paritytech/substrate" }
prometheus-endpoint = { version = "0.10.0-dev", package = "substrate-prometheus-endpoint", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
async-trait = "0.1"
6 changes: 3 additions & 3 deletions client/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use sc_client_api::{self, backend::AuxStore, BlockOf};
use sc_consensus::{BlockCheckParams, BlockImport, BlockImportParams, ImportResult};
use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend, ProvideCache};
use sp_blockchain::{well_known_cache_keys::Id as CacheKeyId, HeaderBackend};
use sp_consensus::Error as ConsensusError;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
use std::{collections::HashMap, marker::PhantomData, sync::Arc};
Expand Down Expand Up @@ -82,7 +82,7 @@ where
B: BlockT,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
I::Error: Into<ConsensusError>,
C: ProvideRuntimeApi<B> + Send + Sync + HeaderBackend<B> + AuxStore + ProvideCache<B> + BlockOf,
C: ProvideRuntimeApi<B> + Send + Sync + HeaderBackend<B> + AuxStore + BlockOf,
C::Api: EthereumRuntimeRPCApi<B>,
C::Api: BlockBuilderApi<B>,
{
Expand All @@ -102,7 +102,7 @@ where
B: BlockT,
I: BlockImport<B, Transaction = sp_api::TransactionFor<C, B>> + Send + Sync,
I::Error: Into<ConsensusError>,
C: ProvideRuntimeApi<B> + Send + Sync + HeaderBackend<B> + AuxStore + ProvideCache<B> + BlockOf,
C: ProvideRuntimeApi<B> + Send + Sync + HeaderBackend<B> + AuxStore + BlockOf,
C::Api: EthereumRuntimeRPCApi<B>,
C::Api: BlockBuilderApi<B>,
{
Expand Down
6 changes: 3 additions & 3 deletions client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
repository = "https:/paritytech/frontier/"

[dependencies]
sp-core = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-database = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-runtime = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-core = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-database = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-runtime = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
pallet-ethereum = { version = "4.0.0-dev", path = "../../frame/ethereum" }
fp-storage = { version = "2.0.0-dev", path = "../../primitives/storage"}
kvdb = "0.10.0"
Expand Down
8 changes: 4 additions & 4 deletions client/mapping-sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ description = "Mapping sync logic for Frontier."
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
sp-runtime = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-blockchain = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sc-client-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate" }
sp-runtime = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-blockchain = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sc-client-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
sp-api = { version = "4.0.0-dev", git = "https:/paritytech/substrate", branch = "polkadot-jsonrpsee-v0.9.13" }
fp-consensus = { version = "2.0.0-dev", path = "../../primitives/consensus" }
fc-consensus = { version = "2.0.0-dev", path = "../consensus" }
fc-db = { version = "2.0.0-dev", path = "../db" }
Expand Down
5 changes: 1 addition & 4 deletions client/rpc-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ description = "RPC traits of Ethereum."
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
jsonrpc-core = "18.0"
jsonrpc-core-client = "18.0"
jsonrpc-derive = "18.0"
jsonrpc-pubsub = "18.0"
jsonrpsee = { version = "0.6.0", features = ["server", "macros"] }
rustc-hex = "2.1.0"
ethereum = { version = "0.10.0", features = ["with-codec"] }
sha3 = "0.8"
Expand Down
190 changes: 103 additions & 87 deletions client/rpc-core/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,188 +19,204 @@
//! Eth rpc interface.

use ethereum_types::{H160, H256, H64, U256, U64};
use jsonrpc_core::{BoxFuture, Result};
use jsonrpc_derive::rpc;
use jsonrpsee::{proc_macros::rpc, types::RpcResult};

use crate::types::{
BlockNumber, Bytes, CallRequest, Filter, FilterChanges, Index, Log, Receipt, RichBlock,
SyncStatus, Transaction, TransactionRequest, Work,
};
pub use rpc_impl_EthApi::gen_server::EthApi as EthApiServer;
pub use rpc_impl_EthFilterApi::gen_server::EthFilterApi as EthFilterApiServer;

/// Eth rpc interface.
#[rpc(server)]
pub trait EthApi {
/// Returns protocol version encoded as a string (quotes are necessary).
#[rpc(name = "eth_protocolVersion")]
fn protocol_version(&self) -> Result<u64>;
#[method(name = "eth_protocolVersion")]
fn protocol_version(&self) -> RpcResult<u64>;

/// Returns an object with data about the sync status or false. (wtf?)
#[rpc(name = "eth_syncing")]
fn syncing(&self) -> Result<SyncStatus>;
#[method(name = "eth_syncing")]
fn syncing(&self) -> RpcResult<SyncStatus>;

/// Returns the number of hashes per second that the node is mining with.
#[rpc(name = "eth_hashrate")]
fn hashrate(&self) -> Result<U256>;
#[method(name = "eth_hashrate")]
fn hashrate(&self) -> RpcResult<U256>;

/// Returns block author.
#[rpc(name = "eth_coinbase")]
fn author(&self) -> Result<H160>;
#[method(name = "eth_coinbase")]
fn author(&self) -> RpcResult<H160>;

/// Returns true if client is actively mining new blocks.
#[rpc(name = "eth_mining")]
fn is_mining(&self) -> Result<bool>;
#[method(name = "eth_mining")]
fn is_mining(&self) -> RpcResult<bool>;

/// Returns the chain ID used for transaction signing at the
/// current best block. None is returned if not
/// available.
#[rpc(name = "eth_chainId")]
fn chain_id(&self) -> Result<Option<U64>>;
#[method(name = "eth_chainId")]
fn chain_id(&self) -> RpcResult<Option<U64>>;

/// Returns current gas_price.
#[rpc(name = "eth_gasPrice")]
fn gas_price(&self) -> Result<U256>;
#[method(name = "eth_gasPrice")]
fn gas_price(&self) -> RpcResult<U256>;

/// Returns accounts list.
#[rpc(name = "eth_accounts")]
fn accounts(&self) -> Result<Vec<H160>>;
#[method(name = "eth_accounts")]
fn accounts(&self) -> RpcResult<Vec<H160>>;

/// Returns highest block number.
#[rpc(name = "eth_blockNumber")]
fn block_number(&self) -> Result<U256>;
#[method(name = "eth_blockNumber")]
fn block_number(&self) -> RpcResult<U256>;

/// Returns balance of the given account.
#[rpc(name = "eth_getBalance")]
fn balance(&self, _: H160, _: Option<BlockNumber>) -> Result<U256>;
#[method(name = "eth_getBalance")]
fn balance(&self, address: H160, block_number: Option<BlockNumber>) -> RpcResult<U256>;

/// Returns content of the storage at given address.
#[rpc(name = "eth_getStorageAt")]
fn storage_at(&self, _: H160, _: U256, _: Option<BlockNumber>) -> Result<H256>;
#[method(name = "eth_getStorageAt")]
fn storage_at(
&self,
address: H160,
key: U256,
block_number: Option<BlockNumber>,
) -> RpcResult<H256>;

/// Returns block with given hash.
#[rpc(name = "eth_getBlockByHash")]
fn block_by_hash(&self, _: H256, _: bool) -> Result<Option<RichBlock>>;
#[method(name = "eth_getBlockByHash")]
fn block_by_hash(&self, hash: H256, b: bool) -> RpcResult<Option<RichBlock>>;

/// Returns block with given number.
#[rpc(name = "eth_getBlockByNumber")]
fn block_by_number(&self, _: BlockNumber, _: bool) -> Result<Option<RichBlock>>;
#[method(name = "eth_getBlockByNumber")]
fn block_by_number(&self, block_number: BlockNumber, b: bool) -> RpcResult<Option<RichBlock>>;

/// Returns the number of transactions sent from given address at given time (block number).
#[rpc(name = "eth_getTransactionCount")]
fn transaction_count(&self, _: H160, _: Option<BlockNumber>) -> Result<U256>;
#[method(name = "eth_getTransactionCount")]
fn transaction_count(
&self,
address: H160,
block_number: Option<BlockNumber>,
) -> RpcResult<U256>;

/// Returns the number of transactions in a block with given hash.
#[rpc(name = "eth_getBlockTransactionCountByHash")]
fn block_transaction_count_by_hash(&self, _: H256) -> Result<Option<U256>>;
#[method(name = "eth_getBlockTransactionCountByHash")]
fn block_transaction_count_by_hash(&self, hash: H256) -> RpcResult<Option<U256>>;

/// Returns the number of transactions in a block with given block number.
#[rpc(name = "eth_getBlockTransactionCountByNumber")]
fn block_transaction_count_by_number(&self, _: BlockNumber) -> Result<Option<U256>>;
#[method(name = "eth_getBlockTransactionCountByNumber")]
fn block_transaction_count_by_number(
&self,
block_number: BlockNumber,
) -> RpcResult<Option<U256>>;

/// Returns the number of uncles in a block with given hash.
#[rpc(name = "eth_getUncleCountByBlockHash")]
fn block_uncles_count_by_hash(&self, _: H256) -> Result<U256>;
#[method(name = "eth_getUncleCountByBlockHash")]
fn block_uncles_count_by_hash(&self, hash: H256) -> RpcResult<U256>;

/// Returns the number of uncles in a block with given block number.
#[rpc(name = "eth_getUncleCountByBlockNumber")]
fn block_uncles_count_by_number(&self, _: BlockNumber) -> Result<U256>;
#[method(name = "eth_getUncleCountByBlockNumber")]
fn block_uncles_count_by_number(&self, block_number: BlockNumber) -> RpcResult<U256>;

/// Returns the code at given address at given time (block number).
#[rpc(name = "eth_getCode")]
fn code_at(&self, _: H160, _: Option<BlockNumber>) -> Result<Bytes>;
#[method(name = "eth_getCode")]
fn code_at(&self, address: H160, block_number: Option<BlockNumber>) -> RpcResult<Bytes>;

/// Sends transaction; will block waiting for signer to return the
/// transaction hash.
#[rpc(name = "eth_sendTransaction")]
fn send_transaction(&self, _: TransactionRequest) -> BoxFuture<Result<H256>>;
#[method(name = "eth_sendTransaction")]
async fn send_transaction(&self, tx: TransactionRequest) -> RpcResult<H256>;

/// Sends signed transaction, returning its hash.
#[rpc(name = "eth_sendRawTransaction")]
fn send_raw_transaction(&self, _: Bytes) -> BoxFuture<Result<H256>>;
#[method(name = "eth_sendRawTransaction")]
async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<H256>;

/// Call contract, returning the output data.
#[rpc(name = "eth_call")]
fn call(&self, _: CallRequest, _: Option<BlockNumber>) -> Result<Bytes>;
#[method(name = "eth_call")]
fn call(&self, req: CallRequest, block_number: Option<BlockNumber>) -> RpcResult<Bytes>;

/// Estimate gas needed for execution of given contract.
#[rpc(name = "eth_estimateGas")]
fn estimate_gas(&self, _: CallRequest, _: Option<BlockNumber>) -> Result<U256>;
#[method(name = "eth_estimateGas")]
fn estimate_gas(&self, req: CallRequest, block_number: Option<BlockNumber>) -> RpcResult<U256>;

/// Get transaction by its hash.
#[rpc(name = "eth_getTransactionByHash")]
fn transaction_by_hash(&self, _: H256) -> Result<Option<Transaction>>;
#[method(name = "eth_getTransactionByHash")]
fn transaction_by_hash(&self, hash: H256) -> RpcResult<Option<Transaction>>;

/// Returns transaction at given block hash and index.
#[rpc(name = "eth_getTransactionByBlockHashAndIndex")]
fn transaction_by_block_hash_and_index(&self, _: H256, _: Index)
-> Result<Option<Transaction>>;
#[method(name = "eth_getTransactionByBlockHashAndIndex")]
fn transaction_by_block_hash_and_index(
&self,
hash: H256,
index: Index,
) -> RpcResult<Option<Transaction>>;

/// Returns transaction by given block number and index.
#[rpc(name = "eth_getTransactionByBlockNumberAndIndex")]
#[method(name = "eth_getTransactionByBlockNumberAndIndex")]
fn transaction_by_block_number_and_index(
&self,
_: BlockNumber,
_: Index,
) -> Result<Option<Transaction>>;
block_number: BlockNumber,
index: Index,
) -> RpcResult<Option<Transaction>>;

/// Returns transaction receipt by transaction hash.
#[rpc(name = "eth_getTransactionReceipt")]
fn transaction_receipt(&self, _: H256) -> Result<Option<Receipt>>;
#[method(name = "eth_getTransactionReceipt")]
fn transaction_receipt(&self, hash: H256) -> RpcResult<Option<Receipt>>;

/// Returns an uncles at given block and index.
#[rpc(name = "eth_getUncleByBlockHashAndIndex")]
fn uncle_by_block_hash_and_index(&self, _: H256, _: Index) -> Result<Option<RichBlock>>;
#[method(name = "eth_getUncleByBlockHashAndIndex")]
fn uncle_by_block_hash_and_index(
&self,
hash: H256,
index: Index,
) -> RpcResult<Option<RichBlock>>;

/// Returns an uncles at given block and index.
#[rpc(name = "eth_getUncleByBlockNumberAndIndex")]
#[method(name = "eth_getUncleByBlockNumberAndIndex")]
fn uncle_by_block_number_and_index(
&self,
_: BlockNumber,
_: Index,
) -> Result<Option<RichBlock>>;
block_number: BlockNumber,
index: Index,
) -> RpcResult<Option<RichBlock>>;

/// Returns logs matching given filter object.
#[rpc(name = "eth_getLogs")]
fn logs(&self, _: Filter) -> Result<Vec<Log>>;
#[method(name = "eth_getLogs")]
fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;

/// Returns the hash of the current block, the seedHash, and the boundary condition to be met.
#[rpc(name = "eth_getWork")]
fn work(&self) -> Result<Work>;
#[method(name = "eth_getWork")]
fn work(&self) -> RpcResult<Work>;

/// Used for submitting a proof-of-work solution.
#[rpc(name = "eth_submitWork")]
fn submit_work(&self, _: H64, _: H256, _: H256) -> Result<bool>;
#[method(name = "eth_submitWork")]
fn submit_work(&self, h64: H64, hash: H256, hash2: H256) -> RpcResult<bool>;

/// Used for submitting mining hashrate.
#[rpc(name = "eth_submitHashrate")]
fn submit_hashrate(&self, _: U256, _: H256) -> Result<bool>;
#[method(name = "eth_submitHashrate")]
fn submit_hashrate(&self, u256: U256, hash: H256) -> RpcResult<bool>;
}

/// Eth filters rpc api (polling).
#[rpc(server)]
pub trait EthFilterApi {
/// Returns id of new filter.
#[rpc(name = "eth_newFilter")]
fn new_filter(&self, _: Filter) -> Result<U256>;
#[method(name = "eth_newFilter")]
fn new_filter(&self, filter: Filter) -> RpcResult<U256>;

/// Returns id of new block filter.
#[rpc(name = "eth_newBlockFilter")]
fn new_block_filter(&self) -> Result<U256>;
#[method(name = "eth_newBlockFilter")]
fn new_block_filter(&self) -> RpcResult<U256>;

/// Returns id of new block filter.
#[rpc(name = "eth_newPendingTransactionFilter")]
fn new_pending_transaction_filter(&self) -> Result<U256>;
#[method(name = "eth_newPendingTransactionFilter")]
fn new_pending_transaction_filter(&self) -> RpcResult<U256>;

/// Returns filter changes since last poll.
#[rpc(name = "eth_getFilterChanges")]
fn filter_changes(&self, _: Index) -> Result<FilterChanges>;
#[method(name = "eth_getFilterChanges")]
fn filter_changes(&self, index: Index) -> RpcResult<FilterChanges>;

/// Returns all logs matching given filter (in a range 'from' - 'to').
#[rpc(name = "eth_getFilterLogs")]
fn filter_logs(&self, _: Index) -> Result<Vec<Log>>;
#[method(name = "eth_getFilterLogs")]
fn filter_logs(&self, index: Index) -> RpcResult<Vec<Log>>;

/// Uninstalls filter.
#[rpc(name = "eth_uninstallFilter")]
fn uninstall_filter(&self, _: Index) -> Result<bool>;
#[method(name = "eth_uninstallFilter")]
fn uninstall_filter(&self, index: Index) -> RpcResult<bool>;
}
Loading