From 547c0cb42f6bd79e400e652e6c090db13d92a185 Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Wed, 1 Apr 2026 17:56:23 +0200 Subject: [PATCH 01/10] Upgraded o1js to 2.14 native prover --- packages/api/package.json | 2 +- packages/cli/package.json | 2 +- packages/common/package.json | 2 +- packages/deployment/package.json | 2 +- packages/indexer/package.json | 2 +- packages/library/package.json | 2 +- packages/module/package.json | 2 +- packages/persistance/package.json | 2 +- packages/processor/package.json | 2 +- packages/protocol/package.json | 2 +- packages/sdk/package.json | 2 +- packages/sequencer/package.json | 2 +- packages/stack/package.json | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index be2cf87b..62e19e9e 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -49,7 +49,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/cli/package.json b/packages/cli/package.json index d50ece96..ebad55ae 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -41,7 +41,7 @@ "@proto-kit/sequencer": "*", "@proto-kit/stack": "*", "@proto-kit/indexer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/common/package.json b/packages/common/package.json index 289236fd..45dc8496 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -26,7 +26,7 @@ "typescript-memoize": "^1.1.1" }, "peerDependencies": { - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/deployment/package.json b/packages/deployment/package.json index df652529..42797dc5 100644 --- a/packages/deployment/package.json +++ b/packages/deployment/package.json @@ -33,7 +33,7 @@ "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", "bullmq": "^4.18.3", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/indexer/package.json b/packages/indexer/package.json index b57bf0c4..502906e9 100644 --- a/packages/indexer/package.json +++ b/packages/indexer/package.json @@ -43,7 +43,7 @@ "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", "koa": "^2.14.2", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0", "type-graphql": "2.0.0-rc.2", "typegraphql-prisma": "0.28" diff --git a/packages/library/package.json b/packages/library/package.json index 87bfac54..21389a98 100644 --- a/packages/library/package.json +++ b/packages/library/package.json @@ -28,7 +28,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/module/package.json b/packages/module/package.json index 4775f85e..49329b48 100644 --- a/packages/module/package.json +++ b/packages/module/package.json @@ -29,7 +29,7 @@ "peerDependencies": { "@proto-kit/common": "*", "@proto-kit/protocol": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "gitHead": "8a7eca319272a15162dc4ad04bdc134b1017716d" diff --git a/packages/persistance/package.json b/packages/persistance/package.json index dda4d383..a47945e4 100644 --- a/packages/persistance/package.json +++ b/packages/persistance/package.json @@ -32,7 +32,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/processor/package.json b/packages/processor/package.json index 617bd6e7..d0781ad8 100644 --- a/packages/processor/package.json +++ b/packages/processor/package.json @@ -45,7 +45,7 @@ "@proto-kit/protocol": "*", "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0", "type-graphql": "2.0.0-rc.2", "typegraphql-prisma": "^0.28" diff --git a/packages/protocol/package.json b/packages/protocol/package.json index 3b6bdf83..db397564 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -25,7 +25,7 @@ }, "peerDependencies": { "@proto-kit/common": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "ts-pattern": "^4.3.0", "tsyringe": "^4.10.0" }, diff --git a/packages/sdk/package.json b/packages/sdk/package.json index f3f74d87..b89d6965 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -30,7 +30,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/sequencer/package.json b/packages/sequencer/package.json index af2afdef..d6fa12c8 100644 --- a/packages/sequencer/package.json +++ b/packages/sequencer/package.json @@ -23,7 +23,7 @@ "@proto-kit/common": "*", "@proto-kit/module": "*", "@proto-kit/protocol": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" }, "devDependencies": { diff --git a/packages/stack/package.json b/packages/stack/package.json index ac07a527..727413b4 100644 --- a/packages/stack/package.json +++ b/packages/stack/package.json @@ -32,7 +32,7 @@ "@proto-kit/protocol": "*", "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "@o1js/native": "2.10.0-dev.6d3a3", "tsyringe": "^4.10.0" }, From 9ad9e193adfe89ec021739d725d9fe835f4d3888 Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Wed, 1 Apr 2026 17:57:31 +0200 Subject: [PATCH 02/10] package-lock --- package-lock.json | 161 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 136 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index f0c2705d..d809b2c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2615,6 +2615,19 @@ ], "peer": true }, + "node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "peer": true, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -3315,6 +3328,84 @@ ], "peer": true }, + "node_modules/@o1js/native-darwin-x64": { + "version": "2.14.0-dev.e1080", + "resolved": "https://registry.npmjs.org/@o1js/native-darwin-x64/-/native-darwin-x64-2.14.0-dev.e1080.tgz", + "integrity": "sha512-scUWJEtWL3vtpG8VU0EHUMSXnLs5YeS8tOCehvEH7dth23IlOWcNg6mHfCKLa+q1fmhrzm1gwVpL/JxyzMRe6g==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, + "node_modules/@o1js/native-linux-arm64": { + "version": "2.14.0-dev.e1080", + "resolved": "https://registry.npmjs.org/@o1js/native-linux-arm64/-/native-linux-arm64-2.14.0-dev.e1080.tgz", + "integrity": "sha512-oittNPPCy0FaJGpp1t/tPW1wImx6j2SRSGv3iFfGfF4rzoS2ioR3Mtz1EYlXei9DApOBKwo9A4T8VDqA/Gmwlw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@o1js/native-linux-x64": { + "version": "2.14.0-dev.e1080", + "resolved": "https://registry.npmjs.org/@o1js/native-linux-x64/-/native-linux-x64-2.14.0-dev.e1080.tgz", + "integrity": "sha512-7js8l3aLDgwDRyf6y4Z6TnGp/AYvg3fDyIJZWskK0KWwwc9mMr9Hl2K40eULzmBfkKtWT8rHb9C7tzuM954Opg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@o1js/native/node_modules/@o1js/native-darwin-x64": { + "version": "2.10.0-dev.6d3a3", + "resolved": "https://registry.npmjs.org/@o1js/native-darwin-x64/-/native-darwin-x64-2.10.0-dev.6d3a3.tgz", + "integrity": "sha512-hiPMb0Dvje9pk+csni7MaGAjtimlt+6yBf9tyASeKfeCd/EQIpKv7yAIFxzP4EMrr6QuHyDEWQMye98Cw7Ua/w==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, + "node_modules/@o1js/native/node_modules/@o1js/native-linux-arm64": { + "version": "2.10.0-dev.6d3a3", + "resolved": "https://registry.npmjs.org/@o1js/native-linux-arm64/-/native-linux-arm64-2.10.0-dev.6d3a3.tgz", + "integrity": "sha512-MGzkdWhQ2iqLPNh2isG3dI/7g84hvzrRArdB++XaxXF1O2i0s8DGv6bt2jDZt2U1FooClzd5ao5yUOAHYUZJUw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, + "node_modules/@o1js/native/node_modules/@o1js/native-linux-x64": { + "version": "2.10.0-dev.6d3a3", + "resolved": "https://registry.npmjs.org/@o1js/native-linux-x64/-/native-linux-x64-2.10.0-dev.6d3a3.tgz", + "integrity": "sha512-kzL+PS7enifE8gH9ntOsXjhYNOSN5rrfgWNt6A1bHQCRUxKjLS63uQ4Use/+2ORBWGBcfD2d6pZiCjqK2jhz7A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true + }, "node_modules/@octokit/action": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/@octokit/action/-/action-6.1.0.tgz", @@ -17953,13 +18044,6 @@ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", "license": "ISC" }, - "node_modules/js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==", - "license": "MIT", - "peer": true - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -21983,15 +22067,15 @@ } }, "node_modules/o1js": { - "version": "2.10.0-dev.6d3a3", - "resolved": "https://registry.npmjs.org/o1js/-/o1js-2.10.0-dev.6d3a3.tgz", - "integrity": "sha512-QoTFmcgrWj/6GTBvKxh6DGyfhPsslXWkKfG0FZv3tBL0OunFeQKQr9SORgXbGK/c1s0KDSEqIKrP6OWLAsz1FA==", + "version": "2.14.0-dev.e1080", + "resolved": "https://registry.npmjs.org/o1js/-/o1js-2.14.0-dev.e1080.tgz", + "integrity": "sha512-g6Xs0/PV9fzEB+Gi2LREW+dK80odD/XWgSRHg01gXxkME2v8a0L/9mv++mn/znOwWeNoFZd0Vao7JWtr4T6VQA==", "license": "Apache-2.0", "peer": true, "dependencies": { + "@noble/hashes": "^1.7.1", "blakejs": "1.2.1", "cachedir": "^2.4.0", - "js-sha256": "^0.9.0", "libsodium-wrappers-sumo": "^0.7.15", "reflect-metadata": "^0.1.13", "stacktrace-js": "^2.0.2", @@ -22004,9 +22088,36 @@ "node": ">=18.14.0" }, "optionalDependencies": { - "@o1js/native": "2.10.0-dev.6d3a3" + "@o1js/native": "2.14.0-dev.e1080" + } + }, + "node_modules/o1js/node_modules/@o1js/native": { + "version": "2.14.0-dev.e1080", + "resolved": "https://registry.npmjs.org/@o1js/native/-/native-2.14.0-dev.e1080.tgz", + "integrity": "sha512-2P7rkE27//ovu403QvdNPgNFjZztO/tQhmbRqmQeU93fVGbtjTwFrQVnEqzrikDVK/323ulUpdTK0xDwOxFN0w==", + "optional": true, + "peer": true, + "optionalDependencies": { + "@o1js/native-darwin-arm64": "2.14.0-dev.e1080", + "@o1js/native-darwin-x64": "2.14.0-dev.e1080", + "@o1js/native-linux-arm64": "2.14.0-dev.e1080", + "@o1js/native-linux-x64": "2.14.0-dev.e1080", + "@o1js/native-win32-x64": "2.14.0-dev.e1080" } }, + "node_modules/o1js/node_modules/@o1js/native-darwin-arm64": { + "version": "2.14.0-dev.e1080", + "resolved": "https://registry.npmjs.org/@o1js/native-darwin-arm64/-/native-darwin-arm64-2.14.0-dev.e1080.tgz", + "integrity": "sha512-V4TKpmiBoKmtXZOn18wYAZWzDRKaFUvEahEBx5uFUF+iLDv3fO17h30yoZ8STiCb2y56LWTGU3EgxwwnjfvQjw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "peer": true + }, "node_modules/o1js/node_modules/cachedir": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/cachedir/-/cachedir-2.4.0.tgz", @@ -28546,7 +28657,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -28583,7 +28694,7 @@ "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", "@proto-kit/stack": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -28720,7 +28831,7 @@ "@types/lodash": "^4.14.194" }, "peerDependencies": { - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -28756,7 +28867,7 @@ "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", "bullmq": "^4.18.3", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -28813,7 +28924,7 @@ "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", "koa": "^2.14.2", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0", "type-graphql": "2.0.0-rc.2", "typegraphql-prisma": "0.28" @@ -28838,7 +28949,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -28858,7 +28969,7 @@ "peerDependencies": { "@proto-kit/common": "*", "@proto-kit/protocol": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -28882,7 +28993,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -28925,7 +29036,7 @@ "@proto-kit/protocol": "*", "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0", "type-graphql": "2.0.0-rc.2", "typegraphql-prisma": "^0.28" @@ -28947,7 +29058,7 @@ }, "peerDependencies": { "@proto-kit/common": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "ts-pattern": "^4.3.0", "tsyringe": "^4.10.0" } @@ -28973,7 +29084,7 @@ "@proto-kit/module": "*", "@proto-kit/protocol": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -29000,7 +29111,7 @@ "@proto-kit/common": "*", "@proto-kit/module": "*", "@proto-kit/protocol": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, @@ -29080,7 +29191,7 @@ "@proto-kit/protocol": "*", "@proto-kit/sdk": "*", "@proto-kit/sequencer": "*", - "o1js": "2.10.0-dev.6d3a3", + "o1js": "2.14.0-dev.e1080", "tsyringe": "^4.10.0" } }, From f108edf6d0192580c4876c414524637009975abd Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Wed, 1 Apr 2026 18:32:27 +0200 Subject: [PATCH 03/10] Fixed block trigger startup order --- .../src/protocol/production/trigger/TimedBlockTrigger.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/sequencer/src/protocol/production/trigger/TimedBlockTrigger.ts b/packages/sequencer/src/protocol/production/trigger/TimedBlockTrigger.ts index 33e8bfae..a821b2f0 100644 --- a/packages/sequencer/src/protocol/production/trigger/TimedBlockTrigger.ts +++ b/packages/sequencer/src/protocol/production/trigger/TimedBlockTrigger.ts @@ -14,6 +14,7 @@ import { import { ensureNotBusy } from "../../../helpers/BusyGuard"; import { SequencerStartupModule } from "../../../sequencer/SequencerStartupModule"; import { BlockProductionInstrumentation } from "../../../metrics/BlockProductionInstrumentation"; +import { SequencerCoreModule } from "../../../sequencer/SequencerCoreModule"; import { BlockTriggerBase } from "./BlockTrigger"; @@ -50,7 +51,10 @@ export class TimedBlockTrigger // Only for start order, we need to make sure startup is finished before // starting the block production @inject("SequencerStartupModule") - private readonly startupModule: SequencerStartupModule + private readonly startupModule: SequencerStartupModule, + // TODO Fix the necessity for this - by having @startable() and starting based on that + @inject("SequencerCoreModule", { isOptional: true }) + private readonly sequencerCoreModule: SequencerCoreModule | undefined ) { super( blockProducerModule, From 90236c7e2946eccdaba78b46a123462ea3f1b0ac Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Thu, 2 Apr 2026 13:34:28 +0200 Subject: [PATCH 04/10] Made settlement proving try 3 times in case of errors --- packages/common/src/utils.ts | 28 +++++++++++++++++++ .../src/settlement/SettlementModule.ts | 8 +++++- .../test/settlement/Settlement.test.ts | 2 +- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts index 56c64ec3..48741d4e 100644 --- a/packages/common/src/utils.ts +++ b/packages/common/src/utils.ts @@ -8,6 +8,7 @@ import { import _ from "lodash"; import { TypedClass } from "./types"; +import { log } from "./log"; export function requireTrue( condition: boolean, @@ -318,3 +319,30 @@ export function takeFirst(arr: T[]): T { } return arr[0]; } + +export async function tryNTimes( + f: () => Promise, + times: number, + delay?: number +) { + let lastError; + + for (let i = 0; i < times; i++) { + try { + // eslint-disable-next-line no-await-in-loop + return await f(); + } catch (e) { + lastError = e; + log.warn(`Attempt ${i + 1} failed. Retrying...`); + + if (delay !== undefined) { + // eslint-disable-next-line no-await-in-loop + await sleep(delay); + } + } + } + + throw new Error( + `Function failed after ${times} tries. Last error: ${lastError}` + ); +} diff --git a/packages/sequencer/src/settlement/SettlementModule.ts b/packages/sequencer/src/settlement/SettlementModule.ts index 6712c66f..dc3b9d37 100644 --- a/packages/sequencer/src/settlement/SettlementModule.ts +++ b/packages/sequencer/src/settlement/SettlementModule.ts @@ -16,6 +16,7 @@ import { DependencyRecord, log, dependencyFactory, + tryNTimes, } from "@proto-kit/common"; import { @@ -161,7 +162,12 @@ export class SettlementModule : this.parentContainer.dependencyContainer.resolve( VanillaSettlementInteraction ); - const settlement = await interaction.settle(batch, options); + + const settlement = await tryNTimes( + async () => await interaction.settle(batch, options), + 3, + 1000 + ); await this.settlementStorage.pushSettlement(settlement); diff --git a/packages/sequencer/test/settlement/Settlement.test.ts b/packages/sequencer/test/settlement/Settlement.test.ts index 683fabe4..b1aa7044 100644 --- a/packages/sequencer/test/settlement/Settlement.test.ts +++ b/packages/sequencer/test/settlement/Settlement.test.ts @@ -14,7 +14,7 @@ describe.each(["mock-proofs", "signed"] as const)( }, }; - describe.only("Default token", () => { + describe("Default token", () => { settlementTestFn(type, network); }); From cdaa3a05934b507738d2bc21fc0f85f7a11e9994 Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Thu, 2 Apr 2026 18:12:46 +0200 Subject: [PATCH 05/10] Fixed feature flags computation --- .../zkProgrammable/FeatureFlagsExtension.ts | 5 +- .../zkProgrammable/ZkProgrammable.test.ts | 63 ++++++++++++++++++- 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/packages/common/src/zkProgrammable/FeatureFlagsExtension.ts b/packages/common/src/zkProgrammable/FeatureFlagsExtension.ts index f0338ee9..e1c8cfa3 100644 --- a/packages/common/src/zkProgrammable/FeatureFlagsExtension.ts +++ b/packages/common/src/zkProgrammable/FeatureFlagsExtension.ts @@ -1,7 +1,10 @@ import { FeatureFlags } from "o1js"; function combineFeatureFlag(a: boolean | undefined, b: boolean | undefined) { - if (a === true || b === true) { + // If both are true => true + // If one or both are undefined (maybe) => maybe + // If both are none => none + if (a === true && b === true) { return true; } else if (a === undefined || b === undefined) { return undefined; diff --git a/packages/common/test/zkProgrammable/ZkProgrammable.test.ts b/packages/common/test/zkProgrammable/ZkProgrammable.test.ts index 500ecb2c..7c4bbb82 100644 --- a/packages/common/test/zkProgrammable/ZkProgrammable.test.ts +++ b/packages/common/test/zkProgrammable/ZkProgrammable.test.ts @@ -1,7 +1,7 @@ import "reflect-metadata"; import { jest } from "@jest/globals"; import { container } from "tsyringe"; -import { Field, Struct, Proof, ZkProgram } from "o1js"; +import { Field, Struct, Proof, ZkProgram, Provable, FeatureFlags } from "o1js"; import { MOCK_PROOF, @@ -116,6 +116,9 @@ class OtherTestProgrammable extends ZkProgrammable { Awaited> > ) { + const w = Provable.witness(Field, () => Field(0)); + w.assertLessThan(Field(100)); + testProgrammableProof.verify(); } @@ -154,6 +157,16 @@ class OtherTestProgrammable extends ZkProgrammable { const testWithProofs = false; +async function withProofsEnabled( + areProofsEnabled: AreProofsEnabled, + f: () => Promise +) { + const proofsBefore = areProofsEnabled.areProofsEnabled; + areProofsEnabled.setProofsEnabled(true); + await f(); + areProofsEnabled.setProofsEnabled(proofsBefore); +} + describe("zkProgrammable", () => { let testProgrammable: TestProgrammable; let artifact: CompileArtifact; @@ -220,6 +233,29 @@ describe("zkProgrammable", () => { }); }); + it("should return correct proof type", async () => { + await withProofsEnabled( + testProgrammable.areProofsEnabled!, + async () => { + const type = await testProgrammable.proofType(); + expect((type as any).maxProofsVerified).toBe(0); + } + ); + }); + + it("should return correct dynamic proof type", async () => { + await withProofsEnabled( + testProgrammable.areProofsEnabled!, + async () => { + const type = await testProgrammable.dynamicProofType(); + expect((type as any).maxProofsVerified).toStrictEqual(0); + expect((type as any).featureFlags).toStrictEqual( + FeatureFlags.allNone + ); + } + ); + }); + it("compile should return the correct verification key", () => { expect.assertions(1); @@ -274,6 +310,31 @@ describe("zkProgrammable", () => { .then((p) => p.compile()); }, 500_000); + it("should return correct proof type", async () => { + await withProofsEnabled( + testProgrammable.areProofsEnabled!, + async () => { + const type = await otherTestProgrammable.proofType(); + expect((type as any).maxProofsVerified).toBe(1); + } + ); + }); + + it("should return correct dynamic proof type", async () => { + await withProofsEnabled( + testProgrammable.areProofsEnabled!, + async () => { + const type = await otherTestProgrammable.dynamicProofType(); + expect((type as any).maxProofsVerified).toBe(1); + const flags = FeatureFlags.allNone; + flags.rangeCheck0 = true; + flags.rangeCheck1 = true; + flags.foreignFieldAdd = true; + expect((type as any).featureFlags).toStrictEqual(flags); + } + ); + }); + it("should successfully pass proof of one zkProgram as input to another zkProgram", async () => { expect.assertions(3); From 49988c0af3b103c075780d0841ae8ef224a25003 Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Thu, 2 Apr 2026 19:11:41 +0200 Subject: [PATCH 06/10] Tried fix for transactionprover error --- packages/common/src/zkProgrammable/ZkProgrammable.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/common/src/zkProgrammable/ZkProgrammable.ts b/packages/common/src/zkProgrammable/ZkProgrammable.ts index 4983cad4..cddeef4b 100644 --- a/packages/common/src/zkProgrammable/ZkProgrammable.ts +++ b/packages/common/src/zkProgrammable/ZkProgrammable.ts @@ -212,10 +212,17 @@ export abstract class ZkProgrammable< ); featureFlags = featureFlagsSet.reduce(combineFeatureFlags); } else { - featureFlags = FeatureFlags.allNone; + featureFlags = FeatureFlags.allMaybe; maxProofsVerified = 0; } + log.debug( + `Computed featured flags of ${programs[0].name} as`, + featureFlags, + "maxProofsVerified:", + maxProofsVerified + ); + return class DynamicProofType extends DynamicProof< PublicInput, PublicOutput From f76073b22dc1f1320c22197176c20d294e535256 Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Thu, 2 Apr 2026 19:41:53 +0200 Subject: [PATCH 07/10] Removed static dynamicproof reference of transactionprover --- .../src/prover/transaction/TransactionProvable.ts | 12 +----------- .../src/prover/transaction/TransactionProver.ts | 4 ++-- .../contracts/settlement/SettlementBase.ts | 3 +++ .../production/tasks/TransactionProvingTask.ts | 4 ++++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/protocol/src/prover/transaction/TransactionProvable.ts b/packages/protocol/src/prover/transaction/TransactionProvable.ts index 137d9934..3c733430 100644 --- a/packages/protocol/src/prover/transaction/TransactionProvable.ts +++ b/packages/protocol/src/prover/transaction/TransactionProvable.ts @@ -129,17 +129,7 @@ export class TransactionProverTransactionArguments extends Struct({ verificationKeyAttestation: RuntimeVerificationKeyAttestation, }) {} -export class DynamicRuntimeProof extends DynamicProof< - Void, - MethodPublicOutput -> { - static publicInputType = Void; - - static publicOutputType = MethodPublicOutput; - - // TODO this won't be 0 for proofs-as-args - static maxProofsVerified = 0 as const; -} +export type DynamicRuntimeProof = DynamicProof; export class TransactionProverExecutionData extends Struct({ transaction: TransactionProverTransactionArguments, diff --git a/packages/protocol/src/prover/transaction/TransactionProver.ts b/packages/protocol/src/prover/transaction/TransactionProver.ts index 349e7b85..774ea86b 100644 --- a/packages/protocol/src/prover/transaction/TransactionProver.ts +++ b/packages/protocol/src/prover/transaction/TransactionProver.ts @@ -408,8 +408,8 @@ export class TransactionProverZkProgrammable extends ZkProgrammable< proveTransactions: { privateInputs: [ - DynamicRuntimeProof, - DynamicRuntimeProof, + runtimeProofType, + runtimeProofType, TransactionProverExecutionData, TransactionProverExecutionData, ], diff --git a/packages/protocol/src/settlement/contracts/settlement/SettlementBase.ts b/packages/protocol/src/settlement/contracts/settlement/SettlementBase.ts index c44857d1..989d4215 100644 --- a/packages/protocol/src/settlement/contracts/settlement/SettlementBase.ts +++ b/packages/protocol/src/settlement/contracts/settlement/SettlementBase.ts @@ -9,6 +9,7 @@ import { TokenContract, UInt32, Permissions, + FeatureFlags, } from "o1js"; import { ChildVerificationKeyService, @@ -49,6 +50,8 @@ export class DynamicBlockProof extends DynamicProof< public static publicOutputType = BlockProverPublicOutput; public static maxProofsVerified = 2 as const; + + public static featureFlags = FeatureFlags.allMaybe; } export interface SettlementContractType { diff --git a/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts b/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts index 386a14b4..228c12e8 100644 --- a/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts +++ b/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts @@ -130,6 +130,10 @@ export class TransactionProvingTask return await this.computeDummy(); } + // eslint-disable-next-line @typescript-eslint/no-shadow + const DynamicRuntimeProof = + await this.runtime.zkProgrammable.dynamicProofType(); + const startingState = input.flatMap((i) => i.parameters.startingState); await executeWithPrefilledStateService( From 3672856441ece729945641c32d6bb3dda547b1ed Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Fri, 3 Apr 2026 19:06:45 +0200 Subject: [PATCH 08/10] Improved error handling and retrying in queue implementations --- .../api/src/metrics/OpenTelemetryServer.ts | 6 +-- packages/common/src/utils.ts | 13 ++++-- .../src/queue/InstantiatedBullQueue.ts | 4 ++ .../src/worker/queue/LocalTaskQueue.ts | 44 +++++++++++-------- .../src/worker/worker/FlowTaskWorker.ts | 12 +---- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/packages/api/src/metrics/OpenTelemetryServer.ts b/packages/api/src/metrics/OpenTelemetryServer.ts index c6c9b1df..9634edcc 100644 --- a/packages/api/src/metrics/OpenTelemetryServer.ts +++ b/packages/api/src/metrics/OpenTelemetryServer.ts @@ -1,8 +1,4 @@ -import { - Sequencer, - SequencerModule, - sequencerModule, -} from "@proto-kit/sequencer"; +import { SequencerModule, sequencerModule } from "@proto-kit/sequencer"; import { NodeSDK } from "@opentelemetry/sdk-node"; import { Resource } from "@opentelemetry/resources"; import { diff --git a/packages/common/src/utils.ts b/packages/common/src/utils.ts index 48741d4e..a0504151 100644 --- a/packages/common/src/utils.ts +++ b/packages/common/src/utils.ts @@ -331,7 +331,7 @@ export async function tryNTimes( try { // eslint-disable-next-line no-await-in-loop return await f(); - } catch (e) { + } catch (e: unknown) { lastError = e; log.warn(`Attempt ${i + 1} failed. Retrying...`); @@ -342,7 +342,12 @@ export async function tryNTimes( } } - throw new Error( - `Function failed after ${times} tries. Last error: ${lastError}` - ); + if (lastError instanceof Error) { + lastError.message = `Function failed after ${times} tries. Last error: ${lastError.message}`; + throw lastError; + } else { + throw new Error( + `Function failed after ${times} tries. Last error: ${lastError}` + ); + } } diff --git a/packages/deployment/src/queue/InstantiatedBullQueue.ts b/packages/deployment/src/queue/InstantiatedBullQueue.ts index 34690c6b..556b9083 100644 --- a/packages/deployment/src/queue/InstantiatedBullQueue.ts +++ b/packages/deployment/src/queue/InstantiatedBullQueue.ts @@ -53,6 +53,10 @@ export class InstantiatedBullQueue implements InstantiatedQueue { this.events.on("error", async (error) => { log.error("Error in worker", error); }); + this.events.on("failed", async (failed) => { + log.error("Error in worker", failed.failedReason); + throw new Error(failed.failedReason); + }); } return this.listeners.pushListener(listener); diff --git a/packages/sequencer/src/worker/queue/LocalTaskQueue.ts b/packages/sequencer/src/worker/queue/LocalTaskQueue.ts index df03e90a..d7e17ac1 100644 --- a/packages/sequencer/src/worker/queue/LocalTaskQueue.ts +++ b/packages/sequencer/src/worker/queue/LocalTaskQueue.ts @@ -114,30 +114,36 @@ export class LocalTaskQueue log.trace(`Working ${task.payload.name} with id ${task.taskId}`); - const payload = await this.workers[queueName]?.handler( - task.payload - ); - - if (payload === "closed" || payload === undefined) { - return; + let payloadLet: TaskPayload | "closed" | undefined; + try { + payloadLet = await this.workers[queueName]?.handler(task.payload); + } catch (error) { + if (task.retries >= 1) { + log.info( + `Task ${task.taskId} ${task.payload.name} failed, retrying` + ); + + // TODO Not sound yet, iterator iterates over old entries without + // this new task + this.queuedTasks[queueName].push({ + payload: task.payload, + taskId: task.taskId, + retries: task.retries - 1, + }); + + return; + } else { + throw error; + } } - log.trace("LocalTaskQueue got", JSON.stringify(payload)); - - if (payload.status === "error" && task.retries >= 1) { - log.info( - `Task ${task.taskId} ${task.payload.name} failed, retrying` - ); - // TODO Not sounds yet, iterator iterates over old entries without - // this new task - this.queuedTasks[queueName].push({ - payload: task.payload, - taskId: task.taskId, - retries: task.retries - 1, - }); + // Make it const so ts can infer narrowing types + const payload = payloadLet; + if (payload === "closed" || payload === undefined) { return; } + log.trace("LocalTaskQueue got", JSON.stringify(payload)); // Notify listeners about result const listenerPromises = this.listeners[queueName]?.map( diff --git a/packages/sequencer/src/worker/worker/FlowTaskWorker.ts b/packages/sequencer/src/worker/worker/FlowTaskWorker.ts index c86d4765..d77a476f 100644 --- a/packages/sequencer/src/worker/worker/FlowTaskWorker.ts +++ b/packages/sequencer/src/worker/worker/FlowTaskWorker.ts @@ -57,20 +57,10 @@ export class FlowTaskWorker implements Closeable { return result; } catch (error: unknown) { - const payload = - error instanceof Error ? error.message : JSON.stringify(error); - log.error("Error in worker (detailed trace): "); log.error(error); - return { - status: "error", - taskId: data.taskId, - flowId: data.flowId, - name: data.name, - payload, - sequencerId: data.sequencerId, - }; + throw error; } }); } From 4e825c246cb3b6cab4b3c4e49c96458fe3c2e603 Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Fri, 3 Apr 2026 19:09:00 +0200 Subject: [PATCH 09/10] Linting --- packages/protocol/src/prover/transaction/TransactionProvable.ts | 1 - .../src/protocol/production/tasks/TransactionProvingTask.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/protocol/src/prover/transaction/TransactionProvable.ts b/packages/protocol/src/prover/transaction/TransactionProvable.ts index 3c733430..caaf277b 100644 --- a/packages/protocol/src/prover/transaction/TransactionProvable.ts +++ b/packages/protocol/src/prover/transaction/TransactionProvable.ts @@ -1,4 +1,3 @@ -// eslint-disable-next-line max-classes-per-file import { CompilableModule, WithZkProgrammable } from "@proto-kit/common"; import { DynamicProof, Field, Proof, Signature, Struct, Void } from "o1js"; diff --git a/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts b/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts index 228c12e8..981a08e4 100644 --- a/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts +++ b/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts @@ -3,7 +3,6 @@ import { Protocol, ProtocolModulesRecord, StateServiceProvider, - DynamicRuntimeProof, TransactionProvable, TransactionProof, TransactionProverPublicInput, From 86ca6f59af4e9b7f371b78ce5b2e07d15d06c601 Mon Sep 17 00:00:00 2001 From: Raphael Panic Date: Fri, 3 Apr 2026 19:37:03 +0200 Subject: [PATCH 10/10] Linting again --- .../src/protocol/production/tasks/TransactionProvingTask.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts b/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts index 981a08e4..4ff33320 100644 --- a/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts +++ b/packages/sequencer/src/protocol/production/tasks/TransactionProvingTask.ts @@ -129,7 +129,6 @@ export class TransactionProvingTask return await this.computeDummy(); } - // eslint-disable-next-line @typescript-eslint/no-shadow const DynamicRuntimeProof = await this.runtime.zkProgrammable.dynamicProofType();