diff --git a/.github/actions/setup-tools/action.yml b/.github/actions/setup-tools/action.yml index b0dcc0aa..313eb210 100644 --- a/.github/actions/setup-tools/action.yml +++ b/.github/actions/setup-tools/action.yml @@ -31,3 +31,14 @@ runs: - name: Install just uses: extractions/setup-just@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + package_json_file: 'prt/contracts/package.json' + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: 'pnpm' + cache-dependency-path: 'prt/contracts/pnpm-lock.yaml' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31e5ce08..2cc6d5ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -238,6 +238,17 @@ jobs: - name: Install just uses: extractions/setup-just@v3 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + package_json_file: 'prt/contracts/package.json' + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: 'pnpm' + cache-dependency-path: 'prt/contracts/pnpm-lock.yaml' + - name: Contracts run: | just -f test/programs/justfile download-deps diff --git a/cartesi-rollups/contracts/.gitignore b/cartesi-rollups/contracts/.gitignore index 6cb61cee..beb62c1f 100644 --- a/cartesi-rollups/contracts/.gitignore +++ b/cartesi-rollups/contracts/.gitignore @@ -19,3 +19,6 @@ docs/ # Gas snapshot .gas-snapshot + +# Cannon +/deployments diff --git a/cartesi-rollups/contracts/cannonfile.instance.toml b/cartesi-rollups/contracts/cannonfile.instance.toml new file mode 100644 index 00000000..1e1d114a --- /dev/null +++ b/cartesi-rollups/contracts/cannonfile.instance.toml @@ -0,0 +1,72 @@ +name = 'cartesi-dave-consensus-instance' +version = '0.0.1' +description = 'Cartesi Dave Consensus Instance' + +[var.Settings] +appOwner = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" +initialHash = "<%= zeroHash %>" + +[pull.prtContracts] +source = "cartesi-prt-multilevel:0.0.1@main" + +[deploy.InputBox] +artifact = "InputBox" +create2 = true +salt = "<%= zeroHash %>" +ifExists = "continue" + +[deploy.DaveConsensusFactory] +artifact = "DaveConsensusFactory" +args = [ + "<%= InputBox.address %>", + "<%= prtContracts.MultiLevelTournamentFactory.address %>", +] +create2 = true +salt = "<%= zeroHash %>" +ifExists = "continue" + +[deploy.ApplicationFactory] +artifact = "ApplicationFactory" +create2 = true +salt = "<%= zeroHash %>" +ifExists = "continue" + +[invoke.newApplication] +target = "ApplicationFactory" +func = "newApplication(address,address,bytes32,bytes)" +args = [ + "<%= zeroAddress %>", + "<%= settings.appOwner %>", + "<%= settings.initialHash %>", + "<%= concat([slice(keccak256('InputBox(address)'), 0, 4), pad(contracts.InputBox.address)]) %>" +] +factory.ApplicationInstance.artifact = "Application" +factory.ApplicationInstance.event = "ApplicationCreated" +factory.ApplicationInstance.arg = 4 + +[invoke.addInput] +target = "InputBox" +func = "addInput" +args = [ + "<%= contracts.ApplicationInstance.address %>", + "<%= stringToHex('Hello, world!') %>", +] +var.firstInput.event = "InputAdded" +var.firstInput.arg = 2 + +[invoke.newDaveConsensus] +target = "DaveConsensusFactory" +func = "newDaveConsensus(address,bytes32)" +args = [ + "<%= contracts.ApplicationInstance.address %>", + "<%= settings.initialHash %>", +] +factory.DaveConsensusInstance.artifact = "DaveConsensus" +factory.DaveConsensusInstance.event = "DaveConsensusCreated" +factory.DaveConsensusInstance.arg = 0 + +[invoke.migrateToOutputsMerkleRootValidator] +target = "ApplicationInstance" +func = "migrateToOutputsMerkleRootValidator" +args = ["<%= contracts.DaveConsensusInstance.address %>"] +from = "<%= settings.appOwner %>" diff --git a/cartesi-rollups/contracts/cannonfile.toml b/cartesi-rollups/contracts/cannonfile.toml index a16df9bb..d8783ece 100644 --- a/cartesi-rollups/contracts/cannonfile.toml +++ b/cartesi-rollups/contracts/cannonfile.toml @@ -6,7 +6,7 @@ description = 'Cartesi Dave Consensus Factory' source = "cartesi-prt-multilevel:0.0.1@main" [pull.cartesiRollups] -source = "cartesi-rollups:2.0.0-rc.17@main" +source = "cartesi-rollups:2.0.0-rc.18@main" [deploy.DaveConsensusFactory] artifact = "DaveConsensusFactory" @@ -16,5 +16,4 @@ args = [ ] create2 = true salt = "<%= zeroHash %>" - - +ifExists = "continue" diff --git a/cartesi-rollups/contracts/deploy_anvil.sh b/cartesi-rollups/contracts/deploy_anvil.sh deleted file mode 100755 index c26628ce..00000000 --- a/cartesi-rollups/contracts/deploy_anvil.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -INITIAL_HASH=`xxd -p -c32 "${MACHINE_PATH}/hash"` - -export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 - -inputbox_script="forge script \ - script/InputBox.s.sol \ - --fork-url 'http://127.0.0.1:8545' \ - --broadcast \ - --non-interactive \ - --sig 'run()' \ - -vvvv 2>&1" - -deploy_inputbox=$(eval $inputbox_script) -inputbox_addresses=$(echo $deploy_inputbox | grep -oP 'new InputBox@(0x[a-fA-F0-9]{40})' | grep -oP '0x[a-fA-F0-9]{40}') -INPUTBOX_ADDRESS=$(echo $inputbox_addresses | cut -d ' ' -f 1) -echo $INPUTBOX_ADDRESS - -daveconsensus_script="forge script \ - script/DaveConsensus.s.sol \ - --fork-url 'http://127.0.0.1:8545' \ - --broadcast \ - --non-interactive \ - --sig 'run(bytes32,address)' \ - '$INITIAL_HASH' \ - '$INPUTBOX_ADDRESS' \ - -vvvv 2>&1" - -deploy_daveconsensus=$(eval $daveconsensus_script) -daveconsensus_addresses=$(echo $deploy_daveconsensus | grep -oP 'new DaveConsensus@(0x[a-fA-F0-9]{40})' | grep -oP '0x[a-fA-F0-9]{40}') -DAVECONSENSUS_ADDRESS=$(echo $daveconsensus_addresses | cut -d ' ' -f 1) -echo $DAVECONSENSUS_ADDRESS diff --git a/cartesi-rollups/contracts/foundry.toml b/cartesi-rollups/contracts/foundry.toml index d6132f42..d7850d4a 100644 --- a/cartesi-rollups/contracts/foundry.toml +++ b/cartesi-rollups/contracts/foundry.toml @@ -7,7 +7,7 @@ via_ir = true allow_paths = ["../../prt/contracts", "../../machine/step"] remappings = [ - 'cartesi-rollups-contracts-2.0.0/=dependencies/cartesi-rollups-contracts-2.0.0-rc.17/src/', + 'cartesi-rollups-contracts-2.0.0/=dependencies/cartesi-rollups-contracts-2.0.0-rc.18/src/', 'prt-contracts/=../../prt/contracts/src/', 'step/=../../machine/step/', @@ -18,4 +18,4 @@ solc-version = "0.8.27" [dependencies] "@openzeppelin-contracts" = "5.2.0" forge-std = "1.9.6" -cartesi-rollups-contracts = "2.0.0-rc.17" +cartesi-rollups-contracts = "2.0.0-rc.18" diff --git a/cartesi-rollups/contracts/justfile b/cartesi-rollups/contracts/justfile index 1b2c3032..751a7194 100644 --- a/cartesi-rollups/contracts/justfile +++ b/cartesi-rollups/contracts/justfile @@ -1,5 +1,6 @@ # Variables BINDINGS_DIR := "./bindings-rs/src/contract" +DEPLOYMENTS_DIR := "./deployments" SRC_DIR := "." BINDINGS_FILTER := "DaveConsensus" @@ -10,6 +11,7 @@ ANVIL_CHAIN_ID := "31337" default: build build: build-smart-contracts bind +clean: clean-smart-contracts clean-bindings clean-deployments fmt: forge fmt @@ -18,7 +20,8 @@ check-fmt: forge fmt --check install-deps: - forge soldeer install + pnpm install + forge soldeer install # compile smart contracts build-smart-contracts: @@ -35,26 +38,28 @@ clean-smart-contracts: clean-bindings: rm -rf {{BINDINGS_DIR}} +# clean cannon deployments +clean-deployments: + rm -rf {{DEPLOYMENTS_DIR}} + # generate Rust bindings from Solidity code bind: clean-bindings forge bind --alloy --select {{BINDINGS_FILTER}} \ --module --bindings-path {{BINDINGS_DIR}} \ --root {{SRC_DIR}} -deploy-dev INITIAL_HASH: - forge script \ - script/InputBox.s.sol \ - --fork-url {{ANVIL_ENDPOINT}} \ - --broadcast \ - --non-interactive \ - --sig 'run()' \ - -vvvv 2>&1 - forge script \ - script/DaveConsensus.s.sol \ - --fork-url {{ANVIL_ENDPOINT}} \ - --broadcast \ - --non-interactive \ - --sig 'run(bytes32,address)' \ - {{INITIAL_HASH}} \ - $(jq -r '.transactions[] | select(.transactionType=="CREATE").contractAddress' broadcast/InputBox.s.sol/{{ANVIL_CHAIN_ID}}/run-latest.json) \ - -vvvv 2>&1 +deploy-dev INITIAL_HASH: deploy-prt-core (deploy-instance INITIAL_HASH) + +deploy-prt-core: + just -f ../../prt/contracts/justfile deploy-core + +deploy-instance INITIAL_HASH: deploy-prt-core (deploy "cannonfile.instance.toml" ("initialHash=" + INITIAL_HASH)) + +deploy CANNONFILE *SETTINGS: + pnpm cannon build \ + --wipe \ + --rpc-url {{ANVIL_ENDPOINT}} \ + --private-key {{PRIVATE_KEY}} \ + --write-deployments {{DEPLOYMENTS_DIR}} \ + {{CANNONFILE}} \ + {{SETTINGS}} diff --git a/cartesi-rollups/contracts/package.json b/cartesi-rollups/contracts/package.json index 75a3c2d6..065a058a 100644 --- a/cartesi-rollups/contracts/package.json +++ b/cartesi-rollups/contracts/package.json @@ -4,6 +4,6 @@ "license": "Apache-2.0", "packageManager": "pnpm@10.7.0", "dependencies": { - "@usecannon/cli": "^2.21.5" + "@usecannon/cli": "^2.22.0" } } diff --git a/cartesi-rollups/contracts/pnpm-lock.yaml b/cartesi-rollups/contracts/pnpm-lock.yaml index de0f27f7..deea3cae 100644 --- a/cartesi-rollups/contracts/pnpm-lock.yaml +++ b/cartesi-rollups/contracts/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@usecannon/cli': - specifier: ^2.21.5 - version: 2.21.5 + specifier: ^2.22.0 + version: 2.22.0 packages: @@ -20,12 +20,12 @@ packages: '@assemblyscript/loader@0.9.4': resolution: {integrity: sha512-HazVq9zwTVwGmqdwYzu7WyQ6FQVZ7SwET0KKQuKm55jD0IfUpZgN0OPIiZG3zV1iSrVYcN0bdwLRXI/VNCYsUA==} - '@babel/code-frame@7.26.2': - resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} + '@babel/code-frame@7.27.1': + resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==} engines: {node: '>=6.9.0'} - '@babel/helper-validator-identifier@7.25.9': - resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} + '@babel/helper-validator-identifier@7.27.1': + resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==} engines: {node: '>=6.9.0'} '@endo/env-options@1.1.8': @@ -95,12 +95,12 @@ packages: '@multiformats/base-x@4.0.1': resolution: {integrity: sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw==} - '@noble/curves@1.8.1': - resolution: {integrity: sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ==} + '@noble/curves@1.8.2': + resolution: {integrity: sha512-vnI7V6lFNe0tLAuJMu+2sX+FcL14TaCWy1qiczg1VwRmPrpQCdq5ESXQMqUc2tluRNf6irBXrWbl1mGN8uaU/g==} engines: {node: ^14.21.3 || >=16} - '@noble/hashes@1.7.1': - resolution: {integrity: sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==} + '@noble/hashes@1.7.2': + resolution: {integrity: sha512-biZ0NUSxyjLLqo6KxEJ1b+C2NAx0wtDoFvCaXHGgUkeHzf3Xc1xKumFKREuT7f7DARNZ/slvYUwFG6B0f2b6hQ==} engines: {node: ^14.21.3 || >=16} '@protobufjs/aspromise@1.1.2': @@ -133,8 +133,8 @@ packages: '@protobufjs/utf8@1.1.0': resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} - '@scure/base@1.2.4': - resolution: {integrity: sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ==} + '@scure/base@1.2.5': + resolution: {integrity: sha512-9rE6EOVeIQzt5TSu4v+K523F8u6DhBsoZWPGKlnCshhlDhy0kJzUX4V+tr2dWmzF1GdekvThABoEQBGBQI7xZw==} '@scure/bip32@1.6.2': resolution: {integrity: sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw==} @@ -148,18 +148,18 @@ packages: '@types/minimist@1.2.5': resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} - '@types/node@22.13.14': - resolution: {integrity: sha512-Zs/Ollc1SJ8nKUAgc7ivOEdIBM8JAKgrqqUYi2J997JuKO7/tpQC+WCetQ1sypiKCQWHdvdg9wBNpUPEWZae7w==} + '@types/node@22.15.18': + resolution: {integrity: sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg==} '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} - '@usecannon/builder@2.21.5': - resolution: {integrity: sha512-Te/RAtoovpP4KM9inVl4A6RrXzjZnHiPpkCi13ZOWpnnrZOPxq2MeDiYDBJmeLm+6dUklAAtCRbHnda+w2GoXA==} + '@usecannon/builder@2.22.0': + resolution: {integrity: sha512-kyYrXU44jXeZ6R6/wV9acpF4rw+6/i9PEHnQ1qbLNxPXlFQfM7Ds16OnRP9Mu33lF2izRaCJUuteM0anUfXFAQ==} engines: {node: '>=16.0.0'} - '@usecannon/cli@2.21.5': - resolution: {integrity: sha512-QdR2ylCPmc8/xljs/LmwSvRv9Z0JSfahoB91SndJjjezkdFPV6B8j3DjkmK2EB+Tr0QKCvqxTopkttOS3C+XWw==} + '@usecannon/cli@2.22.0': + resolution: {integrity: sha512-jVwiR85TMRsmjcb9j1cEGQUQ6N+swBvZXGhqOAJy8+VbZotTdjpD+jY6+wl/oootapQlxDXupBnxGlVQDJnuUQ==} hasBin: true '@usecannon/router@4.1.3': @@ -219,8 +219,8 @@ packages: peerDependencies: axios: 0.x || 1.x - axios@1.8.4: - resolution: {integrity: sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==} + axios@1.9.0: + resolution: {integrity: sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==} balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -234,11 +234,11 @@ packages: blakejs@1.2.1: resolution: {integrity: sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==} - bn.js@4.12.1: - resolution: {integrity: sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==} + bn.js@4.12.2: + resolution: {integrity: sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==} - bn.js@5.2.1: - resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} + bn.js@5.2.2: + resolution: {integrity: sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw==} brace-expansion@2.0.1: resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} @@ -295,8 +295,8 @@ packages: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} - debug@4.4.0: - resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} + debug@4.4.1: + resolution: {integrity: sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -416,8 +416,8 @@ packages: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} - glob@11.0.1: - resolution: {integrity: sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==} + glob@11.0.2: + resolution: {integrity: sha512-YT7U7Vye+t5fZ/QMkBFrTJ7ZQxInIUjwyAjVj84CYXqgBdv30MFUPGnBR6sQaVq6Is15wYJUsnzTuWaGRBhBAQ==} engines: {node: 20 || >=22} hasBin: true @@ -802,8 +802,8 @@ packages: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true - semver@7.7.1: - resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} + semver@7.7.2: + resolution: {integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==} engines: {node: '>=10'} hasBin: true @@ -915,8 +915,8 @@ packages: uint8arrays@3.1.1: resolution: {integrity: sha512-+QJa8QRnbdXVpHYjLoTpJIdCTiw9Ir62nocClWuXIq2JIh4Uta0cQsTSpFL678p2CN8B+XSApwcU+pQEqVpKWg==} - undici-types@6.20.0: - resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} universalify@2.0.1: resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} @@ -942,8 +942,8 @@ packages: varint@6.0.0: resolution: {integrity: sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==} - viem@2.24.1: - resolution: {integrity: sha512-xptFlc081SIPz+ZNDeb0XS/Nn5PU28onq+im+UxEAPCXTIuL1kfw1GTnV8NhbUNoEONnrwcZNqoI0AT0ADF5XQ==} + viem@2.29.3: + resolution: {integrity: sha512-9D/nO+4S3Kk0P8vh6yXUA8OJ0mli9nzoY22qyh8iYHf1Q0GIejUnyq0QGjoDbkTcVzCVD5iA9KBkSxw9Tp3vUg==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: @@ -1008,8 +1008,8 @@ packages: peerDependencies: zod: ^3.13.2 - zod@3.24.2: - resolution: {integrity: sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==} + zod@3.24.4: + resolution: {integrity: sha512-OdqJE9UDRPwWsrHjLN2F8bPxvwJBK22EHLWtanu0LSYr5YqzsaaW3RMgmjwr8Rypg5k+meEJdSPXJZXE/yqOMg==} snapshots: @@ -1017,13 +1017,13 @@ snapshots: '@assemblyscript/loader@0.9.4': {} - '@babel/code-frame@7.26.2': + '@babel/code-frame@7.27.1': dependencies: - '@babel/helper-validator-identifier': 7.25.9 + '@babel/helper-validator-identifier': 7.27.1 js-tokens: 4.0.0 picocolors: 1.1.1 - '@babel/helper-validator-identifier@7.25.9': {} + '@babel/helper-validator-identifier@7.27.1': {} '@endo/env-options@1.1.8': {} @@ -1073,7 +1073,7 @@ snapshots: dependencies: '@ethersproject/bytes': 5.8.0 '@ethersproject/logger': 5.8.0 - bn.js: 5.2.1 + bn.js: 5.2.2 '@ethersproject/bytes@5.8.0': dependencies: @@ -1120,7 +1120,7 @@ snapshots: '@ethersproject/bytes': 5.8.0 '@ethersproject/logger': 5.8.0 '@ethersproject/properties': 5.8.0 - bn.js: 5.2.1 + bn.js: 5.2.2 elliptic: 6.6.1 hash.js: 1.1.7 @@ -1163,11 +1163,11 @@ snapshots: '@multiformats/base-x@4.0.1': {} - '@noble/curves@1.8.1': + '@noble/curves@1.8.2': dependencies: - '@noble/hashes': 1.7.1 + '@noble/hashes': 1.7.2 - '@noble/hashes@1.7.1': {} + '@noble/hashes@1.7.2': {} '@protobufjs/aspromise@1.1.2': {} @@ -1192,39 +1192,39 @@ snapshots: '@protobufjs/utf8@1.1.0': {} - '@scure/base@1.2.4': {} + '@scure/base@1.2.5': {} '@scure/bip32@1.6.2': dependencies: - '@noble/curves': 1.8.1 - '@noble/hashes': 1.7.1 - '@scure/base': 1.2.4 + '@noble/curves': 1.8.2 + '@noble/hashes': 1.7.2 + '@scure/base': 1.2.5 '@scure/bip39@1.5.4': dependencies: - '@noble/hashes': 1.7.1 - '@scure/base': 1.2.4 + '@noble/hashes': 1.7.2 + '@scure/base': 1.2.5 '@types/long@4.0.2': {} '@types/minimist@1.2.5': {} - '@types/node@22.13.14': + '@types/node@22.15.18': dependencies: - undici-types: 6.20.0 + undici-types: 6.21.0 '@types/normalize-package-data@2.4.4': {} - '@usecannon/builder@2.21.5': + '@usecannon/builder@2.22.0': dependencies: '@usecannon/router': 4.1.3 '@usecannon/web-solc': 0.5.1 acorn: 8.14.1 - axios: 1.8.4(debug@4.4.0) - axios-retry: 4.5.0(axios@1.8.4(debug@4.4.0)) + axios: 1.9.0(debug@4.4.1) + axios-retry: 4.5.0(axios@1.9.0(debug@4.4.1)) buffer: 6.0.3 chalk: 4.1.2 - debug: 4.4.0 + debug: 4.4.1 deep-freeze: 0.0.1 form-data: 4.0.2 fuse.js: 7.1.0 @@ -1234,8 +1234,8 @@ snapshots: rfdc: 1.4.1 ses: 1.12.0 typestub-ipfs-only-hash: 4.0.0 - viem: 2.24.1(zod@3.24.2) - zod: 3.24.2 + viem: 2.29.3(zod@3.24.4) + zod: 3.24.4 transitivePeerDependencies: - bufferutil - encoding @@ -1243,26 +1243,26 @@ snapshots: - typescript - utf-8-validate - '@usecannon/cli@2.21.5': + '@usecannon/cli@2.22.0': dependencies: '@iarna/toml': 3.0.0 - '@usecannon/builder': 2.21.5 - abitype: 1.0.8(zod@3.24.2) + '@usecannon/builder': 2.22.0 + abitype: 1.0.8(zod@3.24.4) chalk: 4.1.2 commander: 12.1.0 - debug: 4.4.0 + debug: 4.4.1 eth-provider: 0.13.7 fs-extra: 11.3.0 - glob: 11.0.1 + glob: 11.0.2 lodash: 4.17.21 prompts: 2.4.2 - semver: 7.7.1 + semver: 7.7.2 table: 6.9.0 tildify: 3.0.0 untildify: 4.0.0 - viem: 2.24.1(zod@3.24.2) - znv: 0.4.0(zod@3.24.2) - zod: 3.24.2 + viem: 2.29.3(zod@3.24.4) + znv: 0.4.0(zod@3.24.4) + zod: 3.24.4 transitivePeerDependencies: - bufferutil - encoding @@ -1274,16 +1274,16 @@ snapshots: dependencies: '@ethersproject/abi': 5.8.0 '@ethersproject/keccak256': 5.8.0 - debug: 4.4.0 + debug: 4.4.1 mustache: 4.2.0 transitivePeerDependencies: - supports-color '@usecannon/web-solc@0.5.1': {} - abitype@1.0.8(zod@3.24.2): + abitype@1.0.8(zod@3.24.4): optionalDependencies: - zod: 3.24.2 + zod: 3.24.4 acorn@8.14.1: {} @@ -1310,14 +1310,14 @@ snapshots: asynckit@0.4.0: {} - axios-retry@4.5.0(axios@1.8.4(debug@4.4.0)): + axios-retry@4.5.0(axios@1.9.0(debug@4.4.1)): dependencies: - axios: 1.8.4(debug@4.4.0) + axios: 1.9.0(debug@4.4.1) is-retry-allowed: 2.2.0 - axios@1.8.4(debug@4.4.0): + axios@1.9.0(debug@4.4.1): dependencies: - follow-redirects: 1.15.9(debug@4.4.0) + follow-redirects: 1.15.9(debug@4.4.1) form-data: 4.0.2 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -1335,9 +1335,9 @@ snapshots: blakejs@1.2.1: {} - bn.js@4.12.1: {} + bn.js@4.12.2: {} - bn.js@5.2.1: {} + bn.js@5.2.2: {} brace-expansion@2.0.1: dependencies: @@ -1397,7 +1397,7 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 - debug@4.4.0: + debug@4.4.1: dependencies: ms: 2.1.3 @@ -1422,7 +1422,7 @@ snapshots: elliptic@6.6.1: dependencies: - bn.js: 4.12.1 + bn.js: 4.12.2 brorand: 1.1.0 hash.js: 1.1.7 hmac-drbg: 1.0.1 @@ -1484,9 +1484,9 @@ snapshots: locate-path: 5.0.0 path-exists: 4.0.0 - follow-redirects@1.15.9(debug@4.4.0): + follow-redirects@1.15.9(debug@4.4.1): optionalDependencies: - debug: 4.4.0 + debug: 4.4.1 foreground-child@3.3.1: dependencies: @@ -1528,7 +1528,7 @@ snapshots: dunder-proto: 1.0.1 es-object-atoms: 1.1.1 - glob@11.0.1: + glob@11.0.2: dependencies: foreground-child: 3.3.1 jackspeak: 4.1.0 @@ -1802,21 +1802,21 @@ snapshots: dependencies: hosted-git-info: 4.1.0 is-core-module: 2.16.1 - semver: 7.7.1 + semver: 7.7.2 validate-npm-package-license: 3.0.4 oboe@2.1.5: dependencies: http-https: 1.0.0 - ox@0.6.9(zod@3.24.2): + ox@0.6.9(zod@3.24.4): dependencies: '@adraffy/ens-normalize': 1.11.0 - '@noble/curves': 1.8.1 - '@noble/hashes': 1.7.1 + '@noble/curves': 1.8.2 + '@noble/hashes': 1.7.2 '@scure/bip32': 1.6.2 '@scure/bip39': 1.5.4 - abitype: 1.0.8(zod@3.24.2) + abitype: 1.0.8(zod@3.24.4) eventemitter3: 5.0.1 transitivePeerDependencies: - zod @@ -1837,7 +1837,7 @@ snapshots: parse-json@5.2.0: dependencies: - '@babel/code-frame': 7.26.2 + '@babel/code-frame': 7.27.1 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -1875,7 +1875,7 @@ snapshots: '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 '@types/long': 4.0.2 - '@types/node': 22.13.14 + '@types/node': 22.15.18 long: 4.0.0 proxy-from-env@1.1.0: {} @@ -1886,7 +1886,7 @@ snapshots: dependencies: '@assemblyscript/loader': 0.9.4 bl: 5.1.0 - debug: 4.4.0 + debug: 4.4.1 minimist: 1.2.8 node-fetch: 2.7.0 readable-stream: 3.6.2 @@ -1932,7 +1932,7 @@ snapshots: semver@5.7.2: {} - semver@7.7.1: {} + semver@7.7.2: {} ses@1.12.0: dependencies: @@ -2041,7 +2041,7 @@ snapshots: dependencies: multiformats: 9.9.0 - undici-types@6.20.0: {} + undici-types@6.21.0: {} universalify@2.0.1: {} @@ -2060,15 +2060,15 @@ snapshots: varint@6.0.0: {} - viem@2.24.1(zod@3.24.2): + viem@2.29.3(zod@3.24.4): dependencies: - '@noble/curves': 1.8.1 - '@noble/hashes': 1.7.1 + '@noble/curves': 1.8.2 + '@noble/hashes': 1.7.2 '@scure/bip32': 1.6.2 '@scure/bip39': 1.5.4 - abitype: 1.0.8(zod@3.24.2) + abitype: 1.0.8(zod@3.24.4) isows: 1.0.6(ws@8.18.1) - ox: 0.6.9(zod@3.24.2) + ox: 0.6.9(zod@3.24.4) ws: 8.18.1 transitivePeerDependencies: - bufferutil @@ -2110,9 +2110,9 @@ snapshots: yargs-parser@20.2.9: {} - znv@0.4.0(zod@3.24.2): + znv@0.4.0(zod@3.24.4): dependencies: colorette: 2.0.20 - zod: 3.24.2 + zod: 3.24.4 - zod@3.24.2: {} + zod@3.24.4: {} diff --git a/cartesi-rollups/contracts/script/DaveConsensus.s.sol b/cartesi-rollups/contracts/script/DaveConsensus.s.sol deleted file mode 100644 index 72cf276a..00000000 --- a/cartesi-rollups/contracts/script/DaveConsensus.s.sol +++ /dev/null @@ -1,36 +0,0 @@ -// (c) Cartesi and individual authors (see AUTHORS) -// SPDX-License-Identifier: Apache-2.0 (see LICENSE) - -pragma solidity ^0.8.17; - -import {Script} from "forge-std-1.9.6/src/Script.sol"; - -import {Machine} from "prt-contracts/types/Machine.sol"; -import "prt-contracts/tournament/factories/MultiLevelTournamentFactory.sol"; -import "prt-contracts/state-transition/CmioStateTransition.sol"; -import "prt-contracts/state-transition/RiscVStateTransition.sol"; -import "prt-contracts/state-transition/CartesiStateTransition.sol"; -import "prt-contracts/../test/constants/TestTournamentParametersProvider.sol"; - -import "cartesi-rollups-contracts-2.0.0/inputs/IInputBox.sol"; - -import "src/DaveConsensus.sol"; - -// Only used for tests -contract DaveConsensusScript is Script { - function run(Machine.Hash initialHash, IInputBox inputBox) external { - vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - - MultiLevelTournamentFactory factory = new MultiLevelTournamentFactory( - new TopTournamentFactory(new TopTournament()), - new MiddleTournamentFactory(new MiddleTournament()), - new BottomTournamentFactory(new BottomTournament()), - new TestTournamentParametersProvider(), - new CartesiStateTransition(new RiscVStateTransition(), new CmioStateTransition()) - ); - - new DaveConsensus(inputBox, address(0x0), factory, initialHash); - - vm.stopBroadcast(); - } -} diff --git a/cartesi-rollups/contracts/script/InputBox.s.sol b/cartesi-rollups/contracts/script/InputBox.s.sol deleted file mode 100644 index c99ad877..00000000 --- a/cartesi-rollups/contracts/script/InputBox.s.sol +++ /dev/null @@ -1,20 +0,0 @@ -// (c) Cartesi and individual authors (see AUTHORS) -// SPDX-License-Identifier: Apache-2.0 (see LICENSE) - -pragma solidity ^0.8.17; - -import {Script} from "forge-std-1.9.6/src/Script.sol"; - -import "cartesi-rollups-contracts-2.0.0/inputs/InputBox.sol"; - -// Only used for tests -contract InputBoxScript is Script { - function run() external { - vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - - InputBox inputBox = new InputBox(); - inputBox.addInput(address(0x0), bytes("First input")); // add an input for epoch 0 - - vm.stopBroadcast(); - } -} diff --git a/cartesi-rollups/contracts/soldeer.lock b/cartesi-rollups/contracts/soldeer.lock index 1d19c1c7..2ed36aa6 100644 --- a/cartesi-rollups/contracts/soldeer.lock +++ b/cartesi-rollups/contracts/soldeer.lock @@ -7,10 +7,10 @@ integrity = "4cb7f3777f67fdf4b7d0e2f94d2f93f198b2e5dce718b7062ac7c2c83e1183bd" [[dependencies]] name = "cartesi-rollups-contracts" -version = "2.0.0-rc.17" -url = "https://soldeer-revisions.s3.amazonaws.com/cartesi-rollups-contracts/2_0_0-rc_17_28-03-2025_19:26:24_rollups-contracts.zip" -checksum = "72fed984d9d6464041fe038f9740c2ddb7eb478fc3959f050a0605e8d346fe08" -integrity = "6f9cdd1a1eedafe1d71e767492bbad9f6aaf5eec73b3bdd919152b6b65a6aa72" +version = "2.0.0-rc.18" +url = "https://soldeer-revisions.s3.amazonaws.com/cartesi-rollups-contracts/2_0_0-rc_18_12-05-2025_11:50:51_rollups-contracts.zip" +checksum = "d0ce6abc00c4bbd203c42cbd7bc733ed31dd67e3ebac13308cfbd81c9b48fe27" +integrity = "70bd8100c769d64f04daf18ec3de26ceb07c3d079851142df58ea923ced1d2ee" [[dependencies]] name = "forge-std" diff --git a/cartesi-rollups/contracts/src/CannonDependencies.sol b/cartesi-rollups/contracts/src/CannonDependencies.sol new file mode 100644 index 00000000..03bd7b36 --- /dev/null +++ b/cartesi-rollups/contracts/src/CannonDependencies.sol @@ -0,0 +1,8 @@ +// (c) Cartesi and individual authors (see AUTHORS) +// SPDX-License-Identifier: Apache-2.0 (see LICENSE) + +pragma solidity ^0.8.0; + +// List of contracts used in Cannonfiles + +import "cartesi-rollups-contracts-2.0.0/dapp/ApplicationFactory.sol"; diff --git a/cartesi-rollups/node/blockchain-reader/src/find_contract_creation.rs b/cartesi-rollups/node/blockchain-reader/src/find_contract_creation.rs index e8f35df9..9b542e24 100644 --- a/cartesi-rollups/node/blockchain-reader/src/find_contract_creation.rs +++ b/cartesi-rollups/node/blockchain-reader/src/find_contract_creation.rs @@ -80,31 +80,46 @@ mod tests { #[tokio::test] async fn test_predeployed_contracts_creation_blocks() { - // spawn Anvil + provider + the two contract addrs - let (_anvil, provider, input_box, consensus, _digest) = spawn_anvil_and_provider(); + // spawn Anvil + provider + contracts + let (_anvil, provider, address_book) = spawn_anvil_and_provider(); // find creation block for input_box - let input_block = find_contract_creation_block(&provider, input_box) + let input_block = find_contract_creation_block(&provider, address_book.input_box) .await .expect("failed to find input_box creation block"); // one block before should have no code let prev_input = provider - .get_code_at(input_box) + .get_code_at(address_book.input_box) .block_id(BlockId::Number((input_block - 1).into())) .await .unwrap(); assert!(prev_input.0.is_empty(), "input_box existed too early"); // find creation block for consensus - let consensus_block = find_contract_creation_block(&provider, consensus) + let consensus_block = find_contract_creation_block(&provider, address_book.consensus) .await .expect("failed to find consensus creation block"); // one block before should have no code let prev_consensus = provider - .get_code_at(consensus) + .get_code_at(address_book.consensus) .block_id(BlockId::Number((consensus_block - 1).into())) .await .unwrap(); assert!(prev_consensus.0.is_empty(), "consensus existed too early"); + + // find creation block for application + let application_block = find_contract_creation_block(&provider, address_book.app) + .await + .expect("failed to find application creation block"); + // one block before should have no code + let prev_application = provider + .get_code_at(address_book.app) + .block_id(BlockId::Number((application_block - 1).into())) + .await + .unwrap(); + assert!( + prev_application.0.is_empty(), + "application existed too early" + ); } } diff --git a/cartesi-rollups/node/blockchain-reader/src/lib.rs b/cartesi-rollups/node/blockchain-reader/src/lib.rs index 91b4e5d1..c8652e41 100644 --- a/cartesi-rollups/node/blockchain-reader/src/lib.rs +++ b/cartesi-rollups/node/blockchain-reader/src/lib.rs @@ -22,11 +22,9 @@ use num_traits::cast::ToPrimitive; use rollups_state_manager::sync::Watch; use std::ops::ControlFlow; use std::{ - env::var, fmt, iter::Peekable, marker::{Send, Sync}, - str::FromStr, time::Duration, }; @@ -34,7 +32,7 @@ use cartesi_dave_contracts::daveconsensus::DaveConsensus::{self, EpochSealed}; use cartesi_rollups_contracts::{application::Application, inputbox::InputBox::InputAdded}; use rollups_state_manager::{Epoch, Input, InputId, StateManager}; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] pub struct AddressBook { /// address of app pub app: Address, @@ -62,67 +60,36 @@ impl fmt::Display for AddressBook { impl AddressBook { // fetch other addresses from application pub async fn new(app: Address, provider: &impl Provider) -> Self { - if !app.is_zero() { - let application_contract = Application::new(app, provider); + let application_contract = Application::new(app, provider); - let consensus = application_contract - .getOutputsMerkleRootValidator() - .call() - .await - .expect("fail to query consensus address") - ._0; - - let input_box = { - let consensus_contract = DaveConsensus::new(consensus, provider); - consensus_contract - .getInputBox() - .call() - .await - .expect("fail to query input box address") - ._0 - }; + let consensus = application_contract + .getOutputsMerkleRootValidator() + .call() + .await + .expect("fail to query consensus address") + ._0; - let initial_hash = Self::initial_hash(consensus, provider).await; - let input_box_created_block = find_contract_creation_block(provider, input_box) + let input_box = { + let consensus_contract = DaveConsensus::new(consensus, provider); + consensus_contract + .getInputBox() + .call() .await - .expect("fail to get input_box creation block"); - - Self { - app, - consensus, - input_box, - genesis_block_number: input_box_created_block, - initial_hash, - } - } else { - // Test case. - // TODO: redesign tests so that this is no longer needed. - let consensus = Address::from_str( - var("CONSENSUS") - .expect("fail to load consensus address") - .as_str(), - ) - .expect("fail to parse consensus address"); - - let input_box = { - let consensus_contract = DaveConsensus::new(consensus, provider); - consensus_contract - .getInputBox() - .call() - .await - .expect("fail to query input box address") - ._0 - }; + .expect("fail to query input box address") + ._0 + }; - let initial_hash = Self::initial_hash(consensus, provider).await; + let initial_hash = Self::initial_hash(consensus, provider).await; + let input_box_created_block = find_contract_creation_block(provider, input_box) + .await + .expect("fail to get input_box creation block"); - Self { - app, - consensus, - input_box, - genesis_block_number: 0, - initial_hash, - } + Self { + app, + consensus, + input_box, + genesis_block_number: input_box_created_block, + initial_hash, } } @@ -541,6 +508,7 @@ mod blockchain_reader_tests { sol_types::{SolCall, SolValue}, }; use cartesi_dave_contracts::daveconsensus::DaveConsensus::{self, EpochSealed}; + use cartesi_dave_merkle::Digest; use cartesi_machine::{ Machine, config::{ @@ -557,7 +525,6 @@ mod blockchain_reader_tests { use tokio::time::{Duration, sleep}; type Result = std::result::Result>; - const APP_ADDRESS: Address = Address::ZERO; const INPUT_PAYLOAD: &str = "Hello!"; const INPUT_PAYLOAD2: &str = "Hello Two!"; @@ -598,12 +565,13 @@ mod blockchain_reader_tests { async fn add_input( inputbox: &InputBox::InputBoxInstance<(), DynProvider>, + application_address: Address, input_payload: &'static str, count: usize, ) -> Result<()> { for _ in 0..count { inputbox - .addInput(APP_ADDRESS, input_payload.as_bytes().into()) + .addInput(application_address, input_payload.as_bytes().into()) .max_fee_per_gas(10000000000) .send() .await? @@ -647,6 +615,7 @@ mod blockchain_reader_tests { async fn read_inputs_until_count( url: &str, inputbox_address: &Address, + application_address: &Address, input_reader: &EventReader, count: usize, ) -> Result> { @@ -659,7 +628,7 @@ mod blockchain_reader_tests { read_inputs = input_reader .next( &provider, - Some(&APP_ADDRESS.into_word().into()), + Some(&application_address.into_word().into()), inputbox_address, 0, latest_finalized_block, @@ -692,17 +661,18 @@ mod blockchain_reader_tests { #[tokio::test] async fn test_input_reader() -> Result<()> { - let (anvil, provider, input_box_address, _, _) = spawn_anvil_and_provider(); - let inputbox = InputBox::new(input_box_address, provider.clone()); + let (anvil, provider, address_book) = spawn_anvil_and_provider(); + let inputbox = InputBox::new(address_book.input_box, provider.clone()); let input_count_1 = 2; // Inputbox is deployed with 1 input already - add_input(&inputbox, INPUT_PAYLOAD, input_count_1).await?; + add_input(&inputbox, address_book.app, INPUT_PAYLOAD, input_count_1).await?; let input_reader = create_input_reader(); let mut read_inputs = read_inputs_until_count( &anvil.endpoint(), inputbox.address(), + &address_book.app, &input_reader, 1 + input_count_1, ) @@ -714,10 +684,11 @@ mod blockchain_reader_tests { assert_eq!(received_payload.payload.as_ref(), INPUT_PAYLOAD.as_bytes()); let input_count_2 = 3; - add_input(&inputbox, INPUT_PAYLOAD2, input_count_2).await?; + add_input(&inputbox, address_book.app, INPUT_PAYLOAD2, input_count_2).await?; read_inputs = read_inputs_until_count( &anvil.endpoint(), inputbox.address(), + &address_book.app, &input_reader, 1 + input_count_1 + input_count_2, ) @@ -734,8 +705,8 @@ mod blockchain_reader_tests { #[tokio::test] async fn test_epoch_reader() -> Result<()> { - let (anvil, provider, _, consensus_address, initial_state) = spawn_anvil_and_provider(); - let daveconsensus = DaveConsensus::new(consensus_address, &provider); + let (anvil, provider, address_book) = spawn_anvil_and_provider(); + let daveconsensus = DaveConsensus::new(address_book.consensus, &provider); let epoch_reader = create_epoch_reader(); let read_epochs = @@ -744,7 +715,9 @@ mod blockchain_reader_tests { assert_eq!(read_epochs.len(), 1); assert_eq!( &read_epochs[0].initialMachineStateHash.abi_encode(), - initial_state.slice() + Digest::from_digest(&address_book.initial_hash) + .unwrap() + .slice() ); drop(anvil); @@ -753,23 +726,16 @@ mod blockchain_reader_tests { #[tokio::test] async fn test_blockchain_reader() -> Result<()> { - let (anvil, provider, input_box_address, consensus_address, _) = spawn_anvil_and_provider(); + let (anvil, provider, address_book) = spawn_anvil_and_provider(); - let inputbox = InputBox::new(input_box_address, provider.clone()); + let inputbox = InputBox::new(address_book.input_box, provider.clone()); let (handle, mut state_manager) = state_access(); - let address_book = AddressBook { - app: APP_ADDRESS, - consensus: consensus_address, - input_box: input_box_address, - genesis_block_number: 0, - initial_hash: AddressBook::initial_hash(consensus_address, &provider).await, - }; // Note that inputbox is deployed with 1 input already // add inputs to epoch 0 let input_count_1 = 2; - add_input(&inputbox, INPUT_PAYLOAD, input_count_1).await?; + add_input(&inputbox, address_book.app, INPUT_PAYLOAD, input_count_1).await?; let watch = Watch::default(); @@ -790,13 +756,13 @@ mod blockchain_reader_tests { // add inputs ttest_blockchain_readero epoch 1 let input_count_2 = 3; - add_input(&inputbox, INPUT_PAYLOAD, input_count_2).await?; + add_input(&inputbox, address_book.app, INPUT_PAYLOAD, input_count_2).await?; read_inputs_from_db_until_count(&mut state_manager, 1, input_count_1 + input_count_2) .await?; // add more inputs to epoch 1 let input_count_3 = 3; - add_input(&inputbox, INPUT_PAYLOAD, input_count_3).await?; + add_input(&inputbox, address_book.app, INPUT_PAYLOAD, input_count_3).await?; read_inputs_from_db_until_count( &mut state_manager, 1, diff --git a/cartesi-rollups/node/blockchain-reader/src/test_utils.rs b/cartesi-rollups/node/blockchain-reader/src/test_utils.rs index bd9dcc8c..cac5c663 100644 --- a/cartesi-rollups/node/blockchain-reader/src/test_utils.rs +++ b/cartesi-rollups/node/blockchain-reader/src/test_utils.rs @@ -1,3 +1,4 @@ +use crate::AddressBook; use alloy::{ hex::FromHex, network::EthereumWallet, @@ -6,7 +7,6 @@ use alloy::{ providers::{DynProvider, Provider, ProviderBuilder}, signers::{Signer, local::PrivateKeySigner}, }; -use cartesi_dave_merkle::Digest; use std::{ fs::{self, File}, io::Read, @@ -19,7 +19,7 @@ pub fn program_path() -> PathBuf { PathBuf::from(PROGRAM).canonicalize().unwrap() } -pub fn spawn_anvil_and_provider() -> (AnvilInstance, DynProvider, Address, Address, Digest) { +pub fn spawn_anvil_and_provider() -> (AnvilInstance, DynProvider, AddressBook) { let program_path = program_path(); let anvil = Anvil::default() @@ -45,12 +45,13 @@ pub fn spawn_anvil_and_provider() -> (AnvilInstance, DynProvider, Address, Addre .on_http(anvil.endpoint_url()) .erased(); - let (input_box_address, consensus_address) = { + let (input_box, consensus, app) = { let addresses = fs::read_to_string(program_path.join("addresses")).unwrap(); let mut lines = addresses.lines().map(str::trim); ( Address::from_hex(lines.next().unwrap()).unwrap(), Address::from_hex(lines.next().unwrap()).unwrap(), + Address::from_hex(lines.next().unwrap()).unwrap(), ) }; @@ -65,8 +66,12 @@ pub fn spawn_anvil_and_provider() -> (AnvilInstance, DynProvider, Address, Addre ( anvil, provider, - input_box_address, - consensus_address, - Digest::from_digest(&initial_hash).unwrap(), + AddressBook { + app, + consensus, + input_box, + genesis_block_number: 0, + initial_hash, + }, ) } diff --git a/justfile b/justfile index e76d4261..025d5f39 100644 --- a/justfile +++ b/justfile @@ -4,10 +4,7 @@ update-submodules: clean-emulator: make -C machine/emulator clean depclean distclean -clean-contracts: clean-bindings - just -f ./cartesi-rollups/contracts/justfile clean-smart-contracts - just -f ./prt/contracts/justfile clean-smart-contracts - +clean-contracts: clean-consensus-contracts clean-prt-contracts clean-bindings clean-deployments make -C machine/emulator clean depclean distclean setup: update-submodules clean-emulator clean-contracts @@ -28,8 +25,12 @@ build-consensus: just -f ./cartesi-rollups/contracts/justfile build test-consensus: just -f ./cartesi-rollups/contracts/justfile test +clean-consensus-contracts: + just -f ./cartesi-rollups/contracts/justfile clean-smart-contracts clean-consensus-bindings: just -f ./cartesi-rollups/contracts/justfile clean-bindings +clean-consensus-deployments: + just -f ./cartesi-rollups/contracts/justfile clean-deployments bind-consensus: just -f ./cartesi-rollups/contracts/justfile bind @@ -37,8 +38,12 @@ build-prt: just -f ./prt/contracts/justfile build test-prt: just -f ./prt/contracts/justfile test +clean-prt-contracts: + just -f ./prt/contracts/justfile clean-smart-contracts clean-prt-bindings: just -f ./prt/contracts/justfile clean-bindings +clean-prt-deployments: + just -f ./prt/contracts/justfile clean-deployments bind-prt: just -f ./prt/contracts/justfile bind @@ -46,6 +51,7 @@ build-smart-contracts: build-consensus build-prt test-smart-contracts: build-smart-contracts test-consensus test-prt bind: bind-consensus bind-prt clean-bindings: clean-consensus-bindings clean-prt-bindings +clean-deployments: clean-consensus-deployments clean-prt-deployments fmt-rust-workspace: bind cargo fmt diff --git a/prt/contracts/.gitignore b/prt/contracts/.gitignore index 3db8f2bb..cedbdd95 100644 --- a/prt/contracts/.gitignore +++ b/prt/contracts/.gitignore @@ -24,3 +24,6 @@ lcov.info.pruned # Gas snapshot .gas-snapshot + +# Cannon +/deployments diff --git a/prt/contracts/cannonfile.instance.toml b/prt/contracts/cannonfile.instance.toml new file mode 100644 index 00000000..dc2f3dba --- /dev/null +++ b/prt/contracts/cannonfile.instance.toml @@ -0,0 +1,21 @@ +name = 'cartesi-prt-multilevel-instance' +version = '0.0.1' +description = 'Cartesi PRT contracts test' + +[pull.prtContracts] +source = "cartesi-prt-multilevel:0.0.1@main" + +[var.Settings] +initialHash = "<%= zeroHash %>" +dataProvider = "<%= zeroAddress %>" + +[invoke.deployment] +target = "prtContracts.MultiLevelTournamentFactory" +func = "instantiate" +args = [ + "<%= settings.initialHash %>", + "<%= settings.dataProvider %>", +] +factory.TopTournamentInstance.abiOf = ["prtContracts.TopTournament"] +factory.TopTournamentInstance.event = "tournamentCreated" +factory.TopTournamentInstance.arg = 0 diff --git a/prt/contracts/cannonfile.toml b/prt/contracts/cannonfile.toml index 12dced0b..df5f4cee 100644 --- a/prt/contracts/cannonfile.toml +++ b/prt/contracts/cannonfile.toml @@ -6,11 +6,13 @@ description = 'Cartesi PRT contracts' artifact = "RiscVStateTransition" create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.CmioStateTransition] artifact = "CmioStateTransition" create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.CartesiStateTransition] artifact = "CartesiStateTransition" @@ -20,44 +22,52 @@ args = [ ] create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.TopTournament] artifact = "TopTournament" create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.TopTournamentFactory] artifact = "TopTournamentFactory" args = ["<%= contracts.TopTournament.address %>"] create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.MiddleTournament] artifact = "MiddleTournament" create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.MiddleTournamentFactory] artifact = "MiddleTournamentFactory" args = ["<%= contracts.MiddleTournament.address %>"] create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.BottomTournament] artifact = "BottomTournament" create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.BottomTournamentFactory] artifact = "BottomTournamentFactory" args = ["<%= contracts.BottomTournament.address %>"] create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.CanonicalTournamentParametersProvider] artifact = "CanonicalTournamentParametersProvider" create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" [deploy.MultiLevelTournamentFactory] artifact = "MultiLevelTournamentFactory" @@ -70,3 +80,4 @@ args = [ ] create2 = true salt = "<%= zeroHash %>" +ifExists = "continue" diff --git a/prt/contracts/deploy_anvil.sh b/prt/contracts/deploy_anvil.sh deleted file mode 100755 index 21e35912..00000000 --- a/prt/contracts/deploy_anvil.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -INITIAL_HASH=`xxd -p -c32 "${MACHINE_PATH}/hash"` - -export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 - -forge_script="forge script \ - script/TopTournament.s.sol \ - --fork-url 'http://127.0.0.1:8545' \ - --broadcast \ - --non-interactive \ - --sig 'run(bytes32)' \ - '${INITIAL_HASH}' \ - -vvvv 2>&1" - -output=$(eval $forge_script) -top_tournament_addresses=$(echo $output | grep -oP 'new TopTournament@(0x[a-fA-F0-9]{40})' | grep -oP '0x[a-fA-F0-9]{40}') -top_tournament_address=$(echo $top_tournament_addresses | cut -d ' ' -f 1) - -echo $top_tournament_address diff --git a/prt/contracts/justfile b/prt/contracts/justfile index 9528e883..f18c2592 100644 --- a/prt/contracts/justfile +++ b/prt/contracts/justfile @@ -1,4 +1,5 @@ BINDINGS_DIR := "./bindings-rs/src/contract" +DEPLOYMENTS_DIR := "./deployments" SRC_DIR := "." BINDINGS_FILTER := "^[^I].+TournamentFactory|LeafTournament|RootTournament|^Tournament$" @@ -9,7 +10,7 @@ ANVIL_CHAIN_ID := "31337" default: build build: build-smart-contracts bind -clean: clean-smart-contracts clean-bindings +clean: clean-smart-contracts clean-bindings clean-deployments build-smart-contracts: forge build @@ -31,22 +32,31 @@ check-fmt: forge fmt --check install-deps: - forge soldeer install + pnpm install + forge soldeer install clean-bindings: rm -rf {{BINDINGS_DIR}} +clean-deployments: + rm -rf {{DEPLOYMENTS_DIR}} + bind: clean-bindings forge bind --alloy --select "{{BINDINGS_FILTER}}" \ --module --bindings-path {{BINDINGS_DIR}} \ --root {{SRC_DIR}} -deploy-dev INITIAL_HASH: - forge script \ - script/TopTournament.s.sol \ - --fork-url {{ANVIL_ENDPOINT}} \ - --broadcast \ - --non-interactive \ - --sig 'run(bytes32)' \ - '{{INITIAL_HASH}}' \ - -vvvv 2>&1 +deploy-dev INITIAL_HASH: deploy-core (deploy-instance INITIAL_HASH) + +deploy-core: (deploy "cannonfile.toml") + +deploy-instance INITIAL_HASH: deploy-core (deploy "cannonfile.instance.toml" ("initialHash=" + INITIAL_HASH)) + +deploy CANNONFILE *SETTINGS: + pnpm cannon build \ + --wipe \ + --rpc-url {{ANVIL_ENDPOINT}} \ + --private-key {{PRIVATE_KEY}} \ + --write-deployments {{DEPLOYMENTS_DIR}} \ + {{CANNONFILE}} \ + {{SETTINGS}} diff --git a/prt/contracts/package.json b/prt/contracts/package.json index 8d77348b..d14a0ac7 100644 --- a/prt/contracts/package.json +++ b/prt/contracts/package.json @@ -4,6 +4,6 @@ "license": "Apache-2.0", "packageManager": "pnpm@10.7.0", "dependencies": { - "@usecannon/cli": "^2.21.5" + "@usecannon/cli": "^2.22.0" } } diff --git a/prt/contracts/pnpm-lock.yaml b/prt/contracts/pnpm-lock.yaml index de0f27f7..deea3cae 100644 --- a/prt/contracts/pnpm-lock.yaml +++ b/prt/contracts/pnpm-lock.yaml @@ -9,8 +9,8 @@ importers: .: dependencies: '@usecannon/cli': - specifier: ^2.21.5 - version: 2.21.5 + specifier: ^2.22.0 + version: 2.22.0 packages: @@ -20,12 +20,12 @@ packages: '@assemblyscript/loader@0.9.4': resolution: {integrity: sha512-HazVq9zwTVwGmqdwYzu7WyQ6FQVZ7SwET0KKQuKm55jD0IfUpZgN0OPIiZG3zV1iSrVYcN0bdwLRXI/VNCYsUA==} - '@babel/code-frame@7.26.2': - resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==} + '@babel/code-frame@7.27.1': + resolution: {integrity: sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==} engines: {node: '>=6.9.0'} - '@babel/helper-validator-identifier@7.25.9': - resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==} + '@babel/helper-validator-identifier@7.27.1': + resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==} engines: {node: '>=6.9.0'} '@endo/env-options@1.1.8': @@ -95,12 +95,12 @@ packages: '@multiformats/base-x@4.0.1': resolution: {integrity: sha512-eMk0b9ReBbV23xXU693TAIrLyeO5iTgBZGSJfpqriG8UkYvr/hC9u9pyMlAakDNHWmbhMZCDs6KQO0jzKD8OTw==} - '@noble/curves@1.8.1': - resolution: {integrity: sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ==} + '@noble/curves@1.8.2': + resolution: {integrity: sha512-vnI7V6lFNe0tLAuJMu+2sX+FcL14TaCWy1qiczg1VwRmPrpQCdq5ESXQMqUc2tluRNf6irBXrWbl1mGN8uaU/g==} engines: {node: ^14.21.3 || >=16} - '@noble/hashes@1.7.1': - resolution: {integrity: sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ==} + '@noble/hashes@1.7.2': + resolution: {integrity: sha512-biZ0NUSxyjLLqo6KxEJ1b+C2NAx0wtDoFvCaXHGgUkeHzf3Xc1xKumFKREuT7f7DARNZ/slvYUwFG6B0f2b6hQ==} engines: {node: ^14.21.3 || >=16} '@protobufjs/aspromise@1.1.2': @@ -133,8 +133,8 @@ packages: '@protobufjs/utf8@1.1.0': resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==} - '@scure/base@1.2.4': - resolution: {integrity: sha512-5Yy9czTO47mqz+/J8GM6GIId4umdCk1wc1q8rKERQulIoc8VP9pzDcghv10Tl2E7R96ZUx/PhND3ESYUQX8NuQ==} + '@scure/base@1.2.5': + resolution: {integrity: sha512-9rE6EOVeIQzt5TSu4v+K523F8u6DhBsoZWPGKlnCshhlDhy0kJzUX4V+tr2dWmzF1GdekvThABoEQBGBQI7xZw==} '@scure/bip32@1.6.2': resolution: {integrity: sha512-t96EPDMbtGgtb7onKKqxRLfE5g05k7uHnHRM2xdE6BP/ZmxaLtPek4J4KfVn/90IQNrU1IOAqMgiDtUdtbe3nw==} @@ -148,18 +148,18 @@ packages: '@types/minimist@1.2.5': resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} - '@types/node@22.13.14': - resolution: {integrity: sha512-Zs/Ollc1SJ8nKUAgc7ivOEdIBM8JAKgrqqUYi2J997JuKO7/tpQC+WCetQ1sypiKCQWHdvdg9wBNpUPEWZae7w==} + '@types/node@22.15.18': + resolution: {integrity: sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg==} '@types/normalize-package-data@2.4.4': resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} - '@usecannon/builder@2.21.5': - resolution: {integrity: sha512-Te/RAtoovpP4KM9inVl4A6RrXzjZnHiPpkCi13ZOWpnnrZOPxq2MeDiYDBJmeLm+6dUklAAtCRbHnda+w2GoXA==} + '@usecannon/builder@2.22.0': + resolution: {integrity: sha512-kyYrXU44jXeZ6R6/wV9acpF4rw+6/i9PEHnQ1qbLNxPXlFQfM7Ds16OnRP9Mu33lF2izRaCJUuteM0anUfXFAQ==} engines: {node: '>=16.0.0'} - '@usecannon/cli@2.21.5': - resolution: {integrity: sha512-QdR2ylCPmc8/xljs/LmwSvRv9Z0JSfahoB91SndJjjezkdFPV6B8j3DjkmK2EB+Tr0QKCvqxTopkttOS3C+XWw==} + '@usecannon/cli@2.22.0': + resolution: {integrity: sha512-jVwiR85TMRsmjcb9j1cEGQUQ6N+swBvZXGhqOAJy8+VbZotTdjpD+jY6+wl/oootapQlxDXupBnxGlVQDJnuUQ==} hasBin: true '@usecannon/router@4.1.3': @@ -219,8 +219,8 @@ packages: peerDependencies: axios: 0.x || 1.x - axios@1.8.4: - resolution: {integrity: sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==} + axios@1.9.0: + resolution: {integrity: sha512-re4CqKTJaURpzbLHtIi6XpDv20/CnpXOtjRY5/CU32L8gU8ek9UIivcfvSWvmKEngmVbrUtPpdDwWDWL7DNHvg==} balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -234,11 +234,11 @@ packages: blakejs@1.2.1: resolution: {integrity: sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==} - bn.js@4.12.1: - resolution: {integrity: sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==} + bn.js@4.12.2: + resolution: {integrity: sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==} - bn.js@5.2.1: - resolution: {integrity: sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==} + bn.js@5.2.2: + resolution: {integrity: sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw==} brace-expansion@2.0.1: resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} @@ -295,8 +295,8 @@ packages: resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} engines: {node: '>= 8'} - debug@4.4.0: - resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} + debug@4.4.1: + resolution: {integrity: sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==} engines: {node: '>=6.0'} peerDependencies: supports-color: '*' @@ -416,8 +416,8 @@ packages: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} - glob@11.0.1: - resolution: {integrity: sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==} + glob@11.0.2: + resolution: {integrity: sha512-YT7U7Vye+t5fZ/QMkBFrTJ7ZQxInIUjwyAjVj84CYXqgBdv30MFUPGnBR6sQaVq6Is15wYJUsnzTuWaGRBhBAQ==} engines: {node: 20 || >=22} hasBin: true @@ -802,8 +802,8 @@ packages: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true - semver@7.7.1: - resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} + semver@7.7.2: + resolution: {integrity: sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==} engines: {node: '>=10'} hasBin: true @@ -915,8 +915,8 @@ packages: uint8arrays@3.1.1: resolution: {integrity: sha512-+QJa8QRnbdXVpHYjLoTpJIdCTiw9Ir62nocClWuXIq2JIh4Uta0cQsTSpFL678p2CN8B+XSApwcU+pQEqVpKWg==} - undici-types@6.20.0: - resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==} + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} universalify@2.0.1: resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} @@ -942,8 +942,8 @@ packages: varint@6.0.0: resolution: {integrity: sha512-cXEIW6cfr15lFv563k4GuVuW/fiwjknytD37jIOLSdSWuOI6WnO/oKwmP2FQTU2l01LP8/M5TSAJpzUaGe3uWg==} - viem@2.24.1: - resolution: {integrity: sha512-xptFlc081SIPz+ZNDeb0XS/Nn5PU28onq+im+UxEAPCXTIuL1kfw1GTnV8NhbUNoEONnrwcZNqoI0AT0ADF5XQ==} + viem@2.29.3: + resolution: {integrity: sha512-9D/nO+4S3Kk0P8vh6yXUA8OJ0mli9nzoY22qyh8iYHf1Q0GIejUnyq0QGjoDbkTcVzCVD5iA9KBkSxw9Tp3vUg==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: @@ -1008,8 +1008,8 @@ packages: peerDependencies: zod: ^3.13.2 - zod@3.24.2: - resolution: {integrity: sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==} + zod@3.24.4: + resolution: {integrity: sha512-OdqJE9UDRPwWsrHjLN2F8bPxvwJBK22EHLWtanu0LSYr5YqzsaaW3RMgmjwr8Rypg5k+meEJdSPXJZXE/yqOMg==} snapshots: @@ -1017,13 +1017,13 @@ snapshots: '@assemblyscript/loader@0.9.4': {} - '@babel/code-frame@7.26.2': + '@babel/code-frame@7.27.1': dependencies: - '@babel/helper-validator-identifier': 7.25.9 + '@babel/helper-validator-identifier': 7.27.1 js-tokens: 4.0.0 picocolors: 1.1.1 - '@babel/helper-validator-identifier@7.25.9': {} + '@babel/helper-validator-identifier@7.27.1': {} '@endo/env-options@1.1.8': {} @@ -1073,7 +1073,7 @@ snapshots: dependencies: '@ethersproject/bytes': 5.8.0 '@ethersproject/logger': 5.8.0 - bn.js: 5.2.1 + bn.js: 5.2.2 '@ethersproject/bytes@5.8.0': dependencies: @@ -1120,7 +1120,7 @@ snapshots: '@ethersproject/bytes': 5.8.0 '@ethersproject/logger': 5.8.0 '@ethersproject/properties': 5.8.0 - bn.js: 5.2.1 + bn.js: 5.2.2 elliptic: 6.6.1 hash.js: 1.1.7 @@ -1163,11 +1163,11 @@ snapshots: '@multiformats/base-x@4.0.1': {} - '@noble/curves@1.8.1': + '@noble/curves@1.8.2': dependencies: - '@noble/hashes': 1.7.1 + '@noble/hashes': 1.7.2 - '@noble/hashes@1.7.1': {} + '@noble/hashes@1.7.2': {} '@protobufjs/aspromise@1.1.2': {} @@ -1192,39 +1192,39 @@ snapshots: '@protobufjs/utf8@1.1.0': {} - '@scure/base@1.2.4': {} + '@scure/base@1.2.5': {} '@scure/bip32@1.6.2': dependencies: - '@noble/curves': 1.8.1 - '@noble/hashes': 1.7.1 - '@scure/base': 1.2.4 + '@noble/curves': 1.8.2 + '@noble/hashes': 1.7.2 + '@scure/base': 1.2.5 '@scure/bip39@1.5.4': dependencies: - '@noble/hashes': 1.7.1 - '@scure/base': 1.2.4 + '@noble/hashes': 1.7.2 + '@scure/base': 1.2.5 '@types/long@4.0.2': {} '@types/minimist@1.2.5': {} - '@types/node@22.13.14': + '@types/node@22.15.18': dependencies: - undici-types: 6.20.0 + undici-types: 6.21.0 '@types/normalize-package-data@2.4.4': {} - '@usecannon/builder@2.21.5': + '@usecannon/builder@2.22.0': dependencies: '@usecannon/router': 4.1.3 '@usecannon/web-solc': 0.5.1 acorn: 8.14.1 - axios: 1.8.4(debug@4.4.0) - axios-retry: 4.5.0(axios@1.8.4(debug@4.4.0)) + axios: 1.9.0(debug@4.4.1) + axios-retry: 4.5.0(axios@1.9.0(debug@4.4.1)) buffer: 6.0.3 chalk: 4.1.2 - debug: 4.4.0 + debug: 4.4.1 deep-freeze: 0.0.1 form-data: 4.0.2 fuse.js: 7.1.0 @@ -1234,8 +1234,8 @@ snapshots: rfdc: 1.4.1 ses: 1.12.0 typestub-ipfs-only-hash: 4.0.0 - viem: 2.24.1(zod@3.24.2) - zod: 3.24.2 + viem: 2.29.3(zod@3.24.4) + zod: 3.24.4 transitivePeerDependencies: - bufferutil - encoding @@ -1243,26 +1243,26 @@ snapshots: - typescript - utf-8-validate - '@usecannon/cli@2.21.5': + '@usecannon/cli@2.22.0': dependencies: '@iarna/toml': 3.0.0 - '@usecannon/builder': 2.21.5 - abitype: 1.0.8(zod@3.24.2) + '@usecannon/builder': 2.22.0 + abitype: 1.0.8(zod@3.24.4) chalk: 4.1.2 commander: 12.1.0 - debug: 4.4.0 + debug: 4.4.1 eth-provider: 0.13.7 fs-extra: 11.3.0 - glob: 11.0.1 + glob: 11.0.2 lodash: 4.17.21 prompts: 2.4.2 - semver: 7.7.1 + semver: 7.7.2 table: 6.9.0 tildify: 3.0.0 untildify: 4.0.0 - viem: 2.24.1(zod@3.24.2) - znv: 0.4.0(zod@3.24.2) - zod: 3.24.2 + viem: 2.29.3(zod@3.24.4) + znv: 0.4.0(zod@3.24.4) + zod: 3.24.4 transitivePeerDependencies: - bufferutil - encoding @@ -1274,16 +1274,16 @@ snapshots: dependencies: '@ethersproject/abi': 5.8.0 '@ethersproject/keccak256': 5.8.0 - debug: 4.4.0 + debug: 4.4.1 mustache: 4.2.0 transitivePeerDependencies: - supports-color '@usecannon/web-solc@0.5.1': {} - abitype@1.0.8(zod@3.24.2): + abitype@1.0.8(zod@3.24.4): optionalDependencies: - zod: 3.24.2 + zod: 3.24.4 acorn@8.14.1: {} @@ -1310,14 +1310,14 @@ snapshots: asynckit@0.4.0: {} - axios-retry@4.5.0(axios@1.8.4(debug@4.4.0)): + axios-retry@4.5.0(axios@1.9.0(debug@4.4.1)): dependencies: - axios: 1.8.4(debug@4.4.0) + axios: 1.9.0(debug@4.4.1) is-retry-allowed: 2.2.0 - axios@1.8.4(debug@4.4.0): + axios@1.9.0(debug@4.4.1): dependencies: - follow-redirects: 1.15.9(debug@4.4.0) + follow-redirects: 1.15.9(debug@4.4.1) form-data: 4.0.2 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -1335,9 +1335,9 @@ snapshots: blakejs@1.2.1: {} - bn.js@4.12.1: {} + bn.js@4.12.2: {} - bn.js@5.2.1: {} + bn.js@5.2.2: {} brace-expansion@2.0.1: dependencies: @@ -1397,7 +1397,7 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 - debug@4.4.0: + debug@4.4.1: dependencies: ms: 2.1.3 @@ -1422,7 +1422,7 @@ snapshots: elliptic@6.6.1: dependencies: - bn.js: 4.12.1 + bn.js: 4.12.2 brorand: 1.1.0 hash.js: 1.1.7 hmac-drbg: 1.0.1 @@ -1484,9 +1484,9 @@ snapshots: locate-path: 5.0.0 path-exists: 4.0.0 - follow-redirects@1.15.9(debug@4.4.0): + follow-redirects@1.15.9(debug@4.4.1): optionalDependencies: - debug: 4.4.0 + debug: 4.4.1 foreground-child@3.3.1: dependencies: @@ -1528,7 +1528,7 @@ snapshots: dunder-proto: 1.0.1 es-object-atoms: 1.1.1 - glob@11.0.1: + glob@11.0.2: dependencies: foreground-child: 3.3.1 jackspeak: 4.1.0 @@ -1802,21 +1802,21 @@ snapshots: dependencies: hosted-git-info: 4.1.0 is-core-module: 2.16.1 - semver: 7.7.1 + semver: 7.7.2 validate-npm-package-license: 3.0.4 oboe@2.1.5: dependencies: http-https: 1.0.0 - ox@0.6.9(zod@3.24.2): + ox@0.6.9(zod@3.24.4): dependencies: '@adraffy/ens-normalize': 1.11.0 - '@noble/curves': 1.8.1 - '@noble/hashes': 1.7.1 + '@noble/curves': 1.8.2 + '@noble/hashes': 1.7.2 '@scure/bip32': 1.6.2 '@scure/bip39': 1.5.4 - abitype: 1.0.8(zod@3.24.2) + abitype: 1.0.8(zod@3.24.4) eventemitter3: 5.0.1 transitivePeerDependencies: - zod @@ -1837,7 +1837,7 @@ snapshots: parse-json@5.2.0: dependencies: - '@babel/code-frame': 7.26.2 + '@babel/code-frame': 7.27.1 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -1875,7 +1875,7 @@ snapshots: '@protobufjs/pool': 1.1.0 '@protobufjs/utf8': 1.1.0 '@types/long': 4.0.2 - '@types/node': 22.13.14 + '@types/node': 22.15.18 long: 4.0.0 proxy-from-env@1.1.0: {} @@ -1886,7 +1886,7 @@ snapshots: dependencies: '@assemblyscript/loader': 0.9.4 bl: 5.1.0 - debug: 4.4.0 + debug: 4.4.1 minimist: 1.2.8 node-fetch: 2.7.0 readable-stream: 3.6.2 @@ -1932,7 +1932,7 @@ snapshots: semver@5.7.2: {} - semver@7.7.1: {} + semver@7.7.2: {} ses@1.12.0: dependencies: @@ -2041,7 +2041,7 @@ snapshots: dependencies: multiformats: 9.9.0 - undici-types@6.20.0: {} + undici-types@6.21.0: {} universalify@2.0.1: {} @@ -2060,15 +2060,15 @@ snapshots: varint@6.0.0: {} - viem@2.24.1(zod@3.24.2): + viem@2.29.3(zod@3.24.4): dependencies: - '@noble/curves': 1.8.1 - '@noble/hashes': 1.7.1 + '@noble/curves': 1.8.2 + '@noble/hashes': 1.7.2 '@scure/bip32': 1.6.2 '@scure/bip39': 1.5.4 - abitype: 1.0.8(zod@3.24.2) + abitype: 1.0.8(zod@3.24.4) isows: 1.0.6(ws@8.18.1) - ox: 0.6.9(zod@3.24.2) + ox: 0.6.9(zod@3.24.4) ws: 8.18.1 transitivePeerDependencies: - bufferutil @@ -2110,9 +2110,9 @@ snapshots: yargs-parser@20.2.9: {} - znv@0.4.0(zod@3.24.2): + znv@0.4.0(zod@3.24.4): dependencies: colorette: 2.0.20 - zod: 3.24.2 + zod: 3.24.4 - zod@3.24.2: {} + zod@3.24.4: {} diff --git a/prt/contracts/script/TopTournament.s.sol b/prt/contracts/script/TopTournament.s.sol deleted file mode 100644 index 048c586b..00000000 --- a/prt/contracts/script/TopTournament.s.sol +++ /dev/null @@ -1,36 +0,0 @@ -// (c) Cartesi and individual authors (see AUTHORS) -// SPDX-License-Identifier: Apache-2.0 (see LICENSE) - -pragma solidity ^0.8.17; - -import {Script} from "forge-std-1.9.6/src/Script.sol"; - -import {Machine} from "src/types/Machine.sol"; - -import "prt-contracts/tournament/factories/MultiLevelTournamentFactory.sol"; -import - "prt-contracts/arbitration-config/CanonicalTournamentParametersProvider.sol"; -import "prt-contracts/IDataProvider.sol"; -import "prt-contracts/state-transition/CmioStateTransition.sol"; -import "prt-contracts/state-transition/RiscVStateTransition.sol"; -import "prt-contracts/state-transition/CartesiStateTransition.sol"; - -contract TopTournamentScript is Script { - function run(Machine.Hash initialHash) external { - vm.startBroadcast(vm.envUint("PRIVATE_KEY")); - - MultiLevelTournamentFactory factory = new MultiLevelTournamentFactory( - new TopTournamentFactory(new TopTournament()), - new MiddleTournamentFactory(new MiddleTournament()), - new BottomTournamentFactory(new BottomTournament()), - new CanonicalTournamentParametersProvider(), - new CartesiStateTransition( - new RiscVStateTransition(), new CmioStateTransition() - ) - ); - - factory.instantiate(initialHash, IDataProvider(address(0x0))); - - vm.stopBroadcast(); - } -} diff --git a/prt/contracts/src/ITournamentFactory.sol b/prt/contracts/src/ITournamentFactory.sol index 553c38f3..6d4e0cc9 100644 --- a/prt/contracts/src/ITournamentFactory.sol +++ b/prt/contracts/src/ITournamentFactory.sol @@ -8,7 +8,7 @@ import "prt-contracts/tournament/abstracts/Tournament.sol"; import "prt-contracts/IDataProvider.sol"; interface ITournamentFactory { - event tournamentCreated(ITournament); + event tournamentCreated(ITournament tournament); function instantiate(Machine.Hash initialState, IDataProvider provider) external diff --git a/prt/tests/common/blockchain/utils.lua b/prt/tests/common/blockchain/utils.lua index 8b4024cd..92f30c2e 100644 --- a/prt/tests/common/blockchain/utils.lua +++ b/prt/tests/common/blockchain/utils.lua @@ -19,14 +19,4 @@ local function advance_time(blocks, endpoint) end end --- TODO remove this, since we're dumping/loading an "ready" anvil state. -local deploy_cmd = [[sh -c "cd %s && ./deploy_anvil.sh"]] -local function deploy_contracts(contracts_path) - local reader = io.popen(string.format(deploy_cmd, contracts_path)) - assert(reader, "Failed to open process for deploy command: " .. deploy_cmd) - local output = reader:read("*a") - local success = reader:close() - assert(success, string.format("Deploy command failed:\n%s", output)) -end - -return { advance_time = advance_time, deploy_contracts = deploy_contracts } +return { advance_time = advance_time } diff --git a/prt/tests/compute/justfile b/prt/tests/compute/justfile index b238e154..344f068a 100644 --- a/prt/tests/compute/justfile +++ b/prt/tests/compute/justfile @@ -2,8 +2,6 @@ DOOM_DIR := "./programs/doom" SIMPLE_DIR := "./programs/simple" STRESS_DIR := "./programs/stress" -# TODO each program should get its own, from its own dir. -ROOT_TOURNAMENT := `head -n 1 ./programs/simple/addresses` LUA_NODE := "false" # build compute test programs @@ -15,7 +13,7 @@ test MACH_PATH: rm -rf _state EXTRA_DATA="false" \ LUA_NODE={{LUA_NODE}} \ - ROOT_TOURNAMENT={{ROOT_TOURNAMENT}} \ + ROOT_TOURNAMENT=`head -n 1 -- {{MACH_PATH}}/addresses` \ MACHINE_PATH={{MACH_PATH}} \ lua prt_compute.lua diff --git a/prt/tests/compute/programs/build_anvil_state.sh b/prt/tests/compute/programs/build_anvil_state.sh index c76bfcc3..46bb05cd 100755 --- a/prt/tests/compute/programs/build_anvil_state.sh +++ b/prt/tests/compute/programs/build_anvil_state.sh @@ -4,6 +4,17 @@ program_path=$1 mkdir -p $program_path +# make sure anvil is cleaned up on exit or error +anvil_pid="" +cleanup() { + if [[ -n "$anvil_pid" ]] && kill -0 "$anvil_pid" 2>/dev/null; then + echo "Cleaning up anvil process (PID $anvil_pid)..." + kill -INT "$anvil_pid" + wait "$anvil_pid" || true + fi +} +trap cleanup EXIT + # start anvil with dump state rm -f $program_path/anvil_state.json anvil --preserve-historical-states --slots-in-an-epoch 1 \ @@ -13,20 +24,17 @@ sleep 5 # deploy smart contracts -initial_hash=`xxd -p -c32 "${program_path}/machine-image/hash"` +initial_hash=0x`xxd -p -c32 "${program_path}/machine-image/hash"` just -f ../../../contracts/justfile deploy-dev $initial_hash # generate address file rm -f $program_path/addresses -jq -r '.transactions[] | select(.transactionType=="CALL") | select(.contractName=="MultiLevelTournamentFactory") .additionalContracts[0].address' \ - ../../../contracts/broadcast/TopTournament.s.sol/31337/run-latest.json \ - >> $program_path/addresses +jq -r '.address' ../../../contracts/deployments/TopTournamentInstance.json >> $program_path/addresses cast rpc anvil_mine 2 # # kill anvil, thus dumping its state, to be loaded later by tests -kill -INT "$anvil_pid" -wait $anvil_pid +cleanup diff --git a/prt/tests/rollups/dave/node.lua b/prt/tests/rollups/dave/node.lua index c948f5cb..22196804 100644 --- a/prt/tests/rollups/dave/node.lua +++ b/prt/tests/rollups/dave/node.lua @@ -1,14 +1,13 @@ local helper = require "utils.helper" local ANVIL_KEY_7 = "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356" -local APP_ADDRESS = "0x0000000000000000000000000000000000000000" -local function start_dave_node(machine_path, db_path, sleep_duration, verbosity, trace_level) +local function start_dave_node(machine_path, app_address, db_path, sleep_duration, verbosity, trace_level) local cmd = string.format( [[echo $$ ; exec env MACHINE_PATH='%s' APP_ADDRESS='%s' STATE_DIR='%s' \ RUST_BACKTRACE='%s' RUST_LOG='info',cartesi_prt_core='%s',rollups_epoch_manager='%s' \ ../../../target/debug/cartesi-rollups-prt-node --sleep-duration-seconds %s pk --web3-private-key %s > dave.log 2>&1]], - machine_path, APP_ADDRESS, db_path, trace_level, verbosity, verbosity, sleep_duration, ANVIL_KEY_7 + machine_path, app_address, db_path, trace_level, verbosity, verbosity, sleep_duration, ANVIL_KEY_7 ) local reader = io.popen(cmd) @@ -30,11 +29,11 @@ end local Dave = {} Dave.__index = Dave -function Dave:new(machine_path, consensus, input_box, sleep_duration, verbosity, trace_level) +function Dave:new(machine_path, app_address, sleep_duration, verbosity, trace_level) local n = {} os.execute "rm -rf _state && mkdir _state" - local handle = start_dave_node(machine_path, "_state/", consensus, input_box, sleep_duration, verbosity, trace_level) + local handle = start_dave_node(machine_path, app_address, "_state/", sleep_duration, verbosity, trace_level) n._handle = handle diff --git a/prt/tests/rollups/justfile b/prt/tests/rollups/justfile index 46b6ade5..58e6e94e 100644 --- a/prt/tests/rollups/justfile +++ b/prt/tests/rollups/justfile @@ -1,10 +1,6 @@ ECHO_DIR := "../../../test/programs/echo" HONEYPOT_DIR := "../../../test/programs/honeypot" -# TODO each program should get its own, from its own dir. -APP := "0x0000000000000000000000000000000000000000" -INPUT_BOX := `head -n 1 ../../../test/programs/echo/addresses` -CONSENSUS := `head -n 2 ../../../test/programs/echo/addresses | tail -n 1` WEB3_PRIVATE_KEY := "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" MAX_EPOCH := "1" @@ -12,9 +8,9 @@ MAX_EPOCH := "1" test MACH_PATH: rm -rf _state WEB3_PRIVATE_KEY={{WEB3_PRIVATE_KEY}} \ - APP={{APP}} \ - CONSENSUS={{CONSENSUS}} \ - INPUT_BOX={{INPUT_BOX}} \ + INPUT_BOX=`sed '1q;d' {{MACH_PATH}}/addresses` \ + CONSENSUS=`sed '2q;d' {{MACH_PATH}}/addresses` \ + APP=`sed '3q;d' {{MACH_PATH}}/addresses` \ MACHINE_PATH={{MACH_PATH}} \ MAX_EPOCH={{MAX_EPOCH}} lua prt_rollups.lua && \ MAX_EPOCH={{MAX_EPOCH}} lua check_rollups_winner.lua diff --git a/prt/tests/rollups/prt_rollups.lua b/prt/tests/rollups/prt_rollups.lua index 549d6b00..4c5ce7ef 100755 --- a/prt/tests/rollups/prt_rollups.lua +++ b/prt/tests/rollups/prt_rollups.lua @@ -207,7 +207,7 @@ time.sleep(NODE_DELAY) local verbosity = os.getenv("VERBOSITY") or 'debug' -- 0, 1, full local trace_level = os.getenv("TRACE_LEVEL") or 'full' -local _dave_node = Dave:new(rollups_machine_path .. "/machine-image", SLEEP_TIME, verbosity, trace_level) +local _dave_node = Dave:new(rollups_machine_path .. "/machine-image", APP_ADDRESS, SLEEP_TIME, verbosity, trace_level) time.sleep(NODE_DELAY) local reader = Reader:new(blockchain_constants.endpoint) diff --git a/test/programs/build_anvil_state.sh b/test/programs/build_anvil_state.sh index 192bae85..2422d9ad 100755 --- a/test/programs/build_anvil_state.sh +++ b/test/programs/build_anvil_state.sh @@ -4,6 +4,17 @@ program_path=$1 mkdir -p $program_path +# make sure anvil is cleaned up on exit or error +anvil_pid="" +cleanup() { + if [[ -n "$anvil_pid" ]] && kill -0 "$anvil_pid" 2>/dev/null; then + echo "Cleaning up anvil process (PID $anvil_pid)..." + kill -INT "$anvil_pid" + wait "$anvil_pid" || true + fi +} +trap cleanup EXIT + # start anvil with dump state rm -f $program_path/anvil_state.json anvil --preserve-historical-states --slots-in-an-epoch 1 \ @@ -13,24 +24,19 @@ sleep 5 # deploy smart contracts -initial_hash=`xxd -p -c32 "${program_path}/machine-image/hash"` +initial_hash=0x`xxd -p -c32 "${program_path}/machine-image/hash"` just -f ../../cartesi-rollups/contracts/justfile deploy-dev $initial_hash # generate address file rm -f $program_path/addresses -jq -r '.transactions[] | select(.transactionType=="CREATE").contractAddress' \ - ../../cartesi-rollups/contracts/broadcast/InputBox.s.sol/31337/run-latest.json \ - >> $program_path/addresses - -jq -r '.transactions[] | select(.transactionType=="CREATE") | select(.contractName=="DaveConsensus") .contractAddress' \ - ../../cartesi-rollups/contracts/broadcast/DaveConsensus.s.sol/31337/run-latest.json \ - >> $program_path/addresses +jq -r '.address' ../../cartesi-rollups/contracts/deployments/InputBox.json >> $program_path/addresses +jq -r '.address' ../../cartesi-rollups/contracts/deployments/DaveConsensusInstance.json >> $program_path/addresses +jq -r '.address' ../../cartesi-rollups/contracts/deployments/ApplicationInstance.json >> $program_path/addresses cast rpc anvil_mine 2 # # kill anvil, thus dumping its state, to be loaded later by tests -kill -INT "$anvil_pid" -wait $anvil_pid +cleanup