1use alloy_eips::BlockId;
2use alloy_primitives::{map::AddressMap, U256, U64};
3use jsonrpsee::{core::RpcResult, proc_macros::rpc};
4use serde::{Deserialize, Serialize};
5
6use reth_chain_state as _;
8
9#[cfg_attr(not(feature = "client"), rpc(server, namespace = "reth"))]
11#[cfg_attr(feature = "client", rpc(server, client, namespace = "reth"))]
12pub trait RethApi {
13 #[method(name = "getBalanceChangesInBlock")]
15 async fn reth_get_balance_changes_in_block(
16 &self,
17 block_id: BlockId,
18 ) -> RpcResult<AddressMap<U256>>;
19
20 #[method(name = "getBlockExecutionOutcome")]
26 async fn reth_get_block_execution_outcome(
27 &self,
28 block_id: BlockId,
29 count: Option<U64>,
30 ) -> RpcResult<Option<serde_json::Value>>;
31
32 #[method(name = "jit")]
34 async fn reth_jit(&self, action: RethJitAction) -> RpcResult<()>;
35
36 #[subscription(
38 name = "subscribeChainNotifications",
39 unsubscribe = "unsubscribeChainNotifications",
40 item = reth_chain_state::CanonStateNotification
41 )]
42 async fn reth_subscribe_chain_notifications(&self) -> jsonrpsee::core::SubscriptionResult;
43
44 #[subscription(
48 name = "subscribePersistedBlock",
49 unsubscribe = "unsubscribePersistedBlock",
50 item = alloy_eips::BlockNumHash
51 )]
52 async fn reth_subscribe_persisted_block(&self) -> jsonrpsee::core::SubscriptionResult;
53
54 #[subscription(
59 name = "subscribeFinalizedChainNotifications",
60 unsubscribe = "unsubscribeFinalizedChainNotifications",
61 item = Vec<reth_chain_state::CanonStateNotification>
62 )]
63 async fn reth_subscribe_finalized_chain_notifications(
64 &self,
65 ) -> jsonrpsee::core::SubscriptionResult;
66}
67
68#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
70#[serde(rename_all = "lowercase")]
71pub enum RethJitAction {
72 Enable,
74 Disable,
76 Pause,
78 Unpause,
80 Clear,
82}