Skip to content

Commit

Permalink
Merge branch 'main' into chore/enhance-management-of-custom-docker-im…
Browse files Browse the repository at this point in the history
…ages
  • Loading branch information
leovct authored Apr 29, 2024
2 parents b6b73b8 + 4f9160d commit 326f22d
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 5 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_observability = false' params.yml
yq -Y --in-place '.deploy_blutgang = false' params.yml
yq -Y --in-place '.apply_workload = 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_blutgang = false' params.yml # reset
- name: Apply workload
run: |
yq -Y --in-place '.apply_workload = true' params.yml
kurtosis run --enclave cdk-v1 --args-file params.yml .
yq -Y --in-place '.apply_workload = false' params.yml # reset
- name: Check that batches are being verified
run: |
timeout_minutes="${CHECK_VERIFIED_BATCHES_TIMEOUT_MINUTES}"
Expand Down
24 changes: 24 additions & 0 deletions doc-drafts/workload.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM golang:1.21 AS polycli-builder
ARG POLYCLI_VERSION
WORKDIR /opt/polygon-cli
RUN git clone --branch ${POLYCLI_VERSION} https://github.com/maticnetwork/polygon-cli.git . \
&& CGO_ENABLED=0 go build -o polycli main.go


FROM ubuntu:22.04
LABEL author="[email protected]"
LABEL description="Helper image capable of executing diverse workloads"

COPY --from=polycli-builder /opt/polygon-cli/polycli /usr/bin/polycli
# WARNING (DL3008): Pin versions in apt get install.
# WARNING (DL4006): Set the SHELL option -o pipefail before RUN with a pipe in it
# WARNING (SC1091): (Sourced) file not included in mock.
# hadolint ignore=DL3008,DL4006,SC1091
RUN apt-get update \
&& apt-get install --yes --no-install-recommends curl jq git python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& pip3 install yq \
&& curl --silent --location --proto "=https" https://foundry.paradigm.xyz | bash \
&& /root/.foundry/bin/foundryup \
&& cp /root/.foundry/bin/* /usr/local/bin
18 changes: 17 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +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")
workload_package = import_module("./workload.star")
blutgang_package = import_module("./cdk_blutgang.star")


Expand All @@ -18,6 +19,7 @@ def run(
deploy_zkevm_permissionless_node=True,
deploy_observability=True,
deploy_blutgang=True,
apply_workload=False,
args={
"deployment_suffix": "-001",
"zkevm_prover_image": "hermeznetwork/zkevm-prover:v6.0.0",
Expand Down Expand Up @@ -94,6 +96,7 @@ def run(
"l1_preallocated_mnemonic": "code code code code code code code code code code code quality",
"l1_rpc_url": "http://el-1-geth-lighthouse:8545",
"l1_ws_url": "ws://el-1-geth-lighthouse:8546",
"l1_additional_services": [],
"zkevm_rollup_chain_id": 10101,
"zkevm_rollup_fork_id": 9,
"zkevm_rollup_consensus": "PolygonValidiumEtrog",
Expand All @@ -104,7 +107,13 @@ def run(
"zkevm_aggregator_host": "zkevm-node-aggregator-001",
"genesis_file": "templates/permissionless-node/genesis.json",
"polycli_version": "v0.1.42",
"l1_additional_services": [],
"workload_scripts": [
"polycli_loadtest_on_l2.sh t", # eth transfers
"polycli_loadtest_on_l2.sh 2", # erc20 transfers
"polycli_loadtest_on_l2.sh 7", # erc721 mints
"polycli_loadtest_on_l2.sh v3", # uniswapv3 swaps
"polycli_rpcfuzz_on_l2.sh", # rpc calls
],
"blutgang_image": "makemake1337/blutgang:latest",
"blutgang_rpc_port": "55555",
"blutgang_admin_port": "55556",
Expand Down Expand Up @@ -194,6 +203,13 @@ def run(
else:
plan.print("Skipping the deployment of the observability stack")

# Apply workload
if apply_workload:
plan.print("Apply workload")
workload_package.run(plan, args)
else:
plan.print("Skipping workload application")

# Deploy blutgang for caching
if deploy_blutgang:
plan.print("Deploying blutgang")
Expand Down
20 changes: 16 additions & 4 deletions params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ deploy_zkevm_permissionless_node: true
# Deploy observability stack.
deploy_observability: true

# Deploy eth loadbalancer (blutgang).
# Deploy eth load balancer.
deploy_blutgang: true

# Apply workload to the different components of the CDK stack.
apply_workload: false

args:
# Suffix appended to service names.
# Note: It should be a string.
Expand All @@ -50,6 +53,7 @@ args:
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_bridge_proxy_image: haproxy:2.9.7

workload_image: leovct/workload:0.0.1

# Port configuration.
zkevm_hash_db_port: 50061
Expand Down Expand Up @@ -183,8 +187,16 @@ args:
## Tools versions
polycli_version: v0.1.42

## blutgang configuration.
blutgang_image: makemake1337/blutgang:0.3.5
## Workload configuration.
workload_commands: [
"polycli_loadtest_on_l2.sh t", # eth transfers
"polycli_loadtest_on_l2.sh 2", # erc20 transfers
"polycli_loadtest_on_l2.sh 7", # erc721 mints
"polycli_loadtest_on_l2.sh v3", # uniswapv3 swaps
"polycli_rpcfuzz_on_l2.sh", # rpc calls
]

## ETH Load balancer configuration.
blutgang_image: makemake1337/blutgang:0.3.5
blutgang_rpc_port: 55555
blutgang_admin_port: 55556
blutgang_admin_port: 55556
13 changes: 13 additions & 0 deletions templates/workload/apply_workload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

echo "Applying workload..."
while true; do
# shellcheck disable=SC1054,SC1083
{{range .commands}}
# shellcheck disable=SC1054,SC1083
{{.}} &
# shellcheck disable=SC1056,SC1072,SC1073,SC1009
{{end}}
sleep 120
done
26 changes: 26 additions & 0 deletions templates/workload/polycli_loadtest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -e

# Check if the required arguments are provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <mode>"
exit 1
fi

mode="$1"
requests=100
concurrency=1
rpc_url="{{.rpc_url}}"

echo "Running polycli loadtest (rpc_url=$rpc_url mode=$mode requests=$requests concurrency=$concurrency)..."
# shellcheck disable=SC1083,SC2086
polycli loadtest \
--rpc-url "$rpc_url" \
--chain-id {{.chain_id}} \
--private-key "{{.private_key}}" \
--verbosity 700 \
--mode "$mode" \
--requests "$requests" \
--concurrency "$concurrency" \
{{if .send_legacy_tx}}--legacy{{end}} \
2>$1 | awk -v mode="$mode" -v url="$rpc_url" '{print "loadtest-" mode "-" url " " $0}'
8 changes: 8 additions & 0 deletions templates/workload/polycli_rpcfuzz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

echo "Running polycli rpcfuzz (rpc_url={{.rpc_url}})..."
polycli rpcfuzz \
--rpc-url "{{.rpc_url}}" \
--private-key "{{.private_key}}" \
2>&1 | awk '{print "[rpcfuzz] " $0}'
51 changes: 51 additions & 0 deletions workload.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
def run(plan, args):
# Create scripts artifacts.
apply_workload_template = read_file(src="./templates/workload/apply_workload.sh")
polycli_loadtest_template = read_file(
src="./templates/workload/polycli_loadtest.sh"
)
polycli_rpcfuzz_template = read_file(src="./templates/workload/polycli_rpcfuzz.sh")
zkevm_rpc_service = plan.get_service("zkevm-node-rpc" + args["deployment_suffix"])
zkevm_rpc_url = "http://{}:{}".format(
zkevm_rpc_service.ip_address, zkevm_rpc_service.ports["http-rpc"].number
)
workload_script_artifact = plan.render_templates(
name="workload-script-artifact",
config={
"apply_workload.sh": struct(
template=apply_workload_template,
data={
"commands": args["workload_commands"],
},
),
"polycli_loadtest_on_l2.sh": struct(
template=polycli_loadtest_template,
data={
"rpc_url": zkevm_rpc_url,
"chain_id": args["zkevm_rollup_chain_id"],
"private_key": args["zkevm_l2_admin_private_key"],
"send_legacy_tx": True,
},
),
"polycli_rpcfuzz_on_l2.sh": struct(
template=polycli_rpcfuzz_template,
data={
"rpc_url": zkevm_rpc_url,
"private_key": args["zkevm_l2_admin_private_key"],
},
),
},
)

plan.add_service(
name="workload" + args["deployment_suffix"],
config=ServiceConfig(
image=args["workload_image"],
files={
"/usr/local/bin": Directory(artifact_names=[workload_script_artifact]),
},
entrypoint=["bash", "-c"],
cmd=["chmod +x /usr/local/bin/*.sh && apply_workload.sh"],
user=User(uid=0, gid=0), # Run the container as root user.
),
)

0 comments on commit 326f22d

Please sign in to comment.