Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Alter BEEFY primitives to prepare for potential BLS integration #10466

Merged
merged 7 commits into from
Dec 20, 2021

Conversation

tomusdrw
Copy link
Contributor

This PR makes SignedCommitment contain a generic parameter Signature (instead of harcoded ecsda signature), so that in the future it can be used as: SignedCommitment<BlockNumber, ecsda::Signature> or SignedCommitment<BlockNumber, (ecdsa::Signature, (bls::Signature, ecsda::Signature))>).

Also I've renamed VersionedCommitment to VersionedFinalityProof. Currently BEEFY finality proof is simply the SignedCommitment with sufficient number of valid signatures, but in the future it will include not only the ecdsa Signatures, but also an aggregated BLS signature.

Related: paritytech/grandpa-bridge-gadget#2

CC @drskalman @andresilva

@tomusdrw tomusdrw added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit. labels Dec 10, 2021
let mut signatures_compact: Vec<Signature> = vec![];
let mut signatures_compact: Vec<&'a TSignature> = vec![];

let mut bits: Vec<u8> =
Copy link
Contributor

@kianenigma kianenigma Dec 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we populate this and signatures_compact in one iteration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but actually I think I'd rather use iterators for both:

let mut bits = signatures.iter().map(|x| if x.is_some() { 1 } else { 0 }).collect();
let mut signatures_compact = signatures.iter().filter_map(|x| x).collect();

wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah better 👍🏻

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not my thing, but the changes make sense to me.

Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tomusdrw tomusdrw merged commit 0bc1da8 into master Dec 20, 2021
@tomusdrw tomusdrw deleted the td-beefy-primitives branch December 20, 2021 13:57
AurevoirXavier pushed a commit to darwinia-network/substrate that referenced this pull request Jan 27, 2022
…tytech#10466)

* Generalize signature.

* Fix tests.

* Introduce VersionedFinalityProof.

* cargo +nightly fmt --all

* Rework packing a tad.
grishasobol pushed a commit to gear-tech/substrate that referenced this pull request Mar 28, 2022
…tytech#10466)

* Generalize signature.

* Fix tests.

* Introduce VersionedFinalityProof.

* cargo +nightly fmt --all

* Rework packing a tad.
@drskalman
Copy link
Contributor

@andresilva, @acatangiu: The current structure results in BEEFY messages of around 80K for 1K validators vs if we just keep one aggregated BLS signature it would 32K + 48Bytes + 1000/8 = 32172 that is about 2.5 time bulkier messages for no obvious advantage.

I suggest to have a vector of ECDSA signatures and a single aggregated BLS signature field in the BEEFY message instead of having a vector of (ECDSA, single BLS) signatures.

@acatangiu
Copy link
Contributor

I suggest to have a vector of ECDSA signatures and a single aggregated BLS signature field in the BEEFY message instead of having a vector of (ECDSA, single BLS) signatures.

Agreed! I believe the ideal end result is to have single aggregated signature, resulting in slim messages.

@drskalman
Copy link
Contributor

So aggregation before gossip unfortunately is not possible with unorganized gossip that we have: w3f/bls#51

ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
…tytech#10466)

* Generalize signature.

* Fix tests.

* Introduce VersionedFinalityProof.

* cargo +nightly fmt --all

* Rework packing a tad.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D2-notlive 💤 PR contains changes in a runtime directory that is not deployed to a chain that requires an audit.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants