8000 Build devnet with Cannon by guidanoli · Pull Request #164 · cartesi/dave · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Build devnet with Cannon #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/actions/setup-tools/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
11 changes: 11 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cartesi-rollups/contracts/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ docs/

# Gas snapshot
.gas-snapshot

# Cannon
/deployments
72 changes: 72 additions & 0 deletions cartesi-rollups/contracts/cannonfile.instance.toml
AE96
Original file line number Diff line number Diff line change
@@ -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 %>"
5 changes: 2 additions & 3 deletions cartesi-rollups/contracts/cannonfile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -16,5 +16,4 @@ args = [
]
create2 = true
salt = "<%= zeroHash %>"


ifExists = "continue"
35 changes: 0 additions & 35 deletions cartesi-rollups/contracts/deploy_anvil.sh

This file was deleted.

4 changes: 2 additions & 2 deletions cartesi-rollups/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand All @@ -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"
41 changes: 23 additions & 18 deletions cartesi-rollups/contracts/justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Variables
BINDINGS_DIR := "./bindings-rs/src/contract"
DEPLOYMENTS_DIR := "./deployments"
SRC_DIR := "."
BINDINGS_FILTER := "DaveConsensus"

Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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}}
2 changes: 1 addition & 1 deletion cartesi-rollups/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"license": "Apache-2.0",
"packageManager": "pnpm@10.7.0",
"dependencies": {
"@usecannon/cli": "^2.21.5"
"@usecannon/cli": "^2.22.0"
}
}
Loading
0