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

Configure chain quality grace period for berkeley release #14776

Merged
merged 6 commits into from
Jan 11, 2024

Conversation

nholland94
Copy link
Member

@nholland94 nholland94 commented Jan 2, 2024

This PR configures berkeley's grace period to 4.5 days, and ensures that the grace period works in hard forks.

The original code was hard coding the grace period in terms of a number of days, which would make the grace period unsafe under some network configurations. I exposed the grace period constant as a configuration in terms of slots, and ensured that the grace period end is accounting for enough slots in order to have a fresh sub window samples of the chain density. I also assert that the specified grace period is safe.

I also fixed a bug in the grace period logic where we weren't accounting for hard forks correctly. We were comparing the global slot since hard fork against a global slot since genesis when testing for the grace period. I fixed this and improved the types to add clarity.

I've confirmed the behavior manually by running a local network with 1/3rd of the stake online. The grace period end was computed as expected and the density only dropped after it was expected to.

@nholland94
Copy link
Member Author

!ci-build-me

@nholland94 nholland94 marked this pull request as ready for review January 3, 2024 23:27
@nholland94 nholland94 requested a review from a team as a code owner January 3, 2024 23:27
@nholland94
Copy link
Member Author

!ci-build-me

@nholland94
Copy link
Member Author

!ci-build-me

@nholland94 nholland94 changed the title Increase chain quality grace period to 4.5 days Configure chain quality grace period for berkeley release Jan 4, 2024
@nholland94
Copy link
Member Author

!ci-build-me

@nholland94 nholland94 requested a review from a team as a code owner January 5, 2024 19:23
@nholland94
Copy link
Member Author

!ci-build-me

@nholland94 nholland94 force-pushed the feature/increase-chain-quality-grace-period branch from 39365f0 to c28f5b2 Compare January 10, 2024 19:23
@nholland94
Copy link
Member Author

!ci-build-me

@nholland94 nholland94 merged commit 57bafab into berkeley Jan 11, 2024
39 of 41 checks passed
@nholland94 nholland94 deleted the feature/increase-chain-quality-grace-period branch January 11, 2024 16:14
@sebastiencs
Copy link
Contributor

@nholland94 That new grace_period_slots is ignored in Protocol_constants_checked.to_input, is that expected ?

If 2 Protocol_state.Body have a different value of grace_period_slots, they will still get the same hash (when calling Protocol_state.Body.hash)

let to_input (t : value) =
Array.reduce_exn ~f:Random_oracle.Input.Chunked.append
[| T.to_input t.k
; T.to_input t.delta
; T.to_input t.slots_per_epoch
; T.to_input t.slots_per_sub_window
; Block_time.to_input t.genesis_state_timestamp
|]

@nholland94
Copy link
Member Author

@sebastiencs That's a mistake, thanks for catching it! The to_input function should be destructuring it's input in order to avoid these kind of bugs. I'll put in a fix soon.

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.

None yet

3 participants