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

Multiple winners in autopilot #2996

Merged
merged 16 commits into from
Oct 4, 2024
Merged
7 changes: 7 additions & 0 deletions crates/autopilot/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ pub struct Arguments {
/// before continuing the run loop.
#[clap(long, env, default_value = "2s", value_parser = humantime::parse_duration)]
pub max_run_loop_delay: Duration,

#[clap(long, env, default_value = "1")]
/// The maximum number of winners per auction. Each winner will be allowed
/// to settle their winning orders at the same time.
pub max_winners_per_auction: usize,
}

impl std::fmt::Display for Arguments {
Expand Down Expand Up @@ -271,6 +276,7 @@ impl std::fmt::Display for Arguments {
cow_amm_configs,
run_loop_mode,
max_run_loop_delay,
max_winners_per_auction,
} = self;

write!(f, "{}", shared)?;
Expand Down Expand Up @@ -345,6 +351,7 @@ impl std::fmt::Display for Arguments {
writeln!(f, "cow_amm_configs: {:?}", cow_amm_configs)?;
writeln!(f, "run_loop_mode: {:?}", run_loop_mode)?;
writeln!(f, "max_run_loop_delay: {:?}", max_run_loop_delay)?;
writeln!(f, "max_winners_per_auction: {:?}", max_winners_per_auction)?;
Ok(())
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ pub async fn run(args: Arguments) {
synchronization: args.run_loop_mode,
max_run_loop_delay: args.max_run_loop_delay,
maintenance: Arc::new(maintenance),
max_winners_per_auction: args.max_winners_per_auction,
};
run.run_forever(args.auction_update_interval).await;
unreachable!("run loop exited");
Expand Down Expand Up @@ -618,6 +619,7 @@ async fn shadow_mode(args: Arguments) -> ! {
liveness.clone(),
args.run_loop_mode,
current_block,
args.max_winners_per_auction,
);
shadow.run_forever().await;

Expand Down
1 change: 1 addition & 0 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ pub struct RunLoop {
/// allowed to start before it has to re-synchronize to the blockchain
/// by waiting for the next block to appear.
pub max_run_loop_delay: Duration,
pub max_winners_per_auction: usize,
/// Maintenance tasks that should run before every runloop to have
/// the most recent data available.
pub maintenance: Arc<Maintenance>,
Expand Down
4 changes: 4 additions & 0 deletions crates/autopilot/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ pub struct RunLoop {
liveness: Arc<Liveness>,
synchronization: RunLoopMode,
current_block: CurrentBlockWatcher,
_max_winners_per_auction: usize,
}

impl RunLoop {
#[allow(clippy::too_many_arguments)]
pub fn new(
orderbook: infra::shadow::Orderbook,
drivers: Vec<infra::Driver>,
Expand All @@ -49,6 +51,7 @@ impl RunLoop {
liveness: Arc<Liveness>,
synchronization: RunLoopMode,
current_block: CurrentBlockWatcher,
_max_winners_per_auction: usize,
) -> Self {
Self {
orderbook,
Expand All @@ -60,6 +63,7 @@ impl RunLoop {
liveness,
synchronization,
current_block,
_max_winners_per_auction,
}
}

Expand Down
Loading