-
Notifications
You must be signed in to change notification settings - Fork 330
feat: add support for separate bootnode with bootnodoor #1238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
414a480
add support for separate bootnode with bootnodoor
pk910 b690ada
`kurtosis lint --format`
pk910 132afb2
fix mev.yaml (hardcode image)
pk910 2b5e351
use bootnodoor as execution layer bootnode
pk910 04bb786
Merge branch 'main' into pk910/bootnodoor
barnabasbusa fec3eae
lint
barnabasbusa 3611159
Update mev.yaml
barnabasbusa 5515ce0
Merge branch 'main' into pk910/bootnodoor
barnabasbusa cb68756
Merge branch 'main' into pk910/bootnodoor
barnabasbusa a24f364
Merge branch 'main' into pk910/bootnodoor
barnabasbusa 429e374
Merge branch 'main' into pk910/bootnodoor
pk910 f38a06b
Merge branch 'main' into pk910/bootnodoor
barnabasbusa a340594
Merge branch 'main' into pk910/bootnodoor
barnabasbusa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| shared_utils = import_module("../shared_utils/shared_utils.star") | ||
| constants = import_module("../package_io/constants.star") | ||
|
|
||
| SERVICE_NAME = "bootnodoor" | ||
| HTTP_PORT_NUMBER = 8080 | ||
| DISCOVERY_PORT_NUMBER = 9000 | ||
|
|
||
| USED_PORTS = { | ||
| constants.HTTP_PORT_ID: shared_utils.new_port_spec( | ||
| HTTP_PORT_NUMBER, | ||
| shared_utils.TCP_PROTOCOL, | ||
| shared_utils.HTTP_APPLICATION_PROTOCOL, | ||
| ), | ||
| constants.UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec( | ||
| DISCOVERY_PORT_NUMBER, | ||
| shared_utils.UDP_PROTOCOL, | ||
| ), | ||
| } | ||
|
|
||
|
|
||
| def launch_bootnodoor( | ||
| plan, | ||
| bootnodoor_params, | ||
| el_cl_genesis_data, | ||
| network_params, | ||
| global_node_selectors, | ||
| global_tolerations, | ||
| docker_cache_params, | ||
| ): | ||
| tolerations = shared_utils.get_tolerations(global_tolerations=global_tolerations) | ||
|
|
||
| # Generate a random 32-byte (64 hex char) private key | ||
| private_key = generate_random_private_key(plan) | ||
|
|
||
| # Get the genesis validators root from the genesis data | ||
| genesis_validators_root = el_cl_genesis_data.genesis_validators_root | ||
|
|
||
| # Get the EL genesis hash | ||
| el_genesis_hash = get_el_genesis_hash(plan, network_params, el_cl_genesis_data) | ||
|
|
||
| # Fetch external bootnodes for non-kurtosis networks | ||
| # For kurtosis/shadowfork: bootnodoor is the primary bootnode, no external bootnodes needed | ||
| # For ephemery/devnets: read bootstrap_nodes.txt from genesis data | ||
| external_bootnodes = None | ||
| if network_params.network == constants.NETWORK_NAME.ephemery or ( | ||
| network_params.network not in constants.PUBLIC_NETWORKS | ||
| and network_params.network != constants.NETWORK_NAME.kurtosis | ||
| and constants.NETWORK_NAME.shadowfork not in network_params.network | ||
| ): | ||
| plan.print( | ||
| "Fetching external bootnodes for network: {0}".format( | ||
| network_params.network | ||
| ) | ||
| ) | ||
| external_bootnodes = shared_utils.get_devnet_enrs_list( | ||
| plan, el_cl_genesis_data.files_artifact_uuid | ||
| ) | ||
|
|
||
| config = get_config( | ||
| bootnodoor_params, | ||
| el_cl_genesis_data, | ||
| private_key, | ||
| genesis_validators_root, | ||
| el_genesis_hash, | ||
| external_bootnodes, | ||
| global_node_selectors, | ||
| tolerations, | ||
| docker_cache_params, | ||
| ) | ||
|
|
||
| plan.add_service(SERVICE_NAME, config) | ||
|
|
||
| # Request ENR from the running bootnodoor service | ||
| # The /enr endpoint returns a plain string (not JSON) | ||
| enr_recipe = GetHttpRequestRecipe( | ||
| endpoint="/enr", | ||
| port_id=constants.HTTP_PORT_ID, | ||
| ) | ||
|
|
||
| response = plan.request( | ||
| recipe=enr_recipe, | ||
| service_name=SERVICE_NAME, | ||
| ) | ||
|
|
||
| bootnodoor_enr = response["body"] | ||
|
|
||
| # Request ENODE from the running bootnodoor service for EL bootnode | ||
| enode_recipe = GetHttpRequestRecipe( | ||
| endpoint="/enode", | ||
| port_id=constants.HTTP_PORT_ID, | ||
| ) | ||
|
|
||
| enode_response = plan.request( | ||
| recipe=enode_recipe, | ||
| service_name=SERVICE_NAME, | ||
| ) | ||
|
|
||
| bootnodoor_enode = enode_response["body"] | ||
|
|
||
| return bootnodoor_enr, bootnodoor_enode | ||
|
|
||
|
|
||
| def get_config( | ||
| bootnodoor_params, | ||
| el_cl_genesis_data, | ||
| private_key, | ||
| genesis_validators_root, | ||
| el_genesis_hash, | ||
| external_bootnodes, | ||
| node_selectors, | ||
| tolerations, | ||
| docker_cache_params, | ||
| ): | ||
| cmd = [ | ||
| "--cl-config", | ||
| "{0}/config.yaml".format(constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS), | ||
| "--genesis-validators-root", | ||
| genesis_validators_root, | ||
| "--el-config", | ||
| "{0}/genesis.json".format(constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS), | ||
| "--el-genesis-hash", | ||
| el_genesis_hash, | ||
| "--private-key", | ||
| private_key, | ||
| "--bind-addr", | ||
| "0.0.0.0", | ||
| "--web-ui", | ||
| "--nodedb", | ||
| "/nodes.db", | ||
| ] | ||
|
|
||
| # Add external bootnodes for non-kurtosis networks (ephemery, devnets) | ||
| if external_bootnodes != None: | ||
| cmd.append("--bootnodes") | ||
| cmd.append(external_bootnodes) | ||
|
|
||
| # Add any extra args from the params | ||
| if len(bootnodoor_params.extra_args) > 0: | ||
| cmd.extend(bootnodoor_params.extra_args) | ||
|
|
||
| return ServiceConfig( | ||
| image=shared_utils.docker_cache_image_calc( | ||
| docker_cache_params, | ||
| bootnodoor_params.image, | ||
| ), | ||
| ports=USED_PORTS, | ||
| files={ | ||
| constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data.files_artifact_uuid, | ||
| }, | ||
| cmd=cmd, | ||
| min_cpu=bootnodoor_params.min_cpu, | ||
| max_cpu=bootnodoor_params.max_cpu, | ||
| min_memory=bootnodoor_params.min_mem, | ||
| max_memory=bootnodoor_params.max_mem, | ||
| node_selectors=node_selectors, | ||
| tolerations=tolerations, | ||
| ) | ||
|
|
||
|
|
||
| def get_el_genesis_hash(plan, network_params, el_cl_genesis_data): | ||
| # For mainnet and sepolia, use static genesis hashes | ||
| if network_params.network == "mainnet": | ||
| return "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" | ||
| elif network_params.network == "sepolia": | ||
| return "0x25a5cc106eea7138acab33231d7160d69cb777ee0c2c553fcddf5138993e6dd9" | ||
|
|
||
| # For other networks, extract from deposit_contract_block_hash.txt | ||
| result = plan.run_sh( | ||
| name="read-el-genesis-hash", | ||
| description="Reading EL genesis hash from deposit_contract_block_hash.txt", | ||
| run="cat /network-configs/deposit_contract_block_hash.txt", | ||
| files={ | ||
| "/network-configs": el_cl_genesis_data.files_artifact_uuid, | ||
| }, | ||
| wait=None, | ||
| ) | ||
| return result.output | ||
|
|
||
|
|
||
| def generate_random_private_key(plan): | ||
| # Generate a random 32-byte (64 hex char) private key using /dev/urandom | ||
| result = plan.run_sh( | ||
| name="generate-bootnodoor-private-key", | ||
| description="Generating random private key for bootnodoor", | ||
| run="head -c 32 /dev/urandom | od -An -tx1 | tr -d ' \\n'", | ||
| wait=None, | ||
| ) | ||
| return result.output | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.