Skip to content

Commit

Permalink
feat: signature aggregators
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed Jan 30, 2025
1 parent 6c2e4ef commit 14fceb7
Show file tree
Hide file tree
Showing 52 changed files with 1,274 additions and 409 deletions.
13 changes: 13 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"bin/rundler/",
"crates/aggregators/bls/",
"crates/bindings/fastlz/",
"crates/builder/",
"crates/contracts/",
Expand All @@ -24,6 +25,7 @@ repository = "https://github.com/alchemyplatform/rundler"

[workspace.dependencies]
# rundler crates
rundler-bls = { path = "crates/aggregators/bls" }
rundler-contracts = { path = "crates/contracts" }
rundler-provider = { path = "crates/provider" }
rundler-sim = { path = "crates/sim" }
Expand Down Expand Up @@ -65,6 +67,7 @@ anyhow = "1.0.89"
async-trait = "0.1.83"
auto_impl = "1.2.0"
aws-config = { version = "1.5.6", default-features = false, features = ["rt-tokio", "rustls"] }
bytes = "1.9.0"
cargo-husky = { version = "1", default-features = false, features = ["user-hooks"] }
const-hex = "1.12.0"
futures = "0.3.30"
Expand Down
1 change: 1 addition & 0 deletions bin/rundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ERC-4337 bundler implementation
publish = false

[dependencies]
rundler-bls.workspace = true
rundler-builder.workspace = true
rundler-pool.workspace = true
rundler-provider.workspace = true
Expand Down
38 changes: 38 additions & 0 deletions bin/rundler/src/cli/aggregator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// This file is part of Rundler.
//
// Rundler is free software: you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the Free Software
// Foundation, either version 3 of the License, or (at your option) any later version.
//
// Rundler is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with Rundler.
// If not, see https://www.gnu.org/licenses/.

use std::sync::Arc;

use rundler_bls::BlsSignatureAggregatorV0_7;
use rundler_provider::Providers;
use rundler_types::{aggregator::SignatureAggregatorRegistry, chain::ChainSpec};

use super::CommonArgs;

/// Instantiate aggregators and pass to chain spec
pub fn instantiate_aggregators(
args: &CommonArgs,
chain_spec: &mut ChainSpec,
providers: &(impl Providers + 'static),
) {
let mut registry = SignatureAggregatorRegistry::default();

if args.bls_aggregation_enabled {
if let Some(ep_v0_7) = providers.ep_v0_7() {
let bls_aggregator = BlsSignatureAggregatorV0_7::new(ep_v0_7.clone());
registry.register(Arc::new(bls_aggregator));
}
}

chain_spec.set_signature_aggregators(Arc::new(registry));
}
4 changes: 3 additions & 1 deletion bin/rundler/src/cli/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use rundler_builder::{
TransactionSenderArgs, TransactionSenderKind,
};
use rundler_pool::RemotePoolClient;
use rundler_provider::Providers;
use rundler_sim::{MempoolConfigs, PriorityFeeMode};
use rundler_task::{
server::{connect_with_retries_shutdown, format_socket_addr},
Expand Down Expand Up @@ -433,6 +434,7 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
chain_spec: ChainSpec,
builder_args: BuilderCliArgs,
common_args: CommonArgs,
providers: impl Providers + 'static,
) -> anyhow::Result<()> {
let BuilderCliArgs {
builder: builder_args,
Expand Down Expand Up @@ -469,7 +471,7 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
event_sender,
LocalBuilderBuilder::new(REQUEST_CHANNEL_CAPACITY),
pool,
super::construct_providers(&common_args, &chain_spec)?,
providers,
)
.spawn(task_spawner)
.await?;
Expand Down
25 changes: 19 additions & 6 deletions bin/rundler/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use alloy_primitives::U256;
use anyhow::{bail, Context};
use clap::{builder::PossibleValuesParser, Args, Parser, Subcommand};

mod aggregator;
mod builder;
mod chain_spec;
mod json;
Expand Down Expand Up @@ -66,19 +67,24 @@ pub async fn run() -> anyhow::Result<()> {
)
.context("metrics server should start")?;

let cs = chain_spec::resolve_chain_spec(&opt.common.network, &opt.common.chain_spec);
let mut cs = chain_spec::resolve_chain_spec(&opt.common.network, &opt.common.chain_spec);
tracing::info!("Chain spec: {:#?}", cs);

let providers = construct_providers(&opt.common, &cs)?;
aggregator::instantiate_aggregators(&opt.common, &mut cs, &providers);

match opt.command {
Command::Node(args) => {
node::spawn_tasks(task_spawner.clone(), cs, *args, opt.common).await?
node::spawn_tasks(task_spawner.clone(), cs, *args, opt.common, providers).await?
}
Command::Pool(args) => {
pool::spawn_tasks(task_spawner.clone(), cs, args, opt.common).await?
pool::spawn_tasks(task_spawner.clone(), cs, args, opt.common, providers).await?
}
Command::Rpc(args) => {
rpc::spawn_tasks(task_spawner.clone(), cs, args, opt.common, providers).await?
}
Command::Rpc(args) => rpc::spawn_tasks(task_spawner.clone(), cs, args, opt.common).await?,
Command::Builder(args) => {
builder::spawn_tasks(task_spawner.clone(), cs, args, opt.common).await?
builder::spawn_tasks(task_spawner.clone(), cs, args, opt.common, providers).await?
}
}

Expand Down Expand Up @@ -361,6 +367,13 @@ pub struct CommonArgs {
env = "MAX_EXPECTED_STORAGE_SLOTS"
)]
pub max_expected_storage_slots: Option<usize>,

#[arg(
long = "bls_aggregation_enabled",
name = "bls_aggregation_enabled",
env = "BLS_AGGREGATION_ENABLED"
)]
pub bls_aggregation_enabled: bool,
}

const SIMULATION_GAS_OVERHEAD: u64 = 100_000;
Expand Down Expand Up @@ -606,7 +619,7 @@ where
pub fn construct_providers(
args: &CommonArgs,
chain_spec: &ChainSpec,
) -> anyhow::Result<impl Providers> {
) -> anyhow::Result<impl Providers + 'static> {
let provider = Arc::new(rundler_provider::new_alloy_provider(
args.node_http.as_ref().context("must provide node_http")?,
args.provider_client_timeout_seconds,
Expand Down
4 changes: 2 additions & 2 deletions bin/rundler/src/cli/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use clap::Args;
use rundler_builder::{BuilderEvent, BuilderTask, LocalBuilderBuilder};
use rundler_pool::{LocalPoolBuilder, PoolEvent, PoolTask};
use rundler_provider::Providers;
use rundler_rpc::RpcTask;
use rundler_task::TaskSpawnerExt;
use rundler_types::chain::ChainSpec;
Expand Down Expand Up @@ -49,6 +50,7 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
chain_spec: ChainSpec,
bundler_args: NodeCliArgs,
common_args: CommonArgs,
providers: impl Providers + 'static,
) -> anyhow::Result<()> {
let NodeCliArgs {
pool: pool_args,
Expand Down Expand Up @@ -109,8 +111,6 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
let builder_builder = LocalBuilderBuilder::new(REQUEST_CHANNEL_CAPACITY);
let builder_handle = builder_builder.get_handle();

let providers = super::construct_providers(&common_args, &chain_spec)?;

PoolTask::new(
pool_task_args,
op_pool_event_sender,
Expand Down
4 changes: 3 additions & 1 deletion bin/rundler/src/cli/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use alloy_primitives::Address;
use anyhow::Context;
use clap::Args;
use rundler_pool::{LocalPoolBuilder, PoolConfig, PoolTask, PoolTaskArgs};
use rundler_provider::Providers;
use rundler_sim::MempoolConfigs;
use rundler_task::TaskSpawnerExt;
use rundler_types::{chain::ChainSpec, EntryPointVersion};
Expand Down Expand Up @@ -305,6 +306,7 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
chain_spec: ChainSpec,
pool_args: PoolCliArgs,
common_args: CommonArgs,
providers: impl Providers + 'static,
) -> anyhow::Result<()> {
let PoolCliArgs { pool: pool_args } = pool_args;
let (event_sender, event_rx) = broadcast::channel(EVENT_CHANNEL_CAPACITY);
Expand All @@ -325,7 +327,7 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
task_args,
event_sender,
LocalPoolBuilder::new(REQUEST_CHANNEL_CAPACITY, BLOCK_CHANNEL_CAPACITY),
super::construct_providers(&common_args, &chain_spec)?,
providers,
)
.spawn(task_spawner)
.await?;
Expand Down
13 changes: 5 additions & 8 deletions bin/rundler/src/cli/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use anyhow::Context;
use clap::Args;
use rundler_builder::RemoteBuilderClient;
use rundler_pool::RemotePoolClient;
use rundler_provider::Providers;
use rundler_rpc::{EthApiSettings, RpcTask, RpcTaskArgs, RundlerApiSettings};
use rundler_sim::{EstimationSettings, PrecheckSettings};
use rundler_task::{server::connect_with_retries_shutdown, TaskSpawnerExt};
Expand Down Expand Up @@ -160,6 +161,7 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
chain_spec: ChainSpec,
rpc_args: RpcCliArgs,
common_args: CommonArgs,
providers: impl Providers + 'static,
) -> anyhow::Result<()> {
let RpcCliArgs {
rpc: rpc_args,
Expand Down Expand Up @@ -192,14 +194,9 @@ pub async fn spawn_tasks<T: TaskSpawnerExt + 'static>(
)
.await?;

RpcTask::new(
task_args,
pool,
builder,
super::construct_providers(&common_args, &chain_spec)?,
)
.spawn(task_spawner)
.await?;
RpcTask::new(task_args, pool, builder, providers)
.spawn(task_spawner)
.await?;

Ok(())
}
17 changes: 17 additions & 0 deletions crates/aggregators/bls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "rundler-bls"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
publish = false

[dependencies]
rundler-provider.workspace = true
rundler-types.workspace = true

alloy-primitives.workspace = true
async-trait.workspace = true

[dev-dependencies]
Loading

0 comments on commit 14fceb7

Please sign in to comment.