diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc8aba130..629104f64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,9 @@ env: LINUX_VERSION: 5.15.63-ctsi-2-v0.17.0 ROOTFS_VERSION: v0.18.0 TEST_VERSION: v0.29.0 - CARTESI_TESTS_PATH: /opt/cartesi/share/tests + CARTESI_TESTS_PATH: /usr/share/cartesi-machine/tests + CARTESI_IMAGES_PATH: /usr/share/cartesi-machine/images + CARTESI_UARCH_PATH: /usr/share/cartesi-machine/uarch/uarch-ram.bin jobs: build: name: Build @@ -20,6 +22,9 @@ jobs: with: submodules: recursive + - name: Setup variables + run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -33,16 +38,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Setup docker image tags - id: docker_image_tags - uses: docker/metadata-action@v4 - with: - images: ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator - tags: | - type=ref,event=branch - type=ref,event=tag - type=semver,pattern={{version}},enable=${{startsWith(github.ref, 'refs/tags/v')}} - - name: Set up Depot CLI uses: depot/setup-action@v1 @@ -52,7 +47,7 @@ jobs: file: Dockerfile context: . platforms: linux/amd64,linux/arm64 - tags: ${{ steps.docker_image_tags.outputs.tags }} + tags: ${{ github.repository_owner }}/machine-emulator:devel.build push: false load: true cache-from: type=gha,scope=debian @@ -60,9 +55,61 @@ jobs: build-args: | RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }} GIT_COMMIT=${GITHUB_SHA} + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} + project: ${{ vars.DEPOT_PROJECT }} + token: ${{ secrets.DEPOT_TOKEN }} + + - name: Build debian package (amd64) + uses: depot/build-push-action@v1 + with: + file: Dockerfile + context: . + target: debian-packager + platforms: linux/amd64 + tags: cartesi/machine-emulator:amd64_deb + push: false + load: true + cache-from: type=gha,scope=debian + cache-to: type=gha,mode=max,scope=debian + build-args: | + GIT_COMMIT=${GITHUB_SHA} + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} + project: ${{ vars.DEPOT_PROJECT }} + token: ${{ secrets.DEPOT_TOKEN }} + + - name: Export deb package artifact (amd64) + run: make copy BUILD_PLATFORM=linux/amd64 ARCH=amd64 DEBIAN_IMG=cartesi/machine-emulator:amd64_deb + + - name: Build debian package (arm64) + uses: depot/build-push-action@v1 + with: + file: Dockerfile + context: . + target: debian-packager + platforms: linux/arm64 + tags: cartesi/machine-emulator:arm64_deb + push: false + load: true + cache-from: type=gha,scope=debian + cache-to: type=gha,mode=max,scope=debian + build-args: | + GIT_COMMIT=${GITHUB_SHA} + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} project: ${{ vars.DEPOT_PROJECT }} token: ${{ secrets.DEPOT_TOKEN }} + - name: Export deb package artifact (arm64) + run: make copy BUILD_PLATFORM=linux/arm64 ARCH=arm64 DEBIAN_IMG=cartesi/machine-emulator:arm64_deb + + - name: Upload artifacts + uses: actions/upload-artifact@master + with: + name: artifacts + path: | + uarch-ram.bin + cartesi-machine-v${{ env.MACHINE_EMULATOR_VERSION }}_amd64.deb + cartesi-machine-v${{ env.MACHINE_EMULATOR_VERSION }}_arm64.deb + test_amd64: name: Test (linux/amd64) needs: build @@ -73,6 +120,9 @@ jobs: with: submodules: recursive + - name: Setup variables + run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -97,7 +147,7 @@ jobs: context: . target: installer platforms: linux/amd64 - tags: ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel + tags: ${{ github.repository_owner }}/machine-emulator:devel push: false load: true cache-from: type=gha,scope=debian @@ -105,6 +155,7 @@ jobs: build-args: | RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }} GIT_COMMIT=${GITHUB_SHA} + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} project: ${{ vars.DEPOT_PROJECT }} token: ${{ secrets.DEPOT_TOKEN }} @@ -131,11 +182,11 @@ jobs: - name: Move images to cartesi images folder run: | - mkdir -m 755 -p /opt/cartesi/share/images - mv rom-*.bin linux-*.bin rootfs-*.ext2 /opt/cartesi/share/images/ - cd /opt/cartesi/share/images/ && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin - cd /opt/cartesi/share/images/ && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin - cd /opt/cartesi/share/images/ && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 + mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }} + mv rom-*.bin linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }} + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 - name: Download test suite uses: Legion2/download-release-action@v2.1.0 @@ -145,67 +196,70 @@ jobs: file: machine-tests-${{ env.TEST_VERSION }}.tar.gz - name: Untar test suite - run: mkdir -p ${CARTESI_TESTS_PATH} && tar -xzf machine-tests-${TEST_VERSION}.tar.gz -C ${CARTESI_TESTS_PATH} + run: mkdir -p ${{ env.CARTESI_TESTS_PATH }} && tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }} - name: Simple boot inside the docker image - run: docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine /bin/true + run: docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine /bin/true - name: Run test suite inside the docker image - run: docker run --rm -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine-tests --test-path=${CARTESI_TESTS_PATH} run + run: docker run --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run - name: Save and Load run: | - mkdir -m 755 -p /opt/cartesi/share/images/snapshots - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine --max-mcycle=0 --rollup --store=/opt/cartesi/share/images/snapshots/save_and_load_test - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine --load=/opt/cartesi/share/images/snapshots/save_and_load_test - sudo rm -rf /opt/cartesi/share/images/snapshots + mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}/snapshots + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --max-mcycle=0 --rollup --store=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --load=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test + sudo rm -rf ${{ env.CARTESI_IMAGES_PATH }}/snapshots - name: Run test scripts run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/run.sh + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/run.sh - name: Run grpc lua test scripts run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-grpc-server.sh remote-cartesi-machine cartesi-machine cartesi-machine-tests ${CARTESI_TESTS_PATH} + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-grpc-server.sh remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }} - name: Run jsonrpc lua test scripts run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-jsonrpc-server.sh jsonrpc-remote-cartesi-machine cartesi-machine cartesi-machine-tests ${CARTESI_TESTS_PATH} + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-jsonrpc-server.sh jsonrpc-remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }} - name: Run Merkle tree tests run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-merkle-tree-hash --log2-root-size=30 --log2-leaf-size=12 --input=./src/tests/test-merkle-tree-hash + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-merkle-tree-hash --log2-root-size=30 --log2-leaf-size=12 --input=./src/tests/test-merkle-tree-hash - name: Run C API tests run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t -e LD_LIBRARY_PATH=/opt/cartesi/lib ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-machine-c-api + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-machine-c-api - name: Test microarchitecture interpreter run: | - docker run --rm -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel make uarch-tests run-uarch-tests JOBS=-j$(nproc) + docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make uarch-tests run-uarch-tests JOBS=-j$(nproc) - name: Run rv64ui test suite on microarchitecture run: | - docker run --rm -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/uarch-riscv-tests --test-path=${CARTESI_TESTS_PATH} run + docker run --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/uarch-riscv-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run - name: Run test suite with Microarchitecture run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine-tests --test-path=${CARTESI_TESTS_PATH} --uarch-ram-length=0x20000 --uarch-ram-image=/opt/cartesi/share/uarch/uarch-ram.bin --jobs=$(nproc) run_uarch + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_uarch - name: Run test suite with microarchitecture and host based interpreters comparing machine hashes at every step run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine-tests --test="^rv64ui.*$" --test-path=${CARTESI_TESTS_PATH} --uarch-ram-length=0x20000 --uarch-ram-image=/opt/cartesi/share/uarch/uarch-ram.bin --jobs=$(nproc) run_host_and_uarch + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test="^rv64ui.*$" --test-path=${{ env.CARTESI_TESTS_PATH }} --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_host_and_uarch - name: Create uarch json logs to be used to test the Solidity based microarchitecture interpreter run: | mkdir -p /opt/cartesi/share/logs/uarch-riscv-tests-json-logs - docker run --rm -v /opt/cartesi/share/logs:/opt/cartesi/share/logs -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/uarch-riscv-tests --test-path=${CARTESI_TESTS_PATH} --output-dir=/opt/cartesi/share/logs/uarch-riscv-tests-json-logs --proofs --proofs-frequency=1 json-logs + docker run --rm -v /opt/cartesi/share/logs:/opt/cartesi/share/logs -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/uarch-riscv-tests --test-path=${{ env.CARTESI_TESTS_PATH }} --output-dir=/opt/cartesi/share/logs/uarch-riscv-tests-json-logs --proofs --proofs-frequency=1 json-logs + + - name: Compress uarch json logs + run: tar -czf uarch-riscv-tests-json-logs.tar.gz -C /opt/cartesi/share/logs/uarch-riscv-tests-json-logs . - name: Upload uarch json logs to be used to test the Solidity based microarchitecture interpreter uses: actions/upload-artifact@master with: - name: uarch-riscv-tests-json-logs - path: /opt/cartesi/share/logs/uarch-riscv-tests-json-logs + name: uarch-riscv-tests-json-logs.tar.gz + path: uarch-riscv-tests-json-logs.tar.gz test_arm64: name: Test (linux/arm64) @@ -217,6 +271,9 @@ jobs: with: submodules: recursive + - name: Setup variables + run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -244,7 +301,7 @@ jobs: context: . target: installer platforms: linux/arm64 - tags: ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel + tags: ${{ github.repository_owner }}/machine-emulator:devel push: false load: true cache-from: type=gha,scope=debian @@ -252,6 +309,7 @@ jobs: build-args: | RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }} GIT_COMMIT=${GITHUB_SHA} + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} project: ${{ vars.DEPOT_PROJECT }} token: ${{ secrets.DEPOT_TOKEN }} @@ -278,11 +336,11 @@ jobs: - name: Move images to cartesi images folder run: | - mkdir -m 755 -p /opt/cartesi/share/images - mv rom-*.bin linux-*.bin rootfs-*.ext2 /opt/cartesi/share/images/ - cd /opt/cartesi/share/images/ && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin - cd /opt/cartesi/share/images/ && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin - cd /opt/cartesi/share/images/ && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 + mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }} + mv rom-*.bin linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }}/ + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 - name: Download test suite uses: Legion2/download-release-action@v2.1.0 @@ -292,56 +350,56 @@ jobs: file: machine-tests-${{ env.TEST_VERSION }}.tar.gz - name: Untar test suite - run: mkdir -p ${CARTESI_TESTS_PATH} && tar -xzf machine-tests-${TEST_VERSION}.tar.gz -C ${CARTESI_TESTS_PATH} + run: mkdir -p ${{ env.CARTESI_TESTS_PATH }} && tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }} - name: Simple boot inside the docker image - run: docker run --platform linux/arm64 --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine /bin/true + run: docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine /bin/true - name: Run test suite inside the docker image - run: docker run --platform linux/arm64 --rm -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine-tests --test-path=${CARTESI_TESTS_PATH} run + run: docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run - name: Save and Load run: | - mkdir -m 755 -p /opt/cartesi/share/images/snapshots - docker run --platform linux/arm64 --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine --max-mcycle=0 --rollup --store=/opt/cartesi/share/images/snapshots/save_and_load_test - docker run --platform linux/arm64 --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine --load=/opt/cartesi/share/images/snapshots/save_and_load_test - sudo rm -rf /opt/cartesi/share/images/snapshots + mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }}/snapshots + docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --max-mcycle=0 --rollup --store=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test + docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine --load=${{ env.CARTESI_IMAGES_PATH }}/snapshots/save_and_load_test + sudo rm -rf ${{ env.CARTESI_IMAGES_PATH }}/snapshots - name: Run test scripts run: | - docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/run.sh + docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/run.sh - name: Run grpc lua test scripts run: | - docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-grpc-server.sh remote-cartesi-machine cartesi-machine cartesi-machine-tests ${CARTESI_TESTS_PATH} + docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-grpc-server.sh remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }} - name: Run jsonrpc lua test scripts run: | - docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-jsonrpc-server.sh jsonrpc-remote-cartesi-machine cartesi-machine cartesi-machine-tests ${CARTESI_TESTS_PATH} + docker run --platform linux/arm64 -e "CARTESI_CONCURRENCY_UPDATE_MERKLE_TREE=1" --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-jsonrpc-server.sh jsonrpc-remote-cartesi-machine cartesi-machine cartesi-machine-tests ${{ env.CARTESI_TESTS_PATH }} - name: Run Merkle tree tests run: | - docker run --platform linux/arm64 --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-merkle-tree-hash --log2-root-size=30 --log2-leaf-size=12 --input=./src/tests/test-merkle-tree-hash + docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-merkle-tree-hash --log2-root-size=30 --log2-leaf-size=12 --input=./src/tests/test-merkle-tree-hash - name: Run C API tests run: | - docker run --platform linux/arm64 --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t -e LD_LIBRARY_PATH=/opt/cartesi/lib ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel ./src/tests/test-machine-c-api + docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel ./src/tests/test-machine-c-api - name: Test microarchitecture interpreter run: | - docker run --platform linux/arm64 --rm -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel make uarch-tests JOBS=-j$(nproc) + docker run --platform linux/arm64 --rm -t ${{ github.repository_owner }}/machine-emulator:devel make uarch-tests JOBS=-j$(nproc) - name: Run rv64ui test suite on microarchitecture run: | - docker run --platform linux/arm64 --rm -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/uarch-riscv-tests --test-path=${CARTESI_TESTS_PATH} run + docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/uarch-riscv-tests --test-path=${{ env.CARTESI_TESTS_PATH }} run - name: Run test suite with Microarchitecture run: | - docker run --platform linux/arm64 --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine-tests --test-path=${CARTESI_TESTS_PATH} --uarch-ram-length=0x20000 --uarch-ram-image=/opt/cartesi/share/uarch/uarch-ram.bin --jobs=$(nproc) run_uarch + docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test-path=${{ env.CARTESI_TESTS_PATH }} --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_uarch - name: Run test suite with microarchitecture and host based interpreters comparing machine hashes at every step run: | - docker run --platform linux/arm64 --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel /opt/cartesi/bin/cartesi-machine-tests --test="^rv64ui%-v%-add.bin$" --test-path=${CARTESI_TESTS_PATH} --concurrency=update_merkle_tree:1 --uarch-ram-length=0x20000 --uarch-ram-image=/opt/cartesi/share/uarch/uarch-ram.bin --jobs=$(nproc) run_host_and_uarch + docker run --platform linux/arm64 --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:devel /usr/bin/cartesi-machine-tests --test="^rv64ui%-v%-add.bin$" --test-path=${{ env.CARTESI_TESTS_PATH }} --concurrency=update_merkle_tree:1 --uarch-ram-length=0x20000 --uarch-ram-image=${{ env.CARTESI_UARCH_PATH }} --jobs=$(nproc) run_host_and_uarch static-analysis: name: Static Analysis @@ -352,6 +410,9 @@ jobs: with: submodules: recursive + - name: Setup variables + run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -376,7 +437,7 @@ jobs: context: . target: builder platforms: linux/amd64 - tags: ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel + tags: ${{ github.repository_owner }}/machine-emulator:devel push: false load: true cache-from: type=gha,scope=debian @@ -384,24 +445,25 @@ jobs: build-args: | RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }} GIT_COMMIT=${GITHUB_SHA} + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} project: ${{ vars.DEPOT_PROJECT }} token: ${{ secrets.DEPOT_TOKEN }} - name: Check format (C++) run: | - docker run --rm -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel make check-format + docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make check-format - name: Check format (Lua) run: | - docker run --rm -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel make check-format-lua + docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make check-format-lua - name: Lint (C++) run: | - docker run --rm -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel make -j$(nproc) lint + docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make -j$(nproc) lint - name: Lint (Lua) run: | - docker run --rm -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:devel make check-lua + docker run --rm -t ${{ github.repository_owner }}/machine-emulator:devel make check-lua coverage: name: Coverage @@ -411,6 +473,9 @@ jobs: with: submodules: recursive + - name: Setup variables + run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -435,7 +500,7 @@ jobs: context: . target: installer platforms: linux/amd64 - tags: ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:coverage + tags: ${{ github.repository_owner }}/machine-emulator:coverage push: false load: true cache-from: type=gha,scope=debian-coverage @@ -444,6 +509,7 @@ jobs: GIT_COMMIT=${GITHUB_SHA} RELEASE=no COVERAGE=yes + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} project: ${{ vars.DEPOT_PROJECT }} token: ${{ secrets.DEPOT_TOKEN }} @@ -470,11 +536,11 @@ jobs: - name: Move images to cartesi images folder run: | - mkdir -m 755 -p /opt/cartesi/share/images - mv rom-*.bin linux-*.bin rootfs-*.ext2 /opt/cartesi/share/images/ - cd /opt/cartesi/share/images/ && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin - cd /opt/cartesi/share/images/ && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin - cd /opt/cartesi/share/images/ && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 + mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }} + mv rom-*.bin linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }}/ + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 - name: Download test suite uses: Legion2/download-release-action@v2.1.0 @@ -485,12 +551,12 @@ jobs: - name: Untar test suite run: | - mkdir -m 775 -p ${CARTESI_TESTS_PATH} /opt/cartesi/share/coverage - tar -xzf machine-tests-${TEST_VERSION}.tar.gz -C ${CARTESI_TESTS_PATH} + mkdir -m 775 -p ${{ env.CARTESI_TESTS_PATH }} /opt/cartesi/share/coverage + tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }} - name: Run coverage run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v /opt/cartesi/share/coverage:/opt/cartesi/share/coverage -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:coverage make -j1 test-all coverage-report COVERAGE_OUTPUT_DIR=/opt/cartesi/share/coverage + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v /opt/cartesi/share/coverage:/opt/cartesi/share/coverage -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:coverage make -j1 test-all coverage-report COVERAGE_OUTPUT_DIR=/opt/cartesi/share/coverage - name: Show coverage summary run: cat /opt/cartesi/share/coverage/coverage.txt @@ -519,6 +585,9 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Setup variables + run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV + - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: @@ -537,7 +606,7 @@ jobs: context: . target: installer platforms: linux/amd64 - tags: ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:sanitize + tags: ${{ github.repository_owner }}/machine-emulator:sanitize push: false load: true cache-from: type=gha,scope=debian-sanitize @@ -546,6 +615,7 @@ jobs: RELEASE=no GIT_COMMIT=${GITHUB_SHA} SANITIZE=yes + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} project: ${{ vars.DEPOT_PROJECT }} token: ${{ secrets.DEPOT_TOKEN }} @@ -572,11 +642,11 @@ jobs: - name: Move images to cartesi images folder run: | - mkdir -m 755 -p /opt/cartesi/share/images - mv rom-*.bin linux-*.bin rootfs-*.ext2 /opt/cartesi/share/images/ - cd /opt/cartesi/share/images/ && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin - cd /opt/cartesi/share/images/ && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin - cd /opt/cartesi/share/images/ && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 + mkdir -m 755 -p ${{ env.CARTESI_IMAGES_PATH }} + mv rom-*.bin linux-*.bin rootfs-*.ext2 ${{ env.CARTESI_IMAGES_PATH }}/ + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s linux-${{ env.LINUX_VERSION }}.bin linux.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rom-${{ env.ROM_VERSION }}.bin rom.bin + cd ${{ env.CARTESI_IMAGES_PATH }} && ln -s rootfs-${{ env.ROOTFS_VERSION }}.ext2 rootfs.ext2 - name: Download test suite uses: Legion2/download-release-action@v2.1.0 @@ -587,12 +657,12 @@ jobs: - name: Untar test suite run: | - mkdir -m 775 -p ${CARTESI_TESTS_PATH} - tar -xzf machine-tests-${TEST_VERSION}.tar.gz -C ${CARTESI_TESTS_PATH} + mkdir -m 775 -p ${{ env.CARTESI_TESTS_PATH }} + tar -xzf machine-tests-${{ env.TEST_VERSION }}.tar.gz -C ${{ env.CARTESI_TESTS_PATH }} - name: Run tests with sanitizer run: | - docker run --rm -v /opt/cartesi/share/images:/opt/cartesi/share/images -v ${CARTESI_TESTS_PATH}:${CARTESI_TESTS_PATH} -t ${{ secrets.DOCKER_ORGANIZATION }}/machine-emulator:sanitize make sanitize=yes test test-hash test-scripts test-jsonrpc test-c-api test-uarch-for-coverage test-linux-workload + docker run --rm -v ${{ env.CARTESI_IMAGES_PATH }}:${{ env.CARTESI_IMAGES_PATH }} -v ${{ env.CARTESI_TESTS_PATH }}:${{ env.CARTESI_TESTS_PATH }} -t ${{ github.repository_owner }}/machine-emulator:sanitize make sanitize=yes test test-hash test-scripts test-jsonrpc test-c-api test-uarch-for-coverage test-linux-workload publish_artifacts: name: Publish artifacts @@ -604,6 +674,9 @@ jobs: with: submodules: recursive + - name: Setup variables + run: echo MACHINE_EMULATOR_VERSION=`make version` >> $GITHUB_ENV + - name: Login to Docker Hub uses: docker/login-action@v2 with: @@ -644,24 +717,24 @@ jobs: build-args: | RELEASE=${{ (startsWith(github.ref, 'refs/tags/v') && 'yes' || 'no') }} GIT_COMMIT=${GITHUB_SHA} + MACHINE_EMULATOR_VERSION=${{ env.MACHINE_EMULATOR_VERSION }} project: ${{ vars.DEPOT_PROJECT }} token: ${{ secrets.DEPOT_TOKEN }} - - name: Download uarch json logs to be used to test the Solidity based microarchitecture interpreter + - name: Download artifacts uses: actions/download-artifact@master if: ${{ startsWith(github.ref, 'refs/tags/v') }} - with: - name: uarch-riscv-tests-json-logs - path: /tmp/uarch-riscv-tests-json-logs - name: Create uarch json logs TAR if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: tar -czf uarch-riscv-tests-json-logs-${GITHUB_REF:10}.tar.gz -C /tmp/uarch-riscv-tests-json-logs . + run: mv /tmp/uarch-riscv-tests-json-logs.tar.gz uarch-riscv-tests-json-logs-${GITHUB_REF:10}.tar.gz - - name: Upload TAR to GitHub Release + - name: Upload TAR and DEB to GitHub Release uses: softprops/action-gh-release@v1 if: ${{ startsWith(github.ref, 'refs/tags/v') }} with: - prerelease: false + prerelease: true files: | - uarch-riscv-tests-json-logs-*.tar.gz + uarch-riscv-tests-json-logs-*tar.gz + cartesi-machine-*.deb + uarch-ram.bin diff --git a/.gitignore b/.gitignore index 1efa06d1a..e1608cbce 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.swp *.d *.clang-tidy +*.deb build third-party/cryptopp-CRYPTOPP_7_0_0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 24f8bcd0b..5f119ce59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed bug in get\_proto\_access\_log() - Fixed lint warnings with CLANG 15 - Introduced a workaround for high memory usage when running on QEMU ARM64 +- Added deb to release process ### Added diff --git a/Dockerfile b/Dockerfile index 5d6ac6f87..3b493bf81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,58 +36,46 @@ COPY third-party third-party RUN make -j$(nproc) dep FROM --platform=$TARGETPLATFORM dep-builder as builder +ARG DEB_FILENAME=cartesi-machine.deb COPY . . RUN make -j$(nproc) git_commit=$GIT_COMMIT release=$RELEASE coverage=$COVERAGE sanitize=$SANITIZE && \ make -j$(nproc) uarch -FROM --platform=$TARGETPLATFORM builder as installer +FROM --platform=$TARGETPLATFORM builder as debian-packager +RUN make install-uarch debian-package DESTDIR=$PWD/_install -RUN make install +FROM --platform=$TARGETPLATFORM debian-packager as installer +ARG MACHINE_EMULATOR_VERSION=0.0.0 +ARG TARGETARCH -# For testing purposes -ENV PATH="/opt/cartesi/bin:${PATH}" -ENV CARTESI_IMAGES_PATH=/opt/cartesi/share/images -ENV CARTESI_TESTS_PATH=/opt/cartesi/share/tests -ENV LUA_PATH_5_4="/opt/cartesi/share/lua/5.4/?.lua;;" -ENV LUA_CPATH_5_4="/opt/cartesi/lib/lua/5.4/?.so;;" +RUN make install-tests +RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt install -y \ + ./cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${TARGETARCH}.deb \ + && rm -rf /var/lib/apt/lists/* + +ENV CARTESI_TESTS_PATH="/usr/share/cartesi-machine/tests" +ENV CARTESI_IMAGES_PATH="/usr/share/cartesi-machine/images" FROM --platform=$TARGETPLATFORM debian:bookworm-20230725-slim +ARG MACHINE_EMULATOR_VERSION=0.0.0 +ARG TARGETARCH -RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y \ - libboost-coroutine1.74.0 \ - libboost-context1.74.0 \ - libboost-filesystem1.74.0 \ - libreadline8 \ - openssl \ - libc-ares2 \ - zlib1g \ - ca-certificates \ - libgomp1 \ - lua5.4 \ - genext2fs \ - libb64-0d \ - libcrypto++8 \ - libgrpc++1.51 \ - && rm -rf /var/lib/apt/lists/* +COPY --from=installer \ + /usr/src/emulator/cartesi-machine-v${MACHINE_EMULATOR_VERSION}_${TARGETARCH}.deb \ + cartesi-machine.deb +RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt install -y \ + ./cartesi-machine.deb \ + && rm -rf /var/lib/apt/lists/* \ + && rm cartesi-machine.deb RUN addgroup --system --gid 102 cartesi && \ adduser --system --uid 102 --ingroup cartesi --disabled-login --no-create-home --home /nonexistent --gecos "cartesi user" --shell /bin/false cartesi -COPY --from=installer /opt/cartesi /opt/cartesi -COPY --from=installer /usr/local/lib/lua /usr/local/lib/lua -COPY --from=installer /usr/local/share/lua /usr/local/share/lua - -ENV PATH="/opt/cartesi/bin:${PATH}" -ENV CARTESI_IMAGES_PATH=/opt/cartesi/share/images -ENV CARTESI_TESTS_PATH=/opt/cartesi/share/tests -ENV LUA_PATH_5_4="/opt/cartesi/share/lua/5.4/?.lua;;" -ENV LUA_CPATH_5_4="/opt/cartesi/lib/lua/5.4/?.so;;" - WORKDIR /opt/cartesi EXPOSE 5002 USER cartesi -CMD [ "/opt/cartesi/bin/remote-cartesi-machine", "--server-address=0.0.0.0:5002"] +CMD [ "/usr/bin/remote-cartesi-machine", "--server-address=0.0.0.0:5002"] diff --git a/Makefile b/Makefile index 502ae3226..38b01500f 100644 --- a/Makefile +++ b/Makefile @@ -17,16 +17,20 @@ UNAME:=$(shell uname) # Install settings -PREFIX= /opt/cartesi -BIN_INSTALL_PATH= $(PREFIX)/bin -LIB_INSTALL_PATH= $(PREFIX)/lib -SHARE_INSTALL_PATH= $(PREFIX)/share -IMAGES_INSTALL_PATH= $(SHARE_INSTALL_PATH)/images -UARCH_INSTALL_PATH= $(SHARE_INSTALL_PATH)/uarch -LUA_INSTALL_CPATH= $(PREFIX)/lib/lua/5.4 -LUA_INSTALL_PATH= $(PREFIX)/share/lua/5.4 -INC_INSTALL_PATH= $(PREFIX)/include/machine-emulator +ARCH:= $(shell dpkg --print-architecture 2>/dev/null || echo amd64) +PREFIX= /usr +MACHINE_EMULATOR_VERSION:= $(shell make -sC src version) +MACHINE_EMULATOR_SO_VERSION:= $(shell make -sC src so-version) +DEB_FILENAME= cartesi-machine-v$(MACHINE_EMULATOR_VERSION)_$(ARCH).deb +BIN_RUNTIME_PATH= $(PREFIX)/bin +LIB_RUNTIME_PATH= $(PREFIX)/lib +DOC_RUNTIME_PATH= $(PREFIX)/doc/cartesi-machine +SHARE_RUNTIME_PATH= $(PREFIX)/share/cartesi-machine +IMAGES_RUNTIME_PATH= $(SHARE_RUNTIME_PATH)/images +LUA_RUNTIME_CPATH= $(PREFIX)/lib/lua/5.4 +LUA_RUNTIME_PATH= $(PREFIX)/share/lua/5.4 INSTALL_PLAT = install-$(UNAME) + LIBCARTESI_Darwin=libcartesi.dylib LIBCARTESI_Linux=libcartesi.so LIBCARTESI_PROTOBUF_Darwin=libcartesi_protobuf.dylib @@ -34,6 +38,23 @@ LIBCARTESI_PROTOBUF_Linux=libcartesi_protobuf.so LIBCARTESI_GRPC_Darwin=libcartesi_grpc.dylib LIBCARTESI_GRPC_Linux=libcartesi_grpc.so +LIBCARTESI_SO_Darwin:=libcartesi-$(MACHINE_EMULATOR_SO_VERSION).dylib +LIBCARTESI_SO_Linux:=libcartesi-$(MACHINE_EMULATOR_SO_VERSION).so +LIBCARTESI_SO_PROTOBUF_Darwin:=libcartesi_protobuf-$(MACHINE_EMULATOR_SO_VERSION).dylib +LIBCARTESI_SO_PROTOBUF_Linux:=libcartesi_protobuf-$(MACHINE_EMULATOR_SO_VERSION).so +LIBCARTESI_SO_GRPC_Darwin:=libcartesi_grpc-$(MACHINE_EMULATOR_SO_VERSION).dylib +LIBCARTESI_SO_GRPC_Linux:=libcartesi_grpc-$(MACHINE_EMULATOR_SO_VERSION).so + +BIN_INSTALL_PATH:= $(DESTDIR)$(BIN_RUNTIME_PATH) +LIB_INSTALL_PATH:= $(DESTDIR)$(LIB_RUNTIME_PATH) +DOC_INSTALL_PATH:= $(DESTDIR)$(DOC_RUNTIME_PATH) +SHARE_INSTALL_PATH:= $(DESTDIR)$(SHARE_RUNTIME_PATH) +IMAGES_INSTALL_PATH:= $(DESTDIR)$(IMAGES_RUNTIME_PATH) +UARCH_INSTALL_PATH:= $(SHARE_INSTALL_PATH)/uarch +LUA_INSTALL_CPATH:= $(DESTDIR)$(LUA_RUNTIME_CPATH) +LUA_INSTALL_PATH:= $(DESTDIR)$(LUA_RUNTIME_PATH) +INC_INSTALL_PATH:= $(DESTDIR)$(PREFIX)/include/cartesi-machine + INSTALL= cp -RP CHMOD_EXEC= chmod 0755 CHMOD_DATA= chmod 0644 @@ -42,12 +63,14 @@ STRIP_EXEC= strip -x DEP_TO_BIN= DEP_TO_LIB= EMU_TO_BIN= jsonrpc-remote-cartesi-machine remote-cartesi-machine remote-cartesi-machine-proxy merkle-tree-hash -EMU_TO_LIB= $(LIBCARTESI_$(UNAME)) $(LIBCARTESI_PROTOBUF_$(UNAME)) $(LIBCARTESI_GRPC_$(UNAME)) -EMU_LUA_TO_BIN= cartesi-machine-tests.lua cartesi-machine.lua cartesi-machine-stored-hash.lua rollup-memory-range.lua uarch-riscv-tests.lua -EMU_TO_LUA_PATH= cartesi/util.lua cartesi/proof.lua +EMU_TO_LIB= $(LIBCARTESI_SO_$(UNAME)) $(LIBCARTESI_SO_PROTOBUF_$(UNAME)) $(LIBCARTESI_SO_GRPC_$(UNAME)) +EMU_LUA_TO_BIN= cartesi-machine.lua cartesi-machine-stored-hash.lua rollup-memory-range.lua +EMU_LUA_TEST_TO_BIN= cartesi-machine-tests.lua uarch-riscv-tests.lua +EMU_TO_LUA_PATH= cartesi/util.lua cartesi/proof.lua cartesi/gdbstub.lua EMU_TO_LUA_CPATH= cartesi.so EMU_TO_LUA_CARTESI_CPATH= cartesi/grpc.so cartesi/jsonrpc.so -EMU_TO_INC= pma-defines.h rtc-defines.h +EMU_TO_INC= $(addprefix lib/machine-emulator-defines/,pma-defines.h rtc-defines.h) \ + $(addprefix src/,jsonrpc-machine-c-api.h grpc-machine-c-api.h machine-c-api.h machine-c-defines.h machine-c-version.h) UARCH_TO_SHARE= uarch-ram.bin # Build settings @@ -61,11 +84,11 @@ DEPDIRS := $(addprefix $(DEPDIR)/,mongoose-7.9) DEPCLEAN := $(addsuffix .clean,$(DEPDIRS)) COREPROTO := lib/grpc-interfaces/core.proto LUASOCKET_VERSION ?= 5b18e475f38fcf28429b1cc4b17baee3b9793a62 -LUA_DEFAULT_PATHS = $(LUA_INSTALL_PATH)/?.lua -LUA_DEFAULT_C_PATHS = $(LUA_INSTALL_CPATH)/?.so # Docker image tag TAG ?= devel +DEBIAN_IMG ?= cartesi/machine-emulator:$(TAG).deb + # Docker image platform BUILD_PLATFORM ?= @@ -144,9 +167,11 @@ help: @echo ' distclean - depclean + profile information and downloads' @echo 'Docker targets:' @echo ' build-debian-image - Build the machine-emulator debian based docker image' + @echo ' build-debian-package - BUild the cartesi-machine.deb package from image' @echo 'Generic targets:' @echo '* all - build the src/ code. To build from a clean clone, run: make submodules downloads dep all' @echo ' doc - build the doxygen documentation (requires doxygen to be installed)' + @echo ' copy - copy generated artifacts out of a docker image' @echo ' uarch - build microarchitecture' @echo ' uarch-with-linux-env - build microarchitecture using the linux-env docker image' @echo ' uarch-tests - build and run microarchitecture rv64i instruction tests' @@ -174,6 +199,9 @@ grpc: | $(COREPROTO) hash luacartesi grpc test lint coverage-report check-format format check-format-lua check-lua format-lua: @eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -C $(SRCDIR) $@ +version: + @eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -sC $(SRCDIR) $@ + test-%: @eval $$($(MAKE) -s --no-print-directory env); $(MAKE) -C $(SRCDIR) $@ @@ -205,7 +233,16 @@ build-linux-env: docker build $(DOCKER_PLATFORM) --target linux-env -t cartesi/linux-env:$(TAG) -f Dockerfile . build-debian-image: - docker build $(DOCKER_PLATFORM) --build-arg RELEASE=$(release) --build-arg COVERAGE=$(coverage) --build-arg SANITIZE=$(sanitize) -t cartesi/machine-emulator:$(TAG) -f Dockerfile . + docker build $(DOCKER_PLATFORM) --build-arg RELEASE=$(release) --build-arg COVERAGE=$(coverage) --build-arg SANITIZE=$(sanitize) --build-arg MACHINE_EMULATOR_VERSION=$(MACHINE_EMULATOR_VERSION) -t cartesi/machine-emulator:$(TAG) -f Dockerfile . + +build-debian-package: + docker build $(DOCKER_PLATFORM) --target debian-packager --build-arg RELEASE=$(release) --build-arg COVERAGE=$(coverage) --build-arg SANITIZE=$(sanitize) --build-arg MACHINE_EMULATOR_VERSION=$(MACHINE_EMULATOR_VERSION=) -t $(DEBIAN_IMG) -f Dockerfile . + +copy: + ID=`docker create $(DOCKER_PLATFORM) $(DEBIAN_IMG)` && \ + docker cp $$ID:/usr/src/emulator/$(DEB_FILENAME) . && \ + docker cp $$ID:/usr/src/emulator/uarch/uarch-ram.bin . && \ + docker rm $$ID check-linux-env: @if docker images $(DOCKER_PLATFORM) -q cartesi/linux-env:$(TAG)$(image_name) 2>/dev/null | grep -q .; then \ @@ -242,43 +279,62 @@ uarch-tests-with-linux-env: @$(MAKE) linux-env-exec CONTAINER_COMMAND="make uarch-tests" install-Darwin: - install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_INSTALL_PATH) $(LUA_INSTALL_CPATH)/cartesi.so - install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_INSTALL_PATH) $(LUA_INSTALL_CPATH)/cartesi/grpc.so - install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_INSTALL_PATH) $(LUA_INSTALL_CPATH)/cartesi/jsonrpc.so + install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $(LUA_INSTALL_CPATH)/cartesi.so + install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $(LUA_INSTALL_CPATH)/cartesi/grpc.so + install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $(LUA_INSTALL_CPATH)/cartesi/jsonrpc.so cd $(BIN_INSTALL_PATH) && \ for x in $(DEP_TO_BIN) $(EMU_TO_BIN); do \ - install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_INSTALL_PATH) $$x ;\ + install_name_tool -delete_rpath $(BUILDDIR)/lib -delete_rpath $(SRCDIR) -add_rpath $(LIB_RUNTIME_PATH) $$x ;\ done install-Linux: - cd $(BIN_INSTALL_PATH) && for x in $(DEP_TO_BIN) $(EMU_TO_BIN); do patchelf --set-rpath $(LIB_INSTALL_PATH) $$x ; done - cd $(LIB_INSTALL_PATH) && for x in `find . -maxdepth 1 -type f -name "*.so*"`; do patchelf --set-rpath $(LIB_INSTALL_PATH) $$x ; done - cd $(LUA_INSTALL_CPATH) && for x in `find . -maxdepth 2 -type f -name "*.so"`; do patchelf --set-rpath $(LIB_INSTALL_PATH) $$x ; done - -install-emulator: $(BIN_INSTALL_PATH) $(LUA_INSTALL_CPATH)/cartesi $(LUA_INSTALL_PATH)/cartesi $(INC_INSTALL_PATH) $(IMAGES_INSTALL_PATH) $(UARCH_INSTALL_PATH) + cd $(BIN_INSTALL_PATH) && for x in $(DEP_TO_BIN) $(EMU_TO_BIN); do patchelf --set-rpath $(LIB_RUNTIME_PATH) $$x ; done + cd $(LIB_INSTALL_PATH) && for x in `find . -maxdepth 1 -type f -name "*.so*"`; do patchelf --set-rpath $(LIB_RUNTIME_PATH) $$x ; done + cd $(LUA_INSTALL_CPATH) && for x in `find . -maxdepth 2 -type f -name "*.so"`; do patchelf --set-rpath $(LIB_RUNTIME_PATH) $$x ; done + +install-tests: install + cd src && $(INSTALL) $(EMU_LUA_TEST_TO_BIN) $(LUA_INSTALL_PATH) + cd src && $(INSTALL) tests/test-merkle-tree-hash tests/test-machine-c-api $(BIN_INSTALL_PATH) + cat tools/template/cartesi-machine-tests.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine-tests + cat tools/template/uarch-riscv-tests.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/uarch-riscv-tests + cd $(LUA_INSTALL_PATH) && $(CHMOD_DATA) $(EMU_LUA_TEST_TO_BIN) + cd $(BIN_INSTALL_PATH) && $(CHMOD_EXEC) cartesi-machine-tests uarch-riscv-tests + patchelf --set-rpath $(LIB_RUNTIME_PATH) src/tests/test-merkle-tree-hash + patchelf --set-rpath $(LIB_RUNTIME_PATH) src/tests/test-machine-c-api + +install-emulator: $(BIN_INSTALL_PATH) $(LIB_INSTALL_PATH) $(LUA_INSTALL_CPATH)/cartesi $(LUA_INSTALL_PATH)/cartesi $(INC_INSTALL_PATH) $(IMAGES_INSTALL_PATH) cd src && $(INSTALL) $(EMU_TO_BIN) $(BIN_INSTALL_PATH) cd src && $(INSTALL) $(EMU_TO_LIB) $(LIB_INSTALL_PATH) - cd src && $(INSTALL) $(EMU_LUA_TO_BIN) $(BIN_INSTALL_PATH) + cd src && $(INSTALL) $(EMU_LUA_TO_BIN) $(LUA_INSTALL_PATH) cd src && $(INSTALL) $(EMU_TO_LUA_CPATH) $(LUA_INSTALL_CPATH) cd src && $(INSTALL) $(EMU_TO_LUA_CARTESI_CPATH) $(LUA_INSTALL_CPATH)/cartesi cd src && $(INSTALL) $(EMU_TO_LUA_PATH) $(LUA_INSTALL_PATH)/cartesi - cd uarch && $(INSTALL) $(UARCH_TO_SHARE) $(UARCH_INSTALL_PATH) - cat tools/template/cartesi-machine.template | sed 's|ARG_LUA_PATH|${LUA_DEFAULT_PATHS}|g;s|ARG_LUA_CPATH|${LUA_DEFAULT_C_PATHS}|g;s|ARG_INSTALL_PATH|${IMAGES_INSTALL_PATH}|g;s|ARG_BIN_INSTALL_PATH|${BIN_INSTALL_PATH}|g' > $(BIN_INSTALL_PATH)/cartesi-machine - cat tools/template/cartesi-machine-tests.template | sed 's|ARG_LUA_PATH|${LUA_DEFAULT_PATHS}|g;s|ARG_LUA_CPATH|${LUA_DEFAULT_C_PATHS}|g;s|ARG_BIN_INSTALL_PATH|${BIN_INSTALL_PATH}|g' > $(BIN_INSTALL_PATH)/cartesi-machine-tests - cat tools/template/cartesi-machine-stored-hash.template | sed 's|ARG_LUA_PATH|${LUA_DEFAULT_PATHS}|g;s|ARG_LUA_CPATH|${LUA_DEFAULT_C_PATHS}|g;s|ARG_BIN_INSTALL_PATH|${BIN_INSTALL_PATH}|g' > $(BIN_INSTALL_PATH)/cartesi-machine-stored-hash - cat tools/template/rollup-memory-range.template | sed 's|ARG_LUA_PATH|${LUA_DEFAULT_PATHS}|g;s|ARG_LUA_CPATH|${LUA_DEFAULT_C_PATHS}|g;s|ARG_BIN_INSTALL_PATH|${BIN_INSTALL_PATH}|g' > $(BIN_INSTALL_PATH)/rollup-memory-range - cat tools/template/uarch-riscv-tests.template | sed 's|ARG_LUA_PATH|${LUA_DEFAULT_PATHS}|g;s|ARG_LUA_CPATH|${LUA_DEFAULT_C_PATHS}|g;s|ARG_BIN_INSTALL_PATH|${BIN_INSTALL_PATH}|g' > $(BIN_INSTALL_PATH)/uarch-riscv-tests - cd $(BIN_INSTALL_PATH) && $(CHMOD_EXEC) $(EMU_TO_BIN) cartesi-machine cartesi-machine-tests cartesi-machine-stored-hash rollup-memory-range uarch-riscv-tests - cd $(BIN_INSTALL_PATH) && $(CHMOD_DATA) $(EMU_LUA_TO_BIN) - cd lib/machine-emulator-defines && $(INSTALL) $(EMU_TO_INC) $(INC_INSTALL_PATH) + cat tools/template/cartesi-machine.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_INSTALL_PATH|$(IMAGES_RUNTIME_PATH)|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine + cat tools/template/cartesi-machine-stored-hash.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/cartesi-machine-stored-hash + cat tools/template/rollup-memory-range.template | sed 's|ARG_LUA_PATH|$(LUA_RUNTIME_PATH)/?.lua|g;s|ARG_LUA_CPATH|$(LUA_RUNTIME_CPATH)/?.so|g;s|ARG_LUA_RUNTIME_PATH|$(LUA_RUNTIME_PATH)|g' > $(BIN_INSTALL_PATH)/rollup-memory-range + cd $(BIN_INSTALL_PATH) && $(CHMOD_EXEC) $(EMU_TO_BIN) cartesi-machine cartesi-machine-stored-hash rollup-memory-range + cd $(LIB_INSTALL_PATH) && ln -sf $(LIBCARTESI_SO_$(UNAME)) $(LIBCARTESI_$(UNAME)) + cd $(LIB_INSTALL_PATH) && ln -sf $(LIBCARTESI_SO_PROTOBUF_$(UNAME)) $(LIBCARTESI_PROTOBUF_$(UNAME)) + cd $(LIB_INSTALL_PATH) && ln -sf $(LIBCARTESI_SO_GRPC_$(UNAME)) $(LIBCARTESI_GRPC_$(UNAME)) + cd $(LUA_INSTALL_PATH) && $(CHMOD_DATA) $(EMU_LUA_TO_BIN) + $(INSTALL) $(EMU_TO_INC) $(INC_INSTALL_PATH) + $(INSTALL) tools/gdb $(SHARE_INSTALL_PATH)/gdb cd $(LUA_INSTALL_CPATH) && $(CHMOD_EXEC) $(EMU_TO_LUA_CPATH) -install-strip: +install-uarch: install $(UARCH_INSTALL_PATH) + $(INSTALL) uarch/$(UARCH_TO_SHARE) $(UARCH_INSTALL_PATH) + +install-strip: install-emulator cd $(BIN_INSTALL_PATH) && $(STRIP_EXEC) $(EMU_TO_BIN) $(DEP_TO_BIN) cd $(LIB_INSTALL_PATH) && $(STRIP_EXEC) $(DEP_TO_LIB) cd $(LUA_INSTALL_CPATH) && $(STRIP_EXEC) *.so install: install-emulator install-strip $(INSTALL_PLAT) +debian-package: install + mkdir -p $(DESTDIR)/DEBIAN $(DOC_INSTALL_PATH) + $(INSTALL) COPYING $(DOC_INSTALL_PATH)/copyright + cat tools/template/control.template | sed 's|ARG_VERSION|$(MACHINE_EMULATOR_VERSION)|g;s|ARG_ARCH|$(ARCH)|g' > $(DESTDIR)/DEBIAN/control + dpkg-deb -Zxz --root-owner-group --build $(DESTDIR) $(DEB_FILENAME) .SECONDARY: $(DOWNLOADDIR) $(DEPDIRS) $(COREPROTO) diff --git a/README.md b/README.md index d1457e2d8..8e68167b1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Cartesi Machine Emulator -The Cartesi Machine Emulator is the reference off-chain implementation of the Cartesi Machine Specification. It's written in C/C++ with POSIX dependencies restricted to the terminal, process, and memory-mapping facilites. It is distributed as a library and scriptable in the Lua programming language. +The Cartesi Machine Emulator is the reference off-chain implementation of the Cartesi Machine Specification. It's written in C/C++ with POSIX dependencies restricted to the terminal, process, and memory-mapping facilities. It is distributed as a library and scriptable in the Lua programming language. The emulator implements RISC-V's RV64IMASU ISA. The letters after RV specify the extension set. This selection corresponds to a 64-bit machine, Integer arithmetic with Multiplication and division, Atomic operations, as well as the optional Supervisor and User privilege levels. In addition, Cartesi Machines support the Sv48 mode of address translation and memory protection. diff --git a/src/Makefile b/src/Makefile index 2777254b3..b607b7588 100644 --- a/src/Makefile +++ b/src/Makefile @@ -41,7 +41,7 @@ coverage?=no COVERAGE_TOOLCHAIN?=gcc COVERAGE_OUTPUT_DIR?=coverage -CARTESI_TESTS_PATH?=/opt/cartesi/share/tests +CARTESI_TESTS_PATH?=/opt/cartesi/share/cartesi-machine/tests # So we can use gcc to check if there are unused symbols ifeq ($(gc),yes) @@ -88,15 +88,15 @@ endif BOOST_CORO_LIB_Darwin:=$(BOOST_LIB_DIR_Darwin) -lboost_coroutine-mt -lboost_context-mt BOOST_FILESYSTEM_LIB_Darwin:=$(BOOST_LIB_DIR_Darwin) -lboost_system-mt -lboost_filesystem-mt BOOST_PROCESS_LIB_Darwin:=-lpthread -LIBCARTESI_Darwin=libcartesi.dylib +LIBCARTESI_Darwin=libcartesi-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).dylib LIBCARTESI_LDFLAGS_Darwin=-dynamiclib -undefined dynamic_lookup -install_name '@rpath/$(LIBCARTESI_Darwin)' LIBCARTESI_TESTS_LDFLAGS_Darwin=-Wl,-rpath,$(BUILDDIR)/lib -Wl,-rpath,$(CURDIR) -LIBCARTESI_PROTOBUF_Darwin=libcartesi_protobuf.dylib +LIBCARTESI_PROTOBUF_Darwin=libcartesi_protobuf-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).dylib LIBCARTESI_PROTOBUF_LDFLAGS_Darwin=-dynamiclib -undefined dynamic_lookup -install_name '@rpath/$(LIBCARTESI_PROTOBUF_Darwin)' -LIBCARTESI_GRPC_Darwin=libcartesi_grpc.dylib +LIBCARTESI_GRPC_Darwin=libcartesi_grpc-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).dylib LIBCARTESI_GRPC_LDFLAGS_Darwin=-dynamiclib -undefined dynamic_lookup -install_name '@rpath/$(LIBCARTESI_GRPC_Darwin)' LIBCARTESI_GRPC_TESTS_LDFLAGS_Darwin=-Wl,-rpath,$(BUILDDIR)/lib -Wl,-rpath,$(CURDIR) -LIBCARTESI_JSONRPC_Darwin=libcartesi_jsonrpc.dylib +LIBCARTESI_JSONRPC_Darwin=libcartesi_jsonrpc-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).dylib LIBCARTESI_JSONRPC_LDFLAGS_Darwin=-dynamiclib -undefined dynamic_lookup -install_name '@rpath/$(LIBCARTESI_JSONRPC_Darwin)' LIBCARTESI_JSONRPC_TESTS_LDFLAGS_Darwin=-Wl,-rpath,$(BUILDDIR)/lib -Wl,-rpath,$(CURDIR) CARTESI_EXECUTABLE_LDFLAGS_Darwin=-Wl,-rpath,$(BUILDDIR)/lib -Wl,-rpath,$(CURDIR) @@ -119,15 +119,15 @@ CRYPTOPP_INC_Linux:= GRPC_INC_Linux:= GRPC_LIB_Linux:=-lgrpc++ -lgrpc -lgpr -lprotobuf -lpthread -labsl_synchronization PROTOBUF_LIB_Linux:=-lprotobuf -lpthread -LIBCARTESI_Linux=libcartesi.so +LIBCARTESI_Linux=libcartesi-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).so LIBCARTESI_LDFLAGS_Linux:=$(SOLDFLAGS_Linux) LIBCARTESI_TESTS_LDFLAGS_Linux=-Wl,-rpath,'$$ORIGIN/..' -LIBCARTESI_PROTOBUF_Linux=libcartesi_protobuf.so +LIBCARTESI_PROTOBUF_Linux=libcartesi_protobuf-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).so LIBCARTESI_PROTOBUF_LDFLAGS_Linux:=$(SOLDFLAGS_Linux) -LIBCARTESI_GRPC_Linux=libcartesi_grpc.so +LIBCARTESI_GRPC_Linux=libcartesi_grpc-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).so LIBCARTESI_GRPC_LDFLAGS_Linux:=$(SOLDFLAGS_Linux) LIBCARTESI_GRPC_TESTS_LDFLAGS_Linux=-Wl,-rpath,'$$ORIGIN/..' -LIBCARTESI_JSONRPC_Linux=libcartesi_jsonrpc.so +LIBCARTESI_JSONRPC_Linux=libcartesi_jsonrpc-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).so LIBCARTESI_JSONRPC_LDFLAGS_Linux:=$(SOLDFLAGS_Linux) LIBCARTESI_JSONRPC_TESTS_LDFLAGS_Linux=-Wl,-rpath,'$$ORIGIN/..' CARTESI_EXECUTABLE_LDFLAGS_Linux=-Wl,-rpath,'$$ORIGIN/' -Wl,--copy-dt-needed-entries @@ -152,16 +152,16 @@ PROTOBUF_LIB=$(PROTOBUF_LIB_$(UNAME)) LIBCARTESI=$(LIBCARTESI_$(UNAME)) LIBCARTESI_LDFLAGS=$(LIBCARTESI_LDFLAGS_$(UNAME)) LIBCARTESI_TESTS_LDFLAGS=$(LIBCARTESI_TESTS_LDFLAGS_$(UNAME)) -LIBCARTESI_LIB=-L. -lcartesi +LIBCARTESI_LIB=-L. -lcartesi-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR) LIBCARTESI_PROTOBUF=$(LIBCARTESI_PROTOBUF_$(UNAME)) LIBCARTESI_PROTOBUF_LDFLAGS=$(LIBCARTESI_PROTOBUF_LDFLAGS_$(UNAME)) -LIBCARTESI_PROTOBUF_LIB=-L. -lcartesi_protobuf +LIBCARTESI_PROTOBUF_LIB=-L. -lcartesi_protobuf-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR) CARTESI_EXECUTABLE_LDFLAGS=$(CARTESI_EXECUTABLE_LDFLAGS_$(UNAME)) LIBCARTESI_GRPC=$(LIBCARTESI_GRPC_$(UNAME)) LIBCARTESI_GRPC_LDFLAGS=$(LIBCARTESI_GRPC_LDFLAGS_$(UNAME)) LIBCARTESI_GRPC_TESTS_LDFLAGS=$(LIBCARTESI_GRPC_TESTS_LDFLAGS_$(UNAME)) -LIBCARTESI_GRPC_LIB=-L. -lcartesi_grpc +LIBCARTESI_GRPC_LIB=-L. -lcartesi_grpc-$(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR) CARTESI_LIBS:=$(CRYPTOPP_LIB) $(LIBCARTESI_PROTOBUF_LIB) CARTESI_PROTOBUF_LIBS:=$(PROTOBUF_LIB) @@ -398,6 +398,12 @@ CARTESI_GRPC_LIBS+=-lprofiler LUACARTESI_LIBS+=-lprofiler endif +version: + @echo $(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR).$(EMULATOR_VERSION_PATCH)$(EMULATOR_VERSION_LABEL) + +so-version: + @echo $(EMULATOR_VERSION_MAJOR).$(EMULATOR_VERSION_MINOR) + $(LIBCARTESI): $(CARTESI_OBJS) $(LIBCARTESI_PROTOBUF) $(CXX) $(LDFLAGS) $(LIBCARTESI_LDFLAGS) -o $@ $(CARTESI_OBJS) $(CARTESI_LIBS) diff --git a/tools/template/cartesi-machine-stored-hash.template b/tools/template/cartesi-machine-stored-hash.template index 4324601f2..5d0a86722 100755 --- a/tools/template/cartesi-machine-stored-hash.template +++ b/tools/template/cartesi-machine-stored-hash.template @@ -1,4 +1,4 @@ #!/bin/sh export LUA_PATH_5_4="ARG_LUA_PATH;${LUA_PATH_5_4:-;}" export LUA_CPATH_5_4="ARG_LUA_CPATH;${LUA_CPATH_5_4:-;}" -lua5.4 "ARG_BIN_INSTALL_PATH/cartesi-machine-stored-hash.lua" "$@" +lua5.4 "ARG_LUA_RUNTIME_PATH/cartesi-machine-stored-hash.lua" "$@" diff --git a/tools/template/cartesi-machine-tests.template b/tools/template/cartesi-machine-tests.template index 4b32e50d7..ba398adf1 100755 --- a/tools/template/cartesi-machine-tests.template +++ b/tools/template/cartesi-machine-tests.template @@ -2,4 +2,4 @@ export LUA_PATH_5_4="ARG_LUA_PATH;${LUA_PATH_5_4:-;}" export LUA_CPATH_5_4="ARG_LUA_CPATH;${LUA_CPATH_5_4:-;}" export CARTESI_IMAGES_PATH="ARG_INSTALL_PATH" -lua5.4 "ARG_BIN_INSTALL_PATH/cartesi-machine-tests.lua" "$@" +lua5.4 "ARG_LUA_RUNTIME_PATH/cartesi-machine-tests.lua" "$@" diff --git a/tools/template/cartesi-machine.template b/tools/template/cartesi-machine.template index 6445d79d1..e612c4dbf 100755 --- a/tools/template/cartesi-machine.template +++ b/tools/template/cartesi-machine.template @@ -2,4 +2,4 @@ export LUA_PATH_5_4="ARG_LUA_PATH;${LUA_PATH_5_4:-;}" export LUA_CPATH_5_4="ARG_LUA_CPATH;${LUA_CPATH_5_4:-;}" export CARTESI_IMAGES_PATH="ARG_INSTALL_PATH" -lua5.4 "ARG_BIN_INSTALL_PATH/cartesi-machine.lua" "$@" +lua5.4 "ARG_LUA_RUNTIME_PATH/cartesi-machine.lua" "$@" diff --git a/tools/template/control.template b/tools/template/control.template new file mode 100644 index 000000000..467574b96 --- /dev/null +++ b/tools/template/control.template @@ -0,0 +1,12 @@ +Package: cartesi-machine +Source: cartesi-machine +Version: ARG_VERSION +Homepage: https://docs.cartesi.io/machine/host/cmdline/ +Architecture: ARG_ARCH +Maintainer: Machine Reference Unit +Provides: machine-emulator +Depends: libboost-coroutine1.74.0, libboost-context1.74.0, libboost-filesystem1.74.0, libreadline8, openssl, libc-ares2, zlib1g, ca-certificates, libgomp1, lua5.4, libb64-0d, libcrypto++8, libprotobuf32, libgrpc++1.51 +Section: devel +Priority: optional +Multi-Arch: foreign +Description: The Cartesi Machine Emulator is the reference off-chain implementation of the Cartesi Machine Specification. It's written in C/C++ with POSIX dependencies restricted to the terminal, process, and memory-mapping facilities. It is distributed as a library and scriptable in the Lua programming language. diff --git a/tools/template/rollup-memory-range.template b/tools/template/rollup-memory-range.template index 10c75cd73..84c6cf8c6 100755 --- a/tools/template/rollup-memory-range.template +++ b/tools/template/rollup-memory-range.template @@ -1,4 +1,4 @@ #!/bin/sh export LUA_PATH_5_4="ARG_LUA_PATH;${LUA_PATH_5_4:-;}" export LUA_CPATH_5_4="ARG_LUA_CPATH;${LUA_CPATH_5_4:-;}" -lua5.4 "ARG_BIN_INSTALL_PATH/rollup-memory-range.lua" "$@" +lua5.4 "ARG_LUA_RUNTIME_PATH/rollup-memory-range.lua" "$@" diff --git a/tools/template/uarch-riscv-tests.template b/tools/template/uarch-riscv-tests.template index 9df0a985b..0abe039f9 100644 --- a/tools/template/uarch-riscv-tests.template +++ b/tools/template/uarch-riscv-tests.template @@ -2,4 +2,4 @@ export LUA_PATH_5_4="ARG_LUA_PATH;${LUA_PATH_5_4:-;}" export LUA_CPATH_5_4="ARG_LUA_CPATH;${LUA_CPATH_5_4:-;}" export CARTESI_IMAGES_PATH="ARG_INSTALL_PATH" -lua5.4 "ARG_BIN_INSTALL_PATH/uarch-riscv-tests.lua" "$@" +lua5.4 "ARG_LUA_RUNTIME_PATH/uarch-riscv-tests.lua" "$@"