-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Key Management and Config File for Validator Onboarding #1990
Merged
dailinsubjam
merged 43 commits into
develop
from
sishan/merge_validator_onboarding_after_pull
Nov 9, 2023
Merged
Changes from 41 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
134d39a
remove some generated_from_seed_indexed()
dailinsubjam 21061fe
remove some generated_from_seed_indexed()
dailinsubjam 1189edb
fix lint
dailinsubjam 45208dc
solve conflict
dailinsubjam 9a856fe
make the key pair configurable
dailinsubjam 615037b
get keypair and stakevalue from config in modDA.rs
dailinsubjam 974357a
initialize known_nodes_sk
dailinsubjam d3374fe
generated_from_seed_indexed only appear in initialization or generato…
dailinsubjam e42635f
let the stake value be extractable if needed rather than assign 1u64 …
dailinsubjam 41b287f
unwrap() to expect()
dailinsubjam fc81a8b
avoid too many generic type for OrchestratorState
dailinsubjam 319a336
avoid too many generic type for NetworkConfig
dailinsubjam 4a17875
avoid too many generic type for OrchestratorApi
dailinsubjam eaea764
fix lint
dailinsubjam 0958125
add validator structure in config.rs
4e4fcbf
add validator config with default value
dailinsubjam 87c5de6
simplify hotshot and add node's validator info to hotshotconfig
dailinsubjam 0f97b09
move validator config from NetworkConfig to HotshotConfigFile
dailinsubjam c7ea1a3
fix lint
dailinsubjam f4197f9
remove useless comment
dailinsubjam dbe6450
merge, but why view number could be 0
dailinsubjam 8d5c308
cargo update but now the issue is in block_impl.rs called unwrap() on…
dailinsubjam 992fc67
solve view number overflow and downgrade to original cargo.lock
dailinsubjam 3d36e9c
fix lint
dailinsubjam 07e1f86
fix lint, PartialOrd for Key
dailinsubjam 7958ec8
get other nodes' info during initialization
dailinsubjam 83bedc7
fix lint
dailinsubjam 362199d
add some comments and make sure key generation is only in system init…
dailinsubjam 7acc7b2
Merge pull request #1949 from EspressoSystems/sishan/default_config_p…
dailinsubjam 2b31188
add struct ValidatorConfigFile
dailinsubjam ac71f6b
add validator config file
dailinsubjam 440ab12
Add validator config
dailinsubjam 3319f38
Merge pull request #1964 from EspressoSystems/sishan/config_file_vali…
dailinsubjam 091727c
fix lint
dailinsubjam 4f1fa04
make config file path configurable
dailinsubjam 753f4e5
scripts for generating key pairs added
dailinsubjam e571008
fix lint
dailinsubjam a73c690
forget to add new file for validator config
dailinsubjam aab444f
blank line at the end of the file
dailinsubjam 66f5507
Merge pull request #1980 from EspressoSystems/sishan/scripts_gen_keypair
dailinsubjam 9baa152
Merge branch 'sishan/validator_onboarding' into sishan/merge_validato…
dailinsubjam 0ca0a4f
Update mod.rs for larger timeout duration
dailinsubjam 4185ee5
Revert "Update mod.rs for larger timeout duration"
dailinsubjam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ValidatorConfig { | ||
public_key: BLSPubKey { | ||
pub_key: VerKey( | ||
( | ||
QuadExtField( | ||
2264797523581107490935262917175769123227923636811928330606075281145117212394 | ||
+ 15807017392833049888165434456991157794698032464874424842715555348468160607934 * u | ||
), | ||
QuadExtField( | ||
7996517616082121122160563552650547601395271017260499735456299700133762512689 | ||
+ 7504045709281061282278228438613345070383424761478787301859187055302953740948 * u | ||
), | ||
QuadExtField( | ||
1515973040548822760825076242090160370742046237881440422068330135941139244581 | ||
+ 20251846261653098602911417004145145971080304248810966341160788194007704966108 * u | ||
) | ||
) | ||
) | ||
}, | ||
private_key: BLSPrivKey { | ||
priv_key: SignKey( | ||
BigInt( | ||
[3505488234151006356, 6655477166151225138, 3291219027844407676, 2153641080015542578] | ||
) | ||
) | ||
}, | ||
stake_value: 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
seed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] | ||
node_id = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ValidatorConfig { public_key: BLSPubKey { pub_key: VerKey((QuadExtField(2264797523581107490935262917175769123227923636811928330606075281145117212394 + 15807017392833049888165434456991157794698032464874424842715555348468160607934 * u), QuadExtField(7996517616082121122160563552650547601395271017260499735456299700133762512689 + 7504045709281061282278228438613345070383424761478787301859187055302953740948 * u), QuadExtField(1515973040548822760825076242090160370742046237881440422068330135941139244581 + 20251846261653098602911417004145145971080304248810966341160788194007704966108 * u))) }, private_key: BLSPrivKey { priv_key: SignKey(BigInt([3505488234151006356, 6655477166151225138, 3291219027844407676, 2153641080015542578])) }, stake_value: 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,38 +94,14 @@ pub struct OrchestratorArgs { | |
/// Reads a network configuration from a given filepath | ||
pub fn load_config_from_file<TYPES: NodeType>( | ||
config_file: String, | ||
) -> NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
> { | ||
) -> NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType> { | ||
let config_file_as_string: String = fs::read_to_string(config_file.as_str()) | ||
.unwrap_or_else(|_| panic!("Could not read config file located at {config_file}")); | ||
let config_toml: NetworkConfigFile = | ||
toml::from_str::<NetworkConfigFile>(&config_file_as_string) | ||
let config_toml: NetworkConfigFile<TYPES::SignatureKey> = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is clean! Love it |
||
toml::from_str::<NetworkConfigFile<TYPES::SignatureKey>>(&config_file_as_string) | ||
.expect("Unable to convert config file to TOML"); | ||
|
||
let mut config: NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
> = config_toml.into(); | ||
|
||
// Generate network's public keys | ||
let known_nodes: Vec<_> = (0..config.config.total_nodes.get()) | ||
.map(|node_id| { | ||
TYPES::SignatureKey::generated_from_seed_indexed( | ||
config.seed, | ||
node_id.try_into().unwrap(), | ||
) | ||
.0 | ||
}) | ||
.collect(); | ||
|
||
config.config.known_nodes_with_stake = (0..config.config.total_nodes.get()) | ||
.map(|node_id| known_nodes[node_id].get_stake_table_entry(1u64)) | ||
.collect(); | ||
|
||
let config: NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType> = config_toml.into(); | ||
config | ||
} | ||
|
||
|
@@ -238,11 +214,7 @@ pub trait RunDA< | |
{ | ||
/// Initializes networking, returns self | ||
async fn initialize_networking( | ||
config: NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
>, | ||
config: NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType>, | ||
) -> Self; | ||
|
||
/// Initializes the genesis state and HotShot instance; does not start HotShot consensus | ||
|
@@ -258,8 +230,8 @@ pub trait RunDA< | |
let config = self.get_config(); | ||
|
||
// Get KeyPair for certificate Aggregation | ||
let (pk, sk) = | ||
TYPES::SignatureKey::generated_from_seed_indexed(config.seed, config.node_index); | ||
let pk = config.config.my_own_validator_config.public_key.clone(); | ||
let sk = config.config.my_own_validator_config.private_key.clone(); | ||
let known_nodes_with_stake = config.config.known_nodes_with_stake.clone(); | ||
let entry = pk.get_stake_table_entry(1u64); | ||
|
||
|
@@ -426,13 +398,7 @@ pub trait RunDA< | |
fn get_vid_network(&self) -> VIDNETWORK; | ||
|
||
/// Returns the config for this run | ||
fn get_config( | ||
&self, | ||
) -> NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
>; | ||
fn get_config(&self) -> NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType>; | ||
} | ||
|
||
// WEB SERVER | ||
|
@@ -443,11 +409,7 @@ pub struct WebServerDARun< | |
I: NodeImplementation<TYPES>, | ||
MEMBERSHIP: Membership<TYPES>, | ||
> { | ||
config: NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
>, | ||
config: NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType>, | ||
quorum_network: WebCommChannel<TYPES, I, MEMBERSHIP>, | ||
da_network: WebCommChannel<TYPES, I, MEMBERSHIP>, | ||
view_sync_network: WebCommChannel<TYPES, I, MEMBERSHIP>, | ||
|
@@ -516,18 +478,10 @@ where | |
Self: Sync, | ||
{ | ||
async fn initialize_networking( | ||
config: NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
>, | ||
config: NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType>, | ||
) -> WebServerDARun<TYPES, NODE, MEMBERSHIP> { | ||
// Generate our own key | ||
let (pub_key, _priv_key) = | ||
<<TYPES as NodeType>::SignatureKey as SignatureKey>::generated_from_seed_indexed( | ||
config.seed, | ||
config.node_index, | ||
); | ||
// Get our own key | ||
let pub_key = config.config.my_own_validator_config.public_key.clone(); | ||
|
||
// Get the configuration for the web server | ||
let WebServerConfig { | ||
|
@@ -599,13 +553,7 @@ where | |
self.vid_network.clone() | ||
} | ||
|
||
fn get_config( | ||
&self, | ||
) -> NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
> { | ||
fn get_config(&self) -> NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType> { | ||
self.config.clone() | ||
} | ||
} | ||
|
@@ -615,11 +563,7 @@ where | |
/// Represents a libp2p-based run | ||
pub struct Libp2pDARun<TYPES: NodeType, I: NodeImplementation<TYPES>, MEMBERSHIP: Membership<TYPES>> | ||
{ | ||
config: NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
>, | ||
config: NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType>, | ||
quorum_network: Libp2pCommChannel<TYPES, I, MEMBERSHIP>, | ||
da_network: Libp2pCommChannel<TYPES, I, MEMBERSHIP>, | ||
view_sync_network: Libp2pCommChannel<TYPES, I, MEMBERSHIP>, | ||
|
@@ -688,17 +632,9 @@ where | |
Self: Sync, | ||
{ | ||
async fn initialize_networking( | ||
config: NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
>, | ||
config: NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType>, | ||
) -> Libp2pDARun<TYPES, NODE, MEMBERSHIP> { | ||
let (pubkey, _privkey) = | ||
<<TYPES as NodeType>::SignatureKey as SignatureKey>::generated_from_seed_indexed( | ||
config.seed, | ||
config.node_index, | ||
); | ||
let pubkey = config.config.my_own_validator_config.public_key.clone(); | ||
let mut config = config; | ||
let libp2p_config = config | ||
.libp2p_config | ||
|
@@ -779,8 +715,13 @@ where | |
let mut all_keys = BTreeSet::new(); | ||
let mut da_keys = BTreeSet::new(); | ||
for i in 0..config.config.total_nodes.get() as u64 { | ||
let privkey = TYPES::SignatureKey::generated_from_seed_indexed([0u8; 32], i).1; | ||
let pubkey = TYPES::SignatureKey::from_private(&privkey); | ||
let pubkey = <<TYPES as NodeType>::SignatureKey>::get_public_key( | ||
config | ||
.config | ||
.known_nodes_with_stake | ||
.get(i as usize) | ||
.expect("node_id should be within the range of known_nodes"), | ||
); | ||
if i < config.config.da_committee_size as u64 { | ||
da_keys.insert(pubkey.clone()); | ||
} | ||
|
@@ -848,13 +789,7 @@ where | |
self.vid_network.clone() | ||
} | ||
|
||
fn get_config( | ||
&self, | ||
) -> NetworkConfig< | ||
TYPES::SignatureKey, | ||
<TYPES::SignatureKey as SignatureKey>::StakeTableEntry, | ||
TYPES::ElectionConfigType, | ||
> { | ||
fn get_config(&self) -> NetworkConfig<TYPES::SignatureKey, TYPES::ElectionConfigType> { | ||
self.config.clone() | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this as long as it still works as intended ! I wonder why we implemented it this way to begin with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also wondering about that. In the beginning the implementation on this was very long ago, and later implementation just follow that. There are more discussions on whether we want to keep this on zullip.