Commit 2a8ad19e authored by Barnabas Busa's avatar Barnabas Busa Committed by GitHub

feat: add forkmon (#107)

parent c38bff9f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
This is a [Kurtosis Starlark Package][starlark-docs] that will: This is a [Kurtosis Starlark Package][starlark-docs] that will:
1. Generate EL & CL genesis information using [this genesis generator](https://github.com/skylenet/ethereum-genesis-generator) 1. Generate EL & CL genesis information using [this genesis generator](https://github.com/ethpandaops/ethereum-genesis-generator)
1. Spin up a network of Eth2 Beacon/validator clients 1. Spin up a network of Eth2 Beacon/validator clients
1. Add [a transaction spammer](https://github.com/kurtosis-tech/tx-fuzz) that will repeatedly send transactions to the network 1. Add [a transaction spammer](https://github.com/kurtosis-tech/tx-fuzz) that will repeatedly send transactions to the network
1. Launch [a consensus monitor](https://github.com/ralexstokes/ethereum_consensus_monitor) instance attached to the network 1. Launch [a consensus monitor](https://github.com/ralexstokes/ethereum_consensus_monitor) instance attached to the network
...@@ -145,7 +145,10 @@ To configure the package behaviour, you can modify your `eth2-package-params.yam ...@@ -145,7 +145,10 @@ To configure the package behaviour, you can modify your `eth2-package-params.yam
// This mnemonic will a) be used to create keystores for all the types of validators that we have and b) be used to generate a CL genesis.ssz that has the children // This mnemonic will a) be used to create keystores for all the types of validators that we have and b) be used to generate a CL genesis.ssz that has the children
// validator keys already preregistered as validators // validator keys already preregistered as validators
"preregistered_validator_keys_mnemonic": "giant issue aisle success illegal bike spike question tent bar rely arctic volcano long crawl hungry vocal artwork sniff fantasy very lucky have athlete" "preregistered_validator_keys_mnemonic": "giant issue aisle success illegal bike spike question tent bar rely arctic volcano long crawl hungry vocal artwork sniff fantasy very lucky have athlete",
// The deneb for epoch -- arbitrarily large while we sort out https://github.com/kurtosis-tech/eth-network-package/issues/42 this will take 53~ hours for now
"deneb_for_epoch": 500,
}, },
......
...@@ -98,7 +98,7 @@ Once the Ethereum network is up and running, verification logic will be run to e ...@@ -98,7 +98,7 @@ Once the Ethereum network is up and running, verification logic will be run to e
[main-function]: https://github.com/kurtosis-tech/eth2-package/blob/main/main.star#22 [main-function]: https://github.com/kurtosis-tech/eth2-package/blob/main/main.star#22
[package-io]: https://github.com/kurtosis-tech/eth2-package/tree/main/src/package_io [package-io]: https://github.com/kurtosis-tech/eth2-package/tree/main/src/package_io
[participant-network]: https://github.com/kurtosis-tech/eth2-package/tree/main/src/participant_network [participant-network]: https://github.com/kurtosis-tech/eth2-package/tree/main/src/participant_network
[ethereum-genesis-generator]: https://github.com/skylenet/ethereum-genesis-generator [ethereum-genesis-generator]: https://github.com/ethpandaops/ethereum-genesis-generator
[static-files]: https://github.com/kurtosis-tech/eth2-package/tree/main/static_files [static-files]: https://github.com/kurtosis-tech/eth2-package/tree/main/static_files
[testnet-verifier]: https://github.com/kurtosis-tech/eth2-package/tree/main/src/testnet_verifier [testnet-verifier]: https://github.com/kurtosis-tech/eth2-package/tree/main/src/testnet_verifier
[auxiliary-services]: #auxiliary-services [auxiliary-services]: #auxiliary-services
...@@ -5,7 +5,8 @@ genesis_constants = import_module("github.com/kurtosis-tech/eth-network-package/ ...@@ -5,7 +5,8 @@ genesis_constants = import_module("github.com/kurtosis-tech/eth-network-package/
eth_network_module = import_module("github.com/kurtosis-tech/eth-network-package/main.star") eth_network_module = import_module("github.com/kurtosis-tech/eth-network-package/main.star")
transaction_spammer = import_module("github.com/kurtosis-tech/eth2-package/src/transaction_spammer/transaction_spammer.star") transaction_spammer = import_module("github.com/kurtosis-tech/eth2-package/src/transaction_spammer/transaction_spammer.star")
forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/forkmon/forkmon_launcher.star") cl_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/cl_forkmon/cl_forkmon_launcher.star")
el_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/el_forkmon/el_forkmon_launcher.star")
prometheus = import_module("github.com/kurtosis-tech/eth2-package/src/prometheus/prometheus_launcher.star") prometheus = import_module("github.com/kurtosis-tech/eth2-package/src/prometheus/prometheus_launcher.star")
grafana =import_module("github.com/kurtosis-tech/eth2-package/src/grafana/grafana_launcher.star") grafana =import_module("github.com/kurtosis-tech/eth2-package/src/grafana/grafana_launcher.star")
testnet_verifier = import_module("github.com/kurtosis-tech/eth2-package/src/testnet_verifier/testnet_verifier.star") testnet_verifier = import_module("github.com/kurtosis-tech/eth2-package/src/testnet_verifier/testnet_verifier.star")
...@@ -76,10 +77,15 @@ def run(plan, args): ...@@ -76,10 +77,15 @@ def run(plan, args):
# We need a way to do time.sleep # We need a way to do time.sleep
# TODO add code that waits for CL genesis # TODO add code that waits for CL genesis
plan.print("Launching forkmon") plan.print("Launching cl forkmon")
forkmon_config_template = read_file(static_files.FORKMON_CONFIG_TEMPLATE_FILEPATH) cl_forkmon_config_template = read_file(static_files.CL_FORKMON_CONFIG_TEMPLATE_FILEPATH)
forkmon.launch_forkmon(plan, forkmon_config_template, all_cl_client_contexts, cl_genesis_timestamp, network_params.seconds_per_slot, network_params.slots_per_epoch) cl_forkmon.launch_cl_forkmon(plan, cl_forkmon_config_template, all_cl_client_contexts, cl_genesis_timestamp, network_params.seconds_per_slot, network_params.slots_per_epoch)
plan.print("Succesfully launched forkmon") plan.print("Succesfully launched consensus layer forkmon")
plan.print("Launching el forkmon")
el_forkmon_config_template = read_file(static_files.EL_FORKMON_CONFIG_TEMPLATE_FILEPATH)
el_forkmon.launch_el_forkmon(plan, el_forkmon_config_template, all_el_client_contexts)
plan.print("Succesfully launched execution layer forkmon")
plan.print("Launching prometheus...") plan.print("Launching prometheus...")
prometheus_private_url = prometheus.launch_prometheus( prometheus_private_url = prometheus.launch_prometheus(
......
shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star") shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star")
SERVICE_NAME = "forkmon" SERVICE_NAME = "cl-forkmon"
IMAGE_NAME = "ralexstokes/ethereum_consensus_monitor:latest" IMAGE_NAME = "ralexstokes/ethereum_consensus_monitor:latest"
HTTP_PORT_ID = "http" HTTP_PORT_ID = "http"
HTTP_PORT_NUMBER = 80 HTTP_PORT_NUMBER = 80
FORKMON_CONFIG_FILENAME = "forkmon-config.toml" CL_FORKMON_CONFIG_FILENAME = "cl-forkmon-config.toml"
FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config" CL_FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
USED_PORTS = { USED_PORTS = {
HTTP_PORT_ID:shared_utils.new_port_spec(HTTP_PORT_NUMBER, shared_utils.TCP_PROTOCOL, shared_utils.HTTP_APPLICATION_PROTOCOL) HTTP_PORT_ID:shared_utils.new_port_spec(HTTP_PORT_NUMBER, shared_utils.TCP_PROTOCOL, shared_utils.HTTP_APPLICATION_PROTOCOL)
} }
def launch_forkmon( def launch_cl_forkmon(
plan, plan,
config_template, config_template,
cl_client_contexts, cl_client_contexts,
...@@ -34,9 +34,9 @@ def launch_forkmon( ...@@ -34,9 +34,9 @@ def launch_forkmon(
template_and_data = shared_utils.new_template_and_data(config_template, template_data) template_and_data = shared_utils.new_template_and_data(config_template, template_data)
template_and_data_by_rel_dest_filepath = {} template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[FORKMON_CONFIG_FILENAME] = template_and_data template_and_data_by_rel_dest_filepath[CL_FORKMON_CONFIG_FILENAME] = template_and_data
config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "forkmon-config") config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "cl-forkmon-config")
config = get_config(config_files_artifact_name) config = get_config(config_files_artifact_name)
...@@ -44,12 +44,12 @@ def launch_forkmon( ...@@ -44,12 +44,12 @@ def launch_forkmon(
def get_config(config_files_artifact_name): def get_config(config_files_artifact_name):
config_file_path = shared_utils.path_join(FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE, FORKMON_CONFIG_FILENAME) config_file_path = shared_utils.path_join(CL_FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE, CL_FORKMON_CONFIG_FILENAME)
return ServiceConfig( return ServiceConfig(
image = IMAGE_NAME, image = IMAGE_NAME,
ports = USED_PORTS, ports = USED_PORTS,
files = { files = {
FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name, CL_FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
}, },
cmd = ["--config-path", config_file_path] cmd = ["--config-path", config_file_path]
) )
......
shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star")
SERVICE_NAME = "el-forkmon"
IMAGE_NAME = "skylenet/nodemonitor:darkmode"
HTTP_PORT_ID = "http"
HTTP_PORT_NUMBER = 8080
EL_FORKMON_CONFIG_FILENAME = "el-forkmon-config.toml"
EL_FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
USED_PORTS = {
HTTP_PORT_ID:shared_utils.new_port_spec(HTTP_PORT_NUMBER, shared_utils.TCP_PROTOCOL, shared_utils.HTTP_APPLICATION_PROTOCOL)
}
def launch_el_forkmon(
plan,
config_template,
el_client_contexts,
):
all_el_client_info = []
for client in el_client_contexts:
client_info = new_el_client_info(client.ip_addr, client.rpc_port_num, client.service_name)
all_el_client_info.append(client_info)
template_data = new_config_template_data(HTTP_PORT_NUMBER, all_el_client_info)
template_and_data = shared_utils.new_template_and_data(config_template, template_data)
template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[EL_FORKMON_CONFIG_FILENAME] = template_and_data
config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "el-forkmon-config")
config = get_config(config_files_artifact_name)
plan.add_service(SERVICE_NAME, config)
def get_config(config_files_artifact_name):
config_file_path = shared_utils.path_join(EL_FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE, EL_FORKMON_CONFIG_FILENAME)
return ServiceConfig(
image = IMAGE_NAME,
ports = USED_PORTS,
files = {
EL_FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
},
cmd = [config_file_path]
)
def new_config_template_data(listen_port_num, el_client_info):
return {
"ListenPortNum": listen_port_num,
"ELClientInfo": el_client_info,
}
def new_el_client_info(ip_addr, port_num, service_name):
return {
"IPAddr": ip_addr,
"PortNum": port_num,
"Name": service_name
}
...@@ -176,7 +176,7 @@ def default_network_params(): ...@@ -176,7 +176,7 @@ def default_network_params():
"seconds_per_slot": 12, "seconds_per_slot": 12,
"slots_per_epoch": 32, "slots_per_epoch": 32,
"genesis_delay": 120, "genesis_delay": 120,
"capella_fork_epoch": 2, "capella_fork_epoch": 1,
# arbitrarily large while we sort out https://github.com/kurtosis-tech/eth-network-package/issues/42 # arbitrarily large while we sort out https://github.com/kurtosis-tech/eth-network-package/issues/42
# this will take 53~ hoours for now # this will take 53~ hoours for now
"deneb_fork_epoch": 500, "deneb_fork_epoch": 500,
......
# The path on the module container where static files are housed # The path on the module container where static files are housed
STATIC_FILES_DIRPATH = "github.com/kurtosis-tech/eth2-package/static_files" STATIC_FILES_DIRPATH = "github.com/kurtosis-tech/eth2-package/static_files"
# Forkmon config # CL Forkmon config
FORKMON_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \ CL_FORKMON_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
"/forkmon-config/config.toml.tmpl" "/cl-forkmon-config/config.toml.tmpl"
# EL Forkmon config
EL_FORKMON_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
"/el-forkmon-config/config.toml.tmpl"
# Prometheus config # Prometheus config
PROMETHEUS_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \ PROMETHEUS_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
......
# How often to reload data from the nodes
reload_interval = "10s"
# If specified, a http server will serve static content here
server_address = "0.0.0.0:{{ .ListenPortNum }}"
# Shown in the document title, if specified
chain_name="kurtosis-chain"
# Local or non third party connection require rpc kind
{{ range $elClient := .ELClientInfo }}
[[clients]]
url = "http://{{ $elClient.IPAddr }}:{{ $elClient.PortNum }}"
name = "{{ $elClient.Name }}"
kind = "rpc"
{{- end }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment