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

Add EIP-7251 spec: Increase MAX_EFFECTIVE_BALANCE #3618

Merged
merged 32 commits into from
Mar 28, 2024

Conversation

dapplion
Copy link
Collaborator

@dapplion dapplion commented Mar 8, 2024

Co-authored-by: fradamt <104826920+fradamt@users.noreply.github.com>
@dapplion dapplion changed the title Add EIP-7251 spec Add EIP-7251 spec: Increase MAX_EFFECTIVE_BALANCE Mar 11, 2024
@hwwhww hwwhww added the general:enhancement New feature or request label Mar 12, 2024
specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
@mkalinin
Copy link
Collaborator

mkalinin commented Mar 20, 2024

MIN_SLASHING_PENALTY_QUOTIENT_EIP7251 = 4096 rationale

With this value for the quotient the initial slashing penalty will be roughly equal to 3 days of base_reward (with 32M ETH of total active balance), i.e. it is roughly 3 days worth of attestation rewards. In absolute values it will be 0.5 ETH and 0.0078 ETH for 2048 and 32 ETH validators respectively. The main objective of this reduction is to alleviate additional risk that consolidated validators will have comparing to those that are not consolidated.

Whistleblower reward is also updated: WHISTLEBLOWER_REWARD_QUOTIENT_EIP7251 = 4096 which is 3 days worth of attestation rewards. This should still provide enough incentives to submit slashings and being capped at the MIN_SLASHING_PENALTY_QUOTIENT_EIP7251 will prevent new ETH minting when slashing is processed.

The script to compute a number of base rewards equal to a slashing penalty:

import math

BASE_REWARD_FACTOR = 64
EFFECTIVE_BALANCE_INCREMENT = 1_000_000_000
TOTAL_ACTIVE_BALANCE = 32 * 1_000_000 * EFFECTIVE_BALANCE_INCREMENT  # 32M ETH

MIN_SLASHING_PENALTY_QUOTIENT_EIP7251 = 2**12


def get_base_reward_per_increment():
    return EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR // math.floor(TOTAL_ACTIVE_BALANCE ** 0.5)


def get_base_reward(effective_balance: int):
    increments = effective_balance // EFFECTIVE_BALANCE_INCREMENT
    return increments * get_base_reward_per_increment()


def get_base_rewards_in_slashing_penalty(effective_balance: int):
		base_reward = get_base_reward(effective_balance)
		slashing_penalty = effective_balance // MIN_SLASHING_PENALTY_QUOTIENT_EIP7251
		return slashing_penalty // base_reward

if source_validator.withdrawable_epoch > get_current_epoch(state):
break

next_pending_consolidation += 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Only increment next_pending_consolidation after increase and decrease the balances so that it's more aligned with how next_deposit_index is incremented in process_pending_balance_deposits()

specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
##### Updated `get_expected_withdrawals`

```python
def get_expected_withdrawals(state: BeaconState) -> Tuple[Sequence[Withdrawal], uint64]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want to tag here too since function signature change is important

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what do you mean with "tag"?

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you mean with "tag"?

I mean like adding # [Modified in EIP7251] after the function signature to signal the return type has changed

specs/_features/eip7251/beacon-chain.md Outdated Show resolved Hide resolved
@dapplion
Copy link
Collaborator Author

dapplion commented Mar 22, 2024

@potuz I've added commit ebdb513 with queue_excess_active_balance on the fork transition. It queues all excess balance from early compounding credential adopters

@ethDreamer I've added 6d9ebe1 to switch the target consolidator into compounding credentials if the consolidation is sucessful

@dapplion
Copy link
Collaborator Author

is_aggregator changes

I have removed the is_aggregator changes. While balance-based aggregator selection is necessary for safety, it is only applicable for high regimes of consolidation. The current spec includes consolidation churn, which guarantees a maximum (slow) rate of adoption. We should leave is_aggregator changes out now to reduce complexity later and include them in the subsequent fork if the stakers choose to consolidation into very concentrated validators. Will publish a doc soon with full rationale and numbers to back it up

No p2p topic

This PR is missing a p2p doc on purpose. I believe we don't need a p2p topic to distribute consolidation objects:

Ethereum today relies on HTTP connections for two key actions:

  • most (if not all) syncings from a blank DB (checkpoint sync)
  • proposing +90% of blocks (with MEV-boost)

I don't think it would be a big ask to accept the distribution of consolidations via an off-protocol solution. Most big players can just self-include on their own proposals. There's no incentive to consolidate before or after than other actors. As long the network eventually consolidates. If the off-protocol message distribution service fails that's okay there's no loss of funds just longer inclusion times. Specially because consolidations are a temporary feature that's only useful during a transition. New stake can just deposit consolidated. Removing an HTTP API in 2 years is much simpler than removing p2p code.

@hwwhww
Copy link
Contributor

hwwhww commented Mar 25, 2024

IIRC @fradamt has a branch with new EIP-7251 test cases: michaelneuder#20

Can we add them to this PR now?

@rolfyone
Copy link
Contributor

How does the interplay with other withdrawal types go?
Concrete example,
I'm a genesis validator (not, but as an example) and i've accrued 6 eth of balance since genesis, because i've never switched to 0x01 withdrawal key..
After electra at some point, I finally get around to issuing a bls change, so now Im a validator with 38 odd eth and a 0x01 creds...
Does that mean that i get automatically switched to consolidated due to my more than one eth extra? Or would i have to specifically do a deposit?

add tests, fix small issues
@dapplion
Copy link
Collaborator Author

Does that mean that i get automatically switched to consolidated due to my more than one eth extra? Or would i have to specifically do a deposit?

No validator is automatically changed into consolidating credentials. The current paths to switch are:

  • (implemented): through a consolidation operation, change target validator to 0x02 credentials
  • (pending): through a top-up deposit that includes 0x02 credentials

@dapplion
Copy link
Collaborator Author

@hwwhww can we merge this as-is so contributors can PR fixes on ethereum/consensus-specs instead of my random fork?

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

@dapplion

I haven't reviewed it properly to merge it. Can @mkalinin @fradamt give some PR approvals here?

Copy link
Collaborator

@mkalinin mkalinin left a comment

Choose a reason for hiding this comment

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

Outstanding work everyone! I think it’s a time to merge this PR and continue polishing and fixing the logic in separate PRs as it becomes inconvenient to introduce new changes to the feature

balance = state.balances[index]
if balance > MAX_EFFECTIVE_BALANCE:
excess_balance = balance - MAX_EFFECTIVE_BALANCE
state.balances[index] = balance - excess_balance
Copy link
Contributor

Choose a reason for hiding this comment

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

feels clearer to just say:

state.balances[index] = MAX_EFFECTIVE_BALANCE

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
state.balances[index] = balance - excess_balance
state.balances[index] = MAX_EFFECTIVE_BALANCE

It feels confusing to use both MAX_EFFECTIVE_BALANCE and MAX_EFFECTIVE_BALANCE_EIP7251 in the same file. What do you think about adding a duplicate MAX_EFFECTIVE_BALANCE_PRE_EIP7251 := 32?

Copy link
Collaborator

@mkalinin mkalinin Mar 28, 2024

Choose a reason for hiding this comment

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

I agree with that, maybe MAX_EFFECTIVE_BALANCE_PHASE0? The other question: if we have this variable explicitly defined, can it replace MIN_ACTIVATION_BALANCE? Semantically these are two different things but practically having a single parameter slightly increases readability. So, I am slightly in favour of replacing MIN_ACTIVATION_BALANCE with MAX_EFFECTIVE_BALANCE_PHASE0

Copy link
Contributor

Choose a reason for hiding this comment

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

oh yeah using MIN_ACTIVATION_BALANCE looks better to me 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

So you suggest the opposite, to replace MAX_EFFECTIVE_BALANCE with MIN_ACTIVATION_BALANCE everywhere in the spec? I am fine with either, as long as we use the same param name in all places

Copy link
Contributor

Choose a reason for hiding this comment

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

If the two options are replacing MIN_ACTIVATION_BALANCE with MAX_EFFECTIVE_BALANCE_PHASE0 or replacing MAX_EFFECTIVE_BALANCE with MIN_ACTIVATION_BALANCE, I would prefer the latter, because MIN_ACTIVATION_BALANCE accurately represents what this parameter is in the current system

Copy link
Collaborator

Choose a reason for hiding this comment

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

because MIN_ACTIVATION_BALANCE accurately represents what this parameter is in the current system

Not in every case, it is also a max effective balance for 0x01 creds. And when we want to get MAXEB of a particular validator it makes more sense to use MAX_EFFECTIVE_BALANCE_PHASE) and *_EIP7251. But again, I am fine with either, just don’t want to have MAX_EB, MIN_AB and MAX_EB_EIP7251 in the spec as this is really confusing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For bumped constants in the past we have used:

INACTIVITY_PENALTY_QUOTIENT
INACTIVITY_PENALTY_QUOTIENT_ALTAIR
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX

Copy link
Contributor

@fradamt fradamt Mar 29, 2024

Choose a reason for hiding this comment

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

For bumped constants in the past we have used:

INACTIVITY_PENALTY_QUOTIENT
INACTIVITY_PENALTY_QUOTIENT_ALTAIR
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX

Given that MAX_EFFECTIVE_BALANCE (the phase 0 one) is a constant that we are still using, as opposed to INACTIVITY_PENALTY_QUOTIENT which was fully replaced, I think it makes sense to not follow this convention. I think following it would give the impression that MAX_EFFECTIVE_BALANCE_ELECTRA (or whatever it ends up being) replaces MAX_EFFECTIVE_BALANCE fully.

For this reason, I'd still lean towards using MIN_ACTIVATION_BALANCE only. While it is true that it is also used for the max effective balance of 0x00 and 0x01 credentials, this is similar to what happened in phase0 already, i.e., MAX_EFFECTIVE_BALANCE was used as the min activation balance as well.

Copy link
Contributor

@hwwhww hwwhww left a comment

Choose a reason for hiding this comment

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

I haven't reviewed it carefully, but I am going to merge it to accelerate the later iterations.

@hwwhww hwwhww merged commit e926d2e into ethereum:dev Mar 28, 2024
30 checks passed
@dapplion dapplion deleted the eip-7251 branch May 25, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general:enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants