Skip to content

Commit

Permalink
remove epoch from commitments
Browse files Browse the repository at this point in the history
  • Loading branch information
ss-es committed Dec 11, 2024
1 parent 2c0d46f commit 2eb70ff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 85 deletions.
27 changes: 7 additions & 20 deletions crates/types/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,26 +960,13 @@ impl<TYPES: NodeType> Leaf2<TYPES> {

impl<TYPES: NodeType> Committable for Leaf2<TYPES> {
fn commit(&self) -> committable::Commitment<Self> {
if *self.epoch == 0 {
RawCommitmentBuilder::new("leaf commitment")
.u64_field("view number", *self.view_number)
.field("parent leaf commitment", self.parent_commitment)
.field("block header", self.block_header.commit())
.field("justify qc", self.justify_qc.commit())
.optional("upgrade certificate", &self.upgrade_certificate)
.finalize()
} else {
RawCommitmentBuilder::new("leaf commitment")
.u64_field("view number", *self.view_number)
.u64_field("epoch number", *self.epoch)
.field("parent leaf commitment", self.parent_commitment)
.field("block header", self.block_header.commit())
.field("justify qc", self.justify_qc.commit())
.optional("upgrade certificate", &self.upgrade_certificate)
.fixed_size_bytes(&self.drb_seed)
.fixed_size_bytes(&self.drb_result)
.finalize()
}
RawCommitmentBuilder::new("leaf commitment")
.u64_field("view number", *self.view_number)
.field("parent leaf commitment", self.parent_commitment)
.field("block header", self.block_header.commit())
.field("justify qc", self.justify_qc.commit())
.optional("upgrade certificate", &self.upgrade_certificate)
.finalize()
}
}

Expand Down
89 changes: 24 additions & 65 deletions crates/types/src/simple_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,14 @@ impl<TYPES: NodeType> Committable for QuorumData<TYPES> {

impl<TYPES: NodeType> Committable for QuorumData2<TYPES> {
fn commit(&self) -> Commitment<Self> {
let QuorumData2 { leaf_commit, epoch } = self;

if **epoch == 0 {
committable::RawCommitmentBuilder::new("Quorum data")
.var_size_bytes(leaf_commit.as_ref())
.finalize()
} else {
committable::RawCommitmentBuilder::new("Quorum data")
.var_size_bytes(leaf_commit.as_ref())
.u64(**epoch)
.finalize()
}
let QuorumData2 {
leaf_commit,
epoch: _,
} = self;

committable::RawCommitmentBuilder::new("Quorum data")
.var_size_bytes(leaf_commit.as_ref())
.finalize()
}
}

Expand All @@ -370,18 +366,11 @@ impl<TYPES: NodeType> Committable for TimeoutData<TYPES> {

impl<TYPES: NodeType> Committable for TimeoutData2<TYPES> {
fn commit(&self) -> Commitment<Self> {
let TimeoutData2 { view, epoch } = self;

if **epoch == 0 {
committable::RawCommitmentBuilder::new("Timeout data")
.u64(**view)
.finalize()
} else {
committable::RawCommitmentBuilder::new("Timeout data")
.u64(**view)
.u64(**epoch)
.finalize()
}
let TimeoutData2 { view, epoch: _ } = self;

committable::RawCommitmentBuilder::new("Timeout data")
.u64(**view)
.finalize()
}
}

Expand All @@ -397,18 +386,12 @@ impl<TYPES: NodeType> Committable for DaData2<TYPES> {
fn commit(&self) -> Commitment<Self> {
let DaData2 {
payload_commit,
epoch,
epoch: _,
} = self;
if **epoch == 0 {
committable::RawCommitmentBuilder::new("DA data")
.var_size_bytes(payload_commit.as_ref())
.finalize()
} else {
committable::RawCommitmentBuilder::new("DA data")
.var_size_bytes(payload_commit.as_ref())
.u64(**epoch)
.finalize()
}

committable::RawCommitmentBuilder::new("DA data")
.var_size_bytes(payload_commit.as_ref())
.finalize()
}
}

Expand Down Expand Up @@ -469,18 +452,10 @@ impl<TYPES: NodeType> Committable for ViewSyncPreCommitData2<TYPES> {
let ViewSyncPreCommitData2 {
relay,
round,
epoch,
epoch: _,
} = self;

if **epoch == 0 {
view_and_relay_commit::<TYPES, Self>(*round, *relay, "View Sync Precommit")
} else {
committable::RawCommitmentBuilder::new("View Sync Precommit")
.u64(*relay)
.u64(**round)
.u64(**epoch)
.finalize()
}
view_and_relay_commit::<TYPES, Self>(*round, *relay, "View Sync Precommit")
}
}

Expand All @@ -495,18 +470,10 @@ impl<TYPES: NodeType> Committable for ViewSyncFinalizeData2<TYPES> {
let ViewSyncFinalizeData2 {
relay,
round,
epoch,
epoch: _,
} = self;

if **epoch == 0 {
view_and_relay_commit::<TYPES, Self>(*round, *relay, "View Sync Finalize")
} else {
committable::RawCommitmentBuilder::new("View Sync Finalize")
.u64(*relay)
.u64(**round)
.u64(**epoch)
.finalize()
}
view_and_relay_commit::<TYPES, Self>(*round, *relay, "View Sync Finalize")
}
}

Expand All @@ -521,18 +488,10 @@ impl<TYPES: NodeType> Committable for ViewSyncCommitData2<TYPES> {
let ViewSyncCommitData2 {
relay,
round,
epoch,
epoch: _,
} = self;

if **epoch == 0 {
view_and_relay_commit::<TYPES, Self>(*round, *relay, "View Sync Commit")
} else {
committable::RawCommitmentBuilder::new("View Sync Commit")
.u64(*relay)
.u64(**round)
.u64(**epoch)
.finalize()
}
view_and_relay_commit::<TYPES, Self>(*round, *relay, "View Sync Commit")
}
}

Expand Down

0 comments on commit 2eb70ff

Please sign in to comment.