diff --git a/crates/sui-bridge/src/sui_transaction_builder.rs b/crates/sui-bridge/src/sui_transaction_builder.rs index 932e749f9fd58..b86837bc9e639 100644 --- a/crates/sui-bridge/src/sui_transaction_builder.rs +++ b/crates/sui-bridge/src/sui_transaction_builder.rs @@ -1,7 +1,7 @@ // Copyright (c) Mysten Labs, Inc. // SPDX-License-Identifier: Apache-2.0 -use fastcrypto::traits::{KeyPair, ToFromBytes}; +use fastcrypto::traits::ToFromBytes; use move_core_types::ident_str; use std::{collections::HashMap, str::FromStr}; use sui_types::bridge::{ @@ -17,7 +17,6 @@ use sui_types::{ }; use sui_types::{Identifier, BRIDGE_PACKAGE_ID}; -use crate::crypto::BridgeAuthorityKeyPair; use crate::{ error::{BridgeError, BridgeResult}, types::{BridgeAction, VerifiedCertifiedBridgeAction}, @@ -551,16 +550,17 @@ pub fn build_committee_register_transaction( validator_address: SuiAddress, gas_object_ref: &ObjectRef, bridge_object_arg: ObjectArg, - bridge_key: BridgeAuthorityKeyPair, + bridge_authority_pub_key_bytes: Vec, bridge_url: &str, ref_gas_price: u64, ) -> BridgeResult { let mut builder = ProgrammableTransactionBuilder::new(); let system_state = builder.obj(ObjectArg::SUI_SYSTEM_MUT).unwrap(); let bridge = builder.obj(bridge_object_arg).unwrap(); - let pub_key = bridge_key.public().as_bytes().to_vec(); let bridge_pubkey = builder - .input(CallArg::Pure(bcs::to_bytes(&pub_key).unwrap())) + .input(CallArg::Pure( + bcs::to_bytes(&bridge_authority_pub_key_bytes).unwrap(), + )) .unwrap(); let url = builder .input(CallArg::Pure(bcs::to_bytes(bridge_url.as_bytes()).unwrap())) diff --git a/crates/sui/src/sui_commands.rs b/crates/sui/src/sui_commands.rs index ecab38eb69006..a2b9355cdcb96 100644 --- a/crates/sui/src/sui_commands.rs +++ b/crates/sui/src/sui_commands.rs @@ -40,7 +40,7 @@ use sui_swarm_config::network_config::NetworkConfig; use sui_swarm_config::network_config_builder::ConfigBuilder; use sui_swarm_config::node_config_builder::FullnodeConfigBuilder; use sui_types::base_types::SuiAddress; -use sui_types::crypto::{SignatureScheme, SuiKeyPair}; +use sui_types::crypto::{SignatureScheme, SuiKeyPair, ToFromBytes}; use tracing::info; #[allow(clippy::large_enum_variant)] @@ -404,7 +404,7 @@ impl SuiCommand { sui_address, &gas_obj_ref, bridge_arg, - kp, + kp.public().as_bytes().to_vec(), &format!("http://127.0.0.1:{port}"), rgp, ) diff --git a/crates/sui/src/validator_commands.rs b/crates/sui/src/validator_commands.rs index d9d42ac7c5890..d5a77adee7864 100644 --- a/crates/sui/src/validator_commands.rs +++ b/crates/sui/src/validator_commands.rs @@ -34,10 +34,8 @@ use fastcrypto::{ }; use serde::Serialize; use shared_crypto::intent::{Intent, IntentMessage, IntentScope}; -use sui_bridge::config::BridgeNodeConfig; use sui_bridge::sui_client::SuiClient as SuiBridgeClient; use sui_bridge::sui_transaction_builder::build_committee_register_transaction; -use sui_config::Config; use sui_json_rpc_types::{ SuiObjectDataOptions, SuiTransactionBlockResponse, SuiTransactionBlockResponseOptions, }; @@ -169,9 +167,9 @@ pub enum SuiValidatorCommand { }, /// Sui native bridge committee member registration BridgeCommitteeRegistration { - /// Path to bridge node config + /// Path to Bridge Authority Key file #[clap(long)] - bridge_node_config_path: PathBuf, + bridge_authority_key_path: PathBuf, /// Bridge authority URL which clients collects action signatures from #[clap(long)] bridge_authority_url: String, @@ -469,24 +467,19 @@ impl SuiValidatorCommand { } } SuiValidatorCommand::BridgeCommitteeRegistration { - bridge_node_config_path, + bridge_authority_key_path, bridge_authority_url, } => { - let bridge_config = match BridgeNodeConfig::load(bridge_node_config_path) { - Ok(config) => config, - Err(e) => panic!("Couldn't load BridgeNodeConfig, caused by: {e}"), - }; // Read bridge keypair - let ecdsa_keypair = match read_key(&bridge_config.bridge_authority_key_path, true)? - { + let ecdsa_keypair = match read_key(&bridge_authority_key_path, true)? { SuiKeyPair::Secp256k1(key) => key, _ => unreachable!("we required secp256k1 key in `read_key`"), }; let address = context.active_address()?; println!("Starting bridge committee registration for Sui validator: {address}, with bridge public key: {}", ecdsa_keypair.public); - - let bridge_client = SuiBridgeClient::new(&bridge_config.sui.sui_rpc_url).await?; + let sui_rpc_url = &context.config.get_active_env().unwrap().rpc; + let bridge_client = SuiBridgeClient::new(sui_rpc_url).await?; let bridge = bridge_client .get_mutable_bridge_object_arg_must_succeed() .await; @@ -501,7 +494,7 @@ impl SuiValidatorCommand { address, &gas, bridge, - ecdsa_keypair, + ecdsa_keypair.public().as_bytes().to_vec(), &bridge_authority_url, gas_price, ) diff --git a/crates/test-cluster/src/lib.rs b/crates/test-cluster/src/lib.rs index ed427b31fb117..40045563fd6c6 100644 --- a/crates/test-cluster/src/lib.rs +++ b/crates/test-cluster/src/lib.rs @@ -57,8 +57,8 @@ use sui_types::bridge::{get_bridge, TOKEN_ID_BTC, TOKEN_ID_ETH, TOKEN_ID_USDC, T use sui_types::bridge::{get_bridge_obj_initial_shared_version, BridgeSummary, BridgeTrait}; use sui_types::committee::CommitteeTrait; use sui_types::committee::{Committee, EpochId}; -use sui_types::crypto::KeypairTraits; use sui_types::crypto::SuiKeyPair; +use sui_types::crypto::{KeypairTraits, ToFromBytes}; use sui_types::effects::{TransactionEffects, TransactionEvents}; use sui_types::error::SuiResult; use sui_types::governance::MIN_VALIDATOR_JOINING_STAKE_MIST; @@ -1263,7 +1263,7 @@ impl TestClusterBuilder { validator_address, &gas, bridge_arg, - kp.copy(), + kp.public().as_bytes().to_vec(), &server_url, ref_gas_price, )