Skip to content

Commit

Permalink
feat: end to end entry point routing (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Mar 29, 2024
1 parent eff2ec7 commit 55c6ced
Show file tree
Hide file tree
Showing 45 changed files with 1,666 additions and 632 deletions.
37 changes: 29 additions & 8 deletions bin/rundler/src/cli/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,23 +191,44 @@ impl BuilderArgs {
.context("should have a node HTTP URL")?;
let submit_url = self.submit_url.clone().unwrap_or_else(|| rpc_url.clone());

// TODO these should be scoped by entry point
let mempool_configs = match &common.mempool_config_path {
Some(path) => {
get_json_config::<HashMap<H256, MempoolConfig>>(path, &common.aws_region).await?
}
None => HashMap::from([(H256::zero(), MempoolConfig::default())]),
};

Ok(BuilderTaskArgs {
// TODO: support multiple entry points
entry_points: vec![EntryPointBuilderSettings {
address: chain_spec.entry_point_address,
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,
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: 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,
Expand Down
34 changes: 30 additions & 4 deletions bin/rundler/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,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
47 changes: 38 additions & 9 deletions bin/rundler/src/cli/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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;
Expand Down Expand Up @@ -181,21 +181,21 @@ impl PoolArgs {
tracing::info!("Mempool channel configs: {:?}", mempool_channel_configs);

let chain_id = chain_spec.id;
// TODO(danc): multiple pool configs
let pool_config = PoolConfig {
entry_point: chain_spec.entry_point_address,
entry_point_version: EntryPointVersion::V0_6,
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 @@ -204,6 +204,35 @@ 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,
Expand All @@ -212,7 +241,7 @@ impl PoolArgs {
.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
2 changes: 2 additions & 0 deletions bin/rundler/src/cli/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,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
Loading

0 comments on commit 55c6ced

Please sign in to comment.