Skip to content

Commit

Permalink
feat: Allow selection of additional services (#220)
Browse files Browse the repository at this point in the history
Closes #118

---------

Co-authored-by: Gyanendra Mishra <[email protected]>
  • Loading branch information
victorcolombo and h4ck3rk3y authored Sep 22, 2023
1 parent 5dd4f9b commit 57b15fe
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 92 deletions.
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,26 @@ To configure the package behaviour, you can modify your `network_params.json` fi
"tx_spammer_extra_args": []
},

// True by defaults such that in addition to the Ethereum network:
// - A transaction spammer is launched to fake transactions sent to the network
// - Forkmon will be launched after CL genesis has happened
// - A prometheus will be started, coupled with grafana
// True by defaults, adds services defined in "additional_services" alongside the Ethereum network
// If set to false:
// - only Ethereum network (EL and CL nodes) will be launched. Nothing else (no transaction spammer)
// - params for the CL nodes will be ignored (e.g. CL node image, CL node extra params)
"launch_additional_services": true,

// By default includes
// - A transaction spammer is launched to fake transactions sent to the network
// - Forkmon will be launched after CL genesis has happened
// - A prometheus will be started, coupled with grafana
"additional_services": [
"tx_spammer",
"blob_spammer",
"cl_forkmon",
"el_forkmon",
"beacon_metrics_gazer",
"light_beaconchain_explorer",
"prometheus_grafana",
],

// If set, the package will block until a finalized epoch has occurred.
"wait_for_finalization": false,

Expand Down
178 changes: 90 additions & 88 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -215,95 +215,97 @@ def run(plan, args={}):

if not args_with_right_defaults.launch_additional_services:
return
for additional_service in args_with_right_defaults.additional_services:
if additional_service == "tx_spammer":
plan.print("Launching transaction spammer")
tx_spammer_params = args_with_right_defaults.tx_spammer_params
transaction_spammer.launch_transaction_spammer(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS,
all_el_client_contexts[0],
tx_spammer_params,
)
plan.print("Succesfully launched transaction spammer")
elif additional_service == "blob_spammer":
plan.print("Launching Blob spammer")
blob_spammer.launch_blob_spammer(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS,
all_el_client_contexts[0],
all_cl_client_contexts[0],
network_params.deneb_fork_epoch,
network_params.seconds_per_slot,
network_params.slots_per_epoch,
network_params.genesis_delay,
)
plan.print("Succesfully launched blob spammer")
# We need a way to do time.sleep
# TODO add code that waits for CL genesis
elif additional_service == "cl_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")
elif additional_service == "el_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")
elif additional_service == "beacon_metrics_gazer":
plan.print("Launching beacon metrics gazer")
beacon_metrics_gazer_config_template = read_file(
static_files.BEACON_METRICS_GAZER_CONFIG_TEMPLATE_FILEPATH
)
beacon_metrics_gazer.launch_beacon_metrics_gazer(
plan,
beacon_metrics_gazer_config_template,
all_cl_client_contexts,
args_with_right_defaults.participants,
network_params,
)
plan.print("Succesfully launched beacon metrics gazer")
elif additional_service == "light_beaconchain_explorer":
plan.print("Launching light-beaconchain-explorer")
light_beaconchain_explorer_config_template = read_file(
static_files.LIGHT_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH
)
light_beaconchain_explorer.launch_light_beacon(
plan, light_beaconchain_explorer_config_template, all_cl_client_contexts
)
plan.print("Succesfully light-beaconchain-explorer")
elif additional_service == "prometheus_grafana":
plan.print("Launching prometheus...")
prometheus_private_url = prometheus.launch_prometheus(
plan,
prometheus_config_template,
all_cl_client_contexts,
all_el_client_contexts,
)
plan.print("Successfully launched Prometheus")

plan.print("Launching transaction spammer")
tx_spammer_params = args_with_right_defaults.tx_spammer_params
transaction_spammer.launch_transaction_spammer(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS,
all_el_client_contexts[0],
tx_spammer_params,
)
plan.print("Succesfully launched transaction spammer")

plan.print("Launching Blob spammer")
blob_spammer.launch_blob_spammer(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS,
all_el_client_contexts[0],
all_cl_client_contexts[0],
network_params.deneb_fork_epoch,
network_params.seconds_per_slot,
network_params.slots_per_epoch,
network_params.genesis_delay,
)
plan.print("Succesfully launched blob spammer")

# We need a way to do time.sleep
# TODO add code that waits for CL genesis

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 beacon metrics gazer")
beacon_metrics_gazer_config_template = read_file(
static_files.BEACON_METRICS_GAZER_CONFIG_TEMPLATE_FILEPATH
)
beacon_metrics_gazer.launch_beacon_metrics_gazer(
plan,
beacon_metrics_gazer_config_template,
all_cl_client_contexts,
args_with_right_defaults.participants,
network_params,
)
plan.print("Succesfully launched beacon metrics gazer")

plan.print("Launching light-beaconchain-explorer")
light_beaconchain_explorer_config_template = read_file(
static_files.LIGHT_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH
)
light_beaconchain_explorer.launch_light_beacon(
plan, light_beaconchain_explorer_config_template, all_cl_client_contexts
)
plan.print("Succesfully light-beaconchain-explorer")

plan.print("Launching prometheus...")
prometheus_private_url = prometheus.launch_prometheus(
plan,
prometheus_config_template,
all_cl_client_contexts,
all_el_client_contexts,
)
plan.print("Successfully launched Prometheus")

plan.print("Launching grafana...")
grafana.launch_grafana(
plan,
grafana_datasource_config_template,
grafana_dashboards_config_template,
prometheus_private_url,
)
plan.print("Succesfully launched grafana")
plan.print("Launching grafana...")
grafana.launch_grafana(
plan,
grafana_datasource_config_template,
grafana_dashboards_config_template,
prometheus_private_url,
)
plan.print("Succesfully launched grafana")
else:
fail("Invalid additional service %s" % (additional_service))

if args_with_right_defaults.wait_for_finalization:
plan.print("Waiting for the first finalized epoch")
Expand Down
11 changes: 11 additions & 0 deletions src/package_io/parse_input.star
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# MEV Params
FLASHBOTS_MEV_BOOST_PORT = 18550
MEV_BOOST_SERVICE_NAME_PREFIX = "mev-boost-"
DEFAULT_ADDITIONAL_SERVICES = [
"tx_spammer",
"blob_spammer",
"cl_forkmon",
"el_forkmon",
"beacon_metrics_gazer",
"light_beaconchain_explorer",
"prometheus_grafana",
]

ATTR_TO_BE_SKIPPED_AT_ROOT = (
"network_params",
Expand Down Expand Up @@ -34,6 +43,7 @@ def parse_input(plan, input_args):
result["mev_type"] = None
result["mev_params"] = get_default_mev_params()
result["launch_additional_services"] = True
result["additional_services"] = DEFAULT_ADDITIONAL_SERVICES

for attr in input_args:
value = input_args[attr]
Expand Down Expand Up @@ -119,6 +129,7 @@ def parse_input(plan, input_args):
],
),
launch_additional_services=result["launch_additional_services"],
additional_services=result["additional_services"],
wait_for_finalization=result["wait_for_finalization"],
global_client_log_level=result["global_client_log_level"],
mev_type=result["mev_type"],
Expand Down

0 comments on commit 57b15fe

Please sign in to comment.