mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-03 00:27:38 +00:00
Update Prater config to include Altair fork epoch (#9467)
* Update Prater config after https://github.com/eth2-clients/eth2-networks/pull/58. Add tests to enforce compliance. * gofmt * spec: true * fix test Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
ffbb722777
commit
3d6fad3121
16
WORKSPACE
16
WORKSPACE
@ -263,6 +263,22 @@ filegroup(
|
|||||||
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
|
url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
http_archive(
|
||||||
|
name = "eth2_networks",
|
||||||
|
build_file_content = """
|
||||||
|
filegroup(
|
||||||
|
name = "configs",
|
||||||
|
srcs = glob([
|
||||||
|
"shared/**/config.yaml",
|
||||||
|
]),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
""",
|
||||||
|
sha256 = "9dc47bf6b14aed7fac8833e35ab83a69131b43fa5789b3256bf1ac3d4861aeb8",
|
||||||
|
strip_prefix = "eth2-networks-7fa1b868985ee24aad65567f9250cf7fa86f97b1",
|
||||||
|
url = "https://github.com/eth2-clients/eth2-networks/archive/7fa1b868985ee24aad65567f9250cf7fa86f97b1.tar.gz",
|
||||||
|
)
|
||||||
|
|
||||||
http_archive(
|
http_archive(
|
||||||
name = "com_github_bazelbuild_buildtools",
|
name = "com_github_bazelbuild_buildtools",
|
||||||
sha256 = "7a182df18df1debabd9e36ae07c8edfa1378b8424a04561b674d933b965372b3",
|
sha256 = "7a182df18df1debabd9e36ae07c8edfa1378b8424a04561b674d933b965372b3",
|
||||||
|
@ -124,7 +124,7 @@ func TestGetSpec(t *testing.T) {
|
|||||||
resp, err := server.GetSpec(context.Background(), &emptypb.Empty{})
|
resp, err := server.GetSpec(context.Background(), &emptypb.Empty{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, 89, len(resp.Data))
|
assert.Equal(t, 90, len(resp.Data))
|
||||||
for k, v := range resp.Data {
|
for k, v := range resp.Data {
|
||||||
switch k {
|
switch k {
|
||||||
case "CONFIG_NAME":
|
case "CONFIG_NAME":
|
||||||
@ -313,6 +313,8 @@ func TestGetSpec(t *testing.T) {
|
|||||||
assert.Equal(t, "0x08000000", v)
|
assert.Equal(t, "0x08000000", v)
|
||||||
case "DOMAIN_CONTRIBUTION_AND_PROOF":
|
case "DOMAIN_CONTRIBUTION_AND_PROOF":
|
||||||
assert.Equal(t, "0x09000000", v)
|
assert.Equal(t, "0x09000000", v)
|
||||||
|
case "TRANSITION_TOTAL_DIFFICULTY":
|
||||||
|
assert.Equal(t, "0", v)
|
||||||
default:
|
default:
|
||||||
t.Errorf("Incorrect key: %s", k)
|
t.Errorf("Incorrect key: %s", k)
|
||||||
}
|
}
|
||||||
|
@ -37,11 +37,14 @@ go_test(
|
|||||||
"checktags_test.go",
|
"checktags_test.go",
|
||||||
"config_test.go",
|
"config_test.go",
|
||||||
"loader_test.go",
|
"loader_test.go",
|
||||||
|
"testnet_config_test.go",
|
||||||
|
"testnet_prater_config_test.go",
|
||||||
],
|
],
|
||||||
data = glob(["*.yaml"]) + [
|
data = glob(["*.yaml"]) + [
|
||||||
"@consensus_spec//:spec_data",
|
"@consensus_spec//:spec_data",
|
||||||
"@consensus_spec_tests_mainnet//:test_data",
|
"@consensus_spec_tests_mainnet//:test_data",
|
||||||
"@consensus_spec_tests_minimal//:test_data",
|
"@consensus_spec_tests_minimal//:test_data",
|
||||||
|
"@eth2_networks//:configs",
|
||||||
],
|
],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
gotags = ["develop"],
|
gotags = ["develop"],
|
||||||
|
@ -138,6 +138,7 @@ type BeaconChainConfig struct {
|
|||||||
ShardingForkEpoch types.Epoch `yaml:"SHARDING_FORK_EPOCH" spec:"true"` // ShardingForkEpoch is used to represent the assigned fork epoch for sharding.
|
ShardingForkEpoch types.Epoch `yaml:"SHARDING_FORK_EPOCH" spec:"true"` // ShardingForkEpoch is used to represent the assigned fork epoch for sharding.
|
||||||
ForkVersionSchedule map[[4]byte]types.Epoch // Schedule of fork epochs by version.
|
ForkVersionSchedule map[[4]byte]types.Epoch // Schedule of fork epochs by version.
|
||||||
MinAnchorPowBlockDifficulty uint64 `yaml:"MIN_ANCHOR_POW_BLOCK_DIFFICULTY" spec:"true"` // MinAnchorPowBlockDifficulty specifies the target chain difficulty at the time of the merge.
|
MinAnchorPowBlockDifficulty uint64 `yaml:"MIN_ANCHOR_POW_BLOCK_DIFFICULTY" spec:"true"` // MinAnchorPowBlockDifficulty specifies the target chain difficulty at the time of the merge.
|
||||||
|
TransitionTotalDifficulty uint64 `yaml:"TRANSITION_TOTAL_DIFFICULTY" spec:"true"` // TransitionTotalDifficulty is part of the experimental merge spec. This value is not used (yet) and is expected to be a uint256.
|
||||||
|
|
||||||
// Weak subjectivity values.
|
// Weak subjectivity values.
|
||||||
SafetyDecay uint64 // SafetyDecay is defined as the loss in the 1/3 consensus safety margin of the casper FFG mechanism.
|
SafetyDecay uint64 // SafetyDecay is defined as the loss in the 1/3 consensus safety margin of the casper FFG mechanism.
|
||||||
|
@ -100,28 +100,7 @@ func TestLoadConfigFileMainnet(t *testing.T) {
|
|||||||
assert.Equal(t, c1.DomainSelectionProof, c2.DomainSelectionProof, "%s: DomainSelectionProof", name)
|
assert.Equal(t, c1.DomainSelectionProof, c2.DomainSelectionProof, "%s: DomainSelectionProof", name)
|
||||||
assert.Equal(t, c1.DomainAggregateAndProof, c2.DomainAggregateAndProof, "%s: DomainAggregateAndProof", name)
|
assert.Equal(t, c1.DomainAggregateAndProof, c2.DomainAggregateAndProof, "%s: DomainAggregateAndProof", name)
|
||||||
|
|
||||||
// Ensure all fields from the yaml file exist, were set, and correctly match the expected value.
|
assertYamlFieldsMatch(t, name, fields, c1, c2)
|
||||||
ft1 := reflect.TypeOf(*c1)
|
|
||||||
for _, field := range fields {
|
|
||||||
var found bool
|
|
||||||
for i := 0; i < ft1.NumField(); i++ {
|
|
||||||
v, ok := ft1.Field(i).Tag.Lookup("yaml")
|
|
||||||
if ok && v == field {
|
|
||||||
found = true
|
|
||||||
v1 := reflect.ValueOf(*c1).Field(i).Interface()
|
|
||||||
v2 := reflect.ValueOf(*c2).Field(i).Interface()
|
|
||||||
if reflect.ValueOf(v1).Kind() == reflect.Slice {
|
|
||||||
assert.DeepEqual(t, v1, v2, "%s: %s", name, field)
|
|
||||||
} else {
|
|
||||||
assert.Equal(t, v1, v2, "%s: %s", name, field)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
t.Errorf("No struct tag found `yaml:%s`", field)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.Run("mainnet", func(t *testing.T) {
|
t.Run("mainnet", func(t *testing.T) {
|
||||||
@ -263,3 +242,28 @@ func fieldsFromYaml(t *testing.T, fp string) []string {
|
|||||||
|
|
||||||
return keys
|
return keys
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func assertYamlFieldsMatch(t *testing.T, name string, fields []string, c1, c2 *BeaconChainConfig) {
|
||||||
|
// Ensure all fields from the yaml file exist, were set, and correctly match the expected value.
|
||||||
|
ft1 := reflect.TypeOf(*c1)
|
||||||
|
for _, field := range fields {
|
||||||
|
var found bool
|
||||||
|
for i := 0; i < ft1.NumField(); i++ {
|
||||||
|
v, ok := ft1.Field(i).Tag.Lookup("yaml")
|
||||||
|
if ok && v == field {
|
||||||
|
found = true
|
||||||
|
v1 := reflect.ValueOf(*c1).Field(i).Interface()
|
||||||
|
v2 := reflect.ValueOf(*c2).Field(i).Interface()
|
||||||
|
if reflect.ValueOf(v1).Kind() == reflect.Slice {
|
||||||
|
assert.DeepEqual(t, v1, v2, "%s: %s", name, field)
|
||||||
|
} else {
|
||||||
|
assert.Equal(t, v1, v2, "%s: %s", name, field)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("No struct tag found `yaml:%s`", field)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
16
shared/params/testnet_config_test.go
Normal file
16
shared/params/testnet_config_test.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package params
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||||
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func testnetConfigFilePath(t *testing.T, network string) string {
|
||||||
|
filepath, err := bazel.Runfile("external/eth2_networks")
|
||||||
|
require.NoError(t, err)
|
||||||
|
configFilePath := path.Join(filepath, "shared", network, "config.yaml")
|
||||||
|
return configFilePath
|
||||||
|
}
|
@ -39,6 +39,11 @@ func PraterConfig() *BeaconChainConfig {
|
|||||||
cfg.SecondsPerETH1Block = 14
|
cfg.SecondsPerETH1Block = 14
|
||||||
cfg.DepositChainID = eth1Params.GoerliChainConfig.ChainID.Uint64()
|
cfg.DepositChainID = eth1Params.GoerliChainConfig.ChainID.Uint64()
|
||||||
cfg.DepositNetworkID = eth1Params.GoerliChainConfig.ChainID.Uint64()
|
cfg.DepositNetworkID = eth1Params.GoerliChainConfig.ChainID.Uint64()
|
||||||
cfg.DepositContractAddress = "0xff50ed3d0ec03ac01d4c79aad74928bff48a7b2b"
|
cfg.AltairForkEpoch = 36660
|
||||||
|
cfg.AltairForkVersion = []byte{0x1, 0x0, 0x10, 0x20}
|
||||||
|
cfg.ShardingForkVersion = []byte{0x3, 0x0, 0x10, 0x20}
|
||||||
|
cfg.MergeForkVersion = []byte{0x2, 0x0, 0x10, 0x20}
|
||||||
|
cfg.TransitionTotalDifficulty = 4294967296
|
||||||
|
cfg.DepositContractAddress = "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b"
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
12
shared/params/testnet_prater_config_test.go
Normal file
12
shared/params/testnet_prater_config_test.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package params
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPraterConfigMatchesUpstreamYaml(t *testing.T) {
|
||||||
|
configFP := testnetConfigFilePath(t, "prater")
|
||||||
|
LoadChainConfigFile(configFP)
|
||||||
|
fields := fieldsFromYaml(t, configFP)
|
||||||
|
assertYamlFieldsMatch(t, "prater", fields, BeaconConfig(), PraterConfig())
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user