2021-03-26 06:52:01 +00:00
|
|
|
# beacon_chain
|
2022-02-21 11:55:56 +00:00
|
|
|
# Copyright (c) 2018-2022 Status Research & Development GmbH
|
2021-02-02 22:31:01 +00:00
|
|
|
# Licensed and distributed under either of
|
|
|
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
|
|
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
|
|
|
|
2021-03-26 06:52:01 +00:00
|
|
|
{.push raises: [Defect].}
|
|
|
|
|
2020-07-02 15:14:11 +00:00
|
|
|
import
|
2021-10-12 11:36:52 +00:00
|
|
|
std/[sequtils, strutils, os],
|
2020-07-09 22:08:54 +00:00
|
|
|
stew/shims/macros, nimcrypto/hash,
|
2020-11-12 19:01:26 +00:00
|
|
|
eth/common/eth_types as commonEthTypes,
|
2020-07-09 22:08:54 +00:00
|
|
|
web3/[ethtypes, conversions],
|
2020-09-01 09:01:57 +00:00
|
|
|
chronicles,
|
2021-03-26 14:11:06 +00:00
|
|
|
eth/common/eth_types_json_serialization,
|
2021-10-21 20:27:06 +00:00
|
|
|
ssz_serialization/navigator,
|
2021-08-18 18:57:58 +00:00
|
|
|
../spec/eth2_ssz_serialization,
|
2021-08-12 13:08:20 +00:00
|
|
|
../spec/datatypes/phase0
|
2020-07-02 15:14:11 +00:00
|
|
|
|
|
|
|
# ATTENTION! This file will produce a large C file, because we are inlining
|
|
|
|
# genesis states as C literals in the generated code (and blobs in the final
|
|
|
|
# binary). It makes sense to keep the file small and separated from the rest
|
|
|
|
# of the module in order go gain maximum efficiency in incremental compilation.
|
|
|
|
#
|
2020-11-10 18:41:04 +00:00
|
|
|
# TODO(zah):
|
2020-07-02 15:14:11 +00:00
|
|
|
# We can compress the embedded states with snappy before embedding them here.
|
|
|
|
|
|
|
|
export
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
ethtypes, conversions, RuntimeConfig
|
2020-07-02 15:14:11 +00:00
|
|
|
|
|
|
|
type
|
2020-07-09 22:08:54 +00:00
|
|
|
Eth1BlockHash* = ethtypes.BlockHash
|
2020-07-02 15:14:11 +00:00
|
|
|
|
|
|
|
Eth1Network* = enum
|
|
|
|
mainnet
|
|
|
|
rinkeby
|
|
|
|
goerli
|
|
|
|
|
|
|
|
Eth2NetworkMetadata* = object
|
2020-07-09 22:08:54 +00:00
|
|
|
case incompatible*: bool
|
|
|
|
of false:
|
2020-11-06 21:45:56 +00:00
|
|
|
# TODO work-around a Nim codegen issue where upon constant assignment
|
|
|
|
# the compiler will copy `incompatibilityDesc` even when the case
|
|
|
|
# branch is not active and thus it will override the first variable
|
|
|
|
# in this branch.
|
|
|
|
dummy: string
|
2021-09-08 12:47:48 +00:00
|
|
|
# If the eth1Network is specified, the Eth1Monitor will perform some
|
|
|
|
# additional checks to ensure we are connecting to a web3 provider
|
|
|
|
# serving data for the same network. The value can be set to `None`
|
|
|
|
# for custom networks and testing purposes.
|
2020-07-09 22:08:54 +00:00
|
|
|
eth1Network*: Option[Eth1Network]
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
cfg*: RuntimeConfig
|
2020-07-09 22:08:54 +00:00
|
|
|
|
|
|
|
# Parsing `enr.Records` is still not possible at compile-time
|
|
|
|
bootstrapNodes*: seq[string]
|
|
|
|
|
2020-11-12 19:01:26 +00:00
|
|
|
depositContractDeployedAt*: BlockHashOrNumber
|
2020-07-09 22:08:54 +00:00
|
|
|
|
|
|
|
# Please note that we are using `string` here because SSZ.decode
|
|
|
|
# is not currently usable at compile time and we want to load the
|
|
|
|
# network metadata into a constant.
|
|
|
|
#
|
|
|
|
# We could have also used `seq[byte]`, but this results in a lot
|
|
|
|
# more generated code that slows down compilation. The impact on
|
|
|
|
# compilation times of embedding the genesis as a string is roughly
|
|
|
|
# 0.1s on my machine (you can test this by choosing an invalid name
|
|
|
|
# for the genesis file below).
|
|
|
|
#
|
|
|
|
# `genesisData` will have `len == 0` for networks with a still
|
|
|
|
# unknown genesis state.
|
|
|
|
genesisData*: string
|
2020-11-24 21:21:47 +00:00
|
|
|
genesisDepositsSnapshot*: string
|
2020-07-09 22:08:54 +00:00
|
|
|
else:
|
|
|
|
incompatibilityDesc*: string
|
2020-07-02 15:14:11 +00:00
|
|
|
|
2020-11-24 21:21:47 +00:00
|
|
|
const
|
2021-07-13 14:27:10 +00:00
|
|
|
eth2NetworksDir = currentSourcePath.parentDir.replace('\\', '/') & "/../../vendor/eth2-networks"
|
2020-11-24 21:21:47 +00:00
|
|
|
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
proc readBootstrapNodes*(path: string): seq[string] {.raises: [IOError, Defect].} =
|
|
|
|
# Read a list of ENR values from a YAML file containing a flat list of entries
|
|
|
|
if fileExists(path):
|
|
|
|
splitLines(readFile(path)).
|
|
|
|
filterIt(it.startsWith("enr:")).
|
|
|
|
mapIt(it.strip())
|
|
|
|
else:
|
|
|
|
@[]
|
|
|
|
|
|
|
|
proc readBootEnr*(path: string): seq[string] {.raises: [IOError, Defect].} =
|
|
|
|
# Read a list of ENR values from a YAML file containing a flat list of entries
|
|
|
|
if fileExists(path):
|
|
|
|
splitLines(readFile(path)).
|
|
|
|
filterIt(it.startsWith("- enr:")).
|
|
|
|
mapIt(it[2..^1].strip())
|
|
|
|
else:
|
|
|
|
@[]
|
2020-07-03 19:29:23 +00:00
|
|
|
|
2020-07-02 15:14:11 +00:00
|
|
|
proc loadEth2NetworkMetadata*(path: string): Eth2NetworkMetadata
|
|
|
|
{.raises: [CatchableError, Defect].} =
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
# Load data in eth2-networks format
|
|
|
|
# https://github.com/eth2-clients/eth2-networks/
|
|
|
|
|
2020-07-09 22:08:54 +00:00
|
|
|
try:
|
|
|
|
let
|
2021-02-02 22:31:01 +00:00
|
|
|
genesisPath = path & "/genesis.ssz"
|
|
|
|
genesisDepositsSnapshotPath = path & "/genesis_deposit_contract_snapshot.ssz"
|
|
|
|
configPath = path & "/config.yaml"
|
|
|
|
depositContractBlockPath = path & "/deposit_contract_block.txt"
|
|
|
|
bootstrapNodesPath = path & "/bootstrap_nodes.txt"
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
bootEnrPath = path & "/boot_enr.yaml"
|
|
|
|
|
|
|
|
runtimeConfig = if fileExists(configPath):
|
|
|
|
let (cfg, unknowns) = readRuntimeConfig(configPath)
|
|
|
|
if unknowns.len > 0:
|
|
|
|
when nimvm:
|
|
|
|
# TODO better printing
|
|
|
|
echo "Unknown constants in file: " & unknowns
|
|
|
|
else:
|
|
|
|
warn "Unknown constants in config file", unknowns
|
|
|
|
cfg
|
2020-07-10 14:31:24 +00:00
|
|
|
else:
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
defaultRuntimeConfig
|
2020-07-10 14:31:24 +00:00
|
|
|
|
|
|
|
depositContractBlock = if fileExists(depositContractBlockPath):
|
2020-07-28 13:36:11 +00:00
|
|
|
readFile(depositContractBlockPath).strip
|
2020-07-10 14:31:24 +00:00
|
|
|
else:
|
2020-07-28 13:36:11 +00:00
|
|
|
""
|
2020-07-10 14:31:24 +00:00
|
|
|
|
2020-11-12 19:01:26 +00:00
|
|
|
depositContractDeployedAt = if depositContractBlock.len > 0:
|
|
|
|
BlockHashOrNumber.init(depositContractBlock)
|
|
|
|
else:
|
|
|
|
BlockHashOrNumber(isHash: false, number: 1)
|
|
|
|
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
bootstrapNodes = deduplicate(
|
|
|
|
readBootstrapNodes(bootstrapNodesPath) &
|
|
|
|
readBootEnr(bootEnrPath))
|
2020-07-28 10:46:22 +00:00
|
|
|
|
2020-11-24 21:21:47 +00:00
|
|
|
genesisData = if fileExists(genesisPath):
|
|
|
|
readFile(genesisPath)
|
|
|
|
else:
|
|
|
|
""
|
|
|
|
|
|
|
|
genesisDepositsSnapshot = if fileExists(genesisDepositsSnapshotPath):
|
|
|
|
readFile(genesisDepositsSnapshotPath)
|
|
|
|
else:
|
|
|
|
""
|
2020-07-09 22:08:54 +00:00
|
|
|
|
|
|
|
Eth2NetworkMetadata(
|
|
|
|
incompatible: false,
|
2021-08-25 18:10:54 +00:00
|
|
|
eth1Network: some(
|
|
|
|
if "mainnet" in path: Eth1Network.mainnet else: Eth1Network.goerli),
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
cfg: runtimeConfig,
|
2020-07-28 10:46:22 +00:00
|
|
|
bootstrapNodes: bootstrapNodes,
|
2020-11-12 19:01:26 +00:00
|
|
|
depositContractDeployedAt: depositContractDeployedAt,
|
2020-11-24 21:21:47 +00:00
|
|
|
genesisData: genesisData,
|
|
|
|
genesisDepositsSnapshot: genesisDepositsSnapshot)
|
2020-07-10 14:31:24 +00:00
|
|
|
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
except PresetIncompatibleError as err:
|
2020-07-09 22:08:54 +00:00
|
|
|
Eth2NetworkMetadata(incompatible: true,
|
|
|
|
incompatibilityDesc: err.msg)
|
2020-07-02 15:14:11 +00:00
|
|
|
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
template eth2Network(path: string): Eth2NetworkMetadata =
|
2021-07-13 14:27:10 +00:00
|
|
|
loadEth2NetworkMetadata(eth2NetworksDir & "/" & path)
|
2020-07-28 15:14:13 +00:00
|
|
|
|
2020-09-21 14:19:34 +00:00
|
|
|
const
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
mainnetMetadata* = eth2Network "shared/mainnet"
|
|
|
|
pyrmontMetadata* = eth2Network "shared/pyrmont"
|
|
|
|
praterMetadata* = eth2Network "shared/prater"
|
2020-07-10 14:31:24 +00:00
|
|
|
|
2021-06-16 12:45:05 +00:00
|
|
|
proc getMetadataForNetwork*(networkName: string): Eth2NetworkMetadata {.raises: [Defect, IOError].} =
|
2021-05-31 15:23:13 +00:00
|
|
|
var
|
2020-09-01 09:01:57 +00:00
|
|
|
metadata = case toLowerAscii(networkName)
|
|
|
|
of "mainnet":
|
|
|
|
mainnetMetadata
|
2020-11-12 19:50:49 +00:00
|
|
|
of "pyrmont":
|
|
|
|
pyrmontMetadata
|
2021-03-15 19:49:53 +00:00
|
|
|
of "prater":
|
|
|
|
praterMetadata
|
2020-09-01 09:01:57 +00:00
|
|
|
else:
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
if fileExists(networkName / "config.yaml"):
|
2020-09-01 09:01:57 +00:00
|
|
|
try:
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
loadEth2NetworkMetadata(networkName)
|
|
|
|
except CatchableError as exc:
|
|
|
|
fatal "Cannot load network", msg = exc.msg, networkName
|
2020-09-01 09:01:57 +00:00
|
|
|
quit 1
|
|
|
|
else:
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
fatal "config.yaml not found for network", networkName
|
2020-09-01 09:01:57 +00:00
|
|
|
quit 1
|
|
|
|
|
|
|
|
if metadata.incompatible:
|
|
|
|
fatal "The selected network is not compatible with the current build",
|
|
|
|
reason = metadata.incompatibilityDesc
|
|
|
|
quit 1
|
2022-02-21 11:55:56 +00:00
|
|
|
metadata
|
2020-09-01 09:01:57 +00:00
|
|
|
|
2021-07-13 14:27:10 +00:00
|
|
|
proc getRuntimeConfig*(
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
eth2Network: Option[string]): RuntimeConfig {.raises: [Defect, IOError].} =
|
2020-09-01 09:01:57 +00:00
|
|
|
if eth2Network.isSome:
|
Implement split preset/config support (#2710)
* Implement split preset/config support
This is the initial bulk refactor to introduce runtime config values in
a number of places, somewhat replacing the existing mechanism of loading
network metadata.
It still needs more work, this is the initial refactor that introduces
runtime configuration in some of the places that need it.
The PR changes the way presets and constants work, to match the spec. In
particular, a "preset" now refers to the compile-time configuration
while a "cfg" or "RuntimeConfig" is the dynamic part.
A single binary can support either mainnet or minimal, but not both.
Support for other presets has been removed completely (can be readded,
in case there's need).
There's a number of outstanding tasks:
* `SECONDS_PER_SLOT` still needs fixing
* loading custom runtime configs needs redoing
* checking constants against YAML file
* yeerongpilly support
`build/nimbus_beacon_node --network=yeerongpilly --discv5:no --log-level=DEBUG`
* load fork epoch from config
* fix fork digest sent in status
* nicer error string for request failures
* fix tools
* one more
* fixup
* fixup
* fixup
* use "standard" network definition folder in local testnet
Files are loaded from their standard locations, including genesis etc,
to conform to the format used in the `eth2-networks` repo.
* fix launch scripts, allow unknown config values
* fix base config of rest test
* cleanups
* bundle mainnet config using common loader
* fix spec links and names
* only include supported preset in binary
* drop yeerongpilly, add altair-devnet-0, support boot_enr.yaml
2021-07-12 13:01:38 +00:00
|
|
|
return getMetadataForNetwork(eth2Network.get).cfg
|
2022-02-21 11:55:56 +00:00
|
|
|
defaultRuntimeConfig
|
2020-11-27 19:48:33 +00:00
|
|
|
|
2021-12-14 15:44:34 +00:00
|
|
|
proc extractGenesisValidatorRootFromSnapshot*(
|
2021-06-16 12:45:05 +00:00
|
|
|
snapshot: string): Eth2Digest {.raises: [Defect, IOError, SszError].} =
|
2021-08-12 13:08:20 +00:00
|
|
|
sszMount(snapshot, phase0.BeaconState).genesis_validators_root[]
|