Skip to content
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

feat: implement FIP-0063 #11572

Merged
merged 1 commit into from Jan 29, 2024
Merged

feat: implement FIP-0063 #11572

merged 1 commit into from Jan 29, 2024

Conversation

arajasek
Copy link
Contributor

Related Issues

Implements FIP-0063.

Proposed Changes

  • Introduce the new entry to the Drand Schedule, switching to Quicknet at PineappleHeight + 1
  • Refactor VerifyEntry to receive the previous entry's signature only, not the Entry struct. This signature field is nil for Quicknet entries.
  • Bumping drand deps to pull in Quicknet logic

Additional Info

Checklist

Before you mark the PR ready for review, please make sure that:

  • Commits have a clear commit message.
  • PR title is in the form of of <PR type>: <area>: <change being made>
    • example: fix: mempool: Introduce a cache for valid signatures
    • PR type: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, test
    • area, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps
  • If the PR affects users (e.g., new feature, bug fix, system requirements change), update the CHANGELOG.md and add details to the UNRELEASED section.
  • New features have usage guidelines and / or documentation updates in
  • Tests exist for new functionality or change in behavior
  • CI is green

@arajasek arajasek requested a review from a team as a code owner January 12, 2024 18:29
@arajasek arajasek requested review from snadrus and magik6k and removed request for a team January 12, 2024 18:29
build/drand.go Outdated Show resolved Hide resolved
chain/beacon/beacon.go Outdated Show resolved Hide resolved
Comment on lines 173 to 175
if curr.Round != prev.Round+1 {
return xerrors.Errorf("invalid beacon entry: cur (%d) != prev (%d) + 1", curr.Round, prev.Round)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's safe to drop this for both "current" Drand and quicknet, right?

Choose a reason for hiding this comment

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

I think so - it doesn't seems like in the current implementation the previous beacon should be cached, so there's no way for someone to e.g. provide a historical beacon that gets validated, though might be worth confirming

Choose a reason for hiding this comment

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

hmm well actually we only check the MaxBeaconRoundForEpoch - perhaps it is possible to provide a historical beacon without a check of the round?

Copy link
Contributor

@Kubuxu Kubuxu Jan 22, 2024

Choose a reason for hiding this comment

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

I think it is safe although it (EDIT) was additional check for consistency that drand is behaving well.

chain/beacon/drand/drand.go Outdated Show resolved Hide resolved
build/params_mainnet.go Outdated Show resolved Hide resolved
build/drand.go Show resolved Hide resolved
if e >= bp.Start {
// The new network version kicks in at one _after_ the upgrade height itself,
// so we switch to the new beacon when _strictly_ greater than bp.Start
if e > bp.Start {
Copy link
Contributor

@Kubuxu Kubuxu Jan 22, 2024

Choose a reason for hiding this comment

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

Won't this break the existing migration point?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, you're right, I forgot that we upgraded from incentinet to mainnet. I'll see how best to fix that up.

Copy link
Member

Choose a reason for hiding this comment

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

So... how bad is it if we switch one epoch early? Or, say, 10 epochs early at a completely different upgrade height to reduce the amount of shit happening at the same time?

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as we switch the same in miner, no issue. It's mostly just code/system smell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that, I'm actually inclined to switch later than the upgrade height (get your migration and other nonsense done first, then we switch beacons).

Copy link
Member

Choose a reason for hiding this comment

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

I'm just thinking we may want to ship two upgrades at the same time instead of trying to bundle them into one.

chain/sync.go Outdated Show resolved Hide resolved
if e >= bp.Start {
// The new network version kicks in at one _after_ the upgrade height itself,
// so we switch to the new beacon when _strictly_ greater than bp.Start
if e > bp.Start {
Copy link
Member

Choose a reason for hiding this comment

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

So... how bad is it if we switch one epoch early? Or, say, 10 epochs early at a completely different upgrade height to reduce the amount of shit happening at the same time?

@@ -129,6 +129,7 @@ func (filec *FilecoinEC) ValidateBlock(ctx context.Context, b *types.FullBlock)
return xerrors.Errorf("failed to get lookback tipset for block: %w", err)
}

// TODO: Optimization: We don't need to get latest beacon entry after nv22 and can supply null instead
Copy link
Member

Choose a reason for hiding this comment

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

Could you:

  1. Link to an issue (creating one).
  2. Explain (somewhere) why?

chain/beacon/drand/drand.go Outdated Show resolved Hide resolved
chain/beacon/drand/drand.go Outdated Show resolved Hide resolved
chain/beacon/drand/drand.go Show resolved Hide resolved
"https://api2.drand.sh",
"https://api3.drand.sh",
"https://drand.cloudflare.com",
"https://api.drand.secureweb3.com:6875", // Storswift
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this endpoint monitored by any of the drand monitoring infra? We were burned in the past by 3rd party bootstrappers going offline.

Choose a reason for hiding this comment

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

the endpoint, no, though we get some alerting if their node goes down (which is normally a good indicator).
The client uses all the addresses as fallback so it shouldn’t cause an outage though - what was the issue in the past?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The general issue in the past was that we had a significant number of third-party bootstrappers (let's say 70% of all), and the majority of them were down.

It didn't cause an outage per se, but it slowed down bootstraping.

@arajasek arajasek force-pushed the asr/fip-0063 branch 2 times, most recently from 06c5ad6 to 403887a Compare January 25, 2024 15:20
@arajasek
Copy link
Contributor Author

Rebased on top of DDO work that's landed.

@@ -16,7 +16,8 @@ import (
)

var DrandSchedule = map[abi.ChainEpoch]DrandEnum{
0: DrandMainnet,
0: DrandMainnet,
UpgradePineappleHeight + 10: DrandQuicknet,
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this a constant in the upgrade schedule with a new name?

Copy link
Member

Choose a reason for hiding this comment

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

I.e., pinapple height, then mango height?

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, certainly.

MaxBeaconRoundForEpoch(network.Version, abi.ChainEpoch) uint64
}

func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockHeader, parentEpoch abi.ChainEpoch,
prevEntry types.BeaconEntry) error {
{
// Before nv22 we had "chained" beacons, and so required two entries at a fork
if nv < network.Version22 {
Copy link
Contributor

Choose a reason for hiding this comment

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

If drand network upgrade does not align with chain network upgrade, should we check the exact drand network upgrade epoch here?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a fork logic which works off the DrandSchedule. So, the meaning of this is to disable the old fork logic before switching to the new Drand network.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hanabi1224 Thanks for the question! I don't think we need to check the exact epoch here -- as Kuba said, the intention is to say "before nv22, special-case fork logic this way". For the upcoming change to quicknet, we DON'T want to use the old fork logic, and instead just seamlessly switch to quicknet.

@@ -79,7 +80,12 @@ func ValidateBlockValues(bSchedule Schedule, nv network.Version, h *types.BlockH
return xerrors.Errorf("expected to have beacon entries in this block, but didn't find any")
}

// Verify that the last beacon entry's round corresponds to the round we expect
if nv < network.Version22 && prevEntry.Round == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto, should we decouple drand network version and chain network version here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to above, I don't think so, no. From nv22 onwards we'll be using "unchained" randomness, and so can simply verify round 0 too.

@arajasek arajasek merged commit 78edf46 into feat/nv22 Jan 29, 2024
89 of 90 checks passed
@arajasek arajasek deleted the asr/fip-0063 branch January 29, 2024 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

6 participants