-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for `GetBlockCertificates` and example. * Formatting. * Fix generated files. * Improve documentation and rust doc. * Doc. * Fix conversions of bls signatures for qc and tc sigs. * Split block_certificates into a new module file. * Update CHANGELOG.md Co-authored-by: Aleš Bizjak <[email protected]> * Update src/types/block_certificates.rs Co-authored-by: Aleš Bizjak <[email protected]> * Address review comments. * Revise successor proof. * update concordium-base. * Add optional block identifier argument to example. --------- Co-authored-by: Aleš Bizjak <[email protected]>
- Loading branch information
1 parent
4a35d6f
commit 0173cb0
Showing
8 changed files
with
309 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//! Test the `GetBlockCertificates` endpoint. | ||
use anyhow::Context; | ||
use clap::AppSettings; | ||
use structopt::StructOpt; | ||
|
||
use concordium_rust_sdk::v2; | ||
|
||
#[derive(StructOpt)] | ||
struct App { | ||
#[structopt( | ||
long = "node", | ||
help = "GRPC interface of the node.", | ||
default_value = "http://localhost:20000" | ||
)] | ||
endpoint: v2::Endpoint, | ||
#[structopt(long = "block", help = "Block to query", default_value = "lastfinal")] | ||
bi: v2::BlockIdentifier, | ||
} | ||
|
||
#[tokio::main(flavor = "multi_thread")] | ||
async fn main() -> anyhow::Result<()> { | ||
let app = { | ||
let app = App::clap().global_setting(AppSettings::ColoredHelp); | ||
let matches = app.get_matches(); | ||
App::from_clap(&matches) | ||
}; | ||
|
||
let mut client = v2::Client::new(app.endpoint) | ||
.await | ||
.context("Cannot connect.")?; | ||
|
||
let certificates = client.get_block_certificates(&app.bi).await?; | ||
println!("{:#?}", certificates); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
//! Module exposing certificates for blocks. | ||
//! The types are only relevant for nodes running at least protocol version | ||
//! 6. | ||
|
||
use concordium_base::{ | ||
base::{BakerId, Epoch, Round}, | ||
common::Serial, | ||
hashes, | ||
hashes::BlockHash, | ||
}; | ||
use std::collections::BTreeSet; | ||
|
||
/// An aggregate signature on a [`QuorumCertificate`] created | ||
/// by members of the finalization committee. | ||
#[derive(concordium_base::common::Serialize, Clone, Copy, Debug, PartialEq)] | ||
pub struct QuorumSignature( | ||
pub concordium_base::aggregate_sig::Signature<concordium_base::base::AggregateSigPairing>, | ||
); | ||
|
||
/// A quorum certificate on a block. | ||
#[derive(Debug)] | ||
pub struct QuorumCertificate { | ||
/// [`BlockHash`] of the block that this [`QuorumCertificate`] | ||
/// certifies. | ||
pub block_hash: BlockHash, | ||
/// [`Round`] of the block that this [`QuorumCertificate`] | ||
/// certifies. | ||
pub round: Round, | ||
/// [`Epoch`] of the block that this [`QuorumCertificate`] | ||
/// certifies. | ||
pub epoch: Epoch, | ||
/// The aggregate signature on the block identified by the | ||
/// `block_hash` which serves as a proof that the block | ||
/// was accepted on the chain by a quorum of the finalization | ||
/// committee. | ||
pub aggregate_signature: QuorumSignature, | ||
/// The baker ids of the finalizers that formed | ||
/// the `aggregate_signature`. | ||
/// Note that the signatories are sorted in ascending order of [`BakerId`]. | ||
pub signatories: BTreeSet<BakerId>, | ||
} | ||
|
||
/// A map from a [`Round`] to the set of finalizers | ||
/// (identified by their [`BakerId`]) which signed off | ||
/// in the round. | ||
#[derive(Debug)] | ||
pub struct FinalizerRound { | ||
/// The round which was signed off. | ||
pub round: Round, | ||
/// The set of finalizers who signed off. | ||
/// (identified by their [`BakerId`]) | ||
/// Note that the baker ids are sorted in ascending order and are | ||
/// distinct. | ||
pub finalizers: Vec<BakerId>, | ||
} | ||
|
||
/// An aggregate signature on a [`TimeoutCertificate`] created | ||
/// by members of the finalization committee. | ||
#[derive(concordium_base::common::Serialize, Clone, Copy, Debug, PartialEq)] | ||
pub struct TimeoutSignature( | ||
pub concordium_base::aggregate_sig::Signature<concordium_base::base::AggregateSigPairing>, | ||
); | ||
|
||
/// The timeout certificate serves as a proof that no block | ||
/// was created and/or distributed to the network in time. | ||
/// The [`TimeoutCertificate`] makes it possible for the consensus protocol | ||
/// to advance to the following round, thus giving (possibly) another baker | ||
/// the chance to bake a block. | ||
#[derive(Debug)] | ||
pub struct TimeoutCertificate { | ||
/// The round that timed out. | ||
pub round: Round, | ||
/// The minimum epoch of which signatures are included in | ||
/// the signature for the certificate. | ||
pub min_epoch: Epoch, | ||
/// The rounds of which finalizers have their best quorum | ||
/// certificates in the [`Epoch`] `min_epoch`. | ||
pub qc_rounds_first_epoch: Vec<FinalizerRound>, | ||
/// The rounds of which finalizers have their best quorum | ||
/// certificates in the [`Epoch`] `min_epoch` + 1. | ||
pub qc_rounds_second_epoch: Vec<FinalizerRound>, | ||
/// The aggregate signature by the finalization committee which | ||
/// serves as a proof that the [`Round`] timed out, hence | ||
/// no block was added to the chain. | ||
pub aggregate_signature: TimeoutSignature, | ||
} | ||
|
||
/// The epoch finalization entry serves as a proof that | ||
/// a quorum of the finalization committee has progressed | ||
/// to a new [`Epoch`]. | ||
#[derive(Debug)] | ||
pub struct EpochFinalizationEntry { | ||
/// The [`QuorumCertificate`] of the finalized block. | ||
pub finalized_qc: QuorumCertificate, | ||
/// The [`QuorumCertificate`] of the immediate successor | ||
/// of the block indicated by `finalized_qc`. | ||
pub successor_qc: QuorumCertificate, | ||
/// The witness that proves that the block of the `successor_qc` | ||
/// is an immediate decendant of the block of the `finalized_qc`. | ||
pub successor_proof: hashes::SuccessorProof, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct BlockCertificates { | ||
/// The [`QuorumCertificate`] of a block. | ||
/// Note that this will be [`None`] in the case | ||
/// where the block is a genesis block. | ||
pub quorum_certificate: Option<QuorumCertificate>, | ||
/// The [`TimeoutCertificate`] is present if and only if | ||
/// the previous round of the block timed out. | ||
pub timeout_certificate: Option<TimeoutCertificate>, | ||
/// The [`EpochFinalizationEntry`] is present if and only if | ||
/// the block is the first block of a new [`Epoch`]. | ||
pub epoch_finalization_entry: Option<EpochFinalizationEntry>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters