-
Notifications
You must be signed in to change notification settings - Fork 97
feat(proxyd): add proxyd support #195
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
12 commits
Select commit
Hold shift + click to select a range
1dc7674
add proxyd params
edobry d28a0ae
pass proxyd params and launch
edobry 6643e7e
template proxyd config
edobry 209e017
template replicas
edobry bac7a5a
fix errors
edobry e59c118
fix config file path
edobry 9bf3a8d
fix config file format
edobry 52ede11
add rpc_method_mappings
edobry 2feccfe
enable ws
edobry 27eb573
change service name
edobry f1054a9
lint
edobry e61e33d
remove WS configs as unused
edobry 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
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
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
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,133 @@ | ||
| ethereum_package_shared_utils = import_module( | ||
| "github.com/ethpandaops/ethereum-package/src/shared_utils/shared_utils.star" | ||
| ) | ||
|
|
||
| ethereum_package_constants = import_module( | ||
| "github.com/ethpandaops/ethereum-package/src/package_io/constants.star" | ||
| ) | ||
|
|
||
| constants = import_module("../package_io/constants.star") | ||
| util = import_module("../util.star") | ||
|
|
||
| observability = import_module("../observability/observability.star") | ||
| prometheus = import_module("../observability/prometheus/prometheus_launcher.star") | ||
|
|
||
| # Port nums | ||
| HTTP_PORT_NUM = 8080 | ||
| METRICS_PORT_NUM = 7300 | ||
|
|
||
| TEMPLATES_FILEPATH = "./templates" | ||
|
|
||
| CONFIG_FILE_NAME = "proxyd.toml" | ||
| CONFIG_TEMPLATE_FILEPATH = "{0}/{1}.tmpl".format(TEMPLATES_FILEPATH, CONFIG_FILE_NAME) | ||
|
|
||
| CONFIG_DIRPATH_ON_SERVICE = "/etc/proxyd" | ||
|
|
||
|
|
||
| def get_used_ports(): | ||
| used_ports = { | ||
| constants.HTTP_PORT_ID: ethereum_package_shared_utils.new_port_spec( | ||
| HTTP_PORT_NUM, | ||
| ethereum_package_shared_utils.TCP_PROTOCOL, | ||
| ethereum_package_shared_utils.HTTP_APPLICATION_PROTOCOL, | ||
| ), | ||
| } | ||
| return used_ports | ||
|
|
||
|
|
||
| def launch( | ||
| plan, | ||
| proxyd_params, | ||
| network_params, | ||
| el_contexts, | ||
| observability_helper, | ||
| ): | ||
| config_template = read_file(CONFIG_TEMPLATE_FILEPATH) | ||
|
|
||
| config_artifact_name = create_config_artifact( | ||
| plan, | ||
| config_template, | ||
| el_contexts, | ||
| observability_helper, | ||
| ) | ||
|
|
||
| config = get_proxyd_config( | ||
| plan, | ||
| proxyd_params, | ||
| config_artifact_name, | ||
| observability_helper, | ||
| ) | ||
|
|
||
| service = plan.add_service("proxyd-{0}".format(network_params.network), config) | ||
| service_url = util.make_service_http_url(service) | ||
|
|
||
| observability.register_op_service_metrics_job( | ||
| observability_helper, service, network_params.network | ||
| ) | ||
|
|
||
| return service_url | ||
|
|
||
|
|
||
| def create_config_artifact( | ||
| plan, | ||
| config_template, | ||
| el_contexts, | ||
| observability_helper, | ||
| ): | ||
| config_data = { | ||
| "Ports": { | ||
| "rpc": HTTP_PORT_NUM, | ||
| }, | ||
| "Metrics": { | ||
| "enabled": observability_helper.enabled, | ||
| "port": METRICS_PORT_NUM, | ||
| }, | ||
| "Replicas": { | ||
| "{0}-{1}".format(el_context.client_name, num): el_context.rpc_http_url | ||
| for num, el_context in enumerate(el_contexts) | ||
| }, | ||
| } | ||
|
|
||
| config_template_and_data = ethereum_package_shared_utils.new_template_and_data( | ||
| config_template, config_data | ||
| ) | ||
|
|
||
| config_artifact_name = plan.render_templates( | ||
| { | ||
| CONFIG_FILE_NAME: config_template_and_data, | ||
| }, | ||
| name="proxyd-config", | ||
| ) | ||
|
|
||
| return config_artifact_name | ||
|
|
||
|
|
||
| def get_proxyd_config( | ||
| plan, | ||
| proxyd_params, | ||
| config_artifact_name, | ||
| observability_helper, | ||
| ): | ||
| ports = dict(get_used_ports()) | ||
|
|
||
| cmd = [ | ||
| "proxyd", | ||
| "{0}/{1}".format(CONFIG_DIRPATH_ON_SERVICE, CONFIG_FILE_NAME), | ||
| ] | ||
|
|
||
| # apply customizations | ||
|
|
||
| if observability_helper.enabled: | ||
| observability.expose_metrics_port(ports, port_num=METRICS_PORT_NUM) | ||
|
|
||
| cmd += proxyd_params.extra_params | ||
|
|
||
| return ServiceConfig( | ||
| image="{0}:{1}".format(proxyd_params.image, proxyd_params.tag), | ||
| ports=ports, | ||
| cmd=cmd, | ||
| files={ | ||
| CONFIG_DIRPATH_ON_SERVICE: config_artifact_name, | ||
| }, | ||
| private_ip_address_placeholder=ethereum_package_constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, | ||
| ) |
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,56 @@ | ||
| [server] | ||
| rpc_host = "0.0.0.0" | ||
| rpc_port = {{ .Ports.rpc }} | ||
|
|
||
| {{- if .Metrics.enabled }} | ||
| [metrics] | ||
| enabled = true | ||
| host = "0.0.0.0" | ||
| port = {{ .Metrics.port }} | ||
| {{- end }} | ||
|
|
||
| [backends] | ||
| {{- range $key, $value := .Replicas }} | ||
| [backends.{{ $key }}] | ||
| rpc_url = "{{ $value }}" | ||
| ws_url = "ws://dummy" | ||
| {{- end }} | ||
|
|
||
| [backend_groups] | ||
| [backend_groups.replica] | ||
| backends = [{{ range $key, $value := .Replicas }}"{{ $key }}",{{ end }}] | ||
|
|
||
| [rpc_method_mappings] | ||
| eth_getProof = "replica" | ||
| eth_gasPrice = "replica" | ||
| eth_sendRawTransaction = "replica" | ||
| eth_chainId = "replica" | ||
| eth_blockNumber = "replica" | ||
| net_version = "replica" | ||
| eth_getBlockByHash = "replica" | ||
| eth_getBlockByNumber = "replica" | ||
| eth_getUncleByBlockHashAndIndex = "replica" | ||
| eth_getTransactionByHash = "replica" | ||
| eth_getBlockTransactionCountByHash = "replica" | ||
| eth_getTransactionByBlockHashAndIndex = "replica" | ||
| eth_getTransactionReceipt = "replica" | ||
| eth_maxPriorityFeePerGas = "replica" | ||
| eth_feeHistory = "replica" | ||
| eth_syncing = "replica" | ||
| eth_getLogs = "replica" | ||
| eth_getBalance = "replica" | ||
| eth_getStorageAt = "replica" | ||
| eth_getCode = "replica" | ||
| eth_getTransactionCount = "replica" | ||
| eth_getBlockTransactionCountByNumber = "replica" | ||
| eth_call = "replica" | ||
| eth_estimateGas = "replica" | ||
| debug_traceTransaction = "replica" | ||
| debug_traceBlockByNumber = "replica" | ||
| debug_traceBlockByHash = "replica" | ||
| debug_storageRangeAt = "replica" | ||
| rollup_getInfo = "replica" | ||
| eth_getBlockRange = "replica" | ||
| web3_clientVersion = "replica" | ||
| eth_accounts = "replica" | ||
| debug_dbGet = "replica" | ||
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.