From 60b03766f649d084588a152415f2c53dc6c3db6d Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Tue, 23 Jul 2024 15:59:46 -0300 Subject: [PATCH 1/6] feat(cli): delete GENESIS_BLOCK_31337 (new anvil version fix) --- .changeset/sixty-pants-share.md | 5 +++++ apps/cli/src/node/docker-compose-explorer.yaml | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 .changeset/sixty-pants-share.md diff --git a/.changeset/sixty-pants-share.md b/.changeset/sixty-pants-share.md new file mode 100644 index 00000000..9c676397 --- /dev/null +++ b/.changeset/sixty-pants-share.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": patch +--- + +remove workaround of anvil bug diff --git a/apps/cli/src/node/docker-compose-explorer.yaml b/apps/cli/src/node/docker-compose-explorer.yaml index 25d15c63..551dc793 100644 --- a/apps/cli/src/node/docker-compose-explorer.yaml +++ b/apps/cli/src/node/docker-compose-explorer.yaml @@ -30,7 +30,6 @@ services: CHAIN_ID: ${CHAIN_ID:-31337} RPC_URL_31337: ${RPC_URL:-http://anvil:8545} BLOCK_CONFIRMATIONS_31337: 0 - GENESIS_BLOCK_31337: 22 DB_NAME: ${PGDATABASE:-squid} DB_PORT: ${PGPORT:-5432} DB_HOST: ${PGHOST:-database} From d63d38314e9daa8a05147237e0e0f6dcd2cc8375 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Tue, 23 Jul 2024 15:59:01 -0300 Subject: [PATCH 2/6] feat(cli): account abstraction services (bundler and paymaster) --- .changeset/tasty-hornets-brush.md | 5 ++ apps/cli/src/commands/run.ts | 3 + apps/cli/src/commands/shell.ts | 2 +- apps/cli/src/node/docker-compose-aa.yaml | 84 +++++++++++++++++++ apps/cli/src/node/docker-compose-anvil.yaml | 4 +- .../docker-compose.yaml | 4 +- 6 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 .changeset/tasty-hornets-brush.md create mode 100644 apps/cli/src/node/docker-compose-aa.yaml diff --git a/.changeset/tasty-hornets-brush.md b/.changeset/tasty-hornets-brush.md new file mode 100644 index 00000000..d09f6284 --- /dev/null +++ b/.changeset/tasty-hornets-brush.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": minor +--- + +account abstraction services (bundler and paymaster) diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index 1b89ef73..4ea2fabc 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -101,6 +101,9 @@ export default class Run extends BaseCommand { // explorer composeFiles.push("docker-compose-explorer.yaml"); + // account abstraction + composeFiles.push("docker-compose-aa.yaml"); + // load the no-backend compose file if (flags["no-backend"]) { composeFiles.push("docker-compose-host.yaml"); diff --git a/apps/cli/src/commands/shell.ts b/apps/cli/src/commands/shell.ts index 7a703966..3c8a928b 100644 --- a/apps/cli/src/commands/shell.ts +++ b/apps/cli/src/commands/shell.ts @@ -33,7 +33,7 @@ export default class Shell extends BaseCommand { const ext2 = path.join(containerDir, path.basename(ext2Path)); const ramSize = "128Mi"; const driveLabel = "root"; - const sdkImage = "cartesi/sdk:0.9.0"; // XXX: how to resolve sdk version? + const sdkImage = "cartesi/sdk:0.10.0"; // XXX: how to resolve sdk version? const args = [ "run", "--interactive", diff --git a/apps/cli/src/node/docker-compose-aa.yaml b/apps/cli/src/node/docker-compose-aa.yaml new file mode 100644 index 00000000..7b9465ff --- /dev/null +++ b/apps/cli/src/node/docker-compose-aa.yaml @@ -0,0 +1,84 @@ +services: + alto: + image: cartesi/sdk:0.10.0 + command: + - "alto" + - "--entrypoints" + - "0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789,0x0000000071727De22E5E9d8BAf0edAc6f37da032" + - "--log-level" + - "info" + - "--entrypoint-simulation-contract" + - "0x74Cb5e4eE81b86e70f9045036a1C5477de69eE87" + - "--rpc-url" + - "http://anvil:8545" + - "--min-executor-balance" + - "0" + - "--utility-private-key" + - "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97" + - "--executor-private-keys" + - "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6,0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356,0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e,0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba,0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a" + - "--max-block-range" + - "10000" + - "--safe-mode" + - "false" + - "--port" + - "4337" + - "--public-client-log-level" + - "error" + - "--wallet-client-log-level" + - "error" + - "--polling-interval" + - "100" + - "--enable-debug-endpoints" + + mock-verifying-paymaster: + image: cartesi/sdk:0.10.0 + command: "mock-verifying-paymaster" + environment: + - ALTO_RPC=http://alto:4337 + - ANVIL_RPC=http://anvil:8545 + + prompt: + image: debian:bookworm-slim + environment: + PROMPT_TXT_06_PAYMASTER: "Paymaster running at http://localhost:${CARTESI_LISTEN_PORT}/paymaster/" + PROMPT_TXT_07_BUNDLER: "Bundler running at http://localhost:${CARTESI_LISTEN_PORT}/bundler/" + + traefik-config-generator: + environment: + TRAEFIK_CONFIG_PAYMASTER: | + http: + routers: + paymaster: + rule: "PathPrefix(`/paymaster`)" + middlewares: + - "remove-paymaster-prefix" + service: paymaster + middlewares: + remove-paymaster-prefix: + replacePathRegex: + regex: "^/paymaster/(.*)" + replacement: "/$1" + services: + paymaster: + loadBalancer: + servers: + - url: "http://mock-verifying-paymaster:3000" + TRAEFIK_CONFIG_BUNDLER: | + http: + routers: + bundler: + rule: "PathPrefix(`/bundler`)" + middlewares: + - "remove-bundler-prefix" + service: bundler + middlewares: + remove-bundler-prefix: + replacePathRegex: + regex: "^/bundler/(.*)" + replacement: "/$1" + services: + bundler: + loadBalancer: + servers: + - url: "http://alto:4337" diff --git a/apps/cli/src/node/docker-compose-anvil.yaml b/apps/cli/src/node/docker-compose-anvil.yaml index 02c0d783..8b507aa8 100644 --- a/apps/cli/src/node/docker-compose-anvil.yaml +++ b/apps/cli/src/node/docker-compose-anvil.yaml @@ -1,6 +1,6 @@ services: anvil: - image: cartesi/sdk:0.9.0 + image: cartesi/sdk:0.10.0 command: [ "devnet", @@ -19,7 +19,7 @@ services: - 8545:8545 dapp_deployer: - image: cartesi/sdk:0.9.0 + image: cartesi/sdk:0.10.0 restart: on-failure depends_on: anvil: diff --git a/packages/mock-verifying-paymaster/docker-compose.yaml b/packages/mock-verifying-paymaster/docker-compose.yaml index 0e6656bd..e38bfa1e 100644 --- a/packages/mock-verifying-paymaster/docker-compose.yaml +++ b/packages/mock-verifying-paymaster/docker-compose.yaml @@ -1,6 +1,6 @@ services: anvil: - image: cartesi/sdk:0.9.0 + image: cartesi/sdk:0.10.0 command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"] healthcheck: test: ["CMD", "eth_isready"] @@ -13,7 +13,7 @@ services: - 8545:8545 alto: - image: cartesi/sdk:0.9.0 + image: cartesi/sdk:0.10.0 command: [ "alto", From b5beae125d659fc4de93b3d74b28e4b3ff501c9f Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Tue, 30 Jul 2024 15:54:39 -0300 Subject: [PATCH 3/6] feat(cli): account abstraction contracts information --- .changeset/neat-frogs-cover.md | 5 +++++ apps/cli/src/baseCommand.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .changeset/neat-frogs-cover.md diff --git a/.changeset/neat-frogs-cover.md b/.changeset/neat-frogs-cover.md new file mode 100644 index 00000000..15cf3216 --- /dev/null +++ b/.changeset/neat-frogs-cover.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": minor +--- + +account abstraction contracts information diff --git a/apps/cli/src/baseCommand.ts b/apps/cli/src/baseCommand.ts index 3ec26f18..10faebdb 100644 --- a/apps/cli/src/baseCommand.ts +++ b/apps/cli/src/baseCommand.ts @@ -88,16 +88,26 @@ export abstract class BaseCommand extends Command { AuthorityHistoryPairFactory: authorityHistoryPairFactoryAddress, CartesiDAppFactory: cartesiDAppFactoryAddress, DAppAddressRelay: dAppAddressRelayAddress, + EntryPointV06: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789", + EntryPointV07: "0x0000000071727De22E5E9d8BAf0edAc6f37da032", ERC1155BatchPortal: erc1155BatchPortalAddress, ERC1155SinglePortal: erc1155SinglePortalAddress, ERC20Portal: erc20PortalAddress, ERC721Portal: erc721PortalAddress, EtherPortal: etherPortalAddress, InputBox: inputBoxAddress, + LightAccountFactory: "0x00004EC70002a32400f8ae005A26081065620D20", SelfHostedApplicationFactory: selfHostedApplicationFactoryAddress, + SimpleAccountFactory: "0x9406Cc6185a346906296840746125a0E44976454", + SmartAccountFactory: "0x000000a56Aaca3e9a4C479ea6b6CD0DbcB6634F5", + KernelFactoryV2: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3", + KernelFactoryV3: "0x6723b44Abeec4E71eBE3232BD5B455805baDD22f", + KernelFactoryV3_1: "0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419", TestToken: testTokenAddress, TestNFT: testNftAddress, TestMultiToken: testMultiTokenAddress, + VerifyingPaymasterV06: "0x28ec0633192d0cBd9E1156CE05D5FdACAcB93947", + VerifyingPaymasterV07: "0xc5c97885C67F7361aBAfD2B95067a5bBdA603608", }; // get dapp address From 052bcf1bec2b7afb06ba17a9b0800d92352604ca Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Mon, 5 Aug 2024 22:37:48 -0300 Subject: [PATCH 4/6] feat(cli): flags to disable optional services (explorer, bundler, paymaster) --- .changeset/curvy-cougars-allow.md | 5 +++ apps/cli/src/commands/run.ts | 30 +++++++++++++++-- ...se-aa.yaml => docker-compose-bundler.yaml} | 29 +--------------- .../cli/src/node/docker-compose-database.yaml | 5 --- .../cli/src/node/docker-compose-explorer.yaml | 3 ++ .../src/node/docker-compose-paymaster.yaml | 33 +++++++++++++++++++ 6 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 .changeset/curvy-cougars-allow.md rename apps/cli/src/node/{docker-compose-aa.yaml => docker-compose-bundler.yaml} (64%) create mode 100644 apps/cli/src/node/docker-compose-paymaster.yaml diff --git a/.changeset/curvy-cougars-allow.md b/.changeset/curvy-cougars-allow.md new file mode 100644 index 00000000..2c12b7ed --- /dev/null +++ b/.changeset/curvy-cougars-allow.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": minor +--- + +flags to disable optional services (explorer, bundler, paymaster) diff --git a/apps/cli/src/commands/run.ts b/apps/cli/src/commands/run.ts index 4ea2fabc..f3364147 100644 --- a/apps/cli/src/commands/run.ts +++ b/apps/cli/src/commands/run.ts @@ -17,6 +17,24 @@ export default class Run extends BaseCommand { description: "interval between blocks (in seconds)", default: 5, }), + "disable-explorer": Flags.boolean({ + default: false, + description: + "disable local explorer service to save machine resources", + summary: "disable explorer service", + }), + "disable-bundler": Flags.boolean({ + default: false, + description: + "disable local bundler service to save machine resources", + summary: "disable bundler service", + }), + "disable-paymaster": Flags.boolean({ + default: false, + description: + "disable local paymaster service to save machine resources", + summary: "disable paymaster service", + }), "epoch-length": Flags.integer({ description: "length of an epoch (in blocks)", default: 720, @@ -99,10 +117,18 @@ export default class Run extends BaseCommand { composeFiles.push("docker-compose-anvil.yaml"); // explorer - composeFiles.push("docker-compose-explorer.yaml"); + if (!flags["disable-explorer"]) { + composeFiles.push("docker-compose-explorer.yaml"); + } // account abstraction - composeFiles.push("docker-compose-aa.yaml"); + if (!flags["disable-bundler"]) { + composeFiles.push("docker-compose-bundler.yaml"); + } + if (!flags["disable-paymaster"] && !flags["disable-bundler"]) { + // only add paymaster if bundler is enabled + composeFiles.push("docker-compose-paymaster.yaml"); + } // load the no-backend compose file if (flags["no-backend"]) { diff --git a/apps/cli/src/node/docker-compose-aa.yaml b/apps/cli/src/node/docker-compose-bundler.yaml similarity index 64% rename from apps/cli/src/node/docker-compose-aa.yaml rename to apps/cli/src/node/docker-compose-bundler.yaml index 7b9465ff..3295d207 100644 --- a/apps/cli/src/node/docker-compose-aa.yaml +++ b/apps/cli/src/node/docker-compose-bundler.yaml @@ -30,40 +30,13 @@ services: - "--polling-interval" - "100" - "--enable-debug-endpoints" - - mock-verifying-paymaster: - image: cartesi/sdk:0.10.0 - command: "mock-verifying-paymaster" - environment: - - ALTO_RPC=http://alto:4337 - - ANVIL_RPC=http://anvil:8545 - prompt: image: debian:bookworm-slim environment: - PROMPT_TXT_06_PAYMASTER: "Paymaster running at http://localhost:${CARTESI_LISTEN_PORT}/paymaster/" - PROMPT_TXT_07_BUNDLER: "Bundler running at http://localhost:${CARTESI_LISTEN_PORT}/bundler/" + PROMPT_TXT_06_BUNDLER: "Bundler running at http://localhost:${CARTESI_LISTEN_PORT}/bundler/rpc" traefik-config-generator: environment: - TRAEFIK_CONFIG_PAYMASTER: | - http: - routers: - paymaster: - rule: "PathPrefix(`/paymaster`)" - middlewares: - - "remove-paymaster-prefix" - service: paymaster - middlewares: - remove-paymaster-prefix: - replacePathRegex: - regex: "^/paymaster/(.*)" - replacement: "/$1" - services: - paymaster: - loadBalancer: - servers: - - url: "http://mock-verifying-paymaster:3000" TRAEFIK_CONFIG_BUNDLER: | http: routers: diff --git a/apps/cli/src/node/docker-compose-database.yaml b/apps/cli/src/node/docker-compose-database.yaml index 0b8bc704..fb661ab1 100644 --- a/apps/cli/src/node/docker-compose-database.yaml +++ b/apps/cli/src/node/docker-compose-database.yaml @@ -8,8 +8,3 @@ services: retries: 5 environment: - POSTGRES_PASSWORD=password - - database_creator: - depends_on: - database: - condition: service_healthy diff --git a/apps/cli/src/node/docker-compose-explorer.yaml b/apps/cli/src/node/docker-compose-explorer.yaml index 551dc793..f73b2fb2 100644 --- a/apps/cli/src/node/docker-compose-explorer.yaml +++ b/apps/cli/src/node/docker-compose-explorer.yaml @@ -2,6 +2,9 @@ services: database_creator: image: postgres:15-alpine command: ["createdb", "squid"] + depends_on: + database: + condition: service_healthy environment: PGHOST: ${PGHOST:-database} PGPORT: ${PGPORT:-5432} diff --git a/apps/cli/src/node/docker-compose-paymaster.yaml b/apps/cli/src/node/docker-compose-paymaster.yaml new file mode 100644 index 00000000..6829ed3a --- /dev/null +++ b/apps/cli/src/node/docker-compose-paymaster.yaml @@ -0,0 +1,33 @@ +services: + mock-verifying-paymaster: + image: cartesi/sdk:0.10.0 + command: "mock-verifying-paymaster" + environment: + - ALTO_RPC=http://alto:4337 + - ANVIL_RPC=http://anvil:8545 + + prompt: + image: debian:bookworm-slim + environment: + PROMPT_TXT_07_PAYMASTER: "Paymaster running at http://localhost:${CARTESI_LISTEN_PORT}/paymaster/" + + traefik-config-generator: + environment: + TRAEFIK_CONFIG_PAYMASTER: | + http: + routers: + paymaster: + rule: "PathPrefix(`/paymaster`)" + middlewares: + - "remove-paymaster-prefix" + service: paymaster + middlewares: + remove-paymaster-prefix: + replacePathRegex: + regex: "^/paymaster/(.*)" + replacement: "/$1" + services: + paymaster: + loadBalancer: + servers: + - url: "http://mock-verifying-paymaster:3000" From f55ae37e5fbf29a96abb347d9fb59c3e6a6cf85e Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Tue, 6 Aug 2024 13:42:56 -0300 Subject: [PATCH 5/6] feat(paymaster): printing contract address on startup --- .changeset/witty-lemons-decide.md | 5 +++++ packages/mock-verifying-paymaster/src/index.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/witty-lemons-decide.md diff --git a/.changeset/witty-lemons-decide.md b/.changeset/witty-lemons-decide.md new file mode 100644 index 00000000..d309665d --- /dev/null +++ b/.changeset/witty-lemons-decide.md @@ -0,0 +1,5 @@ +--- +"@cartesi/mock-verifying-paymaster": patch +--- + +printing contract address on startup diff --git a/packages/mock-verifying-paymaster/src/index.ts b/packages/mock-verifying-paymaster/src/index.ts index e1c781d1..2e4049a5 100644 --- a/packages/mock-verifying-paymaster/src/index.ts +++ b/packages/mock-verifying-paymaster/src/index.ts @@ -50,7 +50,9 @@ const main = async () => { return reply.code(200).send({ message: "pong" }); }); - const service = await app.listen({ host: "0.0.0.0", port: 3000 }); + const service = await app.listen({ host: "0.0.0.0", port: 3001 }); + console.log(`VerifyingPaymasterV06: ${verifyingPaymasterV06.address}`); + console.log(`VerifyingPaymasterV07: ${verifyingPaymasterV07.address}`); console.log(`Service ready: ${service}`); }; From 34b251ce7728398f499351c365851d38cee60deb Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Tue, 6 Aug 2024 13:43:45 -0300 Subject: [PATCH 6/6] feat(cli): enable json output of cartesi deploy build --- .changeset/tidy-trees-brake.md | 5 +++++ apps/cli/src/commands/deploy/build.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/tidy-trees-brake.md diff --git a/.changeset/tidy-trees-brake.md b/.changeset/tidy-trees-brake.md new file mode 100644 index 00000000..389ae28f --- /dev/null +++ b/.changeset/tidy-trees-brake.md @@ -0,0 +1,5 @@ +--- +"@cartesi/cli": patch +--- + +enable json output of cartesi deploy build diff --git a/apps/cli/src/commands/deploy/build.ts b/apps/cli/src/commands/deploy/build.ts index 34e65793..5812c04f 100644 --- a/apps/cli/src/commands/deploy/build.ts +++ b/apps/cli/src/commands/deploy/build.ts @@ -24,6 +24,8 @@ export default class DeployBuild extends BaseCommand { }), }; + public static enableJsonFlag = true; + private async buildRollupsImage(platform?: string) { const buildResult = tmpNameSync(); const imagePath = this.getContextPath("image"); @@ -53,7 +55,7 @@ export default class DeployBuild extends BaseCommand { return fs.readFileSync(buildResult, "utf8"); } - public async run(): Promise { + public async run() { const { flags } = await this.parse(DeployBuild); // print machine hash @@ -75,6 +77,6 @@ export default class DeployBuild extends BaseCommand { value: image, }); - return image; + return { image }; } }