mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 21:08:10 -05:00
Add support for electra fork epoch (#15132)
* Add support for electra fork epoch * Fix tests * fixing tests without needing to override electra fork config * reverting electra fork override on blob test too, replacing with custom timefetcher * reverting old changelog * Fix genesis time * Move mainnet test into mainnet_config_test.go * Update spec test to v1.5.0-beta.5 --------- Co-authored-by: james-prysm <james@prysmaticlabs.com> Co-authored-by: Preston Van Loon <preston@pvl.dev>
This commit is contained in:
26
WORKSPACE
26
WORKSPACE
@@ -255,7 +255,7 @@ filegroup(
|
||||
url = "https://github.com/ethereum/EIPs/archive/5480440fe51742ed23342b68cf106cefd427e39d.tar.gz",
|
||||
)
|
||||
|
||||
consensus_spec_version = "v1.5.0-beta.4"
|
||||
consensus_spec_version = "v1.5.0-beta.5"
|
||||
|
||||
bls_test_version = "v0.1.1"
|
||||
|
||||
@@ -271,7 +271,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-QG0NUqaCvP5lKaKKwF/fmeICZVjONMlb7EE+MtYl0C0=",
|
||||
integrity = "sha256-H+Pt4z+HCVDnEBAv814yvsjR7f5l1IpumjFoTj2XnLE=",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/general.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -287,7 +287,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-8NQngTSSqzW/j3tOUi3r5h+94ChRbLNWTt7BOGqr4+E=",
|
||||
integrity = "sha256-Dqiwf5BG7yYyURGf+i87AIdArAyztvcgjoi2kSxrGvo=",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/minimal.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -303,7 +303,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-gFqxbaBnJ7dtdoj0zFbVrtlHv/bLNuWjrTHkyCAjFjI=",
|
||||
integrity = "sha256-xrmsFF243pzXHAjh1EQYKS9gtcwmtHK3wRZDSLlVVRk=",
|
||||
url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/mainnet.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
|
||||
@@ -318,7 +318,7 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-9paalF0POULpP2ga+4ouHSETKYrWNCUCZoJHPuFw06E=",
|
||||
integrity = "sha256-c+gGapqifCvFtmtxfhOwieBDO2Syxp13GECWEpWM/Ho=",
|
||||
strip_prefix = "consensus-specs-" + consensus_spec_version[1:],
|
||||
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
|
||||
)
|
||||
@@ -370,6 +370,22 @@ filegroup(
|
||||
url = "https://github.com/eth-clients/holesky/archive/32a72e21c6e53c262f27d50dd540cb654517d03a.tar.gz", # 2025-03-17
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "mainnet",
|
||||
build_file_content = """
|
||||
filegroup(
|
||||
name = "configs",
|
||||
srcs = [
|
||||
"metadata/config.yaml",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
""",
|
||||
integrity = "sha256-NZr/gsQK9rBHRnznlPBiNzJpK8MPMrfUa3f+QYqn1+g=",
|
||||
strip_prefix = "mainnet-978f1794eada6f85bee76e4d2d5959a5fb8e0cc5",
|
||||
url = "https://github.com/eth-clients/mainnet/archive/978f1794eada6f85bee76e4d2d5959a5fb8e0cc5.tar.gz",
|
||||
)
|
||||
|
||||
http_archive(
|
||||
name = "sepolia_testnet",
|
||||
build_file_content = """
|
||||
|
||||
@@ -211,8 +211,8 @@ func TestListAttestations(t *testing.T) {
|
||||
t.Run("Pre-Electra", func(t *testing.T) {
|
||||
bs, err := util.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
|
||||
chainService := &blockchainmock.ChainService{State: bs}
|
||||
slot := primitives.Slot(0)
|
||||
chainService := &blockchainmock.ChainService{State: bs, Slot: &slot}
|
||||
s := &Server{
|
||||
ChainInfoFetcher: chainService,
|
||||
TimeFetcher: chainService,
|
||||
@@ -1734,7 +1734,8 @@ func TestGetAttesterSlashings(t *testing.T) {
|
||||
t.Run("pre-electra-ok", func(t *testing.T) {
|
||||
bs, err := util.NewBeaconState()
|
||||
require.NoError(t, err)
|
||||
chainService := &blockchainmock.ChainService{State: bs}
|
||||
slot := primitives.Slot(0)
|
||||
chainService := &blockchainmock.ChainService{State: bs, Slot: &slot}
|
||||
|
||||
s := &Server{
|
||||
ChainInfoFetcher: chainService,
|
||||
|
||||
@@ -50,6 +50,7 @@ func TestBlobs(t *testing.T) {
|
||||
|
||||
mockChainService := &mockChain.ChainService{
|
||||
FinalizedRoots: map[[32]byte]bool{},
|
||||
Genesis: time.Now().Add(-time.Duration(uint64(params.BeaconConfig().SlotsPerEpoch)*uint64(params.BeaconConfig().DenebForkEpoch)*params.BeaconConfig().SecondsPerSlot) * time.Second),
|
||||
}
|
||||
s := &Server{
|
||||
OptimisticModeFetcher: mockChainService,
|
||||
|
||||
3
changelog/tt_8.md
Normal file
3
changelog/tt_8.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Added
|
||||
|
||||
- Add support for Electra fork epoch
|
||||
@@ -47,6 +47,7 @@ go_test(
|
||||
"config_test.go",
|
||||
"configset_test.go",
|
||||
"loader_test.go",
|
||||
"mainnet_config_export_test.go",
|
||||
"mainnet_config_test.go",
|
||||
"testnet_config_test.go",
|
||||
"testnet_holesky_config_test.go",
|
||||
@@ -61,6 +62,7 @@ go_test(
|
||||
"@eth2_networks//:configs",
|
||||
"@holesky_testnet//:configs",
|
||||
"@hoodi_testnet//:configs",
|
||||
"@mainnet//:configs",
|
||||
"@sepolia_testnet//:configs",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
|
||||
@@ -35,6 +35,8 @@ var placeholderFields = []string{
|
||||
"EIP7441_FORK_VERSION",
|
||||
"EIP7732_FORK_EPOCH",
|
||||
"EIP7732_FORK_VERSION",
|
||||
"EIP7805_FORK_EPOCH",
|
||||
"EIP7805_FORK_VERSION",
|
||||
"EPOCHS_PER_SHUFFLING_PHASE",
|
||||
"MAX_BLOBS_PER_BLOCK_FULU",
|
||||
"MAX_REQUEST_BLOB_SIDECARS_FULU",
|
||||
|
||||
@@ -28,7 +28,7 @@ const (
|
||||
// Deneb Fork Epoch for mainnet config.
|
||||
mainnetDenebForkEpoch = 269568 // March 13, 2024, 13:55:35 UTC
|
||||
// Electra Fork Epoch for mainnet config
|
||||
mainnetElectraForkEpoch = math.MaxUint64 // Far future / to be defined
|
||||
mainnetElectraForkEpoch = 364032 // May 7, 2025, 10:05:11 UTC
|
||||
// Fulu Fork Epoch for mainnet config
|
||||
mainnetFuluForkEpoch = math.MaxUint64 // Far future / to be defined
|
||||
)
|
||||
|
||||
6
config/params/mainnet_config_export_test.go
Normal file
6
config/params/mainnet_config_export_test.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package params
|
||||
|
||||
// Re-exports for blackbox testing.
|
||||
const MainnetDenebForkEpoch = mainnetDenebForkEpoch
|
||||
var MainnetBeaconConfig = mainnetBeaconConfig
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package params
|
||||
package params_test
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/OffchainLabs/prysm/v6/config/params"
|
||||
"github.com/OffchainLabs/prysm/v6/consensus-types/primitives"
|
||||
"github.com/OffchainLabs/prysm/v6/testing/require"
|
||||
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||
)
|
||||
|
||||
func TestMaxRequestBlock(t *testing.T) {
|
||||
@@ -13,21 +17,39 @@ func TestMaxRequestBlock(t *testing.T) {
|
||||
description string
|
||||
}{
|
||||
{
|
||||
epoch: primitives.Epoch(mainnetDenebForkEpoch - 1), // Assuming the fork epoch is not 0
|
||||
expectedMaxBlock: mainnetBeaconConfig.MaxRequestBlocks,
|
||||
epoch: primitives.Epoch(params.MainnetDenebForkEpoch - 1), // Assuming the fork epoch is not 0
|
||||
expectedMaxBlock: params.MainnetBeaconConfig.MaxRequestBlocks,
|
||||
},
|
||||
{
|
||||
epoch: primitives.Epoch(mainnetDenebForkEpoch),
|
||||
expectedMaxBlock: mainnetBeaconConfig.MaxRequestBlocksDeneb,
|
||||
epoch: primitives.Epoch(params.MainnetDenebForkEpoch),
|
||||
expectedMaxBlock: params.MainnetBeaconConfig.MaxRequestBlocksDeneb,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
maxBlocks := MaxRequestBlock(tc.epoch)
|
||||
maxBlocks := params.MaxRequestBlock(tc.epoch)
|
||||
if maxBlocks != tc.expectedMaxBlock {
|
||||
t.Errorf("For epoch %d, expected max blocks %d, got %d", tc.epoch, tc.expectedMaxBlock, maxBlocks)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMainnetConfigMatchesUpstreamYaml(t *testing.T) {
|
||||
presetFPs := presetsFilePath(t, "mainnet")
|
||||
mn, err := params.ByName(params.MainnetName)
|
||||
require.NoError(t, err)
|
||||
cfg := mn.Copy()
|
||||
for _, fp := range presetFPs {
|
||||
cfg, err = params.UnmarshalConfigFile(fp, cfg)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
fPath, err := bazel.Runfile("external/mainnet")
|
||||
require.NoError(t, err)
|
||||
configFP := path.Join(fPath, "metadata", "config.yaml")
|
||||
pcfg, err := params.UnmarshalConfigFile(configFP, nil)
|
||||
require.NoError(t, err)
|
||||
fields := fieldsFromYamls(t, append(presetFPs, configFP))
|
||||
assertYamlFieldsMatch(t, "mainnet", fields, pcfg, params.BeaconConfig())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user