From f4b82532f8c9e30aa15cf98aef1b1e6d1a6b681c Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Fri, 10 Jan 2025 09:40:29 +0100 Subject: [PATCH 01/33] chore(sidecar): bump version to v0.4.0-alpha.rc1 --- bolt-sidecar/Cargo.lock | 2 +- bolt-sidecar/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bolt-sidecar/Cargo.lock b/bolt-sidecar/Cargo.lock index a8ba5939..b9cc4f21 100644 --- a/bolt-sidecar/Cargo.lock +++ b/bolt-sidecar/Cargo.lock @@ -2011,7 +2011,7 @@ dependencies = [ [[package]] name = "bolt-sidecar" -version = "0.3.1-alpha" +version = "0.4.0-alpha.rc1" dependencies = [ "account_utils", "alloy 0.9.2", diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index c90e4798..a18c2827 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bolt-sidecar" -version = "0.3.1-alpha" +version = "0.4.0-alpha.rc1" edition = "2021" default-run = "bolt-sidecar" From 07f1b72d6f7e5eea2852458a8cd2cefd42139429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Anda=20Estensen?= Date: Fri, 10 Jan 2025 10:07:58 +0100 Subject: [PATCH 02/33] chore(bolt-sidecar): remove BOLT_SIDECAR_MAX_COMMITMENTS_PER_SLOT --- bolt-sidecar/.env.example | 2 -- bolt-sidecar/README.md | 6 ------ bolt-sidecar/src/api/commitments/server/mod.rs | 4 ---- bolt-sidecar/src/config/limits.rs | 9 --------- bolt-sidecar/src/state/execution.rs | 10 ---------- testnets/holesky/README.md | 6 ------ testnets/holesky/bolt-sidecar.env.example | 2 -- testnets/holesky/commit-boost/bolt-sidecar.env.example | 4 ---- .../presets/sidecar-delegations-preset.env.example | 2 -- 9 files changed, 45 deletions(-) diff --git a/bolt-sidecar/.env.example b/bolt-sidecar/.env.example index 6b6bd96a..aea9fce6 100644 --- a/bolt-sidecar/.env.example +++ b/bolt-sidecar/.env.example @@ -29,8 +29,6 @@ BOLT_SIDECAR_COMMITMENT_PRIVATE_KEY= BOLT_SIDECAR_BUILDER_PRIVATE_KEY= # Commitments limits -# Max number of commitments to accept per block -BOLT_SIDECAR_MAX_COMMITMENTS_PER_SLOT=128 # Max committed gas per slot BOLT_SIDECAR_MAX_COMMITTED_GAS_PER_SLOT=10_000_000 # Min profit per gas to accept a commitment diff --git a/bolt-sidecar/README.md b/bolt-sidecar/README.md index c05f1f13..dcb7c823 100644 --- a/bolt-sidecar/README.md +++ b/bolt-sidecar/README.md @@ -103,12 +103,6 @@ Options: [env: BOLT_SIDECAR_BUILDER_PRIVATE_KEY=] [default: 0x240872ca0812e33503482a886e05dfe30ae9cf757bf5c040e70eac685e419c6e] - --max-commitments-per-slot - Max number of commitments to accept per block - - [env: BOLT_SIDECAR_MAX_COMMITMENTS=] - [default: 128] - --max-committed-gas-per-slot Max committed gas per slot diff --git a/bolt-sidecar/src/api/commitments/server/mod.rs b/bolt-sidecar/src/api/commitments/server/mod.rs index 281fc34c..8ff32914 100644 --- a/bolt-sidecar/src/api/commitments/server/mod.rs +++ b/bolt-sidecar/src/api/commitments/server/mod.rs @@ -322,10 +322,6 @@ mod test { let metadata: MetadataResponse = serde_json::from_value(response.result).unwrap(); - assert_eq!( - metadata.limits.max_commitments_per_slot, - expected_limits.max_commitments_per_slot - ); assert_eq!( metadata.limits.max_committed_gas_per_slot, expected_limits.max_committed_gas_per_slot diff --git a/bolt-sidecar/src/config/limits.rs b/bolt-sidecar/src/config/limits.rs index 57243050..cb6ccead 100644 --- a/bolt-sidecar/src/config/limits.rs +++ b/bolt-sidecar/src/config/limits.rs @@ -18,13 +18,6 @@ pub const DEFAULT_MAX_ACCOUNT_STATES_SIZE: u64 = 1_024; #[cfg_attr(test, derive(PartialEq))] #[derive(Debug, Parser, Clone, Copy, serde::Serialize, serde::Deserialize)] pub struct LimitsOpts { - /// Max number of commitments to accept per block - #[clap( - long, - env = "BOLT_SIDECAR_MAX_COMMITMENTS", - default_value_t = LimitsOpts::default().max_commitments_per_slot - )] - pub max_commitments_per_slot: NonZero, /// Max committed gas per slot #[clap( long, @@ -54,8 +47,6 @@ pub struct LimitsOpts { impl Default for LimitsOpts { fn default() -> Self { Self { - max_commitments_per_slot: NonZero::new(DEFAULT_MAX_COMMITMENTS) - .expect("Valid non-zero"), max_committed_gas_per_slot: NonZero::new(DEFAULT_MAX_COMMITTED_GAS) .expect("Valid non-zero"), min_inclusion_profit: DEFAULT_MIN_PROFIT, diff --git a/bolt-sidecar/src/state/execution.rs b/bolt-sidecar/src/state/execution.rs index 240bb203..3b5031cf 100644 --- a/bolt-sidecar/src/state/execution.rs +++ b/bolt-sidecar/src/state/execution.rs @@ -263,16 +263,6 @@ impl ExecutionState { return Err(ValidationError::ChainIdMismatch); } - // Check if there is room for more commitments - if let Some(template) = self.get_block_template(target_slot) { - if template.transactions_len() >= self.limits.max_commitments_per_slot.get() { - return Err(ValidationError::MaxCommitmentsReachedForSlot( - self.slot, - self.limits.max_commitments_per_slot.get(), - )); - } - } - // Check if the committed gas exceeds the maximum let template_committed_gas = self.get_block_template(target_slot).map(|t| t.committed_gas()).unwrap_or(0); diff --git a/testnets/holesky/README.md b/testnets/holesky/README.md index 1ef133ed..f8f8190b 100644 --- a/testnets/holesky/README.md +++ b/testnets/holesky/README.md @@ -765,12 +765,6 @@ Options: [env: BOLT_SIDECAR_COMMITMENT_PRIVATE_KEY=] - --max-commitments-per-slot - Max number of commitments to accept per block - - [env: BOLT_SIDECAR_MAX_COMMITMENTS=] - [default: 128] - --max-committed-gas-per-slot Max committed gas per slot diff --git a/testnets/holesky/bolt-sidecar.env.example b/testnets/holesky/bolt-sidecar.env.example index 02623e73..61de7206 100644 --- a/testnets/holesky/bolt-sidecar.env.example +++ b/testnets/holesky/bolt-sidecar.env.example @@ -29,8 +29,6 @@ BOLT_SIDECAR_COMMITMENT_PRIVATE_KEY= BOLT_SIDECAR_BUILDER_PRIVATE_KEY= # Commitments limits -# Max number of commitments to accept per block -BOLT_SIDECAR_MAX_COMMITMENTS_PER_SLOT=128 # Max committed gas per slot BOLT_SIDECAR_MAX_COMMITTED_GAS_PER_SLOT=10_000_000 # Min profit per gas to accept a commitment diff --git a/testnets/holesky/commit-boost/bolt-sidecar.env.example b/testnets/holesky/commit-boost/bolt-sidecar.env.example index 34344c80..ac4cae3c 100644 --- a/testnets/holesky/commit-boost/bolt-sidecar.env.example +++ b/testnets/holesky/commit-boost/bolt-sidecar.env.example @@ -50,10 +50,6 @@ BOLT_SIDECAR_BUILDER_PRIVATE_KEY=0c824d40ad3545b4973d1d491d7e8f318536b3aad11609e # BOLT_SIDECAR_UNSAFE_DISABLE_ONCHAIN_CHECKS="true" # Commitments limits -# Max number of commitments to accept per block -# YOU CAN CHANGE THIS TO YOUR LIKING 👇 -BOLT_SIDECAR_MAX_COMMITMENTS_PER_SLOT=128 - # Max committed gas per slot # YOU CAN CHANGE THIS TO YOUR LIKING 👇 BOLT_SIDECAR_MAX_COMMITTED_GAS_PER_SLOT=10000000 diff --git a/testnets/holesky/presets/sidecar-delegations-preset.env.example b/testnets/holesky/presets/sidecar-delegations-preset.env.example index a7714dbc..f1e8d0a7 100644 --- a/testnets/holesky/presets/sidecar-delegations-preset.env.example +++ b/testnets/holesky/presets/sidecar-delegations-preset.env.example @@ -27,8 +27,6 @@ BOLT_SIDECAR_FEE_RECIPIENT= BOLT_SIDECAR_COMMITMENT_PRIVATE_KEY= # Commitments limits -# Max number of commitments to accept per block -BOLT_SIDECAR_MAX_COMMITMENTS_PER_SLOT=128 # Max committed gas per slot BOLT_SIDECAR_MAX_COMMITTED_GAS_PER_SLOT=10_000_000 # Min profit per gas to accept a commitment From 18b27fb2884266770a46d0d2abf3d115f85e9049 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Fri, 10 Jan 2025 10:10:02 +0100 Subject: [PATCH 03/33] chore: bump rust version everywhere --- bolt-boost/Dockerfile | 2 +- bolt-boost/rust-toolchain.toml | 2 +- bolt-cli/Dockerfile | 2 +- bolt-cli/rust-toolchain.toml | 2 +- bolt-sidecar/Dockerfile | 2 +- bolt-sidecar/rust-toolchain.toml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bolt-boost/Dockerfile b/bolt-boost/Dockerfile index 68accc26..4e9ddf10 100644 --- a/bolt-boost/Dockerfile +++ b/bolt-boost/Dockerfile @@ -1,4 +1,4 @@ -FROM lukemathwalker/cargo-chef:latest-rust-1.83.0 AS chef +FROM lukemathwalker/cargo-chef:latest-rust-1.84.0 AS chef WORKDIR /app FROM chef AS planner diff --git a/bolt-boost/rust-toolchain.toml b/bolt-boost/rust-toolchain.toml index 6cc20eae..67b05271 100644 --- a/bolt-boost/rust-toolchain.toml +++ b/bolt-boost/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.83.0" +channel = "1.84.0" profile = "default" diff --git a/bolt-cli/Dockerfile b/bolt-cli/Dockerfile index a2b7d868..45945d3e 100644 --- a/bolt-cli/Dockerfile +++ b/bolt-cli/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Base compiler image with necessary dependencies -FROM rust:1.81.0-slim-bullseye AS base +FROM rust:1.84.0-slim-bullseye AS base # Install cargo-chef for dependency caching RUN cargo install cargo-chef diff --git a/bolt-cli/rust-toolchain.toml b/bolt-cli/rust-toolchain.toml index bbf217f2..67b05271 100644 --- a/bolt-cli/rust-toolchain.toml +++ b/bolt-cli/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.81.0" +channel = "1.84.0" profile = "default" diff --git a/bolt-sidecar/Dockerfile b/bolt-sidecar/Dockerfile index 4f9651b6..d2146212 100644 --- a/bolt-sidecar/Dockerfile +++ b/bolt-sidecar/Dockerfile @@ -1,5 +1,5 @@ # Stage 1: Base compiler image with necessary dependencies -FROM rust:1.83.0-slim-bullseye AS base +FROM rust:1.84.0-slim-bullseye AS base # Install cargo-chef for dependency caching RUN cargo install cargo-chef diff --git a/bolt-sidecar/rust-toolchain.toml b/bolt-sidecar/rust-toolchain.toml index 6cc20eae..67b05271 100644 --- a/bolt-sidecar/rust-toolchain.toml +++ b/bolt-sidecar/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.83.0" +channel = "1.84.0" profile = "default" From 3b0ffaedcd8a5e1b0c9e62ab89dd983070a033d7 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Fri, 10 Jan 2025 09:58:30 +0000 Subject: [PATCH 04/33] Feature flag to exclude high compute tests --- .github/workflows/bolt_sidecar_ci.yml | 2 +- bolt-sidecar/Cargo.toml | 3 + bolt-sidecar/src/signer/keystore.rs | 198 +--------------------- bolt-sidecar/src/signer/keystore_tests.rs | 178 +++++++++++++++++++ bolt-sidecar/src/signer/mod.rs | 1 + 5 files changed, 189 insertions(+), 193 deletions(-) create mode 100644 bolt-sidecar/src/signer/keystore_tests.rs diff --git a/.github/workflows/bolt_sidecar_ci.yml b/.github/workflows/bolt_sidecar_ci.yml index 8ca24b31..619481bd 100644 --- a/.github/workflows/bolt_sidecar_ci.yml +++ b/.github/workflows/bolt_sidecar_ci.yml @@ -58,6 +58,6 @@ jobs: - name: Run bolt-sidecar tests run: | cd bolt-sidecar - cargo nextest run --workspace --retries 3 + cargo nextest run --workspace --all-features --retries 3 env: RPC_URL: ${{ secrets.RPC_URL }} diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index a18c2827..4c2d9b34 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -114,3 +114,6 @@ match_same_arms = "warn" redundant_else = "warn" unnecessary_self_imports = "warn" use_self = "warn" + +[features] +keystore-tests = [] diff --git a/bolt-sidecar/src/signer/keystore.rs b/bolt-sidecar/src/signer/keystore.rs index 2833827a..3bf2e5cb 100644 --- a/bolt-sidecar/src/signer/keystore.rs +++ b/bolt-sidecar/src/signer/keystore.rs @@ -137,6 +137,12 @@ impl KeystoreSigner { Ok(sig) } + + #[cfg(test)] + #[allow(unused)] + pub(crate) fn get_key_pairs(&self) -> Vec { + self.keypairs.to_vec() + } } impl Debug for KeystoreSigner { @@ -184,195 +190,3 @@ fn read_dir(path: &PathBuf) -> SignerResult { fn read_path(entry: std::result::Result) -> SignerResult { Ok(entry.map_err(KeystoreError::ReadFromDirectory)?.path()) } - -#[cfg(test)] -mod tests { - use std::{ - fs::File, - io::Write, - path::{Path, PathBuf}, - }; - - use blst::min_pk::SecretKey; - use ethereum_consensus::crypto::PublicKey as BlsPublicKey; - - use crate::{config::ChainConfig, signer::local::LocalSigner}; - - use super::KeystoreSigner; - /// The str path of the root of the project - pub const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); - - const KEYSTORES_DEFAULT_PATH_TEST: &str = "test_data/keys"; - const KEYSTORES_SECRETS_DEFAULT_PATH_TEST: &str = "test_data/secrets"; - - /// If `path` is `Some`, returns a clone of it. Otherwise, returns the path to the - /// `fallback_relative_path` starting from the root of the cargo project. - fn make_path(relative_path: &str) -> PathBuf { - let project_root = env!("CARGO_MANIFEST_DIR"); - Path::new(project_root).join(relative_path) - } - - #[test] - fn test_keystore_signer() { - // 0. Test data setup - - // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases - let tests_keystore_json = [ - r#" - { - "crypto": { - "kdf": { - "function": "scrypt", - "params": { - "dklen": 32, - "n": 262144, - "p": 1, - "r": 8, - "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" - }, - "message": "" - }, - "checksum": { - "function": "sha256", - "params": {}, - "message": "d2217fe5f3e9a1e34581ef8a78f7c9928e436d36dacc5e846690a5581e8ea484" - }, - "cipher": { - "function": "aes-128-ctr", - "params": { - "iv": "264daa3f303d7259501c93d997d84fe6" - }, - "message": "06ae90d55fe0a6e9c5c3bc5b170827b2e5cce3929ed3f116c2811e6366dfe20f" - } - }, - "description": "This is a test keystore that uses scrypt to secure the secret.", - "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", - "path": "m/12381/60/3141592653/589793238", - "uuid": "1d85ae20-35c5-4611-98e8-aa14a633906f", - "version": 4 - } - "#, - r#" - { - "crypto": { - "kdf": { - "function": "pbkdf2", - "params": { - "dklen": 32, - "c": 262144, - "prf": "hmac-sha256", - "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" - }, - "message": "" - }, - "checksum": { - "function": "sha256", - "params": {}, - "message": "8a9f5d9912ed7e75ea794bc5a89bca5f193721d30868ade6f73043c6ea6febf1" - }, - "cipher": { - "function": "aes-128-ctr", - "params": { - "iv": "264daa3f303d7259501c93d997d84fe6" - }, - "message": "cee03fde2af33149775b7223e7845e4fb2c8ae1792e5f99fe9ecf474cc8c16ad" - } - }, - "description": "This is a test keystore that uses PBKDF2 to secure the secret.", - "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", - "path": "m/12381/60/0/0", - "uuid": "64625def-3331-4eea-ab6f-782f3ed16a83", - "version": 4 - } - "#, - ]; - - // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases - let password = r#"𝔱𝔢𝔰𝔱𝔭𝔞𝔰𝔰𝔴𝔬𝔯𝔡🔑"#; - let public_key = "0x9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07"; - let public_key_bytes: [u8; 48] = [ - 0x96, 0x12, 0xd7, 0xa7, 0x27, 0xc9, 0xd0, 0xa2, 0x2e, 0x18, 0x5a, 0x1c, 0x76, 0x84, - 0x78, 0xdf, 0xe9, 0x19, 0xca, 0xda, 0x92, 0x66, 0x98, 0x8c, 0xb3, 0x23, 0x59, 0xc1, - 0x1f, 0x2b, 0x7b, 0x27, 0xf4, 0xae, 0x40, 0x40, 0x90, 0x23, 0x82, 0xae, 0x29, 0x10, - 0xc1, 0x5e, 0x2b, 0x42, 0x0d, 0x07, - ]; - let secret_key = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; - let chain_config = ChainConfig::mainnet(); - - let keystore_path = - format!("{}/{}/{}", CARGO_MANIFEST_DIR, KEYSTORES_DEFAULT_PATH_TEST, public_key); - let keystore_path = PathBuf::from(keystore_path); - - for test_keystore_json in tests_keystore_json { - // 1. Write the keystore in a `test-voting-keystore.json` file so we test both scrypt - // and PBDKF2 - - let mut tmp_keystore_file = - File::create(keystore_path.join("test-voting-keystore.json")) - .expect("to create new keystore file"); - - tmp_keystore_file - .write_all(test_keystore_json.as_bytes()) - .expect("to write to temp file"); - - // Create a file for the secret, we are going to test it as well - let keystores_secrets_path = make_path(KEYSTORES_SECRETS_DEFAULT_PATH_TEST); - let mut tmp_secret_file = File::create(keystores_secrets_path.join(public_key)) - .expect("to create secret file"); - - tmp_secret_file.write_all(password.as_bytes()).expect("to write to temp file"); - - let keys_path = make_path(KEYSTORES_DEFAULT_PATH_TEST); - let keystore_signer_from_password = - KeystoreSigner::from_password(&keys_path, password.as_bytes(), chain_config) - .expect("to create keystore signer from password"); - - assert_eq!(keystore_signer_from_password.keypairs.len(), 3); - assert_eq!( - keystore_signer_from_password - .keypairs - .first() - .expect("to get keypair") - .pk - .to_string(), - public_key - ); - - let keystore_signer_from_directory = KeystoreSigner::from_secrets_directory( - &keys_path, - &keystores_secrets_path, - chain_config, - ) - .expect("to create keystore signer from secrets dir"); - - assert_eq!(keystore_signer_from_directory.keypairs.len(), 3); - assert_eq!( - keystore_signer_from_directory - .keypairs - .first() - .expect("to get keypair") - .pk - .to_string(), - public_key - ); - - // 2. Sign a message with the signer and check the signature - - let keystore_sk_bls = SecretKey::from_bytes( - hex::decode(secret_key).expect("to decode secret key").as_slice(), - ) - .expect("to create secret key"); - - let local_signer = LocalSigner::new(keystore_sk_bls, chain_config); - - let sig_local = local_signer.sign_commit_boost_root([0; 32]).expect("to sign message"); - let sig_keystore = keystore_signer_from_password - .sign_commit_boost_root( - [0; 32], - &BlsPublicKey::try_from(public_key_bytes.as_ref()).unwrap(), - ) - .expect("to sign message"); - assert_eq!(sig_local, sig_keystore); - } - } -} diff --git a/bolt-sidecar/src/signer/keystore_tests.rs b/bolt-sidecar/src/signer/keystore_tests.rs new file mode 100644 index 00000000..5ac192bc --- /dev/null +++ b/bolt-sidecar/src/signer/keystore_tests.rs @@ -0,0 +1,178 @@ +#[cfg(feature = "keystore-tests")] +#[cfg(test)] +mod tests { + use std::{ + fs::File, + io::Write, + path::{Path, PathBuf}, + }; + + use blst::min_pk::SecretKey; + use ethereum_consensus::crypto::PublicKey as BlsPublicKey; + + use crate::{config::ChainConfig, signer::local::LocalSigner}; + + use crate::signer::KeystoreSigner; + /// The str path of the root of the project + pub const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); + + const KEYSTORES_DEFAULT_PATH_TEST: &str = "test_data/keys"; + const KEYSTORES_SECRETS_DEFAULT_PATH_TEST: &str = "test_data/secrets"; + + /// If `path` is `Some`, returns a clone of it. Otherwise, returns the path to the + /// `fallback_relative_path` starting from the root of the cargo project. + fn make_path(relative_path: &str) -> PathBuf { + let project_root = env!("CARGO_MANIFEST_DIR"); + Path::new(project_root).join(relative_path) + } + + #[test] + fn test_keystore_signer() { + // 0. Test data setup + + // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases + let tests_keystore_json = [ + r#" + { + "crypto": { + "kdf": { + "function": "scrypt", + "params": { + "dklen": 32, + "n": 262144, + "p": 1, + "r": 8, + "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" + }, + "message": "" + }, + "checksum": { + "function": "sha256", + "params": {}, + "message": "d2217fe5f3e9a1e34581ef8a78f7c9928e436d36dacc5e846690a5581e8ea484" + }, + "cipher": { + "function": "aes-128-ctr", + "params": { + "iv": "264daa3f303d7259501c93d997d84fe6" + }, + "message": "06ae90d55fe0a6e9c5c3bc5b170827b2e5cce3929ed3f116c2811e6366dfe20f" + } + }, + "description": "This is a test keystore that uses scrypt to secure the secret.", + "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", + "path": "m/12381/60/3141592653/589793238", + "uuid": "1d85ae20-35c5-4611-98e8-aa14a633906f", + "version": 4 + } + "#, + r#" + { + "crypto": { + "kdf": { + "function": "pbkdf2", + "params": { + "dklen": 32, + "c": 262144, + "prf": "hmac-sha256", + "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" + }, + "message": "" + }, + "checksum": { + "function": "sha256", + "params": {}, + "message": "8a9f5d9912ed7e75ea794bc5a89bca5f193721d30868ade6f73043c6ea6febf1" + }, + "cipher": { + "function": "aes-128-ctr", + "params": { + "iv": "264daa3f303d7259501c93d997d84fe6" + }, + "message": "cee03fde2af33149775b7223e7845e4fb2c8ae1792e5f99fe9ecf474cc8c16ad" + } + }, + "description": "This is a test keystore that uses PBKDF2 to secure the secret.", + "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", + "path": "m/12381/60/0/0", + "uuid": "64625def-3331-4eea-ab6f-782f3ed16a83", + "version": 4 + } + "#, + ]; + + // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases + let password = r#"𝔱𝔢𝔰𝔱𝔭𝔞𝔰𝔰𝔴𝔬𝔯𝔡🔑"#; + let public_key = "0x9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07"; + let public_key_bytes: [u8; 48] = [ + 0x96, 0x12, 0xd7, 0xa7, 0x27, 0xc9, 0xd0, 0xa2, 0x2e, 0x18, 0x5a, 0x1c, 0x76, 0x84, + 0x78, 0xdf, 0xe9, 0x19, 0xca, 0xda, 0x92, 0x66, 0x98, 0x8c, 0xb3, 0x23, 0x59, 0xc1, + 0x1f, 0x2b, 0x7b, 0x27, 0xf4, 0xae, 0x40, 0x40, 0x90, 0x23, 0x82, 0xae, 0x29, 0x10, + 0xc1, 0x5e, 0x2b, 0x42, 0x0d, 0x07, + ]; + let secret_key = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; + let chain_config = ChainConfig::mainnet(); + + let keystore_path = + format!("{}/{}/{}", CARGO_MANIFEST_DIR, KEYSTORES_DEFAULT_PATH_TEST, public_key); + let keystore_path = PathBuf::from(keystore_path); + let keystore_path = keystore_path.join("test-voting-keystore.json"); + for test_keystore_json in tests_keystore_json { + // 1. Write the keystore in a `test-voting-keystore.json` file so we test both scrypt + // and PBDKF2 + + let mut tmp_keystore_file = + File::create(&keystore_path).expect("to create new keystore file"); + + tmp_keystore_file + .write_all(test_keystore_json.as_bytes()) + .expect("to write to temp file"); + + // Create a file for the secret, we are going to test it as well + let keystores_secrets_path = make_path(KEYSTORES_SECRETS_DEFAULT_PATH_TEST); + let mut tmp_secret_file = File::create(keystores_secrets_path.join(public_key)) + .expect("to create secret file"); + + tmp_secret_file.write_all(password.as_bytes()).expect("to write to temp file"); + + let keys_path = make_path(KEYSTORES_DEFAULT_PATH_TEST); + let keystore_signer_from_password = + KeystoreSigner::from_password(&keys_path, password.as_bytes(), chain_config) + .expect("to create keystore signer from password"); + + let keypairs = keystore_signer_from_password.get_key_pairs(); + assert_eq!(keypairs.len(), 3); + assert_eq!(keypairs.first().expect("to get keypair").pk.to_string(), public_key); + + let keystore_signer_from_directory = KeystoreSigner::from_secrets_directory( + &keys_path, + &keystores_secrets_path, + chain_config, + ) + .expect("to create keystore signer from secrets dir"); + + let keypairs = keystore_signer_from_directory.get_key_pairs(); + assert_eq!(keypairs.len(), 3); + assert_eq!(keypairs.first().expect("to get keypair").pk.to_string(), public_key); + + // 2. Sign a message with the signer and check the signature + + let keystore_sk_bls = SecretKey::from_bytes( + hex::decode(secret_key).expect("to decode secret key").as_slice(), + ) + .expect("to create secret key"); + + let local_signer = LocalSigner::new(keystore_sk_bls, chain_config); + + let sig_local = local_signer.sign_commit_boost_root([0; 32]).expect("to sign message"); + let sig_keystore = keystore_signer_from_password + .sign_commit_boost_root( + [0; 32], + &BlsPublicKey::try_from(public_key_bytes.as_ref()).unwrap(), + ) + .expect("to sign message"); + assert_eq!(sig_local, sig_keystore); + } + assert!(std::fs::remove_file(&keystore_path).is_ok()); + } +} diff --git a/bolt-sidecar/src/signer/mod.rs b/bolt-sidecar/src/signer/mod.rs index c6663d26..cfb381a8 100644 --- a/bolt-sidecar/src/signer/mod.rs +++ b/bolt-sidecar/src/signer/mod.rs @@ -9,6 +9,7 @@ pub use commit_boost::CommitBoostSigner; /// EIP-2335 keystore signer implementation. pub mod keystore; pub use keystore::KeystoreSigner; +mod keystore_tests; /// Local signer implementation. pub mod local; From d88d6e7950583d5393e03f9183100db25a30b618 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Fri, 10 Jan 2025 12:19:11 +0000 Subject: [PATCH 05/33] tiny rollback --- bolt-sidecar/src/signer/keystore.rs | 199 +++++++++++++++++++++- bolt-sidecar/src/signer/keystore_tests.rs | 178 ------------------- bolt-sidecar/src/signer/mod.rs | 1 - 3 files changed, 193 insertions(+), 185 deletions(-) delete mode 100644 bolt-sidecar/src/signer/keystore_tests.rs diff --git a/bolt-sidecar/src/signer/keystore.rs b/bolt-sidecar/src/signer/keystore.rs index 3bf2e5cb..da1bf7d8 100644 --- a/bolt-sidecar/src/signer/keystore.rs +++ b/bolt-sidecar/src/signer/keystore.rs @@ -137,12 +137,6 @@ impl KeystoreSigner { Ok(sig) } - - #[cfg(test)] - #[allow(unused)] - pub(crate) fn get_key_pairs(&self) -> Vec { - self.keypairs.to_vec() - } } impl Debug for KeystoreSigner { @@ -190,3 +184,196 @@ fn read_dir(path: &PathBuf) -> SignerResult { fn read_path(entry: std::result::Result) -> SignerResult { Ok(entry.map_err(KeystoreError::ReadFromDirectory)?.path()) } + +#[cfg(feature = "keystore-tests")] +#[cfg(test)] +mod tests { + use std::{ + fs::File, + io::Write, + path::{Path, PathBuf}, + }; + + use blst::min_pk::SecretKey; + use ethereum_consensus::crypto::PublicKey as BlsPublicKey; + + use crate::{config::ChainConfig, signer::local::LocalSigner}; + + use super::KeystoreSigner; + /// The str path of the root of the project + pub const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); + + const KEYSTORES_DEFAULT_PATH_TEST: &str = "test_data/keys"; + const KEYSTORES_SECRETS_DEFAULT_PATH_TEST: &str = "test_data/secrets"; + + /// If `path` is `Some`, returns a clone of it. Otherwise, returns the path to the + /// `fallback_relative_path` starting from the root of the cargo project. + fn make_path(relative_path: &str) -> PathBuf { + let project_root = env!("CARGO_MANIFEST_DIR"); + Path::new(project_root).join(relative_path) + } + + #[test] + fn test_keystore_signer() { + // 0. Test data setup + + // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases + let tests_keystore_json = [ + r#" + { + "crypto": { + "kdf": { + "function": "scrypt", + "params": { + "dklen": 32, + "n": 262144, + "p": 1, + "r": 8, + "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" + }, + "message": "" + }, + "checksum": { + "function": "sha256", + "params": {}, + "message": "d2217fe5f3e9a1e34581ef8a78f7c9928e436d36dacc5e846690a5581e8ea484" + }, + "cipher": { + "function": "aes-128-ctr", + "params": { + "iv": "264daa3f303d7259501c93d997d84fe6" + }, + "message": "06ae90d55fe0a6e9c5c3bc5b170827b2e5cce3929ed3f116c2811e6366dfe20f" + } + }, + "description": "This is a test keystore that uses scrypt to secure the secret.", + "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", + "path": "m/12381/60/3141592653/589793238", + "uuid": "1d85ae20-35c5-4611-98e8-aa14a633906f", + "version": 4 + } + "#, + r#" + { + "crypto": { + "kdf": { + "function": "pbkdf2", + "params": { + "dklen": 32, + "c": 262144, + "prf": "hmac-sha256", + "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" + }, + "message": "" + }, + "checksum": { + "function": "sha256", + "params": {}, + "message": "8a9f5d9912ed7e75ea794bc5a89bca5f193721d30868ade6f73043c6ea6febf1" + }, + "cipher": { + "function": "aes-128-ctr", + "params": { + "iv": "264daa3f303d7259501c93d997d84fe6" + }, + "message": "cee03fde2af33149775b7223e7845e4fb2c8ae1792e5f99fe9ecf474cc8c16ad" + } + }, + "description": "This is a test keystore that uses PBKDF2 to secure the secret.", + "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", + "path": "m/12381/60/0/0", + "uuid": "64625def-3331-4eea-ab6f-782f3ed16a83", + "version": 4 + } + "#, + ]; + + // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases + let password = r#"𝔱𝔢𝔰𝔱𝔭𝔞𝔰𝔰𝔴𝔬𝔯𝔡🔑"#; + let public_key = "0x9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07"; + let public_key_bytes: [u8; 48] = [ + 0x96, 0x12, 0xd7, 0xa7, 0x27, 0xc9, 0xd0, 0xa2, 0x2e, 0x18, 0x5a, 0x1c, 0x76, 0x84, + 0x78, 0xdf, 0xe9, 0x19, 0xca, 0xda, 0x92, 0x66, 0x98, 0x8c, 0xb3, 0x23, 0x59, 0xc1, + 0x1f, 0x2b, 0x7b, 0x27, 0xf4, 0xae, 0x40, 0x40, 0x90, 0x23, 0x82, 0xae, 0x29, 0x10, + 0xc1, 0x5e, 0x2b, 0x42, 0x0d, 0x07, + ]; + let secret_key = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; + let chain_config = ChainConfig::mainnet(); + + let keystore_path = + format!("{}/{}/{}", CARGO_MANIFEST_DIR, KEYSTORES_DEFAULT_PATH_TEST, public_key); + let keystore_path = PathBuf::from(keystore_path); + + for test_keystore_json in tests_keystore_json { + // 1. Write the keystore in a `test-voting-keystore.json` file so we test both scrypt + // and PBDKF2 + + let mut tmp_keystore_file = + File::create(keystore_path.join("test-voting-keystore.json")) + .expect("to create new keystore file"); + + tmp_keystore_file + .write_all(test_keystore_json.as_bytes()) + .expect("to write to temp file"); + + // Create a file for the secret, we are going to test it as well + let keystores_secrets_path = make_path(KEYSTORES_SECRETS_DEFAULT_PATH_TEST); + let mut tmp_secret_file = File::create(keystores_secrets_path.join(public_key)) + .expect("to create secret file"); + + tmp_secret_file.write_all(password.as_bytes()).expect("to write to temp file"); + + let keys_path = make_path(KEYSTORES_DEFAULT_PATH_TEST); + let keystore_signer_from_password = + KeystoreSigner::from_password(&keys_path, password.as_bytes(), chain_config) + .expect("to create keystore signer from password"); + + assert_eq!(keystore_signer_from_password.keypairs.len(), 3); + assert_eq!( + keystore_signer_from_password + .keypairs + .first() + .expect("to get keypair") + .pk + .to_string(), + public_key + ); + + let keystore_signer_from_directory = KeystoreSigner::from_secrets_directory( + &keys_path, + &keystores_secrets_path, + chain_config, + ) + .expect("to create keystore signer from secrets dir"); + + assert_eq!(keystore_signer_from_directory.keypairs.len(), 3); + assert_eq!( + keystore_signer_from_directory + .keypairs + .first() + .expect("to get keypair") + .pk + .to_string(), + public_key + ); + + // 2. Sign a message with the signer and check the signature + + let keystore_sk_bls = SecretKey::from_bytes( + hex::decode(secret_key).expect("to decode secret key").as_slice(), + ) + .expect("to create secret key"); + + let local_signer = LocalSigner::new(keystore_sk_bls, chain_config); + + let sig_local = local_signer.sign_commit_boost_root([0; 32]).expect("to sign message"); + let sig_keystore = keystore_signer_from_password + .sign_commit_boost_root( + [0; 32], + &BlsPublicKey::try_from(public_key_bytes.as_ref()).unwrap(), + ) + .expect("to sign message"); + assert_eq!(sig_local, sig_keystore); + } + } +} diff --git a/bolt-sidecar/src/signer/keystore_tests.rs b/bolt-sidecar/src/signer/keystore_tests.rs deleted file mode 100644 index 5ac192bc..00000000 --- a/bolt-sidecar/src/signer/keystore_tests.rs +++ /dev/null @@ -1,178 +0,0 @@ -#[cfg(feature = "keystore-tests")] -#[cfg(test)] -mod tests { - use std::{ - fs::File, - io::Write, - path::{Path, PathBuf}, - }; - - use blst::min_pk::SecretKey; - use ethereum_consensus::crypto::PublicKey as BlsPublicKey; - - use crate::{config::ChainConfig, signer::local::LocalSigner}; - - use crate::signer::KeystoreSigner; - /// The str path of the root of the project - pub const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); - - const KEYSTORES_DEFAULT_PATH_TEST: &str = "test_data/keys"; - const KEYSTORES_SECRETS_DEFAULT_PATH_TEST: &str = "test_data/secrets"; - - /// If `path` is `Some`, returns a clone of it. Otherwise, returns the path to the - /// `fallback_relative_path` starting from the root of the cargo project. - fn make_path(relative_path: &str) -> PathBuf { - let project_root = env!("CARGO_MANIFEST_DIR"); - Path::new(project_root).join(relative_path) - } - - #[test] - fn test_keystore_signer() { - // 0. Test data setup - - // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases - let tests_keystore_json = [ - r#" - { - "crypto": { - "kdf": { - "function": "scrypt", - "params": { - "dklen": 32, - "n": 262144, - "p": 1, - "r": 8, - "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" - }, - "message": "" - }, - "checksum": { - "function": "sha256", - "params": {}, - "message": "d2217fe5f3e9a1e34581ef8a78f7c9928e436d36dacc5e846690a5581e8ea484" - }, - "cipher": { - "function": "aes-128-ctr", - "params": { - "iv": "264daa3f303d7259501c93d997d84fe6" - }, - "message": "06ae90d55fe0a6e9c5c3bc5b170827b2e5cce3929ed3f116c2811e6366dfe20f" - } - }, - "description": "This is a test keystore that uses scrypt to secure the secret.", - "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", - "path": "m/12381/60/3141592653/589793238", - "uuid": "1d85ae20-35c5-4611-98e8-aa14a633906f", - "version": 4 - } - "#, - r#" - { - "crypto": { - "kdf": { - "function": "pbkdf2", - "params": { - "dklen": 32, - "c": 262144, - "prf": "hmac-sha256", - "salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" - }, - "message": "" - }, - "checksum": { - "function": "sha256", - "params": {}, - "message": "8a9f5d9912ed7e75ea794bc5a89bca5f193721d30868ade6f73043c6ea6febf1" - }, - "cipher": { - "function": "aes-128-ctr", - "params": { - "iv": "264daa3f303d7259501c93d997d84fe6" - }, - "message": "cee03fde2af33149775b7223e7845e4fb2c8ae1792e5f99fe9ecf474cc8c16ad" - } - }, - "description": "This is a test keystore that uses PBKDF2 to secure the secret.", - "pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07", - "path": "m/12381/60/0/0", - "uuid": "64625def-3331-4eea-ab6f-782f3ed16a83", - "version": 4 - } - "#, - ]; - - // Reference: https://eips.ethereum.org/EIPS/eip-2335#test-cases - let password = r#"𝔱𝔢𝔰𝔱𝔭𝔞𝔰𝔰𝔴𝔬𝔯𝔡🔑"#; - let public_key = "0x9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07"; - let public_key_bytes: [u8; 48] = [ - 0x96, 0x12, 0xd7, 0xa7, 0x27, 0xc9, 0xd0, 0xa2, 0x2e, 0x18, 0x5a, 0x1c, 0x76, 0x84, - 0x78, 0xdf, 0xe9, 0x19, 0xca, 0xda, 0x92, 0x66, 0x98, 0x8c, 0xb3, 0x23, 0x59, 0xc1, - 0x1f, 0x2b, 0x7b, 0x27, 0xf4, 0xae, 0x40, 0x40, 0x90, 0x23, 0x82, 0xae, 0x29, 0x10, - 0xc1, 0x5e, 0x2b, 0x42, 0x0d, 0x07, - ]; - let secret_key = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"; - let chain_config = ChainConfig::mainnet(); - - let keystore_path = - format!("{}/{}/{}", CARGO_MANIFEST_DIR, KEYSTORES_DEFAULT_PATH_TEST, public_key); - let keystore_path = PathBuf::from(keystore_path); - let keystore_path = keystore_path.join("test-voting-keystore.json"); - for test_keystore_json in tests_keystore_json { - // 1. Write the keystore in a `test-voting-keystore.json` file so we test both scrypt - // and PBDKF2 - - let mut tmp_keystore_file = - File::create(&keystore_path).expect("to create new keystore file"); - - tmp_keystore_file - .write_all(test_keystore_json.as_bytes()) - .expect("to write to temp file"); - - // Create a file for the secret, we are going to test it as well - let keystores_secrets_path = make_path(KEYSTORES_SECRETS_DEFAULT_PATH_TEST); - let mut tmp_secret_file = File::create(keystores_secrets_path.join(public_key)) - .expect("to create secret file"); - - tmp_secret_file.write_all(password.as_bytes()).expect("to write to temp file"); - - let keys_path = make_path(KEYSTORES_DEFAULT_PATH_TEST); - let keystore_signer_from_password = - KeystoreSigner::from_password(&keys_path, password.as_bytes(), chain_config) - .expect("to create keystore signer from password"); - - let keypairs = keystore_signer_from_password.get_key_pairs(); - assert_eq!(keypairs.len(), 3); - assert_eq!(keypairs.first().expect("to get keypair").pk.to_string(), public_key); - - let keystore_signer_from_directory = KeystoreSigner::from_secrets_directory( - &keys_path, - &keystores_secrets_path, - chain_config, - ) - .expect("to create keystore signer from secrets dir"); - - let keypairs = keystore_signer_from_directory.get_key_pairs(); - assert_eq!(keypairs.len(), 3); - assert_eq!(keypairs.first().expect("to get keypair").pk.to_string(), public_key); - - // 2. Sign a message with the signer and check the signature - - let keystore_sk_bls = SecretKey::from_bytes( - hex::decode(secret_key).expect("to decode secret key").as_slice(), - ) - .expect("to create secret key"); - - let local_signer = LocalSigner::new(keystore_sk_bls, chain_config); - - let sig_local = local_signer.sign_commit_boost_root([0; 32]).expect("to sign message"); - let sig_keystore = keystore_signer_from_password - .sign_commit_boost_root( - [0; 32], - &BlsPublicKey::try_from(public_key_bytes.as_ref()).unwrap(), - ) - .expect("to sign message"); - assert_eq!(sig_local, sig_keystore); - } - assert!(std::fs::remove_file(&keystore_path).is_ok()); - } -} diff --git a/bolt-sidecar/src/signer/mod.rs b/bolt-sidecar/src/signer/mod.rs index cfb381a8..c6663d26 100644 --- a/bolt-sidecar/src/signer/mod.rs +++ b/bolt-sidecar/src/signer/mod.rs @@ -9,7 +9,6 @@ pub use commit_boost::CommitBoostSigner; /// EIP-2335 keystore signer implementation. pub mod keystore; pub use keystore::KeystoreSigner; -mod keystore_tests; /// Local signer implementation. pub mod local; From bd540b2ee263b1b12ba1a7155160d95cb22313f0 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:04:54 +0000 Subject: [PATCH 06/33] Tests run on public testnet for quicker CI/CD --- bolt-sidecar/src/chain_io/manager.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/bolt-sidecar/src/chain_io/manager.rs b/bolt-sidecar/src/chain_io/manager.rs index d55e3e0b..8d16043e 100644 --- a/bolt-sidecar/src/chain_io/manager.rs +++ b/bolt-sidecar/src/chain_io/manager.rs @@ -227,19 +227,17 @@ mod tests { use crate::{ chain_io::{manager::generate_operator_keys_mismatch_error, utils::pubkey_hash}, config::chain::Chain, + test_util::{get_test_config, try_get_execution_api_url}, }; use super::BoltManager; #[tokio::test] async fn test_verify_validator_pubkeys() { - let url = Url::parse("http://remotebeast:48545").expect("valid url"); - - // Skip the test if the tailnet server isn't reachable - if reqwest::get(url.clone()).await.is_err_and(|err| err.is_timeout() || err.is_connect()) { - eprintln!("Skipping test because remotebeast is not reachable"); - return; - } + let url = match try_get_execution_api_url().await { + None => return, + Some(u) => Url::parse(u).expect("valid EL URL"), + }; let manager = BoltManager::from_chain(url, Chain::Holesky).expect("manager deployed on Holesky"); @@ -278,12 +276,11 @@ mod tests { #[tokio::test] async fn test_verify_validator_pubkeys_retry() { let _ = tracing_subscriber::fmt::try_init(); - // Point to an EL node that is not yet online - let url = Url::parse("http://localhost:10000").expect("valid url"); + let unresponsive_url = Url::parse("http://localhost:10000").expect("valid EL URL"); - let manager = - BoltManager::from_chain(url, Chain::Holesky).expect("manager deployed on Holesky"); + let manager = BoltManager::from_chain(unresponsive_url, Chain::Holesky) + .expect("manager deployed on Holesky"); let keys = vec![ BlsPublicKey::try_from( @@ -292,13 +289,17 @@ mod tests { let commitment_signer_pubkey = Address::ZERO; tokio::spawn(async move { + let url = match try_get_execution_api_url().await { + None => return, + Some(url) => Url::parse(url).expect("valid EL URL"), + }; // Sleep for a bit so verify_validator_pubkeys is called before the anvil is up tokio::time::sleep(Duration::from_millis(100)).await; let anvil = Anvil::new() - .fork(Url::parse("http://remotebeast:48545").unwrap()) + .fork(url) .port(10000u16) .spawn(); - println!("{}", anvil.endpoint()); + tracing::info!("anvil node: {}", anvil.endpoint()); tokio::time::sleep(Duration::from_secs(10)).await; }); From a960dc9c5aac33f4a03ebf80213c2d5be223ab75 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:12:29 +0000 Subject: [PATCH 07/33] update few URLs --- bolt-sidecar/src/test_util.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/bolt-sidecar/src/test_util.rs b/bolt-sidecar/src/test_util.rs index bd7ef443..eb6ae092 100644 --- a/bolt-sidecar/src/test_util.rs +++ b/bolt-sidecar/src/test_util.rs @@ -31,14 +31,10 @@ use crate::{ }; /// The URL of the test execution client HTTP API. -/// -/// NOTE: this DNS is only available through the Chainbound Tailnet -const EXECUTION_API_URL: &str = "http://remotebeast:48545"; +const EXECUTION_API_URL: &str = "https://ethereum-holesky-rpc.publicnode.com"; /// The URL of the test beacon client HTTP API. -/// -/// NOTE: this DNS is only available through the Chainbound Tailnet -const BEACON_API_URL: &str = "http://remotebeast:44400"; +const BEACON_API_URL: &str = "https://ethereum-holesky-beacon-api.publicnode.com"; /// The URL of the test engine client HTTP API. /// From 9c3ae83be1f5c226b737d3db75e455c2c93bc046 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:17:49 +0000 Subject: [PATCH 08/33] lint --- bolt-sidecar/src/chain_io/manager.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bolt-sidecar/src/chain_io/manager.rs b/bolt-sidecar/src/chain_io/manager.rs index 8d16043e..2e497e99 100644 --- a/bolt-sidecar/src/chain_io/manager.rs +++ b/bolt-sidecar/src/chain_io/manager.rs @@ -227,7 +227,7 @@ mod tests { use crate::{ chain_io::{manager::generate_operator_keys_mismatch_error, utils::pubkey_hash}, config::chain::Chain, - test_util::{get_test_config, try_get_execution_api_url}, + test_util::try_get_execution_api_url, }; use super::BoltManager; From 27e2405f351341b82c8a4257344faa87c0f3f014 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:00:41 +0000 Subject: [PATCH 09/33] use safe APIs, reusable functions --- bolt-sidecar/src/chain_io/manager.rs | 34 ++++++++------- bolt-sidecar/src/client/beacon.rs | 51 ++++++++++++----------- bolt-sidecar/src/primitives/commitment.rs | 4 +- bolt-sidecar/src/state/execution.rs | 8 ++-- bolt-sidecar/src/state/pricing.rs | 5 +-- bolt-sidecar/src/test_util.rs | 10 ++--- 6 files changed, 57 insertions(+), 55 deletions(-) diff --git a/bolt-sidecar/src/chain_io/manager.rs b/bolt-sidecar/src/chain_io/manager.rs index 2e497e99..c01aaa96 100644 --- a/bolt-sidecar/src/chain_io/manager.rs +++ b/bolt-sidecar/src/chain_io/manager.rs @@ -233,14 +233,15 @@ mod tests { use super::BoltManager; #[tokio::test] - async fn test_verify_validator_pubkeys() { - let url = match try_get_execution_api_url().await { - None => return, - Some(u) => Url::parse(u).expect("valid EL URL"), + async fn test_verify_validator_pubkeys() -> eyre::Result<()> { + let _ = tracing_subscriber::fmt::try_init(); + let Some(url) = try_get_execution_api_url().await else { + tracing::warn!("skipping test: execution API URL is not reachable"); + return Ok(()); }; let manager = - BoltManager::from_chain(url, Chain::Holesky).expect("manager deployed on Holesky"); + BoltManager::from_chain(Url::parse(url).unwrap(), Chain::Holesky).expect("manager deployed on Holesky"); let operator = Address::from_hex("725028b0b7c3db8b8242d35cd3a5779838b217b1").expect("valid address"); @@ -271,13 +272,19 @@ mod tests { .await .expect("active validator and correct operator"); assert!(res[0].active); + + Ok(()) } #[tokio::test] - async fn test_verify_validator_pubkeys_retry() { - let _ = tracing_subscriber::fmt::try_init(); + async fn test_verify_validator_pubkeys_retry() -> eyre::Result<()> { + let Some(url) = try_get_execution_api_url().await else { + tracing::warn!("skipping test: execution API URL is not reachable"); + return Ok(()); + }; + // Point to an EL node that is not yet online - let unresponsive_url = Url::parse("http://localhost:10000").expect("valid EL URL"); + let unresponsive_url = Url::parse("http://localhost:10000").expect("valid execution API URL"); let manager = BoltManager::from_chain(unresponsive_url, Chain::Holesky) .expect("manager deployed on Holesky"); @@ -289,16 +296,9 @@ mod tests { let commitment_signer_pubkey = Address::ZERO; tokio::spawn(async move { - let url = match try_get_execution_api_url().await { - None => return, - Some(url) => Url::parse(url).expect("valid EL URL"), - }; // Sleep for a bit so verify_validator_pubkeys is called before the anvil is up tokio::time::sleep(Duration::from_millis(100)).await; - let anvil = Anvil::new() - .fork(url) - .port(10000u16) - .spawn(); + let anvil = Anvil::new().fork(Url::parse(url).unwrap()).port(10000u16).spawn(); tracing::info!("anvil node: {}", anvil.endpoint()); tokio::time::sleep(Duration::from_secs(10)).await; }); @@ -316,5 +316,7 @@ mod tests { operator ) ); + + Ok(()) } } diff --git a/bolt-sidecar/src/client/beacon.rs b/bolt-sidecar/src/client/beacon.rs index e37f5cc8..440be5da 100644 --- a/bolt-sidecar/src/client/beacon.rs +++ b/bolt-sidecar/src/client/beacon.rs @@ -123,47 +123,48 @@ impl Debug for BeaconClient { #[cfg(test)] mod tests { use super::*; - use std::str::FromStr; + use crate::test_util::try_get_beacon_api_url; #[tokio::test] - async fn test_get_prev_randao() { - let url = Url::from_str("http://remotebeast:44400").unwrap(); + async fn test_get_prev_randao() -> eyre::Result<()> { + let _ = tracing_subscriber::fmt::try_init(); + let Some(url) = try_get_beacon_api_url().await else { + tracing::warn!("skipping test: beacon API URL is not reachable"); + return Ok(()); + }; - if reqwest::get(url.clone()).await.is_err_and(|err| err.is_timeout() || err.is_connect()) { - eprintln!("Skipping test because remotebeast is not reachable"); - return; - } - - let beacon_api = BeaconClient::new(url); + let beacon_api = BeaconClient::new(Url::parse(url).unwrap()); assert!(beacon_api.get_prev_randao().await.is_ok()); + + Ok(()) } #[tokio::test] - async fn test_get_expected_withdrawals_at_head() { - let url = Url::from_str("http://remotebeast:44400").unwrap(); - - if reqwest::get(url.clone()).await.is_err_and(|err| err.is_timeout() || err.is_connect()) { - eprintln!("Skipping test because remotebeast is not reachable"); - return; - } + async fn test_get_expected_withdrawals_at_head() -> eyre::Result<()> { + let Some(url) = try_get_beacon_api_url().await else { + tracing::warn!("skipping test: beacon API URL is not reachable"); + return Ok(()); + }; - let beacon_api = BeaconClient::new(url); + let beacon_api = BeaconClient::new(Url::parse(url).unwrap()); assert!(beacon_api.get_expected_withdrawals_at_head().await.is_ok()); + + Ok(()) } #[tokio::test] - async fn test_get_parent_beacon_block_root() { - let url = Url::from_str("http://remotebeast:44400").unwrap(); - - if reqwest::get(url.clone()).await.is_err_and(|err| err.is_timeout() || err.is_connect()) { - eprintln!("Skipping test because remotebeast is not reachable"); - return; - } + async fn test_get_parent_beacon_block_root() -> eyre::Result<()> { + let Some(url) = try_get_beacon_api_url().await else { + tracing::warn!("skipping test: beacon API URL is not reachable"); + return Ok(()); + }; - let beacon_api = BeaconClient::new(url); + let beacon_api = BeaconClient::new(Url::parse(url).unwrap()); assert!(beacon_api.get_parent_beacon_block_root().await.is_ok()); + + Ok(()) } } diff --git a/bolt-sidecar/src/primitives/commitment.rs b/bolt-sidecar/src/primitives/commitment.rs index 5c98b758..d680d32a 100644 --- a/bolt-sidecar/src/primitives/commitment.rs +++ b/bolt-sidecar/src/primitives/commitment.rs @@ -192,8 +192,8 @@ impl InclusionRequest { for tx in &self.txs { // Calculate minimum required priority fee for this transaction let min_priority_fee = pricing - .calculate_min_priority_fee(tx.gas_limit(), preconfirmed_gas)? - + min_inclusion_profit; + .calculate_min_priority_fee(tx.gas_limit(), preconfirmed_gas)? + + min_inclusion_profit; let tip = tx.effective_tip_per_gas(max_base_fee).unwrap_or_default(); if tip < min_priority_fee as u128 { diff --git a/bolt-sidecar/src/state/execution.rs b/bolt-sidecar/src/state/execution.rs index 3b5031cf..5a381492 100644 --- a/bolt-sidecar/src/state/execution.rs +++ b/bolt-sidecar/src/state/execution.rs @@ -8,7 +8,6 @@ use std::collections::HashMap; use thiserror::Error; use tracing::{debug, error, trace, warn}; -use crate::state::pricing; use crate::{ builder::BlockTemplate, common::{ @@ -19,11 +18,11 @@ use crate::{ primitives::{ signature::SignatureError, AccountState, InclusionRequest, SignedConstraints, Slot, }, + state::pricing, telemetry::ApiMetrics, }; -use super::InclusionPricer; -use super::{account_state::AccountStateCache, fetcher::StateFetcher}; +use super::{account_state::AccountStateCache, fetcher::StateFetcher, InclusionPricer}; /// Possible commitment validation errors. /// @@ -310,7 +309,8 @@ impl ExecutionState { return Err(ValidationError::BaseFeeTooLow(max_basefee)); } - // Ensure max_priority_fee_per_gas is greater than or equal to the calculated min_priority_fee + // Ensure max_priority_fee_per_gas is greater than or equal to the calculated + // min_priority_fee if !req.validate_min_priority_fee( &self.pricing, template_committed_gas, diff --git a/bolt-sidecar/src/state/pricing.rs b/bolt-sidecar/src/state/pricing.rs index 69e7c5c5..e4703063 100644 --- a/bolt-sidecar/src/state/pricing.rs +++ b/bolt-sidecar/src/state/pricing.rs @@ -67,7 +67,6 @@ impl InclusionPricer { /// important reason is that we omit large outlier transactions to improve average /// fit, which disproportionately affects the most valuable transactions. /// """ - /// pub fn calculate_min_priority_fee( &self, incoming_gas: u64, @@ -84,8 +83,8 @@ impl InclusionPricer { let after_gas = remaining_gas - incoming_gas; // Calculate numerator and denominator for the logarithm - let fraction = (self.gas_scalar * (remaining_gas as f64) + 1.0) - / (self.gas_scalar * (after_gas as f64) + 1.0); + let fraction = (self.gas_scalar * (remaining_gas as f64) + 1.0) / + (self.gas_scalar * (after_gas as f64) + 1.0); // Calculate block space value in Ether let block_space_value = self.base_multiplier * fraction.ln(); diff --git a/bolt-sidecar/src/test_util.rs b/bolt-sidecar/src/test_util.rs index eb6ae092..2fab3e98 100644 --- a/bolt-sidecar/src/test_util.rs +++ b/bolt-sidecar/src/test_util.rs @@ -31,10 +31,10 @@ use crate::{ }; /// The URL of the test execution client HTTP API. -const EXECUTION_API_URL: &str = "https://ethereum-holesky-rpc.publicnode.com"; +const EXECUTION_API_URL: &str = "https://geth-holesky.bolt.chainbound.io"; /// The URL of the test beacon client HTTP API. -const BEACON_API_URL: &str = "https://ethereum-holesky-beacon-api.publicnode.com"; +const BEACON_API_URL: &str = "https://lighthouse-holesky.bolt.chainbound.io"; /// The URL of the test engine client HTTP API. /// @@ -94,13 +94,13 @@ pub(crate) async fn get_test_config() -> Option { }; if let Some(url) = try_get_execution_api_url().await { - opts.execution_api_url = url.parse().expect("valid URL"); + opts.execution_api_url = url.parse().expect("valid execution API URL"); } if let Some(url) = try_get_beacon_api_url().await { - opts.beacon_api_url = url.parse().expect("valid URL"); + opts.beacon_api_url = url.parse().expect("valid beacon API URL"); } if let Some(url) = try_get_engine_api_url().await { - opts.engine_api_url = url.parse().expect("valid URL"); + opts.engine_api_url = url.parse().expect("valid engine API URL"); } opts.engine_jwt_hex = JwtSecretConfig::from(jwt.as_str()); From 9fda935be12b8b2d893e417b55e4f9adeccd5f02 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Sat, 11 Jan 2025 21:08:08 +0000 Subject: [PATCH 10/33] fmt changes --- bolt-sidecar/src/chain_io/manager.rs | 14 ++++++++------ bolt-sidecar/src/client/beacon.rs | 7 ++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bolt-sidecar/src/chain_io/manager.rs b/bolt-sidecar/src/chain_io/manager.rs index c01aaa96..e826fd31 100644 --- a/bolt-sidecar/src/chain_io/manager.rs +++ b/bolt-sidecar/src/chain_io/manager.rs @@ -223,6 +223,7 @@ mod tests { use ethereum_consensus::primitives::BlsPublicKey; use reqwest::Url; use std::time::Duration; + use tracing::{info, warn}; use crate::{ chain_io::{manager::generate_operator_keys_mismatch_error, utils::pubkey_hash}, @@ -236,12 +237,12 @@ mod tests { async fn test_verify_validator_pubkeys() -> eyre::Result<()> { let _ = tracing_subscriber::fmt::try_init(); let Some(url) = try_get_execution_api_url().await else { - tracing::warn!("skipping test: execution API URL is not reachable"); + warn!("skipping test: execution API URL is not reachable"); return Ok(()); }; - let manager = - BoltManager::from_chain(Url::parse(url).unwrap(), Chain::Holesky).expect("manager deployed on Holesky"); + let manager = BoltManager::from_chain(Url::parse(url).unwrap(), Chain::Holesky) + .expect("manager deployed on Holesky"); let operator = Address::from_hex("725028b0b7c3db8b8242d35cd3a5779838b217b1").expect("valid address"); @@ -279,12 +280,13 @@ mod tests { #[tokio::test] async fn test_verify_validator_pubkeys_retry() -> eyre::Result<()> { let Some(url) = try_get_execution_api_url().await else { - tracing::warn!("skipping test: execution API URL is not reachable"); + warn!("skipping test: execution API URL is not reachable"); return Ok(()); }; // Point to an EL node that is not yet online - let unresponsive_url = Url::parse("http://localhost:10000").expect("valid execution API URL"); + let unresponsive_url = + Url::parse("http://localhost:10000").expect("valid execution API URL"); let manager = BoltManager::from_chain(unresponsive_url, Chain::Holesky) .expect("manager deployed on Holesky"); @@ -299,7 +301,7 @@ mod tests { // Sleep for a bit so verify_validator_pubkeys is called before the anvil is up tokio::time::sleep(Duration::from_millis(100)).await; let anvil = Anvil::new().fork(Url::parse(url).unwrap()).port(10000u16).spawn(); - tracing::info!("anvil node: {}", anvil.endpoint()); + info!("anvil node: {}", anvil.endpoint()); tokio::time::sleep(Duration::from_secs(10)).await; }); diff --git a/bolt-sidecar/src/client/beacon.rs b/bolt-sidecar/src/client/beacon.rs index 440be5da..3435db85 100644 --- a/bolt-sidecar/src/client/beacon.rs +++ b/bolt-sidecar/src/client/beacon.rs @@ -124,12 +124,13 @@ impl Debug for BeaconClient { mod tests { use super::*; use crate::test_util::try_get_beacon_api_url; + use tracing::warn; #[tokio::test] async fn test_get_prev_randao() -> eyre::Result<()> { let _ = tracing_subscriber::fmt::try_init(); let Some(url) = try_get_beacon_api_url().await else { - tracing::warn!("skipping test: beacon API URL is not reachable"); + warn!("skipping test: beacon API URL is not reachable"); return Ok(()); }; @@ -143,7 +144,7 @@ mod tests { #[tokio::test] async fn test_get_expected_withdrawals_at_head() -> eyre::Result<()> { let Some(url) = try_get_beacon_api_url().await else { - tracing::warn!("skipping test: beacon API URL is not reachable"); + warn!("skipping test: beacon API URL is not reachable"); return Ok(()); }; @@ -157,7 +158,7 @@ mod tests { #[tokio::test] async fn test_get_parent_beacon_block_root() -> eyre::Result<()> { let Some(url) = try_get_beacon_api_url().await else { - tracing::warn!("skipping test: beacon API URL is not reachable"); + warn!("skipping test: beacon API URL is not reachable"); return Ok(()); }; From 7cc45fdc7003c7c917d4bed2d156ad63bb696db9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:29:23 +0000 Subject: [PATCH 11/33] chore(deps): bump async-trait from 0.1.84 to 0.1.85 in /bolt-boost Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.84 to 0.1.85. - [Release notes](https://github.com/dtolnay/async-trait/releases) - [Commits](https://github.com/dtolnay/async-trait/compare/0.1.84...0.1.85) --- updated-dependencies: - dependency-name: async-trait dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bolt-boost/Cargo.lock | 4 ++-- bolt-boost/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bolt-boost/Cargo.lock b/bolt-boost/Cargo.lock index 46367a2e..77ea3d59 100644 --- a/bolt-boost/Cargo.lock +++ b/bolt-boost/Cargo.lock @@ -829,9 +829,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.84" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", diff --git a/bolt-boost/Cargo.toml b/bolt-boost/Cargo.toml index 3c6b965b..06afdc76 100644 --- a/bolt-boost/Cargo.toml +++ b/bolt-boost/Cargo.toml @@ -13,7 +13,7 @@ tokio = { version = "1", features = ["full"] } axum = { version = "0.7", features = ["macros"] } axum-extra = "0.10.0" futures = "0.3" -async-trait = "0.1.84" +async-trait = "0.1.85" eyre = "0.6.12" thiserror = "2.0.9" reqwest = "0.12.9" From 016bae784024a303bd946f9af025b28088f30118 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:29:46 +0000 Subject: [PATCH 12/33] chore(deps): bump ethereum_ssz from 0.8.1 to 0.8.2 in /bolt-boost Bumps [ethereum_ssz](https://github.com/sigp/ethereum_ssz) from 0.8.1 to 0.8.2. - [Release notes](https://github.com/sigp/ethereum_ssz/releases) - [Commits](https://github.com/sigp/ethereum_ssz/compare/v0.8.1...v0.8.2) --- updated-dependencies: - dependency-name: ethereum_ssz dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bolt-boost/Cargo.lock | 12 ++++++------ bolt-boost/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bolt-boost/Cargo.lock b/bolt-boost/Cargo.lock index 46367a2e..dba83273 100644 --- a/bolt-boost/Cargo.lock +++ b/bolt-boost/Cargo.lock @@ -198,7 +198,7 @@ dependencies = [ "alloy-serde", "c-kzg", "derive_more", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "ethereum_ssz_derive 0.8.1", "once_cell", "serde", @@ -433,7 +433,7 @@ dependencies = [ "alloy-primitives", "alloy-rpc-types-engine", "alloy-serde", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "ethereum_ssz_derive 0.8.1", "serde", "serde_with", @@ -452,7 +452,7 @@ dependencies = [ "alloy-rlp", "alloy-serde", "derive_more", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "ethereum_ssz_derive 0.8.1", "serde", "strum", @@ -1173,7 +1173,7 @@ dependencies = [ "cb-common", "cb-pbs", "ethereum_ssz 0.7.1", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "ethereum_ssz_derive 0.8.1", "eyre", "futures", @@ -1966,9 +1966,9 @@ dependencies = [ [[package]] name = "ethereum_ssz" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "036c84bd29bff35e29bbee3c8fc0e2fb95db12b6f2f3cae82a827fbc97256f3a" +checksum = "862e41ea8eea7508f70cfd8cd560f0c34bb0af37c719a8e06c2672f0f031d8e5" dependencies = [ "alloy-primitives", "ethereum_serde_utils 0.7.0", diff --git a/bolt-boost/Cargo.toml b/bolt-boost/Cargo.toml index 3c6b965b..f878716e 100644 --- a/bolt-boost/Cargo.toml +++ b/bolt-boost/Cargo.toml @@ -30,7 +30,7 @@ prometheus = "0.13.4" # serialization serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.134" -ethereum_ssz = "0.8.1" +ethereum_ssz = "0.8.2" ethereum_ssz_derive = "0.8.1" # alloy From 71ca55a5b7b859065d9ed2f5973a20c68827b11e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:31:29 +0000 Subject: [PATCH 13/33] chore(deps): bump serde_json from 1.0.134 to 1.0.135 in /bolt-cli Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.134 to 1.0.135. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.134...v1.0.135) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bolt-cli/Cargo.lock | 4 ++-- bolt-cli/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bolt-cli/Cargo.lock b/bolt-cli/Cargo.lock index c8d2a810..700587ec 100644 --- a/bolt-cli/Cargo.lock +++ b/bolt-cli/Cargo.lock @@ -4188,9 +4188,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", diff --git a/bolt-cli/Cargo.toml b/bolt-cli/Cargo.toml index 95b96db9..34370632 100644 --- a/bolt-cli/Cargo.toml +++ b/bolt-cli/Cargo.toml @@ -11,7 +11,7 @@ futures = "0.3.31" # cli clap = { version = "4.5.4", features = ["derive", "env"] } serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.134" +serde_json = "1.0.135" # grpc rustls = { version = "0.23.20", features = ["ring"] } From fc08866af6a55b9ed3314d60f682e7621dd7b130 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:32:41 +0000 Subject: [PATCH 14/33] chore(deps): bump ethereum_ssz from 0.8.1 to 0.8.2 in /bolt-sidecar Bumps [ethereum_ssz](https://github.com/sigp/ethereum_ssz) from 0.8.1 to 0.8.2. - [Release notes](https://github.com/sigp/ethereum_ssz/releases) - [Commits](https://github.com/sigp/ethereum_ssz/compare/v0.8.1...v0.8.2) --- updated-dependencies: - dependency-name: ethereum_ssz dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bolt-sidecar/Cargo.lock | 14 +++++++------- bolt-sidecar/Cargo.toml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bolt-sidecar/Cargo.lock b/bolt-sidecar/Cargo.lock index b9cc4f21..7033d453 100644 --- a/bolt-sidecar/Cargo.lock +++ b/bolt-sidecar/Cargo.lock @@ -363,7 +363,7 @@ dependencies = [ "alloy-serde 0.8.0", "c-kzg", "derive_more 1.0.0", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "ethereum_ssz_derive 0.8.1", "once_cell", "serde", @@ -831,7 +831,7 @@ dependencies = [ "alloy-primitives 0.8.15", "alloy-rpc-types-engine 0.8.0", "alloy-serde 0.8.0", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "ethereum_ssz_derive 0.8.1", "serde", "serde_with", @@ -864,7 +864,7 @@ dependencies = [ "alloy-rlp", "alloy-serde 0.8.0", "derive_more 1.0.0", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "ethereum_ssz_derive 0.8.1", "serde", "strum", @@ -2035,7 +2035,7 @@ dependencies = [ "dotenvy", "eth2_keystore 0.1.0 (git+https://github.com/sigp/lighthouse)", "ethereum-consensus", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "eyre", "futures", "hex", @@ -3783,9 +3783,9 @@ dependencies = [ [[package]] name = "ethereum_ssz" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "036c84bd29bff35e29bbee3c8fc0e2fb95db12b6f2f3cae82a827fbc97256f3a" +checksum = "862e41ea8eea7508f70cfd8cd560f0c34bb0af37c719a8e06c2672f0f031d8e5" dependencies = [ "alloy-primitives 0.8.15", "ethereum_serde_utils 0.7.0", @@ -8773,7 +8773,7 @@ checksum = "3cc60ae4c4236ee721305d0f0b5aa3e8ef5b66f3fa61d17072430bc246d6694a" dependencies = [ "alloy-primitives 0.8.15", "ethereum_hashing 0.7.0", - "ethereum_ssz 0.8.1", + "ethereum_ssz 0.8.2", "smallvec", "typenum", ] diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index 4c2d9b34..e0bfb9f2 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -30,7 +30,7 @@ tree_hash = "0.9" tree_hash_derive = "0.8" secp256k1 = { version = "0.29.0", features = ["rand"] } ssz_rs = { git = "https://github.com/ralexstokes/ssz-rs", rev = "ec3073e" } -ethereum_ssz = "0.8.1" +ethereum_ssz = "0.8.2" # alloy alloy = { version = "0.9.2", features = ["full", "provider-trace-api", "rpc-types-beacon"] } From d4cf8a6a887bc15988789d360709747d753b184d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 07:36:47 +0000 Subject: [PATCH 15/33] chore(deps): bump tokio from 1.42.0 to 1.43.0 in /bolt-sidecar Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.42.0 to 1.43.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.42.0...tokio-1.43.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- bolt-sidecar/Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bolt-sidecar/Cargo.lock b/bolt-sidecar/Cargo.lock index b9cc4f21..45f817f3 100644 --- a/bolt-sidecar/Cargo.lock +++ b/bolt-sidecar/Cargo.lock @@ -8417,9 +8417,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -8435,9 +8435,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", From fdbd8ca917a2daa5c47fd466f6abb15cb38a3385 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 08:11:19 +0000 Subject: [PATCH 16/33] chore(deps): bump tokio from 1.42.0 to 1.43.0 in /bolt-cli Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.42.0 to 1.43.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.42.0...tokio-1.43.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- bolt-cli/Cargo.lock | 12 ++++++------ bolt-cli/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bolt-cli/Cargo.lock b/bolt-cli/Cargo.lock index 700587ec..0e6f5ba5 100644 --- a/bolt-cli/Cargo.lock +++ b/bolt-cli/Cargo.lock @@ -2903,9 +2903,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.167" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libloading" @@ -4667,9 +4667,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -4685,9 +4685,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", diff --git a/bolt-cli/Cargo.toml b/bolt-cli/Cargo.toml index 34370632..2935aa3e 100644 --- a/bolt-cli/Cargo.toml +++ b/bolt-cli/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [dependencies] # async -tokio = { version = "1.42.0", features = ["full"] } +tokio = { version = "1.43.0", features = ["full"] } futures = "0.3.31" # cli From ef903a5d3ccf4ef3bf1d3de9bb387d8ce7c1a434 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 08:13:22 +0000 Subject: [PATCH 17/33] chore(deps): bump async-trait from 0.1.84 to 0.1.85 in /bolt-sidecar Bumps [async-trait](https://github.com/dtolnay/async-trait) from 0.1.84 to 0.1.85. - [Release notes](https://github.com/dtolnay/async-trait/releases) - [Commits](https://github.com/dtolnay/async-trait/compare/0.1.84...0.1.85) --- updated-dependencies: - dependency-name: async-trait dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bolt-sidecar/Cargo.lock | 4 ++-- bolt-sidecar/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bolt-sidecar/Cargo.lock b/bolt-sidecar/Cargo.lock index f74e7e48..c909dcbd 100644 --- a/bolt-sidecar/Cargo.lock +++ b/bolt-sidecar/Cargo.lock @@ -1504,9 +1504,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.84" +version = "0.1.85" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1244b10dcd56c92219da4e14caa97e312079e185f04ba3eea25061561dc0a0" +checksum = "3f934833b4b7233644e5848f235df3f57ed8c80f1528a26c3dfa13d2147fa056" dependencies = [ "proc-macro2", "quote", diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index e0bfb9f2..d6eeb4e6 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -56,7 +56,7 @@ lighthouse_bls = { package = "bls", git = "https://github.com/sigp/lighthouse", serde = { version = "1.0.217", features = ["derive"] } serde_json = "1.0.134" parking_lot = "0.12.1" -async-trait = "0.1.84" +async-trait = "0.1.85" bytes = "1.6.0" hex = "0.4.3" From 0adeabccae279b219d729c2a1a20ede65e33b7ad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 08:14:20 +0000 Subject: [PATCH 18/33] chore(deps): bump serde_json from 1.0.134 to 1.0.135 in /bolt-boost Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.134 to 1.0.135. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.134...v1.0.135) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bolt-boost/Cargo.lock | 4 ++-- bolt-boost/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bolt-boost/Cargo.lock b/bolt-boost/Cargo.lock index 70620479..14b4c2fb 100644 --- a/bolt-boost/Cargo.lock +++ b/bolt-boost/Cargo.lock @@ -3865,9 +3865,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", diff --git a/bolt-boost/Cargo.toml b/bolt-boost/Cargo.toml index 7e20baa9..fb1773d0 100644 --- a/bolt-boost/Cargo.toml +++ b/bolt-boost/Cargo.toml @@ -29,7 +29,7 @@ prometheus = "0.13.4" # serialization serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.134" +serde_json = "1.0.135" ethereum_ssz = "0.8.2" ethereum_ssz_derive = "0.8.1" From c1c4fc7570928bc85b7258ede50c6da132aaf7d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 08:33:56 +0000 Subject: [PATCH 19/33] chore(deps): bump tokio from 1.42.0 to 1.43.0 in /bolt-boost Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.42.0 to 1.43.0. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.42.0...tokio-1.43.0) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- bolt-boost/Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bolt-boost/Cargo.lock b/bolt-boost/Cargo.lock index 14b4c2fb..48031c63 100644 --- a/bolt-boost/Cargo.lock +++ b/bolt-boost/Cargo.lock @@ -2670,9 +2670,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.159" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libm" @@ -4420,9 +4420,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -4438,9 +4438,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", From a1ca649a85f5a6925277081dd5c779f390dc3291 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 08:34:23 +0000 Subject: [PATCH 20/33] chore(deps): bump serde_json from 1.0.134 to 1.0.135 in /bolt-sidecar Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.134 to 1.0.135. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.134...v1.0.135) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- bolt-sidecar/Cargo.lock | 4 ++-- bolt-sidecar/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bolt-sidecar/Cargo.lock b/bolt-sidecar/Cargo.lock index c909dcbd..4813402b 100644 --- a/bolt-sidecar/Cargo.lock +++ b/bolt-sidecar/Cargo.lock @@ -7535,9 +7535,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index d6eeb4e6..fd1bc99f 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -54,7 +54,7 @@ lighthouse_bls = { package = "bls", git = "https://github.com/sigp/lighthouse", # types serde = { version = "1.0.217", features = ["derive"] } -serde_json = "1.0.134" +serde_json = "1.0.135" parking_lot = "0.12.1" async-trait = "0.1.85" bytes = "1.6.0" From 92fbab843607105b6883deae8b814ffebddec80f Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Fri, 10 Jan 2025 17:10:40 +0100 Subject: [PATCH 21/33] fix(sidecar): JSON-RPC error codes --- bolt-sidecar/src/api/commitments/spec.rs | 36 +++++++++++++----------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/bolt-sidecar/src/api/commitments/spec.rs b/bolt-sidecar/src/api/commitments/spec.rs index bc0554bd..960976d7 100644 --- a/bolt-sidecar/src/api/commitments/spec.rs +++ b/bolt-sidecar/src/api/commitments/spec.rs @@ -68,20 +68,22 @@ pub enum CommitmentError { impl From for JsonError { fn from(err: CommitmentError) -> Self { + // Reference: https://www.jsonrpc.org/specification#error_object + // TODO: the custom defined ones should be clearly documented. match err { - CommitmentError::Rejected(err) => Self::new(-32000, err.to_string()), + CommitmentError::Rejected(err) => err.into(), CommitmentError::Duplicate => Self::new(-32001, err.to_string()), - CommitmentError::Internal => Self::new(-32002, err.to_string()), - CommitmentError::NoSignature => Self::new(-32003, err.to_string()), - CommitmentError::InvalidSignature(err) => Self::new(-32004, err.to_string()), - CommitmentError::Signature(err) => Self::new(-32005, err.to_string()), - CommitmentError::Consensus(err) => Self::new(-32006, err.to_string()), + CommitmentError::NoSignature => Self::new(-32002, err.to_string()), + CommitmentError::InvalidSignature(err) => Self::new(-32003, err.to_string()), + CommitmentError::Signature(err) => Self::new(-32004, err.to_string()), + CommitmentError::Consensus(err) => Self::new(-32005, err.to_string()), CommitmentError::Validation(err) => Self::new(-32006, err.to_string()), CommitmentError::MalformedHeader => Self::new(-32007, err.to_string()), - CommitmentError::UnknownMethod => Self::new(-32601, err.to_string()), CommitmentError::InvalidJson(err) => { Self::new(-32600, format!("Invalid request: {err}")) } + CommitmentError::UnknownMethod => Self::new(-32601, err.to_string()), + CommitmentError::Internal => Self::new(-32603, err.to_string()), } } } @@ -89,16 +91,16 @@ impl From for JsonError { impl From<&CommitmentError> for StatusCode { fn from(err: &CommitmentError) -> Self { match err { - CommitmentError::Rejected(_) | - CommitmentError::Duplicate | - CommitmentError::NoSignature | - CommitmentError::InvalidSignature(_) | - CommitmentError::Signature(_) | - CommitmentError::Consensus(_) | - CommitmentError::Validation(_) | - CommitmentError::MalformedHeader | - CommitmentError::UnknownMethod | - CommitmentError::InvalidJson(_) => Self::BAD_REQUEST, + CommitmentError::Rejected(_) + | CommitmentError::Duplicate + | CommitmentError::NoSignature + | CommitmentError::InvalidSignature(_) + | CommitmentError::Signature(_) + | CommitmentError::Consensus(_) + | CommitmentError::Validation(_) + | CommitmentError::MalformedHeader + | CommitmentError::UnknownMethod + | CommitmentError::InvalidJson(_) => Self::BAD_REQUEST, CommitmentError::Internal => Self::INTERNAL_SERVER_ERROR, } } From 70ac3f5171b8c70fb869cc0bfd52d72b6c42bcf5 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Fri, 10 Jan 2025 18:04:51 +0100 Subject: [PATCH 22/33] chore(sidecar): clean up RejectionError type --- bolt-sidecar/Cargo.toml | 2 +- .../src/api/commitments/firewall/processor.rs | 134 ++++++++---------- .../src/api/commitments/server/handlers.rs | 8 +- bolt-sidecar/src/api/commitments/spec.rs | 36 +---- bolt-sidecar/src/primitives/commitment.rs | 3 +- 5 files changed, 77 insertions(+), 106 deletions(-) diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index fd1bc99f..620bec67 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -116,4 +116,4 @@ unnecessary_self_imports = "warn" use_self = "warn" [features] -keystore-tests = [] +keystore-tests = [] diff --git a/bolt-sidecar/src/api/commitments/firewall/processor.rs b/bolt-sidecar/src/api/commitments/firewall/processor.rs index 8a81fc05..b18a92b6 100644 --- a/bolt-sidecar/src/api/commitments/firewall/processor.rs +++ b/bolt-sidecar/src/api/commitments/firewall/processor.rs @@ -23,8 +23,7 @@ use crate::{ api::commitments::{ server::CommitmentEvent, spec::{ - CommitmentError, RejectionError, GET_METADATA_METHOD, GET_VERSION_METHOD, - REQUEST_INCLUSION_METHOD, + CommitmentError, GET_METADATA_METHOD, GET_VERSION_METHOD, REQUEST_INCLUSION_METHOD, }, }, common::BOLT_SIDECAR_VERSION, @@ -279,82 +278,75 @@ impl CommitmentRequestProcessor { let rpc_url = self.url.clone(); trace!(?rpc_url, text, "received text message from websocket connection"); - // Create the channel to send and receive the commitment response let (tx, rx) = oneshot::channel(); - let request = serde_json::from_str::(&text).map_err(|e| e.to_string()); - - // FIXME: still too nested, needs to be refactored. - let response = match request { - Err(e) => Err(e), - Ok(request) => { - let id = request.id; - - match request.method.as_str() { - GET_VERSION_METHOD => Ok(JsonResponse { - id: Some(Value::String(id.to_string())), - result: Value::String(BOLT_SIDECAR_VERSION.clone()), - ..Default::default() - }), - GET_METADATA_METHOD => Ok(JsonResponse { - id: Some(Value::String(id.to_string())), - result: serde_json::to_value(self.state.limits).expect("infallible"), - ..Default::default() - }), - REQUEST_INCLUSION_METHOD => { - // Parse the inclusion request from the parameters - let inclusion_request = serde_json::from_value::( - request.params.first().cloned().unwrap_or_default(), - ) - .map_err(RejectionError::Json) - .inspect_err(|err| error!(?err, "Failed to parse inclusion request")); - - match inclusion_request { - Err(e) => Ok(JsonResponse { - id: Some(Value::String(id.to_string())), - error: Some(e.into()), - ..Default::default() - }), - Ok(inclusion_request) => { - let commitment_request = - CommitmentRequest::Inclusion(inclusion_request); - - let commitment_event = - CommitmentEvent { request: commitment_request, response: tx }; - - if let Err(e) = self.api_events_tx.try_send(commitment_event) { - error!(?e, "failed to send commitment event through channel"); - // NOTE: should we return an internal error to the RPC - // here? - return; - } - - // add the pending response to self buffer for later processing - self.pending_commitment_responses - .push(PendingCommitmentResponse::new(rx, id)); - - return; - } - } - } - other => Err(format!("unsupported method: {}", other)), - } + let request = match serde_json::from_str::(&text) { + Ok(req) => req, + Err(e) => { + warn!(?e, ?rpc_url, "failed to parse JSON-RPC request"); + return; } }; - match response { - Ok(json_response) => { - let message = Message::text( - serde_json::to_string(&json_response).expect("to stringify version response"), - ); + let id = request.id; + let mut response = JsonResponse { + id: Some(Value::String(id.to_string())), + jsonrpc: "2.0".to_string(), + ..Default::default() + }; - // Push the message to the outgoing messages queue for later - // processing - self.outgoing_messages.push_back(message); + match request.method.as_str() { + GET_VERSION_METHOD => { + response.result = Value::String(BOLT_SIDECAR_VERSION.clone()); + self.send_response(response); } - Err(err) => { - warn!(?err, ?rpc_url, "failed to parse JSON-RPC request"); + GET_METADATA_METHOD => { + response.result = serde_json::to_value(self.state.limits).expect("infallible"); + self.send_response(response); } - } + REQUEST_INCLUSION_METHOD => { + let Some(param) = request.params.first().cloned() else { + response.error = Some( + CommitmentError::InvalidParams("missing inclusion request".into()).into(), + ); + self.send_response(response); + return; + }; + + let inclusion_request = match serde_json::from_value::(param) { + Ok(req) => req, + Err(e) => { + let msg = format!("failed to parse inclusion request: {}", e); + error!(?e, "failed to parse inclusion request"); + response.error = Some(CommitmentError::InvalidParams(msg).into()); + self.send_response(response); + return; + } + }; + + let commitment_request = CommitmentRequest::Inclusion(inclusion_request); + let commitment_event = + CommitmentEvent { request: commitment_request, response: tx }; + + if let Err(e) = self.api_events_tx.try_send(commitment_event) { + error!(?e, "failed to send commitment event through channel"); + response.error = Some(CommitmentError::Internal.into()); + self.send_response(response); + return; + } + + // Push the pending commitment response to the queue + self.pending_commitment_responses.push(PendingCommitmentResponse::new(rx, id)); + } + other => { + warn!(?rpc_url, "unsupported method: {}", other); + } + }; + } + + fn send_response(&mut self, response: JsonResponse) { + let message = + Message::text(serde_json::to_string(&response).expect("to stringify response")); + self.outgoing_messages.push_back(message); } } diff --git a/bolt-sidecar/src/api/commitments/server/handlers.rs b/bolt-sidecar/src/api/commitments/server/handlers.rs index d8caff24..66cdfb24 100644 --- a/bolt-sidecar/src/api/commitments/server/handlers.rs +++ b/bolt-sidecar/src/api/commitments/server/handlers.rs @@ -16,8 +16,8 @@ use crate::{ api::commitments::{ server::headers::auth_from_headers, spec::{ - CommitmentError, CommitmentsApi, RejectionError, GET_METADATA_METHOD, - GET_VERSION_METHOD, REQUEST_INCLUSION_METHOD, + CommitmentError, CommitmentsApi, GET_METADATA_METHOD, GET_VERSION_METHOD, + REQUEST_INCLUSION_METHOD, }, }, common::BOLT_SIDECAR_VERSION, @@ -80,12 +80,12 @@ pub async fn rpc_entrypoint( })?; let Some(request_json) = payload.params.first().cloned() else { - return Err(RejectionError::ValidationFailed("Bad params".to_string()).into()); + return Err(CommitmentError::InvalidParams("missing param".to_string()).into()); }; // Parse the inclusion request from the parameters let mut inclusion_request = serde_json::from_value::(request_json) - .map_err(RejectionError::Json) + .map_err(CommitmentError::InvalidJson) .inspect_err(|err| error!(?err, "Failed to parse inclusion request"))?; debug!(?inclusion_request, "New inclusion request"); diff --git a/bolt-sidecar/src/api/commitments/spec.rs b/bolt-sidecar/src/api/commitments/spec.rs index 960976d7..18443087 100644 --- a/bolt-sidecar/src/api/commitments/spec.rs +++ b/bolt-sidecar/src/api/commitments/spec.rs @@ -1,7 +1,6 @@ use alloy::primitives::SignatureError as AlloySignatureError; use axum::{ body::Body, - extract::rejection::JsonRejection, http::{Response, StatusCode}, response::IntoResponse, Json, @@ -31,9 +30,6 @@ pub(super) const MAX_REQUEST_TIMEOUT: std::time::Duration = std::time::Duration: /// Error type for the commitments API. #[derive(Debug, Error)] pub enum CommitmentError { - /// Request rejected. - #[error("Request rejected: {0}")] - Rejected(#[from] RejectionError), /// Consensus validation failed. #[error("Consensus validation error: {0}")] Consensus(#[from] ConsensusError), @@ -63,7 +59,10 @@ pub enum CommitmentError { UnknownMethod, /// Invalid JSON. #[error(transparent)] - InvalidJson(#[from] JsonRejection), + InvalidJson(#[from] serde_json::Error), + /// Invalid JSON-RPC request params. + #[error("Invalid JSON-RPC request params: {0}")] + InvalidParams(String), } impl From for JsonError { @@ -71,7 +70,6 @@ impl From for JsonError { // Reference: https://www.jsonrpc.org/specification#error_object // TODO: the custom defined ones should be clearly documented. match err { - CommitmentError::Rejected(err) => err.into(), CommitmentError::Duplicate => Self::new(-32001, err.to_string()), CommitmentError::NoSignature => Self::new(-32002, err.to_string()), CommitmentError::InvalidSignature(err) => Self::new(-32003, err.to_string()), @@ -83,6 +81,7 @@ impl From for JsonError { Self::new(-32600, format!("Invalid request: {err}")) } CommitmentError::UnknownMethod => Self::new(-32601, err.to_string()), + CommitmentError::InvalidParams(err) => Self::new(-32602, err.to_string()), CommitmentError::Internal => Self::new(-32603, err.to_string()), } } @@ -91,8 +90,7 @@ impl From for JsonError { impl From<&CommitmentError> for StatusCode { fn from(err: &CommitmentError) -> Self { match err { - CommitmentError::Rejected(_) - | CommitmentError::Duplicate + CommitmentError::Duplicate | CommitmentError::NoSignature | CommitmentError::InvalidSignature(_) | CommitmentError::Signature(_) @@ -100,6 +98,7 @@ impl From<&CommitmentError> for StatusCode { | CommitmentError::Validation(_) | CommitmentError::MalformedHeader | CommitmentError::UnknownMethod + | CommitmentError::InvalidParams(_) | CommitmentError::InvalidJson(_) => Self::BAD_REQUEST, CommitmentError::Internal => Self::INTERNAL_SERVER_ERROR, } @@ -115,27 +114,6 @@ impl IntoResponse for CommitmentError { } } -/// Error indicating the rejection of a commitment request. This should -/// be returned to the user. -#[derive(Debug, Error)] -pub enum RejectionError { - /// State validation failed for this request. - #[error("Validation failed: {0}")] - ValidationFailed(String), - /// JSON parsing error. - #[error("JSON parsing error: {0}")] - Json(#[from] serde_json::Error), -} - -impl From for JsonError { - fn from(err: RejectionError) -> Self { - match err { - RejectionError::ValidationFailed(err) => Self::new(-32600, err), - RejectionError::Json(err) => Self::new(-32700, err.to_string()), - } - } -} - /// Implements the commitments-API: #[async_trait::async_trait] pub trait CommitmentsApi { diff --git a/bolt-sidecar/src/primitives/commitment.rs b/bolt-sidecar/src/primitives/commitment.rs index d680d32a..ccfcb6ab 100644 --- a/bolt-sidecar/src/primitives/commitment.rs +++ b/bolt-sidecar/src/primitives/commitment.rs @@ -82,7 +82,8 @@ impl CommitmentRequest { } /// Request to include a transaction at a specific slot. -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)] +#[cfg_attr(test, derive(Default))] +#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct InclusionRequest { /// The consensus slot number at which the transaction should be included. pub slot: u64, From 7c112e9d99c58bedfec48a4dcd3289c2cb57cbd5 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Mon, 13 Jan 2025 11:05:50 +0100 Subject: [PATCH 23/33] fix(sidecar): workaround for axum version errors --- bolt-sidecar/src/api/commitments/server/handlers.rs | 2 +- bolt-sidecar/src/api/commitments/spec.rs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bolt-sidecar/src/api/commitments/server/handlers.rs b/bolt-sidecar/src/api/commitments/server/handlers.rs index 66cdfb24..cad5f33c 100644 --- a/bolt-sidecar/src/api/commitments/server/handlers.rs +++ b/bolt-sidecar/src/api/commitments/server/handlers.rs @@ -80,7 +80,7 @@ pub async fn rpc_entrypoint( })?; let Some(request_json) = payload.params.first().cloned() else { - return Err(CommitmentError::InvalidParams("missing param".to_string()).into()); + return Err(CommitmentError::InvalidParams("missing param".to_string())); }; // Parse the inclusion request from the parameters diff --git a/bolt-sidecar/src/api/commitments/spec.rs b/bolt-sidecar/src/api/commitments/spec.rs index 18443087..f3f40b0e 100644 --- a/bolt-sidecar/src/api/commitments/spec.rs +++ b/bolt-sidecar/src/api/commitments/spec.rs @@ -1,6 +1,7 @@ use alloy::primitives::SignatureError as AlloySignatureError; use axum::{ body::Body, + extract::rejection::JsonRejection, http::{Response, StatusCode}, response::IntoResponse, Json, @@ -63,6 +64,12 @@ pub enum CommitmentError { /// Invalid JSON-RPC request params. #[error("Invalid JSON-RPC request params: {0}")] InvalidParams(String), + /// Invalid JSON. + /// FIXME: (thedevbirb, 2025-13-01) this should be removed because it is dead code, + /// but it allows Rust to pull the correct axum version and not older ones from + /// dependencies (commit-boost). + #[error(transparent)] + RejectedJson(#[from] JsonRejection), } impl From for JsonError { @@ -83,6 +90,7 @@ impl From for JsonError { CommitmentError::UnknownMethod => Self::new(-32601, err.to_string()), CommitmentError::InvalidParams(err) => Self::new(-32602, err.to_string()), CommitmentError::Internal => Self::new(-32603, err.to_string()), + CommitmentError::RejectedJson(err) => Self::new(-32604, err.to_string()), } } } @@ -99,6 +107,7 @@ impl From<&CommitmentError> for StatusCode { | CommitmentError::MalformedHeader | CommitmentError::UnknownMethod | CommitmentError::InvalidParams(_) + | CommitmentError::RejectedJson(_) | CommitmentError::InvalidJson(_) => Self::BAD_REQUEST, CommitmentError::Internal => Self::INTERNAL_SERVER_ERROR, } From f5c94b61caa877cbeb5b23ef94661367e0c63306 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:38:53 +0000 Subject: [PATCH 24/33] Bolt-CLI: Use library for confirmation logic --- bolt-cli/Cargo.lock | 243 +++++++- bolt-cli/Cargo.toml | 1 + bolt-cli/src/cli.rs | 23 + bolt-cli/src/commands/operators/eigenlayer.rs | 10 +- bolt-cli/src/commands/operators/symbiotic.rs | 8 +- bolt-cli/src/commands/validators.rs | 6 +- bolt-cli/src/common/mod.rs | 36 +- bolt-cli/src/pb/v1.rs | 575 ++++++------------ 8 files changed, 433 insertions(+), 469 deletions(-) diff --git a/bolt-cli/Cargo.lock b/bolt-cli/Cargo.lock index 0e6f5ba5..ca5c30c2 100644 --- a/bolt-cli/Cargo.lock +++ b/bolt-cli/Cargo.lock @@ -1160,7 +1160,7 @@ dependencies = [ "miniz_oxide", "object", "rustc-demangle", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1205,7 +1205,7 @@ version = "0.69.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" dependencies = [ - "bitflags", + "bitflags 2.6.0", "cexpr", "clang-sys", "itertools 0.12.1", @@ -1237,6 +1237,12 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.6.0" @@ -1332,6 +1338,7 @@ dependencies = [ "eyre", "futures", "hex", + "inquire", "lazy_static", "prost", "rand", @@ -1439,7 +1446,7 @@ dependencies = [ "js-sys", "num-traits", "wasm-bindgen", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1582,6 +1589,31 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crossterm" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64e6c0fbe2c17357405f7c758c1ef960fce08bdfb2c03d88d2a18d7e09c4b67" +dependencies = [ + "bitflags 1.3.2", + "crossterm_winapi", + "libc", + "mio 0.8.11", + "parking_lot", + "signal-hook", + "signal-hook-mio", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acdd7c62a3665c7f6830a51635d9ac9b23ed385797f70a83bb8bafe9c572ab2b" +dependencies = [ + "winapi", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -1787,6 +1819,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "ecdsa" version = "0.14.8" @@ -2232,6 +2270,24 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42012b0f064e01aa58b545fe3727f90f7dd4020f4a3ea735b50344965f5a57e9" +[[package]] +name = "fuzzy-matcher" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54614a3312934d066701a80f20f15fa3b56d67ac7722b39eea5b4c9dd1d66c94" +dependencies = [ + "thread_local", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -2754,6 +2810,23 @@ dependencies = [ "serde", ] +[[package]] +name = "inquire" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a" +dependencies = [ + "bitflags 2.6.0", + "crossterm", + "dyn-clone", + "fuzzy-matcher", + "fxhash", + "newline-converter", + "once_cell", + "unicode-segmentation", + "unicode-width", +] + [[package]] name = "integer-sqrt" version = "0.1.5" @@ -2914,7 +2987,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -2999,6 +3072,18 @@ dependencies = [ "adler2", ] +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.48.0", +] + [[package]] name = "mio" version = "1.0.3" @@ -3078,6 +3163,15 @@ dependencies = [ "tempfile", ] +[[package]] +name = "newline-converter" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b6b097ecb1cbfed438542d16e84fd7ad9b0c76c8a65b7f9039212a3d14dc7f" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "nom" version = "7.1.3" @@ -3226,7 +3320,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags", + "bitflags 2.6.0", "cfg-if", "foreign-types", "libc", @@ -3325,7 +3419,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -3552,7 +3646,7 @@ checksum = "b4c2511913b88df1637da85cc8d96ec8e43a3f8bb8ccb71ee1ac240d6f3df58d" dependencies = [ "bit-set", "bit-vec", - "bitflags", + "bitflags 2.6.0", "lazy_static", "num-traits", "rand", @@ -3742,7 +3836,7 @@ version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ - "bitflags", + "bitflags 2.6.0", ] [[package]] @@ -3961,7 +4055,7 @@ version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ - "bitflags", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -4119,7 +4213,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", @@ -4303,6 +4397,27 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "signal-hook" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-mio" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +dependencies = [ + "libc", + "mio 0.8.11", + "signal-hook", +] + [[package]] name = "signal-hook-registry" version = "1.4.2" @@ -4538,7 +4653,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags", + "bitflags 2.6.0", "core-foundation", "system-configuration-sys", ] @@ -4674,7 +4789,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio", + "mio 1.0.3", "parking_lot", "pin-project-lite", "signal-hook-registry", @@ -5013,6 +5128,18 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -5281,7 +5408,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -5292,7 +5419,7 @@ checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" dependencies = [ "windows-result", "windows-strings", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -5301,7 +5428,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -5311,7 +5438,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" dependencies = [ "windows-result", - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", ] [[package]] @@ -5320,7 +5456,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -5329,7 +5465,22 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -5338,28 +5489,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -5372,24 +5541,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/bolt-cli/Cargo.toml b/bolt-cli/Cargo.toml index 2935aa3e..49f3cb0d 100644 --- a/bolt-cli/Cargo.toml +++ b/bolt-cli/Cargo.toml @@ -38,6 +38,7 @@ reqwest = { version = "0.12.9", features = ["rustls-tls"] } rand = "0.8.5" lazy_static = "1.5.0" chrono = "0.4.39" +inquire = "0.7.5" [dev-dependencies] tempfile = "3.13.0" diff --git a/bolt-cli/src/cli.rs b/bolt-cli/src/cli.rs index 2e4edf02..95f7409a 100644 --- a/bolt-cli/src/cli.rs +++ b/bolt-cli/src/cli.rs @@ -15,6 +15,7 @@ use crate::{ common::{keystore::DEFAULT_KEYSTORE_PASSWORD, parse_ether_value}, contracts::EigenLayerStrategy, }; +use tracing::info; /// `bolt` is a CLI tool to interact with bolt Protocol ✨ #[derive(Parser, Debug, Clone)] @@ -63,6 +64,28 @@ impl Cmd { Self::PubkeyHash(cmd) => cmd.run(), } } + + /// Asks whether the user wants to proceed further. If not, the process is exited. + #[allow(unreachable_code)] + pub fn request_confirmation() { + // Skip confirmation in tests + #[cfg(test)] + return; + + inquire::Confirm::new("Do you want to continue? (yes/no):") + .prompt() + .map(|proceed| { + if proceed { + return; + } + info!("Aborting"); + std::process::exit(0); + }) + .unwrap_or_else(|err| { + info!("confirmation exited: {}", err); + std::process::exit(0); + }) + } } /// Command for generating BLS delegation or revocation messages. diff --git a/bolt-cli/src/commands/operators/eigenlayer.rs b/bolt-cli/src/commands/operators/eigenlayer.rs index d6cb7500..3e08df64 100644 --- a/bolt-cli/src/commands/operators/eigenlayer.rs +++ b/bolt-cli/src/commands/operators/eigenlayer.rs @@ -15,8 +15,8 @@ use eyre::Context; use tracing::{info, warn}; use crate::{ - cli::{Chain, EigenLayerSubcommand}, - common::{bolt_manager::BoltManagerContract, request_confirmation, try_parse_contract_error}, + cli::{Chain, Cmd, EigenLayerSubcommand}, + common::{bolt_manager::BoltManagerContract, try_parse_contract_error}, contracts::{ bolt::{ BoltEigenLayerMiddleware::{self, BoltEigenLayerMiddlewareErrors}, @@ -62,7 +62,7 @@ impl EigenLayerSubcommand { info!(%strategy, %token, amount = format_ether(amount), ?operator, "Depositing funds into EigenLayer strategy"); - request_confirmation(); + Cmd::request_confirmation(); let token_erc20 = IERC20Instance::new(token, provider); @@ -106,7 +106,7 @@ impl EigenLayerSubcommand { info!(operator = %signer.address(), rpc = %operator_rpc, ?chain, "Registering EigenLayer operator"); - request_confirmation(); + Cmd::request_confirmation(); let deployments = deployments_for_chain(chain); @@ -186,7 +186,7 @@ impl EigenLayerSubcommand { info!(operator = %address, ?chain, "Deregistering EigenLayer operator"); - request_confirmation(); + Cmd::request_confirmation(); let deployments = deployments_for_chain(chain); diff --git a/bolt-cli/src/commands/operators/symbiotic.rs b/bolt-cli/src/commands/operators/symbiotic.rs index 72f09083..d6b6bf38 100644 --- a/bolt-cli/src/commands/operators/symbiotic.rs +++ b/bolt-cli/src/commands/operators/symbiotic.rs @@ -9,8 +9,8 @@ use eyre::Context; use tracing::{info, warn}; use crate::{ - cli::{Chain, SymbioticSubcommand}, - common::{bolt_manager::BoltManagerContract, request_confirmation, try_parse_contract_error}, + cli::{Chain, Cmd, SymbioticSubcommand}, + common::{bolt_manager::BoltManagerContract, try_parse_contract_error}, contracts::{ bolt::BoltSymbioticMiddleware::{self, BoltSymbioticMiddlewareErrors}, deployments_for_chain, @@ -37,7 +37,7 @@ impl SymbioticSubcommand { info!(operator = %signer.address(), rpc = %operator_rpc, ?chain, "Registering Symbiotic operator"); - request_confirmation(); + Cmd::request_confirmation(); // Check if operator is opted in to the bolt network if !IOptInService::new( @@ -108,7 +108,7 @@ impl SymbioticSubcommand { info!(operator = %address, ?chain, "Deregistering Symbiotic operator"); - request_confirmation(); + Cmd::request_confirmation(); let middleware = BoltSymbioticMiddleware::new(deployments.bolt.symbiotic_middleware, provider); diff --git a/bolt-cli/src/commands/validators.rs b/bolt-cli/src/commands/validators.rs index 465510a7..cf1f9298 100644 --- a/bolt-cli/src/commands/validators.rs +++ b/bolt-cli/src/commands/validators.rs @@ -7,8 +7,8 @@ use eyre::Context; use tracing::{info, warn}; use crate::{ - cli::{Chain, ValidatorsCommand, ValidatorsSubcommand}, - common::{hash::compress_bls_pubkey, request_confirmation, try_parse_contract_error}, + cli::{Chain, Cmd, ValidatorsCommand, ValidatorsSubcommand}, + common::{hash::compress_bls_pubkey, try_parse_contract_error}, contracts::{ bolt::BoltValidators::{self, BoltValidatorsErrors}, deployments_for_chain, @@ -52,7 +52,7 @@ impl ValidatorsCommand { let bolt_validators = BoltValidators::new(bolt_validators_address, provider.clone()); - request_confirmation(); + Cmd::request_confirmation(); match bolt_validators .batchRegisterValidatorsUnsafe( diff --git a/bolt-cli/src/common/mod.rs b/bolt-cli/src/common/mod.rs index 9a557959..324576d9 100644 --- a/bolt-cli/src/common/mod.rs +++ b/bolt-cli/src/common/mod.rs @@ -1,4 +1,4 @@ -use std::{fs, io::Write, path::PathBuf, str::FromStr}; +use std::{fs, path::PathBuf, str::FromStr}; use alloy::{ contract::Error as ContractError, @@ -10,7 +10,6 @@ use alloy::{ use ethereum_consensus::crypto::PublicKey as BlsPublicKey; use eyre::{Context, ContextCompat, Result}; use serde::Serialize; -use tracing::info; /// BoltManager contract bindings. pub mod bolt_manager; @@ -106,36 +105,3 @@ pub fn try_parse_contract_error(error: ContractError) -> Result _ => Err(error), } } - -/// Asks whether the user wants to proceed further. If not, the process is exited. -#[allow(unreachable_code)] -pub fn request_confirmation() { - // Skip confirmation in tests - #[cfg(test)] - return; - - loop { - info!("Do you want to continue? (yes/no): "); - - print!("Answer: "); - std::io::stdout().flush().expect("Failed to flush"); - - let mut input = String::new(); - std::io::stdin().read_line(&mut input).expect("Failed to read input"); - - let input = input.trim().to_lowercase(); - - match input.as_str() { - "yes" | "y" => { - return; - } - "no" | "n" => { - info!("Aborting"); - std::process::exit(0); - } - _ => { - println!("Invalid input. Please type 'yes' or 'no'."); - } - } - } -} diff --git a/bolt-cli/src/pb/v1.rs b/bolt-cli/src/pb/v1.rs index dbef7a82..edcc8db4 100644 --- a/bolt-cli/src/pb/v1.rs +++ b/bolt-cli/src/pb/v1.rs @@ -89,10 +89,9 @@ pub mod lister_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; + use tonic::codegen::{http::Uri, *}; #[derive(Debug, Clone)] pub struct ListerClient { inner: tonic::client::Grpc, @@ -136,9 +135,8 @@ pub mod lister_client { >::ResponseBody, >, >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, + >>::Error: + Into + std::marker::Send + std::marker::Sync, { ListerClient::new(InterceptedService::new(inner, interceptor)) } @@ -176,18 +174,11 @@ pub mod lister_client { pub async fn list_accounts( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.Lister/ListAccounts"); let mut req = request.into_request(); @@ -203,19 +194,17 @@ pub mod lister_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with ListerServer. + /// Generated trait containing gRPC methods that should be implemented for use with + /// ListerServer. #[async_trait] pub trait Lister: std::marker::Send + std::marker::Sync + 'static { async fn list_accounts( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct ListerServer { @@ -238,10 +227,7 @@ pub mod lister_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -296,23 +282,16 @@ pub mod lister_server { "/v1.Lister/ListAccounts" => { #[allow(non_camel_case_types)] struct ListAccountsSvc(pub Arc); - impl< - T: Lister, - > tonic::server::UnaryService - for ListAccountsSvc { + impl tonic::server::UnaryService for ListAccountsSvc { type Response = super::ListAccountsResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::list_accounts(&inner, request).await - }; + let fut = + async move { ::list_accounts(&inner, request).await }; Box::pin(fut) } } @@ -338,23 +317,16 @@ pub mod lister_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } + _ => Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers.insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); + Ok(response) + }), } } } @@ -498,10 +470,9 @@ pub mod signer_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; + use tonic::codegen::{http::Uri, *}; #[derive(Debug, Clone)] pub struct SignerClient { inner: tonic::client::Grpc, @@ -545,9 +516,8 @@ pub mod signer_client { >::ResponseBody, >, >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, + >>::Error: + Into + std::marker::Send + std::marker::Sync, { SignerClient::new(InterceptedService::new(inner, interceptor)) } @@ -586,14 +556,9 @@ pub mod signer_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.Signer/Sign"); let mut req = request.into_request(); @@ -603,18 +568,10 @@ pub mod signer_client { pub async fn multisign( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.Signer/Multisign"); let mut req = request.into_request(); @@ -625,66 +582,39 @@ pub mod signer_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1.Signer/SignBeaconAttestation", - ); + let path = http::uri::PathAndQuery::from_static("/v1.Signer/SignBeaconAttestation"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestation")); + req.extensions_mut().insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestation")); self.inner.unary(req, path, codec).await } pub async fn sign_beacon_attestations( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1.Signer/SignBeaconAttestations", - ); + let path = http::uri::PathAndQuery::from_static("/v1.Signer/SignBeaconAttestations"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestations")); + req.extensions_mut().insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestations")); self.inner.unary(req, path, codec).await } pub async fn sign_beacon_proposal( &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1.Signer/SignBeaconProposal", - ); + let path = http::uri::PathAndQuery::from_static("/v1.Signer/SignBeaconProposal"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("v1.Signer", "SignBeaconProposal")); + req.extensions_mut().insert(GrpcMethod::new("v1.Signer", "SignBeaconProposal")); self.inner.unary(req, path, codec).await } } @@ -696,10 +626,11 @@ pub mod signer_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with SignerServer. + /// Generated trait containing gRPC methods that should be implemented for use with + /// SignerServer. #[async_trait] pub trait Signer: std::marker::Send + std::marker::Sync + 'static { async fn sign( @@ -709,10 +640,7 @@ pub mod signer_server { async fn multisign( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn sign_beacon_attestation( &self, request: tonic::Request, @@ -720,10 +648,7 @@ pub mod signer_server { async fn sign_beacon_attestations( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn sign_beacon_proposal( &self, request: tonic::Request, @@ -750,10 +675,7 @@ pub mod signer_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -808,21 +730,15 @@ pub mod signer_server { "/v1.Signer/Sign" => { #[allow(non_camel_case_types)] struct SignSvc(pub Arc); - impl tonic::server::UnaryService - for SignSvc { + impl tonic::server::UnaryService for SignSvc { type Response = super::SignResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::sign(&inner, request).await - }; + let fut = async move { ::sign(&inner, request).await }; Box::pin(fut) } } @@ -851,21 +767,16 @@ pub mod signer_server { "/v1.Signer/Multisign" => { #[allow(non_camel_case_types)] struct MultisignSvc(pub Arc); - impl tonic::server::UnaryService - for MultisignSvc { + impl tonic::server::UnaryService for MultisignSvc { type Response = super::MultisignResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::multisign(&inner, request).await - }; + let fut = + async move { ::multisign(&inner, request).await }; Box::pin(fut) } } @@ -894,23 +805,18 @@ pub mod signer_server { "/v1.Signer/SignBeaconAttestation" => { #[allow(non_camel_case_types)] struct SignBeaconAttestationSvc(pub Arc); - impl< - T: Signer, - > tonic::server::UnaryService - for SignBeaconAttestationSvc { + impl tonic::server::UnaryService + for SignBeaconAttestationSvc + { type Response = super::SignResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::sign_beacon_attestation(&inner, request) - .await + ::sign_beacon_attestation(&inner, request).await }; Box::pin(fut) } @@ -940,23 +846,19 @@ pub mod signer_server { "/v1.Signer/SignBeaconAttestations" => { #[allow(non_camel_case_types)] struct SignBeaconAttestationsSvc(pub Arc); - impl< - T: Signer, - > tonic::server::UnaryService - for SignBeaconAttestationsSvc { + impl + tonic::server::UnaryService + for SignBeaconAttestationsSvc + { type Response = super::MultisignResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::sign_beacon_attestations(&inner, request) - .await + ::sign_beacon_attestations(&inner, request).await }; Box::pin(fut) } @@ -986,15 +888,11 @@ pub mod signer_server { "/v1.Signer/SignBeaconProposal" => { #[allow(non_camel_case_types)] struct SignBeaconProposalSvc(pub Arc); - impl< - T: Signer, - > tonic::server::UnaryService - for SignBeaconProposalSvc { + impl tonic::server::UnaryService + for SignBeaconProposalSvc + { type Response = super::SignResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -1028,23 +926,16 @@ pub mod signer_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } + _ => Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers.insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); + Ok(response) + }), } } } @@ -1117,10 +1008,9 @@ pub mod account_manager_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; + use tonic::codegen::{http::Uri, *}; #[derive(Debug, Clone)] pub struct AccountManagerClient { inner: tonic::client::Grpc, @@ -1164,9 +1054,8 @@ pub mod account_manager_client { >::ResponseBody, >, >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, + >>::Error: + Into + std::marker::Send + std::marker::Sync, { AccountManagerClient::new(InterceptedService::new(inner, interceptor)) } @@ -1204,18 +1093,11 @@ pub mod account_manager_client { pub async fn unlock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.AccountManager/Unlock"); let mut req = request.into_request(); @@ -1225,18 +1107,11 @@ pub mod account_manager_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.AccountManager/Lock"); let mut req = request.into_request(); @@ -1246,25 +1121,14 @@ pub mod account_manager_client { pub async fn generate( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static( - "/v1.AccountManager/Generate", - ); + let path = http::uri::PathAndQuery::from_static("/v1.AccountManager/Generate"); let mut req = request.into_request(); - req.extensions_mut() - .insert(GrpcMethod::new("v1.AccountManager", "Generate")); + req.extensions_mut().insert(GrpcMethod::new("v1.AccountManager", "Generate")); self.inner.unary(req, path, codec).await } } @@ -1276,33 +1140,25 @@ pub mod account_manager_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with AccountManagerServer. + /// Generated trait containing gRPC methods that should be implemented for use with + /// AccountManagerServer. #[async_trait] pub trait AccountManager: std::marker::Send + std::marker::Sync + 'static { async fn unlock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn generate( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct AccountManagerServer { @@ -1325,10 +1181,7 @@ pub mod account_manager_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -1383,23 +1236,16 @@ pub mod account_manager_server { "/v1.AccountManager/Unlock" => { #[allow(non_camel_case_types)] struct UnlockSvc(pub Arc); - impl< - T: AccountManager, - > tonic::server::UnaryService - for UnlockSvc { + impl tonic::server::UnaryService for UnlockSvc { type Response = super::UnlockAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::unlock(&inner, request).await - }; + let fut = + async move { ::unlock(&inner, request).await }; Box::pin(fut) } } @@ -1428,23 +1274,16 @@ pub mod account_manager_server { "/v1.AccountManager/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl< - T: AccountManager, - > tonic::server::UnaryService - for LockSvc { + impl tonic::server::UnaryService for LockSvc { type Response = super::LockAccountResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::lock(&inner, request).await - }; + let fut = + async move { ::lock(&inner, request).await }; Box::pin(fut) } } @@ -1473,15 +1312,9 @@ pub mod account_manager_server { "/v1.AccountManager/Generate" => { #[allow(non_camel_case_types)] struct GenerateSvc(pub Arc); - impl< - T: AccountManager, - > tonic::server::UnaryService - for GenerateSvc { + impl tonic::server::UnaryService for GenerateSvc { type Response = super::GenerateResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, @@ -1515,23 +1348,16 @@ pub mod account_manager_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } + _ => Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers.insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); + Ok(response) + }), } } } @@ -1582,10 +1408,9 @@ pub mod wallet_manager_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] - use tonic::codegen::*; - use tonic::codegen::http::Uri; + use tonic::codegen::{http::Uri, *}; #[derive(Debug, Clone)] pub struct WalletManagerClient { inner: tonic::client::Grpc, @@ -1629,9 +1454,8 @@ pub mod wallet_manager_client { >::ResponseBody, >, >, - , - >>::Error: Into + std::marker::Send + std::marker::Sync, + >>::Error: + Into + std::marker::Send + std::marker::Sync, { WalletManagerClient::new(InterceptedService::new(inner, interceptor)) } @@ -1669,18 +1493,11 @@ pub mod wallet_manager_client { pub async fn unlock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.WalletManager/Unlock"); let mut req = request.into_request(); @@ -1690,18 +1507,11 @@ pub mod wallet_manager_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - > { - self.inner - .ready() - .await - .map_err(|e| { - tonic::Status::unknown( - format!("Service was not ready: {}", e.into()), - ) - })?; + ) -> std::result::Result, tonic::Status> + { + self.inner.ready().await.map_err(|e| { + tonic::Status::unknown(format!("Service was not ready: {}", e.into())) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.WalletManager/Lock"); let mut req = request.into_request(); @@ -1717,26 +1527,21 @@ pub mod wallet_manager_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value, + clippy::let_unit_value )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with WalletManagerServer. + /// Generated trait containing gRPC methods that should be implemented for use with + /// WalletManagerServer. #[async_trait] pub trait WalletManager: std::marker::Send + std::marker::Sync + 'static { async fn unlock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; async fn lock( &self, request: tonic::Request, - ) -> std::result::Result< - tonic::Response, - tonic::Status, - >; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct WalletManagerServer { @@ -1759,10 +1564,7 @@ pub mod wallet_manager_server { max_encoding_message_size: None, } } - pub fn with_interceptor( - inner: T, - interceptor: F, - ) -> InterceptedService + pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService where F: tonic::service::Interceptor, { @@ -1817,23 +1619,16 @@ pub mod wallet_manager_server { "/v1.WalletManager/Unlock" => { #[allow(non_camel_case_types)] struct UnlockSvc(pub Arc); - impl< - T: WalletManager, - > tonic::server::UnaryService - for UnlockSvc { + impl tonic::server::UnaryService for UnlockSvc { type Response = super::UnlockWalletResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::unlock(&inner, request).await - }; + let fut = + async move { ::unlock(&inner, request).await }; Box::pin(fut) } } @@ -1862,23 +1657,16 @@ pub mod wallet_manager_server { "/v1.WalletManager/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl< - T: WalletManager, - > tonic::server::UnaryService - for LockSvc { + impl tonic::server::UnaryService for LockSvc { type Response = super::LockWalletResponse; - type Future = BoxFuture< - tonic::Response, - tonic::Status, - >; + type Future = BoxFuture, tonic::Status>; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { - ::lock(&inner, request).await - }; + let fut = + async move { ::lock(&inner, request).await }; Box::pin(fut) } } @@ -1904,23 +1692,16 @@ pub mod wallet_manager_server { }; Box::pin(fut) } - _ => { - Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers - .insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers - .insert( - http::header::CONTENT_TYPE, - tonic::metadata::GRPC_CONTENT_TYPE, - ); - Ok(response) - }) - } + _ => Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers.insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); + Ok(response) + }), } } } From a1e065428a6216578f448c98dbc638db67371193 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Mon, 13 Jan 2025 11:36:32 +0100 Subject: [PATCH 25/33] chore(sidecar): clean up imports --- bolt-sidecar/Cargo.lock | 388 ++++++++---------------- bolt-sidecar/Cargo.toml | 4 +- bolt-sidecar/src/signer/commit_boost.rs | 3 +- 3 files changed, 128 insertions(+), 267 deletions(-) diff --git a/bolt-sidecar/Cargo.lock b/bolt-sidecar/Cargo.lock index 4813402b..00a9f0c5 100644 --- a/bolt-sidecar/Cargo.lock +++ b/bolt-sidecar/Cargo.lock @@ -132,16 +132,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59febb24956a41c29bb5f450978fbe825bd6456b3f80586c8bd558dc882e7b6a" dependencies = [ "alloy-consensus 0.8.0", + "alloy-contract 0.8.3", "alloy-core", "alloy-eips 0.8.0", "alloy-genesis 0.8.0", "alloy-network 0.8.0", "alloy-provider 0.8.0", + "alloy-pubsub 0.8.3", "alloy-rpc-client 0.8.0", "alloy-rpc-types 0.8.0", "alloy-serde 0.8.0", + "alloy-signer 0.8.0", + "alloy-signer-local 0.8.3", "alloy-transport 0.8.0", "alloy-transport-http 0.8.0", + "alloy-transport-ipc 0.8.3", + "alloy-transport-ws 0.8.3", ] [[package]] @@ -151,22 +157,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbcc41e8a11a4975b18ec6afba2cc48d591fa63336a4c526dacb50479a8d6b35" dependencies = [ "alloy-consensus 0.9.2", - "alloy-contract", + "alloy-contract 0.9.2", "alloy-core", "alloy-eips 0.9.2", "alloy-genesis 0.9.2", "alloy-network 0.9.2", "alloy-provider 0.9.2", - "alloy-pubsub", + "alloy-pubsub 0.9.2", "alloy-rpc-client 0.9.2", "alloy-rpc-types 0.9.2", "alloy-serde 0.9.2", "alloy-signer 0.9.2", - "alloy-signer-local", + "alloy-signer-local 0.9.2", "alloy-transport 0.9.2", "alloy-transport-http 0.9.2", - "alloy-transport-ipc", - "alloy-transport-ws", + "alloy-transport-ipc 0.9.2", + "alloy-transport-ws 0.9.2", ] [[package]] @@ -195,6 +201,7 @@ dependencies = [ "auto_impl", "c-kzg", "derive_more 1.0.0", + "k256 0.13.4", "serde", ] @@ -246,6 +253,27 @@ dependencies = [ "serde", ] +[[package]] +name = "alloy-contract" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b668c78c4b1f12f474ede5a85e8ce550d0aa1ef7d49fd1d22855a43b960e725" +dependencies = [ + "alloy-dyn-abi", + "alloy-json-abi", + "alloy-network 0.8.0", + "alloy-network-primitives 0.8.0", + "alloy-primitives 0.8.15", + "alloy-provider 0.8.0", + "alloy-pubsub 0.8.3", + "alloy-rpc-types-eth 0.8.0", + "alloy-sol-types", + "alloy-transport 0.8.0", + "futures", + "futures-util", + "thiserror 2.0.9", +] + [[package]] name = "alloy-contract" version = "0.9.2" @@ -258,7 +286,7 @@ dependencies = [ "alloy-network-primitives 0.9.2", "alloy-primitives 0.8.15", "alloy-provider 0.9.2", - "alloy-pubsub", + "alloy-pubsub 0.9.2", "alloy-rpc-types-eth 0.9.2", "alloy-sol-types", "alloy-transport 0.9.2", @@ -332,6 +360,7 @@ dependencies = [ "alloy-primitives 0.8.15", "alloy-rlp", "derive_more 1.0.0", + "k256 0.13.4", "serde", ] @@ -614,14 +643,17 @@ dependencies = [ "alloy-network 0.8.0", "alloy-network-primitives 0.8.0", "alloy-primitives 0.8.15", + "alloy-pubsub 0.8.3", "alloy-rpc-client 0.8.0", "alloy-rpc-types-eth 0.8.0", "alloy-transport 0.8.0", "alloy-transport-http 0.8.0", + "alloy-transport-ipc 0.8.3", + "alloy-transport-ws 0.8.3", "async-stream", "async-trait", "auto_impl", - "dashmap 6.1.0", + "dashmap", "futures", "futures-utils-wasm", "lru", @@ -651,19 +683,19 @@ dependencies = [ "alloy-network 0.9.2", "alloy-network-primitives 0.9.2", "alloy-primitives 0.8.15", - "alloy-pubsub", + "alloy-pubsub 0.9.2", "alloy-rpc-client 0.9.2", "alloy-rpc-types-engine 0.9.2", "alloy-rpc-types-eth 0.9.2", "alloy-rpc-types-trace", "alloy-transport 0.9.2", "alloy-transport-http 0.9.2", - "alloy-transport-ipc", - "alloy-transport-ws", + "alloy-transport-ipc 0.9.2", + "alloy-transport-ws 0.9.2", "async-stream", "async-trait", "auto_impl", - "dashmap 6.1.0", + "dashmap", "futures", "futures-utils-wasm", "lru", @@ -680,6 +712,25 @@ dependencies = [ "wasmtimer", ] +[[package]] +name = "alloy-pubsub" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "695809e743628d54510c294ad17a4645bd9f465aeb0d20ee9ce9877c9712dc9c" +dependencies = [ + "alloy-json-rpc 0.8.0", + "alloy-primitives 0.8.15", + "alloy-transport 0.8.0", + "bimap", + "futures", + "serde", + "serde_json", + "tokio", + "tokio-stream", + "tower", + "tracing", +] + [[package]] name = "alloy-pubsub" version = "0.9.2" @@ -729,8 +780,11 @@ checksum = "5c6a0bd0ce5660ac48e4f3bb0c7c5c3a94db287a0be94971599d83928476cbcd" dependencies = [ "alloy-json-rpc 0.8.0", "alloy-primitives 0.8.15", + "alloy-pubsub 0.8.3", "alloy-transport 0.8.0", "alloy-transport-http 0.8.0", + "alloy-transport-ipc 0.8.3", + "alloy-transport-ws 0.8.3", "futures", "pin-project", "reqwest 0.12.9", @@ -752,11 +806,11 @@ checksum = "d06a292b37e182e514903ede6e623b9de96420e8109ce300da288a96d88b7e4b" dependencies = [ "alloy-json-rpc 0.9.2", "alloy-primitives 0.8.15", - "alloy-pubsub", + "alloy-pubsub 0.9.2", "alloy-transport 0.9.2", "alloy-transport-http 0.9.2", - "alloy-transport-ipc", - "alloy-transport-ws", + "alloy-transport-ipc 0.9.2", + "alloy-transport-ws 0.9.2", "futures", "pin-project", "reqwest 0.12.9", @@ -993,6 +1047,22 @@ dependencies = [ "thiserror 2.0.9", ] +[[package]] +name = "alloy-signer-local" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47fababf5a745133490cde927d48e50267f97d3d1209b9fc9f1d1d666964d172" +dependencies = [ + "alloy-consensus 0.8.0", + "alloy-network 0.8.0", + "alloy-primitives 0.8.15", + "alloy-signer 0.8.0", + "async-trait", + "k256 0.13.4", + "rand 0.8.5", + "thiserror 2.0.9", +] + [[package]] name = "alloy-signer-local" version = "0.9.2" @@ -1157,6 +1227,25 @@ dependencies = [ "url", ] +[[package]] +name = "alloy-transport-ipc" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a172a59d24706b26a79a837f86d51745cb26ca6f8524712acd0208a14cff95" +dependencies = [ + "alloy-json-rpc 0.8.0", + "alloy-pubsub 0.8.3", + "alloy-transport 0.8.0", + "bytes", + "futures", + "interprocess", + "pin-project", + "serde_json", + "tokio", + "tokio-util", + "tracing", +] + [[package]] name = "alloy-transport-ipc" version = "0.9.2" @@ -1164,7 +1253,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4da44bc9a5155ab599666d26decafcf12204b72a80eeaba7c5e234ee8ac205" dependencies = [ "alloy-json-rpc 0.9.2", - "alloy-pubsub", + "alloy-pubsub 0.9.2", "alloy-transport 0.9.2", "bytes", "futures", @@ -1176,13 +1265,31 @@ dependencies = [ "tracing", ] +[[package]] +name = "alloy-transport-ws" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fba0e39d181d13c266dbb8ca54ed584a2c66d6e9279afca89c7a6b1825e98abb" +dependencies = [ + "alloy-pubsub 0.8.3", + "alloy-transport 0.8.0", + "futures", + "http 1.2.0", + "rustls 0.23.19", + "serde_json", + "tokio", + "tokio-tungstenite 0.24.0", + "tracing", + "ws_stream_wasm", +] + [[package]] name = "alloy-transport-ws" version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58011745b2f17b334db40df9077d75b181f78360a5bc5c35519e15d4bfce15e2" dependencies = [ - "alloy-pubsub", + "alloy-pubsub 0.9.2", "alloy-transport 0.9.2", "futures", "http 1.2.0", @@ -1687,30 +1794,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "axum-extra" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c794b30c904f0a1c2fb7740f7df7f7972dfaa14ef6f57cb6178dc63e5dca2f04" -dependencies = [ - "axum 0.7.9", - "axum-core 0.4.5", - "bytes", - "fastrand 2.3.0", - "futures-util", - "headers", - "http 1.2.0", - "http-body 1.0.1", - "http-body-util", - "mime", - "multer", - "pin-project-lite", - "serde", - "tower", - "tower-layer", - "tower-service", -] - [[package]] name = "axum-extra" version = "0.10.0" @@ -2021,7 +2104,7 @@ dependencies = [ "alloy-transport-http 0.9.2", "async-trait", "axum 0.8.1", - "axum-extra 0.10.0", + "axum-extra", "beacon-api-client", "bls 0.2.0 (git+https://github.com/sigp/lighthouse)", "blst", @@ -2029,7 +2112,6 @@ dependencies = [ "bytes", "cb-common", "clap", - "commit-boost", "criterion", "derive_more 1.0.0", "dotenvy", @@ -2161,26 +2243,10 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" -[[package]] -name = "cb-cli" -version = "0.4.0" -source = "git+https://github.com/Commit-Boost/commit-boost-client?rev=0f8f69b#0f8f69be3a27e8e095ae4f400afc51d266db790f" -dependencies = [ - "cb-common", - "clap", - "docker-compose-types", - "dotenvy", - "eyre", - "indexmap 2.7.0", - "serde", - "serde_json", - "serde_yaml 0.9.33", -] - [[package]] name = "cb-common" -version = "0.4.0" -source = "git+https://github.com/Commit-Boost/commit-boost-client?rev=0f8f69b#0f8f69be3a27e8e095ae4f400afc51d266db790f" +version = "0.5.0" +source = "git+https://github.com/Commit-Boost/commit-boost-client?tag=v0.5.0#704e9f19719211acfd1697fb8a083c2897aea1a9" dependencies = [ "aes 0.8.4", "alloy 0.8.3", @@ -2215,72 +2281,6 @@ dependencies = [ "url", ] -[[package]] -name = "cb-metrics" -version = "0.4.0" -source = "git+https://github.com/Commit-Boost/commit-boost-client?rev=0f8f69b#0f8f69be3a27e8e095ae4f400afc51d266db790f" -dependencies = [ - "axum 0.7.9", - "cb-common", - "eyre", - "prometheus", - "thiserror 1.0.69", - "tokio", - "tracing", -] - -[[package]] -name = "cb-pbs" -version = "0.4.0" -source = "git+https://github.com/Commit-Boost/commit-boost-client?rev=0f8f69b#0f8f69be3a27e8e095ae4f400afc51d266db790f" -dependencies = [ - "alloy 0.8.3", - "async-trait", - "axum 0.7.9", - "blst", - "cb-common", - "cb-metrics", - "dashmap 5.5.3", - "eyre", - "futures", - "lazy_static", - "parking_lot", - "prometheus", - "reqwest 0.12.9", - "serde_json", - "thiserror 1.0.69", - "tokio", - "tracing", - "url", - "uuid 1.11.0", -] - -[[package]] -name = "cb-signer" -version = "0.4.0" -source = "git+https://github.com/Commit-Boost/commit-boost-client?rev=0f8f69b#0f8f69be3a27e8e095ae4f400afc51d266db790f" -dependencies = [ - "alloy 0.8.3", - "axum 0.7.9", - "axum-extra 0.9.6", - "bimap", - "blst", - "cb-common", - "cb-metrics", - "derive_more 1.0.0", - "eyre", - "headers", - "k256 0.13.4", - "lazy_static", - "prometheus", - "thiserror 1.0.69", - "tokio", - "tracing", - "tree_hash 0.8.0", - "tree_hash_derive", - "uuid 1.11.0", -] - [[package]] name = "cc" version = "1.2.3" @@ -2444,58 +2444,12 @@ dependencies = [ "cc", ] -[[package]] -name = "color-eyre" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - [[package]] name = "colorchoice" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" -[[package]] -name = "commit-boost" -version = "0.4.0" -source = "git+https://github.com/Commit-Boost/commit-boost-client?rev=0f8f69b#0f8f69be3a27e8e095ae4f400afc51d266db790f" -dependencies = [ - "cb-cli", - "cb-common", - "cb-metrics", - "cb-pbs", - "cb-signer", - "clap", - "color-eyre", - "eyre", - "tokio", - "tracing", - "tree_hash 0.8.0", - "tree_hash_derive", -] - [[package]] name = "compare_fields" version = "0.2.0" @@ -2940,19 +2894,6 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04d2cd9c18b9f454ed67da600630b021a8a80bf33f8c95896ab33aaf1c26b728" -[[package]] -name = "dashmap" -version = "5.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" -dependencies = [ - "cfg-if", - "hashbrown 0.14.5", - "lock_api", - "once_cell", - "parking_lot_core", -] - [[package]] name = "dashmap" version = "6.1.0" @@ -3071,37 +3012,6 @@ dependencies = [ "syn 2.0.90", ] -[[package]] -name = "derive_builder" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" -dependencies = [ - "darling 0.20.10", - "proc-macro2", - "quote", - "syn 2.0.90", -] - -[[package]] -name = "derive_builder_macro" -version = "0.20.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" -dependencies = [ - "derive_builder_core", - "syn 2.0.90", -] - [[package]] name = "derive_more" version = "0.99.18" @@ -3253,18 +3163,6 @@ dependencies = [ "syn 2.0.90", ] -[[package]] -name = "docker-compose-types" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9213a368b9c0767c81ef9ced0f712cfd99d27d7de2a22a60e7ac9b1342c8a395" -dependencies = [ - "derive_builder", - "indexmap 2.7.0", - "serde", - "serde_yaml 0.9.33", -] - [[package]] name = "doctest-file" version = "1.0.0" @@ -5637,23 +5535,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fafa6961cabd9c63bcd77a45d7e3b7f3b552b70417831fb0f56db717e72407e" -[[package]] -name = "multer" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" -dependencies = [ - "bytes", - "encoding_rs", - "futures-util", - "http 1.2.0", - "httparse", - "memchr", - "mime", - "spin 0.9.8", - "version_check", -] - [[package]] name = "multiaddr" version = "0.14.0" @@ -6035,12 +5916,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - [[package]] name = "pairing" version = "0.23.0" @@ -8672,16 +8547,6 @@ dependencies = [ "valuable", ] -[[package]] -name = "tracing-error" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1581020d7a273442f5b45074a6a57d5757ad0a47dac0e9f0bd57b81936f3db" -dependencies = [ - "tracing", - "tracing-subscriber", -] - [[package]] name = "tracing-log" version = "0.2.0" @@ -9055,7 +8920,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom 0.2.15", - "rand 0.8.5", "serde", ] diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index 620bec67..dc3cc571 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -79,9 +79,7 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter", "fmt"] } metrics = "0.23" metrics-exporter-prometheus = { version = "0.15.3", features = ["http-listener"] } -# commit-boost -commit-boost = { git = "https://github.com/Commit-Boost/commit-boost-client", rev = "0f8f69b" } -cb-common = { git = "https://github.com/Commit-Boost/commit-boost-client", rev = "0f8f69b" } +cb-common = { git = "https://github.com/Commit-Boost/commit-boost-client", tag = "v0.5.0" } [dev-dependencies] alloy-node-bindings = "0.8.3" # must match alloy version diff --git a/bolt-sidecar/src/signer/commit_boost.rs b/bolt-sidecar/src/signer/commit_boost.rs index 84eebd23..2b1213a7 100644 --- a/bolt-sidecar/src/signer/commit_boost.rs +++ b/bolt-sidecar/src/signer/commit_boost.rs @@ -9,11 +9,10 @@ use cb_common::{ commit::{ client::SignerClient, error::SignerClientError, - request::{GetPubkeysResponse, SignConsensusRequest}, + request::{GetPubkeysResponse, SignConsensusRequest, SignProxyRequest}, }, signer::EcdsaPublicKey, }; -use commit_boost::prelude::SignProxyRequest; use ethereum_consensus::crypto::bls::PublicKey as BlsPublicKey; use parking_lot::RwLock; use reqwest::Url; From c232c3acf12f798fe11cb3b07007e01097958bf2 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Mon, 13 Jan 2025 11:48:00 +0100 Subject: [PATCH 26/33] fix(sidecar); hard-coded error code in tests --- bolt-sidecar/src/api/commitments/server/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bolt-sidecar/src/api/commitments/server/mod.rs b/bolt-sidecar/src/api/commitments/server/mod.rs index 8ff32914..896ee121 100644 --- a/bolt-sidecar/src/api/commitments/server/mod.rs +++ b/bolt-sidecar/src/api/commitments/server/mod.rs @@ -177,7 +177,10 @@ fn make_router(state: Arc) -> Router { #[cfg(test)] mod test { - use crate::{api::commitments::spec::SIGNATURE_HEADER, common::BOLT_SIDECAR_VERSION}; + use crate::{ + api::commitments::spec::SIGNATURE_HEADER, common::BOLT_SIDECAR_VERSION, + primitives::jsonrpc::JsonError, + }; use alloy::signers::{k256::SecretKey, local::PrivateKeySigner}; use handlers::MetadataResponse; use serde_json::json; @@ -228,7 +231,8 @@ mod test { .unwrap(); // Assert unauthorized because of missing signature - assert_eq!(response.error.unwrap().code, -32003); + let expected_error: JsonError = CommitmentError::NoSignature.into(); + assert_eq!(response.error.unwrap().code, expected_error.code); } #[tokio::test] From d94bb814ce7d34f2cd7ce0994b6bd321ca1dfc2e Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Mon, 13 Jan 2025 17:04:58 +0100 Subject: [PATCH 27/33] chore(sidecar): JsonRpcResponse should be an enum --- .../src/api/commitments/firewall/processor.rs | 49 ++++---- .../src/api/commitments/server/handlers.rs | 34 +++--- .../src/api/commitments/server/mod.rs | 19 +-- bolt-sidecar/src/api/commitments/spec.rs | 7 +- bolt-sidecar/src/primitives/jsonrpc.rs | 111 +++++++++++++++--- 5 files changed, 155 insertions(+), 65 deletions(-) diff --git a/bolt-sidecar/src/api/commitments/firewall/processor.rs b/bolt-sidecar/src/api/commitments/firewall/processor.rs index b18a92b6..e91b32ca 100644 --- a/bolt-sidecar/src/api/commitments/firewall/processor.rs +++ b/bolt-sidecar/src/api/commitments/firewall/processor.rs @@ -2,6 +2,7 @@ use futures::{ stream::{FuturesUnordered, SplitSink, SplitStream}, FutureExt, SinkExt, StreamExt, }; +use serde::Serialize; use serde_json::{json, Value}; use std::{collections::VecDeque, future::Future, pin::Pin, task::Poll}; use tokio::{ @@ -30,7 +31,9 @@ use crate::{ config::limits::LimitsOpts, primitives::{ commitment::SignedCommitment, - jsonrpc::{JsonResponse, JsonRpcRequestUuid}, + jsonrpc::{ + JsonRpcErrorResponse, JsonRpcRequestUuid, JsonRpcResponse, JsonRpcSuccessResponse, + }, misc::{Identified, IntoIdentified}, CommitmentRequest, InclusionRequest, }, @@ -257,15 +260,14 @@ impl CommitmentRequestProcessor { return; }; - let mut response = - JsonResponse { id: Some(Value::String(id.to_string())), ..Default::default() }; - - match result_commitment { - Ok(commitment) => response.result = json!(commitment), + let response: JsonRpcResponse = match result_commitment { + Ok(commitment) => JsonRpcSuccessResponse::new(json!(commitment)) + .with_id(Value::String(id.to_string())) + .into(), Err(e) => { - response.error = Some(e.into()); + JsonRpcErrorResponse::new(e.into()).with_id(Value::String(id.to_string())).into() } - } + }; let message = Message::Text(serde_json::to_string(&response).expect("to stringify response")); @@ -289,26 +291,27 @@ impl CommitmentRequestProcessor { }; let id = request.id; - let mut response = JsonResponse { - id: Some(Value::String(id.to_string())), - jsonrpc: "2.0".to_string(), - ..Default::default() - }; match request.method.as_str() { GET_VERSION_METHOD => { - response.result = Value::String(BOLT_SIDECAR_VERSION.clone()); + let response = + JsonRpcSuccessResponse::new(Value::String(BOLT_SIDECAR_VERSION.clone())) + .with_uuid(id) + .into(); self.send_response(response); } GET_METADATA_METHOD => { - response.result = serde_json::to_value(self.state.limits).expect("infallible"); + let response = + JsonRpcSuccessResponse::new(json!(self.state.limits)).with_uuid(id).into(); self.send_response(response); } REQUEST_INCLUSION_METHOD => { let Some(param) = request.params.first().cloned() else { - response.error = Some( + let response: JsonRpcResponse = JsonRpcErrorResponse::new( CommitmentError::InvalidParams("missing inclusion request".into()).into(), - ); + ) + .with_uuid(id) + .into(); self.send_response(response); return; }; @@ -318,7 +321,10 @@ impl CommitmentRequestProcessor { Err(e) => { let msg = format!("failed to parse inclusion request: {}", e); error!(?e, "failed to parse inclusion request"); - response.error = Some(CommitmentError::InvalidParams(msg).into()); + let response: JsonRpcResponse = + JsonRpcErrorResponse::new(CommitmentError::InvalidParams(msg).into()) + .with_uuid(id) + .into(); self.send_response(response); return; } @@ -330,7 +336,10 @@ impl CommitmentRequestProcessor { if let Err(e) = self.api_events_tx.try_send(commitment_event) { error!(?e, "failed to send commitment event through channel"); - response.error = Some(CommitmentError::Internal.into()); + let response: JsonRpcResponse = + JsonRpcErrorResponse::new(CommitmentError::Internal.into()) + .with_uuid(id) + .into(); self.send_response(response); return; } @@ -344,7 +353,7 @@ impl CommitmentRequestProcessor { }; } - fn send_response(&mut self, response: JsonResponse) { + fn send_response(&mut self, response: JsonRpcResponse) { let message = Message::text(serde_json::to_string(&response).expect("to stringify response")); self.outgoing_messages.push_back(message); diff --git a/bolt-sidecar/src/api/commitments/server/handlers.rs b/bolt-sidecar/src/api/commitments/server/handlers.rs index cad5f33c..b36fbd99 100644 --- a/bolt-sidecar/src/api/commitments/server/handlers.rs +++ b/bolt-sidecar/src/api/commitments/server/handlers.rs @@ -9,7 +9,7 @@ use axum::{ }; use axum_extra::extract::WithRejection; use serde::{Deserialize, Serialize}; -use serde_json::Value; +use serde_json::json; use tracing::{debug, error, info, instrument}; use crate::{ @@ -23,7 +23,7 @@ use crate::{ common::BOLT_SIDECAR_VERSION, config::limits::LimitsOpts, primitives::{ - jsonrpc::{JsonResponse, JsonRpcRequest}, + jsonrpc::{JsonRpcRequest, JsonRpcResponse, JsonRpcSuccessResponse}, signature::SignatureError, InclusionRequest, }, @@ -48,15 +48,18 @@ pub async fn rpc_entrypoint( headers: HeaderMap, State(api): State>, WithRejection(Json(payload), _): WithRejection, CommitmentError>, -) -> Result, CommitmentError> { +) -> Result, CommitmentError> { debug!("Received new request"); match payload.method.as_str() { - GET_VERSION_METHOD => Ok(Json(JsonResponse { - id: payload.id, - result: Value::String(BOLT_SIDECAR_VERSION.clone()), - ..Default::default() - })), + GET_VERSION_METHOD => Ok(Json( + JsonRpcSuccessResponse { + id: payload.id, + result: json!(BOLT_SIDECAR_VERSION.to_string()), + ..Default::default() + } + .into(), + )), GET_METADATA_METHOD => { let metadata = MetadataResponse { @@ -64,12 +67,12 @@ pub async fn rpc_entrypoint( version: BOLT_SIDECAR_VERSION.to_string(), }; - let response = JsonResponse { + let response = JsonRpcSuccessResponse { id: payload.id, - result: serde_json::to_value(metadata) - .expect("infallible - metadata only contains primitive types"), + result: json!(metadata), ..Default::default() - }; + } + .into(); Ok(Json(response)) } @@ -113,11 +116,12 @@ pub async fn rpc_entrypoint( let inclusion_commitment = api.request_inclusion(inclusion_request).await?; // Create the JSON-RPC response - let response = JsonResponse { + let response = JsonRpcSuccessResponse { id: payload.id, - result: serde_json::to_value(inclusion_commitment).expect("infallible"), + result: json!(inclusion_commitment), ..Default::default() - }; + } + .into(); Ok(Json(response)) } diff --git a/bolt-sidecar/src/api/commitments/server/mod.rs b/bolt-sidecar/src/api/commitments/server/mod.rs index 896ee121..d3297616 100644 --- a/bolt-sidecar/src/api/commitments/server/mod.rs +++ b/bolt-sidecar/src/api/commitments/server/mod.rs @@ -179,14 +179,14 @@ fn make_router(state: Arc) -> Router { mod test { use crate::{ api::commitments::spec::SIGNATURE_HEADER, common::BOLT_SIDECAR_VERSION, - primitives::jsonrpc::JsonError, + primitives::jsonrpc::JsonRpcError, }; use alloy::signers::{k256::SecretKey, local::PrivateKeySigner}; use handlers::MetadataResponse; use serde_json::json; use crate::{ - primitives::{jsonrpc::JsonResponse, signature::ECDSASignatureExt}, + primitives::{jsonrpc::JsonRpcResponse, signature::ECDSASignatureExt}, test_util::{create_signed_inclusion_request, default_test_transaction}, }; @@ -226,13 +226,13 @@ mod test { .send() .await .unwrap() - .json::() + .json::() .await .unwrap(); // Assert unauthorized because of missing signature - let expected_error: JsonError = CommitmentError::NoSignature.into(); - assert_eq!(response.error.unwrap().code, expected_error.code); + let expected_error: JsonRpcError = CommitmentError::NoSignature.into(); + assert_eq!(response.into_error().unwrap().code(), expected_error.code); } #[tokio::test] @@ -276,10 +276,10 @@ mod test { .await .unwrap(); - let json = response.json::().await.unwrap(); + let json = response.json::().await.unwrap(); // Assert unauthorized because of missing signature - assert!(json.error.is_none()); + assert!(json.into_success().is_some()); let _ = tx.send(()); }); @@ -320,11 +320,12 @@ mod test { .send() .await .unwrap() - .json::() + .json::() .await .unwrap(); - let metadata: MetadataResponse = serde_json::from_value(response.result).unwrap(); + let metadata: MetadataResponse = + serde_json::from_value(response.into_success().unwrap().result).unwrap(); assert_eq!( metadata.limits.max_committed_gas_per_slot, diff --git a/bolt-sidecar/src/api/commitments/spec.rs b/bolt-sidecar/src/api/commitments/spec.rs index f3f40b0e..b33c4154 100644 --- a/bolt-sidecar/src/api/commitments/spec.rs +++ b/bolt-sidecar/src/api/commitments/spec.rs @@ -11,7 +11,7 @@ use thiserror::Error; use crate::{ primitives::{ commitment::InclusionCommitment, - jsonrpc::{JsonError, JsonResponse}, + jsonrpc::{JsonRpcError, JsonRpcErrorResponse}, signature::SignatureError, InclusionRequest, }, @@ -72,7 +72,7 @@ pub enum CommitmentError { RejectedJson(#[from] JsonRejection), } -impl From for JsonError { +impl From for JsonRpcError { fn from(err: CommitmentError) -> Self { // Reference: https://www.jsonrpc.org/specification#error_object // TODO: the custom defined ones should be clearly documented. @@ -117,7 +117,8 @@ impl From<&CommitmentError> for StatusCode { impl IntoResponse for CommitmentError { fn into_response(self) -> Response { let status_code = StatusCode::from(&self); - let json = Json(JsonResponse::from_error(self.into())); + let err = JsonRpcError::from(self); + let json = Json(JsonRpcErrorResponse::new(err)); (status_code, json).into_response() } diff --git a/bolt-sidecar/src/primitives/jsonrpc.rs b/bolt-sidecar/src/primitives/jsonrpc.rs index e59f9dcf..b86e76c3 100644 --- a/bolt-sidecar/src/primitives/jsonrpc.rs +++ b/bolt-sidecar/src/primitives/jsonrpc.rs @@ -1,3 +1,4 @@ +use derive_more::derive::From; use serde::{Deserialize, Serialize}; use serde_json::Value; use uuid::Uuid; @@ -28,44 +29,118 @@ pub struct JsonRpcRequestUuid { pub params: Vec, } -/// A JSON-RPC response +/// A response object for JSON-RPC. +#[derive(Debug, Clone, Serialize, Deserialize, From)] +#[serde(untagged)] +pub enum JsonRpcResponse { + /// A successful response. + Success(JsonRpcSuccessResponse), + /// An error response. + Error(JsonRpcErrorResponse), +} + +impl JsonRpcResponse { + /// Attemps to convert the response into a successful response. + pub fn into_success(self) -> Option { + match self { + Self::Success(success) => Some(success), + _ => None, + } + } + + /// Attemps to convert the response into an error response. + pub fn into_error(self) -> Option { + match self { + Self::Error(error) => Some(error), + _ => None, + } + } +} + +/// A response object for successful JSON-RPC requests. +#[derive(Debug, Clone, Default, Serialize, Deserialize)] +pub struct JsonRpcSuccessResponse { + /// The JSON-RPC version string. MUST be "2.0". + pub jsonrpc: String, + /// Optional ID. + pub id: Option, + /// The result object. + pub result: T, +} + +impl JsonRpcSuccessResponse { + /// Create a new JSON-RPC success response + pub fn new(result: T) -> Self { + Self { jsonrpc: "2.0".to_string(), id: None, result } + } + + /// Set the ID of the response + pub fn with_id(self, id: Value) -> Self { + Self { id: Some(id), ..self } + } + + /// Set the ID of the response from a UUID + pub fn with_uuid(self, id: Uuid) -> Self { + Self { id: Some(Value::String(id.to_string())), ..self } + } +} + +/// A JSON-RPC error response. +/// +/// Reference: https://www.jsonrpc.org/specification #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct JsonResponse { +pub struct JsonRpcErrorResponse { /// The JSON-RPC version string. MUST be "2.0". pub jsonrpc: String, - /// Optional ID. Must be serialized as `null` if not present. + /// Optional ID pub id: Option, - /// The result object. Must be serialized as `null` if an error is present. - #[serde(skip_serializing_if = "Value::is_null", default)] - pub result: Value, - /// The error object. Must be serialized as `null` if no error is present. - #[serde(skip_serializing_if = "Option::is_none")] - pub error: Option, + /// The error object. + pub error: JsonRpcError, } -impl Default for JsonResponse { - fn default() -> Self { - Self { jsonrpc: "2.0".to_string(), id: None, result: Value::Null, error: None } +impl JsonRpcErrorResponse { + /// Create a new JSON-RPC error response + pub fn new(error: JsonRpcError) -> Self { + Self { jsonrpc: "2.0".to_string(), id: None, error } + } + + /// Set the ID of the response. + pub fn with_id(self, id: Value) -> Self { + Self { id: Some(id), ..self } + } + + /// Set the ID of the response from a UUID. + pub fn with_uuid(self, id: Uuid) -> Self { + Self { id: Some(Value::String(id.to_string())), ..self } + } + + /// Returns a clone of the error message. + pub fn message(&self) -> String { + self.error.message.clone() + } + + /// Returns the error code. + pub fn code(&self) -> i32 { + self.error.code } } -impl JsonResponse { - /// Create a new JSON-RPC response with a result - pub fn from_error(error: JsonError) -> Self { - Self { error: Some(error), ..Default::default() } +impl From for JsonRpcErrorResponse { + fn from(error: JsonRpcError) -> Self { + Self::new(error) } } /// A JSON-RPC error object #[derive(Debug, Clone, Serialize, Deserialize)] -pub struct JsonError { +pub struct JsonRpcError { /// The error code pub code: i32, /// The error message pub message: String, } -impl JsonError { +impl JsonRpcError { /// Create a new JSON-RPC error object pub fn new(code: i32, message: String) -> Self { Self { code, message } From 611978ab7195a5ab088e9a66ad5d1ff091faafad Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Mon, 13 Jan 2025 17:37:18 +0100 Subject: [PATCH 28/33] fix(sidecar): dynamic paths --- bolt-sidecar/src/api/spec.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bolt-sidecar/src/api/spec.rs b/bolt-sidecar/src/api/spec.rs index 1cd2813d..fdf0d4f2 100644 --- a/bolt-sidecar/src/api/spec.rs +++ b/bolt-sidecar/src/api/spec.rs @@ -21,7 +21,7 @@ pub const STATUS_PATH: &str = "/eth/v1/builder/status"; /// The path to the builder API register validators endpoint. pub const REGISTER_VALIDATORS_PATH: &str = "/eth/v1/builder/validators"; /// The path to the builder API get header endpoint. -pub const GET_HEADER_PATH: &str = "/eth/v1/builder/header/:slot/:parent_hash/:pubkey"; +pub const GET_HEADER_PATH: &str = "/eth/v1/builder/header/{slot}/{parent_hash}/{pubkey}"; /// The path to the builder API get payload endpoint. pub const GET_PAYLOAD_PATH: &str = "/eth/v1/builder/blinded_blocks"; /// The path to the constraints API submit constraints endpoint. @@ -86,12 +86,12 @@ pub enum BuilderApiError { impl IntoResponse for BuilderApiError { fn into_response(self) -> Response { match self { - Self::FailedRegisteringValidators(error) | - Self::FailedGettingHeader(error) | - Self::FailedGettingPayload(error) | - Self::FailedSubmittingConstraints(error) | - Self::FailedDelegating(error) | - Self::FailedRevoking(error) => { + Self::FailedRegisteringValidators(error) + | Self::FailedGettingHeader(error) + | Self::FailedGettingPayload(error) + | Self::FailedSubmittingConstraints(error) + | Self::FailedDelegating(error) + | Self::FailedRevoking(error) => { (StatusCode::from_u16(error.code).unwrap(), Json(error)).into_response() } Self::NoBids(_) => (StatusCode::NO_CONTENT, self.to_string()).into_response(), From 6342fb2ba6dfafbdf518f0c4d32295fca9e8188c Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Mon, 13 Jan 2025 17:40:34 +0000 Subject: [PATCH 29/33] rollback to modular design --- bolt-cli/src/cli.rs | 23 - bolt-cli/src/commands/operators/eigenlayer.rs | 10 +- bolt-cli/src/commands/operators/symbiotic.rs | 8 +- bolt-cli/src/commands/validators.rs | 6 +- bolt-cli/src/common/mod.rs | 23 + bolt-cli/src/pb/v1.rs | 575 ++++++++++++------ 6 files changed, 432 insertions(+), 213 deletions(-) diff --git a/bolt-cli/src/cli.rs b/bolt-cli/src/cli.rs index 95f7409a..2e4edf02 100644 --- a/bolt-cli/src/cli.rs +++ b/bolt-cli/src/cli.rs @@ -15,7 +15,6 @@ use crate::{ common::{keystore::DEFAULT_KEYSTORE_PASSWORD, parse_ether_value}, contracts::EigenLayerStrategy, }; -use tracing::info; /// `bolt` is a CLI tool to interact with bolt Protocol ✨ #[derive(Parser, Debug, Clone)] @@ -64,28 +63,6 @@ impl Cmd { Self::PubkeyHash(cmd) => cmd.run(), } } - - /// Asks whether the user wants to proceed further. If not, the process is exited. - #[allow(unreachable_code)] - pub fn request_confirmation() { - // Skip confirmation in tests - #[cfg(test)] - return; - - inquire::Confirm::new("Do you want to continue? (yes/no):") - .prompt() - .map(|proceed| { - if proceed { - return; - } - info!("Aborting"); - std::process::exit(0); - }) - .unwrap_or_else(|err| { - info!("confirmation exited: {}", err); - std::process::exit(0); - }) - } } /// Command for generating BLS delegation or revocation messages. diff --git a/bolt-cli/src/commands/operators/eigenlayer.rs b/bolt-cli/src/commands/operators/eigenlayer.rs index 3e08df64..d6cb7500 100644 --- a/bolt-cli/src/commands/operators/eigenlayer.rs +++ b/bolt-cli/src/commands/operators/eigenlayer.rs @@ -15,8 +15,8 @@ use eyre::Context; use tracing::{info, warn}; use crate::{ - cli::{Chain, Cmd, EigenLayerSubcommand}, - common::{bolt_manager::BoltManagerContract, try_parse_contract_error}, + cli::{Chain, EigenLayerSubcommand}, + common::{bolt_manager::BoltManagerContract, request_confirmation, try_parse_contract_error}, contracts::{ bolt::{ BoltEigenLayerMiddleware::{self, BoltEigenLayerMiddlewareErrors}, @@ -62,7 +62,7 @@ impl EigenLayerSubcommand { info!(%strategy, %token, amount = format_ether(amount), ?operator, "Depositing funds into EigenLayer strategy"); - Cmd::request_confirmation(); + request_confirmation(); let token_erc20 = IERC20Instance::new(token, provider); @@ -106,7 +106,7 @@ impl EigenLayerSubcommand { info!(operator = %signer.address(), rpc = %operator_rpc, ?chain, "Registering EigenLayer operator"); - Cmd::request_confirmation(); + request_confirmation(); let deployments = deployments_for_chain(chain); @@ -186,7 +186,7 @@ impl EigenLayerSubcommand { info!(operator = %address, ?chain, "Deregistering EigenLayer operator"); - Cmd::request_confirmation(); + request_confirmation(); let deployments = deployments_for_chain(chain); diff --git a/bolt-cli/src/commands/operators/symbiotic.rs b/bolt-cli/src/commands/operators/symbiotic.rs index d6b6bf38..72f09083 100644 --- a/bolt-cli/src/commands/operators/symbiotic.rs +++ b/bolt-cli/src/commands/operators/symbiotic.rs @@ -9,8 +9,8 @@ use eyre::Context; use tracing::{info, warn}; use crate::{ - cli::{Chain, Cmd, SymbioticSubcommand}, - common::{bolt_manager::BoltManagerContract, try_parse_contract_error}, + cli::{Chain, SymbioticSubcommand}, + common::{bolt_manager::BoltManagerContract, request_confirmation, try_parse_contract_error}, contracts::{ bolt::BoltSymbioticMiddleware::{self, BoltSymbioticMiddlewareErrors}, deployments_for_chain, @@ -37,7 +37,7 @@ impl SymbioticSubcommand { info!(operator = %signer.address(), rpc = %operator_rpc, ?chain, "Registering Symbiotic operator"); - Cmd::request_confirmation(); + request_confirmation(); // Check if operator is opted in to the bolt network if !IOptInService::new( @@ -108,7 +108,7 @@ impl SymbioticSubcommand { info!(operator = %address, ?chain, "Deregistering Symbiotic operator"); - Cmd::request_confirmation(); + request_confirmation(); let middleware = BoltSymbioticMiddleware::new(deployments.bolt.symbiotic_middleware, provider); diff --git a/bolt-cli/src/commands/validators.rs b/bolt-cli/src/commands/validators.rs index cf1f9298..465510a7 100644 --- a/bolt-cli/src/commands/validators.rs +++ b/bolt-cli/src/commands/validators.rs @@ -7,8 +7,8 @@ use eyre::Context; use tracing::{info, warn}; use crate::{ - cli::{Chain, Cmd, ValidatorsCommand, ValidatorsSubcommand}, - common::{hash::compress_bls_pubkey, try_parse_contract_error}, + cli::{Chain, ValidatorsCommand, ValidatorsSubcommand}, + common::{hash::compress_bls_pubkey, request_confirmation, try_parse_contract_error}, contracts::{ bolt::BoltValidators::{self, BoltValidatorsErrors}, deployments_for_chain, @@ -52,7 +52,7 @@ impl ValidatorsCommand { let bolt_validators = BoltValidators::new(bolt_validators_address, provider.clone()); - Cmd::request_confirmation(); + request_confirmation(); match bolt_validators .batchRegisterValidatorsUnsafe( diff --git a/bolt-cli/src/common/mod.rs b/bolt-cli/src/common/mod.rs index 324576d9..d88ec3ca 100644 --- a/bolt-cli/src/common/mod.rs +++ b/bolt-cli/src/common/mod.rs @@ -10,6 +10,7 @@ use alloy::{ use ethereum_consensus::crypto::PublicKey as BlsPublicKey; use eyre::{Context, ContextCompat, Result}; use serde::Serialize; +use tracing::info; /// BoltManager contract bindings. pub mod bolt_manager; @@ -105,3 +106,25 @@ pub fn try_parse_contract_error(error: ContractError) -> Result _ => Err(error), } } + +/// Asks whether the user wants to proceed further. If not, the process is exited. +#[allow(unreachable_code)] +pub fn request_confirmation() { + // Skip confirmation in tests + #[cfg(test)] + return; + + inquire::Confirm::new("Do you want to continue? (yes/no):") + .prompt() + .map(|proceed| { + if proceed { + return; + } + info!("Aborting"); + std::process::exit(0); + }) + .unwrap_or_else(|err| { + info!("confirmation exited: {}", err); + std::process::exit(0); + }) +} diff --git a/bolt-cli/src/pb/v1.rs b/bolt-cli/src/pb/v1.rs index edcc8db4..dbef7a82 100644 --- a/bolt-cli/src/pb/v1.rs +++ b/bolt-cli/src/pb/v1.rs @@ -89,9 +89,10 @@ pub mod lister_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] - use tonic::codegen::{http::Uri, *}; + use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct ListerClient { inner: tonic::client::Grpc, @@ -135,8 +136,9 @@ pub mod lister_client { >::ResponseBody, >, >, - >>::Error: - Into + std::marker::Send + std::marker::Sync, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, { ListerClient::new(InterceptedService::new(inner, interceptor)) } @@ -174,11 +176,18 @@ pub mod lister_client { pub async fn list_accounts( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.Lister/ListAccounts"); let mut req = request.into_request(); @@ -194,17 +203,19 @@ pub mod lister_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with - /// ListerServer. + /// Generated trait containing gRPC methods that should be implemented for use with ListerServer. #[async_trait] pub trait Lister: std::marker::Send + std::marker::Sync + 'static { async fn list_accounts( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct ListerServer { @@ -227,7 +238,10 @@ pub mod lister_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -282,16 +296,23 @@ pub mod lister_server { "/v1.Lister/ListAccounts" => { #[allow(non_camel_case_types)] struct ListAccountsSvc(pub Arc); - impl tonic::server::UnaryService for ListAccountsSvc { + impl< + T: Lister, + > tonic::server::UnaryService + for ListAccountsSvc { type Response = super::ListAccountsResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::list_accounts(&inner, request).await }; + let fut = async move { + ::list_accounts(&inner, request).await + }; Box::pin(fut) } } @@ -317,16 +338,23 @@ pub mod lister_server { }; Box::pin(fut) } - _ => Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers.insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); - Ok(response) - }), + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } } } } @@ -470,9 +498,10 @@ pub mod signer_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] - use tonic::codegen::{http::Uri, *}; + use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct SignerClient { inner: tonic::client::Grpc, @@ -516,8 +545,9 @@ pub mod signer_client { >::ResponseBody, >, >, - >>::Error: - Into + std::marker::Send + std::marker::Sync, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, { SignerClient::new(InterceptedService::new(inner, interceptor)) } @@ -556,9 +586,14 @@ pub mod signer_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.Signer/Sign"); let mut req = request.into_request(); @@ -568,10 +603,18 @@ pub mod signer_client { pub async fn multisign( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.Signer/Multisign"); let mut req = request.into_request(); @@ -582,39 +625,66 @@ pub mod signer_client { &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1.Signer/SignBeaconAttestation"); + let path = http::uri::PathAndQuery::from_static( + "/v1.Signer/SignBeaconAttestation", + ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestation")); + req.extensions_mut() + .insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestation")); self.inner.unary(req, path, codec).await } pub async fn sign_beacon_attestations( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1.Signer/SignBeaconAttestations"); + let path = http::uri::PathAndQuery::from_static( + "/v1.Signer/SignBeaconAttestations", + ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestations")); + req.extensions_mut() + .insert(GrpcMethod::new("v1.Signer", "SignBeaconAttestations")); self.inner.unary(req, path, codec).await } pub async fn sign_beacon_proposal( &mut self, request: impl tonic::IntoRequest, ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1.Signer/SignBeaconProposal"); + let path = http::uri::PathAndQuery::from_static( + "/v1.Signer/SignBeaconProposal", + ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("v1.Signer", "SignBeaconProposal")); + req.extensions_mut() + .insert(GrpcMethod::new("v1.Signer", "SignBeaconProposal")); self.inner.unary(req, path, codec).await } } @@ -626,11 +696,10 @@ pub mod signer_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with - /// SignerServer. + /// Generated trait containing gRPC methods that should be implemented for use with SignerServer. #[async_trait] pub trait Signer: std::marker::Send + std::marker::Sync + 'static { async fn sign( @@ -640,7 +709,10 @@ pub mod signer_server { async fn multisign( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn sign_beacon_attestation( &self, request: tonic::Request, @@ -648,7 +720,10 @@ pub mod signer_server { async fn sign_beacon_attestations( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn sign_beacon_proposal( &self, request: tonic::Request, @@ -675,7 +750,10 @@ pub mod signer_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -730,15 +808,21 @@ pub mod signer_server { "/v1.Signer/Sign" => { #[allow(non_camel_case_types)] struct SignSvc(pub Arc); - impl tonic::server::UnaryService for SignSvc { + impl tonic::server::UnaryService + for SignSvc { type Response = super::SignResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = async move { ::sign(&inner, request).await }; + let fut = async move { + ::sign(&inner, request).await + }; Box::pin(fut) } } @@ -767,16 +851,21 @@ pub mod signer_server { "/v1.Signer/Multisign" => { #[allow(non_camel_case_types)] struct MultisignSvc(pub Arc); - impl tonic::server::UnaryService for MultisignSvc { + impl tonic::server::UnaryService + for MultisignSvc { type Response = super::MultisignResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::multisign(&inner, request).await }; + let fut = async move { + ::multisign(&inner, request).await + }; Box::pin(fut) } } @@ -805,18 +894,23 @@ pub mod signer_server { "/v1.Signer/SignBeaconAttestation" => { #[allow(non_camel_case_types)] struct SignBeaconAttestationSvc(pub Arc); - impl tonic::server::UnaryService - for SignBeaconAttestationSvc - { + impl< + T: Signer, + > tonic::server::UnaryService + for SignBeaconAttestationSvc { type Response = super::SignResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::sign_beacon_attestation(&inner, request).await + ::sign_beacon_attestation(&inner, request) + .await }; Box::pin(fut) } @@ -846,19 +940,23 @@ pub mod signer_server { "/v1.Signer/SignBeaconAttestations" => { #[allow(non_camel_case_types)] struct SignBeaconAttestationsSvc(pub Arc); - impl - tonic::server::UnaryService - for SignBeaconAttestationsSvc - { + impl< + T: Signer, + > tonic::server::UnaryService + for SignBeaconAttestationsSvc { type Response = super::MultisignResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); let fut = async move { - ::sign_beacon_attestations(&inner, request).await + ::sign_beacon_attestations(&inner, request) + .await }; Box::pin(fut) } @@ -888,11 +986,15 @@ pub mod signer_server { "/v1.Signer/SignBeaconProposal" => { #[allow(non_camel_case_types)] struct SignBeaconProposalSvc(pub Arc); - impl tonic::server::UnaryService - for SignBeaconProposalSvc - { + impl< + T: Signer, + > tonic::server::UnaryService + for SignBeaconProposalSvc { type Response = super::SignResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -926,16 +1028,23 @@ pub mod signer_server { }; Box::pin(fut) } - _ => Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers.insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); - Ok(response) - }), + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } } } } @@ -1008,9 +1117,10 @@ pub mod account_manager_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] - use tonic::codegen::{http::Uri, *}; + use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct AccountManagerClient { inner: tonic::client::Grpc, @@ -1054,8 +1164,9 @@ pub mod account_manager_client { >::ResponseBody, >, >, - >>::Error: - Into + std::marker::Send + std::marker::Sync, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, { AccountManagerClient::new(InterceptedService::new(inner, interceptor)) } @@ -1093,11 +1204,18 @@ pub mod account_manager_client { pub async fn unlock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.AccountManager/Unlock"); let mut req = request.into_request(); @@ -1107,11 +1225,18 @@ pub mod account_manager_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.AccountManager/Lock"); let mut req = request.into_request(); @@ -1121,14 +1246,25 @@ pub mod account_manager_client { pub async fn generate( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); - let path = http::uri::PathAndQuery::from_static("/v1.AccountManager/Generate"); + let path = http::uri::PathAndQuery::from_static( + "/v1.AccountManager/Generate", + ); let mut req = request.into_request(); - req.extensions_mut().insert(GrpcMethod::new("v1.AccountManager", "Generate")); + req.extensions_mut() + .insert(GrpcMethod::new("v1.AccountManager", "Generate")); self.inner.unary(req, path, codec).await } } @@ -1140,25 +1276,33 @@ pub mod account_manager_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with - /// AccountManagerServer. + /// Generated trait containing gRPC methods that should be implemented for use with AccountManagerServer. #[async_trait] pub trait AccountManager: std::marker::Send + std::marker::Sync + 'static { async fn unlock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn generate( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct AccountManagerServer { @@ -1181,7 +1325,10 @@ pub mod account_manager_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -1236,16 +1383,23 @@ pub mod account_manager_server { "/v1.AccountManager/Unlock" => { #[allow(non_camel_case_types)] struct UnlockSvc(pub Arc); - impl tonic::server::UnaryService for UnlockSvc { + impl< + T: AccountManager, + > tonic::server::UnaryService + for UnlockSvc { type Response = super::UnlockAccountResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::unlock(&inner, request).await }; + let fut = async move { + ::unlock(&inner, request).await + }; Box::pin(fut) } } @@ -1274,16 +1428,23 @@ pub mod account_manager_server { "/v1.AccountManager/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl tonic::server::UnaryService for LockSvc { + impl< + T: AccountManager, + > tonic::server::UnaryService + for LockSvc { type Response = super::LockAccountResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::lock(&inner, request).await }; + let fut = async move { + ::lock(&inner, request).await + }; Box::pin(fut) } } @@ -1312,9 +1473,15 @@ pub mod account_manager_server { "/v1.AccountManager/Generate" => { #[allow(non_camel_case_types)] struct GenerateSvc(pub Arc); - impl tonic::server::UnaryService for GenerateSvc { + impl< + T: AccountManager, + > tonic::server::UnaryService + for GenerateSvc { type Response = super::GenerateResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, @@ -1348,16 +1515,23 @@ pub mod account_manager_server { }; Box::pin(fut) } - _ => Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers.insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); - Ok(response) - }), + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } } } } @@ -1408,9 +1582,10 @@ pub mod wallet_manager_client { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] - use tonic::codegen::{http::Uri, *}; + use tonic::codegen::*; + use tonic::codegen::http::Uri; #[derive(Debug, Clone)] pub struct WalletManagerClient { inner: tonic::client::Grpc, @@ -1454,8 +1629,9 @@ pub mod wallet_manager_client { >::ResponseBody, >, >, - >>::Error: - Into + std::marker::Send + std::marker::Sync, + , + >>::Error: Into + std::marker::Send + std::marker::Sync, { WalletManagerClient::new(InterceptedService::new(inner, interceptor)) } @@ -1493,11 +1669,18 @@ pub mod wallet_manager_client { pub async fn unlock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.WalletManager/Unlock"); let mut req = request.into_request(); @@ -1507,11 +1690,18 @@ pub mod wallet_manager_client { pub async fn lock( &mut self, request: impl tonic::IntoRequest, - ) -> std::result::Result, tonic::Status> - { - self.inner.ready().await.map_err(|e| { - tonic::Status::unknown(format!("Service was not ready: {}", e.into())) - })?; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { + self.inner + .ready() + .await + .map_err(|e| { + tonic::Status::unknown( + format!("Service was not ready: {}", e.into()), + ) + })?; let codec = tonic::codec::ProstCodec::default(); let path = http::uri::PathAndQuery::from_static("/v1.WalletManager/Lock"); let mut req = request.into_request(); @@ -1527,21 +1717,26 @@ pub mod wallet_manager_server { dead_code, missing_docs, clippy::wildcard_imports, - clippy::let_unit_value + clippy::let_unit_value, )] use tonic::codegen::*; - /// Generated trait containing gRPC methods that should be implemented for use with - /// WalletManagerServer. + /// Generated trait containing gRPC methods that should be implemented for use with WalletManagerServer. #[async_trait] pub trait WalletManager: std::marker::Send + std::marker::Sync + 'static { async fn unlock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; async fn lock( &self, request: tonic::Request, - ) -> std::result::Result, tonic::Status>; + ) -> std::result::Result< + tonic::Response, + tonic::Status, + >; } #[derive(Debug)] pub struct WalletManagerServer { @@ -1564,7 +1759,10 @@ pub mod wallet_manager_server { max_encoding_message_size: None, } } - pub fn with_interceptor(inner: T, interceptor: F) -> InterceptedService + pub fn with_interceptor( + inner: T, + interceptor: F, + ) -> InterceptedService where F: tonic::service::Interceptor, { @@ -1619,16 +1817,23 @@ pub mod wallet_manager_server { "/v1.WalletManager/Unlock" => { #[allow(non_camel_case_types)] struct UnlockSvc(pub Arc); - impl tonic::server::UnaryService for UnlockSvc { + impl< + T: WalletManager, + > tonic::server::UnaryService + for UnlockSvc { type Response = super::UnlockWalletResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::unlock(&inner, request).await }; + let fut = async move { + ::unlock(&inner, request).await + }; Box::pin(fut) } } @@ -1657,16 +1862,23 @@ pub mod wallet_manager_server { "/v1.WalletManager/Lock" => { #[allow(non_camel_case_types)] struct LockSvc(pub Arc); - impl tonic::server::UnaryService for LockSvc { + impl< + T: WalletManager, + > tonic::server::UnaryService + for LockSvc { type Response = super::LockWalletResponse; - type Future = BoxFuture, tonic::Status>; + type Future = BoxFuture< + tonic::Response, + tonic::Status, + >; fn call( &mut self, request: tonic::Request, ) -> Self::Future { let inner = Arc::clone(&self.0); - let fut = - async move { ::lock(&inner, request).await }; + let fut = async move { + ::lock(&inner, request).await + }; Box::pin(fut) } } @@ -1692,16 +1904,23 @@ pub mod wallet_manager_server { }; Box::pin(fut) } - _ => Box::pin(async move { - let mut response = http::Response::new(empty_body()); - let headers = response.headers_mut(); - headers.insert( - tonic::Status::GRPC_STATUS, - (tonic::Code::Unimplemented as i32).into(), - ); - headers.insert(http::header::CONTENT_TYPE, tonic::metadata::GRPC_CONTENT_TYPE); - Ok(response) - }), + _ => { + Box::pin(async move { + let mut response = http::Response::new(empty_body()); + let headers = response.headers_mut(); + headers + .insert( + tonic::Status::GRPC_STATUS, + (tonic::Code::Unimplemented as i32).into(), + ); + headers + .insert( + http::header::CONTENT_TYPE, + tonic::metadata::GRPC_CONTENT_TYPE, + ); + Ok(response) + }) + } } } } From 1a4704c9e8b5dcb95f94c6fa2fcedfaefe88ffa0 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:42:57 +0000 Subject: [PATCH 30/33] Chore: Bolt-CLI: exhaustive err match on inquire Error --- bolt-cli/src/common/mod.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/bolt-cli/src/common/mod.rs b/bolt-cli/src/common/mod.rs index d88ec3ca..f97481a8 100644 --- a/bolt-cli/src/common/mod.rs +++ b/bolt-cli/src/common/mod.rs @@ -1,4 +1,4 @@ -use std::{fs, path::PathBuf, str::FromStr}; +use std::{fs, path::PathBuf, process::exit, str::FromStr}; use alloy::{ contract::Error as ContractError, @@ -9,8 +9,9 @@ use alloy::{ }; use ethereum_consensus::crypto::PublicKey as BlsPublicKey; use eyre::{Context, ContextCompat, Result}; +use inquire::{error::InquireError, Confirm}; use serde::Serialize; -use tracing::info; +use tracing::{error, info}; /// BoltManager contract bindings. pub mod bolt_manager; @@ -114,17 +115,23 @@ pub fn request_confirmation() { #[cfg(test)] return; - inquire::Confirm::new("Do you want to continue? (yes/no):") + Confirm::new("Do you want to continue? (yes/no):") .prompt() .map(|proceed| { if proceed { return; } info!("Aborting"); - std::process::exit(0); + exit(0); }) - .unwrap_or_else(|err| { - info!("confirmation exited: {}", err); - std::process::exit(0); + .unwrap_or_else(|err| match err { + InquireError::OperationCanceled | InquireError::OperationInterrupted => { + info!("Aborting"); + exit(1); + } + _ => { + error!("error confirmation exited: {}", err); + exit(1); + } }) } From 80979ff19afc1840d7cf80a451daf48d05830cd9 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:47:09 +0000 Subject: [PATCH 31/33] tiny change --- bolt-cli/src/common/mod.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bolt-cli/src/common/mod.rs b/bolt-cli/src/common/mod.rs index f97481a8..1c1f93e5 100644 --- a/bolt-cli/src/common/mod.rs +++ b/bolt-cli/src/common/mod.rs @@ -1,4 +1,4 @@ -use std::{fs, path::PathBuf, process::exit, str::FromStr}; +use std::{fs, path::PathBuf, str::FromStr}; use alloy::{ contract::Error as ContractError, @@ -122,16 +122,16 @@ pub fn request_confirmation() { return; } info!("Aborting"); - exit(0); + std::process::exit(0); }) .unwrap_or_else(|err| match err { InquireError::OperationCanceled | InquireError::OperationInterrupted => { info!("Aborting"); - exit(1); + std::process::exit(1); } _ => { error!("error confirmation exited: {}", err); - exit(1); + std::process::exit(1); } }) } From 13d8d42b1c46f30720fab98fd70e42d9ad581a8f Mon Sep 17 00:00:00 2001 From: Precious <3173957+0ex-d@users.noreply.github.com> Date: Tue, 14 Jan 2025 10:37:10 +0000 Subject: [PATCH 32/33] Update bolt-cli/src/common/mod.rs Co-authored-by: Lorenzo --- bolt-cli/src/common/mod.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bolt-cli/src/common/mod.rs b/bolt-cli/src/common/mod.rs index 1c1f93e5..df2ead69 100644 --- a/bolt-cli/src/common/mod.rs +++ b/bolt-cli/src/common/mod.rs @@ -125,12 +125,17 @@ pub fn request_confirmation() { std::process::exit(0); }) .unwrap_or_else(|err| match err { - InquireError::OperationCanceled | InquireError::OperationInterrupted => { + InquireError::OperationCanceled => { + // User pressed ESC, a shorthand for "no" info!("Aborting"); - std::process::exit(1); + std::process::exit(0); + } + InquireError::OperationInterrupted => { + // Triggered a SIGINT via Ctrl-C + std::process::exit(130); } _ => { - error!("error confirmation exited: {}", err); + error!("aborting due to unexpected error: {}", err); std::process::exit(1); } }) From 7e74360540c30d10e73dbb3d9b3bad67629d1a41 Mon Sep 17 00:00:00 2001 From: thedevbirb Date: Tue, 14 Jan 2025 15:22:40 +0100 Subject: [PATCH 33/33] chore(sidecar): add TLS provider --- bolt-sidecar/Cargo.lock | 26 +++++++++++++------------- bolt-sidecar/Cargo.toml | 1 + bolt-sidecar/bin/sidecar.rs | 5 +++++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/bolt-sidecar/Cargo.lock b/bolt-sidecar/Cargo.lock index 00a9f0c5..2bcd2999 100644 --- a/bolt-sidecar/Cargo.lock +++ b/bolt-sidecar/Cargo.lock @@ -1275,7 +1275,7 @@ dependencies = [ "alloy-transport 0.8.0", "futures", "http 1.2.0", - "rustls 0.23.19", + "rustls 0.23.21", "serde_json", "tokio", "tokio-tungstenite 0.24.0", @@ -1293,7 +1293,7 @@ dependencies = [ "alloy-transport 0.9.2", "futures", "http 1.2.0", - "rustls 0.23.19", + "rustls 0.23.21", "serde_json", "tokio", "tokio-tungstenite 0.24.0", @@ -1656,9 +1656,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-lc-rs" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f47bb8cc16b669d267eeccf585aea077d0882f4777b1c1f740217885d6e6e5a3" +checksum = "f409eb70b561706bf8abba8ca9c112729c481595893fd06a2dd9af8ed8441148" dependencies = [ "aws-lc-sys", "paste", @@ -1667,16 +1667,15 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.23.1" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2101df3813227bbaaaa0b04cd61c534c7954b22bd68d399b440be937dc63ff7" +checksum = "923ded50f602b3007e5e63e3f094c479d9c8a9b42d7f4034e4afe456aa48bfd2" dependencies = [ "bindgen", "cc", "cmake", "dunce", "fs_extra", - "libc", "paste", ] @@ -2132,6 +2131,7 @@ dependencies = [ "reqwest 0.12.9", "reth-primitives", "reth-primitives-traits", + "rustls 0.23.21", "secp256k1", "serde", "serde_json", @@ -4529,7 +4529,7 @@ dependencies = [ "hyper 1.5.1", "hyper-util", "log", - "rustls 0.23.19", + "rustls 0.23.21", "rustls-native-certs", "rustls-pki-types", "tokio", @@ -7073,9 +7073,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.19" +version = "0.23.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" +checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8" dependencies = [ "aws-lc-rs", "log", @@ -8356,7 +8356,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.19", + "rustls 0.23.21", "tokio", ] @@ -8380,7 +8380,7 @@ checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", - "rustls 0.23.19", + "rustls 0.23.21", "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", @@ -8684,7 +8684,7 @@ dependencies = [ "httparse", "log", "rand 0.8.5", - "rustls 0.23.19", + "rustls 0.23.21", "rustls-pki-types", "sha1", "thiserror 1.0.69", diff --git a/bolt-sidecar/Cargo.toml b/bolt-sidecar/Cargo.toml index dc3cc571..ef79212b 100644 --- a/bolt-sidecar/Cargo.toml +++ b/bolt-sidecar/Cargo.toml @@ -17,6 +17,7 @@ tower-http = { version = "0.5.2", features = ["timeout"] } tower = "0.5.1" http-body-util = "0.1.2" futures = "0.3" +rustls = "0.23.21" # tokio tokio = { version = "1", features = ["full"] } diff --git a/bolt-sidecar/bin/sidecar.rs b/bolt-sidecar/bin/sidecar.rs index 8053b9c6..7091c6ed 100644 --- a/bolt-sidecar/bin/sidecar.rs +++ b/bolt-sidecar/bin/sidecar.rs @@ -18,6 +18,11 @@ async fn main() -> eyre::Result<()> { println!("{}", BOLT); println!("Running version: {}", BOLT_SIDECAR_VERSION.clone()); + // Init the default rustls provider + if let Err(e) = rustls::crypto::ring::default_provider().install_default() { + bail!("Failed to install default TLS provider: {:?}", e); + } + let opts = Opts::try_parse()?; init_telemetry_stack(opts.telemetry.metrics_port())?;