feat: install op miner endpoint (#13147)

This commit is contained in:
Matthias Seitz
2024-12-05 11:35:09 +01:00
committed by GitHub
parent 305ca2f9a5
commit 0016d91ed6
7 changed files with 114 additions and 16 deletions

View File

@ -45,6 +45,7 @@ alloy-consensus.workspace = true
op-alloy-network.workspace = true
op-alloy-rpc-types.workspace = true
op-alloy-rpc-types-engine.workspace = true
op-alloy-rpc-jsonrpsee.workspace = true
op-alloy-consensus.workspace = true
revm.workspace = true

View File

@ -12,6 +12,7 @@
pub mod error;
pub mod eth;
pub mod miner;
pub mod sequencer;
pub mod witness;

View File

@ -0,0 +1,32 @@
//! Miner API extension for OP.
use alloy_primitives::U64;
use jsonrpsee_core::{async_trait, RpcResult};
pub use op_alloy_rpc_jsonrpsee::traits::MinerApiExtServer;
use reth_optimism_payload_builder::config::OpDAConfig;
use tracing::debug;
/// Miner API extension for OP, exposes settings for the data availability configuration via the
/// `miner_` API.
#[derive(Debug, Clone)]
pub struct OpMinerExtApi {
da_config: OpDAConfig,
}
impl OpMinerExtApi {
/// Instantiate the miner API extension with the given, sharable data availability
/// configuration.
pub const fn new(da_config: OpDAConfig) -> Self {
Self { da_config }
}
}
#[async_trait]
impl MinerApiExtServer for OpMinerExtApi {
/// Handler for `miner_setMaxDASize` RPC method.
async fn set_max_da_size(&self, max_tx_size: U64, max_block_size: U64) -> RpcResult<()> {
debug!(target: "rpc", "Setting max DA size: tx={}, block={}", max_tx_size, max_block_size);
self.da_config.set_max_da_size(max_tx_size.to(), max_block_size.to());
Ok(())
}
}