Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks_docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
build-docker:
name: Build Docker image
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04

steps:
- name: Checkout sources
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
extract-version:
name: Extract version
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
outputs:
VERSION: ${{ steps.extract_version.outputs.VERSION }}
steps:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
matrix:
configs:
- target: linux/amd64
runner: warp-ubuntu-latest-x64-16x
runner: ubuntu-24.04
- target: linux/arm64
runner: warp-ubuntu-latest-arm64-16x
docker_target:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/op_rbuilder_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env:
jobs:
lint_and_test:
name: Lint and test
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
env:
# Set features for the Makefile
FEATURES: ${{ matrix.features }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/op_rbuilder_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ on:
jobs:
extract-version:
name: Extract version
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
outputs:
VERSION: ${{ steps.extract-version.outputs.VERSION }}
steps:
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
matrix:
configs:
- target: x86_64-unknown-linux-gnu
runner: warp-ubuntu-latest-x64-16x
runner: ubuntu-24.04
- target: aarch64-unknown-linux-gnu
runner: warp-ubuntu-latest-arm64-32x
# Paused until docker is pre-installed https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
name: Draft release
if: ${{ github.event.inputs.draft-release == 'true' || github.event_name == 'push'}} # when manually triggered or version tagged
needs: [extract-version, build-binary]
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
permissions:
Expand Down Expand Up @@ -179,7 +179,7 @@ jobs:
matrix:
configs:
- platform: linux/amd64
runner: warp-ubuntu-latest-x64-16x
runner: ubuntu-24.04
- platform: linux/arm64
runner: warp-ubuntu-latest-arm64-16x
steps:
Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:

publish-container-index:
name: Publish container index
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
env:
VERSION: ${{ needs.extract-version.outputs.VERSION }}
needs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tdx_quote_provider_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:
jobs:
check:
name: Check
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
defaults:
run:
working-directory: "./crates/tdx-quote-provider"
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:

docker:
name: Docker Build
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
defaults:
run:
working-directory: "./crates/tdx-quote-provider"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tdx_quote_provider_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ on:
jobs:
extract-version:
name: Extract version
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
outputs:
VERSION: ${{ steps.extract_version.outputs.VERSION }}
steps:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
matrix:
configs:
- target: x86_64-unknown-linux-gnu
runner: warp-ubuntu-latest-x64-16x
runner: ubuntu-24.04
- target: aarch64-unknown-linux-gnu
runner: warp-ubuntu-latest-arm64-32x
# Paused until docker is pre-installed https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
name: Draft release
if: ${{ github.event.inputs.draft-release == 'true' || github.event_name == 'push'}} # when manually triggered or version tagged
needs: [extract-version, build-binary]
runs-on: warp-ubuntu-latest-x64-16x
runs-on: ubuntu-24.04
env:
VERSION: op-${{ needs.extract-version.outputs.VERSION }}
permissions:
Expand Down
23 changes: 21 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,7 @@ time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
vergen = "9.0.4"
vergen-git2 = "1.0.5"
opentelemetry = { version = "0.31", features = ["trace"] }

# Base Path
concurrent-queue = "2.5.0"
tips-core = { git = "https://github.com/base/tips", rev = "c08eaa4fe10c26de8911609b41ddab4918698325", default-features = false }
3 changes: 3 additions & 0 deletions crates/op-rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ workspace = true
[dependencies]
p2p = { path = "../p2p" }

tips-core.workspace = true

reth.workspace = true
reth-optimism-node.workspace = true
reth-optimism-cli.workspace = true
Expand Down Expand Up @@ -112,6 +114,7 @@ url.workspace = true
anyhow = "1"
opentelemetry = { workspace = true, optional = true }
dashmap.workspace = true
concurrent-queue.workspace = true
hex = { workspace = true }
futures = { workspace = true }
futures-util = { workspace = true }
Expand Down
9 changes: 9 additions & 0 deletions crates/op-rbuilder/src/args/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ pub struct OpRbuilderArgs {
/// Whether to enable revert protection by default
#[arg(long = "builder.enable-revert-protection", default_value = "false")]
pub enable_revert_protection: bool,
/// Whether to enable TIPS Resource Metering
#[arg(long = "builder.enable-resource-metering", default_value = "false")]
pub enable_resource_metering: bool,
/// Whether to enable TIPS Resource Metering
#[arg(
long = "builder.resource-metering-buffer-size",
default_value = "10000"
)]
pub resource_metering_buffer_size: usize,

/// Path to builder playgorund to automatically start up the node connected to it
#[arg(
Expand Down
5 changes: 5 additions & 0 deletions crates/op-rbuilder/src/builders/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::{
gas_limiter::AddressGasLimiter,
metrics::OpRBuilderMetrics,
primitives::reth::{ExecutionInfo, TxnExecutionResult},
resource_metering::ResourceMetering,
traits::PayloadTxsBounds,
tx::MaybeRevertingTransaction,
tx_signer::Signer,
Expand Down Expand Up @@ -77,6 +78,8 @@ pub struct OpPayloadBuilderCtx<ExtraCtx: Debug + Default = ()> {
pub max_gas_per_txn: Option<u64>,
/// Rate limiting based on gas. This is an optional feature.
pub address_gas_limiter: AddressGasLimiter,
/// Per transaction resource metering information
pub resource_metering: ResourceMetering,
}

impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {
Expand Down Expand Up @@ -441,6 +444,8 @@ impl<ExtraCtx: Debug + Default> OpPayloadBuilderCtx<ExtraCtx> {

num_txs_considered += 1;

let _resource_usage = self.resource_metering.get(&tx_hash);

// TODO: ideally we should get this from the txpool stream
if let Some(conditional) = conditional
&& !conditional.matches_block_attributes(&block_attr)
Expand Down
5 changes: 5 additions & 0 deletions crates/op-rbuilder/src/builders/flashblocks/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::{
builders::{BuilderConfig, OpPayloadBuilderCtx, flashblocks::FlashblocksConfig},
gas_limiter::{AddressGasLimiter, args::GasLimiterArgs},
metrics::OpRBuilderMetrics,
resource_metering::ResourceMetering,
traits::ClientBounds,
};
use op_revm::OpSpecId;
Expand Down Expand Up @@ -29,6 +30,8 @@ pub(super) struct OpPayloadSyncerCtx {
max_gas_per_txn: Option<u64>,
/// The metrics for the builder
metrics: Arc<OpRBuilderMetrics>,
/// Resource metering tracking
resource_metering: ResourceMetering,
}

impl OpPayloadSyncerCtx {
Expand All @@ -48,6 +51,7 @@ impl OpPayloadSyncerCtx {
chain_spec,
max_gas_per_txn: builder_config.max_gas_per_txn,
metrics,
resource_metering: builder_config.resource_metering,
})
}

Expand Down Expand Up @@ -80,6 +84,7 @@ impl OpPayloadSyncerCtx {
extra_ctx: (),
max_gas_per_txn: self.max_gas_per_txn,
address_gas_limiter: AddressGasLimiter::new(GasLimiterArgs::default()),
resource_metering: self.resource_metering.clone(),
}
}
}
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/builders/flashblocks/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ where
extra_ctx,
max_gas_per_txn: self.config.max_gas_per_txn,
address_gas_limiter: self.address_gas_limiter.clone(),
resource_metering: self.config.resource_metering.clone(),
})
}

Expand Down
9 changes: 9 additions & 0 deletions crates/op-rbuilder/src/builders/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mod flashblocks;
mod generator;
mod standard;

use crate::resource_metering::ResourceMetering;
pub use builder_tx::{
BuilderTransactionCtx, BuilderTransactionError, BuilderTransactions, InvalidContractDataError,
SimulationSuccessResult, get_balance, get_nonce,
Expand Down Expand Up @@ -126,6 +127,9 @@ pub struct BuilderConfig<Specific: Clone> {

/// Address gas limiter stuff
pub gas_limiter_config: GasLimiterArgs,

/// Resource metering context
pub resource_metering: ResourceMetering,
}

impl<S: Debug + Clone> core::fmt::Debug for BuilderConfig<S> {
Expand Down Expand Up @@ -166,6 +170,7 @@ impl<S: Default + Clone> Default for BuilderConfig<S> {
sampling_ratio: 100,
max_gas_per_txn: None,
gas_limiter_config: GasLimiterArgs::default(),
resource_metering: ResourceMetering::default(),
}
}
}
Expand All @@ -188,6 +193,10 @@ where
sampling_ratio: args.telemetry.sampling_ratio,
max_gas_per_txn: args.max_gas_per_txn,
gas_limiter_config: args.gas_limiter.clone(),
resource_metering: ResourceMetering::new(
args.enable_resource_metering,
args.resource_metering_buffer_size,
),
specific: S::try_from(args)?,
})
}
Expand Down
3 changes: 1 addition & 2 deletions crates/op-rbuilder/src/builders/standard/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use super::BuilderConfig;
use crate::{
builders::standard::service::StandardServiceBuilder,
traits::{NodeBounds, PoolBounds},
};

use super::BuilderConfig;

mod builder_tx;
mod payload;
mod service;
Expand Down
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/builders/standard/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ where
extra_ctx: Default::default(),
max_gas_per_txn: self.config.max_gas_per_txn,
address_gas_limiter: self.address_gas_limiter.clone(),
resource_metering: self.config.resource_metering.clone(),
};

let builder = OpBuilder::new(best);
Expand Down
6 changes: 6 additions & 0 deletions crates/op-rbuilder/src/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
metrics::{VERSION, record_flag_gauge_metrics},
monitor_tx_pool::monitor_tx_pool,
primitives::reth::engine_api_builder::OpEngineApiBuilder,
resource_metering::{BaseApiExtServer, ResourceMeteringExt},
revert_protection::{EthApiExtServer, RevertProtectionExt},
tx::FBPooledTransaction,
};
Expand Down Expand Up @@ -109,6 +110,7 @@ where
let op_node = OpNode::new(rollup_args.clone());
let reverted_cache = Cache::builder().max_capacity(100).build();
let reverted_cache_copy = reverted_cache.clone();
let resource_metering = builder_config.resource_metering.clone();

let mut addons: OpAddOns<
_,
Expand Down Expand Up @@ -164,6 +166,10 @@ where
.add_or_replace_configured(revert_protection_ext.into_rpc())?;
}

let resource_metering_ext = ResourceMeteringExt::new(resource_metering);
ctx.modules
.add_or_replace_configured(resource_metering_ext.into_rpc())?;

Ok(())
})
.on_node_started(move |ctx| {
Expand Down
1 change: 1 addition & 0 deletions crates/op-rbuilder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ pub mod tx_signer;

#[cfg(test)]
pub mod mock_tx;
mod resource_metering;
#[cfg(any(test, feature = "testing"))]
pub mod tests;
6 changes: 6 additions & 0 deletions crates/op-rbuilder/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ pub struct OpRBuilderMetrics {
pub bundles_reverted: Histogram,
/// Histogram of eth_sendBundle request duration
pub bundle_receive_duration: Histogram,
/// Count of the number of times transactions had metering information
pub metering_known_transaction: Counter,
/// Count of the number of times transactions did not have any metering information
pub metering_unknown_transaction: Counter,
/// Count of the number of times we were unable to resolve metering information due to locking
pub metering_locked_transaction: Counter,
}

impl OpRBuilderMetrics {
Expand Down
Loading
Loading