From 623157874e922b28e5f7bffc88113e5e05cb8ad8 Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Thu, 21 Aug 2025 15:14:17 -0300 Subject: [PATCH 01/10] ci: bump cartesi/cli version --- .github/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 95838e2..f15a8fc 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -34,7 +34,7 @@ jobs: node-version: current - name: Install Cartesi CLI - run: npm install -g @cartesi/cli@2.0.0-alpha.8 + run: npm install -g @cartesi/cli@2.0.0-alpha.16 - name: Set up QEMU uses: docker/setup-qemu-action@v3 From 23bdc28d80206b8de76339867652ac1be619107a Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Thu, 21 Aug 2025 15:15:26 -0300 Subject: [PATCH 02/10] ci: ad steps to show hash and publish root.ext artifact --- .github/workflows/build.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index f15a8fc..7e7a188 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -45,3 +45,13 @@ jobs: - name: Build ${{ matrix.template }} run: cartesi build working-directory: ${{ matrix.template }} + + - name: Print cartesi-machine hash + run: cartesi hash + working-directory: ${{ matrix.template }} + + - name: Upload root.ext2 artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.template }}-root.ext2 + path: ${{ matrix.template }}/.cartesi/root.ext2 From 035a7dcd4f27fabb0fbfc30e56748b4c9c94142a Mon Sep 17 00:00:00 2001 From: Enderson Maia Date: Mon, 25 Aug 2025 09:27:53 -0300 Subject: [PATCH 03/10] feat(cpp): use Debian 13 (trixie) --- cpp/Dockerfile | 67 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 13 deletions(-) diff --git a/cpp/Dockerfile b/cpp/Dockerfile index a6096d2..ef0ae05 100644 --- a/cpp/Dockerfile +++ b/cpp/Dockerfile @@ -2,25 +2,56 @@ # This enforces that the packages downloaded from the repositories are the same # for the defined date, no matter when the image is built. -ARG UBUNTU_TAG=noble-20250529 -ARG APT_UPDATE_SNAPSHOT=20250601T030400Z +ARG DEBIAN_TAG=trixie-20250811-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z + +# Configure apt to use snapshot.debian.org +FROM scratch AS apt-config +ARG APT_UPDATE_SNAPSHOT +COPY < Date: Mon, 25 Aug 2025 09:30:34 -0300 Subject: [PATCH 04/10] feat(cpp-low-level): use Debian 13 (trixie) --- cpp-low-level/Dockerfile | 91 +++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 20 deletions(-) diff --git a/cpp-low-level/Dockerfile b/cpp-low-level/Dockerfile index 4bb288b..36d647b 100644 --- a/cpp-low-level/Dockerfile +++ b/cpp-low-level/Dockerfile @@ -1,27 +1,64 @@ # syntax=docker.io/docker/dockerfile:1 -ARG MACHINE_GUEST_TOOLS_VERSION=0.17.1 # This enforces that the packages downloaded from the repositories are the same # for the defined date, no matter when the image is built. -ARG UBUNTU_TAG=noble-20250529 -ARG APT_UPDATE_SNAPSHOT=20250601T030400Z +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z +ARG DEBIAN_TAG=trixie-20250811-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb +ARG MACHINE_GUEST_TOOLS_VERSION=0.17.1 + +FROM scratch AS machine-guest-tools-checksum +COPY < Date: Mon, 25 Aug 2025 09:36:45 -0300 Subject: [PATCH 05/10] feat(go): use Debian 13 (trixie) --- go/Dockerfile | 98 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 37 deletions(-) diff --git a/go/Dockerfile b/go/Dockerfile index 2ca3336..bf7ac96 100644 --- a/go/Dockerfile +++ b/go/Dockerfile @@ -2,91 +2,115 @@ # This enforces that the packages downloaded from the repositories are the same # for the defined date, no matter when the image is built. -ARG UBUNTU_TAG=noble-20250529 -ARG APT_UPDATE_SNAPSHOT=20250601T030400Z - -################################################################################ -# riscv64 base stage -FROM --platform=linux/riscv64 ubuntu:${UBUNTU_TAG} AS base-riscv64 +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z +ARG DEBIAN_TAG=trixie-20250811-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb +ARG GO_VERSION=1.24.6 +# Configure apt to use snapshot.debian.org +FROM scratch AS apt-config ARG APT_UPDATE_SNAPSHOT -ARG DEBIAN_FRONTEND=noninteractive -RUN < Date: Mon, 25 Aug 2025 09:40:07 -0300 Subject: [PATCH 06/10] feat(lua): use Debian 13 (trixie) --- lua/Dockerfile | 79 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/lua/Dockerfile b/lua/Dockerfile index 75d7c2e..043ed7f 100644 --- a/lua/Dockerfile +++ b/lua/Dockerfile @@ -2,25 +2,56 @@ # This enforces that the packages downloaded from the repositories are the same # for the defined date, no matter when the image is built. -ARG UBUNTU_TAG=noble-20250529 -ARG APT_UPDATE_SNAPSHOT=20250601T030400Z +ARG DEBIAN_TAG=trixie-20250811-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z + +# Configure apt to use snapshot.debian.org +FROM scratch AS apt-config +ARG APT_UPDATE_SNAPSHOT +COPY < Date: Mon, 25 Aug 2025 09:42:12 -0300 Subject: [PATCH 07/10] feat(python): use Debian 13 (trixie) --- python/.dockerignore | 2 + python/Dockerfile | 96 ++++++++++++++++++++++++++++++++------------ 2 files changed, 72 insertions(+), 26 deletions(-) create mode 100644 python/.dockerignore diff --git a/python/.dockerignore b/python/.dockerignore new file mode 100644 index 0000000..a8c6a37 --- /dev/null +++ b/python/.dockerignore @@ -0,0 +1,2 @@ +.cartesi +.venv diff --git a/python/Dockerfile b/python/Dockerfile index 522b8c5..45c2f2b 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -2,61 +2,105 @@ # This enforces that the packages downloaded from the repositories are the same # for the defined date, no matter when the image is built. -ARG APT_UPDATE_SNAPSHOT=20250424T030400Z +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z +ARG PYTHON_VERSION=3.13.6 + +# Configure apt to use snapshot.debian.org +FROM scratch AS apt-config +ARG APT_UPDATE_SNAPSHOT +COPY < Date: Mon, 25 Aug 2025 09:43:03 -0300 Subject: [PATCH 08/10] feat(ruby): use Debian 13 (trixie) --- ruby/.dockerignore | 1 + ruby/Dockerfile | 91 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 69 insertions(+), 23 deletions(-) diff --git a/ruby/.dockerignore b/ruby/.dockerignore index 82b4d6a..a647c70 100644 --- a/ruby/.dockerignore +++ b/ruby/.dockerignore @@ -1 +1,2 @@ .cartesi +.bundle diff --git a/ruby/Dockerfile b/ruby/Dockerfile index 797b667..4b8f3a6 100644 --- a/ruby/Dockerfile +++ b/ruby/Dockerfile @@ -2,37 +2,69 @@ # This enforces that the packages downloaded from the repositories are the same # for the defined date, no matter when the image is built. -ARG UBUNTU_TAG=noble-20250529 -ARG APT_UPDATE_SNAPSHOT=20250601T030400Z +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z +ARG RUBY_VERSION=3.4.5 + +# Configure apt to use snapshot.debian.org +FROM scratch AS apt-config +ARG APT_UPDATE_SNAPSHOT +COPY < Date: Mon, 25 Aug 2025 09:43:32 -0300 Subject: [PATCH 09/10] feat(rust): use Debian 13 (trixie) --- rust/Dockerfile | 120 ++++++++++++++++++++++++++---------------------- 1 file changed, 64 insertions(+), 56 deletions(-) diff --git a/rust/Dockerfile b/rust/Dockerfile index 9896179..a831daa 100644 --- a/rust/Dockerfile +++ b/rust/Dockerfile @@ -2,106 +2,114 @@ # This enforces that the packages downloaded from the repositories are the same # for the defined date, no matter when the image is built. -ARG UBUNTU_TAG=noble-20250529 -ARG APT_UPDATE_SNAPSHOT=20250601T030400Z - -################################################################################ -# riscv64 base stage -FROM --platform=linux/riscv64 ubuntu:${UBUNTU_TAG} AS base-riscv64 +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z +ARG DEBIAN_TAG=trixie-20250811-slim@sha256:c85a2732e97694ea77237c61304b3bb410e0e961dd6ee945997a06c788c545bb +ARG RUST_VERSION=1.89 +# Configure apt to use snapshot.debian.org +FROM scratch AS apt-config ARG APT_UPDATE_SNAPSHOT -ARG DEBIAN_FRONTEND=noninteractive -RUN <&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; -esac -url="https://static.rust-lang.org/rustup/archive/1.27.1/${rustArch}/rustup-init" -curl -fsSL -O "$url" -echo "${rustupSha256} *rustup-init" | sha256sum -c - -chmod +x rustup-init -./rustup-init -y --no-modify-path --profile minimal --default-toolchain $RUST_VERSION --default-host ${rustArch} -rm rustup-init -chmod -R a+w $RUSTUP_HOME $CARGO_HOME -rustup --version -cargo --version -rustc --version -EOF - -RUN rustup target add riscv64gc-unknown-linux-gnu - WORKDIR /opt/cartesi/dapp COPY . . -RUN cargo build --release + +RUN < Date: Thu, 26 Sep 2024 17:00:55 -0300 Subject: [PATCH 10/10] feat: add PHP application template --- .github/workflows/build.yaml | 1 + php/.dockerignore | 2 + php/.gitignore | 2 + php/Dockerfile | 118 +++++++ php/composer.json | 5 + php/composer.lock | 615 +++++++++++++++++++++++++++++++++++ php/index.php | 52 +++ 7 files changed, 795 insertions(+) create mode 100644 php/.dockerignore create mode 100644 php/.gitignore create mode 100644 php/Dockerfile create mode 100644 php/composer.json create mode 100644 php/composer.lock create mode 100755 php/index.php diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7e7a188..5963de1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,6 +20,7 @@ jobs: - java - javascript - lua + - php - python - ruby - rust diff --git a/php/.dockerignore b/php/.dockerignore new file mode 100644 index 0000000..386c1c9 --- /dev/null +++ b/php/.dockerignore @@ -0,0 +1,2 @@ +.cartesi +vendor diff --git a/php/.gitignore b/php/.gitignore new file mode 100644 index 0000000..386c1c9 --- /dev/null +++ b/php/.gitignore @@ -0,0 +1,2 @@ +.cartesi +vendor diff --git a/php/Dockerfile b/php/Dockerfile new file mode 100644 index 0000000..2ad1b37 --- /dev/null +++ b/php/Dockerfile @@ -0,0 +1,118 @@ +# syntax=docker.io/docker/dockerfile:1 + +# This enforces that the packages downloaded from the repositories are the same +# for the defined date, no matter when the image is built. +ARG APT_UPDATE_SNAPSHOT=20250811T210202Z +ARG PHP_VERSION=8.4.11 + +# Configure apt to use snapshot.debian.org +FROM scratch AS apt-config +ARG APT_UPDATE_SNAPSHOT +COPY <=7.1", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "PSR-17: Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory" + }, + "time": "2024-04-15T12:06:14+00:00" + }, + { + "name": "psr/http-message", + "version": "2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/2.0" + }, + "time": "2023-04-04T09:54:51+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:32:20+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/php/index.php b/php/index.php new file mode 100755 index 0000000..57c3533 --- /dev/null +++ b/php/index.php @@ -0,0 +1,52 @@ +#!/usr/bin/env php + + 'accept']; +$ROLLUP_SERVER = getenv("ROLLUP_HTTP_SERVER_URL") ?: "http://127.0.0.1:5004"; + +function handleAdvance($data) { + $payload = hex2bin(substr($data['payload'], 2)); + error_log("Handling advance request for payload: $payload"); + # TODO: add application logic here + return "accept"; +} + +function handleInspect($data) { + $payload = hex2bin(substr($data['payload'], 2)); + error_log("Handling inspect request for payload: $payload"); + # TODO: add application logic here + return "accept"; +} + +$client = new GuzzleHttp\Client(['base_uri' => $ROLLUP_SERVER]); + +while (true) { + error_log("Sending finish"); + + $response = $client->request('POST', '/finish', [ + 'json' => $FINISH_PAYLOAD + ]); + + if ($response->getStatusCode() == 202) { + error_log("No pending rollup request, trying again"); + } else { + $rollup_req = json_decode($response->getBody(), true); + $metadata = $rollup_req['data']['metadata']; + + switch ($rollup_req['request_type']) { + case 'advance_state': + $finish['status'] = handleAdvance($rollup_req['data']); + break; + case 'inspect_state': + $finish['status'] = handleInspect($rollup_req['data']); + break; + } + } +} + +?>