Skip to content

Commit 7454d0b

Browse files
committed
change da_committees to a map of version to map of epoch to committee
1 parent 99589b4 commit 7454d0b

File tree

7 files changed

+29
-45
lines changed

7 files changed

+29
-45
lines changed

crates/hotshot/types/src/hotshot_config_file.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::{collections::BTreeMap, num::NonZeroUsize, time::Duration};
88

99
use alloy::primitives::U256;
1010
use url::Url;
11+
use vbs::version::Version;
1112
use vec1::Vec1;
1213

1314
use crate::{
@@ -47,7 +48,7 @@ pub struct HotShotConfigFile<TYPES: NodeType> {
4748
pub known_da_nodes: Vec<PeerConfig<TYPES>>,
4849
#[serde(skip)]
4950
/// The known DA nodes' public keys and stake values, by start epoch
50-
pub da_committees: BTreeMap<u64, Vec<PeerConfig<TYPES>>>,
51+
pub da_committees: BTreeMap<Version, BTreeMap<u64, Vec<PeerConfig<TYPES>>>>,
5152
/// Number of staking DA nodes
5253
pub staked_da_nodes: usize,
5354
/// Number of fixed leaders for GPU VID

crates/hotshot/types/src/lib.rs

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ use traits::{
1919
signature_key::{SignatureKey, StateSignatureKey},
2020
};
2121
use url::Url;
22+
use vbs::version::Version;
2223
use vec1::Vec1;
2324

24-
use crate::{traits::node_implementation::ConsensusTime, utils::bincode_opts};
25+
use crate::utils::bincode_opts;
2526
pub mod bundle;
2627
pub mod consensus;
2728
pub mod constants;
@@ -198,7 +199,7 @@ pub struct HotShotConfig<TYPES: NodeType> {
198199
/// All public keys known to be DA nodes
199200
pub known_da_nodes: Vec<PeerConfig<TYPES>>,
200201
/// All public keys known to be DA nodes, by start epoch
201-
pub da_committees: BTreeMap<u64, Vec<PeerConfig<TYPES>>>,
202+
pub da_committees: BTreeMap<Version, BTreeMap<u64, Vec<PeerConfig<TYPES>>>>,
202203
/// List of DA committee (staking)nodes for static DA committee
203204
pub da_staked_committee_size: usize,
204205
/// Number of fixed leaders for GPU VID, normally it will be 0, it's only used when running GPU VID
@@ -271,25 +272,10 @@ impl<TYPES: NodeType> HotShotConfig<TYPES> {
271272
self.known_nodes_with_stake.clone().into()
272273
}
273274

274-
pub fn build_da_committees(&self) -> BTreeMap<TYPES::Epoch, Vec<PeerConfig<TYPES>>> {
275-
if self.da_committees.is_empty() {
276-
tracing::warn!(
277-
"da_committees is not set, falling back to known_da_nodes, which is deprecated."
278-
);
279-
280-
[(TYPES::Epoch::new(0), self.known_da_nodes.clone())].into()
281-
} else {
282-
if !self.known_da_nodes.is_empty() {
283-
tracing::warn!(
284-
"Both known_da_nodes and da_committees are set, known_da_nodes is deprecated \
285-
and will be ignored."
286-
);
287-
}
288-
289-
self.da_committees
290-
.iter()
291-
.map(|(k, v)| (TYPES::Epoch::new(*k), v.clone()))
292-
.collect()
293-
}
275+
pub fn build_da_committees(&self) -> Vec<PeerConfig<TYPES>> {
276+
// TODO: THIS IS A TEMPORARY FIX WITH THE WRONG RETURN TYPE.
277+
// It's done so that we can start using this function and have the existing behavior
278+
// (use known_da_nodes) while we transition to using da_committees.
279+
self.known_da_nodes.clone()
294280
}
295281
}

sequencer/src/genesis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ pub struct Genesis {
111111
#[serde(default)]
112112
pub upgrades: BTreeMap<Version, Upgrade>,
113113
#[serde(default)]
114-
pub da_committees: Option<BTreeMap<TomlKeyU64, Vec<PeerConfigData>>>,
114+
pub da_committees: Option<BTreeMap<Version, BTreeMap<TomlKeyU64, Vec<PeerConfigData>>>>,
115115
}
116116

117117
impl Genesis {

sequencer/src/lib.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -397,14 +397,21 @@ where
397397
.iter()
398398
.map(|(k, v)| {
399399
(
400-
k.into(),
400+
*k,
401401
v.iter()
402-
.map(|pcd| hotshot_types::PeerConfig {
403-
stake_table_entry: StakeTableEntry {
404-
stake_key: pcd.stake_table_key,
405-
stake_amount: U256::from(pcd.stake),
406-
},
407-
state_ver_key: pcd.state_ver_key.clone(),
402+
.map(|(k, v)| {
403+
(
404+
k.into(),
405+
v.iter()
406+
.map(|pcd| hotshot_types::PeerConfig {
407+
stake_table_entry: StakeTableEntry {
408+
stake_key: pcd.stake_table_key,
409+
stake_amount: U256::from(pcd.stake),
410+
},
411+
state_ver_key: pcd.state_ver_key.clone(),
412+
})
413+
.collect(),
414+
)
408415
})
409416
.collect(),
410417
)

sequencer/src/message_compat_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ async fn test_message_compat<Ver: StaticVersionType>(_ver: Ver) {
6969
let membership = EpochMembershipCoordinator::new(
7070
Arc::new(RwLock::new(EpochCommittees::new_stake(
7171
committee.clone(),
72-
[(EpochNumber::new(0), committee)].into(),
72+
committee,
7373
None,
7474
Fetcher::mock(),
7575
epoch_height,

types/src/v0/config.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use hotshot_types::{
88
};
99
use serde::{Deserialize, Serialize};
1010
use tide_disco::Url;
11+
use vbs::version::Version;
1112
use vec1::Vec1;
1213

1314
use crate::{PubKey, SeqTypes};
@@ -56,7 +57,7 @@ pub struct PublicHotShotConfig {
5657
known_nodes_with_stake: Vec<PeerConfig<SeqTypes>>,
5758
known_da_nodes: Vec<PeerConfig<SeqTypes>>,
5859
#[serde(default)]
59-
da_committees: BTreeMap<u64, Vec<PeerConfig<SeqTypes>>>,
60+
da_committees: BTreeMap<Version, BTreeMap<u64, Vec<PeerConfig<SeqTypes>>>>,
6061
da_staked_committee_size: usize,
6162
fixed_leader_for_gpuvid: usize,
6263
next_view_timeout: u64,
@@ -202,10 +203,6 @@ impl PublicHotShotConfig {
202203
self.known_da_nodes.clone()
203204
}
204205

205-
pub fn da_committees(&self) -> BTreeMap<u64, Vec<PeerConfig<SeqTypes>>> {
206-
self.da_committees.clone()
207-
}
208-
209206
pub fn blocks_per_epoch(&self) -> u64 {
210207
self.epoch_height
211208
}

types/src/v0/impls/stake_table.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,18 +1689,11 @@ impl EpochCommittees {
16891689
// TODO remove `new` from trait and rename this to `new`.
16901690
// https://github.com/EspressoSystems/HotShot/commit/fcb7d54a4443e29d643b3bbc53761856aef4de8b
16911691
committee_members: Vec<PeerConfig<SeqTypes>>,
1692-
da_committees: BTreeMap<Epoch, Vec<PeerConfig<SeqTypes>>>,
1692+
da_members: Vec<PeerConfig<SeqTypes>>,
16931693
fixed_block_reward: Option<RewardAmount>,
16941694
fetcher: Fetcher,
16951695
epoch_height: u64,
16961696
) -> Self {
1697-
// TODO: Store da_committees in EpochCommittees. Currently we just pull da_members back out, but we
1698-
// will need to figure out how to integrate da_committees into EpochCommittee and the like.
1699-
let da_members = da_committees
1700-
.get(&Epoch::new(0))
1701-
.cloned()
1702-
.unwrap_or_default(); // For testing reasons, we want to support being given an empty map
1703-
17041697
// For each member, get the stake table entry
17051698
let stake_table: Vec<_> = committee_members
17061699
.iter()

0 commit comments

Comments
 (0)