From 12a7148496efb489961997f77c24cfa69cce26e9 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Fri, 31 Jan 2025 19:03:45 +0000 Subject: [PATCH 1/3] Bolt-cli: Add dry-run flag for developmental/testing --- bolt-cli/src/cli.rs | 41 ++ bolt-cli/src/commands/operators/eigenlayer.rs | 71 ++- bolt-cli/src/commands/operators/symbiotic.rs | 102 ++-- bolt-cli/src/commands/validators.rs | 20 +- bolt-cli/src/common/mod.rs | 31 + bolt-cli/src/pb/v1.rs | 575 ++++++------------ 6 files changed, 382 insertions(+), 458 deletions(-) diff --git a/bolt-cli/src/cli.rs b/bolt-cli/src/cli.rs index 39589e103..f80a72845 100644 --- a/bolt-cli/src/cli.rs +++ b/bolt-cli/src/cli.rs @@ -187,6 +187,11 @@ pub enum ValidatorsSubcommand { /// The private key to sign the transactions with. #[clap(long, env = "ADMIN_PRIVATE_KEY")] admin_private_key: B256, + + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Check the status of a validator (batch). Status { @@ -242,6 +247,10 @@ pub enum EigenLayerSubcommand { /// The amount to deposit into the strategy, in units (e.g. '1ether', '10gwei'). #[clap(long, env = "EIGENLAYER_STRATEGY_DEPOSIT_AMOUNT", value_parser = parse_ether_value)] amount: U256, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Register an operator into the bolt AVS. @@ -264,6 +273,10 @@ pub enum EigenLayerSubcommand { /// If not provided, a random value is used. #[clap(long, env = "OPERATOR_SIGNATURE_SALT")] salt: Option, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Deregister an EigenLayer operator from the bolt AVS. @@ -274,6 +287,10 @@ pub enum EigenLayerSubcommand { /// The private key of the operator. #[clap(long, env = "OPERATOR_PRIVATE_KEY")] operator_private_key: B256, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Update the operator RPC. @@ -287,6 +304,10 @@ pub enum EigenLayerSubcommand { /// The URL of the operator RPC. #[clap(long, env = "OPERATOR_RPC")] operator_rpc: Url, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Check the status of an operator in the bolt AVS. @@ -304,6 +325,10 @@ pub enum EigenLayerSubcommand { /// The URL of the RPC to read data from #[clap(long, env = "RPC_URL")] rpc_url: Url, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, } @@ -325,6 +350,10 @@ pub enum SymbioticSubcommand { /// The operator's extra data string to be stored in the registry. #[clap(long, env = "OPERATOR_EXTRA_DATA")] extra_data: String, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Deregister a Symbiotic operator from bolt. @@ -335,6 +364,10 @@ pub enum SymbioticSubcommand { /// The private key of the operator. #[clap(long, env = "OPERATOR_PRIVATE_KEY")] operator_private_key: B256, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Update the operator RPC. @@ -348,6 +381,10 @@ pub enum SymbioticSubcommand { /// The URL of the operator RPC. #[clap(long, env = "OPERATOR_RPC")] operator_rpc: Url, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, /// Check the status of a Symbiotic operator. @@ -365,6 +402,10 @@ pub enum SymbioticSubcommand { /// The URL of the RPC to read data from #[clap(long, env = "RPC_URL")] rpc_url: Url, + /// Run the command in "dry run" mode, run all steps without broadcast. + /// Useful for testing and debugging purposes. + #[clap(short, long, env = "DRY_RUN", default_value = "false")] + dry_run: bool, }, } diff --git a/bolt-cli/src/commands/operators/eigenlayer.rs b/bolt-cli/src/commands/operators/eigenlayer.rs index a72ac5efd..e7f48005e 100644 --- a/bolt-cli/src/commands/operators/eigenlayer.rs +++ b/bolt-cli/src/commands/operators/eigenlayer.rs @@ -16,7 +16,9 @@ use crate::{ cli::{Chain, EigenLayerSubcommand}, common::{ // bolt_manager::BoltManagerContract::{self, BoltManagerContractErrors}, + handle_rpc_dry_run, request_confirmation, + shutdown_anvil, try_parse_contract_error, }, contracts::{ @@ -41,15 +43,17 @@ impl EigenLayerSubcommand { /// Run the EigenLayer subcommand. pub async fn run(self) -> eyre::Result<()> { match self { - Self::Deposit { rpc_url, strategy, amount, operator_private_key } => { + Self::Deposit { rpc_url, strategy, amount, operator_private_key, dry_run } => { let signer = PrivateKeySigner::from_bytes(&operator_private_key) .wrap_err("valid private key")?; let operator = signer.address(); + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer)) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -96,19 +100,30 @@ impl EigenLayerSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully deposited collateral into strategy"); + info!("Successfully deposited collateral into strategy"); + + shutdown_anvil(anvil); Ok(()) } - Self::Register { rpc_url, operator_rpc, salt, operator_private_key, extra_data } => { + Self::Register { + rpc_url, + operator_rpc, + salt, + operator_private_key, + extra_data, + dry_run, + } => { let signer = PrivateKeySigner::from_bytes(&operator_private_key) .wrap_err("valid private key")?; + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer.clone())) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -169,7 +184,7 @@ impl EigenLayerSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully registered EigenLayer operator"); + info!("Successfully registered EigenLayer operator"); } Err(e) => parse_eigenlayer_middleware_mainnet_errors(e)?, } @@ -193,24 +208,28 @@ impl EigenLayerSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully registered EigenLayer operator"); + info!("Successfully registered EigenLayer operator"); } Err(e) => parse_eigenlayer_middleware_holesky_errors(e)?, } } + shutdown_anvil(anvil); + Ok(()) } - Self::Deregister { rpc_url, operator_private_key } => { + Self::Deregister { rpc_url, operator_private_key, dry_run } => { let signer = PrivateKeySigner::from_bytes(&operator_private_key) .wrap_err("valid private key")?; let address = signer.address(); + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer)) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -238,7 +257,7 @@ impl EigenLayerSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully deregistered EigenLayer operator"); + info!("Successfully deregistered EigenLayer operator"); } Err(e) => parse_eigenlayer_middleware_mainnet_errors(e)?, } @@ -258,24 +277,28 @@ impl EigenLayerSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully deregistered EigenLayer operator"); + info!("Successfully deregistered EigenLayer operator"); } Err(e) => parse_eigenlayer_middleware_holesky_errors(e)?, } } + shutdown_anvil(anvil); + Ok(()) } - Self::UpdateRpc { rpc_url, operator_private_key, operator_rpc } => { + Self::UpdateRpc { rpc_url, operator_private_key, operator_rpc, dry_run } => { let signer = PrivateKeySigner::from_bytes(&operator_private_key) .wrap_err("valid private key")?; let address = signer.address(); + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer)) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -308,7 +331,7 @@ impl EigenLayerSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully updated EigenLayer operator RPC"); + info!("Successfully updated EigenLayer operator RPC"); } Err(e) => parse_eigenlayer_middleware_mainnet_errors(e)?, } @@ -334,7 +357,7 @@ impl EigenLayerSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully updated EigenLayer operator RPC"); + info!("Successfully updated EigenLayer operator RPC"); } Err(e) => match try_parse_contract_error::(e)? { BoltManagerErrors::OperatorNotRegistered(_) => { @@ -350,6 +373,8 @@ impl EigenLayerSubcommand { } } + shutdown_anvil(anvil); + Ok(()) } @@ -380,7 +405,7 @@ impl EigenLayerSubcommand { info!(?address, "EigenLayer operator is registered"); } else { warn!(?address, "Operator not registered"); - return Ok(()) + return Ok(()); } } Err(e) => { @@ -428,7 +453,7 @@ impl EigenLayerSubcommand { info!(?address, "EigenLayer operator is registered"); } else { warn!(?address, "Operator not registered"); - return Ok(()) + return Ok(()); } let middleware = BoltEigenLayerMiddlewareHolesky::new( @@ -476,8 +501,10 @@ impl EigenLayerSubcommand { Ok(()) } - Self::ListStrategies { rpc_url } => { - let provider = ProviderBuilder::new().on_http(rpc_url.clone()); + Self::ListStrategies { rpc_url, dry_run } => { + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + + let provider = ProviderBuilder::new().on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -513,6 +540,8 @@ impl EigenLayerSubcommand { info!("- Token: {} - Strategy: {}", token_symbol, strategy_address); } + shutdown_anvil(anvil); + Ok(()) } } @@ -653,6 +682,7 @@ mod tests { operator_private_key: secret_key, strategy: weth_strategy_address, amount: U256::from(1), + dry_run: false, }, }, }; @@ -669,6 +699,7 @@ mod tests { extra_data: "hello world computer 🌐".to_string(), operator_rpc: None, salt: None, + dry_run: false, }, }, }; @@ -693,6 +724,7 @@ mod tests { rpc_url: anvil_url.clone(), operator_private_key: secret_key, operator_rpc: "https://boooooolt.chainbound.io/rpc".parse().expect("valid url"), + dry_run: false, }, }, }; @@ -715,6 +747,7 @@ mod tests { subcommand: EigenLayerSubcommand::Deregister { rpc_url: anvil_url.clone(), operator_private_key: secret_key, + dry_run: false, }, }, }; diff --git a/bolt-cli/src/commands/operators/symbiotic.rs b/bolt-cli/src/commands/operators/symbiotic.rs index 94cdb9f7c..23cba2236 100644 --- a/bolt-cli/src/commands/operators/symbiotic.rs +++ b/bolt-cli/src/commands/operators/symbiotic.rs @@ -1,10 +1,7 @@ use alloy::{ contract::Error as ContractError, network::EthereumWallet, - primitives::{ - utils::format_ether, - U256, - }, + primitives::{utils::format_ether, U256}, providers::ProviderBuilder, signers::local::PrivateKeySigner, sol_types::SolInterface, @@ -14,16 +11,17 @@ use tracing::{info, warn}; use crate::{ cli::{Chain, SymbioticSubcommand}, - common::{ - request_confirmation, try_parse_contract_error, - }, + common::{handle_rpc_dry_run, request_confirmation, shutdown_anvil, try_parse_contract_error}, contracts::{ bolt::{ - BoltManager::{self, BoltManagerErrors}, - BoltSymbioticMiddlewareHolesky::{self, BoltSymbioticMiddlewareHoleskyErrors}, - BoltSymbioticMiddlewareMainnet::{self, BoltSymbioticMiddlewareMainnetErrors}, - OperatorsRegistryV1::{self, OperatorsRegistryV1Errors} - }, deployments_for_chain, erc20::IERC20, symbiotic::{IOptInService, IVault} + BoltManager::{self, BoltManagerErrors}, + BoltSymbioticMiddlewareHolesky::{self, BoltSymbioticMiddlewareHoleskyErrors}, + BoltSymbioticMiddlewareMainnet::{self, BoltSymbioticMiddlewareMainnetErrors}, + OperatorsRegistryV1::{self, OperatorsRegistryV1Errors}, + }, + deployments_for_chain, + erc20::IERC20, + symbiotic::{IOptInService, IVault}, }, }; @@ -31,22 +29,26 @@ impl SymbioticSubcommand { /// Run the symbiotic subcommand. pub async fn run(self) -> eyre::Result<()> { match self { - Self::Register { operator_rpc, operator_private_key, rpc_url, extra_data } => { + Self::Register { operator_rpc, operator_private_key, rpc_url, extra_data, dry_run } => { let signer = PrivateKeySigner::from_bytes(&operator_private_key) .wrap_err("valid private key")?; + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer.clone())) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; let deployments = deployments_for_chain(chain); - let operator_rpc = operator_rpc.unwrap_or_else(|| chain.bolt_rpc().unwrap_or_else(|| - panic!("The bolt RPC is not deployed on {:?}. Please use the `--operator-rpc` flag to specify one manually.", chain)) - ); + let operator_rpc = operator_rpc.unwrap_or_else(|| { + chain.bolt_rpc().unwrap_or_else(|| { + panic!( "The bolt RPC is not deployed on {:?}. Please use the `--operator-rpc` flag to specify one manually.", chain) + }) + }); info!(operator = %signer.address(), rpc = %operator_rpc, ?chain, "Registering Symbiotic operator"); @@ -94,7 +96,7 @@ impl SymbioticSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully registered Symbiotic operator"); + info!("Successfully registered Symbiotic operator"); } Err(e) => parse_symbiotic_middleware_mainnet_errors(e)?, } @@ -116,25 +118,29 @@ impl SymbioticSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully registered Symbiotic operator"); + info!("Successfully registered Symbiotic operator"); } Err(e) => parse_symbiotic_middleware_holesky_errors(e)?, } } + shutdown_anvil(anvil); + Ok(()) } - Self::Deregister { rpc_url, operator_private_key } => { + Self::Deregister { rpc_url, operator_private_key, dry_run } => { let signer = PrivateKeySigner::from_bytes(&operator_private_key) .wrap_err("valid private key")?; let address = signer.address(); + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer)) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -163,7 +169,7 @@ impl SymbioticSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully deregistered Symbiotic operator"); + info!("Successfully deregistered Symbiotic operator"); } Err(e) => parse_symbiotic_middleware_mainnet_errors(e)?, } @@ -185,24 +191,28 @@ impl SymbioticSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully deregistered Symbiotic operator"); + info!("Successfully deregistered Symbiotic operator"); } Err(e) => parse_symbiotic_middleware_holesky_errors(e)?, } } + shutdown_anvil(anvil); + Ok(()) } - Self::UpdateRpc { rpc_url, operator_private_key, operator_rpc } => { + Self::UpdateRpc { rpc_url, operator_private_key, operator_rpc, dry_run } => { let signer = PrivateKeySigner::from_bytes(&operator_private_key) .wrap_err("valid private key")?; let address = signer.address(); + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer)) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -217,10 +227,14 @@ impl SymbioticSubcommand { info!(?address, "Symbiotic operator is registered"); } else { warn!(?address, "Operator not registered"); - return Ok(()) + return Ok(()); } - match bolt_manager.updateOperatorRPC(operator_rpc.to_string()).send().await { + let result = match bolt_manager + .updateOperatorRPC(operator_rpc.to_string()) + .send() + .await + { Ok(pending) => { info!( hash = ?pending.tx_hash(), @@ -232,7 +246,8 @@ impl SymbioticSubcommand { eyre::bail!("Transaction failed: {:?}", receipt) } - info!("Succesfully updated Symbiotic operator RPC"); + info!("Successfully updated Symbiotic operator RPC"); + Ok(()) } Err(e) => match try_parse_contract_error::(e)? { BoltManagerErrors::OperatorNotRegistered(_) => { @@ -242,8 +257,11 @@ impl SymbioticSubcommand { unreachable!("Unexpected error with selector {:?}", other.selector()) } }, - } - Ok(()) + }; + + shutdown_anvil(anvil); + + result } Self::Status { rpc_url, address } => { @@ -274,13 +292,13 @@ impl SymbioticSubcommand { info!(?address, "Symbiotic operator is registered"); } else { warn!(?address, "Operator not registered"); - return Ok(()) + return Ok(()); } } Err(e) => { let other = try_parse_contract_error::(e)?; bail!("Unexpected error with selector {:?}", other.selector()) - }, + } } match registry.isActiveOperator(address).call().await { @@ -294,7 +312,7 @@ impl SymbioticSubcommand { Err(e) => { let other = try_parse_contract_error::(e)?; bail!("Unexpected error with selector {:?}", other.selector()) - }, + } } match middleware.getOperatorCollaterals(address).call().await { @@ -322,10 +340,13 @@ impl SymbioticSubcommand { info!(?address, "Symbiotic operator is registered"); } else { warn!(?address, "Operator not registered"); - return Ok(()) + return Ok(()); } - let middleware = BoltSymbioticMiddlewareHolesky::new(deployments.bolt.symbiotic_middleware, provider.clone()); + let middleware = BoltSymbioticMiddlewareHolesky::new( + deployments.bolt.symbiotic_middleware, + provider.clone(), + ); match bolt_manager.getOperatorData(address).call().await { Ok(operator_data) => { @@ -367,8 +388,10 @@ impl SymbioticSubcommand { Ok(()) } - Self::ListVaults { rpc_url } => { - let provider = ProviderBuilder::new().on_http(rpc_url.clone()); + Self::ListVaults { rpc_url, dry_run } => { + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + + let provider = ProviderBuilder::new().on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -404,6 +427,8 @@ impl SymbioticSubcommand { info!("- Token: {} - Vault: {}", token_symbol, vault_address); } + shutdown_anvil(anvil); + Ok(()) } } @@ -585,6 +610,7 @@ mod tests { operator_private_key: secret_key, extra_data: "sudo rm -rf / --no-preserve-root".to_string(), operator_rpc: None, + dry_run: false, }, }, }; @@ -610,6 +636,7 @@ mod tests { operator_rpc: "https://boooooooooooooooolt.chainbound.io" .parse() .expect("valid url"), + dry_run: false, }, }, }; @@ -632,6 +659,7 @@ mod tests { subcommand: SymbioticSubcommand::Deregister { rpc_url: anvil_url.clone(), operator_private_key: secret_key, + dry_run: false, }, }, }; diff --git a/bolt-cli/src/commands/validators.rs b/bolt-cli/src/commands/validators.rs index 465510a72..2926e2a9c 100644 --- a/bolt-cli/src/commands/validators.rs +++ b/bolt-cli/src/commands/validators.rs @@ -8,7 +8,10 @@ use tracing::{info, warn}; use crate::{ cli::{Chain, ValidatorsCommand, ValidatorsSubcommand}, - common::{hash::compress_bls_pubkey, request_confirmation, try_parse_contract_error}, + common::{ + handle_rpc_dry_run, hash::compress_bls_pubkey, request_confirmation, shutdown_anvil, + try_parse_contract_error, + }, contracts::{ bolt::BoltValidators::{self, BoltValidatorsErrors}, deployments_for_chain, @@ -24,14 +27,17 @@ impl ValidatorsCommand { admin_private_key, authorized_operator, rpc_url, + dry_run, } => { let signer = PrivateKeySigner::from_bytes(&admin_private_key) .wrap_err("valid private key")?; + let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; + let provider = ProviderBuilder::new() .with_recommended_fillers() .wallet(EthereumWallet::from(signer)) - .on_http(rpc_url); + .on_http(rpc); let chain = Chain::try_from_provider(&provider).await?; @@ -54,7 +60,7 @@ impl ValidatorsCommand { request_confirmation(); - match bolt_validators + let result = match bolt_validators .batchRegisterValidatorsUnsafe( pubkey_hashes, max_committed_gas_limit, @@ -74,6 +80,7 @@ impl ValidatorsCommand { } info!("Successfully registered validators into bolt"); + Ok(()) } Err(e) => { let decoded = try_parse_contract_error::(e)?; @@ -94,9 +101,11 @@ impl ValidatorsCommand { ), } } - } + }; - Ok(()) + shutdown_anvil(anvil); + + result } ValidatorsSubcommand::Status { rpc_url, pubkeys_path, pubkeys } => { @@ -183,6 +192,7 @@ mod tests { authorized_operator: account, pubkeys_path: "./test_data/pubkeys.json".parse().unwrap(), rpc_url: anvil_url.clone(), + dry_run: true, }, }; diff --git a/bolt-cli/src/common/mod.rs b/bolt-cli/src/common/mod.rs index 78f1acd02..cb782d4cb 100644 --- a/bolt-cli/src/common/mod.rs +++ b/bolt-cli/src/common/mod.rs @@ -3,6 +3,7 @@ use std::{fs, path::PathBuf, str::FromStr}; use alloy::{ contract::Error as ContractError, dyn_abi::DynSolType, + node_bindings::{Anvil, AnvilInstance}, primitives::{Bytes, U256}, sol_types::SolInterface, transports::TransportError, @@ -10,6 +11,7 @@ use alloy::{ use ethereum_consensus::crypto::PublicKey as BlsPublicKey; use eyre::{Context, ContextCompat, Result}; use inquire::{error::InquireError, Confirm}; +use reqwest::Url; use serde::Serialize; use tracing::{error, info}; @@ -137,3 +139,32 @@ pub fn request_confirmation() { } }) } + +/// Determines the RPC URL to use. If `dry_run` is enabled, it spawns an `Anvil` instance and +/// returns its endpoint. Otherwise, returns the original `rpc_url`. +pub(crate) fn handle_rpc_dry_run( + rpc_url: Url, + dry_run: bool, +) -> eyre::Result<(Url, Option)> { + if !dry_run { + return Ok((rpc_url, None)); + } + + let anvil = Anvil::new() + .fork(rpc_url) + .try_spawn() + .map_err(|e| eyre::eyre!("[dry-run] Failed to spawn Anvil: {}", e))?; + + let anvil_url = anvil.endpoint_url(); + info!("[dry-run] Anvil endpoint URL: {}", anvil_url); + + Ok((anvil_url, Some(anvil))) +} + +/// drop provided `AnvilInstance` to control resource consumption +pub fn shutdown_anvil(anvil: Option) { + if let Some(anvil_instance) = anvil { + info!("[dry-run] Shutting down Anvil instance."); + drop(anvil_instance); + } +} diff --git a/bolt-cli/src/pb/v1.rs b/bolt-cli/src/pb/v1.rs index dbef7a820..edcc8db4c 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 803f9ced8f070bdd2c21d59866d324f8fcc34773 Mon Sep 17 00:00:00 2001 From: Precious <3173957+0ex-d@users.noreply.github.com> Date: Tue, 11 Feb 2025 19:45:29 +0000 Subject: [PATCH 2/3] Update cli.rs --- bolt-cli/src/cli.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bolt-cli/src/cli.rs b/bolt-cli/src/cli.rs index f80a72845..d13b0e5ee 100644 --- a/bolt-cli/src/cli.rs +++ b/bolt-cli/src/cli.rs @@ -325,10 +325,6 @@ pub enum EigenLayerSubcommand { /// The URL of the RPC to read data from #[clap(long, env = "RPC_URL")] rpc_url: Url, - /// Run the command in "dry run" mode, run all steps without broadcast. - /// Useful for testing and debugging purposes. - #[clap(short, long, env = "DRY_RUN", default_value = "false")] - dry_run: bool, }, } @@ -402,10 +398,6 @@ pub enum SymbioticSubcommand { /// The URL of the RPC to read data from #[clap(long, env = "RPC_URL")] rpc_url: Url, - /// Run the command in "dry run" mode, run all steps without broadcast. - /// Useful for testing and debugging purposes. - #[clap(short, long, env = "DRY_RUN", default_value = "false")] - dry_run: bool, }, } From 00d9fcd49d9ab081bcc1dae2c5f8024ccbe02622 Mon Sep 17 00:00:00 2001 From: David <3173957+0ex-d@users.noreply.github.com> Date: Tue, 11 Feb 2025 19:56:33 +0000 Subject: [PATCH 3/3] remove simulation from listvaults and ListStrategies --- bolt-cli/src/commands/operators/eigenlayer.rs | 8 +- bolt-cli/src/commands/operators/symbiotic.rs | 8 +- bolt-cli/src/pb/v1.rs | 575 ++++++++++++------ 3 files changed, 401 insertions(+), 190 deletions(-) diff --git a/bolt-cli/src/commands/operators/eigenlayer.rs b/bolt-cli/src/commands/operators/eigenlayer.rs index e7f48005e..909eae2d0 100644 --- a/bolt-cli/src/commands/operators/eigenlayer.rs +++ b/bolt-cli/src/commands/operators/eigenlayer.rs @@ -501,10 +501,8 @@ impl EigenLayerSubcommand { Ok(()) } - Self::ListStrategies { rpc_url, dry_run } => { - let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; - - let provider = ProviderBuilder::new().on_http(rpc); + Self::ListStrategies { rpc_url } => { + let provider = ProviderBuilder::new().on_http(rpc_url.clone()); let chain = Chain::try_from_provider(&provider).await?; @@ -540,8 +538,6 @@ impl EigenLayerSubcommand { info!("- Token: {} - Strategy: {}", token_symbol, strategy_address); } - shutdown_anvil(anvil); - Ok(()) } } diff --git a/bolt-cli/src/commands/operators/symbiotic.rs b/bolt-cli/src/commands/operators/symbiotic.rs index 23cba2236..bc4066154 100644 --- a/bolt-cli/src/commands/operators/symbiotic.rs +++ b/bolt-cli/src/commands/operators/symbiotic.rs @@ -388,10 +388,8 @@ impl SymbioticSubcommand { Ok(()) } - Self::ListVaults { rpc_url, dry_run } => { - let (rpc, anvil) = handle_rpc_dry_run(rpc_url, dry_run)?; - - let provider = ProviderBuilder::new().on_http(rpc); + Self::ListVaults { rpc_url } => { + let provider = ProviderBuilder::new().on_http(rpc_url.clone()); let chain = Chain::try_from_provider(&provider).await?; @@ -427,8 +425,6 @@ impl SymbioticSubcommand { info!("- Token: {} - Vault: {}", token_symbol, vault_address); } - shutdown_anvil(anvil); - Ok(()) } } diff --git a/bolt-cli/src/pb/v1.rs b/bolt-cli/src/pb/v1.rs index edcc8db4c..dbef7a820 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) + }) + } } } }