1use alloy_dyn_abi::TypedData;
4use alloy_eips::{eip2930::AccessListResult, BlockId, BlockNumberOrTag};
5use alloy_json_rpc::RpcObject;
6use alloy_primitives::{Address, Bytes, B256, B64, U256, U64};
7use alloy_rpc_types_eth::{
8 simulate::{SimulatePayload, SimulatedBlock},
9 state::{EvmOverrides, StateOverride},
10 transaction::TransactionRequest,
11 BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Index,
12 StateContext, SyncStatus, Work,
13};
14use alloy_serde::JsonStorageKey;
15use jsonrpsee::{core::RpcResult, proc_macros::rpc};
16use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult};
17use tracing::trace;
18
19use crate::{
20 helpers::{EthApiSpec, EthBlocks, EthCall, EthFees, EthState, EthTransactions, FullEthApi},
21 RpcBlock, RpcHeader, RpcReceipt, RpcTransaction,
22};
23
24pub trait FullEthApiServer:
27 EthApiServer<
28 RpcTransaction<Self::NetworkTypes>,
29 RpcBlock<Self::NetworkTypes>,
30 RpcReceipt<Self::NetworkTypes>,
31 RpcHeader<Self::NetworkTypes>,
32 > + FullEthApi
33 + Clone
34{
35}
36
37impl<T> FullEthApiServer for T where
38 T: EthApiServer<
39 RpcTransaction<T::NetworkTypes>,
40 RpcBlock<T::NetworkTypes>,
41 RpcReceipt<T::NetworkTypes>,
42 RpcHeader<T::NetworkTypes>,
43 > + FullEthApi
44 + Clone
45{
46}
47
48#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
50#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
51pub trait EthApi<T: RpcObject, B: RpcObject, R: RpcObject, H: RpcObject> {
52 #[method(name = "protocolVersion")]
54 async fn protocol_version(&self) -> RpcResult<U64>;
55
56 #[method(name = "syncing")]
58 fn syncing(&self) -> RpcResult<SyncStatus>;
59
60 #[method(name = "coinbase")]
62 async fn author(&self) -> RpcResult<Address>;
63
64 #[method(name = "accounts")]
66 fn accounts(&self) -> RpcResult<Vec<Address>>;
67
68 #[method(name = "blockNumber")]
70 fn block_number(&self) -> RpcResult<U256>;
71
72 #[method(name = "chainId")]
74 async fn chain_id(&self) -> RpcResult<Option<U64>>;
75
76 #[method(name = "getBlockByHash")]
78 async fn block_by_hash(&self, hash: B256, full: bool) -> RpcResult<Option<B>>;
79
80 #[method(name = "getBlockByNumber")]
82 async fn block_by_number(&self, number: BlockNumberOrTag, full: bool) -> RpcResult<Option<B>>;
83
84 #[method(name = "getBlockTransactionCountByHash")]
86 async fn block_transaction_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>>;
87
88 #[method(name = "getBlockTransactionCountByNumber")]
90 async fn block_transaction_count_by_number(
91 &self,
92 number: BlockNumberOrTag,
93 ) -> RpcResult<Option<U256>>;
94
95 #[method(name = "getUncleCountByBlockHash")]
97 async fn block_uncles_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>>;
98
99 #[method(name = "getUncleCountByBlockNumber")]
101 async fn block_uncles_count_by_number(
102 &self,
103 number: BlockNumberOrTag,
104 ) -> RpcResult<Option<U256>>;
105
106 #[method(name = "getBlockReceipts")]
108 async fn block_receipts(&self, block_id: BlockId) -> RpcResult<Option<Vec<R>>>;
109
110 #[method(name = "getUncleByBlockHashAndIndex")]
112 async fn uncle_by_block_hash_and_index(&self, hash: B256, index: Index)
113 -> RpcResult<Option<B>>;
114
115 #[method(name = "getUncleByBlockNumberAndIndex")]
117 async fn uncle_by_block_number_and_index(
118 &self,
119 number: BlockNumberOrTag,
120 index: Index,
121 ) -> RpcResult<Option<B>>;
122
123 #[method(name = "getRawTransactionByHash")]
127 async fn raw_transaction_by_hash(&self, hash: B256) -> RpcResult<Option<Bytes>>;
128
129 #[method(name = "getTransactionByHash")]
131 async fn transaction_by_hash(&self, hash: B256) -> RpcResult<Option<T>>;
132
133 #[method(name = "getRawTransactionByBlockHashAndIndex")]
135 async fn raw_transaction_by_block_hash_and_index(
136 &self,
137 hash: B256,
138 index: Index,
139 ) -> RpcResult<Option<Bytes>>;
140
141 #[method(name = "getTransactionByBlockHashAndIndex")]
143 async fn transaction_by_block_hash_and_index(
144 &self,
145 hash: B256,
146 index: Index,
147 ) -> RpcResult<Option<T>>;
148
149 #[method(name = "getRawTransactionByBlockNumberAndIndex")]
152 async fn raw_transaction_by_block_number_and_index(
153 &self,
154 number: BlockNumberOrTag,
155 index: Index,
156 ) -> RpcResult<Option<Bytes>>;
157
158 #[method(name = "getTransactionByBlockNumberAndIndex")]
160 async fn transaction_by_block_number_and_index(
161 &self,
162 number: BlockNumberOrTag,
163 index: Index,
164 ) -> RpcResult<Option<T>>;
165
166 #[method(name = "getTransactionBySenderAndNonce")]
168 async fn transaction_by_sender_and_nonce(
169 &self,
170 address: Address,
171 nonce: U64,
172 ) -> RpcResult<Option<T>>;
173
174 #[method(name = "getTransactionReceipt")]
176 async fn transaction_receipt(&self, hash: B256) -> RpcResult<Option<R>>;
177
178 #[method(name = "getBalance")]
180 async fn balance(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<U256>;
181
182 #[method(name = "getStorageAt")]
184 async fn storage_at(
185 &self,
186 address: Address,
187 index: JsonStorageKey,
188 block_number: Option<BlockId>,
189 ) -> RpcResult<B256>;
190
191 #[method(name = "getTransactionCount")]
193 async fn transaction_count(
194 &self,
195 address: Address,
196 block_number: Option<BlockId>,
197 ) -> RpcResult<U256>;
198
199 #[method(name = "getCode")]
201 async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<Bytes>;
202
203 #[method(name = "getHeaderByNumber")]
205 async fn header_by_number(&self, hash: BlockNumberOrTag) -> RpcResult<Option<H>>;
206
207 #[method(name = "getHeaderByHash")]
209 async fn header_by_hash(&self, hash: B256) -> RpcResult<Option<H>>;
210
211 #[method(name = "simulateV1")]
214 async fn simulate_v1(
215 &self,
216 opts: SimulatePayload,
217 block_number: Option<BlockId>,
218 ) -> RpcResult<Vec<SimulatedBlock<B>>>;
219
220 #[method(name = "call")]
222 async fn call(
223 &self,
224 request: TransactionRequest,
225 block_number: Option<BlockId>,
226 state_overrides: Option<StateOverride>,
227 block_overrides: Option<Box<BlockOverrides>>,
228 ) -> RpcResult<Bytes>;
229
230 #[method(name = "callMany")]
233 async fn call_many(
234 &self,
235 bundles: Vec<Bundle>,
236 state_context: Option<StateContext>,
237 state_override: Option<StateOverride>,
238 ) -> RpcResult<Vec<Vec<EthCallResponse>>>;
239
240 #[method(name = "createAccessList")]
255 async fn create_access_list(
256 &self,
257 request: TransactionRequest,
258 block_number: Option<BlockId>,
259 state_override: Option<StateOverride>,
260 ) -> RpcResult<AccessListResult>;
261
262 #[method(name = "estimateGas")]
265 async fn estimate_gas(
266 &self,
267 request: TransactionRequest,
268 block_number: Option<BlockId>,
269 state_override: Option<StateOverride>,
270 ) -> RpcResult<U256>;
271
272 #[method(name = "gasPrice")]
274 async fn gas_price(&self) -> RpcResult<U256>;
275
276 #[method(name = "getAccount")]
278 async fn get_account(
279 &self,
280 address: Address,
281 block: BlockId,
282 ) -> RpcResult<Option<alloy_rpc_types_eth::Account>>;
283
284 #[method(name = "maxPriorityFeePerGas")]
286 async fn max_priority_fee_per_gas(&self) -> RpcResult<U256>;
287
288 #[method(name = "blobBaseFee")]
290 async fn blob_base_fee(&self) -> RpcResult<U256>;
291
292 #[method(name = "feeHistory")]
300 async fn fee_history(
301 &self,
302 block_count: U64,
303 newest_block: BlockNumberOrTag,
304 reward_percentiles: Option<Vec<f64>>,
305 ) -> RpcResult<FeeHistory>;
306
307 #[method(name = "mining")]
309 async fn is_mining(&self) -> RpcResult<bool>;
310
311 #[method(name = "hashrate")]
313 async fn hashrate(&self) -> RpcResult<U256>;
314
315 #[method(name = "getWork")]
318 async fn get_work(&self) -> RpcResult<Work>;
319
320 #[method(name = "submitHashrate")]
326 async fn submit_hashrate(&self, hashrate: U256, id: B256) -> RpcResult<bool>;
327
328 #[method(name = "submitWork")]
330 async fn submit_work(&self, nonce: B64, pow_hash: B256, mix_digest: B256) -> RpcResult<bool>;
331
332 #[method(name = "sendTransaction")]
335 async fn send_transaction(&self, request: TransactionRequest) -> RpcResult<B256>;
336
337 #[method(name = "sendRawTransaction")]
339 async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<B256>;
340
341 #[method(name = "sign")]
344 async fn sign(&self, address: Address, message: Bytes) -> RpcResult<Bytes>;
345
346 #[method(name = "signTransaction")]
349 async fn sign_transaction(&self, transaction: TransactionRequest) -> RpcResult<Bytes>;
350
351 #[method(name = "signTypedData")]
353 async fn sign_typed_data(&self, address: Address, data: TypedData) -> RpcResult<Bytes>;
354
355 #[method(name = "getProof")]
358 async fn get_proof(
359 &self,
360 address: Address,
361 keys: Vec<JsonStorageKey>,
362 block_number: Option<BlockId>,
363 ) -> RpcResult<EIP1186AccountProofResponse>;
364}
365
366#[async_trait::async_trait]
367impl<T>
368 EthApiServer<
369 RpcTransaction<T::NetworkTypes>,
370 RpcBlock<T::NetworkTypes>,
371 RpcReceipt<T::NetworkTypes>,
372 RpcHeader<T::NetworkTypes>,
373 > for T
374where
375 T: FullEthApi,
376 jsonrpsee_types::error::ErrorObject<'static>: From<T::Error>,
377{
378 async fn protocol_version(&self) -> RpcResult<U64> {
380 trace!(target: "rpc::eth", "Serving eth_protocolVersion");
381 EthApiSpec::protocol_version(self).await.to_rpc_result()
382 }
383
384 fn syncing(&self) -> RpcResult<SyncStatus> {
386 trace!(target: "rpc::eth", "Serving eth_syncing");
387 EthApiSpec::sync_status(self).to_rpc_result()
388 }
389
390 async fn author(&self) -> RpcResult<Address> {
392 Err(internal_rpc_err("unimplemented"))
393 }
394
395 fn accounts(&self) -> RpcResult<Vec<Address>> {
397 trace!(target: "rpc::eth", "Serving eth_accounts");
398 Ok(EthApiSpec::accounts(self))
399 }
400
401 fn block_number(&self) -> RpcResult<U256> {
403 trace!(target: "rpc::eth", "Serving eth_blockNumber");
404 Ok(U256::from(
405 EthApiSpec::chain_info(self).with_message("failed to read chain info")?.best_number,
406 ))
407 }
408
409 async fn chain_id(&self) -> RpcResult<Option<U64>> {
411 trace!(target: "rpc::eth", "Serving eth_chainId");
412 Ok(Some(EthApiSpec::chain_id(self)))
413 }
414
415 async fn block_by_hash(
417 &self,
418 hash: B256,
419 full: bool,
420 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
421 trace!(target: "rpc::eth", ?hash, ?full, "Serving eth_getBlockByHash");
422 Ok(EthBlocks::rpc_block(self, hash.into(), full).await?)
423 }
424
425 async fn block_by_number(
427 &self,
428 number: BlockNumberOrTag,
429 full: bool,
430 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
431 trace!(target: "rpc::eth", ?number, ?full, "Serving eth_getBlockByNumber");
432 Ok(EthBlocks::rpc_block(self, number.into(), full).await?)
433 }
434
435 async fn block_transaction_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>> {
437 trace!(target: "rpc::eth", ?hash, "Serving eth_getBlockTransactionCountByHash");
438 Ok(EthBlocks::block_transaction_count(self, hash.into()).await?.map(U256::from))
439 }
440
441 async fn block_transaction_count_by_number(
443 &self,
444 number: BlockNumberOrTag,
445 ) -> RpcResult<Option<U256>> {
446 trace!(target: "rpc::eth", ?number, "Serving eth_getBlockTransactionCountByNumber");
447 Ok(EthBlocks::block_transaction_count(self, number.into()).await?.map(U256::from))
448 }
449
450 async fn block_uncles_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>> {
452 trace!(target: "rpc::eth", ?hash, "Serving eth_getUncleCountByBlockHash");
453 Ok(EthBlocks::ommers(self, hash.into())?.map(|ommers| U256::from(ommers.len())))
454 }
455
456 async fn block_uncles_count_by_number(
458 &self,
459 number: BlockNumberOrTag,
460 ) -> RpcResult<Option<U256>> {
461 trace!(target: "rpc::eth", ?number, "Serving eth_getUncleCountByBlockNumber");
462 Ok(EthBlocks::ommers(self, number.into())?.map(|ommers| U256::from(ommers.len())))
463 }
464
465 async fn block_receipts(
467 &self,
468 block_id: BlockId,
469 ) -> RpcResult<Option<Vec<RpcReceipt<T::NetworkTypes>>>> {
470 trace!(target: "rpc::eth", ?block_id, "Serving eth_getBlockReceipts");
471 Ok(EthBlocks::block_receipts(self, block_id).await?)
472 }
473
474 async fn uncle_by_block_hash_and_index(
476 &self,
477 hash: B256,
478 index: Index,
479 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
480 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getUncleByBlockHashAndIndex");
481 Ok(EthBlocks::ommer_by_block_and_index(self, hash.into(), index).await?)
482 }
483
484 async fn uncle_by_block_number_and_index(
486 &self,
487 number: BlockNumberOrTag,
488 index: Index,
489 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
490 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getUncleByBlockNumberAndIndex");
491 Ok(EthBlocks::ommer_by_block_and_index(self, number.into(), index).await?)
492 }
493
494 async fn raw_transaction_by_hash(&self, hash: B256) -> RpcResult<Option<Bytes>> {
496 trace!(target: "rpc::eth", ?hash, "Serving eth_getRawTransactionByHash");
497 Ok(EthTransactions::raw_transaction_by_hash(self, hash).await?)
498 }
499
500 async fn transaction_by_hash(
502 &self,
503 hash: B256,
504 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
505 trace!(target: "rpc::eth", ?hash, "Serving eth_getTransactionByHash");
506 Ok(EthTransactions::transaction_by_hash(self, hash)
507 .await?
508 .map(|tx| tx.into_transaction(self.tx_resp_builder()))
509 .transpose()?)
510 }
511
512 async fn raw_transaction_by_block_hash_and_index(
514 &self,
515 hash: B256,
516 index: Index,
517 ) -> RpcResult<Option<Bytes>> {
518 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getRawTransactionByBlockHashAndIndex");
519 Ok(EthTransactions::raw_transaction_by_block_and_tx_index(self, hash.into(), index.into())
520 .await?)
521 }
522
523 async fn transaction_by_block_hash_and_index(
525 &self,
526 hash: B256,
527 index: Index,
528 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
529 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getTransactionByBlockHashAndIndex");
530 Ok(EthTransactions::transaction_by_block_and_tx_index(self, hash.into(), index.into())
531 .await?)
532 }
533
534 async fn raw_transaction_by_block_number_and_index(
536 &self,
537 number: BlockNumberOrTag,
538 index: Index,
539 ) -> RpcResult<Option<Bytes>> {
540 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getRawTransactionByBlockNumberAndIndex");
541 Ok(EthTransactions::raw_transaction_by_block_and_tx_index(
542 self,
543 number.into(),
544 index.into(),
545 )
546 .await?)
547 }
548
549 async fn transaction_by_block_number_and_index(
551 &self,
552 number: BlockNumberOrTag,
553 index: Index,
554 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
555 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getTransactionByBlockNumberAndIndex");
556 Ok(EthTransactions::transaction_by_block_and_tx_index(self, number.into(), index.into())
557 .await?)
558 }
559
560 async fn transaction_by_sender_and_nonce(
562 &self,
563 sender: Address,
564 nonce: U64,
565 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
566 trace!(target: "rpc::eth", ?sender, ?nonce, "Serving eth_getTransactionBySenderAndNonce");
567 Ok(EthTransactions::get_transaction_by_sender_and_nonce(self, sender, nonce.to(), true)
568 .await?)
569 }
570
571 async fn transaction_receipt(
573 &self,
574 hash: B256,
575 ) -> RpcResult<Option<RpcReceipt<T::NetworkTypes>>> {
576 trace!(target: "rpc::eth", ?hash, "Serving eth_getTransactionReceipt");
577 Ok(EthTransactions::transaction_receipt(self, hash).await?)
578 }
579
580 async fn balance(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<U256> {
582 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getBalance");
583 Ok(EthState::balance(self, address, block_number).await?)
584 }
585
586 async fn storage_at(
588 &self,
589 address: Address,
590 index: JsonStorageKey,
591 block_number: Option<BlockId>,
592 ) -> RpcResult<B256> {
593 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getStorageAt");
594 Ok(EthState::storage_at(self, address, index, block_number).await?)
595 }
596
597 async fn transaction_count(
599 &self,
600 address: Address,
601 block_number: Option<BlockId>,
602 ) -> RpcResult<U256> {
603 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getTransactionCount");
604 Ok(EthState::transaction_count(self, address, block_number).await?)
605 }
606
607 async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<Bytes> {
609 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getCode");
610 Ok(EthState::get_code(self, address, block_number).await?)
611 }
612
613 async fn header_by_number(
615 &self,
616 block_number: BlockNumberOrTag,
617 ) -> RpcResult<Option<RpcHeader<T::NetworkTypes>>> {
618 trace!(target: "rpc::eth", ?block_number, "Serving eth_getHeaderByNumber");
619 Ok(EthBlocks::rpc_block_header(self, block_number.into()).await?)
620 }
621
622 async fn header_by_hash(&self, hash: B256) -> RpcResult<Option<RpcHeader<T::NetworkTypes>>> {
624 trace!(target: "rpc::eth", ?hash, "Serving eth_getHeaderByHash");
625 Ok(EthBlocks::rpc_block_header(self, hash.into()).await?)
626 }
627
628 async fn simulate_v1(
630 &self,
631 payload: SimulatePayload,
632 block_number: Option<BlockId>,
633 ) -> RpcResult<Vec<SimulatedBlock<RpcBlock<T::NetworkTypes>>>> {
634 trace!(target: "rpc::eth", ?block_number, "Serving eth_simulateV1");
635 let _permit = self.tracing_task_guard().clone().acquire_owned().await;
636 Ok(EthCall::simulate_v1(self, payload, block_number).await?)
637 }
638
639 async fn call(
641 &self,
642 request: TransactionRequest,
643 block_number: Option<BlockId>,
644 state_overrides: Option<StateOverride>,
645 block_overrides: Option<Box<BlockOverrides>>,
646 ) -> RpcResult<Bytes> {
647 trace!(target: "rpc::eth", ?request, ?block_number, ?state_overrides, ?block_overrides, "Serving eth_call");
648 Ok(EthCall::call(
649 self,
650 request,
651 block_number,
652 EvmOverrides::new(state_overrides, block_overrides),
653 )
654 .await?)
655 }
656
657 async fn call_many(
659 &self,
660 bundles: Vec<Bundle>,
661 state_context: Option<StateContext>,
662 state_override: Option<StateOverride>,
663 ) -> RpcResult<Vec<Vec<EthCallResponse>>> {
664 trace!(target: "rpc::eth", ?bundles, ?state_context, ?state_override, "Serving eth_callMany");
665 Ok(EthCall::call_many(self, bundles, state_context, state_override).await?)
666 }
667
668 async fn create_access_list(
670 &self,
671 request: TransactionRequest,
672 block_number: Option<BlockId>,
673 state_override: Option<StateOverride>,
674 ) -> RpcResult<AccessListResult> {
675 trace!(target: "rpc::eth", ?request, ?block_number, ?state_override, "Serving eth_createAccessList");
676 Ok(EthCall::create_access_list_at(self, request, block_number, state_override).await?)
677 }
678
679 async fn estimate_gas(
681 &self,
682 request: TransactionRequest,
683 block_number: Option<BlockId>,
684 state_override: Option<StateOverride>,
685 ) -> RpcResult<U256> {
686 trace!(target: "rpc::eth", ?request, ?block_number, "Serving eth_estimateGas");
687 Ok(EthCall::estimate_gas_at(
688 self,
689 request,
690 block_number.unwrap_or_default(),
691 state_override,
692 )
693 .await?)
694 }
695
696 async fn gas_price(&self) -> RpcResult<U256> {
698 trace!(target: "rpc::eth", "Serving eth_gasPrice");
699 Ok(EthFees::gas_price(self).await?)
700 }
701
702 async fn get_account(
704 &self,
705 address: Address,
706 block: BlockId,
707 ) -> RpcResult<Option<alloy_rpc_types_eth::Account>> {
708 trace!(target: "rpc::eth", "Serving eth_getAccount");
709 Ok(EthState::get_account(self, address, block).await?)
710 }
711
712 async fn max_priority_fee_per_gas(&self) -> RpcResult<U256> {
714 trace!(target: "rpc::eth", "Serving eth_maxPriorityFeePerGas");
715 Ok(EthFees::suggested_priority_fee(self).await?)
716 }
717
718 async fn blob_base_fee(&self) -> RpcResult<U256> {
720 trace!(target: "rpc::eth", "Serving eth_blobBaseFee");
721 Ok(EthFees::blob_base_fee(self).await?)
722 }
723
724 async fn fee_history(
734 &self,
735 block_count: U64,
736 newest_block: BlockNumberOrTag,
737 reward_percentiles: Option<Vec<f64>>,
738 ) -> RpcResult<FeeHistory> {
739 trace!(target: "rpc::eth", ?block_count, ?newest_block, ?reward_percentiles, "Serving eth_feeHistory");
740 Ok(EthFees::fee_history(self, block_count.to(), newest_block, reward_percentiles).await?)
741 }
742
743 async fn is_mining(&self) -> RpcResult<bool> {
745 Err(internal_rpc_err("unimplemented"))
746 }
747
748 async fn hashrate(&self) -> RpcResult<U256> {
750 Ok(U256::ZERO)
751 }
752
753 async fn get_work(&self) -> RpcResult<Work> {
755 Err(internal_rpc_err("unimplemented"))
756 }
757
758 async fn submit_hashrate(&self, _hashrate: U256, _id: B256) -> RpcResult<bool> {
760 Ok(false)
761 }
762
763 async fn submit_work(
765 &self,
766 _nonce: B64,
767 _pow_hash: B256,
768 _mix_digest: B256,
769 ) -> RpcResult<bool> {
770 Err(internal_rpc_err("unimplemented"))
771 }
772
773 async fn send_transaction(&self, request: TransactionRequest) -> RpcResult<B256> {
775 trace!(target: "rpc::eth", ?request, "Serving eth_sendTransaction");
776 Ok(EthTransactions::send_transaction(self, request).await?)
777 }
778
779 async fn send_raw_transaction(&self, tx: Bytes) -> RpcResult<B256> {
781 trace!(target: "rpc::eth", ?tx, "Serving eth_sendRawTransaction");
782 Ok(EthTransactions::send_raw_transaction(self, tx).await?)
783 }
784
785 async fn sign(&self, address: Address, message: Bytes) -> RpcResult<Bytes> {
787 trace!(target: "rpc::eth", ?address, ?message, "Serving eth_sign");
788 Ok(EthTransactions::sign(self, address, message).await?)
789 }
790
791 async fn sign_transaction(&self, request: TransactionRequest) -> RpcResult<Bytes> {
793 trace!(target: "rpc::eth", ?request, "Serving eth_signTransaction");
794 Ok(EthTransactions::sign_transaction(self, request).await?)
795 }
796
797 async fn sign_typed_data(&self, address: Address, data: TypedData) -> RpcResult<Bytes> {
799 trace!(target: "rpc::eth", ?address, ?data, "Serving eth_signTypedData");
800 Ok(EthTransactions::sign_typed_data(self, &data, address)?)
801 }
802
803 async fn get_proof(
805 &self,
806 address: Address,
807 keys: Vec<JsonStorageKey>,
808 block_number: Option<BlockId>,
809 ) -> RpcResult<EIP1186AccountProofResponse> {
810 trace!(target: "rpc::eth", ?address, ?keys, ?block_number, "Serving eth_getProof");
811 Ok(EthState::get_proof(self, address, keys, block_number)?.await?)
812 }
813}