Add deneb config/params from deneb-integration (#12783)

Co-authored-by: Terence Tsao <terence@prysmaticlabs.com>
Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
Preston Van Loon
2023-08-23 15:07:25 -05:00
committed by GitHub
parent f0d54254ed
commit 5433502055
12 changed files with 70 additions and 11 deletions

View File

@@ -51,6 +51,8 @@ func TestGetSpec(t *testing.T) {
config.BellatrixForkEpoch = 101
config.CapellaForkVersion = []byte("CapellaForkVersion")
config.CapellaForkEpoch = 103
config.DenebForkVersion = []byte("DenebForkVersion")
config.DenebForkEpoch = 105
config.BLSWithdrawalPrefixByte = byte('b')
config.ETH1AddressWithdrawalPrefixByte = byte('c')
config.GenesisDelay = 24
@@ -129,6 +131,9 @@ func TestGetSpec(t *testing.T) {
var dam [4]byte
copy(dam[:], []byte{'1', '0', '0', '0'})
config.DomainApplicationMask = dam
var dbs [4]byte
copy(dam[:], []byte{'2', '0', '0', '0'})
config.DomainBlobSidecar = dbs
params.OverrideBeaconConfig(config)
@@ -136,7 +141,7 @@ func TestGetSpec(t *testing.T) {
resp, err := server.GetSpec(context.Background(), &emptypb.Empty{})
require.NoError(t, err)
assert.Equal(t, 108, len(resp.Data))
assert.Equal(t, 111, len(resp.Data))
for k, v := range resp.Data {
switch k {
case "CONFIG_NAME":
@@ -205,6 +210,10 @@ func TestGetSpec(t *testing.T) {
assert.Equal(t, "0x"+hex.EncodeToString([]byte("CapellaForkVersion")), v)
case "CAPELLA_FORK_EPOCH":
assert.Equal(t, "103", v)
case "DENEB_FORK_VERSION":
assert.Equal(t, "0x"+hex.EncodeToString([]byte("DenebForkVersion")), v)
case "DENEB_FORK_EPOCH":
assert.Equal(t, "105", v)
case "MIN_ANCHOR_POW_BLOCK_DIFFICULTY":
assert.Equal(t, "1000", v)
case "BLS_WITHDRAWAL_PREFIX":
@@ -269,6 +278,8 @@ func TestGetSpec(t *testing.T) {
assert.Equal(t, "51", v)
case "MAX_VOLUNTARY_EXITS":
assert.Equal(t, "52", v)
case "MAX_BLOBS_PER_BLOCK":
assert.Equal(t, "4", v)
case "TIMELY_HEAD_FLAG_INDEX":
assert.Equal(t, "0x35", v)
case "TIMELY_SOURCE_FLAG_INDEX":
@@ -335,6 +346,8 @@ func TestGetSpec(t *testing.T) {
assert.Equal(t, "0x0a000000", v)
case "DOMAIN_APPLICATION_BUILDER":
assert.Equal(t, "0x00000001", v)
case "DOMAIN_BLOB_SIDECAR":
assert.Equal(t, "0x00000000", v)
case "TRANSITION_TOTAL_DIFFICULTY":
assert.Equal(t, "0", v)
case "TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH":

View File

@@ -28,6 +28,7 @@ go_library(
"//consensus-types/primitives:go_default_library",
"//encoding/bytesutil:go_default_library",
"//math:go_default_library",
"//runtime/version:go_default_library",
"@com_github_ethereum_go_ethereum//common:go_default_library",
"@com_github_ethereum_go_ethereum//params:go_default_library",
"@com_github_mohae_deepcopy//:go_default_library",

View File

@@ -8,6 +8,7 @@ import (
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
"github.com/prysmaticlabs/prysm/v4/encoding/bytesutil"
"github.com/prysmaticlabs/prysm/v4/runtime/version"
)
// BeaconChainConfig contains constant configs for node to participate in beacon chain.
@@ -104,7 +105,7 @@ type BeaconChainConfig struct {
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.
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.
MaxValidatorsPerWithdrawalsSweep uint64 `yaml:"MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP" spec:"true"` // MaxValidatorsPerWithdrawalsSweep bounds the size of the sweep searching for withdrawals per slot.
// BLS domain values.
DomainBeaconProposer [4]byte `yaml:"DOMAIN_BEACON_PROPOSER" spec:"true"` // DomainBeaconProposer defines the BLS signature domain for beacon proposal verification.
@@ -120,6 +121,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
DomainBlobSidecar [4]byte `yaml:"DOMAIN_BLOB_SIDECAR" spec:"true"` // DomainBlobSidecar defines the BLS signature domain for blob sidecar.
// Prysm constants.
GweiPerEth uint64 // GweiPerEth is the amount of gwei corresponding to 1 eth.
@@ -154,6 +156,8 @@ type BeaconChainConfig struct {
BellatrixForkEpoch primitives.Epoch `yaml:"BELLATRIX_FORK_EPOCH" spec:"true"` // BellatrixForkEpoch is used to represent the assigned fork epoch for bellatrix.
CapellaForkVersion []byte `yaml:"CAPELLA_FORK_VERSION" spec:"true"` // CapellaForkVersion is used to represent the fork version for capella.
CapellaForkEpoch primitives.Epoch `yaml:"CAPELLA_FORK_EPOCH" spec:"true"` // CapellaForkEpoch is used to represent the assigned fork epoch for capella.
DenebForkVersion []byte `yaml:"DENEB_FORK_VERSION" spec:"true"` // DenebForkVersion is used to represent the fork version for deneb.
DenebForkEpoch primitives.Epoch `yaml:"DENEB_FORK_EPOCH" spec:"true"` // DenebForkEpoch is used to represent the assigned fork epoch for deneb.
ForkVersionSchedule map[[fieldparams.VersionLength]byte]primitives.Epoch // Schedule of fork epochs by version.
ForkVersionNames map[[fieldparams.VersionLength]byte]string // Human-readable names of fork versions.
@@ -227,18 +231,31 @@ func configForkSchedule(b *BeaconChainConfig) map[[fieldparams.VersionLength]byt
fvs[bytesutil.ToBytes4(b.AltairForkVersion)] = b.AltairForkEpoch
fvs[bytesutil.ToBytes4(b.BellatrixForkVersion)] = b.BellatrixForkEpoch
fvs[bytesutil.ToBytes4(b.CapellaForkVersion)] = b.CapellaForkEpoch
fvs[bytesutil.ToBytes4(b.DenebForkVersion)] = b.DenebForkEpoch
return fvs
}
func configForkNames(b *BeaconChainConfig) map[[fieldparams.VersionLength]byte]string {
cfv := ConfigForkVersions(b)
fvn := map[[fieldparams.VersionLength]byte]string{}
fvn[bytesutil.ToBytes4(b.GenesisForkVersion)] = "phase0"
fvn[bytesutil.ToBytes4(b.AltairForkVersion)] = "altair"
fvn[bytesutil.ToBytes4(b.BellatrixForkVersion)] = "bellatrix"
fvn[bytesutil.ToBytes4(b.CapellaForkVersion)] = "capella"
for k, v := range cfv {
fvn[k] = version.String(v)
}
return fvn
}
// ConfigForkVersions returns a mapping between a fork version param and the version identifier
// from the runtime/version package.
func ConfigForkVersions(b *BeaconChainConfig) map[[fieldparams.VersionLength]byte]int {
return map[[fieldparams.VersionLength]byte]int{
bytesutil.ToBytes4(b.GenesisForkVersion): version.Phase0,
bytesutil.ToBytes4(b.AltairForkVersion): version.Altair,
bytesutil.ToBytes4(b.BellatrixForkVersion): version.Bellatrix,
bytesutil.ToBytes4(b.CapellaForkVersion): version.Capella,
bytesutil.ToBytes4(b.DenebForkVersion): version.Deneb,
}
}
// Eth1DataVotesLength returns the maximum length of the votes on the Eth1 data,
// computed from the parameters in BeaconChainConfig.
func (b *BeaconChainConfig) Eth1DataVotesLength() uint64 {

View File

@@ -10,6 +10,7 @@ func InteropConfig() *BeaconChainConfig {
c.AltairForkVersion = []byte{1, 0, 0, 235}
c.BellatrixForkVersion = []byte{2, 0, 0, 235}
c.CapellaForkVersion = []byte{3, 0, 0, 235}
c.DenebForkVersion = []byte{4, 0, 0, 235}
c.InitializeForkSchedule()
return c

View File

@@ -207,6 +207,8 @@ func ConfigToYaml(cfg *BeaconChainConfig) []byte {
fmt.Sprintf("TERMINAL_BLOCK_HASH: %#x", cfg.TerminalBlockHash),
fmt.Sprintf("TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: %d", cfg.TerminalBlockHashActivationEpoch),
fmt.Sprintf("DEPOSIT_CONTRACT_ADDRESS: %s", cfg.DepositContractAddress),
fmt.Sprintf("DENEB_FORK_EPOCH: %d", cfg.DenebForkEpoch),
fmt.Sprintf("DENEB_FORK_VERSION: %#x", cfg.DenebForkVersion),
}
yamlFile := []byte(strings.Join(lines, "\n"))

View File

@@ -20,11 +20,10 @@ import (
// Variables defined in the placeholderFields will not be tested in `TestLoadConfigFile`.
// These are variables that we don't use in Prysm. (i.e. future hardfork, light client... etc)
var placeholderFields = []string{"UPDATE_TIMEOUT", "DENEB_FORK_EPOCH", "DENEB_FORK_VERSION",
"ATTESTATION_SUBNET_EXTRA_BITS", "RESP_TIMEOUT", "MAX_REQUEST_BLOCKS", "EPOCHS_PER_SUBNET_SUBSCRIPTION",
"EIP6110_FORK_EPOCH", "MESSAGE_DOMAIN_INVALID_SNAPPY", "MIN_EPOCHS_FOR_BLOCK_REQUESTS", "MAXIMUM_GOSSIP_CLOCK_DISPARITY",
"MESSAGE_DOMAIN_VALID_SNAPPY", "GOSSIP_MAX_SIZE", "SUBNETS_PER_NODE", "ATTESTATION_SUBNET_COUNT",
"MAX_CHUNK_SIZE", "ATTESTATION_PROPAGATION_SLOT_RANGE", "ATTESTATION_SUBNET_PREFIX_BITS", "EIP6110_FORK_VERSION", "TTFB_TIMEOUT"}
var placeholderFields = []string{"UPDATE_TIMEOUT", "ATTESTATION_SUBNET_EXTRA_BITS", "RESP_TIMEOUT", "MAX_REQUEST_BLOCKS", "EPOCHS_PER_SUBNET_SUBSCRIPTION",
"EIP6110_FORK_EPOCH", "MESSAGE_DOMAIN_INVALID_SNAPPY", "MIN_EPOCHS_FOR_BLOCK_REQUESTS", "MAXIMUM_GOSSIP_CLOCK_DISPARITY", "MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS",
"MESSAGE_DOMAIN_VALID_SNAPPY", "GOSSIP_MAX_SIZE", "SUBNETS_PER_NODE", "ATTESTATION_SUBNET_COUNT", "MAX_REQUEST_BLOCKS_DENEB", "MAX_REQUEST_BLOB_SIDECARS", "EIP7002_FORK_EPOCH", "EIP7002_FORK_VERSION",
"MAX_CHUNK_SIZE", "ATTESTATION_PROPAGATION_SLOT_RANGE", "ATTESTATION_SUBNET_PREFIX_BITS", "EIP6110_FORK_VERSION", "TTFB_TIMEOUT", "WHISK_FORK_VERSION", "WHISK_FORK_EPOCH", "WHISK_FORK_EPOCH", "BLOB_SIDECAR_SUBNET_COUNT", "MAX_BLOBS_PER_BLOCK"}
func assertEqualConfigs(t *testing.T, name string, fields []string, expected, actual *params.BeaconChainConfig) {
// Misc params.
@@ -115,11 +114,13 @@ func assertEqualConfigs(t *testing.T, name string, fields []string, expected, ac
assert.Equal(t, expected.AltairForkEpoch, actual.AltairForkEpoch, "%s: AltairForkEpoch", name)
assert.Equal(t, expected.BellatrixForkEpoch, actual.BellatrixForkEpoch, "%s: BellatrixForkEpoch", name)
assert.Equal(t, expected.CapellaForkEpoch, actual.CapellaForkEpoch, "%s: CapellaForkEpoch", name)
assert.Equal(t, expected.DenebForkEpoch, actual.DenebForkEpoch, "%s: DenebForkEpoch", name)
assert.Equal(t, expected.SqrRootSlotsPerEpoch, actual.SqrRootSlotsPerEpoch, "%s: SqrRootSlotsPerEpoch", name)
assert.DeepEqual(t, expected.GenesisForkVersion, actual.GenesisForkVersion, "%s: GenesisForkVersion", name)
assert.DeepEqual(t, expected.AltairForkVersion, actual.AltairForkVersion, "%s: AltairForkVersion", name)
assert.DeepEqual(t, expected.BellatrixForkVersion, actual.BellatrixForkVersion, "%s: BellatrixForkVersion", name)
assert.DeepEqual(t, expected.CapellaForkVersion, actual.CapellaForkVersion, "%s: CapellaForkVersion", name)
assert.DeepEqual(t, expected.DenebForkVersion, actual.DenebForkVersion, "%s: DenebForkVersion", name)
assertYamlFieldsMatch(t, name, fields, expected, actual)
}
@@ -130,6 +131,7 @@ func TestModifiedE2E(t *testing.T) {
c.TerminalTotalDifficulty = "0"
c.AltairForkEpoch = 0
c.BellatrixForkEpoch = 0
c.DenebForkEpoch = 358
y := params.ConfigToYaml(c)
cfg, err := params.UnmarshalConfig(y, nil)
require.NoError(t, err)

View File

@@ -212,6 +212,8 @@ var mainnetBeaconConfig = &BeaconChainConfig{
BellatrixForkEpoch: mainnetBellatrixForkEpoch,
CapellaForkVersion: []byte{3, 0, 0, 0},
CapellaForkEpoch: 194048,
DenebForkVersion: []byte{4, 0, 0, 0},
DenebForkEpoch: math.MaxUint64,
// New values introduced in Altair hard fork 1.
// Participation flag indices.
@@ -279,14 +281,17 @@ func FillTestVersions(c *BeaconChainConfig, b byte) {
c.AltairForkVersion = make([]byte, fieldparams.VersionLength)
c.BellatrixForkVersion = make([]byte, fieldparams.VersionLength)
c.CapellaForkVersion = make([]byte, fieldparams.VersionLength)
c.DenebForkVersion = make([]byte, fieldparams.VersionLength)
c.GenesisForkVersion[fieldparams.VersionLength-1] = b
c.AltairForkVersion[fieldparams.VersionLength-1] = b
c.BellatrixForkVersion[fieldparams.VersionLength-1] = b
c.CapellaForkVersion[fieldparams.VersionLength-1] = b
c.DenebForkVersion[fieldparams.VersionLength-1] = b
c.GenesisForkVersion[0] = 0
c.AltairForkVersion[0] = 1
c.BellatrixForkVersion[0] = 2
c.CapellaForkVersion[0] = 3
c.DenebForkVersion[0] = 4
}

View File

@@ -88,6 +88,8 @@ func MinimalSpecConfig() *BeaconChainConfig {
minimalConfig.BellatrixForkEpoch = math.MaxUint64
minimalConfig.CapellaForkVersion = []byte{3, 0, 0, 1}
minimalConfig.CapellaForkEpoch = math.MaxUint64
minimalConfig.DenebForkVersion = []byte{4, 0, 0, 1}
minimalConfig.DenebForkEpoch = math.MaxUint64
minimalConfig.SyncCommitteeSize = 32
minimalConfig.InactivityScoreBias = 4

View File

@@ -41,6 +41,9 @@ BELLATRIX_FORK_EPOCH: 8
# Capella
CAPELLA_FORK_VERSION: 0x030000fd
CAPELLA_FORK_EPOCH: 10
# Deneb
DENEB_FORK_VERSION: 0x040000fd
DENEB_FORK_EPOCH: 18446744073709551615
# Time parameters

View File

@@ -1,9 +1,12 @@
package params
import "math"
const (
AltairE2EForkEpoch = 6
BellatrixE2EForkEpoch = 8
CapellaE2EForkEpoch = 10
DenebE2EForkEpoch = math.MaxUint64
)
// E2ETestConfig retrieves the configurations made specifically for E2E testing.
@@ -38,6 +41,7 @@ func E2ETestConfig() *BeaconChainConfig {
e2eConfig.AltairForkEpoch = AltairE2EForkEpoch
e2eConfig.BellatrixForkEpoch = BellatrixE2EForkEpoch
e2eConfig.CapellaForkEpoch = CapellaE2EForkEpoch
e2eConfig.DenebForkEpoch = DenebE2EForkEpoch
// Terminal Total Difficulty.
e2eConfig.TerminalTotalDifficulty = "480"
@@ -48,6 +52,7 @@ func E2ETestConfig() *BeaconChainConfig {
e2eConfig.AltairForkVersion = []byte{1, 0, 0, 253}
e2eConfig.BellatrixForkVersion = []byte{2, 0, 0, 253}
e2eConfig.CapellaForkVersion = []byte{3, 0, 0, 253}
e2eConfig.DenebForkVersion = []byte{4, 0, 0, 253}
e2eConfig.InitializeForkSchedule()
return e2eConfig
@@ -78,6 +83,7 @@ func E2EMainnetTestConfig() *BeaconChainConfig {
e2eConfig.AltairForkEpoch = AltairE2EForkEpoch
e2eConfig.BellatrixForkEpoch = BellatrixE2EForkEpoch
e2eConfig.CapellaForkEpoch = CapellaE2EForkEpoch
e2eConfig.DenebForkEpoch = DenebE2EForkEpoch
// Terminal Total Difficulty.
e2eConfig.TerminalTotalDifficulty = "480"
@@ -88,6 +94,7 @@ func E2EMainnetTestConfig() *BeaconChainConfig {
e2eConfig.AltairForkVersion = []byte{1, 0, 0, 254}
e2eConfig.BellatrixForkVersion = []byte{2, 0, 0, 254}
e2eConfig.CapellaForkVersion = []byte{3, 0, 0, 254}
e2eConfig.DenebForkVersion = []byte{4, 0, 0, 254}
e2eConfig.InitializeForkSchedule()
return e2eConfig

View File

@@ -1,6 +1,8 @@
package params
import (
"math"
eth1Params "github.com/ethereum/go-ethereum/params"
)
@@ -40,6 +42,8 @@ func PraterConfig() *BeaconChainConfig {
cfg.BellatrixForkVersion = []byte{0x2, 0x0, 0x10, 0x20}
cfg.CapellaForkEpoch = 162304
cfg.CapellaForkVersion = []byte{0x3, 0x0, 0x10, 0x20}
cfg.DenebForkVersion = []byte{0x4, 0x0, 0x10, 0x20}
cfg.DenebForkEpoch = math.MaxUint64
cfg.TerminalTotalDifficulty = "10790000"
cfg.DepositContractAddress = "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b"
cfg.InitializeForkSchedule()

View File

@@ -7,6 +7,7 @@ const (
Altair
Bellatrix
Capella
Deneb
)
var versionToString = map[int]string{
@@ -14,6 +15,7 @@ var versionToString = map[int]string{
Altair: "altair",
Bellatrix: "bellatrix",
Capella: "capella",
Deneb: "deneb",
}
// stringToVersion and allVersions are populated in init()