From 502579c0de00645da84518d0b70f503e5df2b7a0 Mon Sep 17 00:00:00 2001 From: Renan Santos Date: Mon, 3 Jun 2024 12:51:17 -0300 Subject: [PATCH 1/3] fix: stop end-to-end testing --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 247ae1173..13267952a 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,10 @@ submodules: ## Download the git submodules @git submodule update --init --recursive .PHONY: test -test: unit-test e2e-test ## Execute all tests +test: unit-test ## Execute all tests .PHONY: unit-test -unit-test:## Execute unit tests +unit-test: ## Execute unit tests @echo "Running unit tests" @go test ./... @@ -91,3 +91,4 @@ docker-clean: ## Remove the containers and volumes from previous compose run .PHONY: help help: ## Show help for each of the Makefile recipes @grep "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/:.*##\(.*\)/:\n\t\1\n/' + From 5a56ecc52b08c729dad31219b29a8c4942edf8e4 Mon Sep 17 00:00:00 2001 From: Renan Santos Date: Thu, 6 Jun 2024 14:38:04 -0300 Subject: [PATCH 2/3] chore: update machine version and devnet addresses --- build/compose-devnet.yaml | 2 +- build/docker-bake.hcl | 29 +++++++++++++++-------------- pkg/addresses/addresses.go | 2 +- setup_env.sh | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/build/compose-devnet.yaml b/build/compose-devnet.yaml index da518ef69..b7339fa62 100644 --- a/build/compose-devnet.yaml +++ b/build/compose-devnet.yaml @@ -19,7 +19,7 @@ services: CARTESI_BLOCKCHAIN_WS_ENDPOINT: "ws://devnet:8545" CARTESI_BLOCKCHAIN_IS_LEGACY: "false" CARTESI_BLOCKCHAIN_FINALITY_OFFSET: "1" - CARTESI_CONTRACTS_APPLICATION_ADDRESS: "0xb72c832dDeA10326143831F1E5F1646920C9c990" + CARTESI_CONTRACTS_APPLICATION_ADDRESS: "0x2E663fe9aE92275242406A185AA4fC8174339D3E" CARTESI_CONTRACTS_ICONSENSUS_ADDRESS: "0x77e5a5fb18F72b5106621f66C704c006c6dB4578" CARTESI_CONTRACTS_INPUT_BOX_ADDRESS: "0xA1b8EB1F13d8D5Db976a653BbDF8972cfD14691C" CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER: "16" diff --git a/build/docker-bake.hcl b/build/docker-bake.hcl index 97d82d813..2c2025ca7 100644 --- a/build/docker-bake.hcl +++ b/build/docker-bake.hcl @@ -17,22 +17,23 @@ target "common" { dockerfile = "./build/Dockerfile" context = ".." args = { - BASE_IMAGE = "debian:bookworm-20240311-slim" - RUST_VERSION = "1.78.0" - GO_VERSION = "1.22.1" - FOUNDRY_NIGHTLY_VERSION = "293fad73670b7b59ca901c7f2105bf7a29165a90" - MACHINE_EMULATOR_VERSION = "0.16.1" - TOOLS_VERSION = "0.14.1" - LINUX_VERSION = "0.19.1" - LINUX_KERNEL_VERSION = "6.5.9-ctsi-1-v0.19.1" + BASE_IMAGE = "debian:bookworm-20240311-slim" + RUST_VERSION = "1.78.0" + GO_VERSION = "1.22.1" + FOUNDRY_NIGHTLY_VERSION = "293fad73670b7b59ca901c7f2105bf7a29165a90" + MACHINE_EMULATOR_VERSION = "0.17.0" + MACHINE_TOOLS_VERSION = "0.15.0" + MACHINE_IMAGE_KERNEL_VERSION = "0.20.0" + MACHINE_KERNEL_VERSION = "6.5.13" + MACHINE_XGENEXT2FS_VERSION = "1.5.6" } } target "rollups-node" { inherits = ["common"] target = "rollups-node" - args = { - ROLLUPS_NODE_VERSION = "devel" + args = { + ROLLUPS_NODE_VERSION = "devel" } } @@ -46,9 +47,9 @@ target "rollups-node-devnet" { target = "rollups-node-devnet" } -target "rollups-node-ci-base" { - inherits = ["common"] - target = "rollups-node-ci-base" +target "rollups-node-ci" { + inherits = ["common"] + target = "rollups-node-ci" dockerfile = "./Dockerfile" - context = "." + context = "." } diff --git a/pkg/addresses/addresses.go b/pkg/addresses/addresses.go index 8a4b710a2..466b63254 100644 --- a/pkg/addresses/addresses.go +++ b/pkg/addresses/addresses.go @@ -35,7 +35,7 @@ type Book struct { // Get the addresses for the test environment. func GetTestBook() *Book { return &Book{ - Application: common.HexToAddress("0xb72c832dDeA10326143831F1E5F1646920C9c990"), + Application: common.HexToAddress("0x2E663fe9aE92275242406A185AA4fC8174339D3E"), ApplicationFactory: common.HexToAddress("0x39cc8d1faB70F713784032f166aB7Fe3B4801144"), Authority: common.HexToAddress("0x77e5a5fb18F72b5106621f66C704c006c6dB4578"), AuthorityFactory: common.HexToAddress("0x5EF4260c72a7A8df752AFF49aC46Ba741754E04a"), diff --git a/setup_env.sh b/setup_env.sh index b6f7fcf45..761cab0e4 100644 --- a/setup_env.sh +++ b/setup_env.sh @@ -9,7 +9,7 @@ export CARTESI_BLOCKCHAIN_WS_ENDPOINT="ws://localhost:8545" export CARTESI_BLOCKCHAIN_IS_LEGACY="false" export CARTESI_BLOCKCHAIN_FINALITY_OFFSET="1" export CARTESI_BLOCKCHAIN_BLOCK_TIMEOUT="60" -export CARTESI_CONTRACTS_APPLICATION_ADDRESS="0xb72c832dDeA10326143831F1E5F1646920C9c990" +export CARTESI_CONTRACTS_APPLICATION_ADDRESS="0x2E663fe9aE92275242406A185AA4fC8174339D3E" export CARTESI_CONTRACTS_ICONSENSUS_ADDRESS="0x77e5a5fb18F72b5106621f66C704c006c6dB4578" export CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="0xA1b8EB1F13d8D5Db976a653BbDF8972cfD14691C" export CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER="16" From e1b1e2462c49ceef34fcc5c755fdae87f3bc4343 Mon Sep 17 00:00:00 2001 From: Renan Santos Date: Thu, 6 Jun 2024 14:38:47 -0300 Subject: [PATCH 3/3] feat: update the Dockerfile with emulator dependencies - Adds linux.bin and rootfs.ext2 download to the emulator stage. - Adds a emulator-devel stage that install libcmt and xgenext2fs. - Configures the CI image to use CGO. - Refactors the Dockerfile to improve readability. --- .github/workflows/build.yml | 6 +- .github/workflows/clean-up-images.yml | 2 +- build/Dockerfile | 457 +++++++++++++++++--------- build/docker-bake.override.hcl | 4 +- internal/node/machinehash_test.go | 3 +- 5 files changed, 306 insertions(+), 166 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0b157164..ba1b16077 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -140,7 +140,7 @@ jobs: uses: docker/metadata-action@v5 with: images: | - name=ghcr.io/cartesi/rollups-node-ci-base + name=ghcr.io/cartesi/rollups-node-ci tags: | type=semver,pattern={{version}} type=ref,event=branch @@ -162,7 +162,7 @@ jobs: ./docker-bake.hcl ${{ steps.docker_meta.outputs.bake-file }} ./docker-bake.platforms.hcl - targets: rollups-node-ci-base + targets: rollups-node-ci push: true project: ${{ vars.DEPOT_PROJECT }} workdir: build @@ -174,7 +174,7 @@ jobs: test-go: runs-on: ubuntu-22.04 container: - image: ghcr.io/cartesi/rollups-node-ci-base:${{needs.build-ci-base.outputs.output}} + image: ghcr.io/cartesi/rollups-node-ci:${{needs.build-ci-base.outputs.output}} needs: - build-ci-base steps: diff --git a/.github/workflows/clean-up-images.yml b/.github/workflows/clean-up-images.yml index d3d030c78..acccfeb41 100644 --- a/.github/workflows/clean-up-images.yml +++ b/.github/workflows/clean-up-images.yml @@ -17,7 +17,7 @@ jobs: matrix: image: - rollups-node - - rollups-node-ci-base + - rollups-node-ci steps: - uses: vlaurin/action-ghcr-prune@v0.6.0 with: diff --git a/build/Dockerfile b/build/Dockerfile index a65da65e6..fde0a34d5 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -3,20 +3,18 @@ # syntax=docker.io/docker/dockerfile:1 -# This dockerfile contains multiple stages to build three final targets. -# The file was split in a section for each final target. - -# Version config that should be set in the bake file. +# Version configuration that should be set in the bake file. ARG BASE_IMAGE ARG RUST_VERSION ARG GO_VERSION ARG FOUNDRY_NIGHTLY_VERSION -ARG MACHINE_EMULATOR_VERSION -ARG ROOTFS_VERSION -ARG LINUX_VERSION -ARG LINUX_KERNEL_VERSION ARG ROM_VERSION ARG ROLLUPS_NODE_VERSION +ARG MACHINE_EMULATOR_VERSION +ARG MACHINE_TOOLS_VERSION +ARG MACHINE_IMAGE_KERNEL_VERSION +ARG MACHINE_KERNEL_VERSION +ARG MACHINE_XGENEXT2FS_VERSION # Build directories. ARG SNAPSHOT_BUILD_PATH=/build/snapshot @@ -24,177 +22,323 @@ ARG DEVNET_BUILD_PATH=/build/devnet ARG RUST_BUILD_PATH=/build/rollups-node/rust ARG GO_BUILD_PATH=/build/rollups-node/go -# Runtime dir for the cartesi-machine snapshot. +# Runtime directory for the cartesi-machine snapshot. ARG SNAPSHOT_RUNTIME_PATH=/usr/share/cartesi/snapshot -#################################################################################################### -# STAGE: emulator-base +# ============================================================================= +# STAGE: emulator # -# This stage creates a base-image with the Cartesi machine emulator. -# The result is used as the base for the snapshot and the node targets. -# We do this instead of using the cartesi/machine-emulator image to have control over the distro -# used by the base image. -FROM ${BASE_IMAGE} as emulator-base +# - Install ca-certificates and curl (setup). +# - Install the machine-emulator. +# - Download linux.bin. +# - Download rootfs.ext2. +# +# NOTE: We do not use the cartesi/machine-emulator image to have control over +# the distro used by the base image. +# ============================================================================= + +FROM ${BASE_IMAGE} as emulator -# Install machine-emulator ARG MACHINE_EMULATOR_VERSION +ARG MACHINE_TOOLS_VERSION +ARG MACHINE_IMAGE_KERNEL_VERSION +ARG MACHINE_KERNEL_VERSION +ARG DEBIAN_FRONTEND=noninteractive + +# Install ca-certificates and curl (setup). +RUN < /dev/null + apt-get update + apt-get install -y --no-install-recommends \ + docker-ce \ + docker-ce-cli \ + containerd.io \ + docker-buildx-plugin \ + docker-compose-plugin + # Cartesi Machine Emulator + SDK_URL=https://github.com/cartesi/machine-emulator-sdk +EOF + +# ============================================================================= # STAGE: snapshot-builder # -# This stage builds the snapshot using the machine emulator as base image. -FROM emulator-base as snapshot-builder - -# Download rootfs and linux. -# Add these files to the directories the cartesi-machine expects. -WORKDIR /usr/share/cartesi-machine/images/ -ARG TOOLS_VERSION -ARG LINUX_VERSION -ARG LINUX_KERNEL_VERSION -ADD https://github.com/cartesi/machine-emulator-tools/releases/download/v${TOOLS_VERSION}/rootfs-tools-v${TOOLS_VERSION}.ext2 rootfs.ext2 -ADD https://github.com/cartesi/image-kernel/releases/download/v${LINUX_VERSION}/linux-${LINUX_KERNEL_VERSION}.bin linux.bin - -# Generate snapshot with echo and store it. +# - Build an echo snapshot. +# +# DEPRECATED: this stage is going to be deleted, as the CI won't be generating +# machine snapshots in the future. +# ============================================================================= + +FROM emulator as snapshot-builder + WORKDIR /build ARG SNAPSHOT_BUILD_PATH RUN cartesi-machine \ --ram-length=128Mi \ --store=$SNAPSHOT_BUILD_PATH \ + --no-rollback \ -- "ioctl-echo-loop --vouchers=1 --notices=1 --reports=1 --verbose=1" +# ============================================================================= # STAGE: rollups-node-snapshot # -# This stage copies the image from the builder. -# We use the emulator as base image so we can easily create a container with a volume shared with -# the rollups-node container. -FROM emulator-base as rollups-node-snapshot +# This stage copies the image from the snapshot-builder. +# We use the emulator as the base image so we can easily create a container +# that shares a volume with the rollups-node container. +# +# DEPRECATED: this stage is going to be deleted, as the CI won't be generating +# machine snapshots in the future. +# ============================================================================= + +FROM emulator as rollups-node-snapshot # Copy image from the builder stage. ARG SNAPSHOT_BUILD_PATH ARG SNAPSHOT_RUNTIME_PATH WORKDIR ${SNAPSHOT_RUNTIME_PATH} -COPY --from=snapshot-builder --chown=cartesi:cartesi ${SNAPSHOT_BUILD_PATH} ${SNAPSHOT_RUNTIME_PATH} +COPY --from=snapshot-builder --chown=cartesi:cartesi \ + ${SNAPSHOT_BUILD_PATH} ${SNAPSHOT_RUNTIME_PATH} # Set dummy command. CMD /bin/bash -#################################################################################################### -# TARGET: rollups-node-devnet -# -# This target contains the Ethereum node that rollups node uses for testing. -# This target requires the machine-snapshot built in the snapshot-builder stage. - +# ============================================================================= # STAGE: devnet-base # -# This stage installs Foundry. +# - Install ca-certificates, curl, and git (setup). +# - Install Foundry from downloaded pre-compiled binaries. +# ============================================================================= + FROM ${BASE_IMAGE} as devnet-base -# Install system dependencies. +# Install ca-certificates, curl, and git (setup). ARG DEBIAN_FRONTEND=noninteractive RUN < /dev/null - apt-get update - apt-get install -y --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -EOF \ No newline at end of file diff --git a/build/docker-bake.override.hcl b/build/docker-bake.override.hcl index d2204f478..69177bd88 100644 --- a/build/docker-bake.override.hcl +++ b/build/docker-bake.override.hcl @@ -21,6 +21,6 @@ target "rollups-node-devnet" { tags = ["${DOCKER_ORGANIZATION}/rollups-node-devnet:${TAG}"] } -target "rollups-node-ci-base" { - tags = ["${DOCKER_ORGANIZATION}/rollups-node-ci-base:${TAG}"] +target "rollups-node-ci" { + tags = ["${DOCKER_ORGANIZATION}/rollups-node-ci:${TAG}"] } diff --git a/internal/node/machinehash_test.go b/internal/node/machinehash_test.go index c1aefc8fb..76dc1b24d 100644 --- a/internal/node/machinehash_test.go +++ b/internal/node/machinehash_test.go @@ -116,8 +116,7 @@ func mockMachineDir(hash string) (string, error) { return temp, nil } -// Generates a new Cartesi Machine snapshot in a temporary directory and returns -// its path +// Generates a new Cartesi Machine snapshot in a temporary directory and returns its path func createMachineSnapshot() (string, error) { tmpDir, err := os.MkdirTemp("", "") if err != nil {