Skip to content

Commit

Permalink
Encode jit orders function
Browse files Browse the repository at this point in the history
  • Loading branch information
squadgazzz committed Nov 22, 2024
1 parent 5b27c13 commit 695a679
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
12 changes: 6 additions & 6 deletions crates/driver/src/boundary/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ fn web3(eth: &Ethereum) -> Web3 {

/// Builds a web3 client that buffers requests and sends them in a
/// batch call.
pub fn buffered_web3_client(ethrpc: &Url, ethrpc_args: &shared::ethrpc::Arguments) -> Web3 {
web3_client(ethrpc, ethrpc_args)
pub fn buffered_web3_client(ethrpc_url: &Url, ethrpc_args: &shared::ethrpc::Arguments) -> Web3 {
web3_client(ethrpc_url, ethrpc_args)
}

/// Builds a web3 client that sends requests one by one.
pub fn unbuffered_web3_client(ethrpc: &Url) -> Web3 {
pub fn unbuffered_web3_client(ethrpc_url: &Url) -> Web3 {
web3_client(
ethrpc,
ethrpc_url,
&shared::ethrpc::Arguments {
ethrpc_max_batch_size: 0,
ethrpc_max_concurrent_requests: 0,
Expand All @@ -61,10 +61,10 @@ pub fn unbuffered_web3_client(ethrpc: &Url) -> Web3 {
)
}

fn web3_client(ethrpc: &Url, ethrpc_args: &shared::ethrpc::Arguments) -> Web3 {
fn web3_client(ethrpc_url: &Url, ethrpc_args: &shared::ethrpc::Arguments) -> Web3 {
let http_factory =
shared::http_client::HttpClientFactory::new(&shared::http_client::Arguments {
http_timeout: std::time::Duration::from_secs(10),
});
shared::ethrpc::web3(ethrpc_args, &http_factory, ethrpc, "base")
shared::ethrpc::web3(ethrpc_args, &http_factory, ethrpc_url, "base")
}
5 changes: 3 additions & 2 deletions crates/driver/src/infra/blockchain/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl Contracts {
chain: chain::Id,
addresses: Addresses,
block_stream: CurrentBlockWatcher,
ethrpc_args: &shared::ethrpc::Arguments,
archive_node_url: Option<&Url>,
) -> Result<Self, Error> {
let address_for = |contract: &ethcontract::Contract,
Expand Down Expand Up @@ -67,8 +68,8 @@ impl Contracts {
);

let archive_node_web3 = archive_node_url.as_ref().map_or(web3.clone(), |url| {
boundary::buffered_web3_client(url, &shared::ethrpc::Arguments::default())
}); // todo: provide it from the config
boundary::buffered_web3_client(url, ethrpc_args)
});
let mut cow_amm_registry = cow_amm::Registry::new(archive_node_web3);
for config in addresses.cow_amms {
cow_amm_registry
Expand Down
2 changes: 2 additions & 0 deletions crates/driver/src/infra/blockchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl Ethereum {
rpc: Rpc,
addresses: contracts::Addresses,
gas: Arc<GasPriceEstimator>,
ethrpc_args: &shared::ethrpc::Arguments,
archive_node_url: Option<&Url>,
) -> Self {
let Rpc { web3, chain, url } = rpc;
Expand All @@ -88,6 +89,7 @@ impl Ethereum {
chain,
addresses,
current_block_stream.clone(),
ethrpc_args,
archive_node_url,
)
.await
Expand Down
9 changes: 7 additions & 2 deletions crates/driver/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async fn run_with(args: cli::Args, addr_sender: Option<oneshot::Sender<SocketAdd
tracing::info!("running driver with {config:#?}");

let (shutdown_sender, shutdown_receiver) = tokio::sync::oneshot::channel();
let eth = ethereum(&config, ethrpc).await;
let eth = ethereum(&config, ethrpc, &args.ethrpc_args).await;
let serve = Api {
solvers: solvers(&config, &eth).await,
liquidity: liquidity(&config, &eth).await,
Expand Down Expand Up @@ -130,7 +130,11 @@ async fn ethrpc(args: &cli::Args) -> blockchain::Rpc {
.expect("connect ethereum RPC")
}

async fn ethereum(config: &infra::Config, ethrpc: blockchain::Rpc) -> Ethereum {
async fn ethereum(
config: &infra::Config,
ethrpc: blockchain::Rpc,
ethrpc_args: &shared::ethrpc::Arguments,
) -> Ethereum {
let gas = Arc::new(
blockchain::GasPriceEstimator::new(ethrpc.web3(), &config.gas_estimator, &config.mempools)
.await
Expand All @@ -140,6 +144,7 @@ async fn ethereum(config: &infra::Config, ethrpc: blockchain::Rpc) -> Ethereum {
ethrpc,
config.contracts.clone(),
gas,
ethrpc_args,
config.archive_node_url.as_ref(),
)
.await
Expand Down
3 changes: 2 additions & 1 deletion crates/driver/src/tests/setup/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl Solver {
.collect::<HashMap<_, _>>();

let url = config.blockchain.web3_url.parse().unwrap();
let rpc = infra::blockchain::Rpc::new(&url, &shared::ethrpc::Arguments::default())
let rpc = infra::blockchain::Rpc::new(&url, &Default::default())
.await
.unwrap();
let gas = Arc::new(
Expand Down Expand Up @@ -411,6 +411,7 @@ impl Solver {
cow_amms: vec![],
},
gas,
&Default::default(),
None,
)
.await;
Expand Down

0 comments on commit 695a679

Please sign in to comment.