From ae262b6d5a4d9393aeb6525647e7e63e36104de8 Mon Sep 17 00:00:00 2001 From: sprites0 <199826320+sprites0@users.noreply.github.com> Date: Wed, 26 Feb 2025 02:44:41 +0000 Subject: [PATCH] Make node read-only Transactions should be sent to official rpc; mark it as read only and check if we can proxy the requests later --- crates/rpc/rpc-eth-api/src/core.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/crates/rpc/rpc-eth-api/src/core.rs b/crates/rpc/rpc-eth-api/src/core.rs index c103835a8..bd7b21280 100644 --- a/crates/rpc/rpc-eth-api/src/core.rs +++ b/crates/rpc/rpc-eth-api/src/core.rs @@ -769,33 +769,28 @@ where } /// Handler for: `eth_sendTransaction` - async fn send_transaction(&self, request: TransactionRequest) -> RpcResult { - trace!(target: "rpc::eth", ?request, "Serving eth_sendTransaction"); - Ok(EthTransactions::send_transaction(self, request).await?) + async fn send_transaction(&self, _request: TransactionRequest) -> RpcResult { + Err(internal_rpc_err("The node is read-only")) } /// Handler for: `eth_sendRawTransaction` - async fn send_raw_transaction(&self, tx: Bytes) -> RpcResult { - trace!(target: "rpc::eth", ?tx, "Serving eth_sendRawTransaction"); - Ok(EthTransactions::send_raw_transaction(self, tx).await?) + async fn send_raw_transaction(&self, _tx: Bytes) -> RpcResult { + Err(internal_rpc_err("The node is read-only")) } /// Handler for: `eth_sign` - async fn sign(&self, address: Address, message: Bytes) -> RpcResult { - trace!(target: "rpc::eth", ?address, ?message, "Serving eth_sign"); - Ok(EthTransactions::sign(self, address, message).await?) + async fn sign(&self, _address: Address, _message: Bytes) -> RpcResult { + Err(internal_rpc_err("The node is read-only")) } /// Handler for: `eth_signTransaction` - async fn sign_transaction(&self, request: TransactionRequest) -> RpcResult { - trace!(target: "rpc::eth", ?request, "Serving eth_signTransaction"); - Ok(EthTransactions::sign_transaction(self, request).await?) + async fn sign_transaction(&self, _request: TransactionRequest) -> RpcResult { + Err(internal_rpc_err("The node is read-only")) } /// Handler for: `eth_signTypedData` - async fn sign_typed_data(&self, address: Address, data: TypedData) -> RpcResult { - trace!(target: "rpc::eth", ?address, ?data, "Serving eth_signTypedData"); - Ok(EthTransactions::sign_typed_data(self, &data, address)?) + async fn sign_typed_data(&self, _address: Address, _data: TypedData) -> RpcResult { + Err(internal_rpc_err("The node is read-only")) } /// Handler for: `eth_getProof`