diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 034d4dc23..7c9d5c2e5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -123,6 +123,7 @@ jobs: yq -Y --in-place '.deploy_cdk_bridge_infra = false' params.yml yq -Y --in-place '.deploy_zkevm_permissionless_node = false' params.yml yq -Y --in-place '.deploy_observability = false' params.yml + yq -Y --in-place '.deploy_blutgang = false' params.yml - name: Deploy L1 run: | @@ -166,6 +167,12 @@ jobs: kurtosis run --enclave cdk-v1 --args-file params.yml . yq -Y --in-place '.deploy_observability = false' params.yml # reset + - name: Deploy Loadbalancer (blutgang) + run: | + yq -Y --in-place '.deploy_blutgang = true' params.yml + kurtosis run --enclave cdk-v1 --args-file params.yml . + yq -Y --in-place '.deploy_blutgang = false' params.yml # reset + - name: Check that batches are being verified run: | timeout_minutes="${CHECK_VERIFIED_BATCHES_TIMEOUT_MINUTES}" diff --git a/cdk_blutgang.star b/cdk_blutgang.star new file mode 100644 index 000000000..1fcbc272d --- /dev/null +++ b/cdk_blutgang.star @@ -0,0 +1,51 @@ +def run(plan, args): + blutgang_name = "blutgang" + args["deployment_suffix"] + blutgang_config_template = read_file( + src="./templates/blutgang/blutgang-config.toml" + ) + + zkevm_sequencer_service = plan.get_service(name="zkevm-node-sequencer" + args["deployment_suffix"]) + zkevm_sequencer_http_url = "http://{}:{}".format(zkevm_sequencer_service.ip_address, zkevm_sequencer_service.ports["rpc"].number) + + zkevm_rpc_service = plan.get_service(name="zkevm-node-rpc" + args["deployment_suffix"]) + zkevm_rpc_http_url = "http://{}:{}".format(zkevm_rpc_service.ip_address, zkevm_rpc_service.ports["http-rpc"].number) + zkevm_rpc_ws_url = "ws://{}:{}".format(zkevm_rpc_service.ip_address, zkevm_rpc_service.ports["ws-rpc"].number) + + zkevm_rpc_pless_service = plan.get_service(name="zkevm-node-rpc-pless" + args["deployment_suffix"]) + zkevm_rpc_pless_http_url = "http://{}:{}".format(zkevm_rpc_pless_service.ip_address, zkevm_rpc_pless_service.ports["http-rpc"].number) + zkevm_rpc_pless_ws_url = "ws://{}:{}".format(zkevm_rpc_pless_service.ip_address, zkevm_rpc_pless_service.ports["ws-rpc"].number) + + blutgang_config_artifact = plan.render_templates( + name="blutgang-config-artifact", + config={ + "blutgang-config.toml": struct(template=blutgang_config_template, data={ + "l2_sequencer_url": zkevm_sequencer_http_url, + "l2_rpc_url": zkevm_rpc_http_url, + "l2_ws_url": zkevm_rpc_ws_url, + "l2_rpc_pless_url": zkevm_rpc_pless_http_url, + "l2_ws_pless_url": zkevm_rpc_pless_ws_url, + } | args) + }, + ) + + blutgang_service_config = ServiceConfig( + image=args["blutgang_image"], + ports={ + "http": PortSpec(args["blutgang_rpc_port"], application_protocol="http"), + "admin": PortSpec(args["blutgang_admin_port"], application_protocol="http"), + }, + files={ + "/etc/blutgang": Directory( + artifact_names=[ + blutgang_config_artifact, + ] + ), + }, + cmd=["/app/blutgang", "-c", "/etc/blutgang/blutgang-config.toml"] + ) + + plan.add_service( + name=blutgang_name, + config=blutgang_service_config, + description="Starting blutgang service", + ) \ No newline at end of file diff --git a/main.star b/main.star index 1cc717104..b516fd6ab 100644 --- a/main.star +++ b/main.star @@ -5,7 +5,7 @@ cdk_central_environment_package = import_module("./cdk_central_environment.star" cdk_bridge_infra_package = import_module("./cdk_bridge_infra.star") zkevm_permissionless_node_package = import_module("./zkevm_permissionless_node.star") observability_package = import_module("./observability.star") - +blutgang_package = import_module("./cdk_blutgang.star") def run( plan, @@ -16,6 +16,7 @@ def run( deploy_cdk_central_environment=True, deploy_zkevm_permissionless_node=True, deploy_observability=True, + deploy_blutgang=True, args={ "deployment_suffix": "-001", "zkevm_prover_image": "hermeznetwork/zkevm-prover:v6.0.0", @@ -102,6 +103,9 @@ def run( "zkevm_aggregator_host": "zkevm-node-aggregator-001", "genesis_file": "templates/permissionless-node/genesis.json", "polycli_version": "v0.1.42", + "blutgang_image": "makemake1337/blutgang:latest", + "blutgang_rpc_port": "55555", + "blutgang_admin_port": "55556", }, ): """Deploy a Polygon CDK Devnet with various configurable options. @@ -187,3 +191,11 @@ def run( observability_package.run(plan, observability_args) else: plan.print("Skipping the deployment of the observability stack") + + # Deploy blutgang for caching + if deploy_blutgang: + plan.print("Deploying blutgang") + blutgang_args = dict(args) + blutgang_package.run(plan, blutgang_args) + else: + plan.print("Skipping the deployment of blutgang") \ No newline at end of file diff --git a/params.yml b/params.yml index cff5dba66..92e82a385 100644 --- a/params.yml +++ b/params.yml @@ -23,6 +23,9 @@ deploy_zkevm_permissionless_node: true # Deploy observability stack. deploy_observability: true +# Deploy eth loadbalancer (blutgang). +deploy_blutgang: true + args: # Suffix appended to service names. # Note: It should be a string. @@ -180,3 +183,9 @@ args: ## Tools versions polycli_version: v0.1.42 + + ## blutgang configuration. + blutgang_image: makemake1337/blutgang:0.3.5 + + blutgang_rpc_port: 55555 + blutgang_admin_port: 55556 \ No newline at end of file diff --git a/templates/blutgang/blutgang-config.toml b/templates/blutgang/blutgang-config.toml new file mode 100644 index 000000000..9e870e877 --- /dev/null +++ b/templates/blutgang/blutgang-config.toml @@ -0,0 +1,86 @@ +# Config for blutgang goes here +[blutgang] +# Clear the cache DB on startup +do_clear = true +# Where to bind blutgang to +address = "0.0.0.0:{{.blutgang_rpc_port}}" +# Moving average length for the latency +ma_length = 100 +# Sort RPCs by latency on startup. Recommended to leave on. +sort_on_startup = true +# Enable health checking +health_check = true +# Enable content type header checking. Set this to `true` if you want +# Blutgang to be JSON-RPC compliant. +header_check = true +# Acceptable time to wait for a response in ms +ttl = 30 +# How many times to retry a request before giving up +max_retries = 32 +# Block time in ms, used as a sanity check when not receiving subscriptions +expected_block_time = 20000 +# Time between health checks in ms +health_check_ttl = 400 +# Supress the health check running info messages +supress_rpc_check = false + +# Note: the admin namespace contains volatile functions and +# should not be exposed publicly. +[admin] +# Enable the admin namespace +enabled = true +# Address for the admin RPC +address = "0.0.0.0:{{.blutgang_admin_port}}" +# Only allow read-only methods +# Recommended `true` unless you 100% need write methods +readonly = true +# Enable the use of JWT for auth +# Should be on if exposing to the internet +jwt = false +# jwt token +key = "" + +# Sled config +# Sled is the database we use for our cache, for more info check their docs +[sled] +# Path to db +db_path = "./blutgang-cache" +# sled mode. Can be HighThroughput/LowSpace +mode = "HighThroughput" +# Cache size in bytes. +cache_capacity = 1000000000 +# Use zstd compression. Reduces size 60-70%, +# and increases CPU and latency by around 10% for db writes and 2% for reads. +# If storage constrained, it's fine to have it be on. +compression = false +# Print DB profile when dropped. Doesn't do anything for now. +print_profile = false +# Frequency of flushes in ms +flush_every_ms = 240 + +# Add separate RPCs as TOML tables +# DO NOT name an rpc `blutgang`, `admin`, or `sled` + +[sequencer] +url = "{{.l2_sequencer_url}}" +# ws_url = "{{.l2_sequencer_ws_url}}" +# The maximum amount of time we can use this rpc in a row. +max_consecutive = 150 +# Max amount of queries per second. +max_per_second = 200 + +[rpc] +url = "{{.l2_rpc_url}}" +ws_url = "{{.l2_ws_url}}" +# The maximum amount of time we can use this rpc in a row. +max_consecutive = 150 +# Max amount of queries per second. +max_per_second = 200 + +[rpcpless] +url = "{{.l2_rpc_pless_url}}" +ws_url = "{{.l2_ws_pless_url}}" +# The maximum amount of time we can use this rpc in a row. +max_consecutive = 150 +# Max amount of queries per second. +max_per_second = 200