From 25169a35a0024aee486b50cafb6f728f7a4caa96 Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:15:47 -0400 Subject: [PATCH 01/10] feat: initialize kurtosis package --- kurtosis.yml | 4 +++ main.star | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 kurtosis.yml create mode 100644 main.star diff --git a/kurtosis.yml b/kurtosis.yml new file mode 100644 index 0000000..bd10c79 --- /dev/null +++ b/kurtosis.yml @@ -0,0 +1,4 @@ +name: github.com/rollkit/cosmwasm +description: |- + Kurtosis package for a Rollkit CosmWasm rollup +replace: {} diff --git a/main.star b/main.star new file mode 100644 index 0000000..975eaf0 --- /dev/null +++ b/main.star @@ -0,0 +1,77 @@ +# This Kurtosis package spins up a minimal CosmWasm rollup that connects to a DA node +# +# NOTE: currently this is only connecting to a local DA node + +da_node = import_module("github.com/rollkit/local-da/main.star@v0.3.0") + +def run(plan): + ########## + # DA + ########## + + da_address = da_node.run( + plan, + ) + plan.print("connecting to da layer via {0}".format(da_address)) + + ################# + # CosmWasm Rollup + ################# + plan.print("Adding CosmWasm service") + rpc_port_number = 36657 + grpc_port_number = 9290 + p2p_port_number = 36656 + wasmd_start_cmd = [ + "wasmd", + "start", + "--rollkit.aggregator", + "--rollkit.da_address {0}".format(da_address), + "--rpc.laddr tcp://127.0.0.1:{0}".format(rpc_port_number), + "--grpc.address 127.0.0.1:{0}".format(grpc_port_number), + "--p2p.laddr 0.0.0.0:{0}".format(p2p_port_number), + "--minimum-gas-prices='0.025uwasm'", + ] + wasmd_ports = { + "rpc-laddr": defaultPortSpec(rpc_port_number), + # "grpc-addr": defaultPortSpec(grpc_port_number), + # "p2p-laddr": defaultPortSpec(p2p_port_number), + } + wasm = plan.add_service( + name="wasm", + config=ServiceConfig( + # Using CosmWasm version v0.1.0 + # image="ghcr.io/rollkit/cosmwasm:xxxxx", + image = ImageBuildSpec( + image_name="cosmwasm", + build_context_dir=".", + ), + cmd=["/bin/sh", "-c", " ".join(wasmd_start_cmd)], + ports=wasmd_ports, + public_ports=wasmd_ports, + ready_conditions=ReadyCondition( + recipe=ExecRecipe( + command=["wasmd", "status", "-n tcp://localhost:{0}".format(rpc_port_number)], + extract={ + "output": "fromjson | .node_info.network", + }, + ), + field="extract.output", + assertion="==", + target_value="localwasm", + interval="1s", + timeout="1m", + ), + ), + ) + + wasm_address = "http://{0}:{1}".format( + wasm.ip_address, wasm.ports["rpc-laddr"].number + ) + plan.print("CosmWasm service is available at {0}".format(wasm_address)) + +def defaultPortSpec(port_number): + return PortSpec( + number=port_number, + transport_protocol="TCP", + application_protocol="http", + ) \ No newline at end of file From 7cff748c99be0096ea2fe8d1355865b614b62bb2 Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:08:24 -0400 Subject: [PATCH 02/10] testing --- .github/workflows/docker-build-publish.yml | 2 +- main.star | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-build-publish.yml b/.github/workflows/docker-build-publish.yml index 2aa7afe..ec01ebe 100644 --- a/.github/workflows/docker-build-publish.yml +++ b/.github/workflows/docker-build-publish.yml @@ -14,7 +14,7 @@ jobs: permissions: contents: write packages: write - uses: rollkit/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.4.1 + uses: rollkit/.github/.github/workflows/reusable_dockerfile_pipeline.yml@develop with: dockerfile: Dockerfile secrets: inherit diff --git a/main.star b/main.star index 975eaf0..c40157b 100644 --- a/main.star +++ b/main.star @@ -74,4 +74,4 @@ def defaultPortSpec(port_number): number=port_number, transport_protocol="TCP", application_protocol="http", - ) \ No newline at end of file + ) From 3b19c3b8a820e764123009ce44d9eef53bf6be1b Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:03:55 -0400 Subject: [PATCH 03/10] fix: working mvp of kurtosis instance --- main.star | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.star b/main.star index c40157b..39b470f 100644 --- a/main.star +++ b/main.star @@ -26,15 +26,15 @@ def run(plan): "start", "--rollkit.aggregator", "--rollkit.da_address {0}".format(da_address), - "--rpc.laddr tcp://127.0.0.1:{0}".format(rpc_port_number), - "--grpc.address 127.0.0.1:{0}".format(grpc_port_number), + "--rpc.laddr tcp://0.0.0.0:{0}".format(rpc_port_number), + "--grpc.address 0.0.0.0:{0}".format(grpc_port_number), "--p2p.laddr 0.0.0.0:{0}".format(p2p_port_number), "--minimum-gas-prices='0.025uwasm'", ] wasmd_ports = { "rpc-laddr": defaultPortSpec(rpc_port_number), - # "grpc-addr": defaultPortSpec(grpc_port_number), - # "p2p-laddr": defaultPortSpec(p2p_port_number), + "grpc-addr": defaultPortSpec(grpc_port_number), + "p2p-laddr": defaultPortSpec(p2p_port_number), } wasm = plan.add_service( name="wasm", @@ -50,7 +50,7 @@ def run(plan): public_ports=wasmd_ports, ready_conditions=ReadyCondition( recipe=ExecRecipe( - command=["wasmd", "status", "-n tcp://localhost:{0}".format(rpc_port_number)], + command=["wasmd", "status", "-n", "tcp://127.0.0.1:{0}".format(rpc_port_number)], extract={ "output": "fromjson | .node_info.network", }, @@ -59,7 +59,7 @@ def run(plan): assertion="==", target_value="localwasm", interval="1s", - timeout="1m", + timeout="10s", ), ), ) From a1a16be7e6263a5aeef7260dac2a6d6b75a238fd Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:33:48 -0400 Subject: [PATCH 04/10] chore: use docker iamge --- main.star | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.star b/main.star index 39b470f..763cef0 100644 --- a/main.star +++ b/main.star @@ -40,11 +40,12 @@ def run(plan): name="wasm", config=ServiceConfig( # Using CosmWasm version v0.1.0 - # image="ghcr.io/rollkit/cosmwasm:xxxxx", - image = ImageBuildSpec( - image_name="cosmwasm", - build_context_dir=".", - ), + image="ghcr.io/rollkit/cosmwasm:a661153", + # Use ImageBuildSpec when testing changes to Dockerfile + # image = ImageBuildSpec( + # image_name="cosmwasm", + # build_context_dir=".", + # ), cmd=["/bin/sh", "-c", " ".join(wasmd_start_cmd)], ports=wasmd_ports, public_ports=wasmd_ports, From 4a8197a31fb80ce623a5f3b082824c524c73d605 Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:47:08 -0400 Subject: [PATCH 05/10] feat: reduce docker image size --- Dockerfile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Dockerfile b/Dockerfile index 72cc7db..987f2e5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,6 +50,28 @@ RUN sed -i '/wasmd start/s/^/#/' init.sh RUN bash init.sh +# Stage 2: Create a minimal runtime image +FROM debian:bullseye-slim + +# Install only the necessary runtime dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + bash \ + curl \ + jq \ + ca-certificates \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +WORKDIR /root + +# Copy the wasmd binary from the build stage +COPY --from=build-env /go/bin/wasmd /usr/bin/wasmd + +# Copy the .wasmd directory from the build stage +COPY --from=build-env /root/.wasmd /root/.wasmd + +# Ensure the wasmd binary is executable +RUN chmod +x /usr/bin/wasmd + EXPOSE 36657 36656 9290 # Keep the container running From 2eda1f2798a9d35e337df084d23aa86728c214f1 Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:07:21 -0400 Subject: [PATCH 06/10] testing smaller docker image --- Dockerfile | 15 ++++++++++----- main.star | 11 +++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 987f2e5..19f8f99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ bash \ curl \ jq \ - ranger \ - vim \ libc6 \ ca-certificates \ && apt-get clean \ @@ -51,14 +49,17 @@ RUN sed -i '/wasmd start/s/^/#/' init.sh RUN bash init.sh # Stage 2: Create a minimal runtime image -FROM debian:bullseye-slim +FROM debian:bookworm-slim # Install only the necessary runtime dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ bash \ curl \ + ranger \ jq \ + vim \ ca-certificates \ + libc6 \ && apt-get clean && rm -rf /var/lib/apt/lists/* WORKDIR /root @@ -66,11 +67,15 @@ WORKDIR /root # Copy the wasmd binary from the build stage COPY --from=build-env /go/bin/wasmd /usr/bin/wasmd +# Ensure the wasmd binary is executable +RUN chmod +x /usr/bin/wasmd + # Copy the .wasmd directory from the build stage COPY --from=build-env /root/.wasmd /root/.wasmd -# Ensure the wasmd binary is executable -RUN chmod +x /usr/bin/wasmd +# Copy over wasmd depenendencies +RUN mkdir -p /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.5.0 +COPY --from=build-env /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.5.0/ /go/pkg/mod/github.com/!cosm!wasm/wasmvm@v1.5.0/ EXPOSE 36657 36656 9290 diff --git a/main.star b/main.star index 763cef0..33925b8 100644 --- a/main.star +++ b/main.star @@ -4,6 +4,7 @@ da_node = import_module("github.com/rollkit/local-da/main.star@v0.3.0") + def run(plan): ########## # DA @@ -40,7 +41,7 @@ def run(plan): name="wasm", config=ServiceConfig( # Using CosmWasm version v0.1.0 - image="ghcr.io/rollkit/cosmwasm:a661153", + image="ghcr.io/rollkit/cosmwasm:ad0e9e4", # Use ImageBuildSpec when testing changes to Dockerfile # image = ImageBuildSpec( # image_name="cosmwasm", @@ -51,7 +52,12 @@ def run(plan): public_ports=wasmd_ports, ready_conditions=ReadyCondition( recipe=ExecRecipe( - command=["wasmd", "status", "-n", "tcp://127.0.0.1:{0}".format(rpc_port_number)], + command=[ + "wasmd", + "status", + "-n", + "tcp://127.0.0.1:{0}".format(rpc_port_number), + ], extract={ "output": "fromjson | .node_info.network", }, @@ -70,6 +76,7 @@ def run(plan): ) plan.print("CosmWasm service is available at {0}".format(wasm_address)) + def defaultPortSpec(port_number): return PortSpec( number=port_number, From 3600d620594138b386488c74fee1a3d84cc82b9b Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:08:17 -0400 Subject: [PATCH 07/10] chore: revert docker workflow workaround --- .github/workflows/docker-build-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-build-publish.yml b/.github/workflows/docker-build-publish.yml index ec01ebe..2aa7afe 100644 --- a/.github/workflows/docker-build-publish.yml +++ b/.github/workflows/docker-build-publish.yml @@ -14,7 +14,7 @@ jobs: permissions: contents: write packages: write - uses: rollkit/.github/.github/workflows/reusable_dockerfile_pipeline.yml@develop + uses: rollkit/.github/.github/workflows/reusable_dockerfile_pipeline.yml@v0.4.1 with: dockerfile: Dockerfile secrets: inherit From 04138350530e1c1017767cb0eba0e1ef9e6310cb Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:11:11 -0400 Subject: [PATCH 08/10] fix(ci): spelling error in dockerfile lint --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 36f7b7b..1e78e55 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,6 +18,6 @@ jobs: - uses: rollkit/.github/.github/actions/markdown-lint@v0.4.1 dockerfile-lint: - uses: rollkit/.github/.github/workflows/reuseable_dockerfile_lint.yml@v0.4.1 + uses: rollkit/.github/.github/workflows/reusable_dockerfile_lint.yml@v0.4.1 with: failure-threshold: "error" From bf3964f07450089f9bf05f17c5cdb1481a56a8bb Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:13:58 -0400 Subject: [PATCH 09/10] fix: markdownlint error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 36165bd..0a8ed3f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ This repository contains the supporting code for the [CosmWasm tutorial](https:/ ## Overview -The `main` branch contains the Dockerfile and Kurtosis packages for the CosmWasm tutorial. +The `main` branch contains the Dockerfile and Kurtosis packages for the CosmWasm tutorial. The `tutorial` branch contains the CosmWasm wasmd code that is used to build the binary for reference. From 5eefc6a5a45782519c43fa94a885acb182167792 Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Thu, 11 Jul 2024 11:23:16 -0400 Subject: [PATCH 10/10] chore: update to working docker image --- main.star | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.star b/main.star index 33925b8..5fefac4 100644 --- a/main.star +++ b/main.star @@ -41,7 +41,7 @@ def run(plan): name="wasm", config=ServiceConfig( # Using CosmWasm version v0.1.0 - image="ghcr.io/rollkit/cosmwasm:ad0e9e4", + image="ghcr.io/rollkit/cosmwasm:3b5a25b", # Use ImageBuildSpec when testing changes to Dockerfile # image = ImageBuildSpec( # image_name="cosmwasm",