1use crate::{
4 helpers::{EthApiSpec, EthBlocks, EthCall, EthFees, EthState, EthTransactions, FullEthApi},
5 RpcBlock, RpcHeader, RpcReceipt, RpcTransaction,
6};
7use alloy_dyn_abi::TypedData;
8use alloy_eips::{eip2930::AccessListResult, BlockId, BlockNumberOrTag};
9use alloy_json_rpc::RpcObject;
10use alloy_primitives::{Address, Bytes, B256, B64, U256, U64};
11use alloy_rpc_types_eth::{
12 simulate::{SimulatePayload, SimulatedBlock},
13 state::{EvmOverrides, StateOverride},
14 BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse, FeeHistory, Index,
15 StateContext, SyncStatus, Work,
16};
17use alloy_serde::JsonStorageKey;
18use jsonrpsee::{core::RpcResult, proc_macros::rpc};
19use reth_primitives_traits::TxTy;
20use reth_rpc_convert::RpcTxReq;
21use reth_rpc_eth_types::FillTransaction;
22use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult};
23use std::collections::HashMap;
24use tracing::trace;
25
26pub trait FullEthApiServer:
29 EthApiServer<
30 RpcTxReq<Self::NetworkTypes>,
31 RpcTransaction<Self::NetworkTypes>,
32 RpcBlock<Self::NetworkTypes>,
33 RpcReceipt<Self::NetworkTypes>,
34 RpcHeader<Self::NetworkTypes>,
35 TxTy<Self::Primitives>,
36 > + FullEthApi
37 + Clone
38{
39}
40
41impl<T> FullEthApiServer for T where
42 T: EthApiServer<
43 RpcTxReq<T::NetworkTypes>,
44 RpcTransaction<T::NetworkTypes>,
45 RpcBlock<T::NetworkTypes>,
46 RpcReceipt<T::NetworkTypes>,
47 RpcHeader<T::NetworkTypes>,
48 TxTy<T::Primitives>,
49 > + FullEthApi
50 + Clone
51{
52}
53
54#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
56#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
57pub trait EthApi<
58 TxReq: RpcObject,
59 T: RpcObject,
60 B: RpcObject,
61 R: RpcObject,
62 H: RpcObject,
63 RawTx: RpcObject,
64>
65{
66 #[method(name = "protocolVersion")]
68 async fn protocol_version(&self) -> RpcResult<U64>;
69
70 #[method(name = "syncing")]
72 fn syncing(&self) -> RpcResult<SyncStatus>;
73
74 #[method(name = "coinbase")]
76 async fn author(&self) -> RpcResult<Address>;
77
78 #[method(name = "accounts")]
80 fn accounts(&self) -> RpcResult<Vec<Address>>;
81
82 #[method(name = "blockNumber")]
84 fn block_number(&self) -> RpcResult<U256>;
85
86 #[method(name = "chainId")]
88 async fn chain_id(&self) -> RpcResult<Option<U64>>;
89
90 #[method(name = "getBlockByHash")]
92 async fn block_by_hash(&self, hash: B256, full: bool) -> RpcResult<Option<B>>;
93
94 #[method(name = "getBlockByNumber")]
96 async fn block_by_number(&self, number: BlockNumberOrTag, full: bool) -> RpcResult<Option<B>>;
97
98 #[method(name = "getBlockTransactionCountByHash")]
100 async fn block_transaction_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>>;
101
102 #[method(name = "getBlockTransactionCountByNumber")]
104 async fn block_transaction_count_by_number(
105 &self,
106 number: BlockNumberOrTag,
107 ) -> RpcResult<Option<U256>>;
108
109 #[method(name = "getUncleCountByBlockHash")]
111 async fn block_uncles_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>>;
112
113 #[method(name = "getUncleCountByBlockNumber")]
115 async fn block_uncles_count_by_number(
116 &self,
117 number: BlockNumberOrTag,
118 ) -> RpcResult<Option<U256>>;
119
120 #[method(name = "getBlockReceipts")]
122 async fn block_receipts(&self, block_id: BlockId) -> RpcResult<Option<Vec<R>>>;
123
124 #[method(name = "getUncleByBlockHashAndIndex")]
126 async fn uncle_by_block_hash_and_index(&self, hash: B256, index: Index)
127 -> RpcResult<Option<B>>;
128
129 #[method(name = "getUncleByBlockNumberAndIndex")]
131 async fn uncle_by_block_number_and_index(
132 &self,
133 number: BlockNumberOrTag,
134 index: Index,
135 ) -> RpcResult<Option<B>>;
136
137 #[method(name = "getRawTransactionByHash")]
141 async fn raw_transaction_by_hash(&self, hash: B256) -> RpcResult<Option<Bytes>>;
142
143 #[method(name = "getTransactionByHash")]
145 async fn transaction_by_hash(&self, hash: B256) -> RpcResult<Option<T>>;
146
147 #[method(name = "getRawTransactionByBlockHashAndIndex")]
149 async fn raw_transaction_by_block_hash_and_index(
150 &self,
151 hash: B256,
152 index: Index,
153 ) -> RpcResult<Option<Bytes>>;
154
155 #[method(name = "getTransactionByBlockHashAndIndex")]
157 async fn transaction_by_block_hash_and_index(
158 &self,
159 hash: B256,
160 index: Index,
161 ) -> RpcResult<Option<T>>;
162
163 #[method(name = "getRawTransactionByBlockNumberAndIndex")]
166 async fn raw_transaction_by_block_number_and_index(
167 &self,
168 number: BlockNumberOrTag,
169 index: Index,
170 ) -> RpcResult<Option<Bytes>>;
171
172 #[method(name = "getTransactionByBlockNumberAndIndex")]
174 async fn transaction_by_block_number_and_index(
175 &self,
176 number: BlockNumberOrTag,
177 index: Index,
178 ) -> RpcResult<Option<T>>;
179
180 #[method(name = "getTransactionBySenderAndNonce")]
182 async fn transaction_by_sender_and_nonce(
183 &self,
184 address: Address,
185 nonce: U64,
186 ) -> RpcResult<Option<T>>;
187
188 #[method(name = "getTransactionReceipt")]
190 async fn transaction_receipt(&self, hash: B256) -> RpcResult<Option<R>>;
191
192 #[method(name = "getBalance")]
194 async fn balance(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<U256>;
195
196 #[method(name = "getStorageAt")]
198 async fn storage_at(
199 &self,
200 address: Address,
201 index: JsonStorageKey,
202 block_number: Option<BlockId>,
203 ) -> RpcResult<B256>;
204
205 #[method(name = "getStorageValues")]
207 async fn storage_values(
208 &self,
209 requests: HashMap<Address, Vec<JsonStorageKey>>,
210 block_number: Option<BlockId>,
211 ) -> RpcResult<HashMap<Address, Vec<B256>>>;
212
213 #[method(name = "getTransactionCount")]
215 async fn transaction_count(
216 &self,
217 address: Address,
218 block_number: Option<BlockId>,
219 ) -> RpcResult<U256>;
220
221 #[method(name = "getCode")]
223 async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<Bytes>;
224
225 #[method(name = "getHeaderByNumber")]
227 async fn header_by_number(&self, hash: BlockNumberOrTag) -> RpcResult<Option<H>>;
228
229 #[method(name = "getHeaderByHash")]
231 async fn header_by_hash(&self, hash: B256) -> RpcResult<Option<H>>;
232
233 #[method(name = "simulateV1")]
236 async fn simulate_v1(
237 &self,
238 opts: SimulatePayload<TxReq>,
239 block_number: Option<BlockId>,
240 ) -> RpcResult<Vec<SimulatedBlock<B>>>;
241
242 #[method(name = "call")]
244 async fn call(
245 &self,
246 request: TxReq,
247 block_number: Option<BlockId>,
248 state_overrides: Option<StateOverride>,
249 block_overrides: Option<Box<BlockOverrides>>,
250 ) -> RpcResult<Bytes>;
251
252 #[method(name = "fillTransaction")]
254 async fn fill_transaction(&self, request: TxReq) -> RpcResult<FillTransaction<RawTx>>;
255
256 #[method(name = "callMany")]
259 async fn call_many(
260 &self,
261 bundles: Vec<Bundle<TxReq>>,
262 state_context: Option<StateContext>,
263 state_override: Option<StateOverride>,
264 ) -> RpcResult<Vec<Vec<EthCallResponse>>>;
265
266 #[method(name = "createAccessList")]
281 async fn create_access_list(
282 &self,
283 request: TxReq,
284 block_number: Option<BlockId>,
285 state_override: Option<StateOverride>,
286 ) -> RpcResult<AccessListResult>;
287
288 #[method(name = "estimateGas")]
291 async fn estimate_gas(
292 &self,
293 request: TxReq,
294 block_number: Option<BlockId>,
295 state_override: Option<StateOverride>,
296 ) -> RpcResult<U256>;
297
298 #[method(name = "gasPrice")]
300 async fn gas_price(&self) -> RpcResult<U256>;
301
302 #[method(name = "getAccount")]
304 async fn get_account(
305 &self,
306 address: Address,
307 block: BlockId,
308 ) -> RpcResult<Option<alloy_rpc_types_eth::Account>>;
309
310 #[method(name = "maxPriorityFeePerGas")]
312 async fn max_priority_fee_per_gas(&self) -> RpcResult<U256>;
313
314 #[method(name = "blobBaseFee")]
316 async fn blob_base_fee(&self) -> RpcResult<U256>;
317
318 #[method(name = "feeHistory")]
326 async fn fee_history(
327 &self,
328 block_count: U64,
329 newest_block: BlockNumberOrTag,
330 reward_percentiles: Option<Vec<f64>>,
331 ) -> RpcResult<FeeHistory>;
332
333 #[method(name = "mining")]
335 async fn is_mining(&self) -> RpcResult<bool>;
336
337 #[method(name = "hashrate")]
339 async fn hashrate(&self) -> RpcResult<U256>;
340
341 #[method(name = "getWork")]
344 async fn get_work(&self) -> RpcResult<Work>;
345
346 #[method(name = "submitHashrate")]
352 async fn submit_hashrate(&self, hashrate: U256, id: B256) -> RpcResult<bool>;
353
354 #[method(name = "submitWork")]
356 async fn submit_work(&self, nonce: B64, pow_hash: B256, mix_digest: B256) -> RpcResult<bool>;
357
358 #[method(name = "sendTransaction")]
361 async fn send_transaction(&self, request: TxReq) -> RpcResult<B256>;
362
363 #[method(name = "sendRawTransaction")]
365 async fn send_raw_transaction(&self, bytes: Bytes) -> RpcResult<B256>;
366
367 #[method(name = "sendRawTransactionSync")]
371 async fn send_raw_transaction_sync(&self, bytes: Bytes) -> RpcResult<R>;
372
373 #[method(name = "sign")]
376 async fn sign(&self, address: Address, message: Bytes) -> RpcResult<Bytes>;
377
378 #[method(name = "signTransaction")]
381 async fn sign_transaction(&self, transaction: TxReq) -> RpcResult<Bytes>;
382
383 #[method(name = "signTypedData")]
385 async fn sign_typed_data(&self, address: Address, data: TypedData) -> RpcResult<Bytes>;
386
387 #[method(name = "getProof")]
390 async fn get_proof(
391 &self,
392 address: Address,
393 keys: Vec<JsonStorageKey>,
394 block_number: Option<BlockId>,
395 ) -> RpcResult<EIP1186AccountProofResponse>;
396
397 #[method(name = "getAccountInfo")]
401 async fn get_account_info(
402 &self,
403 address: Address,
404 block: BlockId,
405 ) -> RpcResult<alloy_rpc_types_eth::AccountInfo>;
406
407 #[method(name = "getBlockAccessListByBlockHash")]
409 async fn block_access_list_by_block_hash(&self, hash: B256) -> RpcResult<Option<Bytes>>;
410
411 #[method(name = "getBlockAccessListByBlockNumber")]
413 async fn block_access_list_by_block_number(
414 &self,
415 number: BlockNumberOrTag,
416 ) -> RpcResult<Option<Bytes>>;
417}
418
419#[async_trait::async_trait]
420impl<T>
421 EthApiServer<
422 RpcTxReq<T::NetworkTypes>,
423 RpcTransaction<T::NetworkTypes>,
424 RpcBlock<T::NetworkTypes>,
425 RpcReceipt<T::NetworkTypes>,
426 RpcHeader<T::NetworkTypes>,
427 TxTy<T::Primitives>,
428 > for T
429where
430 T: FullEthApi,
431 jsonrpsee_types::error::ErrorObject<'static>: From<T::Error>,
432{
433 async fn protocol_version(&self) -> RpcResult<U64> {
435 trace!(target: "rpc::eth", "Serving eth_protocolVersion");
436 EthApiSpec::protocol_version(self).await.to_rpc_result()
437 }
438
439 fn syncing(&self) -> RpcResult<SyncStatus> {
441 trace!(target: "rpc::eth", "Serving eth_syncing");
442 EthApiSpec::sync_status(self).to_rpc_result()
443 }
444
445 async fn author(&self) -> RpcResult<Address> {
447 Err(internal_rpc_err("unimplemented"))
448 }
449
450 fn accounts(&self) -> RpcResult<Vec<Address>> {
452 trace!(target: "rpc::eth", "Serving eth_accounts");
453 Ok(EthTransactions::accounts(self))
454 }
455
456 fn block_number(&self) -> RpcResult<U256> {
458 trace!(target: "rpc::eth", "Serving eth_blockNumber");
459 Ok(U256::from(
460 EthApiSpec::chain_info(self).with_message("failed to read chain info")?.best_number,
461 ))
462 }
463
464 async fn chain_id(&self) -> RpcResult<Option<U64>> {
466 trace!(target: "rpc::eth", "Serving eth_chainId");
467 Ok(Some(EthApiSpec::chain_id(self)))
468 }
469
470 async fn block_by_hash(
472 &self,
473 hash: B256,
474 full: bool,
475 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
476 trace!(target: "rpc::eth", ?hash, ?full, "Serving eth_getBlockByHash");
477 Ok(EthBlocks::rpc_block(self, hash.into(), full).await?)
478 }
479
480 async fn block_by_number(
482 &self,
483 number: BlockNumberOrTag,
484 full: bool,
485 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
486 trace!(target: "rpc::eth", ?number, ?full, "Serving eth_getBlockByNumber");
487 Ok(EthBlocks::rpc_block(self, number.into(), full).await?)
488 }
489
490 async fn block_transaction_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>> {
492 trace!(target: "rpc::eth", ?hash, "Serving eth_getBlockTransactionCountByHash");
493 Ok(EthBlocks::block_transaction_count(self, hash.into()).await?.map(U256::from))
494 }
495
496 async fn block_transaction_count_by_number(
498 &self,
499 number: BlockNumberOrTag,
500 ) -> RpcResult<Option<U256>> {
501 trace!(target: "rpc::eth", ?number, "Serving eth_getBlockTransactionCountByNumber");
502 Ok(EthBlocks::block_transaction_count(self, number.into()).await?.map(U256::from))
503 }
504
505 async fn block_uncles_count_by_hash(&self, hash: B256) -> RpcResult<Option<U256>> {
507 trace!(target: "rpc::eth", ?hash, "Serving eth_getUncleCountByBlockHash");
508
509 if let Some(block) = self.block_by_hash(hash, false).await? {
510 Ok(Some(U256::from(block.uncles.len())))
511 } else {
512 Ok(None)
513 }
514 }
515
516 async fn block_uncles_count_by_number(
518 &self,
519 number: BlockNumberOrTag,
520 ) -> RpcResult<Option<U256>> {
521 trace!(target: "rpc::eth", ?number, "Serving eth_getUncleCountByBlockNumber");
522
523 if let Some(block) = self.block_by_number(number, false).await? {
524 Ok(Some(U256::from(block.uncles.len())))
525 } else {
526 Ok(None)
527 }
528 }
529
530 async fn block_receipts(
532 &self,
533 block_id: BlockId,
534 ) -> RpcResult<Option<Vec<RpcReceipt<T::NetworkTypes>>>> {
535 trace!(target: "rpc::eth", ?block_id, "Serving eth_getBlockReceipts");
536 Ok(EthBlocks::block_receipts(self, block_id).await?)
537 }
538
539 async fn uncle_by_block_hash_and_index(
541 &self,
542 hash: B256,
543 index: Index,
544 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
545 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getUncleByBlockHashAndIndex");
546 Ok(EthBlocks::ommer_by_block_and_index(self, hash.into(), index).await?)
547 }
548
549 async fn uncle_by_block_number_and_index(
551 &self,
552 number: BlockNumberOrTag,
553 index: Index,
554 ) -> RpcResult<Option<RpcBlock<T::NetworkTypes>>> {
555 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getUncleByBlockNumberAndIndex");
556 Ok(EthBlocks::ommer_by_block_and_index(self, number.into(), index).await?)
557 }
558
559 async fn raw_transaction_by_hash(&self, hash: B256) -> RpcResult<Option<Bytes>> {
561 trace!(target: "rpc::eth", ?hash, "Serving eth_getRawTransactionByHash");
562 Ok(EthTransactions::raw_transaction_by_hash(self, hash).await?)
563 }
564
565 async fn transaction_by_hash(
567 &self,
568 hash: B256,
569 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
570 trace!(target: "rpc::eth", ?hash, "Serving eth_getTransactionByHash");
571 Ok(EthTransactions::transaction_by_hash(self, hash)
572 .await?
573 .map(|tx| tx.into_transaction(self.converter()))
574 .transpose()
575 .map_err(T::Error::from)?)
576 }
577
578 async fn raw_transaction_by_block_hash_and_index(
580 &self,
581 hash: B256,
582 index: Index,
583 ) -> RpcResult<Option<Bytes>> {
584 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getRawTransactionByBlockHashAndIndex");
585 Ok(EthTransactions::raw_transaction_by_block_and_tx_index(self, hash.into(), index.into())
586 .await?)
587 }
588
589 async fn transaction_by_block_hash_and_index(
591 &self,
592 hash: B256,
593 index: Index,
594 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
595 trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getTransactionByBlockHashAndIndex");
596 Ok(EthTransactions::transaction_by_block_and_tx_index(self, hash.into(), index.into())
597 .await?)
598 }
599
600 async fn raw_transaction_by_block_number_and_index(
602 &self,
603 number: BlockNumberOrTag,
604 index: Index,
605 ) -> RpcResult<Option<Bytes>> {
606 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getRawTransactionByBlockNumberAndIndex");
607 Ok(EthTransactions::raw_transaction_by_block_and_tx_index(
608 self,
609 number.into(),
610 index.into(),
611 )
612 .await?)
613 }
614
615 async fn transaction_by_block_number_and_index(
617 &self,
618 number: BlockNumberOrTag,
619 index: Index,
620 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
621 trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getTransactionByBlockNumberAndIndex");
622 Ok(EthTransactions::transaction_by_block_and_tx_index(self, number.into(), index.into())
623 .await?)
624 }
625
626 async fn transaction_by_sender_and_nonce(
628 &self,
629 sender: Address,
630 nonce: U64,
631 ) -> RpcResult<Option<RpcTransaction<T::NetworkTypes>>> {
632 trace!(target: "rpc::eth", ?sender, ?nonce, "Serving eth_getTransactionBySenderAndNonce");
633 Ok(EthTransactions::get_transaction_by_sender_and_nonce(self, sender, nonce.to(), true)
634 .await?)
635 }
636
637 async fn transaction_receipt(
639 &self,
640 hash: B256,
641 ) -> RpcResult<Option<RpcReceipt<T::NetworkTypes>>> {
642 trace!(target: "rpc::eth", ?hash, "Serving eth_getTransactionReceipt");
643 Ok(EthTransactions::transaction_receipt(self, hash).await?)
644 }
645
646 async fn balance(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<U256> {
648 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getBalance");
649 Ok(EthState::balance(self, address, block_number).await?)
650 }
651
652 async fn storage_at(
654 &self,
655 address: Address,
656 index: JsonStorageKey,
657 block_number: Option<BlockId>,
658 ) -> RpcResult<B256> {
659 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getStorageAt");
660 Ok(EthState::storage_at(self, address, index, block_number).await?)
661 }
662
663 async fn storage_values(
665 &self,
666 requests: HashMap<Address, Vec<JsonStorageKey>>,
667 block_number: Option<BlockId>,
668 ) -> RpcResult<HashMap<Address, Vec<B256>>> {
669 trace!(target: "rpc::eth", ?block_number, "Serving eth_getStorageValues");
670 Ok(EthState::storage_values(self, requests, block_number).await?)
671 }
672
673 async fn transaction_count(
675 &self,
676 address: Address,
677 block_number: Option<BlockId>,
678 ) -> RpcResult<U256> {
679 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getTransactionCount");
680 Ok(EthState::transaction_count(self, address, block_number).await?)
681 }
682
683 async fn get_code(&self, address: Address, block_number: Option<BlockId>) -> RpcResult<Bytes> {
685 trace!(target: "rpc::eth", ?address, ?block_number, "Serving eth_getCode");
686 Ok(EthState::get_code(self, address, block_number).await?)
687 }
688
689 async fn header_by_number(
691 &self,
692 block_number: BlockNumberOrTag,
693 ) -> RpcResult<Option<RpcHeader<T::NetworkTypes>>> {
694 trace!(target: "rpc::eth", ?block_number, "Serving eth_getHeaderByNumber");
695 Ok(EthBlocks::rpc_block_header(self, block_number.into()).await?)
696 }
697
698 async fn header_by_hash(&self, hash: B256) -> RpcResult<Option<RpcHeader<T::NetworkTypes>>> {
700 trace!(target: "rpc::eth", ?hash, "Serving eth_getHeaderByHash");
701 Ok(EthBlocks::rpc_block_header(self, hash.into()).await?)
702 }
703
704 async fn simulate_v1(
706 &self,
707 payload: SimulatePayload<RpcTxReq<T::NetworkTypes>>,
708 block_number: Option<BlockId>,
709 ) -> RpcResult<Vec<SimulatedBlock<RpcBlock<T::NetworkTypes>>>> {
710 trace!(target: "rpc::eth", ?block_number, "Serving eth_simulateV1");
711 let _permit = self.tracing_task_guard().clone().acquire_owned().await;
712 Ok(EthCall::simulate_v1(self, payload, block_number).await?)
713 }
714
715 async fn call(
717 &self,
718 request: RpcTxReq<T::NetworkTypes>,
719 block_number: Option<BlockId>,
720 state_overrides: Option<StateOverride>,
721 block_overrides: Option<Box<BlockOverrides>>,
722 ) -> RpcResult<Bytes> {
723 trace!(target: "rpc::eth", ?request, ?block_number, ?state_overrides, ?block_overrides, "Serving eth_call");
724 Ok(EthCall::call(
725 self,
726 request,
727 block_number,
728 EvmOverrides::new(state_overrides, block_overrides),
729 )
730 .await?)
731 }
732
733 async fn fill_transaction(
735 &self,
736 request: RpcTxReq<T::NetworkTypes>,
737 ) -> RpcResult<FillTransaction<TxTy<T::Primitives>>> {
738 trace!(target: "rpc::eth", ?request, "Serving eth_fillTransaction");
739 Ok(EthTransactions::fill_transaction(self, request).await?)
740 }
741
742 async fn call_many(
744 &self,
745 bundles: Vec<Bundle<RpcTxReq<T::NetworkTypes>>>,
746 state_context: Option<StateContext>,
747 state_override: Option<StateOverride>,
748 ) -> RpcResult<Vec<Vec<EthCallResponse>>> {
749 trace!(target: "rpc::eth", ?bundles, ?state_context, ?state_override, "Serving eth_callMany");
750 Ok(EthCall::call_many(self, bundles, state_context, state_override).await?)
751 }
752
753 async fn create_access_list(
755 &self,
756 request: RpcTxReq<T::NetworkTypes>,
757 block_number: Option<BlockId>,
758 state_override: Option<StateOverride>,
759 ) -> RpcResult<AccessListResult> {
760 trace!(target: "rpc::eth", ?request, ?block_number, ?state_override, "Serving eth_createAccessList");
761 Ok(EthCall::create_access_list_at(self, request, block_number, state_override).await?)
762 }
763
764 async fn estimate_gas(
766 &self,
767 request: RpcTxReq<T::NetworkTypes>,
768 block_number: Option<BlockId>,
769 state_override: Option<StateOverride>,
770 ) -> RpcResult<U256> {
771 trace!(target: "rpc::eth", ?request, ?block_number, "Serving eth_estimateGas");
772 Ok(EthCall::estimate_gas_at(
773 self,
774 request,
775 block_number.unwrap_or_default(),
776 state_override,
777 )
778 .await?)
779 }
780
781 async fn gas_price(&self) -> RpcResult<U256> {
783 trace!(target: "rpc::eth", "Serving eth_gasPrice");
784 Ok(EthFees::gas_price(self).await?)
785 }
786
787 async fn get_account(
789 &self,
790 address: Address,
791 block: BlockId,
792 ) -> RpcResult<Option<alloy_rpc_types_eth::Account>> {
793 trace!(target: "rpc::eth", "Serving eth_getAccount");
794 Ok(EthState::get_account(self, address, block).await?)
795 }
796
797 async fn max_priority_fee_per_gas(&self) -> RpcResult<U256> {
799 trace!(target: "rpc::eth", "Serving eth_maxPriorityFeePerGas");
800 Ok(EthFees::suggested_priority_fee(self).await?)
801 }
802
803 async fn blob_base_fee(&self) -> RpcResult<U256> {
805 trace!(target: "rpc::eth", "Serving eth_blobBaseFee");
806 Ok(EthFees::blob_base_fee(self).await?)
807 }
808
809 async fn fee_history(
819 &self,
820 block_count: U64,
821 newest_block: BlockNumberOrTag,
822 reward_percentiles: Option<Vec<f64>>,
823 ) -> RpcResult<FeeHistory> {
824 trace!(target: "rpc::eth", ?block_count, ?newest_block, ?reward_percentiles, "Serving eth_feeHistory");
825 Ok(EthFees::fee_history(self, block_count.to(), newest_block, reward_percentiles).await?)
826 }
827
828 async fn is_mining(&self) -> RpcResult<bool> {
830 Err(internal_rpc_err("unimplemented"))
831 }
832
833 async fn hashrate(&self) -> RpcResult<U256> {
835 Ok(U256::ZERO)
836 }
837
838 async fn get_work(&self) -> RpcResult<Work> {
840 Err(internal_rpc_err("unimplemented"))
841 }
842
843 async fn submit_hashrate(&self, _hashrate: U256, _id: B256) -> RpcResult<bool> {
845 Ok(false)
846 }
847
848 async fn submit_work(
850 &self,
851 _nonce: B64,
852 _pow_hash: B256,
853 _mix_digest: B256,
854 ) -> RpcResult<bool> {
855 Err(internal_rpc_err("unimplemented"))
856 }
857
858 async fn send_transaction(&self, request: RpcTxReq<T::NetworkTypes>) -> RpcResult<B256> {
860 trace!(target: "rpc::eth", ?request, "Serving eth_sendTransaction");
861 Ok(EthTransactions::send_transaction_request(self, request).await?)
862 }
863
864 async fn send_raw_transaction(&self, tx: Bytes) -> RpcResult<B256> {
866 trace!(target: "rpc::eth", ?tx, "Serving eth_sendRawTransaction");
867 Ok(EthTransactions::send_raw_transaction(self, tx).await?)
868 }
869
870 async fn send_raw_transaction_sync(&self, tx: Bytes) -> RpcResult<RpcReceipt<T::NetworkTypes>> {
872 trace!(target: "rpc::eth", ?tx, "Serving eth_sendRawTransactionSync");
873 Ok(EthTransactions::send_raw_transaction_sync(self, tx).await?)
874 }
875
876 async fn sign(&self, address: Address, message: Bytes) -> RpcResult<Bytes> {
878 trace!(target: "rpc::eth", ?address, ?message, "Serving eth_sign");
879 Ok(EthTransactions::sign(self, address, message).await?)
880 }
881
882 async fn sign_transaction(&self, request: RpcTxReq<T::NetworkTypes>) -> RpcResult<Bytes> {
884 trace!(target: "rpc::eth", ?request, "Serving eth_signTransaction");
885 Ok(EthTransactions::sign_transaction(self, request).await?)
886 }
887
888 async fn sign_typed_data(&self, address: Address, data: TypedData) -> RpcResult<Bytes> {
890 trace!(target: "rpc::eth", ?address, ?data, "Serving eth_signTypedData");
891 Ok(EthTransactions::sign_typed_data(self, &data, address)?)
892 }
893
894 async fn get_proof(
896 &self,
897 address: Address,
898 keys: Vec<JsonStorageKey>,
899 block_number: Option<BlockId>,
900 ) -> RpcResult<EIP1186AccountProofResponse> {
901 trace!(target: "rpc::eth", ?address, ?keys, ?block_number, "Serving eth_getProof");
902 Ok(EthState::get_proof(self, address, keys, block_number)?.await?)
903 }
904
905 async fn get_account_info(
907 &self,
908 address: Address,
909 block: BlockId,
910 ) -> RpcResult<alloy_rpc_types_eth::AccountInfo> {
911 trace!(target: "rpc::eth", "Serving eth_getAccountInfo");
912 Ok(EthState::get_account_info(self, address, block).await?)
913 }
914
915 async fn block_access_list_by_block_hash(&self, hash: B256) -> RpcResult<Option<Bytes>> {
917 trace!(target: "rpc::eth", ?hash, "Serving eth_getBlockAccessListByBlockHash");
918 Err(internal_rpc_err("unimplemented"))
919 }
920
921 async fn block_access_list_by_block_number(
923 &self,
924 number: BlockNumberOrTag,
925 ) -> RpcResult<Option<Bytes>> {
926 trace!(target: "rpc::eth", ?number, "Serving eth_getBlockAccessListByBlockNumber");
927 Err(internal_rpc_err("unimplemented"))
928 }
929}