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

Generalize pallet-babe to be independent of BABE primitives #5655

Closed
wants to merge 16 commits into from

Conversation

sorpaas
Copy link
Member

@sorpaas sorpaas commented Apr 15, 2020

This is an attempt that aims at generalizing pallet-babe so that it does not depend on BABE primitives. The goal is to make the pallet also suitable to be used in Sassafras.

Mostly we'd need to generalize the pre-digest and post-block-digest logics, which are the differences of BABE and Sassafras. The current generalization still depend on schnorrkel types. Given Sassafras needs to be moved to ring VRF, this also has to be generalized.

@sorpaas sorpaas added the A3-in_progress Pull request is in progress. No review needed at this stage. label Apr 15, 2020
@sorpaas
Copy link
Member Author

sorpaas commented Apr 16, 2020

I finished the part that generalize frame-babe (but not yet over schnorrkel). Still a few docs and naming things to change, but in general should be mostly ready for some reviews.

@sorpaas sorpaas marked this pull request as ready for review April 16, 2020 17:25
@sorpaas sorpaas added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Apr 16, 2020
@gavofyork gavofyork added 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. labels Jul 1, 2020
@gavofyork
Copy link
Member

@sorpaas we'll need this bringing up to date...
@andresilva is this something you could review?

@gnunicorn
Copy link
Contributor

closing because of inactivity.

@gnunicorn gnunicorn closed this Sep 9, 2020

if let PreDigest::Primary(primary) = digest {
if let Some(randomness) = T::make_randomness(&digest) {
// place the VRF output into the `Initialized` storage item
// and it'll be put onto the under-construction randomness
// later, once we've decided which epoch this block is in.
Copy link

Choose a reason for hiding this comment

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

Can someone explain the issue with knowing in which epoch the block comes? It'd be easier on the storage if UnderConstruction = Hash(UnderConstruction, BlockVrfOutput) but you cannot do that if you donnot what epoch a block lies in. We should always know what epoch sassafras blocks lie in though, yes?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just that at this point we are still running the block initialization logic and haven't processed any epoch change. It might be the case that this block starts a new epoch, in which case the randomness should be pooled under the new epoch (i.e. empty pool) rather than adding it to the existing epoch's. This will all be done as part of block processing so once we exit from the runtime the randomness will be stored in its appropriate place (you're right that we can always tell what epoch a given block belongs to).

Copy link

Choose a reason for hiding this comment

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

In sassafras, we authorized block production by building this VRF output list for the whole epoch, so we'll need to know our epoch so that we can check the right list. I suspect this might just be a place where babe and sassafras diverge more than expected.

@burdges
Copy link

burdges commented Sep 9, 2020

cc #7053

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants