diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..f567020 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.env +config.toml diff --git a/Cargo.lock b/Cargo.lock index 890a580..11a76b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2452,6 +2452,7 @@ dependencies = [ "itertools 0.10.5", "jsonrpsee-types", "once_cell", + "openssl", "reqwest 0.12.4", "serde", "serde_derive", @@ -2856,6 +2857,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.2.3+3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cff92b6f71555b61bb9315f7c64da3ca43d87531622120fea0195fc761b4843" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.102" @@ -2864,6 +2874,7 @@ checksum = "c597637d56fbc83893a35eb0dd04b2b8e7a50c91e64e9493e398b5df4fb45fa2" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index 5e7aa75..c73bed7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,10 @@ name = "mangorpc-latency-tester" version = "0.1.0" edition = "2021" +[[bin]] +name = "mangorpc-latency-tester" +path = "src/main.rs" + [dependencies] solana-sdk = "1.17.31" solana-rpc-client-api = "1.17.31" @@ -37,3 +41,4 @@ solana-program = "1.17.31" solana-transaction-status = "1.17.31" once_cell = "1.19.0" chrono = "0.4.38" +openssl = { version = "0.10.59", features = ["vendored"] } diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9c035c1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM rust:latest as base +WORKDIR /usr/src/myapp +COPY Cargo.toml Cargo.lock ./ +RUN cargo fetch +COPY src ./src +RUN cargo install --path . --bin mangorpc-latency-tester +FROM debian:bookworm-slim as run +RUN apt-get update && apt-get -y install ca-certificates libc6 libssl3 libssl-dev openssl +COPY --from=0 /usr/local/cargo/bin/mangorpc-latency-tester /usr/local/bin/mangorpc-latency-tester +CMD ["mangorpc-latency-tester", "watch-measure-send-transaction", "--watch-interval-seconds", "21600"] diff --git a/README.md b/README.md index 357720d..44822a2 100644 --- a/README.md +++ b/README.md @@ -67,3 +67,14 @@ cargo run watch-measure-send-transaction -- --watch-interval 600 ``` ![example discord message](discord1.png) + +## deployment on fly + +install flyctl then... + +- `fly apps create` +- `fly secrets set --config fly.toml KEY="value"` for .env vars +- `fly deploy --config fly.toml --ha=false --remote-only` +- `fly status` for status +- `fly logs` for logs + diff --git a/fly.toml b/fly.toml new file mode 100644 index 0000000..fc3e576 --- /dev/null +++ b/fly.toml @@ -0,0 +1,17 @@ +app = "cks-tx-tester" +primary_region = "ams" +kill_signal = "SIGTERM" +kill_timeout = 60 + +[build] +dockerfile = "./Dockerfile" +ignorefile = ".dockerignore" + +[deploy] +strategy = "immediate" + +[[vm]] +size = "performance-2x" +memory = "4GB" +cpus = 2 +cpu_kind = "performance" diff --git a/src/config.rs b/src/config.rs index 8dcf18c..26f6e0a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -51,8 +51,11 @@ fn setup_logging() { pub fn parse_user_key(raw: String) -> Result { let byte_strs: Vec<&str> = raw.split(',').collect(); - let bytes: Result, _> = byte_strs.iter().map(|s| s.parse::()).collect(); - let user = Keypair::from_bytes(&bytes?)?; + let bytes: Vec = byte_strs + .iter() + .map(|s| s.parse::().expect("parses u8")) + .collect::>(); + let user = Keypair::from_bytes(&bytes)?; Ok(user) } diff --git a/src/measure_txs.rs b/src/measure_txs.rs index 49f320a..c499e3e 100644 --- a/src/measure_txs.rs +++ b/src/measure_txs.rs @@ -164,6 +164,7 @@ async fn send_and_confirm_self_transfer_tx( atomic_slot: Arc, label: String, rpc_client: Arc, + test_client: Arc, recent_blockhash: Hash, priority_fee: u64, lamports: u64, @@ -182,10 +183,10 @@ async fn send_and_confirm_self_transfer_tx( let tx = Transaction::new(&[&user], message, recent_blockhash); let slot_sent = atomic_slot.load(Ordering::Relaxed); - let signature = rpc_client.send_and_confirm_transaction(&tx).await?; - sleep(Duration::from_secs(5)).await; + let signature = test_client.send_transaction(&tx).await?; + sleep(Duration::from_secs(60)).await; let slot_confirmed = rpc_client - .get_transaction(&signature, UiTransactionEncoding::Json) + .get_transaction(&signature, UiTransactionEncoding::Base64) .await? .slot; @@ -227,6 +228,7 @@ pub async fn watch_measure_txs( } let rpc_client = RpcClient::new(rpc_url); + let rpc_client = Arc::new(rpc_client); let mut interval = time::interval(Duration::from_secs(watch_interval_seconds)); let mut slot_diffs_by_label: HashMap> = HashMap::new(); @@ -245,8 +247,9 @@ pub async fn watch_measure_txs( let mut sig_futs = Vec::new(); let c_by_l = clients_by_label.clone(); for (i, (label, client)) in c_by_l.iter().enumerate() { + let rpc_client = Arc::clone(&rpc_client); let label = label.clone(); - let rpc_client = Arc::clone(client); + let test_client = Arc::clone(client); let user = Arc::clone(&user); let a_slot = Arc::clone(&atomic_slot); let fut = send_and_confirm_self_transfer_tx( @@ -254,6 +257,7 @@ pub async fn watch_measure_txs( a_slot, label, rpc_client, + test_client, recent_blockhash, priority_fee, i as u64,