Skip to content

Commit

Permalink
chore: upgrade narwhal pointer (MystenLabs#4316)
Browse files Browse the repository at this point in the history
* Update narwhal pointer

* fix: adapt the Narwhal pointer in Sui post merge of narwhal/MystenLabs#859 (MystenLabs#4354)

This enacts the reversion of MystenLabs#818

* Add comments from MystenLabs#4219

* Update authority.rs after rebase

* hakari generate

Co-authored-by: François Garillot <[email protected]>
  • Loading branch information
arun-koshy and huitseeker authored Aug 30, 2022
1 parent 08d12eb commit 31ce002
Show file tree
Hide file tree
Showing 28 changed files with 698 additions and 608 deletions.
407 changes: 235 additions & 172 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/sui-benchmark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async-trait = "0.1.57"
rayon = "1.5.3"
anyhow = { version = "1.0.57", features = ["backtrace"] }
futures = "0.3.23"
serde = { version = "1.0.142", features = ["derive"] }
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0.83"
tempfile = "3.3.0"
tokio = { version = "1.20.1", features = ["full"] }
Expand Down Expand Up @@ -41,7 +41,7 @@ sui-node = { path = "../sui-node" }
sui-json-rpc-types = { path = "../sui-json-rpc-types" }

move-core-types = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2", features = ["address20"] }
narwhal-node = { git = "https://github.com/MystenLabs/narwhal", rev = "f4cab79d77cf70b0d564fa640fb748584a3ba36f", package = "node" }
narwhal-node = { git = "https://github.com/MystenLabs/narwhal", rev = "e994f67cacc2a42dd5d73fe3a64b9b490da72c3d", package = "node" }
workspace-hack = { path = "../workspace-hack"}
test-utils = { path = "../test-utils" }

Expand Down
4 changes: 2 additions & 2 deletions crates/sui-cluster-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ publish = false
edition = "2021"

[dependencies]
serde = { version = "1.0.142", features = ["derive"] }
serde = { version = "1.0.144", features = ["derive"] }
futures = "0.3.23"
serde_json = "1.0.83"
tempfile = "3.3.0"
Expand All @@ -32,4 +32,4 @@ sui-core = { path = "../sui-core" }
sui-json = { path = "../sui-json" }
sui-config = { path = "../sui-config" }
test-utils = { path = "../test-utils" }
workspace-hack = { path = "../workspace-hack"}
workspace-hack = { path = "../workspace-hack"}
6 changes: 3 additions & 3 deletions crates/sui-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bcs = "0.1.3"
arc-swap = "1.5.1"
camino = "1.1.1"
anyhow = { version = "1.0.58", features = ["backtrace"] }
serde = { version = "1.0.141", features = ["derive", "rc"] }
serde = { version = "1.0.144", features = ["derive", "rc"] }
serde_with = "1.14.0"
serde_yaml = "0.8.26"
rand = "0.8.5"
Expand All @@ -20,13 +20,13 @@ multiaddr = "0.14.0"
once_cell = "1.13.1"
tracing = "0.1.36"

fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "a9e58305dc463c40b9d357730203406214909f04" }
fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "c022a2ae23ca7cc2778293fd3b1db42e8cd02d3b" }

move-binary-format = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" }
move-package = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" }
move-core-types = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2", features = ["address20"] }
move-vm-runtime = { git = "https://github.com/move-language/move", rev = "70b34a66473c34ad30d101290b249f2db3c847a2" }
narwhal-config = { git = "https://github.com/MystenLabs/narwhal", rev = "f4cab79d77cf70b0d564fa640fb748584a3ba36f", package = "config" }
narwhal-config = { git = "https://github.com/MystenLabs/narwhal", rev = "e994f67cacc2a42dd5d73fe3a64b9b490da72c3d", package = "config" }


sui-framework = { path = "../sui-framework" }
Expand Down
41 changes: 32 additions & 9 deletions crates/sui-config/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ impl Genesis {
.validator_set
.iter()
.map(|validator| {
// 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()
Expand All @@ -75,6 +78,29 @@ impl Genesis {
primary_to_primary: validator.narwhal_primary_to_primary.clone(),
worker_to_primary: validator.narwhal_worker_to_primary.clone(),
};
let authority = narwhal_config::Authority {
stake: validator.stake as narwhal_config::Stake, //TODO this should at least be the same size integer
primary,
};

(name, authority)
})
.collect();
std::sync::Arc::new(arc_swap::ArcSwap::from_pointee(narwhal_config::Committee {
authorities: narwhal_committee,
epoch: self.epoch() as narwhal_config::Epoch,
}))
}

pub fn narwhal_worker_cache(&self) -> narwhal_config::SharedWorkerCache {
let workers = self
.validator_set
.iter()
.map(|validator| {
let name = validator
.protocol_key()
.try_into()
.expect("Can't get narwhal public key");
let workers = [(
0, // worker_id
narwhal_config::WorkerInfo {
Expand All @@ -85,19 +111,16 @@ impl Genesis {
)]
.into_iter()
.collect();
let authority = narwhal_config::Authority {
stake: validator.stake as narwhal_config::Stake, //TODO this should at least be the same size integer
primary,
workers,
};
let worker_index = narwhal_config::WorkerIndex(workers);

(name, authority)
(name, worker_index)
})
.collect();
std::sync::Arc::new(arc_swap::ArcSwap::from_pointee(narwhal_config::Committee {
authorities: narwhal_committee,
narwhal_config::WorkerCache {
workers,
epoch: self.epoch() as narwhal_config::Epoch,
}))
}
.into()
}

pub fn sui_system_object(&self) -> SuiSystemState {
Expand Down
1 change: 1 addition & 0 deletions crates/sui-config/tests/snapshot_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn populated_genesis_snapshot_matches() {
assert_yaml_snapshot!(genesis.validator_set());
assert_yaml_snapshot!(genesis.committee().unwrap());
assert_yaml_snapshot!(genesis.narwhal_committee());
assert_yaml_snapshot!(genesis.narwhal_worker_cache());
assert_yaml_snapshot!(genesis.sui_system_object());
// Serialized `genesis` is not static and cannot be snapshot tested.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,4 @@ authorities:
primary:
primary_to_primary: ""
worker_to_primary: ""
workers:
0:
transactions: ""
worker_to_worker: ""
primary_to_worker: ""
epoch: 0

Loading

0 comments on commit 31ce002

Please sign in to comment.