Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ machine-snapshot/**
/cartesi-rollups-claimer
/cartesi-rollups-jsonrpc-api
/cartesi-rollups-prt
/cartesi-rollups-machine-tool
/rollups-contracts
/rollups-prt-contracts
/applications
Expand Down
84 changes: 72 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ TARGET_OS?=$(shell uname)
export TARGET_OS

ROLLUPS_NODE_VERSION := 2.0.0-alpha.11
ROLLUPS_CONTRACTS_VERSION := 2.2.0
ROLLUPS_CONTRACTS_VERSION := 3.0.0-alpha.6
ROLLUPS_CONTRACTS_URL:=https://github.com/cartesi/rollups-contracts/releases/download/
ROLLUPS_CONTRACTS_ARTIFACT:=rollups-contracts-$(ROLLUPS_CONTRACTS_VERSION)-artifacts.tar.gz
ROLLUPS_CONTRACTS_SHA256:=31c20a8c50f794185957ebd6e554fc99c8e01f0fdf9a80628d031fb0edc7091d
ROLLUPS_PRT_CONTRACTS_VERSION := 2.1.1
ROLLUPS_CONTRACTS_SHA256:=ad1e0880766d25419fc6da1858ea4e7b9074b400e9d9ef68da88b12f4a8bba45
ROLLUPS_PRT_CONTRACTS_VERSION := 3.0.0-alpha.3
ROLLUPS_PRT_CONTRACTS_URL:=https://github.com/cartesi/dave/releases/download/
ROLLUPS_PRT_CONTRACTS_ARTIFACT:=cartesi-rollups-prt-$(ROLLUPS_PRT_CONTRACTS_VERSION)-contract-artifacts.tar.gz
ROLLUPS_PRT_CONTRACTS_SHA256:=830815bcd858a67b73738c6747030960d88ed1e2e0b123086f2112b1ff47f7c9
ROLLUPS_PRT_CONTRACTS_SHA256:=240f4934df7a313dc05a4ae6cc3eee97b5c146952c4218502fec0db83f36a5a5

IMAGE_TAG ?= devel

Expand Down Expand Up @@ -59,7 +59,7 @@ DOCKER_PLATFORM=--platform $(BUILD_PLATFORM)
endif

# Go artifacts
GO_ARTIFACTS := $(addprefix cartesi-rollups-,node cli evm-reader advancer validator claimer jsonrpc-api prt)
GO_ARTIFACTS := $(addprefix cartesi-rollups-,node cli evm-reader advancer validator claimer jsonrpc-api prt machine-tool)

# fixme(vfusco): path on all oses
CGO_CFLAGS:= -I$(PREFIX)/include
Expand Down Expand Up @@ -123,11 +123,15 @@ env:
@echo export CARTESI_BLOCKCHAIN_HTTP_ENDPOINT="http://localhost:8545"
@echo export CARTESI_BLOCKCHAIN_WS_ENDPOINT="ws://localhost:8545"
@echo export CARTESI_BLOCKCHAIN_ID="31337"
@echo export CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="0x1b51e2992A2755Ba4D6F7094032DF91991a0Cfac"
@echo export CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS="0x5E96408CFE423b01dADeD3bc867E6013135990cc"
@echo export CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS="0x26E758238CB6eC5aB70ce0dd52aF2d7b82e1972E"
@echo export CARTESI_CONTRACTS_SELF_HOSTED_APPLICATION_FACTORY_ADDRESS="0x010D3CbB4223F5bCc7b7B03cEE59f3aAea8eDb8A"
@echo export CARTESI_CONTRACTS_DAVE_APP_FACTORY_ADDRESS="0xfC2DBC639b5FB9AfE66A8696eC14EaD9FbFBC404"
@echo export CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="0x346B3df038FE9f8380071eC6514D5a83aD143939"
@echo export CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS="0x3C1FE01c542a88A523FF6847eD1E26176c8C4ED0"
@echo export CARTESI_CONTRACTS_QUORUM_FACTORY_ADDRESS="0x1f94009389F408B8D0ADfFcF8BBDCe5552BaCa5F"
@echo export CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS="0xC549F89cF1ca43eDDECC64Ac2208F4b283B1c483"
@echo export CARTESI_CONTRACTS_SELF_HOSTED_APPLICATION_FACTORY_ADDRESS="0x6145C5996a71a379E030aEb0440df79D60833418"
@echo export CARTESI_CONTRACTS_DAVE_APP_FACTORY_ADDRESS="0x33FFf0b681c90664dD048a60400AE2D827a4c5bb"
@echo export CARTESI_DEVNET_ERC20_PORTAL_ADDRESS="0x22E57511C30CcE6CDaa742E13CE3b774fDC663b1"
@echo export CARTESI_DEVNET_TEST_ERC20_ADDRESS="0x88A2120B7068E78692C8fd12E751d610B6377E4d"
@echo export CARTESI_DEVNET_WITHDRAWAL_OUTPUT_BUILDER_ADDRESS="0x0745787835A019cd4dae8EDB541Fbc0647793d63"
@echo export CARTESI_AUTH_MNEMONIC=\"test test test test test test test test test test test junk\"
@echo export CARTESI_DATABASE_CONNECTION="postgres://postgres:password@localhost:5432/rollupsdb?sslmode=disable"
@echo export CARTESI_SNAPSHOTS_DIR="snapshots"
Expand Down Expand Up @@ -293,6 +297,8 @@ reject-loop-dapp: applications/reject-loop-dapp ## Reject loop dapp

exception-loop-dapp: applications/exception-loop-dapp ## Exception loop dapp

erc20-withdrawal-dapp: applications/erc20-withdrawal-dapp ## ERC-20 withdrawal test dapp

applications/reject-loop-dapp: ## Create reject-loop-dapp test application
@echo "Creating reject-loop-dapp test application"
@mkdir -p applications
Expand All @@ -303,6 +309,18 @@ applications/exception-loop-dapp: ## Create exception-loop-dapp test application
@mkdir -p applications
@cartesi-machine --ram-length=128Mi --store=applications/exception-loop-dapp --final-hash -- ioctl-echo-loop --vouchers=1 --notices=1 --reports=1 --exception=1 --verbose=1

applications/erc20-withdrawal-dapp: test/dapps/erc20-withdrawal/install.sh ## Create ERC-20 withdrawal test application
@echo "Creating ERC-20 withdrawal test application"
@mkdir -p applications
@PORTAL=$${CARTESI_DEVNET_ERC20_PORTAL_ADDRESS:-0x22E57511C30CcE6CDaa742E13CE3b774fDC663b1}; \
TOKEN=$${CARTESI_DEVNET_TEST_ERC20_ADDRESS:-0x88A2120B7068E78692C8fd12E751d610B6377E4d}; \
cartesi-machine --ram-length=128Mi \
--flash-drive=label:accounts,length:4Mi,mke2fs:false,mount:false,user:dapp \
--env=TRUSTED_ERC20_PORTAL=$$PORTAL \
--env=TRUSTED_ERC20_TOKEN=$$TOKEN \
--append-init-file=test/dapps/erc20-withdrawal/install.sh \
--store=applications/erc20-withdrawal-dapp --final-hash -- /usr/local/bin/erc20-withdrawal-dapp

deploy-echo-dapp: applications/echo-dapp ## Deploy echo-dapp test application
@echo "Deploying echo-dapp test application"
@./cartesi-rollups-cli deploy application echo-dapp applications/echo-dapp/
Expand All @@ -319,6 +337,46 @@ deploy-prt-echo-dapp: applications/echo-dapp ## Deploy echo-dapp test applicatio
@echo "Deploying echo-dapp test application"
@./cartesi-rollups-cli deploy application prt-echo-dapp applications/echo-dapp/ --prt

deploy-erc20-withdrawal-dapp: applications/erc20-withdrawal-dapp ## Deploy ERC-20 withdrawal test application
@set -e; \
APP=$${APP:-erc20-withdrawal-dapp}; \
GUARDIAN=$${GUARDIAN:-0x70997970C51812dc3A010C7d01b50e0d17dc79C8}; \
BUILDER=$${CARTESI_DEVNET_WITHDRAWAL_OUTPUT_BUILDER_ADDRESS:-0x0745787835A019cd4dae8EDB541Fbc0647793d63}; \
DRIVE_START_INDEX=$$(jq -r '.config.flash_drive[] | select(.length == 4194304) | (.start / 4194304 | floor)' \
applications/erc20-withdrawal-dapp/config.json); \
WITHDRAWAL_CONFIG=$$(jq -cn \
--arg guardian "$$GUARDIAN" \
--arg builder "$$BUILDER" \
--argjson drive "$$DRIVE_START_INDEX" \
'{guardian:$$guardian,log2_leaves_per_account:0,log2_max_num_of_accounts:17,accounts_drive_start_index:$$drive,withdrawal_output_builder:$$builder}'); \
echo "Deploying $$APP with accounts-drive start index $$DRIVE_START_INDEX"; \
./cartesi-rollups-cli deploy application "$$APP" applications/erc20-withdrawal-dapp \
--salt "$$(openssl rand -hex 32)" \
--withdrawal-config "$$WITHDRAWAL_CONFIG" \
--enable=false; \
./cartesi-rollups-cli app execution-parameters set "$$APP" snapshot_policy EVERY_EPOCH; \
./cartesi-rollups-cli app status "$$APP" enabled --yes

fund-wallet: ## Fund the default Anvil wallet with ETH and test ERC-20
@set -e; \
RPC_URL=$${CARTESI_BLOCKCHAIN_HTTP_ENDPOINT:-http://localhost:8545}; \
TOKEN=$${CARTESI_DEVNET_TEST_ERC20_ADDRESS:-0x88A2120B7068E78692C8fd12E751d610B6377E4d}; \
WALLET=$${WALLET:-$$(cast rpc --rpc-url "$$RPC_URL" eth_accounts | jq -r '.[0]')}; \
ETH_WEI=$${ETH_WEI:-0x8ac7230489e80000}; \
TOKEN_AMOUNT=$${TOKEN_AMOUNT:-1000000}; \
echo "Funding $$WALLET with $$ETH_WEI wei"; \
cast rpc --rpc-url "$$RPC_URL" anvil_setBalance "$$WALLET" "$$ETH_WEI" >/dev/null; \
echo "Minting $$TOKEN_AMOUNT test ERC-20 units to $$WALLET"; \
cast send --rpc-url "$$RPC_URL" --from "$$WALLET" --unlocked "$$TOKEN" "mint(uint256)" "$$TOKEN_AMOUNT" >/dev/null

withdraw-wallet: cartesi-rollups-cli ## Send a test withdrawal request from the current signer
@set -e; \
APP=$${APP:-erc20-withdrawal-dapp}; \
AMOUNT=$${AMOUNT:-25}; \
PAYLOAD=$$(printf '0x01%016x' "$$AMOUNT"); \
echo "Sending withdrawal request to $$APP: amount=$$AMOUNT payload=$$PAYLOAD"; \
./cartesi-rollups-cli send "$$APP" "$$PAYLOAD" --hex --yes --json

# Temporary test dependencies target while we are not using distribution packages
DOWNLOADS_DIR = test/downloads
CARTESI_TEST_MACHINE_IMAGES = $(DOWNLOADS_DIR)/linux.bin
Expand Down Expand Up @@ -447,7 +505,7 @@ test-with-compose: ## Run all tests using docker compose with auto-shutdown
@$(MAKE) unit-test-with-compose
@$(MAKE) integration-test-with-compose

integration-test-local: build echo-dapp reject-loop-dapp exception-loop-dapp ## Run integration tests locally (requires: make start && eval $$(make env))
integration-test-local: build cartesi-rollups-machine-tool echo-dapp reject-loop-dapp exception-loop-dapp erc20-withdrawal-dapp ## Run integration tests locally (requires: make start && eval $$(make env))
@cartesi-rollups-cli db init
@if lsof -ti:10000 >/dev/null 2>&1; then \
echo "Killing stale node on port 10000..."; \
Expand All @@ -457,6 +515,7 @@ integration-test-local: build echo-dapp reject-loop-dapp exception-loop-dapp ##
@export CARTESI_TEST_DAPP_PATH=$(CURDIR)/applications/echo-dapp; \
export CARTESI_TEST_REJECT_DAPP_PATH=$(CURDIR)/applications/reject-loop-dapp; \
export CARTESI_TEST_EXCEPTION_DAPP_PATH=$(CURDIR)/applications/exception-loop-dapp; \
export CARTESI_TEST_ERC20_WITHDRAWAL_DAPP_PATH=$(CURDIR)/applications/erc20-withdrawal-dapp; \
$(MAKE) integration-test

deploy-load-test-apps: applications/echo-dapp ## Deploy 3 echo-dapp instances for load testing
Expand Down Expand Up @@ -514,7 +573,7 @@ build-debian-package: install
dpkg-deb -Zxz --root-owner-group --build $(DESTDIR) $(DEB_FILENAME)

.PHONY: \
build build-go $(GO_ARTIFACTS) \
build build-go $(GO_ARTIFACTS) cartesi-rollups-machine-tool \
clean clean-go clean-contracts clean-docs clean-devnet-files clean-dapps clean-test-dependencies clean-debian-packages \
test unit-test unit-test-with-compose integration-test integration-test-with-compose integration-test-local test-with-compose ci-test coverage-report \
generate generate-contracts generate-config generate-inspect check-generate generate-db \
Expand All @@ -523,4 +582,5 @@ build-debian-package: install
devnet image tester-image debian-packager run-with-compose shutdown-compose \
start start-devnet start-postgres stop stop-devnet stop-postgres restart restart-devnet restart-postgres \
install copy-debian-package build-debian-package \
deploy-erc20-withdrawal-dapp fund-wallet withdraw-wallet \
env help version
18 changes: 14 additions & 4 deletions api/openapi/inspect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,24 @@ paths:

"503":
description: |
The application is registered but its Cartesi Machine instance
has not been initialized yet. If the application is in the
enabled state, the machine will be available once the advancer
service completes initialization.
The inspect request cannot be served right now.
This can happen when the application is registered but its
Cartesi Machine instance has not been initialized yet, when the
application has been foreclosed and its machine is no longer
available for live inspect requests, or when the application's
inspect capacity is exhausted.
content:
text/plain:
schema:
$ref: "#/components/schemas/Error"
examples:
machineNotReady:
value: Machine not ready
foreclosed:
value: Application was foreclosed; machine unavailable
atCapacity:
value: Application inspect at capacity

default:
description: Error response.
Expand Down
Loading
Loading