Skip to content

Commit

Permalink
Merge branch 'main' into 3045/add-submission-address-autopilot
Browse files Browse the repository at this point in the history
  • Loading branch information
sunce86 authored Jan 17, 2025
2 parents e7d8e23 + 395d605 commit e8b91dc
Show file tree
Hide file tree
Showing 70 changed files with 890 additions and 449 deletions.
2 changes: 1 addition & 1 deletion .github/nitpicks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Reminder: Please consider backward compatibility when modifying the API specification.
If breaking changes are unavoidable, ensure:
- You explicitly pointed out breaking changes.
- You communicate the changes to affected teams.
- You communicate the changes to affected teams (at least Frontend team and SAFE team).
- You provide proper versioning and migration mechanisms.
pathFilter:
- "**/openapi.yml"
2 changes: 1 addition & 1 deletion .github/workflows/hotfix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Check out
uses: actions/checkout@v4
with:
token: "${{ secrets.HOTFIX_ACTION_JOB }}"
token: "${{ secrets.HOTFIX_ACTION_TOKEN }}"
fetch-depth: 0

- name: Configure git
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ jobs:

test-forked-node:
# Do not run this job on forks since some secrets are required for it.
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
if: |
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'push' && github.ref == 'refs/heads/main')
timeout-minutes: 60
runs-on: ubuntu-latest
env:
Expand Down
51 changes: 14 additions & 37 deletions Cargo.lock

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

9 changes: 3 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ clap = { version = "4.5.6", features = ["derive", "env"] }
dashmap = "6.1.0"
derivative = "2.2.0"
derive_more = { version = "1.0.0", features = ["full"] }
ethcontract = { version = "0.25.7", default-features = false, features = ["aws-kms"] }
ethcontract = { version = "0.25.8", default-features = false, features = ["aws-kms"] }
mimalloc = "0.1.43"
ethcontract-generate = { version = "0.25.7", default-features = false }
ethcontract-mock = { version = "0.25.7", default-features = false }
ethcontract-generate = { version = "0.25.8", default-features = false }
ethcontract-mock = { version = "0.25.8", default-features = false }
ethereum-types = "0.14.1"
flate2 = "1.0.30"
futures = "0.3.30"
Expand All @@ -28,11 +28,9 @@ humantime-serde = "1.1.1"
hyper = "0.14.29"
indexmap = "2.2.6"
itertools = "0.12.1"
lazy_static = "1.4.0"
maplit = "1.0.2"
mockall = "0.12.1"
num = "0.4.3"
once_cell = "1.19.0"
primitive-types = "0.12"
prometheus = "0.13.4"
prometheus-metric-storage = "0.5.0"
Expand All @@ -46,7 +44,6 @@ serde_with = "3.8.1"
sqlx = { version = "0.7", default-features = false, features = ["runtime-tokio", "tls-native-tls", "bigdecimal", "chrono", "postgres", "macros"] }
strum = { version = "0.26.2", features = ["derive"] }
tempfile = "3.10.1"
time = { version = "0.3.36", features = ["macros"] }
thiserror = "1.0.61"
toml = "0.8.14"
tokio = { version = "1.38.0", features = ["tracing"] }
Expand Down
21 changes: 20 additions & 1 deletion crates/app-data/src/app_data.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::{app_data_hash::hash_full_app_data, AppDataHash, Hooks},
anyhow::{anyhow, Context, Result},
primitive_types::H160,
primitive_types::{H160, U256},
serde::{de, Deserialize, Deserializer, Serialize, Serializer},
std::{fmt, fmt::Display},
};
Expand All @@ -24,6 +24,24 @@ pub struct ProtocolAppData {
pub signer: Option<H160>,
pub replaced_order: Option<ReplacedOrder>,
pub partner_fee: Option<PartnerFee>,
pub flashloan: Option<Flashloan>,
}

/// Contains information to hint at how a solver could make
/// use of flashloans to settle the associated order.
/// Since using flashloans introduces a bunch of complexities
/// all these hints are not binding for the solver.
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
pub struct Flashloan {
/// Which contract to request the flashloan from.
lender: Option<H160>,
/// Who should receive the borrowed tokens. If this is not
/// set the order owner will get the tokens.
borrower: Option<H160>,
/// Which token to flashloan.
token: H160,
/// How much of the token to flashloan.
amount: U256,
}

#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
Expand Down Expand Up @@ -217,6 +235,7 @@ impl From<BackendAppData> for ProtocolAppData {
signer: None,
replaced_order: None,
partner_fee: None,
flashloan: None,
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions crates/autopilot/src/database/onchain_order_events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ type GeneralOnchainOrderPlacementData = (
OnchainOrderPlacement,
Order,
);
async fn parse_general_onchain_order_placement_data<'a>(
quoter: &'a dyn OrderQuoting,
async fn parse_general_onchain_order_placement_data(
quoter: &'_ dyn OrderQuoting,
order_placement_events_and_quotes_zipped: Vec<(EthContractEvent<ContractEvent>, i64, i64)>,
domain_separator: DomainSeparator,
settlement_contract: H160,
Expand Down Expand Up @@ -616,7 +616,6 @@ fn convert_onchain_order_placement(
settlement_contract: ByteArray(settlement_contract.0),
sell_token_balance: sell_token_source_into(order_data.sell_token_balance),
buy_token_balance: buy_token_destination_into(order_data.buy_token_balance),
full_fee_amount: u256_to_big_decimal(&order_data.fee_amount),
cancellation_timestamp: None,
class: match order_data.fee_amount.is_zero() {
true => OrderClass::Limit,
Expand Down Expand Up @@ -925,7 +924,6 @@ mod test {
settlement_contract: ByteArray(settlement_contract.0),
sell_token_balance: sell_token_source_into(expected_order_data.sell_token_balance),
buy_token_balance: buy_token_destination_into(expected_order_data.buy_token_balance),
full_fee_amount: u256_to_big_decimal(&expected_order_data.fee_amount),
cancellation_timestamp: None,
};
assert_eq!(onchain_order_placement, expected_onchain_order_placement);
Expand Down Expand Up @@ -1036,7 +1034,6 @@ mod test {
settlement_contract: ByteArray(settlement_contract.0),
sell_token_balance: sell_token_source_into(expected_order_data.sell_token_balance),
buy_token_balance: buy_token_destination_into(expected_order_data.buy_token_balance),
full_fee_amount: u256_to_big_decimal(&U256::zero()),
cancellation_timestamp: None,
};
assert_eq!(onchain_order_placement, expected_onchain_order_placement);
Expand Down
4 changes: 2 additions & 2 deletions crates/autopilot/src/infra/solvers/dto/reveal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ pub struct Request {
/// Unique ID of the solution (per driver competition), to reveal.
pub solution_id: u64,
/// Auction ID in which the specified solution ID is competing.
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub auction_id: Option<i64>,
#[serde_as(as = "serde_with::DisplayFromStr")]
pub auction_id: i64,
}

#[serde_as]
Expand Down
4 changes: 2 additions & 2 deletions crates/autopilot/src/infra/solvers/dto/settle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ pub struct Request {
/// The last block number in which the solution TX can be included
pub submission_deadline_latest_block: u64,
/// Auction ID in which the specified solution ID is competing.
#[serde_as(as = "Option<serde_with::DisplayFromStr>")]
pub auction_id: Option<i64>,
#[serde_as(as = "serde_with::DisplayFromStr")]
pub auction_id: i64,
}
2 changes: 1 addition & 1 deletion crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ impl RunLoop {
let request = settle::Request {
solution_id,
submission_deadline_latest_block,
auction_id: None, // Requires 2-stage release for API-break change
auction_id,
};
driver
.settle(&request, self.config.max_settlement_transaction_wait)
Expand Down
2 changes: 1 addition & 1 deletion crates/autopilot/src/shadow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl RunLoop {
let revealed = driver
.reveal(&reveal::Request {
solution_id,
auction_id: None, // Requires 2-stage release for API-break change
auction_id: request.id,
})
.await
.map_err(Error::Reveal)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/database/src/jit_orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use {

pub const SELECT: &str = r#"
o.uid, o.owner, o.creation_timestamp, o.sell_token, o.buy_token, o.sell_amount, o.buy_amount,
o.valid_to, o.app_data, o.fee_amount, o.fee_amount AS full_fee_amount, o.kind, o.partially_fillable, o.signature,
o.valid_to, o.app_data, o.fee_amount, o.kind, o.partially_fillable, o.signature,
o.receiver, o.signing_scheme, '\x9008d19f58aabd9ed0d60971565aa8510560ab41'::bytea AS settlement_contract, o.sell_token_balance, o.buy_token_balance,
'liquidity'::OrderClass AS class,
(SELECT COALESCE(SUM(t.buy_amount), 0) FROM trades t WHERE t.order_uid = o.uid) AS sum_buy,
Expand Down
Loading

0 comments on commit e8b91dc

Please sign in to comment.