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

Electra: full beacon config #13918

Merged
merged 3 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion beacon-chain/rpc/eth/config/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,20 @@ func TestGetSpec(t *testing.T) {
config.MaxWithdrawalsPerPayload = 74
config.MaxBlsToExecutionChanges = 75
config.MaxValidatorsPerWithdrawalsSweep = 76
config.MinSlashingPenaltyQuotientElectra = 77
config.MaxEffectiveBalanceElectra = 78
config.CompoundingWithdrawalPrefixByte = byte('d')
config.WhistleBlowerRewardQuotientElectra = 79
config.PendingPartialWithdrawalsLimit = 80
config.MinActivationBalance = 81
config.PendingBalanceDepositLimit = 82
config.MaxPendingPartialsPerWithdrawalSweep = 83
config.PendingConsolidationsLimit = 84
config.MaxPartialWithdrawalsPerPayload = 85
config.FullExitRequestAmount = 86
config.MaxConsolidations = 87
config.MaxAttesterSlashingsElectra = 88
config.MaxAttestationsElectra = 89

var dbp [4]byte
copy(dbp[:], []byte{'0', '0', '0', '1'})
Expand All @@ -158,6 +172,9 @@ func TestGetSpec(t *testing.T) {
var dam [4]byte
copy(dam[:], []byte{'1', '0', '0', '0'})
config.DomainApplicationMask = dam
var dc [4]byte
copy(dc[:], []byte{'1', '1', '0', '0'})
config.DomainConsolidation = dc
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed the spec value is 0x0B000000, so the first 2 bytes being 1 stuck out as wrong. I think this should be []byte[11, 0, 0, 0]: https://go.dev/play/p/fkwg-mzX8Zb

Copy link
Member Author

Choose a reason for hiding this comment

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

These are dummy values. This whole test sucks


params.OverrideBeaconConfig(config)

Expand All @@ -172,7 +189,7 @@ func TestGetSpec(t *testing.T) {
data, ok := resp.Data.(map[string]interface{})
require.Equal(t, true, ok)

assert.Equal(t, 136, len(data))
assert.Equal(t, 151, len(data))
for k, v := range data {
t.Run(k, func(t *testing.T) {
switch k {
Expand Down Expand Up @@ -471,6 +488,36 @@ func TestGetSpec(t *testing.T) {
assert.Equal(t, "32", v)
case "MAX_REQUEST_DATA_COLUMN_SIDECARS":
assert.Equal(t, "16384", v)
case "MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA":
assert.Equal(t, "77", v)
case "MAX_EFFECTIVE_BALANCE_ELECTRA":
assert.Equal(t, "78", v)
case "COMPOUNDING_WITHDRAWAL_PREFIX":
assert.Equal(t, "0x64", v)
case "WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA":
assert.Equal(t, "79", v)
case "PENDING_PARTIAL_WITHDRAWALS_LIMIT":
assert.Equal(t, "80", v)
case "MIN_ACTIVATION_BALANCE":
assert.Equal(t, "81", v)
case "PENDING_BALANCE_DEPOSIT_LIMIT":
assert.Equal(t, "82", v)
case "MAX_PENDING_PARTIALS_PER_WITHDRAWAL_SWEEP":
assert.Equal(t, "83", v)
case "PENDING_CONSOLIDATIONS_LIMIT":
assert.Equal(t, "84", v)
case "MAX_PARTIAL_WITHDRAWALS_PER_PAYLOAD":
assert.Equal(t, "85", v)
case "FULL_EXIT_REQUEST_AMOUNT":
assert.Equal(t, "86", v)
case "MAX_CONSOLIDATIONS":
assert.Equal(t, "87", v)
case "DOMAIN_CONSOLIDATION":
assert.Equal(t, "0x31313030", v)
case "MAX_ATTESTER_SLASHINGS_ELECTRA":
assert.Equal(t, "88", v)
case "MAX_ATTESTATIONS_ELECTRA":
assert.Equal(t, "89", v)
default:
t.Errorf("Incorrect key: %s", k)
}
Expand Down
5 changes: 5 additions & 0 deletions config/fieldparams/mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ const (
BlobSize = 131072 // defined to match blob.size in bazel ssz codegen
KzgCommitmentInclusionProofDepth = 17 // Merkle proof depth for blob_kzg_commitments list item
NextSyncCommitteeBranchDepth = 5 // NextSyncCommitteeBranchDepth defines the depth of the next sync committee branch.
PendingBalanceDepositsLimit = 134217728 // Maximum number of pending balance deposits in the beacon state.
PendingPartialWithdrawalsLimit = 134217728 // Maximum number of pending partial withdrawals in the beacon state.
PendingConsolidationsLimit = 262144 // Maximum number of pending consolidations in the beacon state.
MaxDepositReceiptsPerPayload = 8192 // Maximum number of deposit receipts in an execution payload.
MaxWithdrawalRequestsPerPayload = 16 // Maximum number of execution layer withdrawal requests in an execution payload.
)
5 changes: 5 additions & 0 deletions config/fieldparams/minimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ const (
BlobSize = 131072 // defined to match blob.size in bazel ssz codegen
KzgCommitmentInclusionProofDepth = 17 // Merkle proof depth for blob_kzg_commitments list item
NextSyncCommitteeBranchDepth = 5 // NextSyncCommitteeBranchDepth defines the depth of the next sync committee branch.
PendingBalanceDepositsLimit = 134217728 // Maximum number of pending balance deposits in the beacon state.
PendingPartialWithdrawalsLimit = 64 // Maximum number of pending partial withdrawals in the beacon state.
PendingConsolidationsLimit = 64 // Maximum number of pending consolidations in the beacon state.
MaxDepositReceiptsPerPayload = 4 // Maximum number of deposit receipts in an execution payload.
MaxWithdrawalRequestsPerPayload = 2 // Maximum number of execution layer withdrawal requests in an execution payload.
)
40 changes: 29 additions & 11 deletions config/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,15 @@ type BeaconChainConfig struct {

// Gwei value constants.
MinDepositAmount uint64 `yaml:"MIN_DEPOSIT_AMOUNT" spec:"true"` // MinDepositAmount is the minimum amount of Gwei a validator can send to the deposit contract at once (lower amounts will be reverted).
MinActivationBalance uint64 `yaml:"MIN_ACTIVATION_BALANCE" spec:"true"` // MinActivationBalance is the minimum amount of Gwei a validator must have to be activated in the beacon state.
MaxEffectiveBalance uint64 `yaml:"MAX_EFFECTIVE_BALANCE" spec:"true"` // MaxEffectiveBalance is the maximal amount of Gwei that is effective for staking.
EjectionBalance uint64 `yaml:"EJECTION_BALANCE" spec:"true"` // EjectionBalance is the minimal GWei a validator needs to have before ejected.
EffectiveBalanceIncrement uint64 `yaml:"EFFECTIVE_BALANCE_INCREMENT" spec:"true"` // EffectiveBalanceIncrement is used for converting the high balance into the low balance for validators.

// Initial value constants.
BLSWithdrawalPrefixByte byte `yaml:"BLS_WITHDRAWAL_PREFIX" spec:"true"` // BLSWithdrawalPrefixByte is used for BLS withdrawal and it's the first byte.
ETH1AddressWithdrawalPrefixByte byte `yaml:"ETH1_ADDRESS_WITHDRAWAL_PREFIX" spec:"true"` // ETH1AddressWithdrawalPrefixByte is used for withdrawals and it's the first byte.
CompoundingWithdrawalPrefixByte byte `yaml:"COMPOUNDING_WITHDRAWAL_PREFIX" spec:"true"` // CompoundingWithdrawalPrefixByteByte is used for compounding withdrawals and it's the first byte.
ZeroHash [32]byte // ZeroHash is used to represent a zeroed out 32 byte array.

// Time parameters constants.
Expand Down Expand Up @@ -97,12 +99,15 @@ type BeaconChainConfig struct {
ProportionalSlashingMultiplier uint64 `yaml:"PROPORTIONAL_SLASHING_MULTIPLIER" spec:"true"` // ProportionalSlashingMultiplier is used as a multiplier on slashed penalties.

// Max operations per block constants.
MaxProposerSlashings uint64 `yaml:"MAX_PROPOSER_SLASHINGS" spec:"true"` // MaxProposerSlashings defines the maximum number of slashings of proposers possible in a block.
MaxAttesterSlashings uint64 `yaml:"MAX_ATTESTER_SLASHINGS" spec:"true"` // MaxAttesterSlashings defines the maximum number of casper FFG slashings possible in a block.
MaxAttestations uint64 `yaml:"MAX_ATTESTATIONS" spec:"true"` // MaxAttestations defines the maximum allowed attestations in a beacon block.
MaxDeposits uint64 `yaml:"MAX_DEPOSITS" spec:"true"` // MaxDeposits defines the maximum number of validator deposits in a block.
MaxVoluntaryExits uint64 `yaml:"MAX_VOLUNTARY_EXITS" spec:"true"` // MaxVoluntaryExits defines the maximum number of validator exits in a block.
MaxWithdrawalsPerPayload uint64 `yaml:"MAX_WITHDRAWALS_PER_PAYLOAD" spec:"true"` // MaxWithdrawalsPerPayload defines the maximum number of withdrawals in a block.
MaxProposerSlashings uint64 `yaml:"MAX_PROPOSER_SLASHINGS" spec:"true"` // MaxProposerSlashings defines the maximum number of slashings of proposers possible in a block.
MaxAttesterSlashings uint64 `yaml:"MAX_ATTESTER_SLASHINGS" spec:"true"` // MaxAttesterSlashings defines the maximum number of casper FFG slashings possible in a block.
MaxAttesterSlashingsElectra uint64 `yaml:"MAX_ATTESTER_SLASHINGS_ELECTRA" spec:"true"` // MaxAttesterSlashingsElectra defines the maximum number of casper FFG slashings possible in a block post Electra hard fork.
MaxAttestations uint64 `yaml:"MAX_ATTESTATIONS" spec:"true"` // MaxAttestations defines the maximum allowed attestations in a beacon block.
MaxAttestationsElectra uint64 `yaml:"MAX_ATTESTATIONS_ELECTRA" spec:"true"` // MaxAttestationsElectra defines the maximum allowed attestations in a beacon block post Electra hard fork.
MaxDeposits uint64 `yaml:"MAX_DEPOSITS" spec:"true"` // MaxDeposits defines the maximum number of validator deposits in a block.
MaxVoluntaryExits uint64 `yaml:"MAX_VOLUNTARY_EXITS" spec:"true"` // MaxVoluntaryExits defines the maximum number of validator exits in a block.
MaxWithdrawalsPerPayload uint64 `yaml:"MAX_WITHDRAWALS_PER_PAYLOAD" spec:"true"` // MaxWithdrawalsPerPayload defines the maximum number of withdrawals in a block.
MaxPartialWithdrawalsPerPayload uint64 `yaml:"MAX_PARTIAL_WITHDRAWALS_PER_PAYLOAD" spec:"true"`
MaxBlsToExecutionChanges uint64 `yaml:"MAX_BLS_TO_EXECUTION_CHANGES" spec:"true"` // MaxBlsToExecutionChanges defines the maximum number of BLS-to-execution-change objects in a block.
MaxValidatorsPerWithdrawalsSweep uint64 `yaml:"MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP" spec:"true"` // MaxValidatorsPerWithdrawalsSweep bounds the size of the sweep searching for withdrawals per slot.

Expand All @@ -120,6 +125,7 @@ type BeaconChainConfig struct {
DomainApplicationMask [4]byte `yaml:"DOMAIN_APPLICATION_MASK" spec:"true"` // DomainApplicationMask defines the BLS signature domain for application mask.
DomainApplicationBuilder [4]byte `yaml:"DOMAIN_APPLICATION_BUILDER" spec:"true"` // DomainApplicationBuilder defines the BLS signature domain for application builder.
DomainBLSToExecutionChange [4]byte `yaml:"DOMAIN_BLS_TO_EXECUTION_CHANGE" spec:"true"` // DomainBLSToExecutionChange defines the BLS signature domain to change withdrawal addresses to ETH1 prefix
DomainConsolidation [4]byte `yaml:"DOMAIN_CONSOLIDATION" spec:"true"`

// Prysm constants.
GweiPerEth uint64 // GweiPerEth is the amount of gwei corresponding to 1 eth.
Expand All @@ -139,6 +145,7 @@ type BeaconChainConfig struct {
BeaconStateBellatrixFieldCount int // BeaconStateBellatrixFieldCount defines how many fields are in beacon state post upgrade to Bellatrix.
BeaconStateCapellaFieldCount int // BeaconStateCapellaFieldCount defines how many fields are in beacon state post upgrade to Capella.
BeaconStateDenebFieldCount int // BeaconStateDenebFieldCount defines how many fields are in beacon state post upgrade to Deneb.
BeaconStateElectraFieldCount int // BeaconStateElectraFieldCount defines how many fields are in beacon state post upgrade to Electra.

// Slasher constants.
WeakSubjectivityPeriod primitives.Epoch // WeakSubjectivityPeriod defines the time period expressed in number of epochs were proof of stake network should validate block headers and attestations for slashable events.
Expand Down Expand Up @@ -229,11 +236,19 @@ type BeaconChainConfig struct {
MaxRequestBlocksDeneb uint64 `yaml:"MAX_REQUEST_BLOCKS_DENEB" spec:"true"` // MaxRequestBlocksDeneb is the maximum number of blocks in a single request after the deneb epoch.

// Values introduce in Electra upgrade
NumberOfColumns uint64 `yaml:"NUMBER_OF_COLUMNS" spec:"true"` // NumberOfColumns in the extended data matrix.
DataColumnSidecarSubnetCount uint64 `yaml:"DATA_COLUMN_SIDECAR_SUBNET_COUNT" spec:"true"` // DataColumnSidecarSubnetCount is the number of data column sidecar subnets used in the gossipsub protocol
MaxPerEpochActivationExitChurnLimit uint64 `yaml:"MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT" spec:"true"` // MaxPerEpochActivationExitChurnLimit represents the maximum combined activation and exit churn.
MinPerEpochChurnLimitElectra uint64 `yaml:"MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA" spec:"true"` // MinPerEpochChurnLimitElectra is the minimum amount of churn allotted for validator rotations for electra.
MaxRequestDataColumnSidecars uint64 `yaml:"MAX_REQUEST_DATA_COLUMN_SIDECARS" spec:"true"` // MaxRequestDataColumnSidecars is the maximum number of data column sidecars in a single request
DataColumnSidecarSubnetCount uint64 `yaml:"DATA_COLUMN_SIDECAR_SUBNET_COUNT" spec:"true"` // DataColumnSidecarSubnetCount is the number of data column sidecar subnets used in the gossipsub protocol
MaxPerEpochActivationExitChurnLimit uint64 `yaml:"MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT" spec:"true"` // MaxPerEpochActivationExitChurnLimit represents the maximum combined activation and exit churn.
MinPerEpochChurnLimitElectra uint64 `yaml:"MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA" spec:"true"` // MinPerEpochChurnLimitElectra is the minimum amount of churn allotted for validator rotations for electra.
MaxRequestDataColumnSidecars uint64 `yaml:"MAX_REQUEST_DATA_COLUMN_SIDECARS" spec:"true"` // MaxRequestDataColumnSidecars is the maximum number of data column sidecars in a single request
MaxEffectiveBalanceElectra uint64 `yaml:"MAX_EFFECTIVE_BALANCE_ELECTRA" spec:"true"` // MaxEffectiveBalanceElectra is the maximal amount of Gwei that is effective for staking, increased in electra.
MinSlashingPenaltyQuotientElectra uint64 `yaml:"MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA" spec:"true"` // MinSlashingPenaltyQuotientElectra is used to calculate the minimum penalty to prevent DoS attacks, modified for electra.
WhistleBlowerRewardQuotientElectra uint64 `yaml:"WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA" spec:"true"` // WhistleBlowerRewardQuotientElectra is used to calculate whistle blower reward, modified in electra.
PendingBalanceDepositLimit uint64 `yaml:"PENDING_BALANCE_DEPOSIT_LIMIT" spec:"true"` // PendingBalanceDepositLimit is the maximum number of pending balance deposits allowed in the beacon state.
PendingPartialWithdrawalsLimit uint64 `yaml:"PENDING_PARTIAL_WITHDRAWALS_LIMIT" spec:"true"` // PendingPartialWithdrawalsLimit is the maximum number of pending partial withdrawals allowed in the beacon state.
PendingConsolidationsLimit uint64 `yaml:"PENDING_CONSOLIDATIONS_LIMIT" spec:"true"` // PendingConsolidationsLimit is the maximum number of pending validator consolidations allowed in the beacon state.
MaxConsolidations uint64 `yaml:"MAX_CONSOLIDATIONS" spec:"true"` // MaxConsolidations is the maximum number of consolidations in a block.
MaxPendingPartialsPerWithdrawalSweep uint64 `yaml:"MAX_PENDING_PARTIALS_PER_WITHDRAWAL_SWEEP" spec:"true"` // MaxPendingPartialsPerWithdrawalSweep is the maximum number of pending partial withdrawals to process per payload.
FullExitRequestAmount uint64 `yaml:"FULL_EXIT_REQUEST_AMOUNT" spec:"true"` // FullExitRequestAmount is the amount of Gwei required to request a full exit.

// Networking Specific Parameters
GossipMaxSize uint64 `yaml:"GOSSIP_MAX_SIZE" spec:"true"` // GossipMaxSize is the maximum allowed size of uncompressed gossip messages.
Expand All @@ -252,6 +267,9 @@ type BeaconChainConfig struct {
AttestationSubnetPrefixBits uint64 `yaml:"ATTESTATION_SUBNET_PREFIX_BITS" spec:"true"` // AttestationSubnetPrefixBits is defined as (ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS).
SubnetsPerNode uint64 `yaml:"SUBNETS_PER_NODE" spec:"true"` // SubnetsPerNode is the number of long-lived subnets a beacon node should be subscribed to.
NodeIdBits uint64 `yaml:"NODE_ID_BITS" spec:"true"` // NodeIdBits defines the bit length of a node id.

// PeerDAS
NumberOfColumns uint64 `yaml:"NUMBER_OF_COLUMNS" spec:"true"` // NumberOfColumns in the extended data matrix.
}

// InitializeForkSchedule initializes the schedules forks baked into the config.
Expand Down
22 changes: 19 additions & 3 deletions config/params/mainnet_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ var mainnetBeaconConfig = &BeaconChainConfig{
// Initial value constants.
BLSWithdrawalPrefixByte: byte(0),
ETH1AddressWithdrawalPrefixByte: byte(1),
CompoundingWithdrawalPrefixByte: byte(2),
ZeroHash: [32]byte{},

// Time parameter constants.
Expand Down Expand Up @@ -147,7 +148,9 @@ var mainnetBeaconConfig = &BeaconChainConfig{
// Max operations per block constants.
MaxProposerSlashings: 16,
MaxAttesterSlashings: 2,
MaxAttesterSlashingsElectra: 1,
MaxAttestations: 128,
MaxAttestationsElectra: 8,
MaxDeposits: 16,
MaxVoluntaryExits: 16,
MaxWithdrawalsPerPayload: 16,
Expand All @@ -168,6 +171,7 @@ var mainnetBeaconConfig = &BeaconChainConfig{
DomainApplicationMask: bytesutil.Uint32ToBytes4(0x00000001),
DomainApplicationBuilder: bytesutil.Uint32ToBytes4(0x00000001),
DomainBLSToExecutionChange: bytesutil.Uint32ToBytes4(0x0A000000),
DomainConsolidation: bytesutil.Uint32ToBytes4(0x0B000000),

// Prysm constants.
GweiPerEth: 1000000000,
Expand All @@ -189,6 +193,7 @@ var mainnetBeaconConfig = &BeaconChainConfig{
BeaconStateBellatrixFieldCount: 25,
BeaconStateCapellaFieldCount: 28,
BeaconStateDenebFieldCount: 28,
BeaconStateElectraFieldCount: 37,

// Slasher related values.
WeakSubjectivityPeriod: 54000,
Expand Down Expand Up @@ -270,11 +275,19 @@ var mainnetBeaconConfig = &BeaconChainConfig{
MaxRequestBlocksDeneb: 128,

// Values related to electra
NumberOfColumns: 128,
MaxRequestDataColumnSidecars: 16384,
DataColumnSidecarSubnetCount: 32,
MinPerEpochChurnLimitElectra: 128000000000,
MaxPerEpochActivationExitChurnLimit: 256000000000,
MinPerEpochChurnLimitElectra: 128_000_000_000,
MaxPerEpochActivationExitChurnLimit: 256_000_000_000,
MaxEffectiveBalanceElectra: 2048_000_000_000,
MinSlashingPenaltyQuotientElectra: 4096,
WhistleBlowerRewardQuotientElectra: 4096,
PendingBalanceDepositLimit: 134_217_728,
PendingPartialWithdrawalsLimit: 134_217_728,
PendingConsolidationsLimit: 262_144,
MinActivationBalance: 32_000_000_000,
MaxConsolidations: 1,
FullExitRequestAmount: 0,

// Values related to networking parameters.
GossipMaxSize: 10 * 1 << 20, // 10 MiB
Expand All @@ -293,6 +306,9 @@ var mainnetBeaconConfig = &BeaconChainConfig{
AttestationSubnetPrefixBits: 6,
SubnetsPerNode: 2,
NodeIdBits: 256,

// PeerDAS
NumberOfColumns: 128,
}

// MainnetTestConfig provides a version of the mainnet config that has a different name
Expand Down
4 changes: 3 additions & 1 deletion config/params/minimal_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ func MinimalSpecConfig() *BeaconChainConfig {
// Max operations per block
minimalConfig.MaxProposerSlashings = 16
minimalConfig.MaxAttesterSlashings = 2
minimalConfig.MaxAttesterSlashingsElectra = 1
minimalConfig.MaxAttestations = 128
minimalConfig.MaxAttestationsElectra = 8
minimalConfig.MaxDeposits = 16
minimalConfig.MaxVoluntaryExits = 16
minimalConfig.MaxWithdrawalsPerPayload = 4
Expand Down Expand Up @@ -92,7 +94,7 @@ func MinimalSpecConfig() *BeaconChainConfig {
minimalConfig.DenebForkVersion = []byte{4, 0, 0, 1}
minimalConfig.DenebForkEpoch = math.MaxUint64
minimalConfig.ElectraForkVersion = []byte{5, 0, 0, 1}
minimalConfig.AltairForkEpoch = math.MaxUint64
minimalConfig.ElectraForkEpoch = math.MaxUint64

minimalConfig.SyncCommitteeSize = 32
minimalConfig.InactivityScoreBias = 4
Expand Down
Loading