Skip to content

Commit

Permalink
validation for blockspace capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
0xForerunner committed Sep 27, 2024
1 parent 9177bca commit d35e5a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions world-chain-builder/src/node/args.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use clap::value_parser;
use reth_node_optimism::args::RollupArgs;

/// Parameters for rollup configuration
Expand Down Expand Up @@ -27,6 +28,6 @@ pub struct WorldChainBuilderArgs {
/// verified transactions to fill the capacity, the remaining blockspace will be filled with
/// unverified transactions.
/// This arg is a percentage of the total blockspace with the default set to 70 (ie 70%).
#[arg(long = "builder.verified_blockspace_capacity", default_value = "70")]
pub verified_blockspace_capacity: u64,
#[arg(long = "builder.verified_blockspace_capacity", default_value = "70", value_parser = value_parser!(u8).range(0..=100))]
pub verified_blockspace_capacity: u8,
}
12 changes: 6 additions & 6 deletions world-chain-builder/src/payload/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use crate::pool::tx::WorldChainPoolTransaction;
pub struct WorldChainPayloadBuilder<EvmConfig> {
inner: OptimismPayloadBuilder<EvmConfig>,
// TODO: docs describing that this is a percent, ex: 50 is 50/100
verified_blockspace_capacity: u64,
verified_blockspace_capacity: u8,
// TODO: NOTE: we need to insert the verified txs into the table after they are inserted into the block
_database_env: Arc<DatabaseEnv>,
}
Expand All @@ -63,7 +63,7 @@ where
/// `OptimismPayloadBuilder` constructor.
pub const fn new(
evm_config: EvmConfig,
verified_blockspace_capacity: u64,
verified_blockspace_capacity: u8,
_database_env: Arc<DatabaseEnv>,
) -> Self {
let inner = OptimismPayloadBuilder::new(evm_config);
Expand Down Expand Up @@ -167,12 +167,12 @@ where

#[derive(Debug)]
pub struct WorldChainPayloadServiceBuilder {
pub verified_blockspace_capacity: u64,
pub verified_blockspace_capacity: u8,
pub db: Arc<DatabaseEnv>,
}

impl WorldChainPayloadServiceBuilder {
pub const fn new(verified_blockspace_capacity: u64, db: Arc<DatabaseEnv>) -> Self {
pub const fn new(verified_blockspace_capacity: u8, db: Arc<DatabaseEnv>) -> Self {
Self {
verified_blockspace_capacity,
db,
Expand Down Expand Up @@ -240,7 +240,7 @@ pub(crate) fn worldchain_payload<EvmConfig, Pool, Client>(
args: BuildArguments<Pool, Client, OptimismPayloadBuilderAttributes, OptimismBuiltPayload>,
initialized_cfg: CfgEnvWithHandlerCfg,
initialized_block_env: BlockEnv,
verified_blockspace_capacity: u64,
verified_blockspace_capacity: u8,
_compute_pending_block: bool,
) -> Result<BuildOutcome<OptimismBuiltPayload>, PayloadBuilderError>
where
Expand Down Expand Up @@ -433,7 +433,7 @@ where
}

if !attributes.no_tx_pool {
let verified_gas_limit = (verified_blockspace_capacity * block_gas_limit) / 100;
let verified_gas_limit = (verified_blockspace_capacity as u64 * block_gas_limit) / 100;
while let Some(pool_tx) = best_txs.next() {
// If the transaction is verified, check if it can be added within the verified gas limit
if pool_tx.transaction.semaphore_proof().is_some()
Expand Down

0 comments on commit d35e5a3

Please sign in to comment.