From c53262cede9d63b3ce3de9af2236d4f4644dea19 Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Thu, 25 Apr 2024 09:32:07 +0900 Subject: [PATCH 1/7] feat: add blutgang integration Signed-off-by: Ji Hwan --- cdk_blutgang.star | 34 ++++++++++ main.star | 22 ++++++- params.yml | 20 ++++++ templates/blutgang/blutgang-config.toml | 86 +++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 cdk_blutgang.star create mode 100644 templates/blutgang/blutgang-config.toml diff --git a/cdk_blutgang.star b/cdk_blutgang.star new file mode 100644 index 00000000..52180436 --- /dev/null +++ b/cdk_blutgang.star @@ -0,0 +1,34 @@ +def run(plan, args): + blutgang_name = "blutgang" + args["deployment_suffix"] + blutgang_config_template = read_file( + src="./templates/blutgang/blutgang-config.toml" + ) + + blutgang_config_artifact = plan.render_templates( + name="blutgang-config-artifact", + config={ + "blutgang-config.toml": struct(template=blutgang_config_template, data=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 1cc71710..5278360b 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,17 @@ 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_http_address": "0.0.0.0:55555", + "blutgang_admin_address": "0.0.0.0:55556", + "blutgang_rpc_port": "55555", + "blutgang_admin_port": "55556", + "l2_sequencer_url": "http://zkevm-node-sequencer-001:8123", + "l2_sequencer_ws_url": "ws://zkevm-node-sequencer-001:8133", + "l2_rpc_url": "http://zkevm-node-rpc-001:8123", + "l2_ws_url": "ws://zkevm-node-rpc-001:8133", + "l2_rpc_pless_url": "http://zkevm-node-rpc-pless-001:8123", + "l2_ws_pless_url": "ws://zkevm-node-rpc-pless-001:8133", }, ): """Deploy a Polygon CDK Devnet with various configurable options. @@ -187,3 +199,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 f7fd5646..6dc37212 100644 --- a/params.yml +++ b/params.yml @@ -23,6 +23,9 @@ deploy_zkevm_permissionless_node: true # Deploy observability stack. deploy_observability: true +# Deploy blutgang. +deploy_blutgang: true + args: # Suffix appended to service names. # Note: It should be a string. @@ -179,3 +182,20 @@ args: ## Tools versions polycli_version: v0.1.42 + + ## blutgang configuration. + blutgang_image: makemake1337/blutgang:latest + + blutgang_http_address: 0.0.0.0:55555 + blutgang_admin_address: 0.0.0.0:55556 + blutgang_rpc_port: 55555 + blutgang_admin_port: 55556 + + l2_sequencer_url: http://zkevm-node-sequencer-001:8123 + l2_sequencer_ws_url: ws://zkevm-node-sequencer-001:8133 + + l2_rpc_url: http://zkevm-node-rpc-001:8123 + l2_ws_url: ws://zkevm-node-rpc-001:8133 + + l2_rpc_pless_url: http://zkevm-node-rpc-pless-001:8123 + l2_ws_pless_url: ws://zkevm-node-rpc-pless-001:8133 \ 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 00000000..73d42bb1 --- /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 = "{{.blutgang_http_address}}" +# 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 = "{{.blutgang_admin_address}}" +# 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 From 7bac289f58e97ca94c711a5337f73645f906f29e Mon Sep 17 00:00:00 2001 From: Ji Hwan KIM <125336262+jhkimqd@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:20:07 +0900 Subject: [PATCH 2/7] Update params.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Léo Vincent <28714795+leovct@users.noreply.github.com> --- params.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params.yml b/params.yml index 6dc37212..47dcfe80 100644 --- a/params.yml +++ b/params.yml @@ -184,7 +184,7 @@ args: polycli_version: v0.1.42 ## blutgang configuration. - blutgang_image: makemake1337/blutgang:latest + blutgang_image: makemake1337/blutgang:0.3.5 blutgang_http_address: 0.0.0.0:55555 blutgang_admin_address: 0.0.0.0:55556 From 6c3b842f0e46aebff5b50bbe927b3b0237f35e70 Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Thu, 25 Apr 2024 17:33:47 +0900 Subject: [PATCH 3/7] chore: make commment more intuitive Signed-off-by: Ji Hwan --- params.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params.yml b/params.yml index 6dc37212..527103fd 100644 --- a/params.yml +++ b/params.yml @@ -23,7 +23,7 @@ deploy_zkevm_permissionless_node: true # Deploy observability stack. deploy_observability: true -# Deploy blutgang. +# Deploy eth loadbalancer (blutgang). deploy_blutgang: true args: From a0b73af3924cf4372cbf345d18981c797f10f889 Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Thu, 25 Apr 2024 23:31:07 +0900 Subject: [PATCH 4/7] chore: cleanup Signed-off-by: Ji Hwan --- cdk_blutgang.star | 19 ++++++++++++++++++- params.yml | 13 +------------ templates/blutgang/blutgang-config.toml | 6 +++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/cdk_blutgang.star b/cdk_blutgang.star index 52180436..8108ee68 100644 --- a/cdk_blutgang.star +++ b/cdk_blutgang.star @@ -4,10 +4,27 @@ def run(plan, args): src="./templates/blutgang/blutgang-config.toml" ) + zkevm_sequencer_service = plan.get_service("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("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("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=args) + "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) }, ) diff --git a/params.yml b/params.yml index 674fb0e3..c89a36f2 100644 --- a/params.yml +++ b/params.yml @@ -186,16 +186,5 @@ args: ## blutgang configuration. blutgang_image: makemake1337/blutgang:0.3.5 - blutgang_http_address: 0.0.0.0:55555 - blutgang_admin_address: 0.0.0.0:55556 blutgang_rpc_port: 55555 - blutgang_admin_port: 55556 - - l2_sequencer_url: http://zkevm-node-sequencer-001:8123 - l2_sequencer_ws_url: ws://zkevm-node-sequencer-001:8133 - - l2_rpc_url: http://zkevm-node-rpc-001:8123 - l2_ws_url: ws://zkevm-node-rpc-001:8133 - - l2_rpc_pless_url: http://zkevm-node-rpc-pless-001:8123 - l2_ws_pless_url: ws://zkevm-node-rpc-pless-001:8133 \ No newline at end of file + blutgang_admin_port: 55556 \ No newline at end of file diff --git a/templates/blutgang/blutgang-config.toml b/templates/blutgang/blutgang-config.toml index 73d42bb1..9e870e87 100644 --- a/templates/blutgang/blutgang-config.toml +++ b/templates/blutgang/blutgang-config.toml @@ -3,7 +3,7 @@ # Clear the cache DB on startup do_clear = true # Where to bind blutgang to -address = "{{.blutgang_http_address}}" +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. @@ -30,7 +30,7 @@ supress_rpc_check = false # Enable the admin namespace enabled = true # Address for the admin RPC -address = "{{.blutgang_admin_address}}" +address = "0.0.0.0:{{.blutgang_admin_port}}" # Only allow read-only methods # Recommended `true` unless you 100% need write methods readonly = true @@ -63,7 +63,7 @@ flush_every_ms = 240 [sequencer] url = "{{.l2_sequencer_url}}" -ws_url = "{{.l2_sequencer_ws_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. From a3d4c617bf9234443d801b0c426511f09da83986 Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Fri, 26 Apr 2024 10:26:31 +0900 Subject: [PATCH 5/7] fix: add name= to add_service() Signed-off-by: Ji Hwan --- cdk_blutgang.star | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cdk_blutgang.star b/cdk_blutgang.star index 8108ee68..1fcbc272 100644 --- a/cdk_blutgang.star +++ b/cdk_blutgang.star @@ -4,14 +4,14 @@ def run(plan, args): src="./templates/blutgang/blutgang-config.toml" ) - zkevm_sequencer_service = plan.get_service("zkevm-node-sequencer" + args["deployment_suffix"]) + 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("zkevm-node-rpc" + args["deployment_suffix"]) + 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("zkevm-node-rpc-pless" + args["deployment_suffix"]) + 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) From 2265440631bf3c80f31e81951ad02c11b75365a9 Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Fri, 26 Apr 2024 12:48:31 +0900 Subject: [PATCH 6/7] fix: add blutgang workflow to fix ci Signed-off-by: Ji Hwan --- .github/workflows/deploy.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 034d4dc2..7c9d5c2e 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}" From e13693a20b6d6c589f618ffab76fd3b7d02596b4 Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Fri, 26 Apr 2024 15:58:21 +0900 Subject: [PATCH 7/7] chore: remove unused vars Signed-off-by: Ji Hwan --- main.star | 8 -------- 1 file changed, 8 deletions(-) diff --git a/main.star b/main.star index 5278360b..b516fd6a 100644 --- a/main.star +++ b/main.star @@ -104,16 +104,8 @@ def run( "genesis_file": "templates/permissionless-node/genesis.json", "polycli_version": "v0.1.42", "blutgang_image": "makemake1337/blutgang:latest", - "blutgang_http_address": "0.0.0.0:55555", - "blutgang_admin_address": "0.0.0.0:55556", "blutgang_rpc_port": "55555", "blutgang_admin_port": "55556", - "l2_sequencer_url": "http://zkevm-node-sequencer-001:8123", - "l2_sequencer_ws_url": "ws://zkevm-node-sequencer-001:8133", - "l2_rpc_url": "http://zkevm-node-rpc-001:8123", - "l2_ws_url": "ws://zkevm-node-rpc-001:8133", - "l2_rpc_pless_url": "http://zkevm-node-rpc-pless-001:8123", - "l2_ws_pless_url": "ws://zkevm-node-rpc-pless-001:8133", }, ): """Deploy a Polygon CDK Devnet with various configurable options.