diff --git a/config/config.go b/config/config.go index 5d321376..4934f927 100644 --- a/config/config.go +++ b/config/config.go @@ -1,16 +1,24 @@ package config -import _ "embed" +import ( + "embed" +) +// explorer config +// //go:embed default.config.yml var DefaultConfigYml string +// chain presets +// //go:embed preset-mainnet.chain.yml var MainnetPresetYml string //go:embed preset-minimal.chain.yml var MinimalPresetYml string +// chain configs +// //go:embed mainnet.chain.yml var MainnetChainYml string @@ -20,5 +28,13 @@ var PraterChainYml string //go:embed sepolia.chain.yml var SepoliaChainYml string +//go:embed holesky.chain.yml +var HoleskyChainYml string + //go:embed testnet.chain.yml var TestnetChainYml string + +// validator names +// +//go:embed *.names.yml +var ValidatorNamesYml embed.FS diff --git a/config/holesky.chain.yml b/config/holesky.chain.yml new file mode 100644 index 00000000..490cb02c --- /dev/null +++ b/config/holesky.chain.yml @@ -0,0 +1,117 @@ +# Extends the mainnet preset +PRESET_BASE: 'mainnet' +CONFIG_NAME: holesky + +# Genesis +# --------------------------------------------------------------- +# `2**14` (= 16,384) +MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 16384 +# Sep-15-2023 13:55:00 +UTC +MIN_GENESIS_TIME: 1694786100 +GENESIS_FORK_VERSION: 0x00017000 +# Genesis delay 5 mins +GENESIS_DELAY: 300 + + +# Forking +# --------------------------------------------------------------- +# Some forks are disabled for now: +# - These may be re-assigned to another fork-version later +# - Temporarily set to max uint64 value: 2**64 - 1 + +# Altair +ALTAIR_FORK_VERSION: 0x10017000 +ALTAIR_FORK_EPOCH: 0 +# Merge +BELLATRIX_FORK_VERSION: 0x20017000 +BELLATRIX_FORK_EPOCH: 0 +TERMINAL_TOTAL_DIFFICULTY: 0 +TERMINAL_BLOCK_HASH: 0x0000000000000000000000000000000000000000000000000000000000000000 +TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: 18446744073709551615 + +# Capella +CAPELLA_FORK_VERSION: 0x30017000 +CAPELLA_FORK_EPOCH: 256 + +# DENEB +DENEB_FORK_VERSION: 0x40017000 +DENEB_FORK_EPOCH: 18446744073709551615 + +# Time parameters +# --------------------------------------------------------------- +# 12 seconds +SECONDS_PER_SLOT: 12 +# 14 (estimate from Eth1 mainnet) +SECONDS_PER_ETH1_BLOCK: 14 +# 2**8 (= 256) epochs ~27 hours +MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256 +# 2**8 (= 256) epochs ~27 hours +SHARD_COMMITTEE_PERIOD: 256 +# 2**11 (= 2,048) Eth1 blocks ~8 hours +ETH1_FOLLOW_DISTANCE: 2048 + + +# Validator cycle +# --------------------------------------------------------------- +# 2**2 (= 4) +INACTIVITY_SCORE_BIAS: 4 +# 2**4 (= 16) +INACTIVITY_SCORE_RECOVERY_RATE: 16 +# 28,000,000,000 Gwei to ensure quicker ejection +EJECTION_BALANCE: 28000000000 +# 2**2 (= 4) +MIN_PER_EPOCH_CHURN_LIMIT: 4 +# 2**16 (= 65,536) +CHURN_LIMIT_QUOTIENT: 65536 + +# Fork choice +# --------------------------------------------------------------- +# 40% +PROPOSER_SCORE_BOOST: 40 + +# Deposit contract +# --------------------------------------------------------------- +DEPOSIT_CHAIN_ID: 17000 +DEPOSIT_NETWORK_ID: 17000 +DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242 + +# Networking +# --------------------------------------------------------------- +# `10 * 2**20` (= 10485760, 10 MiB) +GOSSIP_MAX_SIZE: 10485760 +# `2**10` (= 1024) +MAX_REQUEST_BLOCKS: 1024 +# `2**8` (= 256) +EPOCHS_PER_SUBNET_SUBSCRIPTION: 256 +# `MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2` (= 33024, ~5 months) +MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024 +# `10 * 2**20` (=10485760, 10 MiB) +MAX_CHUNK_SIZE: 10485760 +# 5s +TTFB_TIMEOUT: 5 +# 10s +RESP_TIMEOUT: 10 +ATTESTATION_PROPAGATION_SLOT_RANGE: 32 +# 500ms +MAXIMUM_GOSSIP_CLOCK_DISPARITY: 500 +MESSAGE_DOMAIN_INVALID_SNAPPY: 0x00000000 +MESSAGE_DOMAIN_VALID_SNAPPY: 0x01000000 +# 2 subnets per node +SUBNETS_PER_NODE: 2 +# 2**8 (= 64) +ATTESTATION_SUBNET_COUNT: 64 +ATTESTATION_SUBNET_EXTRA_BITS: 0 +# ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS +ATTESTATION_SUBNET_PREFIX_BITS: 6 + +# Deneb +# `2**7` (=128) +MAX_REQUEST_BLOCKS_DENEB: 128 +# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK +MAX_REQUEST_BLOB_SIDECARS: 768 +# `2**12` (= 4096 epochs, ~18 days) +MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096 +# `6` +BLOB_SIDECAR_SUBNET_COUNT: 6 +# `uint64(6)` +MAX_BLOBS_PER_BLOCK: 6 \ No newline at end of file diff --git a/config/holesky.names.yml b/config/holesky.names.yml new file mode 100644 index 00000000..e62ba751 --- /dev/null +++ b/config/holesky.names.yml @@ -0,0 +1,42 @@ + +0-9999: "google_cloud" +10000-19999: "arnetheduck" +20000-69999: "attestant" +70000-89999: "chainbase" +90000-99999: "chainstack" +100000-199999: "teku" +200000-219999: "cryptomanufaktur" +220000-269999: "ef_devops" +270000-279999: "ef_security" +280000-284999: "erigon" +285000-324999: "ethstaker" +325000-344999: "goerli-afri" +345000-394999: "grandine" +395000-494999: "besu" +495000-594999: "kiln" +595000-694999: "lighthouse" +695000-794999: "lodestar" +795000-894999: "nethermind" +895000-994999: "nimbus" +995000-1094999: "p2p.org" +1095000-1104999: "protolambda" +1105000-1204999: "prysm" +1205000-1209999: "ralexstokes" +1210000-1309999: "rockawayx" +#1310000-1359999: "rocket_pool" +1310000-1314999: "rp-rocknet" +1315000-1318299: "rp-invis" +1318300-1320347: "rp-ramana" +1320348-1325347: "rp-peteris" +1325348-1330347: "rp-yokem" +1330348-1332847: "rp-haurog" +1332848-1336147: "rp-florange" +1336148-1339147: "rp-pk910" +1339148-1342447: "rp-sters" +1342448-1345747: "rp-vacalaranja" +1345748-1349047: "rp-patches" +1349048-1352347: "rp-faisalm" +1352348-1357347: "rp-object" +1357348-1359999: "rp-other" +1360000-1409999: "rockx" +1410000-1459999: "stakely" diff --git a/config/sepolia.names.yml b/config/sepolia.names.yml new file mode 100644 index 00000000..d9d99814 --- /dev/null +++ b/config/sepolia.names.yml @@ -0,0 +1,24 @@ + +0-99: "ef_devops" +100-199: "nethermind" +200-299: "besu" +300-399: "erigon" +400-499: "lighthouse" +500-599: "teku" +600-699: "nimbus" +700-799: "lodestar" +800-899: "prysm" +900-999: "attestant" +1000-1099: "q9f" +1100-1199: "lightclient" +1200-1299: "kiln.fi" +1300-1399: "ralexstokes" +1400-1499: "simply staking" +1500-1549: "ef_security" +1550-1569: "ef_devops" +1570-1572: "attestant" +1573-1672: "blox staking" +1673-1772: "missing keys" +1773-1779: "staked.us" +1780-1879: "obol network" +1880-1972: "staked.us" diff --git a/services/validatornames.go b/services/validatornames.go index caa9b968..f8a38c8c 100644 --- a/services/validatornames.go +++ b/services/validatornames.go @@ -12,6 +12,7 @@ import ( "sync" "time" + "github.com/pk910/light-beaconchain-explorer/config" "github.com/pk910/light-beaconchain-explorer/db" "github.com/pk910/light-beaconchain-explorer/dbtypes" "github.com/pk910/light-beaconchain-explorer/utils" @@ -53,7 +54,12 @@ func (vn *ValidatorNames) LoadValidatorNames() { vn.namesMutex.Unlock() // load names - if utils.Config.Frontend.ValidatorNamesYaml != "" { + if strings.HasPrefix(utils.Config.Frontend.ValidatorNamesYaml, "~internal/") { + err := vn.loadFromInternalYaml(utils.Config.Frontend.ValidatorNamesYaml[10:]) + if err != nil { + logger_vn.WithError(err).Errorf("error while loading validator names from internal yaml") + } + } else if utils.Config.Frontend.ValidatorNamesYaml != "" { err := vn.loadFromYaml(utils.Config.Frontend.ValidatorNamesYaml) if err != nil { logger_vn.WithError(err).Errorf("error while loading validator names from yaml") @@ -80,6 +86,7 @@ func (vn *ValidatorNames) loadFromYaml(fileName string) error { if err != nil { return fmt.Errorf("error opening validator names file %v: %v", fileName, err) } + defer f.Close() namesYaml := map[string]string{} decoder := yaml.NewDecoder(f) @@ -88,10 +95,36 @@ func (vn *ValidatorNames) loadFromYaml(fileName string) error { return fmt.Errorf("error decoding validator names file %v: %v", fileName, err) } + nameCount := vn.parseNamesMap(namesYaml) + logger_vn.Infof("loaded %v validator names from yaml (%v)", nameCount, fileName) + + return nil +} + +func (vn *ValidatorNames) loadFromInternalYaml(fileName string) error { + f, err := config.ValidatorNamesYml.Open(fileName) + if err != nil { + return fmt.Errorf("could not find internal validator names file %v: %v", fileName, err) + } + + namesYaml := map[string]string{} + decoder := yaml.NewDecoder(f) + err = decoder.Decode(&namesYaml) + if err != nil { + return fmt.Errorf("could not find internal validator names file %v: %v", fileName, err) + } + + nameCount := vn.parseNamesMap(namesYaml) + logger_vn.Infof("loaded %v validator names from internal yaml (%v)", nameCount, fileName) + + return nil +} + +func (vn *ValidatorNames) parseNamesMap(names map[string]string) int { vn.namesMutex.Lock() defer vn.namesMutex.Unlock() nameCount := 0 - for idxStr, name := range namesYaml { + for idxStr, name := range names { rangeParts := strings.Split(idxStr, "-") minIdx, err := strconv.ParseUint(rangeParts[0], 10, 64) if err != nil { @@ -109,9 +142,7 @@ func (vn *ValidatorNames) loadFromYaml(fileName string) error { nameCount++ } } - logger_vn.Infof("loaded %v validator names from yaml (%v)", nameCount, fileName) - - return nil + return nameCount } type validatorNamesRangesResponse struct { diff --git a/utils/config.go b/utils/config.go index dbd5a6bc..9e24017b 100644 --- a/utils/config.go +++ b/utils/config.go @@ -39,6 +39,8 @@ func ReadConfig(cfg *types.Config, path string) error { err = yaml.Unmarshal([]byte(config.PraterChainYml), &chainConfig) case "sepolia": err = yaml.Unmarshal([]byte(config.SepoliaChainYml), &chainConfig) + case "holesky": + err = yaml.Unmarshal([]byte(config.HoleskyChainYml), &chainConfig) default: return fmt.Errorf("tried to set known chain-config, but unknown chain-name") } @@ -113,6 +115,16 @@ func ReadConfig(cfg *types.Config, path string) error { } } + // default validator names + if cfg.Frontend.ValidatorNamesYaml == "" && cfg.Frontend.ValidatorNamesInventory == "" { + switch cfg.Chain.Name { + case "sepolia": + cfg.Frontend.ValidatorNamesYaml = "~internal/sepolia.names.yml" + case "holesky": + cfg.Frontend.ValidatorNamesYaml = "~internal/holesky.names.yml" + } + } + // endpoints if cfg.BeaconApi.Endpoints == nil && cfg.BeaconApi.Endpoint != "" { cfg.BeaconApi.Endpoints = []types.EndpointConfig{