From 695a6793b7ab9a793691ca22e7a979fe3fe7b354 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 22 Nov 2024 18:01:27 +0000 Subject: [PATCH] Encode jit orders function --- crates/driver/src/boundary/mod.rs | 12 ++++++------ crates/driver/src/infra/blockchain/contracts.rs | 5 +++-- crates/driver/src/infra/blockchain/mod.rs | 2 ++ crates/driver/src/run.rs | 9 +++++++-- crates/driver/src/tests/setup/solver.rs | 3 ++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/crates/driver/src/boundary/mod.rs b/crates/driver/src/boundary/mod.rs index c6aacc1f74..91cdc6d0fc 100644 --- a/crates/driver/src/boundary/mod.rs +++ b/crates/driver/src/boundary/mod.rs @@ -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, @@ -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") } diff --git a/crates/driver/src/infra/blockchain/contracts.rs b/crates/driver/src/infra/blockchain/contracts.rs index 664793a7ed..b9c26ad97e 100644 --- a/crates/driver/src/infra/blockchain/contracts.rs +++ b/crates/driver/src/infra/blockchain/contracts.rs @@ -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 { let address_for = |contract: ðcontract::Contract, @@ -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 diff --git a/crates/driver/src/infra/blockchain/mod.rs b/crates/driver/src/infra/blockchain/mod.rs index 76fa77deac..e49427346c 100644 --- a/crates/driver/src/infra/blockchain/mod.rs +++ b/crates/driver/src/infra/blockchain/mod.rs @@ -74,6 +74,7 @@ impl Ethereum { rpc: Rpc, addresses: contracts::Addresses, gas: Arc, + ethrpc_args: &shared::ethrpc::Arguments, archive_node_url: Option<&Url>, ) -> Self { let Rpc { web3, chain, url } = rpc; @@ -88,6 +89,7 @@ impl Ethereum { chain, addresses, current_block_stream.clone(), + ethrpc_args, archive_node_url, ) .await diff --git a/crates/driver/src/run.rs b/crates/driver/src/run.rs index 6eefa9c92c..973becda1e 100644 --- a/crates/driver/src/run.rs +++ b/crates/driver/src/run.rs @@ -50,7 +50,7 @@ async fn run_with(args: cli::Args, addr_sender: Option 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 @@ -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 diff --git a/crates/driver/src/tests/setup/solver.rs b/crates/driver/src/tests/setup/solver.rs index 9194ab8a58..d9e1dc0e33 100644 --- a/crates/driver/src/tests/setup/solver.rs +++ b/crates/driver/src/tests/setup/solver.rs @@ -381,7 +381,7 @@ impl Solver { .collect::>(); 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( @@ -411,6 +411,7 @@ impl Solver { cow_amms: vec![], }, gas, + &Default::default(), None, ) .await;