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

eip-7251: New compute_consolidation_epoch_and_update_churn #13981

Merged

Conversation

prestonvanloon
Copy link
Member

What type of PR is this?

Feature

What does this PR do? Why is it needed?

Extracted from #13903.

This PR implements new spec method compute_consolidation_epoch_and_update_churn in electra.

Which issues(s) does this PR fix?

Tracking @ #13849

Other notes for review

https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.2/specs/electra/beacon-chain.md#new-compute_consolidation_epoch_and_update_churn

beacon-chain/core/electra/churn.go Outdated Show resolved Hide resolved
// Consolidation doesn't fit in the current earliest epoch.
if consolidationBalance > consolidationBalanceToConsume {
balanceToProcess := consolidationBalance - consolidationBalanceToConsume
// additional_epochs = (balance_to_process - 1) // per_epoch_consolidation_churn + 1
Copy link
Member

Choose a reason for hiding this comment

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

Do we intend to leave // additional_epochs = (balance_to_process - 1) // per_epoch_consolidation_churn + 1 here?

Copy link
Contributor

Choose a reason for hiding this comment

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

there's a ++ below

Copy link
Member

Choose a reason for hiding this comment

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

no, I meant the python comment in general

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I left the python code here because this line is a bit confusing where the division and addition are several lines apart.

Copy link
Contributor

@potuz potuz left a comment

Choose a reason for hiding this comment

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

My only comment is with regards to the spec, It smells to me that there's a function that explicitlyhas two separate concerns, there's the code logic to compute the consodation epoch and update the churn, I would have preferred two separate helpers for this. We could implement it this way internally.

beacon-chain/core/electra/churn.go Outdated Show resolved Hide resolved
}
additionalEpochs++
earliestConsolidationEpoch += primitives.Epoch(additionalEpochs)
consolidationBalanceToConsume += math.Gwei(additionalEpochs) * perEpochConsolidationChurn
Copy link
Contributor

Choose a reason for hiding this comment

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

Not from this PR but I find it funny that Gwei is defined in the math package.

beacon-chain/core/electra/churn.go Outdated Show resolved Hide resolved
tests for compute_consolidation_epoch_and_update_churn
@prestonvanloon prestonvanloon force-pushed the eip-7251-compute_consolidation_epoch_and_update_churn branch from e5d71cf to 9026515 Compare May 11, 2024 15:03
@prestonvanloon prestonvanloon added this pull request to the merge queue May 13, 2024
Merged via the queue into develop with commit e28b669 May 13, 2024
16 of 17 checks passed
@prestonvanloon prestonvanloon deleted the eip-7251-compute_consolidation_epoch_and_update_churn branch May 13, 2024 14:40
ErnestK pushed a commit to ErnestK/prysm that referenced this pull request May 19, 2024
…ysmaticlabs#13981)

tests for compute_consolidation_epoch_and_update_churn

Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
nisdas pushed a commit that referenced this pull request Jul 4, 2024
…3981)

tests for compute_consolidation_epoch_and_update_churn

Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
This pull request was closed.
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.

4 participants