Skip to content

Commit

Permalink
feat: add forkmon (ethpandaops#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa authored Jul 14, 2023
1 parent c38bff9 commit 2a8ad19
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 20 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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. 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
Expand Down Expand Up @@ -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
// 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,

},

Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
[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
[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
[testnet-verifier]: https://github.com/kurtosis-tech/eth2-package/tree/main/src/testnet_verifier
[auxiliary-services]: #auxiliary-services
16 changes: 11 additions & 5 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -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")
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")
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")
Expand Down Expand Up @@ -76,10 +77,15 @@ def run(plan, args):
# We need a way to do time.sleep
# TODO add code that waits for CL genesis

plan.print("Launching forkmon")
forkmon_config_template = read_file(static_files.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)
plan.print("Succesfully launched forkmon")
plan.print("Launching cl forkmon")
cl_forkmon_config_template = read_file(static_files.CL_FORKMON_CONFIG_TEMPLATE_FILEPATH)
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 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...")
prometheus_private_url = prometheus.launch_prometheus(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
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"

HTTP_PORT_ID = "http"
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 = {
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,
config_template,
cl_client_contexts,
Expand All @@ -34,22 +34,22 @@ def launch_forkmon(

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[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)

plan.add_service(SERVICE_NAME, config)


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(
image = IMAGE_NAME,
ports = USED_PORTS,
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]
)
Expand Down
67 changes: 67 additions & 0 deletions src/el_forkmon/el_forkmon_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
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
}
2 changes: 1 addition & 1 deletion src/package_io/parse_input.star
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def default_network_params():
"seconds_per_slot": 12,
"slots_per_epoch": 32,
"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
# this will take 53~ hoours for now
"deneb_fork_epoch": 500,
Expand Down
10 changes: 7 additions & 3 deletions src/static_files/static_files.star
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# The path on the module container where static files are housed
STATIC_FILES_DIRPATH = "github.com/kurtosis-tech/eth2-package/static_files"

# Forkmon config
FORKMON_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
"/forkmon-config/config.toml.tmpl"
# CL Forkmon config
CL_FORKMON_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
"/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_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
Expand Down
13 changes: 13 additions & 0 deletions static_files/el-forkmon-config/config.toml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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 }}

0 comments on commit 2a8ad19

Please sign in to comment.