diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 95838e2..5963de1 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -20,6 +20,7 @@ jobs: - java - javascript - lua + - php - python - ruby - rust @@ -34,7 +35,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 @@ -45,3 +46,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 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 <=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; + } + } +} + +?> 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 <&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 <