op_alloy_rpc_jsonrpsee/
traits.rs#![allow(missing_docs)]
use alloc::{boxed::Box, string::String, vec::Vec};
use core::net::IpAddr;
use alloy_eips::BlockNumberOrTag;
use alloy_primitives::{B256, U64};
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use op_alloy_protocol::{ExecutingMessage, SafetyLevel};
use op_alloy_rpc_types::{
OutputResponse, PeerDump, PeerInfo, PeerStats, RollupConfig, SafeHeadResponse, SyncStatus,
};
use op_alloy_rpc_types_engine::{ProtocolVersion, SuperchainSignal};
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "optimism"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "optimism"))]
pub trait RollupNode {
#[method(name = "outputAtBlock")]
async fn op_output_at_block(&self, block_number: BlockNumberOrTag)
-> RpcResult<OutputResponse>;
#[method(name = "safeHeadAtL1Block")]
async fn op_safe_head_at_l1_block(
&self,
block_number: BlockNumberOrTag,
) -> RpcResult<SafeHeadResponse>;
#[method(name = "syncStatus")]
async fn op_sync_status(&self) -> RpcResult<SyncStatus>;
#[method(name = "rollupConfig")]
async fn op_rollup_config(&self) -> RpcResult<RollupConfig>;
#[method(name = "version")]
async fn op_version(&self) -> RpcResult<String>;
}
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "opp2p"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "opp2p"))]
pub trait OpP2PApi {
#[method(name = "self")]
async fn opp2p_self(&self) -> RpcResult<PeerInfo>;
#[method(name = "peers")]
async fn opp2p_peers(&self) -> RpcResult<PeerDump>;
#[method(name = "peerStats")]
async fn opp2p_peer_stats(&self) -> RpcResult<PeerStats>;
#[method(name = "discoveryTable")]
async fn opp2p_discovery_table(&self) -> RpcResult<Vec<String>>;
#[method(name = "blockPeer")]
async fn opp2p_block_peer(&self, peer: String) -> RpcResult<()>;
#[method(name = "listBlockedPeers")]
async fn opp2p_list_blocked_peers(&self) -> RpcResult<Vec<String>>;
#[method(name = "blocAddr")]
async fn opp2p_block_addr(&self, ip: IpAddr) -> RpcResult<()>;
#[method(name = "unblockAddr")]
async fn opp2p_unblock_addr(&self, ip: IpAddr) -> RpcResult<()>;
#[method(name = "listBlockedAddrs")]
async fn opp2p_list_blocked_addrs(&self) -> RpcResult<Vec<IpAddr>>;
#[method(name = "blockSubnet")]
async fn opp2p_block_subnet(&self, subnet: String) -> RpcResult<()>;
#[method(name = "unblockSubnet")]
async fn opp2p_unblock_subnet(&self, subnet: String) -> RpcResult<()>;
#[method(name = "listBlockedSubnets")]
async fn opp2p_list_blocked_subnets(&self) -> RpcResult<Vec<String>>;
#[method(name = "protectPeer")]
async fn opp2p_protect_peer(&self, peer: String) -> RpcResult<()>;
#[method(name = "unprotectPeer")]
async fn opp2p_unprotect_peer(&self, peer: String) -> RpcResult<()>;
#[method(name = "connectPeer")]
async fn opp2p_connect_peer(&self, peer: String) -> RpcResult<()>;
#[method(name = "disconnectPeer")]
async fn opp2p_disconnect_peer(&self, peer: String) -> RpcResult<()>;
}
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "admin"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "admin"))]
pub trait OpAdminApi {
#[method(name = "resetDerivationPipeline")]
async fn admin_reset_derivation_pipeline(&self) -> RpcResult<()>;
#[method(name = "startSequencer")]
async fn admin_start_sequencer(&self, block_hash: B256) -> RpcResult<()>;
#[method(name = "stopSequencer")]
async fn admin_stop_sequencer(&self) -> RpcResult<B256>;
#[method(name = "sequencerActive")]
async fn admin_sequencer_active(&self) -> RpcResult<bool>;
}
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "engine"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "engine"))]
pub trait EngineApiExt {
#[method(name = "signalSuperchainV1")]
async fn signal_superchain_v1(&self, signal: SuperchainSignal) -> RpcResult<ProtocolVersion>;
}
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "miner"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "miner"))]
pub trait MinerApiExt {
#[method(name = "setMaxDASize")]
async fn set_max_da_size(&self, max_tx_size: U64, max_block_size: U64) -> RpcResult<bool>;
}
#[rpc(client, namespace = "supervisor")]
pub trait SupervisorApi {
#[method(name = "checkMessages")]
async fn check_messages(
&self,
messages: Vec<ExecutingMessage>,
min_safety: SafetyLevel,
) -> RpcResult<()>;
}