Skip to content

Commit

Permalink
fix: fastlane integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Vid201 committed Oct 31, 2024
1 parent 137b489 commit 4ea56f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
18 changes: 11 additions & 7 deletions bin/silius/src/bundler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ use silius_metrics::{launch_metrics_exporter, mempool::MetricsHandler};
use silius_primitives::{
bundler::BundleStrategy,
constants::{
entry_point, fastlane_relay_endpoints, flashbots_relay_endpoints,
entry_point,
fastlane_relay_endpoints::FASTLANE_POLYGON,
flashbots_relay_endpoints,
storage::DATABASE_FOLDER_NAME,
supported_chains::CHAINS,
validation::reputation::{
BAN_SLACK, MIN_INCLUSION_RATE_DENOMINATOR, MIN_UNSTAKE_DELAY, THROTTLING_SLACK,
},
},
provider::BlockStream,
provider::{create_http_provider, BlockStream},
reputation::ReputationEntry,
simulation::CodeHash,
UserOperationHash, UserOperationSigned, Wallet,
Expand All @@ -48,6 +50,7 @@ use std::{
net::SocketAddr,
str::FromStr,
sync::Arc,
time::Duration,
};
use tracing::{info, warn};

Expand Down Expand Up @@ -234,16 +237,17 @@ where
);
}
BundleStrategy::Fastlane => {
let relay_endpoints: Vec<String> =
let relay_endpoint: String =
match chain_conn.named().expect("Fastlane is only supported on Polygon") {
NamedChain::Polygon => {
vec![fastlane_relay_endpoints::FASTLANE_POLYGON.into()]
}
NamedChain::Polygon => FASTLANE_POLYGON.into(),
_ => panic!("Fastlane is only supported on Polygon"),
};

let relay_client =
create_http_provider(&relay_endpoint, Duration::from_millis(75)).await?;
let client =
Arc::new(FastlaneClient::new(eth_client.clone(), relay_endpoints, wallet.clone()));
Arc::new(FastlaneClient::new(eth_client.clone(), relay_client, wallet.clone()));

bundler_service_run(
SocketAddr::new(args.bundler_addr, args.bundler_port),
wallet,
Expand Down
20 changes: 9 additions & 11 deletions crates/bundler/src/fastlane.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::bundler::SendBundleOp;
use ethers::{
middleware::SignerMiddleware,
providers::Middleware,
providers::{Http, Middleware, Provider},
signers::LocalWallet,
types::{
transaction::{
Expand All @@ -12,14 +12,14 @@ use ethers::{
},
};
use silius_primitives::{simulation::StorageMap, Wallet};
use std::{collections::HashMap, sync::Arc, time::Duration};
use std::{collections::HashMap, sync::Arc};
use tracing::trace;

/// A type alias for the Ethereum Conditional Signer client
#[derive(Clone)]
pub struct FastlaneClient<M> {
pub client: SignerMiddleware<Arc<M>, LocalWallet>,
pub relay_endpoints: Vec<String>,
pub relay_client: Provider<Http>,
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -69,11 +69,8 @@ where
}
}

let tx = self
.client
.send_raw_transaction_conditional(signed_tx, prefix, options)
.await?
.interval(Duration::from_millis(75));
let tx =
self.relay_client.send_raw_transaction_conditional(signed_tx, prefix, options).await?;
let tx_hash = tx.tx_hash();

let tx_receipt = tx.await?;
Expand All @@ -92,12 +89,13 @@ where
///
/// # Arguments
/// * `eth_client` - Connection to the Ethereum execution client
/// * `relay_client` - Connection to the Fastlane relay client
/// * `wallet` - A [Wallet](Wallet) instance
///
/// # Returns
/// * `ConditionalClient` - A [Ethereum Signer Middleware](ConditionalClient)
pub fn new(eth_client: Arc<M>, relay_endpoints: Vec<String>, wallet: Wallet) -> Self {
let signer = SignerMiddleware::new(eth_client, wallet.signer);
Self { client: signer, relay_endpoints }
pub fn new(eth_client: Arc<M>, relay_client: Provider<Http>, wallet: Wallet) -> Self {
let signer = SignerMiddleware::new(eth_client, wallet.clone().signer);
Self { client: signer, relay_client }
}
}
1 change: 0 additions & 1 deletion crates/primitives/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub async fn create_http_provider(
poll_interval: Duration,
) -> eyre::Result<Provider<Http>> {
let provider = Provider::<Http>::try_from(addr)?;

Ok(provider.interval(poll_interval))
}

Expand Down

0 comments on commit 4ea56f9

Please sign in to comment.