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 #[method(name = "getAccountInfo")]
369 async fn get_account_info(
370 &self,
371 address: Address,
372 block: BlockId,
373 ) -> RpcResult<alloy_rpc_types_eth::AccountInfo>;
374}
375
376#[async_trait::async_trait]
377impl<T>
378 EthApiServer<
379 RpcTransaction<T::NetworkTypes>,
380 RpcBlock<T::NetworkTypes>,
381 RpcReceipt<T::NetworkTypes>,
382 RpcHeader<T::NetworkTypes>,
383 > for T
384where
385 T: FullEthApi,
386 jsonrpsee_types::error::ErrorObject<'static>: From<T::Error>,
387{
388 async fn protocol_version(&self) -> RpcResult<U64> {
390 trace!(target: "rpc::eth", "Serving eth_protocolVersion");
391 EthApiSpec::protocol_version(self).await.to_rpc_result()
392 }
393
394 fn syncing(&self) -> RpcResult<SyncStatus> {
396 trace!(target: "rpc::eth", "Serving eth_syncing");
397 EthApiSpec::sync_status(self).to_rpc_result()
398 }
399
400 async fn author(&self) -> RpcResult<Address> {
402 Err(internal_rpc_err("unimplemented"))
403 }
404
405 fn accounts(&self) -> RpcResult<Vec<Address>> {
407 trace!(target: "rpc::eth", "Serving eth_accounts");
408 Ok(EthApiSpec::accounts(self))
409 }
410
411 fn block_number(&self) -> RpcResult<U256> {
413 trace!(target: "rpc::eth", "Serving eth_blockNumber");
414 Ok(U256::from(
415 EthApiSpec::chain_info(self).with_message("failed to read chain info")?.best_number,
416 ))
417 }
418
419 async fn chain_id(&self) -> RpcResult<Option<U64>> {
421 trace!(target: "rpc::eth", "Serving eth_chainId");
422 Ok(Some(EthApiSpec::chain_id(self)))
423 }
424
425 async fn block_by_hash(
427 &self,
428 hash: B256,
429 full: bool,
430 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
431 trace!(target: "rpc::eth", ?hash, ?full, "Serving eth_getBlockByHash");
432 Ok(EthBlocks::rpc_block(self, hash.into(), full).await?)
433 }
434
435 async fn block_by_number(
437 &self,
438 number: BlockNumberOrTag,
439 full: bool,
440 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
441 trace!(target: "rpc::eth", ?number, ?full, "Serving eth_getBlockByNumber");
442 Ok(EthBlocks::rpc_block(self, number.into(), full).await?)
443 }
444
445 async fn block_transaction_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>> {
447 trace!(target: "rpc::eth", ?hash, "Serving eth_getBlockTransactionCountByHash");
448 Ok(EthBlocks::block_transaction_count(self, hash.into()).await?.map(U256::from))
449 }
450
451 async fn block_transaction_count_by_number(
453 &self,
454 number: BlockNumberOrTag,
455 ) -> RpcResult<Option<U256>> {
456 trace!(target: "rpc::eth", ?number, "Serving eth_getBlockTransactionCountByNumber");
457 Ok(EthBlocks::block_transaction_count(self, number.into()).await?.map(U256::from))
458 }
459
460 async fn block_uncles_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>> {
462 trace!(target: "rpc::eth", ?hash, "Serving eth_getUncleCountByBlockHash");
463 Ok(EthBlocks::ommers(self, hash.into())?.map(|ommers| U256::from(ommers.len())))
464 }
465
466 async fn block_uncles_count_by_number(
468 &self,
469 number: BlockNumberOrTag,
470 ) -> RpcResult<Option<U256>> {
471 trace!(target: "rpc::eth", ?number, "Serving eth_getUncleCountByBlockNumber");
472 Ok(EthBlocks::ommers(self, number.into())?.map(|ommers| U256::from(ommers.len())))
473 }
474
475 async fn block_receipts(
477 &self,
478 block_id: BlockId,
479 ) -> RpcResult<Option<Vec<RpcReceipt<T::NetworkTypes>>>> {
480 trace!(target: "rpc::eth", ?block_id, "Serving eth_getBlockReceipts");
481 Ok(EthBlocks::block_receipts(self, block_id).await?)
482 }
483
484 async fn uncle_by_block_hash_and_index(
486 &self,
487 hash: B256,
488 index: Index,
489 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
490 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getUncleByBlockHashAndIndex");
491 Ok(EthBlocks::ommer_by_block_and_index(self, hash.into(), index).await?)
492 }
493
494 async fn uncle_by_block_number_and_index(
496 &self,
497 number: BlockNumberOrTag,
498 index: Index,
499 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
500 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getUncleByBlockNumberAndIndex");
501 Ok(EthBlocks::ommer_by_block_and_index(self, number.into(), index).await?)
502 }
503
504 async fn raw_transaction_by_hash(&self, hash: B256) -> RpcResult<Option<Bytes>> {
506 trace!(target: "rpc::eth", ?hash, "Serving eth_getRawTransactionByHash");
507 Ok(EthTransactions::raw_transaction_by_hash(self, hash).await?)
508 }
509
510 async fn transaction_by_hash(
512 &self,
513 hash: B256,
514 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
515 trace!(target: "rpc::eth", ?hash, "Serving eth_getTransactionByHash");
516 Ok(EthTransactions::transaction_by_hash(self, hash)
517 .await?
518 .map(|tx| tx.into_transaction(self.tx_resp_builder()))
519 .transpose()?)
520 }
521
522 async fn raw_transaction_by_block_hash_and_index(
524 &self,
525 hash: B256,
526 index: Index,
527 ) -> RpcResult<Option<Bytes>> {
528 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getRawTransactionByBlockHashAndIndex");
529 Ok(EthTransactions::raw_transaction_by_block_and_tx_index(self, hash.into(), index.into())
530 .await?)
531 }
532
533 async fn transaction_by_block_hash_and_index(
535 &self,
536 hash: B256,
537 index: Index,
538 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
539 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getTransactionByBlockHashAndIndex");
540 Ok(EthTransactions::transaction_by_block_and_tx_index(self, hash.into(), index.into())
541 .await?)
542 }
543
544 async fn raw_transaction_by_block_number_and_index(
546 &self,
547 number: BlockNumberOrTag,
548 index: Index,
549 ) -> RpcResult<Option<Bytes>> {
550 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getRawTransactionByBlockNumberAndIndex");
551 Ok(EthTransactions::raw_transaction_by_block_and_tx_index(
552 self,
553 number.into(),
554 index.into(),
555 )
556 .await?)
557 }
558
559 async fn transaction_by_block_number_and_index(
561 &self,
562 number: BlockNumberOrTag,
563 index: Index,
564 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
565 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getTransactionByBlockNumberAndIndex");
566 Ok(EthTransactions::transaction_by_block_and_tx_index(self, number.into(), index.into())
567 .await?)
568 }
569
570 async fn transaction_by_sender_and_nonce(
572 &self,
573 sender: Address,
574 nonce: U64,
575 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
576 trace!(target: "rpc::eth", ?sender, ?nonce, "Serving eth_getTransactionBySenderAndNonce");
577 Ok(EthTransactions::get_transaction_by_sender_and_nonce(self, sender, nonce.to(), true)
578 .await?)
579 }
580
581 async fn transaction_receipt(
583 &self,
584 hash: B256,
585 ) -> RpcResult<Option<RpcReceipt<T::NetworkTypes>>> {
586 trace!(target: "rpc::eth", ?hash, "Serving eth_getTransactionReceipt");
587 Ok(EthTransactions::transaction_receipt(self, hash).await?)
588 }
589
590 async fn balance(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<U256> {
592 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getBalance");
593 Ok(EthState::balance(self, address, block_number).await?)
594 }
595
596 async fn storage_at(
598 &self,
599 address: Address,
600 index: JsonStorageKey,
601 block_number: Option<BlockId>,
602 ) -> RpcResult<B256> {
603 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getStorageAt");
604 Ok(EthState::storage_at(self, address, index, block_number).await?)
605 }
606
607 async fn transaction_count(
609 &self,
610 address: Address,
611 block_number: Option<BlockId>,
612 ) -> RpcResult<U256> {
613 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getTransactionCount");
614 Ok(EthState::transaction_count(self, address, block_number).await?)
615 }
616
617 async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<Bytes> {
619 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getCode");
620 Ok(EthState::get_code(self, address, block_number).await?)
621 }
622
623 async fn header_by_number(
625 &self,
626 block_number: BlockNumberOrTag,
627 ) -> RpcResult<Option<RpcHeader<T::NetworkTypes>>> {
628 trace!(target: "rpc::eth", ?block_number, "Serving eth_getHeaderByNumber");
629 Ok(EthBlocks::rpc_block_header(self, block_number.into()).await?)
630 }
631
632 async fn header_by_hash(&self, hash: B256) -> RpcResult<Option<RpcHeader<T::NetworkTypes>>> {
634 trace!(target: "rpc::eth", ?hash, "Serving eth_getHeaderByHash");
635 Ok(EthBlocks::rpc_block_header(self, hash.into()).await?)
636 }
637
638 async fn simulate_v1(
640 &self,
641 payload: SimulatePayload,
642 block_number: Option<BlockId>,
643 ) -> RpcResult<Vec<SimulatedBlock<RpcBlock<T::NetworkTypes>>>> {
644 trace!(target: "rpc::eth", ?block_number, "Serving eth_simulateV1");
645 let _permit = self.tracing_task_guard().clone().acquire_owned().await;
646 Ok(EthCall::simulate_v1(self, payload, block_number).await?)
647 }
648
649 async fn call(
651 &self,
652 request: TransactionRequest,
653 block_number: Option<BlockId>,
654 state_overrides: Option<StateOverride>,
655 block_overrides: Option<Box<BlockOverrides>>,
656 ) -> RpcResult<Bytes> {
657 trace!(target: "rpc::eth", ?request, ?block_number, ?state_overrides, ?block_overrides, "Serving eth_call");
658 Ok(EthCall::call(
659 self,
660 request,
661 block_number,
662 EvmOverrides::new(state_overrides, block_overrides),
663 )
664 .await?)
665 }
666
667 async fn call_many(
669 &self,
670 bundles: Vec<Bundle>,
671 state_context: Option<StateContext>,
672 state_override: Option<StateOverride>,
673 ) -> RpcResult<Vec<Vec<EthCallResponse>>> {
674 trace!(target: "rpc::eth", ?bundles, ?state_context, ?state_override, "Serving eth_callMany");
675 Ok(EthCall::call_many(self, bundles, state_context, state_override).await?)
676 }
677
678 async fn create_access_list(
680 &self,
681 request: TransactionRequest,
682 block_number: Option<BlockId>,
683 state_override: Option<StateOverride>,
684 ) -> RpcResult<AccessListResult> {
685 trace!(target: "rpc::eth", ?request, ?block_number, ?state_override, "Serving eth_createAccessList");
686 Ok(EthCall::create_access_list_at(self, request, block_number, state_override).await?)
687 }
688
689 async fn estimate_gas(
691 &self,
692 request: TransactionRequest,
693 block_number: Option<BlockId>,
694 state_override: Option<StateOverride>,
695 ) -> RpcResult<U256> {
696 trace!(target: "rpc::eth", ?request, ?block_number, "Serving eth_estimateGas");
697 Ok(EthCall::estimate_gas_at(
698 self,
699 request,
700 block_number.unwrap_or_default(),
701 state_override,
702 )
703 .await?)
704 }
705
706 async fn gas_price(&self) -> RpcResult<U256> {
708 trace!(target: "rpc::eth", "Serving eth_gasPrice");
709 Ok(EthFees::gas_price(self).await?)
710 }
711
712 async fn get_account(
714 &self,
715 address: Address,
716 block: BlockId,
717 ) -> RpcResult<Option<alloy_rpc_types_eth::Account>> {
718 trace!(target: "rpc::eth", "Serving eth_getAccount");
719 Ok(EthState::get_account(self, address, block).await?)
720 }
721
722 async fn max_priority_fee_per_gas(&self) -> RpcResult<U256> {
724 trace!(target: "rpc::eth", "Serving eth_maxPriorityFeePerGas");
725 Ok(EthFees::suggested_priority_fee(self).await?)
726 }
727
728 async fn blob_base_fee(&self) -> RpcResult<U256> {
730 trace!(target: "rpc::eth", "Serving eth_blobBaseFee");
731 Ok(EthFees::blob_base_fee(self).await?)
732 }
733
734 async fn fee_history(
744 &self,
745 block_count: U64,
746 newest_block: BlockNumberOrTag,
747 reward_percentiles: Option<Vec<f64>>,
748 ) -> RpcResult<FeeHistory> {
749 trace!(target: "rpc::eth", ?block_count, ?newest_block, ?reward_percentiles, "Serving eth_feeHistory");
750 Ok(EthFees::fee_history(self, block_count.to(), newest_block, reward_percentiles).await?)
751 }
752
753 async fn is_mining(&self) -> RpcResult<bool> {
755 Err(internal_rpc_err("unimplemented"))
756 }
757
758 async fn hashrate(&self) -> RpcResult<U256> {
760 Ok(U256::ZERO)
761 }
762
763 async fn get_work(&self) -> RpcResult<Work> {
765 Err(internal_rpc_err("unimplemented"))
766 }
767
768 async fn submit_hashrate(&self, _hashrate: U256, _id: B256) -> RpcResult<bool> {
770 Ok(false)
771 }
772
773 async fn submit_work(
775 &self,
776 _nonce: B64,
777 _pow_hash: B256,
778 _mix_digest: B256,
779 ) -> RpcResult<bool> {
780 Err(internal_rpc_err("unimplemented"))
781 }
782
783 async fn send_transaction(&self, request: TransactionRequest) -> RpcResult<B256> {
785 trace!(target: "rpc::eth", ?request, "Serving eth_sendTransaction");
786 Ok(EthTransactions::send_transaction(self, request).await?)
787 }
788
789 async fn send_raw_transaction(&self, tx: Bytes) -> RpcResult<B256> {
791 trace!(target: "rpc::eth", ?tx, "Serving eth_sendRawTransaction");
792 Ok(EthTransactions::send_raw_transaction(self, tx).await?)
793 }
794
795 async fn sign(&self, address: Address, message: Bytes) -> RpcResult<Bytes> {
797 trace!(target: "rpc::eth", ?address, ?message, "Serving eth_sign");
798 Ok(EthTransactions::sign(self, address, message).await?)
799 }
800
801 async fn sign_transaction(&self, request: TransactionRequest) -> RpcResult<Bytes> {
803 trace!(target: "rpc::eth", ?request, "Serving eth_signTransaction");
804 Ok(EthTransactions::sign_transaction(self, request).await?)
805 }
806
807 async fn sign_typed_data(&self, address: Address, data: TypedData) -> RpcResult<Bytes> {
809 trace!(target: "rpc::eth", ?address, ?data, "Serving eth_signTypedData");
810 Ok(EthTransactions::sign_typed_data(self, &data, address)?)
811 }
812
813 async fn get_proof(
815 &self,
816 address: Address,
817 keys: Vec<JsonStorageKey>,
818 block_number: Option<BlockId>,
819 ) -> RpcResult<EIP1186AccountProofResponse> {
820 trace!(target: "rpc::eth", ?address, ?keys, ?block_number, "Serving eth_getProof");
821 Ok(EthState::get_proof(self, address, keys, block_number)?.await?)
822 }
823
824 async fn get_account_info(
826 &self,
827 address: Address,
828 block: BlockId,
829 ) -> RpcResult<alloy_rpc_types_eth::AccountInfo> {
830 trace!(target: "rpc::eth", "Serving eth_getAccountInfo");
831 Ok(EthState::get_account_info(self, address, block).await?)
832 }
833}