Skip to content

Commit

Permalink
Merge branch 'main' into feat/cdk-erigon-node-3
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct authored Apr 26, 2024
2 parents 900ef3e + 20b02a0 commit fadf84b
Show file tree
Hide file tree
Showing 12 changed files with 542 additions and 14 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ jobs:
yq -Y --in-place '.deploy_zkevm_permissionless_node = false' params.yml
yq -Y --in-place '.deploy_cdk_erigon_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: |
Expand Down Expand Up @@ -173,6 +174,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}"
Expand Down
51 changes: 51 additions & 0 deletions cdk_blutgang.star
Original file line number Diff line number Diff line change
@@ -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",
)
2 changes: 2 additions & 0 deletions doc-drafts/ready-for-publication/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Docs in this folder are ready to be edited and meant for public
guides.
357 changes: 357 additions & 0 deletions doc-drafts/working-with-the-timelock/working-with-the-timelock.org

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions docs/how-to/quick-test-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ comments: true

A quick and easy method for testing a running CDK stack, whether in validium or rollup mode, is by sending a zero-value transaction and examining the result.

## Get the URL

First inspect the logs to find the `zkevm-node-rpc` details. For example, in the Kurtosis stack you should see something like:

```sh
zkevm-node-rpc-001 http-rpc: 8123/tcp -> http://127.0.0.1:32803
```
```sh
zkevm-node-rpc-001 http-rpc: 8123/tcp -> http://127.0.0.1:32803
```

## Send transaction with cast

Expand Down
6 changes: 4 additions & 2 deletions docs/how-to/use-native-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,11 @@ The first derived private key from the `code...quality` mnemonic is
![Balance of receiving account](../img/how-to/gas-token-img/12_bridge.png)
## Using cast to do a bridge claim
## Using cast to withdraw assets from the bridge
The following work-in-progress cast script processes a bridge claim. Feel free to go through line-by-line and tweak where necessary.
The following work-in-progress cast script processes a bridge claim.
Feel free to go through line-by-line and tweak where necessary.
```sh
#!/bin/bash
Expand Down
8 changes: 4 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ hide:

# Overview

Kurtosis is a developer platform that allows you to package and launch a backend stack without becoming overburdened with configuration details.
[Kurtosis](https://docs.kurtosis.com/) is a developer platform that allows you to package and launch a backend stack without becoming overburdened with configuration details.

The Polygon team has implemented a Kurtosis build for the CDK stack which includes all zkEVM node components, services, and a validium option.
The Polygon team has implemented a stable CDK build with Kurtosis which includes all node components and services, as well as a validium option.

The documentation in this get started section relates to the CDK Kurtosis implementation.

## CDK architecture

Expand All @@ -24,7 +26,5 @@ The diagram below shows how CDK stack components may interact with each other an

The [quick start documents](quickstart/deploy-stack.md) show you how to deploy a private, portable, and modular Polygon CDK developer stack on [Kurtosis](https://github.com/kurtosis-tech/kurtosis).

The deployment document is aimed at users and developers who do not necessarily want to run the latest CDK versions, or follow the full tutorials, and are happy to play around with an experimental set up.

<br/>

14 changes: 13 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cdk_bridge_infra_package = import_module("./cdk_bridge_infra.star")
zkevm_permissionless_node_package = import_module("./zkevm_permissionless_node.star")
cdk_erigon_package = import_module("./cdk_erigon.star")
observability_package = import_module("./observability.star")

blutgang_package = import_module("./cdk_blutgang.star")

def run(
plan,
Expand All @@ -18,6 +18,7 @@ def run(
deploy_zkevm_permissionless_node=True,
deploy_cdk_erigon_node=True,
deploy_observability=True,
deploy_blutgang=True,
args={
"deployment_suffix": "-001",
"zkevm_prover_image": "hermeznetwork/zkevm-prover:v6.0.0",
Expand Down Expand Up @@ -105,6 +106,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.
Expand Down Expand Up @@ -197,3 +201,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")
5 changes: 2 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ theme:

nav:
- Overview: index.md
- For technical users:
- Deploy and manage a CDK stack:
- Deploy the CDK stack: quickstart/deploy-stack.md
- Set up a permissionless node: quickstart/set-up-node.md
- Observability: quickstart/observability.md
- For developers:
- Breakdown the deployment: quickstart/breakdown-deployment.md
- zkEVM contracts caching: quickstart/zkevm-cache-contracts.md
- How to:
- Migrate:
- Fork id 7 to 9: how-to/migrate/forkid-7-to-9.md
- Use a native token: how-to/use-native-token.md
- Mint, bridge, and use tokens: how-to/use-native-token.md
- Integrate a DAC: how-to/integrate-da.md
- Manage allowlists with policies: how-to/manage-policies.md
- Quickly test a running stack: how-to/quick-test-stack.md
Expand Down
10 changes: 10 additions & 0 deletions params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ deploy_cdk_erigon_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.
Expand Down Expand Up @@ -148,6 +151,7 @@ args:
## L1 configuration.
l1_chain_id: 271828
l1_preallocated_mnemonic: code code code code code code code code code code code quality
l1_funding_amount: 100ether
l1_rpc_url: http://el-1-geth-lighthouse:8545
l1_ws_url: ws://el-1-geth-lighthouse:8546
# https://github.com/kurtosis-tech/ethereum-package/tree/main?tab=readme-ov-file#configuration
Expand Down Expand Up @@ -182,3 +186,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
86 changes: 86 additions & 0 deletions templates/blutgang/blutgang-config.toml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion templates/contract-deploy/run-contract-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fund_account_on_l1() {
cast send \
--rpc-url "{{.l1_rpc_url}}" \
--mnemonic "{{.l1_preallocated_mnemonic}}" \
--value "100ether" \
--value "{{.l1_funding_amount}}" \
"$address"
}

Expand Down

0 comments on commit fadf84b

Please sign in to comment.