-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathop.rs
More file actions
150 lines (126 loc) · 5.72 KB
/
op.rs
File metadata and controls
150 lines (126 loc) · 5.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! Additional Node command arguments.
//!
//! Copied from OptimismNode to allow easy extension.
//! clap [Args](clap::Args) for optimism rollup configuration
use std::path::PathBuf;
use anyhow::{Result, anyhow};
use clap::Parser;
use reth_optimism_cli::commands::Commands;
use reth_optimism_node::args::RollupArgs;
use crate::gas_limiter::args::GasLimiterArgs;
/// Parameters for rollup configuration
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
#[command(next_help_heading = "Rollup")]
pub struct OpRbuilderArgs {
/// Rollup configuration
#[command(flatten)]
pub rollup_args: RollupArgs,
/// chain block time in milliseconds
#[arg(long = "rollup.chain-block-time", default_value = "1000", env = "CHAIN_BLOCK_TIME")]
pub chain_block_time: u64,
/// max gas a transaction can use
#[arg(long = "builder.max_gas_per_txn")]
pub max_gas_per_txn: Option<u64>,
/// How much time extra to wait for the block building job to complete and not get garbage collected
#[arg(long = "builder.extra-block-deadline-secs", default_value = "20")]
pub extra_block_deadline_secs: u64,
/// Whether to enable TIPS Resource Metering
#[arg(long = "builder.enable-resource-metering", default_value = "false")]
pub enable_resource_metering: bool,
/// Buffer size for tx data store (LRU eviction when full)
#[arg(long = "builder.tx-data-store-buffer-size", default_value = "10000")]
pub tx_data_store_buffer_size: usize,
/// Path to builder playgorund to automatically start up the node connected to it
#[arg(
long = "builder.playground",
num_args = 0..=1,
default_missing_value = "$HOME/.playground/devnet/",
value_parser = expand_path,
env = "PLAYGROUND_DIR",
)]
pub playground: Option<PathBuf>,
#[command(flatten)]
pub flashblocks: FlashblocksArgs,
#[command(flatten)]
pub telemetry: TelemetryArgs,
#[command(flatten)]
pub gas_limiter: GasLimiterArgs,
}
impl Default for OpRbuilderArgs {
fn default() -> Self {
let args = crate::args::Cli::parse_from(["dummy", "node"]);
let Commands::Node(node_command) = args.command else { unreachable!() };
node_command.ext
}
}
fn expand_path(s: &str) -> Result<PathBuf> {
shellexpand::full(s)
.map_err(|e| anyhow!("expansion error for `{s}`: {e}"))?
.into_owned()
.parse()
.map_err(|e| anyhow!("invalid path after expansion: {e}"))
}
/// Parameters for Flashblocks configuration
/// The names in the struct are prefixed with `flashblocks` to avoid conflicts
/// with the legacy standard builder configuration (now removed) since these args are
/// flattened into the main `OpRbuilderArgs` struct with the other rollup/node args.
#[derive(Debug, Clone, PartialEq, Eq, clap::Args)]
pub struct FlashblocksArgs {
/// Flashblocks is always enabled; these options tune its behavior.
/// The port that we bind to for the websocket server that provides flashblocks
#[arg(long = "flashblocks.port", env = "FLASHBLOCKS_WS_PORT", default_value = "1111")]
pub flashblocks_port: u16,
/// The address that we bind to for the websocket server that provides flashblocks
#[arg(long = "flashblocks.addr", env = "FLASHBLOCKS_WS_ADDR", default_value = "127.0.0.1")]
pub flashblocks_addr: String,
/// flashblock block time in milliseconds
#[arg(long = "flashblocks.block-time", default_value = "250", env = "FLASHBLOCK_BLOCK_TIME")]
pub flashblocks_block_time: u64,
/// Builder would always thry to produce fixed number of flashblocks without regard to time of
/// FCU arrival.
/// In cases of late FCU it could lead to partially filled blocks.
#[arg(long = "flashblocks.fixed", default_value = "false", env = "FLASHBLOCK_FIXED")]
pub flashblocks_fixed: bool,
/// Time by which blocks would be completed earlier in milliseconds.
///
/// This time used to account for latencies, this time would be deducted from total block
/// building time before calculating number of fbs.
#[arg(long = "flashblocks.leeway-time", default_value = "75", env = "FLASHBLOCK_LEEWAY_TIME")]
pub flashblocks_leeway_time: u64,
/// Whether to disable state root calculation for each flashblock
#[arg(
long = "flashblocks.disable-state-root",
default_value = "false",
env = "FLASHBLOCKS_DISABLE_STATE_ROOT"
)]
pub flashblocks_disable_state_root: bool,
/// Whether to enforce priority fee ordering within flashblocks.
/// When enabled, transactions that would violate descending priority fee order are skipped
/// and deferred to the next flashblock.
#[arg(
long = "flashblocks.enforce-priority-fee-ordering",
default_value = "true",
env = "FLASHBLOCKS_ENFORCE_PRIORITY_FEE_ORDERING"
)]
pub flashblocks_enforce_priority_fee_ordering: bool,
}
impl Default for FlashblocksArgs {
fn default() -> Self {
let args = crate::args::Cli::parse_from(["dummy", "node"]);
let Commands::Node(node_command) = args.command else { unreachable!() };
node_command.ext.flashblocks
}
}
/// Parameters for telemetry configuration
#[derive(Debug, Clone, Default, PartialEq, Eq, clap::Args)]
pub struct TelemetryArgs {
/// OpenTelemetry endpoint for traces
#[arg(long = "telemetry.otlp-endpoint", env = "OTEL_EXPORTER_OTLP_ENDPOINT")]
pub otlp_endpoint: Option<String>,
/// OpenTelemetry headers for authentication
#[arg(long = "telemetry.otlp-headers", env = "OTEL_EXPORTER_OTLP_HEADERS")]
pub otlp_headers: Option<String>,
/// Inverted sampling frequency in blocks. 1 - each block, 100 - every 100th block.
#[arg(long = "telemetry.sampling-ratio", env = "SAMPLING_RATIO", default_value = "100")]
pub sampling_ratio: u64,
}