8000 Follow up on #939 (leader election and drand) by nicola · Pull Request #967 · filecoin-project/specs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Follow up on #939 (leader election and drand) #967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 33 commits into from
Aug 13, 2020
Merged

Conversation

nicola
Copy link
Contributor
@nicola nicola commented Jun 30, 2020

Follow up on #939

@nikkolasg
Copy link
Contributor

we must cherry-pick henri's commit 5fd4097

@nicola nicola requested review from sternhenri and nikkolasg July 7, 2020 17:04
@@ -86,6 +66,36 @@ GetRandomness(dst, l, s):
{{< readfile file="/docs/actors/actors/crypto/randomness.go" code="true" lang="go" >}}
{{< readfile file="/docs/systems/filecoin_blockchain/struct/chain/chain.go" code="true" lang="go" >}}

## Drawing tickets from the VRF-chain for proof inclusion

There are a few instances in which the protocol requires inclusion to be drawn from the Filecoin blockchain's VRF-chain (which generates {{<sref tickets>}} with each new block), in order to tie certain proofs to a particular set of Filecoin blocks (i.e. a given chain or fork). This is notably the case for Seal Pre-commits (see {{<sref sealing>}}).
Copy link
Member

Choose a reason for hiding this comment

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

the protocol requires inclusion?

Copy link
Member

Choose a reason for hiding this comment

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

"This is notably the case for Seal Pre-commits (see {{}})." is awkward phrasing

Copy link
Contributor Author
@nicola nicola Jul 11, 2020

Choose a reason for hiding this comment

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

this is the fact that SealRandomness must be taken from VRF chain, this ensures that no other fork can replay it. We should make it explicit.

Copy link
Contributor

Choose a reason for hiding this comment

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

fair enough. I'll rephrase.

Copy link
Contributor
@sternhenri sternhenri left a comment

Choose a reason for hiding this comment

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

Some notes. Note that ElectionPeriod is currently undefined in spec, and imo, not particularly helpful to understanding the Filecoin/drand mapping (but maybe that is beacuse not defined)...

I also think we may not be on the exact same page wrt which drand-related methods are called during filecoin block generation vs validation @nikkolasg

Comment on lines 113 to 114
When mining, a miner can fetch entries from the drand network to include them in
the new block by calling the method `GetBeaconEntriesForEpoch`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Last I checked lotus this is not quite right. The drand network methods (ie to fetch the values) are invoked in block creation. The GetBeaconEntries/Entry method are used as part of block validation...

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, that's what this function is doing: it fetches the drand entries via network drand.Public(round) is a call to the drand network.
For block validation, you use GetRandomnessFromBeacon(e ChainEpoch, head ChainEpoch), which derives the randomness from the chain itself.
Does that seem right to you ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Mmmh I guess you're right. In that case, the naming is not very good (ie we should make explicit what fetches from beacon and what fetches from chain) but I suppose this is correct, yes.

@@ -119,6 +152,25 @@ GetBeaconEntriesForEpoch(epoch) []BeaconEntry {
}
```

XXX: is it ever used this function ?
Copy link
Contributor

Choose a reason for hiding this comment 67F4

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

Yes, as part of validation. GetBeaconEntriesForEpoch is not used anywhere else though, last I checked.

Copy link
Contributor

Choose a reason for hiding this comment

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

For me, the func GetRandomnessFromBeacon(e ChainEpoch, head ChainEpoch) (DrandEntry,error) is what is used now, the "new" function to make sure we take care of the issue @nicola wrote before (about having null blocks changing the drand round <-> filecoin round mapping).
If you consider GetRandomnessFromBeacon the "one function to use to get drand entry from the chain", then I'm not sure we still need this one (GetBeaconEntryForEpoch) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

you're right, they look dup at this point. In that case we should replace all uses of GetBeaconEntryForEpoch with GetRandomnessFromBeacon and remove the former, no?

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

Comment on lines 136 to 141
// special case for genesis block (it has no beacon entry and so the first verifiable value comes at height 2,
// as with GetBeaconEntriesForEpoch()
if priorBlockHeader.Epoch == 0 {
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

why the removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ping @nikkolasg

Copy link
Contributor

Choose a reason for hiding this comment

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

ping @nikkolasg

sternhenri and others added 2 commits July 12, 2020 07:08
Co-authored-by: Henri <3359083+sternhenri@users.noreply.github.com>
@nikkolasg
Copy link
Contributor

@sternhenri I replied to your comments by other questions / assertions :)

nikkolasg
nikkolasg previously approved these changes Aug 4, 2020
@sternhenri
Copy link
Contributor

Left a final ping for you @nikkolasg, but otherwise lgtm.

sternhenri
sternhenri previously approved these changes Aug 5, 2020
@nikkolasg
Copy link
Contributor

Which ping ? ;)

@nicola nicola requested review from nikkolasg and sternhenri August 10, 2020 14:25
@nicola nicola changed the base branch from master to beta August 10, 2020 14:27
nikkolasg
nikkolasg previously approved these changes Aug 10, 2020
@nicola
Copy link
Contributor Author
nicola commented Aug 10, 2020

We may have to rebase this. Will @yiannisbot's team fix the conflict with beta?

sternhenri
sternhenri previously approved these changes Aug 11, 2020
@olizilla
Copy link
Collaborator

I will fix the conflicts with beta 🎉


Per the above, a Filecoin chain will contain the entirety of the beacon's output from the Filecoin genesis to the current block.

Given their role in leader election and other critical protocols in Filecoin, a block's beacon entries must be validated for every block. See {{<sref drand>}} for details. This can be done by ensuring every beacon entry is a valid signature over the prior one in the chain, using drand's [`Verify`](https://github.com/drand/drand/blob/master/beacon/beacon.go#L72) endpoint as follows:
Copy link
Collaborator

Choose a reason for hiding this comment

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

The source file in drand with the Verify function has moved and the link 404s. I'm gonna updated it to point to https://github.com/drand/drand/blob/763e9a252cf59060c675ced0562e8eba506971c1/chain/beacon.go#L76

License: MIT
Signed-off-by: Oli Evans <oli@tableflip.io>
@olizilla olizilla dismissed stale reviews from sternhenri and nikkolasg via fddb585 August 13, 2020 13:42
@olizilla
Copy link
Collaborator

@yiannisbot I've fixed the merge conflicts here. Please review and merge when ready.

@nikkolasg I've taken care to preserve the content of your PR, but if you have time, please verify the merge conflict fixes to check nothing got lost in translation.

Copy link
Collaborator
@yiannisbot yiannisbot left a comment

Choose a reason for hiding this comment

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

Everything looks good to me!

@yiannisbot yiannisbot merged commit cf18c12 into beta Aug 13, 2020
hugomrdias added a commit that referenced this pull request Sep 26, 2020
…n update (#1066)

This PR is applying all the latest changes in the Expected Consensus, Leader Election and the rationale behind Poisson Sortition of WinCount. It builds on top of the changes merged from #967

Tooling:
- katex shortcode documented and working
- markdown linter actually fails now

Co-authored-by: Hugo Dias <hugomrdias@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0