-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: implement FIP-0063 #11572
Conversation
chain/beacon/drand/drand.go
Outdated
if curr.Round != prev.Round+1 { | ||
return xerrors.Errorf("invalid beacon entry: cur (%d) != prev (%d) + 1", curr.Round, prev.Round) | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
7ccaa9d
to
9e080ad
Compare
chain/beacon/beacon.go
Outdated
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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/beacon/beacon.go
Outdated
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 { |
There was a problem hiding this comment.
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?
chain/consensus/filcns/filecoin.go
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you:
- Link to an issue (creating one).
- Explain (somewhere) why?
"https://api2.drand.sh", | ||
"https://api3.drand.sh", | ||
"https://drand.cloudflare.com", | ||
"https://api.drand.secureweb3.com:6875", // Storswift |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
06c5ad6
to
403887a
Compare
Rebased on top of DDO work that's landed. |
build/params_butterfly.go
Outdated
@@ -16,7 +16,8 @@ import ( | |||
) | |||
|
|||
var DrandSchedule = map[abi.ChainEpoch]DrandEnum{ | |||
0: DrandMainnet, | |||
0: DrandMainnet, | |||
UpgradePineappleHeight + 10: DrandQuicknet, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
403887a
to
7613cdf
Compare
Related Issues
Implements FIP-0063.
Proposed Changes
VerifyEntry
to receive the previous entry's signature only, not theEntry
struct. This signature field is nil for Quicknet entries.Additional Info
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps