Skip to content

Commit 527dd8f

Browse files
authored
Merge branch 'cowprotocol:main' into main
2 parents e1e6690 + 0b4416d commit 527dd8f

File tree

64 files changed

+698
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+698
-529
lines changed

Cargo.lock

Lines changed: 156 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resolver = "3"
33
members = ["crates/*"]
44

55
[workspace.dependencies]
6-
alloy = { git = "https://github.com/alloy-rs/alloy", rev = "c15a4a3c04ce15bfa3796cc449f8407200b7599f", default-features = false }
6+
alloy = { version = "1.0.27", default-features = false }
77
anyhow = "=1.0.76"
88
async-trait = "0.1.80"
99
axum = "0.6"
@@ -81,6 +81,7 @@ opentelemetry = { version = "0.30", features = ["tracing"] }
8181
opentelemetry-otlp = "0.30"
8282
opentelemetry_sdk = "0.30"
8383
orderbook = { path = "crates/orderbook" }
84+
paste = "1.0"
8485
pin-project-lite = "0.2.14"
8586
rate-limit = { path = "crates/rate-limit" }
8687
refunder = { path = "crates/refunder" }

crates/autopilot/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ name = "autopilot"
1515
path = "src/main.rs"
1616

1717
[dependencies]
18+
alloy = { workspace = true }
1819
app-data = { workspace = true }
1920
bytes-hex = { workspace = true }
2021
anyhow = { workspace = true }

crates/autopilot/src/database/ethflow_events/event_retriever.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl EventRetrieving for EthFlowRefundRetriever {
3030
type Event = contracts::cowswap_eth_flow::Event;
3131

3232
fn get_events(&self) -> AllEventsBuilder<DynTransport, Self::Event> {
33-
let mut events = AllEventsBuilder::new(self.web3.clone(), H160::default(), None);
33+
let mut events = AllEventsBuilder::new(self.web3.legacy.clone(), H160::default(), None);
3434
// We want to observe multiple addresses for events.
3535
events.filter = events.filter.address(self.addresses.clone());
3636
// Filter out events that we don't want to listen for in the contract. `Self` is

crates/autopilot/src/database/onchain_order_events/event_retriever.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl EventRetrieving for CoWSwapOnchainOrdersContract {
4040
type Event = cowswap_onchain_orders::Event;
4141

4242
fn get_events(&self) -> AllEventsBuilder<DynTransport, Self::Event> {
43-
let mut events = AllEventsBuilder::new(self.web3.clone(), H160::default(), None);
43+
let mut events = AllEventsBuilder::new(self.web3.legacy.clone(), H160::default(), None);
4444
// We want to observe multiple addresses for events.
4545
events.filter = events.filter.address(self.addresses.clone());
4646
// Filter out events that don't belong to the ABI of `OnchainOrdersContract`.

crates/autopilot/src/database/onchain_order_events/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@ mod test {
793793
contracts::cowswap_onchain_orders::event_data::OrderPlacement as ContractOrderPlacement,
794794
database::{byte_array::ByteArray, onchain_broadcasted_orders::OnchainOrderPlacement},
795795
ethcontract::{Bytes, EventMetadata, H160, U256},
796+
ethrpc::Web3,
796797
model::{
797798
DomainSeparator,
798799
order::{BuyTokenDestination, OrderData, OrderKind, SellTokenSource},
@@ -806,7 +807,6 @@ mod test {
806807
sell_token_source_into,
807808
signing_scheme_into,
808809
},
809-
ethrpc::create_env_test_transport,
810810
fee::FeeParameters,
811811
order_quoting::{MockOrderQuoting, Quote, QuoteData},
812812
},
@@ -1234,7 +1234,7 @@ mod test {
12341234
custom_onchain_order_parser
12351235
.expect_customized_event_data_for_event_index()
12361236
.returning(|_, _, _, _| 1u8);
1237-
let web3 = Web3::new(create_env_test_transport());
1237+
let web3 = Web3::new_from_env();
12381238
let onchain_order_parser = OnchainOrderParser {
12391239
db: Postgres {
12401240
pool: PgPool::connect_lazy("postgresql://").unwrap(),

crates/autopilot/src/infra/blockchain/contracts.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
use {crate::domain, chain::Chain, ethcontract::dyns::DynWeb3, primitive_types::H160};
1+
use {
2+
crate::domain,
3+
chain::Chain,
4+
contracts::alloy::{ChainalysisOracle, InstanceExt},
5+
ethrpc::Web3,
6+
primitive_types::H160,
7+
};
28

39
#[derive(Debug, Clone)]
410
pub struct Contracts {
511
settlement: contracts::GPv2Settlement,
612
signatures: contracts::support::Signatures,
713
weth: contracts::WETH9,
814
balances: contracts::support::Balances,
9-
chainalysis_oracle: Option<contracts::ChainalysisOracle>,
15+
chainalysis_oracle: Option<ChainalysisOracle::Instance>,
1016
trampoline: contracts::HooksTrampoline,
1117

1218
/// The authenticator contract that decides which solver is allowed to
@@ -26,7 +32,7 @@ pub struct Addresses {
2632
}
2733

2834
impl Contracts {
29-
pub async fn new(web3: &DynWeb3, chain: &Chain, addresses: Addresses) -> Self {
35+
pub async fn new(web3: &Web3, chain: &Chain, addresses: Addresses) -> Self {
3036
let address_for = |contract: &ethcontract::Contract, address: Option<H160>| {
3137
address
3238
.or_else(|| deployment_address(contract, chain))
@@ -70,7 +76,9 @@ impl Contracts {
7076
),
7177
);
7278

73-
let chainalysis_oracle = contracts::ChainalysisOracle::deployed(web3).await.ok();
79+
let chainalysis_oracle = ChainalysisOracle::Instance::deployed(&web3.alloy)
80+
.await
81+
.ok();
7482

7583
let settlement_domain_separator = domain::eth::DomainSeparator(
7684
settlement
@@ -122,7 +130,7 @@ impl Contracts {
122130
&self.settlement_domain_separator
123131
}
124132

125-
pub fn chainalysis_oracle(&self) -> &Option<contracts::ChainalysisOracle> {
133+
pub fn chainalysis_oracle(&self) -> &Option<ChainalysisOracle::Instance> {
126134
&self.chainalysis_oracle
127135
}
128136

crates/autopilot/src/infra/blockchain/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use {
22
self::contracts::Contracts,
33
crate::{boundary, domain::eth},
44
chain::Chain,
5-
ethcontract::dyns::DynWeb3,
6-
ethrpc::{block_stream::CurrentBlockWatcher, extensions::DebugNamespace},
5+
ethrpc::{Web3, block_stream::CurrentBlockWatcher, extensions::DebugNamespace},
76
primitive_types::U256,
87
std::time::Duration,
98
thiserror::Error,
@@ -14,7 +13,7 @@ pub mod contracts;
1413

1514
/// An Ethereum RPC connection.
1615
pub struct Rpc {
17-
web3: DynWeb3,
16+
web3: Web3,
1817
chain: Chain,
1918
url: Url,
2019
}
@@ -43,7 +42,7 @@ impl Rpc {
4342
}
4443

4544
/// Returns a reference to the underlying web3 client.
46-
pub fn web3(&self) -> &DynWeb3 {
45+
pub fn web3(&self) -> &Web3 {
4746
&self.web3
4847
}
4948

@@ -56,8 +55,8 @@ impl Rpc {
5655
/// The Ethereum blockchain.
5756
#[derive(Clone)]
5857
pub struct Ethereum {
59-
web3: DynWeb3,
60-
unbuffered_web3: DynWeb3,
58+
web3: Web3,
59+
unbuffered_web3: Web3,
6160
chain: Chain,
6261
current_block: CurrentBlockWatcher,
6362
contracts: Contracts,
@@ -71,8 +70,8 @@ impl Ethereum {
7170
/// Since this type is essential for the program this method will panic on
7271
/// any initialization error.
7372
pub async fn new(
74-
web3: DynWeb3,
75-
unbuffered_web3: DynWeb3,
73+
web3: Web3,
74+
unbuffered_web3: Web3,
7675
chain: &Chain,
7776
url: Url,
7877
addresses: contracts::Addresses,

crates/autopilot/src/infra/persistence/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use {
1818
SellTokenSource as DbSellTokenSource,
1919
SigningScheme as DbSigningScheme,
2020
},
21-
settlement_observations::Observation,
2221
solver_competition_v2::{Order, Solution},
2322
},
2423
domain::auction::order::{
@@ -690,19 +689,6 @@ impl Persistence {
690689
)
691690
.await?;
692691

693-
database::settlement_observations::upsert(
694-
&mut ex,
695-
Observation {
696-
block_number,
697-
log_index,
698-
gas_used: u256_to_big_decimal(&gas.0),
699-
effective_gas_price: u256_to_big_decimal(&gas_price.0.0),
700-
surplus: u256_to_big_decimal(&surplus.0),
701-
fee: u256_to_big_decimal(&fee.0),
702-
},
703-
)
704-
.await?;
705-
706692
store_order_events(
707693
&mut ex,
708694
fee_breakdown.keys().cloned().collect(),

crates/autopilot/src/run.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,9 @@ use {
2626
chain::Chain,
2727
clap::Parser,
2828
contracts::{BalancerV2Vault, IUniswapV3Factory},
29-
ethcontract::{
30-
BlockNumber,
31-
H160,
32-
common::DeploymentInformation,
33-
dyns::DynWeb3,
34-
errors::DeployError,
35-
},
36-
ethrpc::block_stream::block_number_to_block_number_hash,
37-
futures::stream::StreamExt,
29+
ethcontract::{BlockNumber, H160, common::DeploymentInformation, errors::DeployError},
30+
ethrpc::{Web3, block_stream::block_number_to_block_number_hash},
31+
futures::StreamExt,
3832
model::DomainSeparator,
3933
observe::metrics::LivenessChecking,
4034
shared::{
@@ -116,8 +110,8 @@ async fn unbuffered_ethrpc(url: &Url) -> infra::blockchain::Rpc {
116110

117111
#[instrument(skip_all)]
118112
async fn ethereum(
119-
web3: DynWeb3,
120-
unbuffered_web3: DynWeb3,
113+
web3: Web3,
114+
unbuffered_web3: Web3,
121115
chain: &Chain,
122116
url: Url,
123117
contracts: infra::blockchain::contracts::Addresses,

0 commit comments

Comments
 (0)