Skip to content

Commit

Permalink
feat: generate keys if not default key is used (#707)
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa authored Jul 4, 2024
1 parent a9ba40e commit 2d1cab5
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 27 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ network_params:
# - A prometheus will be started, coupled with grafana
# - A beacon metrics gazer will be launched
# - A light beacon chain explorer will be launched
# - Default: ["tx_spammer", "blob_spammer", "el_forkmon", "beacon_metrics_gazer", "dora"," "prometheus_grafana"]
# - Default: []
additional_services:
- assertoor
- broadcaster
Expand Down Expand Up @@ -1007,7 +1007,7 @@ For more details, including a guide and architecture of the `mev-boost` infrastr
## Pre-funded accounts at Genesis
This package comes with [20 prefunded keys for testing](https://github.com/ethpandaops/ethereum-package/blob/main/src/prelaunch_data_generator/genesis_constants/genesis_constants.star).
This package comes with [21 prefunded keys for testing](https://github.com/ethpandaops/ethereum-package/blob/main/src/prelaunch_data_generator/genesis_constants/genesis_constants.star).
Here's a table of where the keys are used
Expand Down
29 changes: 21 additions & 8 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ mev_custom_flood = import_module(
)
broadcaster = import_module("./src/broadcaster/broadcaster.star")
assertoor = import_module("./src/assertoor/assertoor_launcher.star")
get_prefunded_accounts = import_module(
"./src/prefunded_accounts/get_prefunded_accounts.star"
)

GRAFANA_USER = "admin"
GRAFANA_PASSWORD = "admin"
Expand Down Expand Up @@ -83,6 +86,15 @@ def run(plan, args={}):
keymanager_enabled = args_with_right_defaults.keymanager_enabled
apache_port = args_with_right_defaults.apache_port

prefunded_accounts = genesis_constants.PRE_FUNDED_ACCOUNTS
if (
network_params.preregistered_validator_keys_mnemonic
!= constants.DEFAULT_MNEMONIC
):
prefunded_accounts = get_prefunded_accounts.get_accounts(
plan, network_params.preregistered_validator_keys_mnemonic
)

grafana_datasource_config_template = read_file(
static_files.GRAFANA_DATASOURCE_CONFIG_TEMPLATE_FILEPATH
)
Expand Down Expand Up @@ -240,7 +252,7 @@ def run(plan, args={}):

first_cl_client = all_cl_contexts[0]
first_client_beacon_name = first_cl_client.beacon_service_name
contract_owner, normal_user = genesis_constants.PRE_FUNDED_ACCOUNTS[6:8]
contract_owner, normal_user = prefunded_accounts[6:8]
mev_flood.launch_mev_flood(
plan,
mev_params.mev_flood_image,
Expand Down Expand Up @@ -362,8 +374,9 @@ def run(plan, args={}):
if len(args_with_right_defaults.additional_services) == 0:
output = struct(
all_participants=all_participants,
pre_funded_accounts=genesis_constants.PRE_FUNDED_ACCOUNTS,
pre_funded_accounts=prefunded_accounts,
network_params=network_params,
network_id=network_id,
final_genesis_timestamp=final_genesis_timestamp,
genesis_validators_root=genesis_validators_root,
)
Expand All @@ -379,7 +392,7 @@ def run(plan, args={}):
tx_spammer_params = args_with_right_defaults.tx_spammer_params
transaction_spammer.launch_transaction_spammer(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS,
prefunded_accounts,
fuzz_target,
tx_spammer_params,
network_params.electra_fork_epoch,
Expand All @@ -390,7 +403,7 @@ def run(plan, args={}):
plan.print("Launching Blob spammer")
blob_spammer.launch_blob_spammer(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS,
prefunded_accounts,
fuzz_target,
all_cl_contexts[0],
network_params.deneb_fork_epoch,
Expand All @@ -404,7 +417,7 @@ def run(plan, args={}):
goomy_blob_params = args_with_right_defaults.goomy_blob_params
goomy_blob.launch_goomy_blob(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS,
prefunded_accounts,
all_el_contexts,
all_cl_contexts[0],
network_params.seconds_per_slot,
Expand Down Expand Up @@ -606,8 +619,8 @@ def run(plan, args={}):
elif additional_service == "custom_flood":
mev_custom_flood.spam_in_background(
plan,
genesis_constants.PRE_FUNDED_ACCOUNTS[-1].private_key,
genesis_constants.PRE_FUNDED_ACCOUNTS[0].address,
prefunded_accounts[-1].private_key,
prefunded_accounts[0].address,
fuzz_target,
args_with_right_defaults.custom_flood_params,
global_node_selectors,
Expand Down Expand Up @@ -669,7 +682,7 @@ def run(plan, args={}):
if ("blockscout" in args_with_right_defaults.additional_services) == False
else blockscout_sc_verif_url,
all_participants=all_participants,
pre_funded_accounts=genesis_constants.PRE_FUNDED_ACCOUNTS,
pre_funded_accounts=prefunded_accounts,
network_params=network_params,
network_id=network_id,
final_genesis_timestamp=final_genesis_timestamp,
Expand Down
8 changes: 1 addition & 7 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,7 @@ network_params:
additional_preloaded_contracts: {}
devnet_repo: ethpandaops
checkpoint_sync_enabled: false
additional_services:
- tx_spammer
- blob_spammer
- el_forkmon
- beacon_metrics_gazer
- dora
- prometheus_grafana
additional_services: []
dora_params:
image: ""
tx_spammer_params:
Expand Down
2 changes: 2 additions & 0 deletions src/package_io/constants.star
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ DEFAULT_MEV_SECRET_KEY = (
"0x607a11b45a7219cc61a3d9c5fd08c7eebd602a6a19a977f8d3771d5711a550f2"
)

DEFAULT_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"

PRIVATE_IP_ADDRESS_PLACEHOLDER = "KURTOSIS_IP_ADDR_PLACEHOLDER"

GENESIS_FORK_VERSION = "0x10000038"
Expand Down
13 changes: 3 additions & 10 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,7 @@ MEV_BOOST_SERVICE_NAME_PREFIX = "mev-boost"
# Minimum number of validators required for a network to be valid is 64
MIN_VALIDATORS = 64

DEFAULT_ADDITIONAL_SERVICES = [
"tx_spammer",
"blob_spammer",
"el_forkmon",
"beacon_metrics_gazer",
"dora",
"prometheus_grafana",
]
DEFAULT_ADDITIONAL_SERVICES = []

ATTR_TO_BE_SKIPPED_AT_ROOT = (
"network_params",
Expand Down Expand Up @@ -782,7 +775,7 @@ def default_network_params():
"deposit_contract_address": "0x4242424242424242424242424242424242424242",
"seconds_per_slot": 12,
"num_validator_keys_per_node": 64,
"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": constants.DEFAULT_MNEMONIC,
"preregistered_validator_count": 0,
"genesis_delay": 20,
"max_per_epoch_activation_churn_limit": 8,
Expand Down Expand Up @@ -814,7 +807,7 @@ def default_minimal_network_params():
"deposit_contract_address": "0x4242424242424242424242424242424242424242",
"seconds_per_slot": 6,
"num_validator_keys_per_node": 64,
"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": constants.DEFAULT_MNEMONIC,
"preregistered_validator_count": 0,
"genesis_delay": 20,
"max_per_epoch_activation_churn_limit": 4,
Expand Down
41 changes: 41 additions & 0 deletions src/prefunded_accounts/get_prefunded_accounts.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
new_prefunded_account = import_module(
"../prelaunch_data_generator/genesis_constants/genesis_constants.star"
)

IMAGE = "wealdtech/ethereal:latest"


def get_accounts(plan, mnemonic, num_of_keys=21):
PRE_FUNDED_ACCOUNTS = []
plan.print("mnemonic: {0}".format(mnemonic))
for current_key in range(num_of_keys):
private_key = plan.run_sh(
name="run-ethereal-private-key",
image=IMAGE,
description="Running ethereal to derive private keys of key {0}".format(
current_key
),
run="private_key=$(/app/ethereal hd keys --seed=\"{0}\" --path=\"m/44'/60'/0'/0/{1}\" | awk '/Private key/{{print substr($NF, 3)}}'); echo -n $private_key".format(
mnemonic, current_key
),
)
eth_address = plan.run_sh(
name="run-ethereal-eth-address",
image=IMAGE,
description="Running ethereal to derive eth address of key {0}".format(
current_key
),
run="eth_addr=$(/app/ethereal hd keys --seed=\"{0}\" --path=\"m/44'/60'/0'/0/{1}\" | awk '/Ethereum address/{{print $NF}}'); echo -n $eth_addr".format(
mnemonic, current_key
),
)

PRE_FUNDED_ACCOUNTS.append(
new_prefunded_account.new_prefunded_account(
eth_address.output, private_key.output
)
)

plan.print("PRE_FUNDED_ACCOUNTS: {0}".format(PRE_FUNDED_ACCOUNTS))

return PRE_FUNDED_ACCOUNTS
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,9 @@ PRE_FUNDED_ACCOUNTS = [
"0xD8F3183DEF51A987222D845be228e0Bbb932C222",
"c5114526e042343c6d1899cad05e1c00ba588314de9b96929914ee0df18d46b2",
),
# m/44'/60'/0'/0/20
new_prefunded_account(
"0xafF0CA253b97e54440965855cec0A8a2E2399896",
"4b9f63ecf84210c5366c66d68fa1f5da1fa4f634fad6dfc86178e4d79ff9e59",
),
]

0 comments on commit 2d1cab5

Please sign in to comment.