diff --git a/build/Dockerfile b/build/Dockerfile index a65da65e6..d6f8041d0 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -4,19 +4,19 @@ # 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,67 +24,189 @@ 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 +# +# - Install ca-certificates and curl (setup). +# - Install the machine-emulator. +# - Download linux.bin. +# - Download rootfs.ext2. # -# 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 +# 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 +# This stage builds an echo snapshot. +# ============================================================================= + +FROM emulator as snapshot-builder # Generate snapshot with echo and store it. WORKDIR /build @@ -92,73 +214,78 @@ 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 +# ============================================================================= +# TARGET: 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 +# TODO: this should be deleted. +# ============================================================================= + +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. +# ============================================================================= + FROM ${BASE_IMAGE} as devnet-base -# Install system dependencies. +# 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/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..1bb63d1e5 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" } } @@ -47,8 +48,8 @@ target "rollups-node-devnet" { } target "rollups-node-ci-base" { - inherits = ["common"] - target = "rollups-node-ci-base" + inherits = ["common"] + target = "rollups-node-ci-base" dockerfile = "./Dockerfile" - context = "." + context = "." } 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 { 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"