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

[EASY] Remove score cap #2577

Merged
merged 4 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
8 changes: 1 addition & 7 deletions crates/autopilot/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use {
crate::{domain::fee::FeeFactor, infra},
anyhow::Context,
clap::ValueEnum,
primitive_types::{H160, U256},
primitive_types::H160,
shared::{
arguments::{display_list, display_option, ExternalSolver},
bad_token::token_owner_finder,
Expand Down Expand Up @@ -167,10 +167,6 @@ pub struct Arguments {
#[clap(long, env, default_value = "5")]
pub additional_deadline_for_rewards: usize,

/// Cap used for CIP20 score calculation. Defaults to 0.01 ETH.
#[clap(long, env, default_value = "0.01", value_parser = shared::arguments::wei_from_ether)]
pub score_cap: U256,

/// The amount of time that the autopilot waits looking for a settlement
/// transaction onchain after the driver acknowledges the receipt of a
/// settlement.
Expand Down Expand Up @@ -254,7 +250,6 @@ impl std::fmt::Display for Arguments {
drivers,
submission_deadline,
additional_deadline_for_rewards,
score_cap,
shadow,
solve_deadline,
fee_policies,
Expand Down Expand Up @@ -316,7 +311,6 @@ impl std::fmt::Display for Arguments {
"additional_deadline_for_rewards: {}",
additional_deadline_for_rewards
)?;
writeln!(f, "score_cap: {}", score_cap)?;
display_option(f, "shadow", shadow)?;
writeln!(f, "solve_deadline: {:?}", solve_deadline)?;
writeln!(f, "fee_policies: {:?}", fee_policies)?;
Expand Down
4 changes: 0 additions & 4 deletions crates/autopilot/src/infra/solvers/dto/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ impl Request {
id: domain::auction::Id,
auction: &domain::Auction,
trusted_tokens: &HashSet<H160>,
score_cap: U256,
time_limit: Duration,
) -> Self {
Self {
Expand All @@ -48,7 +47,6 @@ impl Request {
.unique_by(|token| token.address)
.collect(),
deadline: Utc::now() + chrono::Duration::from_std(time_limit).unwrap(),
score_cap,
}
}
}
Expand All @@ -62,8 +60,6 @@ pub struct Request {
pub tokens: Vec<Token>,
pub orders: Vec<Order>,
pub deadline: DateTime<Utc>,
#[serde_as(as = "HexOrDecimalU256")]
pub score_cap: U256,
}

#[serde_as]
Expand Down
2 changes: 0 additions & 2 deletions crates/autopilot/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,6 @@ pub async fn run(args: Arguments) {
market_makable_token_list,
submission_deadline: args.submission_deadline as u64,
additional_deadline_for_rewards: args.additional_deadline_for_rewards as u64,
score_cap: args.score_cap,
max_settlement_transaction_wait: args.max_settlement_transaction_wait,
solve_deadline: args.solve_deadline,
in_flight_orders: Default::default(),
Expand Down Expand Up @@ -667,7 +666,6 @@ async fn shadow_mode(args: Arguments) -> ! {
orderbook,
drivers,
trusted_tokens,
args.score_cap,
args.solve_deadline,
liveness.clone(),
);
Expand Down
2 changes: 0 additions & 2 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pub struct RunLoop {
pub market_makable_token_list: AutoUpdatingTokenList,
pub submission_deadline: u64,
pub additional_deadline_for_rewards: u64,
pub score_cap: U256,
pub max_settlement_transaction_wait: Duration,
pub solve_deadline: Duration,
pub in_flight_orders: Arc<Mutex<Option<InFlightOrders>>>,
Expand Down Expand Up @@ -304,7 +303,6 @@ impl RunLoop {
id,
auction,
&self.market_makable_token_list.all(),
self.score_cap,
self.solve_deadline,
);
let request = &request;
Expand Down
12 changes: 2 additions & 10 deletions crates/autopilot/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub struct RunLoop {
trusted_tokens: AutoUpdatingTokenList,
auction: domain::auction::Id,
block: u64,
score_cap: U256,
solve_deadline: Duration,
liveness: Arc<Liveness>,
}
Expand All @@ -42,7 +41,6 @@ impl RunLoop {
orderbook: infra::shadow::Orderbook,
drivers: Vec<infra::Driver>,
trusted_tokens: AutoUpdatingTokenList,
score_cap: U256,
solve_deadline: Duration,
liveness: Arc<Liveness>,
) -> Self {
Expand All @@ -52,7 +50,6 @@ impl RunLoop {
trusted_tokens,
auction: 0,
block: 0,
score_cap,
solve_deadline,
liveness,
}
Expand Down Expand Up @@ -190,13 +187,8 @@ impl RunLoop {
id: domain::auction::Id,
auction: &domain::Auction,
) -> Vec<Participant<'_>> {
let request = solve::Request::new(
id,
auction,
&self.trusted_tokens.all(),
self.score_cap,
self.solve_deadline,
);
let request =
solve::Request::new(id, auction, &self.trusted_tokens.all(), self.solve_deadline);
let request = &request;

futures::future::join_all(self.drivers.iter().map(|driver| async move {
Expand Down
4 changes: 0 additions & 4 deletions crates/driver/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ components:
Information about tokens used in the auction.
deadline:
$ref: "#/components/schemas/DateTime"
scoreCap:
description: |
The protocol rewards the winning solver the difference between the observed score and the second best score up to this cap.
$ref: "#/components/schemas/BigUint"
SolveResponse:
description: |
Response of the solve endpoint.
Expand Down
9 changes: 1 addition & 8 deletions crates/driver/src/domain/competition/auction.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use {
super::{order, Order, Score},
super::{order, Order},
crate::{
domain::{
competition::{self, auction},
Expand Down Expand Up @@ -32,7 +32,6 @@ pub struct Auction {
tokens: Tokens,
gas_price: eth::GasPrice,
deadline: time::Deadline,
score_cap: Score,
}

impl Auction {
Expand All @@ -42,7 +41,6 @@ impl Auction {
tokens: impl Iterator<Item = Token>,
deadline: time::Deadline,
eth: &Ethereum,
score_cap: Score,
) -> Result<Self, Error> {
let tokens = Tokens(tokens.map(|token| (token.address, token)).collect());

Expand All @@ -66,7 +64,6 @@ impl Auction {
tokens,
gas_price: eth.gas_price().await?,
deadline,
score_cap,
})
}

Expand Down Expand Up @@ -109,10 +106,6 @@ impl Auction {
self.deadline
}

pub fn score_cap(&self) -> Score {
self.score_cap
}

pub fn prices(&self) -> Prices {
self.tokens
.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl Settlement {
mempools::RevertProtection::Disabled => gas_cost,
};
let score = competition::Score::new(
auction.score_cap(),
competition::Score(eth::U256::MAX.try_into().unwrap()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to remove this Score think in this PR as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change becomes too large then and hard to review. Planned to do it as part of #2493

objective_value,
success_probability,
failure_cost,
Expand Down
1 change: 0 additions & 1 deletion crates/driver/src/domain/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ impl Order {
.into_iter(),
self.deadline,
eth,
Default::default(),
)
.await
.map_err(|err| match err {
Expand Down
3 changes: 0 additions & 3 deletions crates/driver/src/infra/api/routes/solve/dto/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ impl Auction {
}),
time::Deadline::new(self.deadline, timeouts),
eth,
self.score_cap.try_into().map_err(|_| Error::ZeroScoreCap)?,
)
.await
.map_err(Into::into)
Expand Down Expand Up @@ -200,8 +199,6 @@ pub struct Auction {
tokens: Vec<Token>,
orders: Vec<Order>,
deadline: chrono::DateTime<chrono::Utc>,
#[serde_as(as = "serialize::U256")]
score_cap: eth::U256,
}

impl Auction {
Expand Down
3 changes: 0 additions & 3 deletions crates/driver/src/tests/cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ pub const DEFAULT_SCORE_MAX: u64 = 500000000000;
/// The default solver fee for limit orders.
pub const DEFAULT_SOLVER_FEE: &str = "1e-16";

/// The default maximum value to be payout out to solver per solution
pub const DEFAULT_SCORE_CAP: &str = "1e-2";

/// A generic wrapper struct for representing amounts in Ether using high
/// precision.
///
Expand Down
10 changes: 1 addition & 9 deletions crates/driver/src/tests/setup/driver.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
use {
super::{blockchain::Blockchain, Mempool, Partial, Solver, Test},
crate::{
domain::competition::order,
infra::time,
tests::{
cases::{self, EtherExt},
hex_address,
},
},
crate::{domain::competition::order, infra::time, tests::hex_address},
rand::seq::SliceRandom,
serde_json::json,
std::{io::Write, net::SocketAddr, path::PathBuf},
Expand Down Expand Up @@ -121,7 +114,6 @@ pub fn solve_req(test: &Test) -> serde_json::Value {
"tokens": tokens_json,
"orders": orders_json,
"deadline": test.deadline,
"scoreCap": cases::DEFAULT_SCORE_CAP.ether().into_wei().to_string(),
})
}

Expand Down
Loading