mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-16 08:26:37 +00:00
* Support for driving multiple EL nodes from a single Nimbus BN Full list of changes: * Eth1Monitor has been renamed to ELManager to match its current responsibilities better. * The ELManager is no longer optional in the code (it won't have a nil value under any circumstances). * The support for subscribing for headers was removed as it only worked with WebSockets and contributed significant complexity while bringing only a very minor advantage. * The `--web3-url` parameter has been deprecated in favor of a new `--el` parameter. The new parameter has a reasonable default value and supports specifying a different JWT for each connection. Each connection can also be configured with a different set of responsibilities (e.g. download deposits, validate blocks and/or produce blocks). On the command-line, these properties can be configured through URL properties stored in the #anchor part of the URL. In TOML files, they come with a very natural syntax (althrough the URL scheme is also supported). * The previously scattered EL-related state and logic is now moved to `eth1_monitor.nim` (this module will be renamed to `el_manager.nim` in a follow-up commit). State is assigned properly either to the `ELManager` or the to individual `ELConnection` objects where appropriate. The ELManager executes all Engine API requests against all attached EL nodes, in parallel. It compares their results and if there is a disagreement regarding the validity of a certain payload, this is detected and the beacon node is protected from publishing a block with a potential execution layer consensus bug in it. The BN provides metrics per EL node for the number of successful or failed requests for each type Engine API requests. If an EL node goes offline and connectivity is resoted later, we report the problem and the remedy in edge-triggered fashion. * More progress towards implementing Deneb block production in the VC and comparing the value of blocks produced by the EL and the builder API. * Adds a Makefile target for the zhejiang testnet
74 lines
2.3 KiB
Nim
74 lines
2.3 KiB
Nim
import
|
|
std/[json, strutils, times, sequtils],
|
|
chronos, confutils, chronicles,
|
|
web3, web3/ethtypes as web3Types,
|
|
eth/async_utils,
|
|
../beacon_chain/beacon_chain_db,
|
|
../beacon_chain/networking/network_metadata,
|
|
../beacon_chain/eth1/eth1_monitor,
|
|
../beacon_chain/spec/[presets, helpers]
|
|
|
|
type
|
|
CliFlags = object
|
|
network {.
|
|
defaultValue: "mainnet"
|
|
name: "network".}: string
|
|
elUrls {.
|
|
name: "el".}: seq[EngineApiUrlConfigValue]
|
|
jwtSecret {.
|
|
name: "jwt-secret".}: Option[InputFile]
|
|
outDepositsFile {.
|
|
name: "out-deposits-file".}: Option[OutFile]
|
|
|
|
proc main(flags: CliFlags) {.async.} =
|
|
let
|
|
db = BeaconChainDB.new("", inMemory = true)
|
|
metadata = getMetadataForNetwork(flags.network)
|
|
beaconTimeFn = proc(): BeaconTime =
|
|
# BEWARE of this hack
|
|
# The EL manager consults the current time in order to determine when the
|
|
# transition configuration exchange should start. We assume Bellatrix has
|
|
# just arrived which should trigger the configuration exchange and allow
|
|
# the downloader to connect to ELs serving the Engine API.
|
|
start_beacon_time(Slot(metadata.cfg.BELLATRIX_FORK_EPOCH * SLOTS_PER_EPOCH))
|
|
|
|
let
|
|
elManager = ELManager.new(
|
|
metadata.cfg,
|
|
metadata.depositContractBlock,
|
|
metadata.depositContractBlockHash,
|
|
db,
|
|
toFinalEngineApiUrls(flags.elUrls, flags.jwtSecret),
|
|
eth1Network = metadata.eth1Network)
|
|
|
|
elManager.start()
|
|
|
|
var depositsFile: File
|
|
if flags.outDepositsFile.isSome:
|
|
depositsFile = open(string flags.outDepositsFile.get, fmWrite)
|
|
depositsFile.write(
|
|
"block", ",",
|
|
"validatorKey", ",",
|
|
"withdrawalCredentials", "\n")
|
|
depositsFile.flushFile()
|
|
|
|
var blockIdx = 0
|
|
while not elManager.isSynced():
|
|
await sleepAsync chronos.seconds(1)
|
|
|
|
if flags.outDepositsFile.isSome and
|
|
elManager.eth1ChainBlocks.len > blockIdx:
|
|
for i in blockIdx ..< elManager.eth1ChainBlocks.len:
|
|
for deposit in elManager.eth1ChainBlocks[i].deposits:
|
|
depositsFile.write(
|
|
$elManager.eth1ChainBlocks[i].number, ",",
|
|
$deposit.pubkey, ",",
|
|
$deposit.withdrawal_credentials, "\n")
|
|
depositsFile.flushFile()
|
|
|
|
blockIdx = elManager.eth1ChainBlocks.len
|
|
|
|
info "All deposits downloaded"
|
|
|
|
waitFor main(load CliFlags)
|