diff --git a/Cargo.lock b/Cargo.lock index c1eec3468..5b937788a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1143,6 +1143,37 @@ dependencies = [ "ethers-core", ] +[[package]] +name = "reth-rpc" +version = "0.1.0" +dependencies = [ + "reth-primitives", + "reth-rpc-api", + "reth-rpc-types", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "reth-rpc-api" +version = "0.1.0" +dependencies = [ + "jsonrpsee", + "reth-primitives", + "reth-rpc-types", +] + +[[package]] +name = "reth-rpc-types" +version = "0.1.0" +dependencies = [ + "fastrlp", + "reth-primitives", + "serde", + "serde_json", +] + [[package]] name = "reth-stages" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index d50aac83c..9ec2f7668 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ members = [ "crates/net/rpc-api", "crates/net/rpc-types", "crates/primitives", - "crates/net/p2p", "crates/stages" ] diff --git a/crates/net/rpc-api/src/eth.rs b/crates/net/rpc-api/src/eth.rs index b6397044a..d5fa2ba54 100644 --- a/crates/net/rpc-api/src/eth.rs +++ b/crates/net/rpc-api/src/eth.rs @@ -1,8 +1,14 @@ -use jsonrpsee::{core::RpcResult as Result, proc_macros::rpc}; -use reth_primitives::{Address, BlockNumber, Bytes, H256, H64, U256, U64}; +use jsonrpsee::{ + core::{RpcResult as Result, __reexports::serde_json}, + proc_macros::rpc, +}; +use reth_primitives::{ + transaction, transaction::eip2930::AccessListWithGasUsed, Address, BlockId, BlockNumber, Bytes, + H256, H64, U256, U64, +}; use reth_rpc_types::{ - CallRequest, FeeHistory, Index, RichBlock, SyncStatus, Transaction, TransactionReceipt, - TransactionRequest, Work, + CallRequest, EIP1186AccountProofResponse, FeeHistory, Index, RichBlock, SyncStatus, + Transaction, TransactionReceipt, TransactionRequest, Work, }; /// Eth rpc interface. @@ -97,7 +103,7 @@ pub trait EthApi { /// Returns balance of the given account. #[method(name = "eth_getBalance")] - fn balance(&self, address: Address, number: Option) -> Result; + fn balance(&self, address: Address, block_number: Option) -> Result; /// Returns content of the storage at given address. #[method(name = "eth_getStorageAt")] @@ -105,25 +111,46 @@ pub trait EthApi { &self, address: Address, index: U256, - number: Option, + block_number: Option, ) -> Result; /// Returns the number of transactions sent from given address at given time (block number). #[method(name = "eth_getTransactionCount")] - fn transaction_count(&self, address: Address, number: Option) -> Result; + fn transaction_count(&self, address: Address, block_number: Option) -> Result; /// Returns the code at given address at given time (block number). #[method(name = "eth_getCode")] - fn code_at(&self, address: Address, number: Option) -> Result; + fn code_at(&self, address: Address, block_number: Option) -> Result; /// Call contract, returning the output data. #[method(name = "eth_call")] - fn call(&self, request: CallRequest, number: Option) -> Result; + fn call(&self, request: CallRequest, block_number: Option) -> Result; + + /// This method creates an EIP2930 type accessList based on a given Transaction. The accessList + /// contains all storage slots and addresses read and written by the transaction, except for the + /// sender account and the precompiles. + /// + /// It returns list of addresses and storage keys used by the transaction, plus the gas + /// consumed when the access list is added. That is, it gives you the list of addresses and + /// storage keys that will be used by that transaction, plus the gas consumed if the access + /// list is included. Like eth_estimateGas, this is an estimation; the list could change + /// when the transaction is actually mined. Adding an accessList to your transaction does + /// not necessary result in lower gas usage compared to a transaction without an access + /// list. + #[method(name = "eth_createAccessList")] + async fn create_access_list( + &self, + request: CallRequest, + block_number: Option, + ) -> Result; /// Estimate gas needed for execution of given contract. #[method(name = "eth_estimateGas")] - async fn estimate_gas(&self, request: CallRequest, number: Option) - -> Result; + async fn estimate_gas( + &self, + request: CallRequest, + block_number: Option, + ) -> Result; /// Returns current gas_price. #[method(name = "eth_gasPrice")] @@ -171,4 +198,28 @@ pub trait EthApi { /// Sends signed transaction, returning its hash. #[method(name = "eth_sendRawTransaction")] async fn send_raw_transaction(&self, bytes: Bytes) -> Result; + + /// Returns an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + /// + len(message) + message))). + #[method(name = "eth_sign")] + async fn sign(&self, address: Address, message: Bytes) -> Result; + + /// Signs a transaction that can be submitted to the network at a later time using with + /// `eth_sendRawTransaction.` + #[method(name = "eth_signTransaction")] + async fn sign_transaction(&self, transaction: CallRequest) -> Result; + + /// Signs data via [EIP-712](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md). + #[method(name = "eth_signTypedData")] + async fn sign_typed_data(&self, address: Address, data: serde_json::Value) -> Result; + + /// Returns the account and storage values of the specified account including the Merkle-proof. + /// This call can be used to verify that the data you are pulling from is not tampered with. + #[method(name = "eth_getProof")] + async fn get_proof( + &self, + address: Address, + keys: Vec, + block_number: Option, + ) -> Result; }