mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-26 03:59:52 +00:00
small repairs and additions
This commit is contained in:
parent
7b15c09b45
commit
79aa0fb46e
@ -8,8 +8,10 @@
|
|||||||
[![Status: #nimbus-general](https://img.shields.io/badge/status-nimbus--general-orange.svg)](https://join.status.im/nimbus-general)
|
[![Status: #nimbus-general](https://img.shields.io/badge/status-nimbus--general-orange.svg)](https://join.status.im/nimbus-general)
|
||||||
|
|
||||||
|
|
||||||
|
# NOTE - whole document to be concluded...
|
||||||
|
|
||||||
# description
|
# description
|
||||||
Nimbus Unified combines Ethereum execution and consensus layer functionalities, featuring a fully integrated beacon node), validator duties, and execution layer support. This setup allows the Nimbus client to handle both Ethereum consensus (Eth2) and execution (Eth1) tasks within a single package.
|
Nimbus Unified combines Ethereum execution and consensus layer functionalities, featuring a fully integrated beacon node, validator duties, and execution layer support. This setup allows the Nimbus client to handle both Ethereum consensus (Eth2) and execution (Eth1) tasks within a single package.
|
||||||
|
|
||||||
--> meh, requires improvement
|
--> meh, requires improvement
|
||||||
# documentation
|
# documentation
|
||||||
@ -45,4 +47,4 @@ or
|
|||||||
|
|
||||||
* Apache License, Version 2.0: [LICENSE-APACHEv2](LICENSE-APACHEv2) or https://www.apache.org/licenses/LICENSE-2.0
|
* Apache License, Version 2.0: [LICENSE-APACHEv2](LICENSE-APACHEv2) or https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
at your option. These files may not be copied, modified, or distributed except according to those terms.
|
These files may not be copied, modified, or distributed except according to those terms.
|
||||||
|
@ -12,7 +12,8 @@ type NimbusTasksError* = object of CatchableError
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
## TODO: implement a json (or other format like yaml) config reader for config reading (file config scenarios)
|
## TODO: implement a json (or other format like yaml) config reader for config reading (file config scenarios)
|
||||||
## TODO: implement a command line reader to read arguments
|
## 1) implement a command line reader to read arguments
|
||||||
|
## 2) good option to adhere to other projects conventions and use the in place support to read and load
|
||||||
type NimbusConfig* = object
|
type NimbusConfig* = object
|
||||||
configTable: Table[string, string]
|
configTable: Table[string, string]
|
||||||
|
|
||||||
@ -20,16 +21,19 @@ type NimbusConfig* = object
|
|||||||
type TaskParameters* = object
|
type TaskParameters* = object
|
||||||
name*: string
|
name*: string
|
||||||
configs*: string
|
configs*: string
|
||||||
beaconNodeConfigs*: BeaconNodeConf
|
beaconNodeConfigs*: BeaconNodeConf #
|
||||||
# TODO: replace this with the extracted configs from NimbusConfig needed by the worker
|
|
||||||
|
|
||||||
## Task shutdown flag
|
## Task shutdown flag
|
||||||
|
##
|
||||||
## The behaviour required: this thread needs to atomically change the flag value when
|
## The behaviour required: this thread needs to atomically change the flag value when
|
||||||
## a shutdown is required or when detects a stopped thread.
|
## a shutdown is required or when detects a stopped thread.
|
||||||
|
##
|
||||||
## Given the behaviour wanted, atomic operations are sufficient without barriers or fences. Compilers
|
## Given the behaviour wanted, atomic operations are sufficient without barriers or fences. Compilers
|
||||||
## may reorder instructions, but given that the order is not important, this does not affect
|
## may reorder instructions, but given that the order is not important, this does not affect
|
||||||
## the semantic wanted: If instructions are reordered, the worker will fail to read on the current iteration
|
## the semantic wanted: If instructions are reordered, the worker will fail to read on the current iteration
|
||||||
## but will read it correctly on the next iteration ( this thread is the only on which changes the flag behaviour,
|
## but will read it correctly on the next iteration ( this thread is the only on which changes the flag behaviour,
|
||||||
## and will always change it to true)
|
## and will always change it to true)
|
||||||
|
##
|
||||||
|
## With this we avoid the overhead of locks
|
||||||
var isShutDownRequired*: Atomic[bool]
|
var isShutDownRequired*: Atomic[bool]
|
||||||
isShutDownRequired.store(false)
|
isShutDownRequired.store(false)
|
||||||
|
@ -23,7 +23,7 @@ logScope:
|
|||||||
topics = "Consensus layer"
|
topics = "Consensus layer"
|
||||||
|
|
||||||
## following procedures are copies from nimbus_beacon_node.nim.
|
## following procedures are copies from nimbus_beacon_node.nim.
|
||||||
## TODO: extract from that file into a common file
|
## TODO: if possible, extract from that file into a common file
|
||||||
|
|
||||||
## runs beacon node
|
## runs beacon node
|
||||||
## adapted from nimbus-eth2
|
## adapted from nimbus-eth2
|
||||||
@ -62,6 +62,7 @@ proc doRunBeaconNode(
|
|||||||
# except Exception as exc:
|
# except Exception as exc:
|
||||||
# raiseAssert exc.msg # TODO fix metrics
|
# raiseAssert exc.msg # TODO fix metrics
|
||||||
|
|
||||||
|
## adapted/copied from nimbus-eth2
|
||||||
proc fetchGenesisState(
|
proc fetchGenesisState(
|
||||||
metadata: Eth2NetworkMetadata,
|
metadata: Eth2NetworkMetadata,
|
||||||
genesisState = none(InputFile),
|
genesisState = none(InputFile),
|
||||||
@ -96,6 +97,7 @@ proc fetchGenesisState(
|
|||||||
else:
|
else:
|
||||||
nil
|
nil
|
||||||
|
|
||||||
|
## adapted/copied from nimbus-eth2
|
||||||
proc doRunTrustedNodeSync(
|
proc doRunTrustedNodeSync(
|
||||||
db: BeaconChainDB,
|
db: BeaconChainDB,
|
||||||
metadata: Eth2NetworkMetadata,
|
metadata: Eth2NetworkMetadata,
|
||||||
@ -138,7 +140,7 @@ proc consensusWrapper*(parameters: TaskParameters) {.raises: [CatchableError].}
|
|||||||
doRunBeaconNode(config, rng)
|
doRunBeaconNode(config, rng)
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
fatal "error", message = e.msg
|
fatal "error", message = e.msg
|
||||||
quit 1
|
# TODO: we need to create an dedicated atomic asking task manager to join threads
|
||||||
|
|
||||||
let
|
let
|
||||||
metadata = loadEth2Network(config)
|
metadata = loadEth2Network(config)
|
||||||
@ -149,16 +151,18 @@ proc consensusWrapper*(parameters: TaskParameters) {.raises: [CatchableError].}
|
|||||||
waitFor(
|
waitFor(
|
||||||
db.doRunTrustedNodeSync(
|
db.doRunTrustedNodeSync(
|
||||||
metadata, config.databaseDir, config.eraDir, "http://127.0.0.1:5052",
|
metadata, config.databaseDir, config.eraDir, "http://127.0.0.1:5052",
|
||||||
config.stateId, config.lcTrustedBlockRoot, config.backfillBlocks, config.reindex,
|
config.stateId, config.lcTrustedBlockRoot, config.backfillBlocks,
|
||||||
config.downloadDepositSnapshot, genesisState,
|
config.reindex, config.downloadDepositSnapshot, genesisState,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
except CatchableError as e:
|
except CatchableError as e:
|
||||||
fatal "error", message = e.msg
|
# TODO: we need to create an dedicated atomic asking task manager to join threads
|
||||||
quit 1
|
fatal "error", message = e.MsgSource
|
||||||
|
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
# TODO: nice to start creating some binary launch scripts
|
||||||
|
|
||||||
# --web3-url=http://127.0.0.1:8551 --jwt-secret=/tmp/jwtsecret --log-level=TRACE
|
# --web3-url=http://127.0.0.1:8551 --jwt-secret=/tmp/jwtsecret --log-level=TRACE
|
||||||
# --network=${NETWORK} \
|
# --network=${NETWORK} \
|
||||||
# --data-dir="${DATA_DIR}" \
|
# --data-dir="${DATA_DIR}" \
|
||||||
|
@ -15,12 +15,10 @@ import
|
|||||||
beacon_chain/[beacon_chain_db]
|
beacon_chain/[beacon_chain_db]
|
||||||
|
|
||||||
## Constants
|
## Constants
|
||||||
|
## TODO: evaluate the proposed timeouts with team
|
||||||
const cNimbusMaxTasks* = 5
|
const cNimbusMaxTasks* = 5
|
||||||
const cNimbusTaskTimeoutMs* = 5000
|
const cNimbusTaskTimeoutMs* = 5000
|
||||||
|
|
||||||
## Exceptions
|
|
||||||
type NimbusTasksError* = object of CatchableError
|
|
||||||
|
|
||||||
## Task and associated task information
|
## Task and associated task information
|
||||||
type NimbusTask* = ref object
|
type NimbusTask* = ref object
|
||||||
name*: string
|
name*: string
|
||||||
@ -99,7 +97,12 @@ proc addNewTask*(
|
|||||||
|
|
||||||
if currentIndex < 0:
|
if currentIndex < 0:
|
||||||
raise newException(NimbusTasksError, "No free slots on Nimbus Tasks")
|
raise newException(NimbusTasksError, "No free slots on Nimbus Tasks")
|
||||||
createThread(tasks.taskList[currentIndex].threadHandler, taskHandler, parameters)
|
try:
|
||||||
|
createThread(tasks.taskList[currentIndex].threadHandler, taskHandler, parameters)
|
||||||
|
except CatchableError as e:
|
||||||
|
# TODO: joinThreads
|
||||||
|
fatal "error creating task (thread)", msg=e.msg
|
||||||
|
|
||||||
info "Created task:", task = tasks.taskList[currentIndex].name
|
info "Created task:", task = tasks.taskList[currentIndex].name
|
||||||
|
|
||||||
## Task monitoring
|
## Task monitoring
|
||||||
@ -109,8 +112,8 @@ proc monitor*(tasksList: var NimbusTasks, config: NimbusConfig) =
|
|||||||
while true:
|
while true:
|
||||||
info "checking tasks ... "
|
info "checking tasks ... "
|
||||||
|
|
||||||
# -check an atomic (to be created when needed) if it s required to shutdown
|
# -check tasks flag (to be created when needed) if it's required to shutdown
|
||||||
# this will atomic flag solves:
|
# this atomic flag solves:
|
||||||
# - non responding thread
|
# - non responding thread
|
||||||
# - thread that required shutdown
|
# - thread that required shutdown
|
||||||
|
|
||||||
@ -123,7 +126,8 @@ proc startTasks*(
|
|||||||
let
|
let
|
||||||
|
|
||||||
# TODO: extract configs for each task from NimbusConfig
|
# TODO: extract configs for each task from NimbusConfig
|
||||||
# or extract them somewhere else and passs them here
|
# or extract them somewhere else and passs them here.
|
||||||
|
# check nimbus_configs annotations.
|
||||||
execName = "Execution Layer"
|
execName = "Execution Layer"
|
||||||
consName = "Consensus Layer"
|
consName = "Consensus Layer"
|
||||||
var
|
var
|
||||||
@ -149,7 +153,7 @@ when isMainModule:
|
|||||||
## - file limits
|
## - file limits
|
||||||
## - check if we have permissions to create data folder if needed
|
## - check if we have permissions to create data folder if needed
|
||||||
## - setup logging
|
## - setup logging
|
||||||
## - read configuration
|
## - read configuration (check nimbus_configs file anottations)
|
||||||
## - implement config reader for all components
|
## - implement config reader for all components
|
||||||
let nimbusConfigs = NimbusConfig()
|
let nimbusConfigs = NimbusConfig()
|
||||||
var tasksList: NimbusTasks = NimbusTasks.new
|
var tasksList: NimbusTasks = NimbusTasks.new
|
||||||
@ -168,6 +172,7 @@ when isMainModule:
|
|||||||
tasksList.startTasks(nimbusConfigs, beaconNodeConfig)
|
tasksList.startTasks(nimbusConfigs, beaconNodeConfig)
|
||||||
|
|
||||||
## Graceful shutdown by handling of Ctrl+C signal
|
## Graceful shutdown by handling of Ctrl+C signal
|
||||||
|
## TODO: we might need to declare it per thread
|
||||||
proc controlCHandler() {.noconv.} =
|
proc controlCHandler() {.noconv.} =
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||||
|
Loading…
x
Reference in New Issue
Block a user