diff --git a/WORKSPACE b/WORKSPACE index 793946dec..0b78e910d 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -197,7 +197,7 @@ filegroup( url = "https://github.com/eth2-clients/slashing-protection-interchange-tests/archive/b8413ca42dc92308019d0d4db52c87e9e125c4e9.tar.gz", ) -consensus_spec_version = "v1.1.0-beta.4" +consensus_spec_version = "v1.1.0" bls_test_version = "v0.1.1" @@ -213,7 +213,7 @@ filegroup( visibility = ["//visibility:public"], ) """, - sha256 = "d2d501453cf29777896a5f9ae52e93921f34330e57fcc5b55e4982d4795236b9", + sha256 = "0f58ec1c8995ab2c0a3aada873e1a02f333c8659fdacaa1c76fbdce28b6177dc", url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/general.tar.gz" % consensus_spec_version, ) @@ -229,7 +229,7 @@ filegroup( visibility = ["//visibility:public"], ) """, - sha256 = "b152f1f03a4fdacd1882fe867bdfbd5067e74ed3c532bd01d81e7adf6cc3737a", + sha256 = "d2eeadef3f8885748f769a06eb916bea60fb00112a90cec3288ea78db5557df3", url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/minimal.tar.gz" % consensus_spec_version, ) @@ -245,7 +245,7 @@ filegroup( visibility = ["//visibility:public"], ) """, - sha256 = "6046f89c679a9ffda217dee6f021eb7c4fe91aad6ff940fae4d2cf894cc61cbb", + sha256 = "bbc345432f4eaa4babe2619e16fcf3f607113ede82d1bd0fff2633c1376419f7", url = "https://github.com/ethereum/consensus-spec-tests/releases/download/%s/mainnet.tar.gz" % consensus_spec_version, ) @@ -260,7 +260,7 @@ filegroup( visibility = ["//visibility:public"], ) """, - sha256 = "26a0a2c3022a3c5354f3204c7e441580df2e585dbde22a43a1d43f885b3a221c", + sha256 = "787a50c2a03bebab92f089333f598780ca7b4849b36a4897e6603ddd3e86ec24", strip_prefix = "consensus-specs-" + consensus_spec_version[1:], url = "https://github.com/ethereum/consensus-specs/archive/refs/tags/%s.tar.gz" % consensus_spec_version, ) diff --git a/config/params/loader_test.go b/config/params/loader_test.go index 91a11535a..16e6df7b6 100644 --- a/config/params/loader_test.go +++ b/config/params/loader_test.go @@ -14,6 +14,11 @@ import ( "gopkg.in/yaml.v2" ) +var placeholderFields = []string{ + "TERMINAL_TOTAL_DIFFICULTY", + "TERMINAL_BLOCK_HASH", +} + func TestLoadConfigFileMainnet(t *testing.T) { // See https://media.githubusercontent.com/media/ethereum/consensus-spec-tests/master/tests/minimal/config/phase0.yaml assertVals := func(name string, fields []string, c1, c2 *params.BeaconChainConfig) { @@ -105,16 +110,19 @@ func TestLoadConfigFileMainnet(t *testing.T) { } t.Run("mainnet", func(t *testing.T) { - mainnetConfigFile := presetsFilePath(t, "mainnet") + mainnetPresetsFile := presetsFilePath(t, "mainnet") + params.LoadChainConfigFile(mainnetPresetsFile) + mainnetConfigFile := configFilePath(t, "mainnet") params.LoadChainConfigFile(mainnetConfigFile) - fields := fieldsFromYaml(t, mainnetConfigFile) + fields := fieldsFromYamls(t, []string{mainnetPresetsFile, mainnetConfigFile}) assertVals("mainnet", fields, params.MainnetConfig(), params.BeaconConfig()) }) t.Run("minimal", func(t *testing.T) { - minimalConfigFile := presetsFilePath(t, "minimal") - params.LoadChainConfigFile(minimalConfigFile) - fields := fieldsFromYaml(t, minimalConfigFile) + minimalPresetsFile := presetsFilePath(t, "minimal") + params.LoadChainConfigFile(minimalPresetsFile) + minimalConfigFile := configFilePath(t, "minimal") + fields := fieldsFromYamls(t, []string{minimalPresetsFile, minimalConfigFile}) assertVals("minimal", fields, params.MinimalSpecConfig(), params.BeaconConfig()) }) } @@ -226,19 +234,21 @@ func presetsFilePath(t *testing.T, config string) string { return configFilePath } -func fieldsFromYaml(t *testing.T, fp string) []string { - yamlFile, err := ioutil.ReadFile(fp) - require.NoError(t, err) - m := make(map[string]interface{}) - require.NoError(t, yaml.Unmarshal(yamlFile, &m)) - +func fieldsFromYamls(t *testing.T, fps []string) []string { var keys []string - for k := range m { - keys = append(keys, k) - } + for _, fp := range fps { + yamlFile, err := ioutil.ReadFile(fp) + require.NoError(t, err) + m := make(map[string]interface{}) + require.NoError(t, yaml.Unmarshal(yamlFile, &m)) - if len(keys) == 0 { - t.Errorf("No fields loaded from yaml file %s", fp) + for k := range m { + keys = append(keys, k) + } + + if len(keys) == 0 { + t.Errorf("No fields loaded from yaml file %s", fp) + } } return keys @@ -252,6 +262,11 @@ func assertYamlFieldsMatch(t *testing.T, name string, fields []string, c1, c2 *p for i := 0; i < ft1.NumField(); i++ { v, ok := ft1.Field(i).Tag.Lookup("yaml") if ok && v == field { + if isPlaceholderField(v) { + // If you see this error, remove the field from placeholderFields. + t.Errorf("beacon config has a placeholder field defined, remove %s from the placeholder fields variable", v) + continue + } found = true v1 := reflect.ValueOf(*c1).Field(i).Interface() v2 := reflect.ValueOf(*c2).Field(i).Interface() @@ -263,8 +278,17 @@ func assertYamlFieldsMatch(t *testing.T, name string, fields []string, c1, c2 *p break } } - if !found { + if !found && !isPlaceholderField(field) { // Ignore placeholder fields t.Errorf("No struct tag found `yaml:%s`", field) } } } + +func isPlaceholderField(field string) bool { + for _, f := range placeholderFields { + if f == field { + return true + } + } + return false +} diff --git a/config/params/testnet_prater_config_test.go b/config/params/testnet_prater_config_test.go index ab2efb4d5..9548fba09 100644 --- a/config/params/testnet_prater_config_test.go +++ b/config/params/testnet_prater_config_test.go @@ -7,8 +7,10 @@ import ( ) func TestPraterConfigMatchesUpstreamYaml(t *testing.T) { + presetFP := presetsFilePath(t, "mainnet") + params.LoadChainConfigFile(presetFP) configFP := testnetConfigFilePath(t, "prater") params.LoadChainConfigFile(configFP) - fields := fieldsFromYaml(t, configFP) + fields := fieldsFromYamls(t, []string{configFP, presetFP}) assertYamlFieldsMatch(t, "prater", fields, params.BeaconConfig(), params.PraterConfig()) }