Skip to content

Commit

Permalink
get other nodes' info during initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
dailinsubjam committed Oct 26, 2023
1 parent 07e1f86 commit 7958ec8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 0 additions & 2 deletions crates/hotshot/examples/infra/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,12 @@ pub fn load_config_from_file<TYPES: NodeType>(
config_toml.into();

// Generate network's public keys
let mut known_nodes_sk = Vec::new();
let known_nodes: Vec<_> = (0..config.config.total_nodes.get())
.map(|node_id| {
let (key_pair, sk) = TYPES::SignatureKey::generated_from_seed_indexed(
config.seed,
node_id.try_into().unwrap(),
);
known_nodes_sk.push(sk);
key_pair
})
.collect();
Expand Down
13 changes: 12 additions & 1 deletion crates/orchestrator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ pub struct HotShotConfigFile<KEY: SignatureKey> {
pub total_nodes: NonZeroUsize,
/// My own public key, secret key, stake value
pub my_own_validator_config: ValidatorConfig<KEY>,
/// The known nodes' public key and stake value
pub known_nodes_with_stake: Vec<KEY::StakeTableEntry>,
/// Number of committee nodes
pub committee_nodes: usize,
/// Maximum transactions per block
Expand Down Expand Up @@ -205,7 +207,7 @@ impl<KEY: SignatureKey, E: ElectionConfig> From<HotShotConfigFile<KEY>> for HotS
total_nodes: val.total_nodes,
max_transactions: val.max_transactions,
min_transactions: val.min_transactions,
known_nodes_with_stake: Vec::new(),
known_nodes_with_stake: val.known_nodes_with_stake,
my_own_validator_config: val.my_own_validator_config,
da_committee_size: val.committee_nodes,
next_view_timeout: val.next_view_timeout,
Expand Down Expand Up @@ -233,9 +235,18 @@ fn default_padding() -> usize {

impl<KEY: SignatureKey> Default for HotShotConfigFile<KEY> {
fn default() -> Self {
let gen_known_nodes_with_stake = (0..10)
.map(|node_id| {
let cur_validator_config: ValidatorConfig<KEY> =
ValidatorConfig::generated_from_seed_indexed([0u8; 32], node_id, 1);

cur_validator_config.public_key.get_stake_table_entry(cur_validator_config.stake_value)
} )
.collect();
Self {
total_nodes: NonZeroUsize::new(10).unwrap(),
my_own_validator_config: ValidatorConfig::default(),
known_nodes_with_stake: gen_known_nodes_with_stake,
committee_nodes: 5,
max_transactions: NonZeroUsize::new(100).unwrap(),
min_transactions: 1,
Expand Down

0 comments on commit 7958ec8

Please sign in to comment.