Skip to content

Commit 4982b3c

Browse files
committed
Add version to CertifiedBlock.
Helps with validating the commitment.
1 parent c8ba7c0 commit 4982b3c

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

timeboost-builder/src/certifier.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ impl Tracker {
665665
async fn deliver(&self, leader: bool, tx: &Sender<CertifiedBlock<Validated>>) -> Result<bool> {
666666
if let Some(cert) = self.votes.certificate() {
667667
if let Some(block) = &self.block {
668-
let cb = CertifiedBlock::new(cert.clone(), block.clone(), leader);
668+
let cb = CertifiedBlock::v1(cert.clone(), block.clone(), leader);
669669
tx.send(cb).await.map_err(|_| EndOfPlay::CertifierDown)?;
670670
return Ok(true);
671671
}

timeboost-builder/src/submit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ mod tests {
252252
}
253253
}
254254
let l = self.c.leader(*i.round().num() as usize) == self.p;
255-
CertifiedBlock::new(a.certificate().cloned().unwrap(), b, l)
255+
CertifiedBlock::v1(a.certificate().cloned().unwrap(), b, l)
256256
}
257257
}
258258

timeboost-types/src/block.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,12 @@ impl Committable for BlockInfo {
211211
#[cbor(map)]
212212
pub struct CertifiedBlock<S> {
213213
#[cbor(n(0))]
214-
data: Block,
214+
version: u8,
215215

216216
#[cbor(n(1))]
217+
data: Block,
218+
219+
#[cbor(n(2))]
217220
cert: Certificate<BlockInfo>,
218221

219222
#[cbor(skip)]
@@ -224,15 +227,20 @@ pub struct CertifiedBlock<S> {
224227
}
225228

226229
impl<S> CertifiedBlock<S> {
227-
pub fn new(cert: Certificate<BlockInfo>, data: Block, leader: bool) -> Self {
230+
pub fn v1(cert: Certificate<BlockInfo>, data: Block, leader: bool) -> Self {
228231
Self {
232+
version: 1,
229233
cert,
230234
data,
231235
leader,
232236
_marker: PhantomData,
233237
}
234238
}
235239

240+
pub fn version(&self) -> u8 {
241+
self.version
242+
}
243+
236244
pub fn committee(&self) -> CommitteeId {
237245
self.cert.data().round().committee()
238246
}
@@ -261,6 +269,7 @@ impl CertifiedBlock<Unchecked> {
261269
.is_valid_with_threshold_par(c, c.one_honest_threshold())
262270
{
263271
Some(CertifiedBlock {
272+
version: self.version,
264273
data: self.data,
265274
cert: self.cert,
266275
leader: self.leader,

0 commit comments

Comments
 (0)