-
Notifications
You must be signed in to change notification settings - Fork 149
load da_committee from genesis file #3634
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
Changes from 5 commits
7ab3920
0f33ed3
2ba49dd
ebd970c
a09bb19
d9c4e11
1bd7291
aa5929b
bad54a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,10 @@ use std::{ | |
use alloy::primitives::Address; | ||
use anyhow::{Context, Ok}; | ||
use espresso_types::{ | ||
v0_3::ChainConfig, FeeAccount, FeeAmount, GenesisHeader, L1BlockInfo, L1Client, Timestamp, | ||
Upgrade, | ||
v0_3::ChainConfig, FeeAccount, FeeAmount, GenesisHeader, L1BlockInfo, L1Client, SeqTypes, | ||
Timestamp, Upgrade, | ||
}; | ||
use hotshot_types::traits::node_implementation::NodeType; | ||
use serde::{Deserialize, Serialize}; | ||
use vbs::version::Version; | ||
|
||
|
@@ -44,6 +45,21 @@ pub enum L1Finalized { | |
Timestamp { timestamp: Timestamp }, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct PeerConfigData { | ||
pub stake_table_key: <SeqTypes as NodeType>::SignatureKey, | ||
pub state_ver_key: <SeqTypes as NodeType>::StateSignatureKey, | ||
pub stake: u64, | ||
} | ||
|
||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct VersionedDaCommittee { | ||
#[serde(with = "version_ser")] | ||
pub start_version: Version, | ||
pub start_epoch: u64, | ||
pub committee: Vec<PeerConfigData>, | ||
} | ||
|
||
|
||
/// Genesis of an Espresso chain. | ||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub struct Genesis { | ||
|
@@ -67,6 +83,8 @@ pub struct Genesis { | |
#[serde(rename = "upgrade", with = "upgrade_ser")] | ||
#[serde(default)] | ||
pub upgrades: BTreeMap<Version, Upgrade>, | ||
#[serde(default)] | ||
pub da_committees: Option<Vec<VersionedDaCommittee>>, | ||
} | ||
|
||
impl Genesis { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,14 +57,15 @@ use hotshot_types::{ | |
epoch_membership::EpochMembershipCoordinator, | ||
light_client::{StateKeyPair, StateSignKey}, | ||
signature_key::{BLSPrivKey, BLSPubKey}, | ||
stake_table::StakeTableEntry, | ||
traits::{ | ||
metrics::{Metrics, NoMetrics}, | ||
network::ConnectedNetwork, | ||
node_implementation::{NodeImplementation, NodeType, Versions}, | ||
storage::Storage, | ||
}, | ||
utils::BuilderCommitment, | ||
ValidatorConfig, | ||
ValidatorConfig, VersionedDaCommittee, | ||
}; | ||
pub use options::Options; | ||
use serde::{Deserialize, Serialize}; | ||
|
@@ -390,6 +391,28 @@ where | |
network_config.config.epoch_start_block = epoch_start_block; | ||
network_config.config.stake_table_capacity = stake_table_capacity; | ||
|
||
if let Some(da_committees) = &genesis.da_committees { | ||
tracing::warn!("setting da_committees from genesis"); | ||
network_config.config.da_committees = da_committees | ||
.iter() | ||
.map(|src| VersionedDaCommittee::<SeqTypes> { | ||
start_version: src.start_version, | ||
start_epoch: src.start_epoch, | ||
committee: src | ||
.committee | ||
.iter() | ||
.map(|pcd| hotshot_types::PeerConfig { | ||
stake_table_entry: StakeTableEntry { | ||
stake_key: pcd.stake_table_key, | ||
stake_amount: U256::from(pcd.stake), | ||
}, | ||
state_ver_key: pcd.state_ver_key.clone(), | ||
}) | ||
.collect(), | ||
}) | ||
.collect(); | ||
} | ||
Comment on lines
394
to
396
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. I'm not sure I see the reason for any of this -- can't we just use the same type? can't this entire block just be |
||
|
||
// If the `Libp2p` bootstrap nodes were supplied via the command line, override those | ||
// present in the config file. | ||
if let Some(bootstrap_nodes) = network_params.libp2p_bootstrap_nodes { | ||
|
@@ -529,7 +552,7 @@ where | |
// Create the HotShot membership | ||
let mut membership = EpochCommittees::new_stake( | ||
network_config.config.known_nodes_with_stake.clone(), | ||
network_config.config.known_da_nodes.clone(), | ||
network_config.config.build_da_committees(), | ||
|
||
block_reward, | ||
fetcher, | ||
epoch_height, | ||
|
@@ -1020,6 +1043,7 @@ pub mod testing { | |
fixed_leader_for_gpuvid: 0, | ||
num_nodes_with_stake: num_nodes.try_into().unwrap(), | ||
known_da_nodes: known_nodes_with_stake.clone(), | ||
da_committees: Default::default(), | ||
known_nodes_with_stake: known_nodes_with_stake.clone(), | ||
next_view_timeout: Duration::from_secs(5).as_millis() as u64, | ||
num_bootstrap: 1usize, | ||
|
@@ -1269,7 +1293,7 @@ pub mod testing { | |
let block_reward = fetcher.fetch_fixed_block_reward().await.ok(); | ||
let mut membership = EpochCommittees::new_stake( | ||
config.known_nodes_with_stake.clone(), | ||
config.known_da_nodes.clone(), | ||
config.build_da_committees(), | ||
block_reward, | ||
fetcher, | ||
config.epoch_height, | ||
|
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 don't think this function is necessary. We can keep the base
da_stake_table
(or whateverMembership
currently stores) separate from theepoch_da_committees
that apply at specific epochs, as we do for the full quorum stake table anyway