Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc): introduce entry point routing #636

Merged
merged 12 commits into from
Mar 31, 2024
Merged
8 changes: 5 additions & 3 deletions Cargo.lock

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

42 changes: 35 additions & 7 deletions bin/rundler/src/cli/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ use anyhow::Context;
use clap::Args;
use ethers::types::H256;
use rundler_builder::{
self, BuilderEvent, BuilderEventKind, BuilderTask, BuilderTaskArgs, LocalBuilderBuilder,
TransactionSenderType,
self, BuilderEvent, BuilderEventKind, BuilderTask, BuilderTaskArgs, EntryPointBuilderSettings,
LocalBuilderBuilder, TransactionSenderType,
};
use rundler_pool::RemotePoolClient;
use rundler_sim::{MempoolConfig, PriorityFeeMode};
use rundler_task::{
server::{connect_with_retries_shutdown, format_socket_addr},
spawn_tasks_with_shutdown,
};
use rundler_types::chain::ChainSpec;
use rundler_types::{chain::ChainSpec, EntryPointVersion};
use rundler_utils::emit::{self, WithEntryPoint, EVENT_CHANNEL_CAPACITY};
use tokio::sync::broadcast;

Expand Down Expand Up @@ -110,7 +110,7 @@ pub struct BuilderArgs {
pub submit_url: Option<String>,

/// Choice of what sender type to to use for transaction submission.
/// Defaults to the value of `raw`. Other options inclue `flashbots`,
/// Defaults to the value of `raw`. Other options include `flashbots`,
/// `conditional` and `polygon_bloxroute`
#[arg(
long = "builder.sender",
Expand Down Expand Up @@ -198,8 +198,39 @@ impl BuilderArgs {
None => HashMap::from([(H256::zero(), MempoolConfig::default())]),
};

let mut entry_points = vec![];

if common.entry_point_v0_6_enabled {
entry_points.push(EntryPointBuilderSettings {
address: chain_spec.entry_point_address_v0_6,
version: EntryPointVersion::V0_6,
num_bundle_builders: common.num_builders_v0_6,
bundle_builder_index_offset: self.builder_index_offset,
mempool_configs: mempool_configs
.iter()
.filter(|(_, v)| v.entry_point() == chain_spec.entry_point_address_v0_6)
.map(|(k, v)| (*k, v.clone()))
.collect(),
});
}
if common.entry_point_v0_7_enabled {
entry_points.push(EntryPointBuilderSettings {
address: chain_spec.entry_point_address_v0_7,
version: EntryPointVersion::V0_7,
num_bundle_builders: common.num_builders_v0_7,
bundle_builder_index_offset: self.builder_index_offset,
mempool_configs: mempool_configs
.iter()
.filter(|(_, v)| v.entry_point() == chain_spec.entry_point_address_v0_7)
.map(|(k, v)| (*k, v.clone()))
.collect(),
});
}

Ok(BuilderTaskArgs {
entry_points,
chain_spec,
unsafe_mode: common.unsafe_mode,
rpc_url,
private_key: self.private_key.clone(),
aws_kms_key_ids: self.aws_kms_key_ids.clone(),
Expand All @@ -217,14 +248,11 @@ impl BuilderArgs {
sender_type: self.sender_type,
eth_poll_interval: Duration::from_millis(common.eth_poll_interval_millis),
sim_settings: common.into(),
mempool_configs,
max_blocks_to_wait_for_mine: self.max_blocks_to_wait_for_mine,
replacement_fee_percent_increase: self.replacement_fee_percent_increase,
max_fee_increases: self.max_fee_increases,
remote_address,
bloxroute_auth_header: self.bloxroute_auth_header.clone(),
num_bundle_builders: common.num_builders,
bundle_builder_index_offset: self.builder_index_offset,
})
}
}
Expand Down
38 changes: 34 additions & 4 deletions bin/rundler/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ pub struct CommonArgs {
)]
node_http: Option<String>,

/// Flag for turning unsafe bundling mode on
#[arg(long = "unsafe", env = "UNSAFE", global = true)]
unsafe_mode: bool,

#[arg(
long = "max_verification_gas",
name = "max_verification_gas",
Expand Down Expand Up @@ -254,12 +258,38 @@ pub struct CommonArgs {
pub mempool_config_path: Option<String>,

#[arg(
long = "num_builders",
name = "num_builders",
env = "NUM_BUILDERS",
long = "entry_point_v0_6_enabled",
name = "entry_point_v0_6_enabled",
env = "ENTRY_POINT_V0_6_ENABLED",
default_value = "true"
)]
pub entry_point_v0_6_enabled: bool,

// Ignored if entry_point_v0_6_enabled is false
#[arg(
long = "num_builders_v0_6",
name = "num_builders_v0_6",
env = "NUM_BUILDERS_V0_6",
default_value = "1"
)]
pub num_builders_v0_6: u64,

#[arg(
long = "entry_point_v0_7_enabled",
name = "entry_point_v0_7_enabled",
env = "ENTRY_POINT_V0_7_ENABLED",
default_value = "true"
)]
pub entry_point_v0_7_enabled: bool,

// Ignored if entry_point_v0_7_enabled is false
#[arg(
long = "num_builders_v0_7",
name = "num_builders_v0_7",
env = "NUM_BUILDERS_V0_7",
default_value = "1"
)]
pub num_builders: u64,
pub num_builders_v0_7: u64,
}

const SIMULATION_GAS_OVERHEAD: u64 = 100_000;
Expand Down
48 changes: 40 additions & 8 deletions bin/rundler/src/cli/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ use std::{collections::HashMap, net::SocketAddr, time::Duration};

use anyhow::Context;
use clap::Args;
use ethers::types::H256;
use ethers::types::{Address, H256};
use rundler_pool::{LocalPoolBuilder, PoolConfig, PoolTask, PoolTaskArgs};
use rundler_sim::MempoolConfig;
use rundler_task::spawn_tasks_with_shutdown;
use rundler_types::chain::ChainSpec;
use rundler_types::{chain::ChainSpec, EntryPointVersion};
use rundler_utils::emit::{self, EVENT_CHANNEL_CAPACITY};
use tokio::sync::broadcast;

Expand Down Expand Up @@ -181,19 +181,21 @@ impl PoolArgs {
tracing::info!("Mempool channel configs: {:?}", mempool_channel_configs);

let chain_id = chain_spec.id;
let pool_config = PoolConfig {
entry_point: chain_spec.entry_point_address,
let pool_config_base = PoolConfig {
// update per entry point
entry_point: Address::default(),
entry_point_version: EntryPointVersion::Unspecified,
num_shards: 0,
mempool_channel_configs: HashMap::new(),
// Base config
chain_id,
// Currently use the same shard count as the number of builders
num_shards: common.num_builders,
same_sender_mempool_count: self.same_sender_mempool_count,
min_replacement_fee_increase_percentage: self.min_replacement_fee_increase_percentage,
max_size_of_pool_bytes: self.max_size_in_bytes,
blocklist: blocklist.clone(),
allowlist: allowlist.clone(),
precheck_settings: common.try_into()?,
sim_settings: common.into(),
mempool_channel_configs: mempool_channel_configs.clone(),
throttled_entity_mempool_count: self.throttled_entity_mempool_count,
throttled_entity_live_blocks: self.throttled_entity_live_blocks,
paymaster_tracking_enabled: self.paymaster_tracking_enabled,
Expand All @@ -202,14 +204,44 @@ impl PoolArgs {
drop_min_num_blocks: self.drop_min_num_blocks,
};

let mut pool_configs = vec![];

if common.entry_point_v0_6_enabled {
pool_configs.push(PoolConfig {
entry_point: chain_spec.entry_point_address_v0_6,
entry_point_version: EntryPointVersion::V0_6,
num_shards: common.num_builders_v0_6,
mempool_channel_configs: mempool_channel_configs
.iter()
.filter(|(_, v)| v.entry_point() == chain_spec.entry_point_address_v0_6)
.map(|(k, v)| (*k, v.clone()))
.collect(),
..pool_config_base.clone()
});
}
if common.entry_point_v0_7_enabled {
pool_configs.push(PoolConfig {
entry_point: chain_spec.entry_point_address_v0_7,
entry_point_version: EntryPointVersion::V0_7,
num_shards: common.num_builders_v0_7,
mempool_channel_configs: mempool_channel_configs
.iter()
.filter(|(_, v)| v.entry_point() == chain_spec.entry_point_address_v0_7)
.map(|(k, v)| (*k, v.clone()))
.collect(),
..pool_config_base.clone()
});
}

Ok(PoolTaskArgs {
chain_spec,
unsafe_mode: common.unsafe_mode,
http_url: common
.node_http
.clone()
.context("pool requires node_http arg")?,
http_poll_interval: Duration::from_millis(common.eth_poll_interval_millis),
pool_configs: vec![pool_config],
pool_configs,
remote_address,
chain_update_channel_capacity: self.chain_update_channel_capacity.unwrap_or(1024),
})
Expand Down
3 changes: 3 additions & 0 deletions bin/rundler/src/cli/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ impl RpcArgs {

Ok(RpcTaskArgs {
chain_spec,
unsafe_mode: common.unsafe_mode,
port: self.port,
host: self.host.clone(),
rpc_url: common
Expand All @@ -110,6 +111,8 @@ impl RpcArgs {
estimation_settings,
rpc_timeout: Duration::from_secs(self.timeout_seconds.parse()?),
max_connections: self.max_connections,
entry_point_v0_6_enabled: common.entry_point_v0_6_enabled,
entry_point_v0_7_enabled: common.entry_point_v0_7_enabled,
})
}
}
Expand Down
38 changes: 0 additions & 38 deletions bin/tools/src/bin/get_example_ops.rs

This file was deleted.

3 changes: 1 addition & 2 deletions crates/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ license.workspace = true
repository.workspace = true

[dependencies]
rundler-pool = { path = "../pool" }
rundler-provider = { path = "../provider" }
rundler-sim = { path = "../sim" }
rundler-task = { path = "../task" }
Expand Down Expand Up @@ -46,7 +45,7 @@ mockall = {workspace = true, optional = true }

[dev-dependencies]
mockall.workspace = true
rundler-pool = { path = "../pool", features = ["test-utils"] }
rundler-types = { path = "../types", features = ["test-utils"] }
rundler-provider = { path = "../provider", features = ["test-utils"] }
rundler-sim = { path = "../sim", features = ["test-utils"] }

Expand Down
Loading
Loading