Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e4c083b
Clean up usage of ethcontract exports
jmg-duarte Dec 15, 2025
1dd3d2a
lints
jmg-duarte Dec 15, 2025
12eab6f
fix driver test issue
jmg-duarte Dec 15, 2025
693126a
comment
jmg-duarte Dec 15, 2025
736b9e6
Migrate RPC calls into alloy
jmg-duarte Dec 15, 2025
a23adf2
fix compilation
jmg-duarte Dec 15, 2025
e690706
fix lint
jmg-duarte Dec 16, 2025
187b2d0
Merge branch 'main' into jmgd/alloy/rpc
jmg-duarte Dec 16, 2025
10c9735
wip
jmg-duarte Dec 17, 2025
6fb3f16
Merge branch 'main' into jmgd/alloy/rpc
jmg-duarte Dec 17, 2025
525129e
fix wrong migrations
jmg-duarte Dec 17, 2025
394c9e7
Merge branch 'jmgd/alloy/rpc' into jmgd/alloy/signer
jmg-duarte Dec 17, 2025
616697c
match signature
jmg-duarte Dec 17, 2025
3e84f43
clippy
jmg-duarte Dec 17, 2025
c147604
Merge branch 'jmgd/alloy/rpc' into jmgd/alloy/signer
jmg-duarte Dec 17, 2025
8a2a26a
Merge branch 'main' into jmgd/alloy/signer
jmg-duarte Dec 17, 2025
a19d78f
Merge branch 'main' into jmgd/alloy/rpc
jmg-duarte Dec 17, 2025
4761f68
Merge branch 'jmgd/alloy/rpc' into jmgd/alloy/signer
jmg-duarte Dec 17, 2025
663b732
Migrate TestAccount to alloy
jmg-duarte Dec 17, 2025
106e1f7
Merge branch 'main' into jmgd/alloy/rpc
jmg-duarte Dec 18, 2025
8e3d7fa
Merge branch 'jmgd/alloy/rpc' into jmgd/alloy/signer
jmg-duarte Dec 18, 2025
461519b
Merge branch 'jmgd/alloy/signer' into jmgd/alloy/account
jmg-duarte Dec 18, 2025
0e6210e
migrate solver accounts to alloy
jmg-duarte Dec 18, 2025
0d5c47d
lints
jmg-duarte Dec 19, 2025
2e1ce01
Merge branch 'main' into jmgd/alloy/solver-account
jmg-duarte Dec 19, 2025
ab57d1b
Fix nonce
jmg-duarte Dec 19, 2025
fdb2ce8
address comment
jmg-duarte Dec 19, 2025
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
3 changes: 1 addition & 2 deletions crates/driver/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use {
},
util::{Bytes, math},
},
ethrpc::alloy::conversions::IntoAlloy,
futures::{StreamExt, future::Either, stream::FuturesUnordered},
itertools::Itertools,
std::{
Expand Down Expand Up @@ -128,7 +127,7 @@ impl Competition {
let mut auction = Arc::unwrap_or_clone(tasks.auction.await);

let settlement_contract = *self.eth.contracts().settlement().address();
let solver_address = self.solver.account().address().into_alloy();
let solver_address = self.solver.address();
let order_sorting_strategies = self.order_sorting_strategies.clone();

// Add the CoW AMM orders to the auction
Expand Down
1 change: 1 addition & 0 deletions crates/driver/src/domain/competition/solution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use {
solver::{ManageNativeToken, Solver},
},
},
alloy::network::TxSigner,
chrono::Utc,
futures::future::try_join_all,
itertools::Itertools,
Expand Down
77 changes: 76 additions & 1 deletion crates/driver/src/domain/eth/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use {
crate::util::{Bytes, conv::u256::U256Ext},
alloy::rpc::types::TransactionRequest,
derive_more::{From, Into},
ethrpc::alloy::conversions::{IntoAlloy, IntoLegacy},
itertools::Itertools,
Expand Down Expand Up @@ -92,8 +93,71 @@ impl From<AccessList> for web3::types::AccessList {
}
}

impl IntoIterator for AccessList {
type IntoIter = std::collections::hash_map::IntoIter<Address, HashSet<StorageKey>>;
type Item = (Address, HashSet<StorageKey>);

fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}

impl<I> FromIterator<(Address, I)> for AccessList
where
I: IntoIterator<Item = B256>,
{
fn from_iter<T: IntoIterator<Item = (Address, I)>>(iter: T) -> Self {
Self(
iter.into_iter()
.map(|(address, i)| {
(
address,
i.into_iter().map(StorageKey).collect::<HashSet<_>>(),
)
})
.collect(),
)
}
}

impl From<alloy::eips::eip2930::AccessList> for AccessList {
fn from(value: alloy::eips::eip2930::AccessList) -> Self {
Self(
value
.0
.into_iter()
.map(|item| {
(
item.address,
item.storage_keys
.into_iter()
.map(StorageKey)
.collect::<HashSet<_>>(),
)
})
.collect(),
)
}
}

impl From<AccessList> for alloy::eips::eip2930::AccessList {
fn from(value: AccessList) -> Self {
Self(
value
.into_iter()
.map(
|(address, storage_keys)| alloy::eips::eip2930::AccessListItem {
address,
storage_keys: storage_keys.into_iter().map(|k| k.0).collect(),
},
)
.collect(),
)
}
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Into, From)]
struct StorageKey(pub B256);
pub struct StorageKey(pub B256);

// TODO This type should probably use Ethereum::is_contract to verify during
// construction that it does indeed point to a contract
Expand Down Expand Up @@ -377,6 +441,17 @@ impl std::fmt::Debug for Tx {
}
}

impl From<Tx> for TransactionRequest {
fn from(value: Tx) -> Self {
TransactionRequest::default()
.from(value.from)
.to(value.to)
.value(value.value.0)
.input(value.input.0.into())
.access_list(value.access_list.into())
}
}

impl Tx {
pub fn set_access_list(self, access_list: AccessList) -> Self {
Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/driver/src/domain/mempools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl Mempools {
mempool: &infra::mempool::Mempool,
original_tx_gas_price: eth::GasPrice,
solver: &Solver,
nonce: eth::U256,
nonce: u64,
) -> Result<TxId, Error> {
let fallback_gas_price = original_tx_gas_price * GAS_PRICE_BUMP;
let replacement_gas_price = self
Expand Down Expand Up @@ -319,7 +319,7 @@ impl Mempools {
&self,
mempool: &infra::Mempool,
solver: &Solver,
nonce: eth::U256,
nonce: u64,
) -> anyhow::Result<Option<eth::GasPrice>> {
let pending_tx = match mempool
.find_pending_tx_in_mempool(solver.address(), nonce)
Expand Down
34 changes: 18 additions & 16 deletions crates/driver/src/infra/config/file/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use {
mempool,
notify,
simulator,
solver::{self, BadTokenDetection, SolutionMerging},
solver::{self, Account, BadTokenDetection, SolutionMerging},
},
},
alloy::signers::{aws::AwsSigner, local::PrivateKeySigner},
chain::Chain,
ethrpc::alloy::conversions::IntoLegacy,
futures::future::join_all,
number::conversions::big_decimal_to_big_rational,
std::path::Path,
Expand Down Expand Up @@ -52,22 +52,24 @@ pub async fn load(chain: Chain, path: &Path) -> infra::Config {
);
infra::Config {
solvers: join_all(config.solvers.into_iter().map(|solver_config| async move {
let account = match solver_config.account {
file::Account::PrivateKey(private_key) => ethcontract::Account::Offline(
ethcontract::PrivateKey::from_raw(private_key.0).unwrap(),
None,
),
file::Account::Kms(key_id) => {
let config = ethcontract::aws_config::load_from_env().await;
let account =
ethcontract::transaction::kms::Account::new((&config).into(), &key_id.0)
.await
.unwrap_or_else(|_| panic!("Unable to load KMS account {key_id:?}"));
ethcontract::Account::Kms(account, None)
let account: Account = match solver_config.account {
file::Account::PrivateKey(private_key) => {
PrivateKeySigner::from_bytes(&private_key)
.expect(
"private key should
be valid",
)
.into()
}
file::Account::Address(address) => {
ethcontract::Account::Local(address.into_legacy(), None)
file::Account::Kms(arn) => {
let sdk_config = alloy::signers::aws::aws_config::load_from_env().await;
let client = alloy::signers::aws::aws_sdk_kms::Client::new(&sdk_config);
AwsSigner::new(client, arn.0, config.chain_id)
.await
.expect("unable to load kms account {arn:?}")
.into()
}
file::Account::Address(address) => Account::Address(address),
};
solver::Config {
endpoint: solver_config.endpoint,
Expand Down
18 changes: 14 additions & 4 deletions crates/driver/src/infra/config/file/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use load::load;
use {
crate::{domain::eth, infra, util::serialize},
alloy::primitives::Address,
alloy::{eips::BlockNumberOrTag, primitives::Address},
number::serialization::HexOrDecimalU256,
reqwest::Url,
serde::{Deserialize, Deserializer, Serialize},
Expand Down Expand Up @@ -144,6 +144,16 @@ impl From<BlockNumber> for web3::types::BlockNumber {
}
}

impl From<BlockNumber> for BlockNumberOrTag {
fn from(value: BlockNumber) -> Self {
match value {
BlockNumber::Pending => Self::Pending,
BlockNumber::Latest => Self::Latest,
BlockNumber::Earliest => Self::Earliest,
}
}
}

#[serde_as]
#[derive(Debug, Deserialize)]
#[serde(rename_all = "kebab-case")]
Expand Down Expand Up @@ -332,9 +342,9 @@ enum Account {
PrivateKey(eth::B256),
/// AWS KMS is used to sign transactions. Expects the key identifier.
Kms(#[serde_as(as = "serde_with::DisplayFromStr")] Arn),
/// An address is used to identify the account for signing, relying on the
/// connected node's account management features. This can also be used to
/// start the driver in a dry-run mode.
/// Used to start the driver in the dry-run mode. This account type is
/// *unable* to sign transactions as alloy does not support *implicit*
/// node-side signing.
Address(eth::Address),
}

Expand Down
Loading
Loading