Recompute SqrRootSlotsPerEpoch at startup for custom configs (#9554)

* Recompute SqrRootSlotsPerEpoch at startup for custom configs

* Fix bazel deps

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
This commit is contained in:
Kirill Fedoseev 2021-09-09 20:03:00 +03:00 committed by GitHub
parent a6abfa5dd8
commit 5325558f03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -21,6 +21,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//shared/bytesutil:go_default_library",
"//shared/mathutil:go_default_library",
"@com_github_ethereum_go_ethereum//params:go_default_library",
"@com_github_mohae_deepcopy//:go_default_library",
"@com_github_prysmaticlabs_eth2_types//:go_default_library",

View File

@ -5,6 +5,8 @@ import (
"io/ioutil"
"strings"
types "github.com/prysmaticlabs/eth2-types"
"github.com/prysmaticlabs/prysm/shared/mathutil"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
@ -42,6 +44,8 @@ func LoadChainConfigFile(chainConfigFileName string) {
log.WithError(err).Error("There were some issues parsing the config from a yaml file")
}
}
// recompute SqrRootSlotsPerEpoch constant to handle non-standard values of SlotsPerEpoch
conf.SqrRootSlotsPerEpoch = types.Slot(mathutil.IntegerSquareRoot(uint64(conf.SlotsPerEpoch)))
log.Debugf("Config file values: %+v", conf)
OverrideBeaconConfig(conf)
}