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(provider): add an entry point v0.7 provider #646

Merged
merged 3 commits into from
Mar 29, 2024
Merged
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
38 changes: 30 additions & 8 deletions bin/rundler/src/cli/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,46 @@ 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,
private_key: self.private_key.clone(),
aws_kms_key_ids: self.aws_kms_key_ids.clone(),
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: 39 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,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
Loading
Loading