diff --git a/README.md b/README.md index 881ab88b74aa4..621c67b3d252e 100644 --- a/README.md +++ b/README.md @@ -44,11 +44,10 @@ Example `genesis.conf` { "authorities": [ { - "address": "bd654f352c895d9ec14c491d3f2b4e1f98fb07323383bebe9f95ab625bff2fa0", - "key_pair": "DfwJMkbD877Xehkaa03aPTsP5f4CpSADNCfX3Iukku69ZU81LIldnsFMSR0/K04fmPsHMjODvr6flatiW/8voA==", + "key_pair": "xWhgxF5fagohi2V9jzUToxnhJbTwbtV2qX4dbMGXR7lORTBuDBe+ppFDnnHz8L/BcYHWO76EuQzUYe5pnpLsFQ==", "host": "127.0.0.1", - "port": 10004, - "db_path": "./authorities_db/bd654f352c895d9ec14c491d3f2b4e1f98fb07323383bebe9f95ab625bff2fa0", + "port": 10000, + "db_path": "./authorities_db/4e45306e0c17bea691439e71f3f0bfc17181d63bbe84b90cd461ee699e92ec15", "stake": 1 } ], diff --git a/sui/src/config.rs b/sui/src/config.rs index 3f864ace890df..2690614ec72d7 100644 --- a/sui/src/config.rs +++ b/sui/src/config.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use sui_types::base_types::*; -use sui_types::crypto::KeyPair; +use sui_types::crypto::{get_key_pair, KeyPair}; use crate::utils::optional_address_as_hex; use crate::utils::optional_address_from_hex; @@ -55,14 +55,9 @@ impl<'de> Deserialize<'de> for AuthorityPrivateInfo { where D: serde::de::Deserializer<'de>, { - let (new_address, new_key_pair) = get_key_pair(); + let (_, new_key_pair) = get_key_pair(); let json = Value::deserialize(deserializer)?; - let address = if let Some(val) = json.get("address") { - address_from_hex(val).map_err(serde::de::Error::custom)? - } else { - new_address - }; let key_pair = if let Some(val) = json.get("key_pair") { KeyPair::deserialize(val).map_err(serde::de::Error::custom)? } else { @@ -87,7 +82,7 @@ impl<'de> Deserialize<'de> for AuthorityPrivateInfo { } else { PathBuf::from(".") .join(AUTHORITIES_DB_NAME) - .join(encode_address_hex(&address)) + .join(encode_bytes_hex(key_pair.public_key_bytes())) }; let stake = if let Some(val) = json.get("stake") { usize::deserialize(val).map_err(serde::de::Error::custom)? @@ -96,7 +91,6 @@ impl<'de> Deserialize<'de> for AuthorityPrivateInfo { }; Ok(AuthorityPrivateInfo { - address, key_pair, host, port, @@ -242,7 +236,7 @@ impl GenesisConfig { let mut authority = AuthorityPrivateInfo::deserialize(Value::String(String::new()))?; authority.db_path = working_dir .join(AUTHORITIES_DB_NAME) - .join(encode_address_hex(&authority.address)); + .join(encode_bytes_hex(&authority.key_pair.public_key_bytes())); authorities.push(authority) } let mut accounts = Vec::new(); diff --git a/sui/src/sui_commands.rs b/sui/src/sui_commands.rs index 7e4ea79b16187..7671a55acad7b 100644 --- a/sui/src/sui_commands.rs +++ b/sui/src/sui_commands.rs @@ -11,12 +11,11 @@ use std::sync::Arc; use structopt::StructOpt; use sui_core::authority::{AuthorityState, AuthorityStore}; use sui_core::authority_server::AuthorityServer; -use sui_types::base_types::{ - get_key_pair, SequenceNumber, SuiAddress, TransactionDigest, TxContext, -}; +use sui_types::base_types::{SequenceNumber, SuiAddress, TransactionDigest, TxContext}; use sui_adapter::adapter::generate_package_id; use sui_types::committee::Committee; +use sui_types::crypto::get_key_pair; use sui_types::error::SuiResult; use sui_types::object::Object; use tracing::{error, info}; @@ -112,9 +111,9 @@ async fn genesis( ); for authority in genesis_conf.authorities { - voting_right.insert(authority.address, authority.stake); + voting_right.insert(*authority.key_pair.public_key_bytes(), authority.stake); authority_info.push(AuthorityInfo { - address: authority.address, + name: *authority.key_pair.public_key_bytes(), host: authority.host.clone(), base_port: authority.port, }); diff --git a/sui/src/unit_tests/cli_tests.rs b/sui/src/unit_tests/cli_tests.rs index 61a05c103d404..f63098754c965 100644 --- a/sui/src/unit_tests/cli_tests.rs +++ b/sui/src/unit_tests/cli_tests.rs @@ -6,7 +6,8 @@ use sui::config::{ AUTHORITIES_DB_NAME, }; use sui::wallet_commands::{WalletCommands, WalletContext}; -use sui_types::base_types::{encode_address_hex, get_key_pair, ObjectID}; +use sui_types::base_types::{encode_bytes_hex, ObjectID}; +use sui_types::crypto::get_key_pair; use tokio::task; use tracing_test::traced_test; diff --git a/sui/src/utils.rs b/sui/src/utils.rs index 462e488d892be..e7b757649986e 100644 --- a/sui/src/utils.rs +++ b/sui/src/utils.rs @@ -7,7 +7,7 @@ use std::fs::File; use std::io::BufReader; use std::net::TcpListener; use std::path::{Path, PathBuf}; -use sui_types::base_types::{decode_address_hex, encode_address_hex, PublicKeyBytes}; +use sui_types::base_types::{decode_bytes_hex, encode_bytes_hex, SuiAddress}; use tracing::log::trace; pub const DEFAULT_STARTING_PORT: u16 = 10000; @@ -75,7 +75,7 @@ impl PortAllocator { } pub fn optional_address_as_hex( - key: &Option, + key: &Option, serializer: S, ) -> Result where @@ -83,18 +83,16 @@ where { serializer.serialize_str( &*key - .map(|addr| encode_address_hex(&addr)) + .map(|addr| encode_bytes_hex(&addr)) .unwrap_or_else(|| "".to_string()), ) } -pub fn optional_address_from_hex<'de, D>( - deserializer: D, -) -> Result, D::Error> +pub fn optional_address_from_hex<'de, D>(deserializer: D) -> Result, D::Error> where D: serde::de::Deserializer<'de>, { let s = String::deserialize(deserializer)?; - let value = decode_address_hex(&s).map_err(serde::de::Error::custom)?; + let value = decode_bytes_hex(&s).map_err(serde::de::Error::custom)?; Ok(Some(value)) } diff --git a/sui_core/src/authority.rs b/sui_core/src/authority.rs index a040aa2664d00..17c90331c0012 100644 --- a/sui_core/src/authority.rs +++ b/sui_core/src/authority.rs @@ -484,7 +484,7 @@ impl AuthorityState { pub async fn new_with_genesis_modules( committee: Committee, name: AuthorityName, - secret: StableSyncSigner, + secret: StableSyncAuthoritySigner, store: Arc, ) -> Self { let (genesis_modules, native_functions) = genesis::clone_genesis_data();