Skip to content

Commit

Permalink
fix: everything but subscriptions is now http (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
montekki committed Sep 14, 2023
1 parent c06651c commit 831bdf4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
8 changes: 8 additions & 0 deletions bin/withdrawal-finalizer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ pub struct Config {
#[envconfig(from = "ETH_CLIENT_WS_URL")]
pub eth_client_ws_url: Url,

/// L1 HTTP url.
#[envconfig(from = "ETH_CLIENT_HTTP_URL")]
pub eth_client_http_url: Url,

/// Address of the `L1Bridge` contract.
#[envconfig(from = "CONTRACTS_L1_ERC20_BRIDGE_PROXY_ADDR")]
pub l1_erc20_bridge_proxy_addr: Address,
Expand All @@ -34,6 +38,10 @@ pub struct Config {
#[envconfig(from = "API_WEB3_JSON_RPC_WS_URL")]
pub api_web3_json_rpc_ws_url: Url,

/// L2 HTTP Endpoint
#[envconfig(from = "API_WEB3_JSON_RPC_HTTP_URL")]
pub api_web3_json_rpc_http_url: Url,

#[envconfig(from = "DATABASE_URL")]
pub database_url: Url,

Expand Down
25 changes: 4 additions & 21 deletions bin/withdrawal-finalizer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{str::FromStr, sync::Arc, time::Duration};
use envconfig::Envconfig;
use ethers::{
prelude::SignerMiddleware,
providers::{JsonRpcClient, Middleware, Provider, Ws},
providers::{Http, JsonRpcClient, Middleware, Provider},
signers::LocalWallet,
types::U256,
};
Expand Down Expand Up @@ -165,18 +165,11 @@ async fn main() -> Result<()> {
// `ethers-rs`. In the logic of reconnections have to happen as long
// as the application exists; below code configures that number to
// be `usize::MAX` as such.
let provider_l1 =
Provider::<Ws>::connect_with_reconnects(config.eth_client_ws_url.as_ref(), usize::MAX)
.await
.unwrap();
let provider_l1 = Provider::<Http>::try_from(config.eth_client_http_url.as_ref()).unwrap();
let client_l1 = Arc::new(provider_l1);

let provider_l2 = Provider::<Ws>::connect_with_reconnects(
config.api_web3_json_rpc_ws_url.as_str(),
usize::MAX,
)
.await
.unwrap();
let provider_l2 =
Provider::<Http>::try_from(config.api_web3_json_rpc_http_url.as_str()).unwrap();

let client_l2 = Arc::new(provider_l2);

Expand Down Expand Up @@ -285,16 +278,6 @@ async fn main() -> Result<()> {
config.tx_retry_timeout,
finalizer_account_address,
);

let provider_l2 = Provider::<Ws>::connect_with_reconnects(
config.api_web3_json_rpc_ws_url.as_str(),
usize::MAX,
)
.await
.unwrap();

let client_l2 = Arc::new(provider_l2);

let finalizer_handle = tokio::spawn(finalizer.run(client_l2));

tokio::select! {
Expand Down

0 comments on commit 831bdf4

Please sign in to comment.