Skip to content

Berachain Bectra Annotations - #1

Open
rezzmah wants to merge 19 commits into
devfrom
bectra
Open

Berachain Bectra Annotations#1
rezzmah wants to merge 19 commits into
devfrom
bectra

Conversation

@rezzmah

@rezzmah rezzmah commented Apr 8, 2025

Copy link
Copy Markdown

The PR annotates the pectra specification with the relevant changes for Berachain.

@rezzmah
rezzmah marked this pull request as ready for review April 14, 2025 22:47

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

would probably note that this is for the first Electra hardfork on berachain (electra0 / "0x05000000"). We may activate 6110 or parts of 7691 in future Electra hardforks on berachain mainnet (electra1, etc.)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

| `WITHDRAWAL_REQUEST_TYPE` | `Bytes1('0x01')` |
| `CONSOLIDATION_REQUEST_TYPE` | `Bytes1('0x02')` |

@BERA: We introduce all of these fields, however, the Consensus Layer will only process `WITHDRAWAL_REQUEST_TYPE`. This means that if a user attempts to submit a `CONSOLIDATION_REQUEST_TYPE` or `DEPOSIT_REQUEST_TYPE`, they should expect to see no change to the system. However, their transaction will still be accepted on the execution layer.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

would note that DEPOSIT_REQUEST_TYPE EL requests should not occur on Berachain as the unforked EL clients should not find Deposit Contract events to form as CL requests. (because the event signature in Berachain's deposit contract is different)

| `MIN_ACTIVATION_BALANCE` | `Gwei(2**5 * 10**9)` (= 32,000,000,000) | *[New in Electra:EIP7251]* Minimum balance for a validator to become active |
| `MAX_EFFECTIVE_BALANCE_ELECTRA` | `Gwei(2**11 * 10**9)` (= 2048,000,000,000) | *[New in Electra:EIP7251]* Maximum effective balance for a compounding validator |

@BERA: In Berachain, `MIN_ACTIVATION_BALANCE` will be set to reflected as 250K Bera and `MAX_EFFECTIVE_BALANCE_ELECTRA` will be reflected as 10_000_000 BERA.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

How will this play out with our already EjectionBalance? Asking this because we actually set our EjectionBalance on mainnet to 240k BERA. And then we handle that in processing the val set updates by adding back the 10k BERA increment here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment thread specs/electra/beacon-chain.md Outdated
return withdrawals, processed_partial_withdrawals_count
```

@BERA: We need to extend our implementation to handle `pending_partial_withdrawals`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should we explain how we are using this list here?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

or is it exact same as in spec?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I don't see any reason to deviate from spec here

| ------------------------------- | ---------------- | ----------------------------------------------------------------------------------- |
| `COMPOUNDING_WITHDRAWAL_PREFIX` | `Bytes1('0x02')` | *[New in Electra:EIP7251]* Withdrawal credential prefix for a compounding validator |

@BERA: In Ethereum, compounding validators are those can have a balance higher than 32 ETH, introduced as part of EIP-7251. In Berachain, all validators are considered 'compounding validators' as they can all have a balance above 250k BERA. As such, we skip distinguishing between compounding and non-compounding validators.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

withdrawable_epoch: Epoch
```

@BERA: Must be introduced to support the withdrawals logic.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

index: uint64
```

@BERA: Introduced for parity in ExecutionRequestsRoot calculation but unused.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment on lines +317 to +318
@BERA: Introduced for parity in ExecutionRequestsRoot calculation but unused.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

execution_requests: ExecutionRequests # [New in Electra]
```

@BERA: We extend the beacon block body with `execution_requests`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

earliest_consolidation_epoch: Epoch # [New in Electra:EIP7251] @BERA: Unused
pending_deposits: List[PendingDeposit, PENDING_DEPOSITS_LIMIT] # [New in Electra:EIP7251] @BERA: Unused
# [New in Electra:EIP7251]
pending_partial_withdrawals: List[PendingPartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

)
```

@BERA: Effectively already implemented as we have `v.EffectiveBalance >= threshold`, where `threshold` is equivalent to `MIN_ACTIVATION_BALANCE`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

return is_compounding_withdrawal_credential(validator.withdrawal_credentials)
```

@BERA: `has_compounding_withdrawal_credential` but always returns true. See reasoning in `is_compounding_withdrawal_credential`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment on lines +540 to +546
@BERA: Berachain only supports 0x01 credentials, so all validators should have this return true. We modify the implementation as below since `has_compounding_withdrawal_credential` will always returns true:

```go
func (v Validator) HasExecutionWithdrawalCredential() bool {
return v.HasEth1WithdrawalCredentials()
}
```

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

)
```

@BERA: We do not need to deviate from this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

return MIN_ACTIVATION_BALANCE
```

@BERA: This will always return 10_000_000 million on Berachain.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

)
```

@BERA: Introduced and used in `process_withdrawal_request`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

validator.SetExitEpoch(exitQueueEpoch)
validator.SetWithdrawableEpoch(withdrawableEpoch)
```

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We continue to ignore this case as there is not forseeable way for a validator's balance to fall below the EJECTION_BALANCE balance, without it directly initiating a validator exit.

For example, post-electra, if a Partial Withdrawal Request is made, the balance must remain above `MIN_ACTIVATION_BALANCE`. A Full Withdrawal Request will remove the entire balance and initiate a validator

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

execution_requests: ExecutionRequests # [New in Electra]
```

@BERA: Implemented.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

...
```

@BERA: Implemented.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

...
```

@BERA: Implemented.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment on lines +1222 to +1227
@BERA: We modify:

- `process_withdrawals` - Update pending partial withdrawals
- `process_execution_payload` - Implemented.
- `process_operations` - Call `process_withdrawal_request` in `process_operations`

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

```

@BERA: We need to extend our implementation to handle `pending_partial_withdrawals`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

state.next_withdrawal_validator_index = next_validator_index
```

@BERA: We adopt the change around `processed_partial_withdrawals_count`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

]
```

@BERA: Implemented.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

)
```

@BERA: Implemented.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Implicitly passed as part of the beacon block

return validator
```

@BERA: In Berachain, the implementation can be found in `NewValidatorFromDeposit`. No change is required.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

1. `initiate_validator_exit` does not rely on churn.
2. `has_compounding_withdrawal_credential` will always be true.
3. Partial withdrawals will not rely on churn to calculate the exit and withdrawable epochs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Comment thread specs/electra/fork.md
return post
```

@BERA: We need to update the BeaconState fork version and set `pending_partial_withdrawals=[]`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

2 participants