Skip to content

Commit

Permalink
Remove SubmissionPreference (#1843)
Browse files Browse the repository at this point in the history
I came across this field when checking what else needs to be ported to
colocated driver.

This field is not used in colocated world and I would rather remove it
since it is not used anymore (no solver is sending it) (and there is not
much sense for it to exist).

Colocated driver is supposed to determine the submission strategies
based on revert risk. And we also landed on a pretty decent public
mempool + Mevblocker setup.
  • Loading branch information
sunce86 authored Sep 7, 2023
1 parent 275da37 commit 51763ab
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 70 deletions.
30 changes: 0 additions & 30 deletions crates/shared/src/http_solver/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ pub struct SettledBatchAuctionModel {
pub approvals: Vec<ApprovalModel>,
#[serde(default)]
pub interaction_data: Vec<InteractionData>,
#[serde(default)]
pub submitter: SubmissionPreference,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(flatten)]
pub score: Option<Score>,
Expand Down Expand Up @@ -522,15 +520,6 @@ pub enum InternalizationStrategy {
SkipInternalizableInteraction,
}

/// Searchers can override submission strategy of the protocol
#[derive(Debug, Clone, Default, Deserialize, PartialEq, Eq, Serialize)]
pub enum SubmissionPreference {
#[default]
ProtocolDefault,
Flashbots,
PublicMempool,
}

#[cfg(test)]
mod tests {
use {
Expand Down Expand Up @@ -1025,25 +1014,6 @@ mod tests {
assert!(serde_json::from_str::<SettledBatchAuctionModel>(x).is_ok());
}

#[test]
fn decode_submitter_flashbots() {
let solution = r#"
{
"tokens": {},
"orders": {},
"metadata": {
"environment": null
},
"ref_token": null,
"prices": {},
"uniswaps": {},
"submitter": "Flashbots"
}
"#;
let deserialized = serde_json::from_str::<SettledBatchAuctionModel>(solution).unwrap();
assert_eq!(deserialized.submitter, SubmissionPreference::Flashbots);
}

#[test]
fn decode_execution_plan() {
assert_eq!(
Expand Down
9 changes: 2 additions & 7 deletions crates/solver/src/settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ mod settlement_encoder;

use {
crate::liquidity::Settleable,
anyhow::{ensure, Result},
anyhow::Result,
model::order::{Order, OrderKind},
num::{rational::Ratio, BigInt, BigRational, One, Signed, Zero},
primitive_types::{H160, U256},
shared::{
conversions::U256Ext as _,
encoded_settlement::{encode_trade, EncodedSettlement, EncodedTrade},
http_solver::model::{InternalizationStrategy, SubmissionPreference},
http_solver::model::InternalizationStrategy,
},
std::{
collections::{HashMap, HashSet},
Expand Down Expand Up @@ -240,8 +240,6 @@ impl Interaction for NoopInteraction {
#[derive(Debug, Clone, Default)]
pub struct Settlement {
pub encoder: SettlementEncoder,
pub submitter: SubmissionPreference, /* todo - extract submitter and score into a separate
* struct */
pub score: Option<Score>,
}

Expand Down Expand Up @@ -289,7 +287,6 @@ impl Settlement {
let encoder = self.encoder.without_onchain_liquidity();
Self {
encoder,
submitter: self.submitter.clone(),
score: self.score,
}
}
Expand Down Expand Up @@ -472,11 +469,9 @@ impl Settlement {

/// See SettlementEncoder::merge
pub fn merge(self, other: Self) -> Result<Self> {
ensure!(self.submitter == other.submitter, "different submitters");
let merged = self.encoder.merge(other.encoder)?;
Ok(Self {
encoder: merged,
submitter: self.submitter,
score: match (self.score, other.score) {
(Some(left), Some(right)) => left.merge(&right),
_ => None,
Expand Down
32 changes: 3 additions & 29 deletions crates/solver/src/settlement_submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use {
futures::FutureExt,
gas_estimation::{GasPrice1559, GasPriceEstimating},
primitive_types::{H256, U256},
shared::{code_fetching::CodeFetching, http_solver::model::SubmissionPreference},
shared::code_fetching::CodeFetching,
std::{
collections::HashMap,
sync::{Arc, Mutex},
Expand Down Expand Up @@ -211,35 +211,9 @@ impl SolutionSubmitter {
}
}

// combine protocol enabled strategies with settlement prefered strategies
let strategies = match settlement.submitter {
SubmissionPreference::ProtocolDefault => self.transaction_strategies.as_slice(),
SubmissionPreference::Flashbots => {
let position = self
.transaction_strategies
.iter()
.position(|strategy| matches!(strategy, TransactionStrategy::Flashbots(_)));
match position {
Some(index) => &self.transaction_strategies[index..index + 1],
// if flashbots are disabled by protocol, default to protocol strategies
None => self.transaction_strategies.as_slice(),
}
}
SubmissionPreference::PublicMempool => {
let position = self
.transaction_strategies
.iter()
.position(|strategy| matches!(strategy, TransactionStrategy::PublicMempool(_)));
match position {
Some(index) => &self.transaction_strategies[index..index + 1],
// if public mempool is disabled by protocol, default to protocol strategies
None => self.transaction_strategies.as_slice(),
}
}
};

let network_id = self.web3.net().version().await?;
let mut futures = strategies
let mut futures = self
.transaction_strategies
.iter()
.enumerate()
.map(|(i, strategy)| {
Expand Down
4 changes: 0 additions & 4 deletions crates/solver/src/solver/http_solver/settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ struct IntermediateSettlement<'a> {
executions: Vec<Execution>, // executions are sorted by execution coordinate.
prices: HashMap<H160, U256>,
slippage: SlippageContext<'a>,
submitter: SubmissionPreference,
score: Option<Score>,
// Causes either an error or a fee of 0 whenever a fee is expected but none was provided.
enforce_correct_fees: bool,
Expand Down Expand Up @@ -238,7 +237,6 @@ impl<'a> IntermediateSettlement<'a> {
settled.interaction_data,
[executed_limit_orders, foreign_liquidity_orders].concat(),
);
let submitter = settled.submitter;
let score = settled.score;

if duplicate_coordinates(&executions) {
Expand All @@ -252,15 +250,13 @@ impl<'a> IntermediateSettlement<'a> {
prices,
approvals,
slippage,
submitter,
score,
enforce_correct_fees,
})
}

fn into_settlement(self) -> Result<Settlement> {
let mut settlement = Settlement::new(self.prices);
settlement.submitter = self.submitter;
settlement.score = self.score;

// Make sure to always add approval interactions **before** any
Expand Down

0 comments on commit 51763ab

Please sign in to comment.