reth_optimism_rpc/
miner.rs

1//! Miner API extension for OP.
2
3use alloy_primitives::U64;
4use jsonrpsee_core::{async_trait, RpcResult};
5pub use op_alloy_rpc_jsonrpsee::traits::MinerApiExtServer;
6use reth_optimism_payload_builder::config::OpDAConfig;
7use tracing::debug;
8
9/// Miner API extension for OP, exposes settings for the data availability configuration via the
10/// `miner_` API.
11#[derive(Debug, Clone)]
12pub struct OpMinerExtApi {
13    da_config: OpDAConfig,
14}
15
16impl OpMinerExtApi {
17    /// Instantiate the miner API extension with the given, sharable data availability
18    /// configuration.
19    pub const fn new(da_config: OpDAConfig) -> Self {
20        Self { da_config }
21    }
22}
23
24#[async_trait]
25impl MinerApiExtServer for OpMinerExtApi {
26    /// Handler for `miner_setMaxDASize` RPC method.
27    async fn set_max_da_size(&self, max_tx_size: U64, max_block_size: U64) -> RpcResult<bool> {
28        debug!(target: "rpc", "Setting max DA size: tx={}, block={}", max_tx_size, max_block_size);
29        self.da_config.set_max_da_size(max_tx_size.to(), max_block_size.to());
30        Ok(true)
31    }
32}