Skip to content

Commit

Permalink
vote: add ephemeral bankhash and slot to TowerSync
Browse files Browse the repository at this point in the history
  • Loading branch information
AshwinSekar committed Sep 24, 2024
1 parent 037838a commit 18f9f0d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ pub(crate) enum BlockhashStatus {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "9ziHa1vA7WG5RCvXiE3g1f2qjSTNa47FB7e2czo7en7a")
frozen_abi(digest = "Lbx8JWmgAWq4SSo1XyrXprAgPtp9ncRNJJPCKH1pZ3W")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower {
Expand Down
2 changes: 1 addition & 1 deletion core/src/consensus/tower1_14_11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample),
frozen_abi(digest = "6VhLW7DSHNzrcswtxbNo4cb47oGrKLcKuDmCWVpUMLLM")
frozen_abi(digest = "FYKsZaj6MH3hqA4ksJWEG8LHQZF3Ty5PQgfbexnpAPtB")
)]
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
pub struct Tower1_14_11 {
Expand Down
2 changes: 1 addition & 1 deletion programs/vote/src/vote_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use {
#[cfg_attr(
feature = "frozen-abi",
derive(AbiExample, AbiEnumVisitor),
frozen_abi(digest = "3dbyMxwfCN43orGKa5YiyY1EqN2K97pTicNhKYTZSUQH")
frozen_abi(digest = "5zYYafKxFiaQj4s1PUhK7bW2rKAXBBcnpHVxR8kfpZhQ")
)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub enum VoteTransaction {
Expand Down
30 changes: 26 additions & 4 deletions sdk/program/src/vote/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,21 @@ impl VoteStateUpdate {

#[cfg_attr(
feature = "frozen-abi",
frozen_abi(digest = "5PFw9pyF1UG1DXVsw7gpjHegNyRycAAxWf2GA9wUXPs5"),
frozen_abi(digest = "DqMoZ6hSsG1wguKx49kjZmU8sEu7jjzDWqg14qxoeinM"),
derive(AbiExample)
)]
#[derive(Serialize, Default, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct TowerSync {
/// The proposed tower
/// the proposed tower
pub lockouts: VecDeque<Lockout>,
/// The proposed root
/// the proposed root
pub root: Option<Slot>,
/// signature of the bank's state at the last slot
/// signature of the VoteState's at the latest slot in `lockouts`
pub yolo_hash: Hash,
/// the latest fully replayed slot, equal to the last
/// slot in `lockouts` until asynchronous execution.
pub replay_tip: Slot,
/// signature of the bank's state at `replay_tip`
pub hash: Hash,
/// processing timestamp of last slot
pub timestamp: Option<UnixTimestamp>,
Expand All @@ -251,6 +256,8 @@ impl From<Vec<(Slot, u32)>> for TowerSync {
Self {
lockouts,
root: None,
yolo_hash: Hash::default(),
replay_tip: 0,
hash: Hash::default(),
timestamp: None,
block_id: Hash::default(),
Expand All @@ -265,9 +272,13 @@ impl TowerSync {
hash: Hash,
block_id: Hash,
) -> Self {
let replay_tip = lockouts.back().map(|l| l.slot).unwrap_or(0);
let yolo_hash = hash;
Self {
lockouts,
root,
yolo_hash,
replay_tip,
hash,
timestamp: None,
block_id,
Expand Down Expand Up @@ -298,8 +309,11 @@ impl TowerSync {
.map(|(cc, s)| Lockout::new_with_confirmation_count(s, cc.saturating_add(1) as u32))
.rev()
.collect();
let replay_tip = lockouts.back().map(|l| l.slot).unwrap_or(0);
Self {
lockouts,
replay_tip,
yolo_hash: hash,
hash,
root,
timestamp: None,
Expand Down Expand Up @@ -1090,6 +1104,8 @@ pub mod serde_tower_sync {
root: Slot,
#[serde(with = "short_vec")]
lockout_offsets: Vec<LockoutOffset>,
replay_tip: Slot,
yolo_hash: Hash,
hash: Hash,
timestamp: Option<UnixTimestamp>,
block_id: Hash,
Expand Down Expand Up @@ -1119,6 +1135,8 @@ pub mod serde_tower_sync {
let compact_tower_sync = CompactTowerSync {
root: tower_sync.root.unwrap_or(Slot::MAX),
lockout_offsets: lockout_offsets.collect::<Result<_, _>>()?,
replay_tip: tower_sync.replay_tip,
yolo_hash: tower_sync.yolo_hash,
hash: tower_sync.hash,
timestamp: tower_sync.timestamp,
block_id: tower_sync.block_id,
Expand All @@ -1133,6 +1151,8 @@ pub mod serde_tower_sync {
let CompactTowerSync {
root,
lockout_offsets,
replay_tip,
yolo_hash,
hash,
timestamp,
block_id,
Expand All @@ -1157,6 +1177,8 @@ pub mod serde_tower_sync {
Ok(TowerSync {
root,
lockouts: lockouts.collect::<Result<_, _>>()?,
replay_tip,
yolo_hash,
hash,
timestamp,
block_id,
Expand Down

0 comments on commit 18f9f0d

Please sign in to comment.