Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Solana Libs #147

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
3,378 changes: 2,149 additions & 1,229 deletions Cargo.lock

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ members = [
resolver = "1"

[workspace.package]
version = "0.2.0"
version = "0.3.0"
authors = ["Jito Network <[email protected]>"]
repository = "https://github.com/jito-foundation/jito-relayer"
homepage = "https://jito.network/"
license = "Apache-2.0"
edition = "2021"

[workspace.dependencies]
agave-validator = "2.0.22"
axum = "0.5.17"
bincode = "1.3.3"
bytes = "1.4.0"
Expand All @@ -34,12 +35,12 @@ futures-util = "0.3"
histogram = "0.6.9"
hostname = "0.3"
itertools = "0.10.5"
jito-block-engine = { path = "block_engine", version = "=0.2.0" }
jito-core = { path = "core", version = "=0.2.0" }
jito-protos = { path = "jito-protos", version = "=0.2.0" }
jito-relayer = { path = "relayer", version = "=0.2.0" }
jito-relayer-web = { path = "web", version = "=0.2.0" }
jito-rpc = { path = "rpc", version = "=0.2.0" }
jito-block-engine = { path = "block_engine", version = "=0.3.0" }
jito-core = { path = "core", version = "=0.3.0" }
jito-protos = { path = "jito-protos", version = "=0.3.0" }
jito-relayer = { path = "relayer", version = "=0.3.0" }
jito-relayer-web = { path = "web", version = "=0.3.0" }
jito-rpc = { path = "rpc", version = "=0.3.0" }
jwt = { version = "0.16.0", features = ["openssl"] }
keyed_priority_queue = "0.4.1"
lazy_static = "1.4.0"
Expand All @@ -57,20 +58,19 @@ serde = { version = "1.0.160", features = ["derive"] }
serde_json = "1.0.96"
serde_yaml = "0.9.32"
sha2 = "0.10.6"
solana-address-lookup-table-program = "=1.18.22"
solana-client = "=1.18.22"
solana-core = "=1.18.22"
solana-gossip = "=1.18.22"
solana-measure = "=1.18.22"
solana-metrics = "=1.18.22"
solana-net-utils = "=1.18.22"
solana-perf = "=1.18.22"
solana-program = "=1.18.22"
solana-rayon-threadlimit = "=1.18.22"
solana-runtime = "=1.18.22"
solana-sdk = "=1.18.22"
solana-streamer = "=1.18.22"
solana-validator = "=1.18.22"
solana-address-lookup-table-program = "2.0.22"
solana-client = "2.0.22"
solana-core = "2.0.22"
solana-gossip = "2.0.22"
solana-measure = "2.0.22"
solana-metrics = "2.0.22"
solana-net-utils = "2.0.22"
solana-perf = "2.0.22"
solana-program = "2.0.22"
solana-rayon-threadlimit = "2.0.22"
solana-runtime = "2.0.22"
solana-sdk = "2.0.22"
solana-streamer = "2.0.22"
thiserror = "1.0.40"
tikv-jemallocator = { version = "0.4", features = ["profiling"] }
tokio = { version = "1.29.1", features = ["full"] }
Expand Down
50 changes: 33 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,52 @@
# syntax=docker/dockerfile:1.4.0
FROM rust:1.66.0-slim-bullseye as builder
FROM rust:1.64-slim-bullseye as builder

RUN set -x \
&& apt-get -qq update \
&& apt-get -qq -y install \
clang \
cmake \
libudev-dev \
unzip \
libssl-dev \
pkg-config \
zlib1g-dev \
curl
RUN rustup component add rustfmt && update-ca-certificates

ENV PROTOC_VERSION 21.12
# Add Google Protocol Buffers for Libra's metrics library.
ENV PROTOC_VERSION 3.8.0
ENV PROTOC_ZIP protoc-$PROTOC_VERSION-linux-x86_64.zip
RUN curl -Ss -OL https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP \

RUN set -x \
&& apt update \
&& apt install -y \
clang \
cmake \
libudev-dev \
make \
unzip \
libssl-dev \
pkg-config \
zlib1g-dev \
curl \
&& rustup component add rustfmt \
&& rustup component add clippy \
&& rustc --version \
&& cargo --version \
&& curl -OL https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP \
&& unzip -o $PROTOC_ZIP -d /usr/local bin/protoc \
&& unzip -o $PROTOC_ZIP -d /usr/local include/* \
&& rm -f $PROTOC_ZIP

ENV HOME=/home/root
WORKDIR $HOME/app
COPY . .
RUN mkdir -p docker-output

ARG ci_commit
# NOTE: Keep this here before build since variable is referenced during CI build step.
ENV CI_COMMIT=$ci_commit

ARG debug

# cache these directories for reuse
# see: https://docs.docker.com/build/cache/#use-the-dedicated-run-cache
RUN --mount=type=cache,mode=0777,target=/home/root/app/target \
--mount=type=cache,mode=0777,target=/usr/local/cargo/registry \
--mount=type=cache,mode=0777,target=/usr/local/cargo/git \
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --release && cp target/release/jito-* ./
if [ "$debug" = "false" ] ; then \
./cargo stable build --release && cp target/release/jito-* ./; \
else \
RUSTFLAGS='-g -C force-frame-pointers=yes' ./cargo stable build --release && cp target/release/jito-* ./; \
fi

FROM debian:bullseye-slim as jito-transaction-relayer
RUN apt-get -qq update && apt-get -qq -y install ca-certificates libssl1.1 && rm -rf /var/lib/apt/lists/*
Expand Down
2 changes: 1 addition & 1 deletion block_engine/src/block_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ fn is_aoi_in_static_keys(
.iter()
.enumerate()
.any(|(idx, acc)| {
(tx.message.is_maybe_writable(idx) && accounts_of_interest.cache_get(acc).is_some())
(tx.message.is_maybe_writable(idx, None) && accounts_of_interest.cache_get(acc).is_some())
// note: can't detect CPIs without execution, so aggressively forward txs than contain account in POI
|| programs_of_interest.cache_get(acc).is_some()
})
Expand Down
28 changes: 28 additions & 0 deletions cargo
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# shellcheck source=ci/rust-version.sh
here=$(dirname "$0")

toolchain=
case "$1" in
stable)
source "${here}"/ci/rust-version.sh stable
# shellcheck disable=SC2054 # rust_stable is sourced from rust-version.sh
toolchain="$rust_stable"
shift
;;
nightly)
source "${here}"/ci/rust-version.sh nightly
# shellcheck disable=SC2054 # rust_nightly is sourced from rust-version.sh
toolchain="$rust_nightly"
shift
;;
*)
source "${here}"/ci/rust-version.sh stable
# shellcheck disable=SC2054 # rust_stable is sourced from rust-version.sh
toolchain="$rust_stable"
;;
esac

set -x
exec cargo "+${toolchain}" "${@}"
13 changes: 13 additions & 0 deletions ci/read-cargo-variable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# source this file
jedleggett marked this conversation as resolved.
Show resolved Hide resolved
readCargoVariable() {
declare variable="$1"
declare Cargo_toml="$2"

while read -r name equals value _; do
if [[ $name = "$variable" && $equals = = ]]; then
echo "${value//\"/}"
return
fi
done < <(cat "$Cargo_toml")
echo "Unable to locate $variable in $Cargo_toml" 1>&2
}
69 changes: 69 additions & 0 deletions ci/rust-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#
jedleggett marked this conversation as resolved.
Show resolved Hide resolved
# This file maintains the rust versions for use by CI.
#
# Obtain the environment variables without any automatic toolchain updating:
# $ source ci/rust-version.sh
#
# Obtain the environment variables updating both stable and nightly, only stable, or
# only nightly:
# $ source ci/rust-version.sh all
# $ source ci/rust-version.sh stable
# $ source ci/rust-version.sh nightly

# Then to build with either stable or nightly:
# $ cargo +"$rust_stable" build
# $ cargo +"$rust_nightly" build
#

if [[ -n $RUST_STABLE_VERSION ]]; then
stable_version="$RUST_STABLE_VERSION"
else
# read rust version from rust-toolchain.toml file
base="$(dirname "${BASH_SOURCE[0]}")"
# pacify shellcheck: cannot follow dynamic path
# shellcheck disable=SC1090,SC1091
source "$base/read-cargo-variable.sh"
stable_version=$(readCargoVariable channel "$base/../rust-toolchain.toml")
fi

if [[ -n $RUST_NIGHTLY_VERSION ]]; then
nightly_version="$RUST_NIGHTLY_VERSION"
else
nightly_version=2024-08-08
fi


export rust_stable="$stable_version"

export rust_nightly=nightly-"$nightly_version"

[[ -z $1 ]] || (

rustup_install() {
declare toolchain=$1
if ! cargo +"$toolchain" -V > /dev/null; then
echo "$0: Missing toolchain? Installing...: $toolchain" >&2
rustup install "$toolchain" --no-self-update
rustup component add rustfmt --toolchain "$toolchain"
cargo +"$toolchain" -V
fi
}

set -e
cd "$(dirname "${BASH_SOURCE[0]}")"
case $1 in
stable)
rustup_install "$rust_stable"
;;
nightly)
rustup_install "$rust_nightly"
;;
all)
rustup_install "$rust_stable"
rustup_install "$rust_nightly"
;;
*)
echo "$0: Note: ignoring unknown argument: $1" >&2
;;
esac
)
12 changes: 7 additions & 5 deletions core/src/tpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! multi-stage transaction processing pipeline in software.
use std::{
collections::HashMap,
net::{IpAddr, UdpSocket},
net::UdpSocket,
sync::{atomic::AtomicBool, Arc, RwLock},
thread,
thread::JoinHandle,
Expand Down Expand Up @@ -30,6 +30,7 @@ pub const DEFAULT_TPU_COALESCE_MS: u64 = 5;

// allow multiple connections for NAT and any open/close overlap
pub const MAX_QUIC_CONNECTIONS_PER_IP: usize = 8;
pub const MAX_CONNECTIONS_PER_IPADDR_PER_MIN: u64 = 64;

#[derive(Debug)]
pub struct TpuSockets {
Expand All @@ -51,8 +52,6 @@ impl Tpu {
sockets: TpuSockets,
exit: &Arc<AtomicBool>,
keypair: &Keypair,
tpu_ip: &IpAddr,
tpu_fwd_ip: &IpAddr,
rpc_load_balancer: &Arc<LoadBalancer>,
max_unstaked_quic_connections: usize,
max_staked_quic_connections: usize,
Expand Down Expand Up @@ -82,17 +81,18 @@ impl Tpu {
.into_iter()
.map(|sock| {
spawn_server(
"quic_streamer_tpu",
"quic_streamer_tpu",
sock,
keypair,
*tpu_ip,
tpu_sender.clone(),
exit.clone(),
MAX_QUIC_CONNECTIONS_PER_PEER,
staked_nodes.clone(),
max_staked_quic_connections,
max_unstaked_quic_connections,
DEFAULT_MAX_STREAMS_PER_MS,
MAX_CONNECTIONS_PER_IPADDR_PER_MIN,
DEFAULT_WAIT_FOR_CHUNK_TIMEOUT,
Duration::from_millis(DEFAULT_TPU_COALESCE_MS),
)
Expand All @@ -106,17 +106,18 @@ impl Tpu {
.into_iter()
.map(|sock| {
spawn_server(
"quic_streamer_tpu_forwards",
"quic_streamer_tpu_forwards",
sock,
keypair,
*tpu_fwd_ip,
tpu_forwards_sender.clone(),
exit.clone(),
MAX_QUIC_CONNECTIONS_PER_PEER,
staked_nodes.clone(),
max_staked_quic_connections.saturating_add(max_unstaked_quic_connections),
0, // Prevent unstaked nodes from forwarding transactions
DEFAULT_MAX_STREAMS_PER_MS,
MAX_CONNECTIONS_PER_IPADDR_PER_MIN,
DEFAULT_WAIT_FOR_CHUNK_TIMEOUT,
Duration::from_millis(DEFAULT_TPU_COALESCE_MS),
)
Expand All @@ -134,6 +135,7 @@ impl Tpu {
tpu_receiver,
TransactionSigVerifier::new(banking_packet_sender),
"tpu-verifier",
"tpu-verifier",
);

(
Expand Down
7 changes: 6 additions & 1 deletion f
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ GIT_SHA="$(git describe --always --dirty)"

echo "Git hash: $GIT_SHA"

DOCKER_BUILDKIT=1 docker build -t jitolabs/jito-transaction-relayer . --progress=plain
DEBUG_FLAGS=${1-false}

DOCKER_BUILDKIT=1 docker build \
--build-arg debug=$DEBUG_FLAGS \
--build-arg ci_commit=$GIT_SHA \
-t jitolabs/jito-transaction-relayer . --progress=plain

# Creates a temporary container, copies binaries built inside container and removes the temporary container.
docker rm temp || true
Expand Down
9 changes: 5 additions & 4 deletions relayer/src/auth_interceptor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{net::IpAddr, str::FromStr, sync::Arc};

use chrono::{NaiveDateTime, Utc};
use chrono::{DateTime, NaiveDateTime, Utc};
use jwt::{AlgorithmType, Header, PKeyWithDigest, Token, Verified, VerifyWithKey};
use log::*;
use openssl::pkey::Public;
Expand Down Expand Up @@ -33,8 +33,9 @@ impl From<&DeSerClaims> for Claims {
Self {
client_ip: IpAddr::from_str(&de_ser_claims.client_ip).unwrap(),
client_pubkey: Pubkey::from_str(&de_ser_claims.client_pubkey).unwrap(),
expires_at_utc: NaiveDateTime::from_timestamp_opt(de_ser_claims.expires_at_unix_ts, 0)
.unwrap(),
expires_at_utc: DateTime::from_timestamp(de_ser_claims.expires_at_unix_ts, 0)
.unwrap()
.naive_utc(),
}
}
}
Expand All @@ -51,7 +52,7 @@ impl From<Claims> for DeSerClaims {
Self {
client_ip: claims.client_ip.to_string(),
client_pubkey: claims.client_pubkey.to_string(),
expires_at_unix_ts: claims.expires_at_utc.timestamp(),
expires_at_unix_ts: claims.expires_at_utc.and_utc().timestamp(),
}
}
}
Expand Down
Loading
Loading