1use alloy_eips::BlockId;
2use alloy_primitives::{map::AddressMap, U256, U64};
3use jsonrpsee::{core::RpcResult, proc_macros::rpc};
4use serde::{Deserialize, Serialize};
5use serde_json::value::RawValue;
6
7use reth_chain_state as _;
9
10#[rpc(server, 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")]
29 async fn reth_get_block_execution_outcome(
30 &self,
31 block_id: BlockId,
32 count: Option<U64>,
33 ) -> RpcResult<Option<Box<RawValue>>>;
34
35 #[method(name = "jit")]
37 async fn reth_jit(&self, action: RethJitAction) -> RpcResult<()>;
38
39 #[subscription(
41 name = "subscribeChainNotifications",
42 unsubscribe = "unsubscribeChainNotifications",
43 item = reth_chain_state::CanonStateNotification
44 )]
45 async fn reth_subscribe_chain_notifications(&self) -> jsonrpsee::core::SubscriptionResult;
46
47 #[subscription(
51 name = "subscribePersistedBlock",
52 unsubscribe = "unsubscribePersistedBlock",
53 item = alloy_eips::BlockNumHash
54 )]
55 async fn reth_subscribe_persisted_block(&self) -> jsonrpsee::core::SubscriptionResult;
56
57 #[subscription(
62 name = "subscribeFinalizedChainNotifications",
63 unsubscribe = "unsubscribeFinalizedChainNotifications",
64 item = Vec<reth_chain_state::CanonStateNotification>
65 )]
66 async fn reth_subscribe_finalized_chain_notifications(
67 &self,
68 ) -> jsonrpsee::core::SubscriptionResult;
69}
70
71#[derive(Clone, Copy, Debug, Deserialize, Serialize)]
73#[serde(rename_all = "lowercase")]
74pub enum RethJitAction {
75 Enable,
77 Disable,
79 Pause,
81 Unpause,
83 Clear,
85}