Skip to content

Commit

Permalink
fix: decouple Sui and Narwhal key formats
Browse files Browse the repository at this point in the history
  • Loading branch information
huitseeker committed Sep 12, 2022
1 parent 07af178 commit 61acd5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/sui-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ once_cell = "1.14.0"
tracing = "0.1.36"

fastcrypto = "0.1.2"

move-binary-format = { git = "https://github.com/move-language/move", rev = "e1e647b73dbd3652aabb2020728a4a517c26e28e" }
move-package = { git = "https://github.com/move-language/move", rev = "e1e647b73dbd3652aabb2020728a4a517c26e28e" }
move-core-types = { git = "https://github.com/move-language/move", rev = "e1e647b73dbd3652aabb2020728a4a517c26e28e", features = ["address20"] }
move-vm-runtime = { git = "https://github.com/move-language/move", rev = "e1e647b73dbd3652aabb2020728a4a517c26e28e" }
narwhal-config = { git = "https://github.com/MystenLabs/narwhal", rev = "2b77ef805c9bce0af4d74477dd922d150d31cb16", package = "config" }
narwhal-crypto = { git = "https://github.com/MystenLabs/narwhal", rev = "2b77ef805c9bce0af4d74477dd922d150d31cb16", package = "crypto" }

sui-framework = { path = "../sui-framework" }
sui-adapter = { path = "../sui-adapter" }
Expand Down
11 changes: 4 additions & 7 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use sui_adapter::in_memory_storage::InMemoryStorage;
use sui_adapter::temporary_store::{InnerTemporaryStore, TemporaryStore};
use sui_types::base_types::ObjectID;
use sui_types::base_types::TransactionDigest;
use sui_types::crypto::ToFromBytes;
use sui_types::crypto::{AuthorityPublicKeyBytes, AuthoritySignature};
use sui_types::gas::SuiGasStatus;
use sui_types::messages::CallArg;
Expand Down Expand Up @@ -70,9 +71,7 @@ impl Genesis {
// Strong requirement here for narwhal and sui to be on the same version of fastcrypto
// for AuthorityPublicBytes to cast to type alias PublicKey defined in narwhal to
// construct narwhal Committee struct.
let name = validator
.protocol_key()
.try_into()
let name = narwhal_crypto::PublicKey::from_bytes(validator.protocol_key().as_ref())
.expect("Can't get narwhal public key");
let primary = narwhal_config::PrimaryAddresses {
primary_to_primary: validator.narwhal_primary_to_primary.clone(),
Expand All @@ -97,9 +96,7 @@ impl Genesis {
.validator_set
.iter()
.map(|validator| {
let name = validator
.protocol_key()
.try_into()
let name = narwhal_crypto::PublicKey::from_bytes(validator.protocol_key().as_ref())
.expect("Can't get narwhal public key");
let workers = [(
0, // worker_id
Expand Down Expand Up @@ -598,9 +595,9 @@ const GENESIS_BUILDER_COMMITTEE_DIR: &str = "committee";
mod test {
use super::Builder;
use crate::{genesis_config::GenesisConfig, utils, ValidatorInfo};
use fastcrypto::traits::KeyPair;
use sui_types::crypto::{
generate_proof_of_possession, get_key_pair_from_rng, AccountKeyPair, AuthorityKeyPair,
KeypairTraits,
};

#[test]
Expand Down

0 comments on commit 61acd5c

Please sign in to comment.