Skip to content

Commit

Permalink
fix: no longer assert the BE sends back UUIDs as bundle ids (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
segfaultdoc authored Jun 21, 2023
1 parent bad5c1a commit 16ac3ad
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/backrun/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ solana-transaction-status = { git = "https://github.com/jito-foundation/jito-sol
thiserror = "1.0.40"
tokio = "1.27.0"
tonic = { version = "0.8.3", features = ["tls", "tls-roots", "tls-webpki-roots"] }
uuid = { version = "1.0.0", features = ["v4", "fast-rng"] }
5 changes: 2 additions & 3 deletions examples/backrun/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use jito_protos::{
};
use jito_searcher_client::{
client_interceptor::ClientInterceptor, cluster_data_impl::ClusterDataImpl, grpc_connect,
utils::derive_tip_accounts, ClusterData, SearcherClient, SearcherClientError,
utils::derive_tip_accounts, BundleId, ClusterData, SearcherClient, SearcherClientError,
SearcherClientResult,
};
use log::*;
Expand All @@ -44,7 +44,6 @@ use tokio::{
time::{interval, sleep},
};
use tonic::{codegen::InterceptedService, transport::Channel, Status};
use uuid::Uuid;

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
Expand Down Expand Up @@ -112,7 +111,7 @@ async fn send_bundles(
InterceptedService<Channel, ClientInterceptor>,
>,
bundles: &[BundledTransactions],
) -> Result<Vec<result::Result<Uuid, SearcherClientError>>> {
) -> Result<Vec<result::Result<BundleId, SearcherClientError>>> {
let mut futs = vec![];
for b in bundles {
let txs = b
Expand Down
2 changes: 1 addition & 1 deletion protos/mev-protos
Submodule mev-protos updated 1 files
+28 −2 bundle.proto
1 change: 0 additions & 1 deletion searcher_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ solana-sdk = { git = "https://github.com/jito-foundation/jito-solana.git", tag =
thiserror = "1.0.39"
tokio = { version = "1.14.1", features = ["full"] }
tonic = { version = "0.8.3", features = ["tls"] }
uuid = { version = "1.0.0", features = ["v4", "fast-rng"] }
27 changes: 14 additions & 13 deletions searcher_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ pub mod client_interceptor;
pub mod cluster_data_impl;
pub mod convert;

use std::{
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};

use bincode::serialize;
Expand All @@ -34,18 +31,22 @@ use tonic::{
transport::{Channel, Endpoint},
Status,
};
use uuid::Uuid;

use crate::convert::{proto_packet_from_versioned_tx, versioned_tx_from_packet};

/// BundleId is expected to be a hash of the contained transaction signatures:
/// fn derive_bundle_id(transactions: &[VersionedTransaction]) -> String {
/// let mut hasher = Sha256::new();
/// hasher.update(transactions.iter().map(|tx| tx.signatures[0]).join(","));
/// format!("{:x}", hasher.finalize())
/// }
pub type BundleId = String;

#[derive(Error, Debug)]
pub enum SearcherClientError {
#[error("block-engine transport error {0}")]
BlockEngineTransportError(#[from] transport::Error),

#[error("the Uuid returned from the server is invalid")]
InvalidBundleUuid,

#[error("no upcoming validator is running jito-solana")]
NoUpcomingJitoValidator,

Expand Down Expand Up @@ -97,14 +98,14 @@ where
}

/// Sends the list of transactions as a bundle iff the leader is a jito-solana.
/// Returns the bundle's Uuid generated by the block-engine.
/// Returns the bundle's id.
pub async fn send_bundle(
&self,
transactions: Vec<VersionedTransaction>,
// Defines how many slots to lookahead for a jito-solana validator in order to
// determine whether or not the bundle can be sent.
slot_lookahead: u64,
) -> SearcherClientResult<Uuid> {
) -> SearcherClientResult<BundleId> {
let next_leader_slot = self
.cluster_data
.next_jito_validator()
Expand All @@ -131,7 +132,7 @@ where
})
.await?;

Uuid::from_str(&resp.into_inner().uuid).map_err(|_e| SearcherClientError::InvalidBundleUuid)
Ok(resp.into_inner().uuid)
}

/// Sends transactions through the normal pipeline, regardless of if the leader is running jito-solana.
Expand Down

0 comments on commit 16ac3ad

Please sign in to comment.