Skip to content

Commit

Permalink
add start_threshold for orchestrator (#3054)
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-es authored Apr 26, 2024
1 parent 866fd4c commit dba082f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/orchestrator/run-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ cdn_marshal_address = "127.0.0.1:9000"
[config]
num_nodes_with_stake = 10
num_nodes_without_stake = 0
start_threshold = [
8,
10,
]
staked_committee_nodes = 10
non_staked_committee_nodes = 0
fixed_leader_for_gpuvid = 0
Expand Down
5 changes: 5 additions & 0 deletions crates/orchestrator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ fn default_builder_url() -> Url {
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(bound(deserialize = ""))]
pub struct HotShotConfigFile<KEY: SignatureKey> {
/// The proportion of nodes required before the orchestrator issues the ready signal,
/// expressed as (numerator, denominator)
pub start_threshold: (u64, u64),
/// Total number of staked nodes in the network
pub num_nodes_with_stake: NonZeroUsize,
/// Total number of non-staked nodes in the network
Expand Down Expand Up @@ -667,6 +670,7 @@ impl<KEY: SignatureKey, E: ElectionConfig> From<HotShotConfigFile<KEY>> for HotS
fn from(val: HotShotConfigFile<KEY>) -> Self {
HotShotConfig {
execution_type: ExecutionType::Continuous,
start_threshold: val.start_threshold,
num_nodes_with_stake: val.num_nodes_with_stake,
num_nodes_without_stake: val.num_nodes_without_stake,
known_da_nodes: val.known_da_nodes,
Expand Down Expand Up @@ -737,6 +741,7 @@ impl<KEY: SignatureKey> Default for HotShotConfigFile<KEY> {

Self {
num_nodes_with_stake: NonZeroUsize::new(10).unwrap(),
start_threshold: (8, 10),
num_nodes_without_stake: 0,
my_own_validator_config: ValidatorConfig::default(),
known_nodes_with_stake: gen_known_nodes_with_stake,
Expand Down
6 changes: 5 additions & 1 deletion crates/orchestrator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,11 @@ where
fn post_ready(&mut self) -> Result<(), ServerError> {
self.nodes_connected += 1;
println!("Nodes connected: {}", self.nodes_connected);
if self.nodes_connected >= (self.config.config.num_nodes_with_stake.get() as u64) {
// i.e. nodes_connected >= num_nodes_with_stake * (start_threshold.0 / start_threshold.1)
if self.nodes_connected * self.config.config.start_threshold.1
>= (self.config.config.num_nodes_with_stake.get() as u64)
* self.config.config.start_threshold.0
{
self.start = true;
}
Ok(())
Expand Down
1 change: 1 addition & 0 deletions crates/testing/src/test_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ impl TestDescription {
let config = HotShotConfig {
// TODO this doesn't exist anymore
execution_type: ExecutionType::Incremental,
start_threshold: (1, 1),
num_nodes_with_stake: NonZeroUsize::new(num_nodes_with_stake).unwrap(),
// Currently making this zero for simplicity
known_da_nodes,
Expand Down
3 changes: 3 additions & 0 deletions crates/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ impl<KEY: SignatureKey> Default for PeerConfig<KEY> {
pub struct HotShotConfig<KEY: SignatureKey, ELECTIONCONFIG: ElectionConfig> {
/// Whether to run one view or continuous views
pub execution_type: ExecutionType,
/// The proportion of nodes required before the orchestrator issues the ready signal,
/// expressed as (numerator, denominator)
pub start_threshold: (u64, u64),
/// Total number of nodes in the network
// Earlier it was total_nodes
pub num_nodes_with_stake: NonZeroUsize,
Expand Down

0 comments on commit dba082f

Please sign in to comment.