gate-evm-tools 1.0.28 → 1.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/bin/cli.js +3 -0
- package/bin/delivery.cjs +51 -0
- package/bin/manifest-bootstrap.js +4 -15
- package/bin/workflow.cjs +1 -1
- package/dist/commands/plan/file-store.d.ts.map +1 -0
- package/dist/commands/plan/generate-deployment.d.ts +48 -0
- package/dist/commands/plan/generate-deployment.d.ts.map +1 -0
- package/dist/commands/plan/generate-deployment.js +211 -0
- package/dist/commands/plan/generate-deployment.js.map +1 -0
- package/dist/commands/plan/helpers.d.ts.map +1 -0
- package/dist/commands/plan/index.d.ts +3 -0
- package/dist/commands/plan/index.d.ts.map +1 -0
- package/dist/commands/plan/index.js +88 -0
- package/dist/commands/plan/index.js.map +1 -0
- package/dist/commands/sync.js +1 -1
- package/dist/commands/sync.js.map +1 -1
- package/dist/core/BytecodeChecker.d.ts.map +1 -1
- package/dist/core/BytecodeChecker.js +27 -8
- package/dist/core/BytecodeChecker.js.map +1 -1
- package/dist/core/preparation/artifacts.d.ts +2 -0
- package/dist/core/preparation/artifacts.d.ts.map +1 -1
- package/dist/core/preparation/artifacts.js +9 -3
- package/dist/core/preparation/artifacts.js.map +1 -1
- package/dist/core/preparation/evm.d.ts +38 -2
- package/dist/core/preparation/evm.d.ts.map +1 -1
- package/dist/core/preparation/evm.js +104 -32
- package/dist/core/preparation/evm.js.map +1 -1
- package/dist/core/preparation/evmManifestSync.d.ts +63 -0
- package/dist/core/preparation/evmManifestSync.d.ts.map +1 -0
- package/dist/core/preparation/evmManifestSync.js +146 -0
- package/dist/core/preparation/evmManifestSync.js.map +1 -0
- package/dist/core/preparation/index.d.ts +40 -2
- package/dist/core/preparation/index.d.ts.map +1 -1
- package/dist/core/preparation/index.js +3 -3
- package/dist/core/preparation/index.js.map +1 -1
- package/dist/core/preparation/manifest.d.ts +15 -3
- package/dist/core/preparation/manifest.d.ts.map +1 -1
- package/dist/core/preparation/manifest.js +21 -26
- package/dist/core/preparation/manifest.js.map +1 -1
- package/dist/core/preparation/normalize.d.ts.map +1 -1
- package/dist/core/preparation/normalize.js +14 -9
- package/dist/core/preparation/normalize.js.map +1 -1
- package/dist/core/preparation/types.d.ts +7 -2
- package/dist/core/preparation/types.d.ts.map +1 -1
- package/dist/custody/hardhat-runtime.d.ts.map +1 -1
- package/dist/custody/hardhat-runtime.js +2 -0
- package/dist/custody/hardhat-runtime.js.map +1 -1
- package/dist/custody/hardhat.d.ts +1 -0
- package/dist/custody/hardhat.d.ts.map +1 -1
- package/dist/custody/hardhat.js +1 -0
- package/dist/custody/hardhat.js.map +1 -1
- package/dist/custody/index.d.ts +1 -0
- package/dist/custody/index.d.ts.map +1 -1
- package/dist/custody/index.js +1 -0
- package/dist/custody/index.js.map +1 -1
- package/dist/custody/provider-wait.d.ts +13 -0
- package/dist/custody/provider-wait.d.ts.map +1 -0
- package/dist/custody/provider-wait.js +78 -0
- package/dist/custody/provider-wait.js.map +1 -0
- package/dist/delivery/policy.d.ts +6 -0
- package/dist/delivery/policy.d.ts.map +1 -0
- package/dist/delivery/policy.js +24 -0
- package/dist/delivery/policy.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/sync/index.d.ts +15 -0
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +8 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/workflow/index.d.ts +6 -1
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +4 -0
- package/dist/workflow/index.js.map +1 -1
- package/dist-cjs/core/BytecodeChecker.js +526 -0
- package/dist-cjs/core/BytecodeChecker.js.map +1 -0
- package/dist-cjs/core/legacyProxyArtifact.js +42 -0
- package/dist-cjs/core/legacyProxyArtifact.js.map +1 -0
- package/dist-cjs/core/preparation/artifacts.js +11 -4
- package/dist-cjs/core/preparation/artifacts.js.map +1 -1
- package/dist-cjs/core/preparation/evm.js +105 -32
- package/dist-cjs/core/preparation/evm.js.map +1 -1
- package/dist-cjs/core/preparation/evmManifestSync.js +155 -0
- package/dist-cjs/core/preparation/evmManifestSync.js.map +1 -0
- package/dist-cjs/core/preparation/index.js +3 -3
- package/dist-cjs/core/preparation/index.js.map +1 -1
- package/dist-cjs/core/preparation/manifest.js +23 -28
- package/dist-cjs/core/preparation/manifest.js.map +1 -1
- package/dist-cjs/core/preparation/normalize.js +14 -9
- package/dist-cjs/core/preparation/normalize.js.map +1 -1
- package/dist-cjs/custody/hardhat-runtime.js +2 -0
- package/dist-cjs/custody/hardhat-runtime.js.map +1 -1
- package/dist-cjs/custody/hardhat.js +3 -1
- package/dist-cjs/custody/hardhat.js.map +1 -1
- package/dist-cjs/custody/index.js +3 -1
- package/dist-cjs/custody/index.js.map +1 -1
- package/dist-cjs/custody/provider-wait.js +81 -0
- package/dist-cjs/custody/provider-wait.js.map +1 -0
- package/dist-cjs/delivery/policy.js +29 -0
- package/dist-cjs/delivery/policy.js.map +1 -0
- package/dist-cjs/sync/index.js +8 -0
- package/dist-cjs/sync/index.js.map +1 -1
- package/dist-cjs/workflow/index.js +12 -1
- package/dist-cjs/workflow/index.js.map +1 -1
- package/dist-runtime/config/openzeppelin.d.ts +2 -1
- package/dist-runtime/config/openzeppelin.js +2 -19
- package/dist-runtime/config/openzeppelin.js.map +1 -1
- package/dist-runtime/delivery/abi.d.ts +14 -0
- package/dist-runtime/delivery/abi.js +161 -0
- package/dist-runtime/delivery/abi.js.map +1 -0
- package/dist-runtime/delivery/aggregate-bootstrap.d.ts +12 -0
- package/dist-runtime/delivery/aggregate-bootstrap.js +40 -0
- package/dist-runtime/delivery/aggregate-bootstrap.js.map +1 -0
- package/dist-runtime/delivery/aggregate-channel.d.ts +28 -0
- package/dist-runtime/delivery/aggregate-channel.js +155 -0
- package/dist-runtime/delivery/aggregate-channel.js.map +1 -0
- package/dist-runtime/delivery/aggregate-inputs.d.ts +168 -0
- package/dist-runtime/delivery/aggregate-inputs.js +57 -0
- package/dist-runtime/delivery/aggregate-inputs.js.map +1 -0
- package/dist-runtime/delivery/aggregate-source.d.ts +25 -0
- package/dist-runtime/delivery/aggregate-source.js +79 -0
- package/dist-runtime/delivery/aggregate-source.js.map +1 -0
- package/dist-runtime/delivery/aggregate-worker.d.ts +1 -0
- package/dist-runtime/delivery/aggregate-worker.js +191 -0
- package/dist-runtime/delivery/aggregate-worker.js.map +1 -0
- package/dist-runtime/delivery/aggregate.d.ts +51 -0
- package/dist-runtime/delivery/aggregate.js +190 -0
- package/dist-runtime/delivery/aggregate.js.map +1 -0
- package/dist-runtime/delivery/bindings.d.ts +21 -0
- package/dist-runtime/delivery/bindings.js +53 -0
- package/dist-runtime/delivery/bindings.js.map +1 -0
- package/dist-runtime/delivery/check-code.d.ts +19 -0
- package/dist-runtime/delivery/check-code.js +63 -0
- package/dist-runtime/delivery/check-code.js.map +1 -0
- package/dist-runtime/delivery/closure-format.d.ts +77 -0
- package/dist-runtime/delivery/closure-format.js +225 -0
- package/dist-runtime/delivery/closure-format.js.map +1 -0
- package/dist-runtime/delivery/codec-pin.d.ts +2 -0
- package/dist-runtime/delivery/codec-pin.js +7 -0
- package/dist-runtime/delivery/codec-pin.js.map +1 -0
- package/dist-runtime/delivery/codec.d.ts +19 -0
- package/dist-runtime/delivery/codec.js +73 -0
- package/dist-runtime/delivery/codec.js.map +1 -0
- package/dist-runtime/delivery/compiler-dependency-pins.d.ts +7 -0
- package/dist-runtime/delivery/compiler-dependency-pins.js +1689 -0
- package/dist-runtime/delivery/compiler-dependency-pins.js.map +1 -0
- package/dist-runtime/delivery/compiler-files.d.ts +40 -0
- package/dist-runtime/delivery/compiler-files.js +220 -0
- package/dist-runtime/delivery/compiler-files.js.map +1 -0
- package/dist-runtime/delivery/compiler-io.d.ts +2 -0
- package/dist-runtime/delivery/compiler-io.js +13 -0
- package/dist-runtime/delivery/compiler-io.js.map +1 -0
- package/dist-runtime/delivery/compiler-pins.d.ts +10 -0
- package/dist-runtime/delivery/compiler-pins.js +147 -0
- package/dist-runtime/delivery/compiler-pins.js.map +1 -0
- package/dist-runtime/delivery/compiler.d.ts +188 -0
- package/dist-runtime/delivery/compiler.js +850 -0
- package/dist-runtime/delivery/compiler.js.map +1 -0
- package/dist-runtime/delivery/config.d.ts +48 -0
- package/dist-runtime/delivery/config.js +99 -0
- package/dist-runtime/delivery/config.js.map +1 -0
- package/dist-runtime/delivery/configuration-definition.d.ts +22 -0
- package/dist-runtime/delivery/configuration-definition.js +316 -0
- package/dist-runtime/delivery/configuration-definition.js.map +1 -0
- package/dist-runtime/delivery/configuration-hre.d.ts +17 -0
- package/dist-runtime/delivery/configuration-hre.js +198 -0
- package/dist-runtime/delivery/configuration-hre.js.map +1 -0
- package/dist-runtime/delivery/configuration-runtime.d.ts +36 -0
- package/dist-runtime/delivery/configuration-runtime.js +248 -0
- package/dist-runtime/delivery/configuration-runtime.js.map +1 -0
- package/dist-runtime/delivery/configuration.d.ts +35 -0
- package/dist-runtime/delivery/configuration.js +83 -0
- package/dist-runtime/delivery/configuration.js.map +1 -0
- package/dist-runtime/delivery/create2.d.ts +3 -0
- package/dist-runtime/delivery/create2.js +48 -0
- package/dist-runtime/delivery/create2.js.map +1 -0
- package/dist-runtime/delivery/custom-closure.d.ts +27 -0
- package/dist-runtime/delivery/custom-closure.js +818 -0
- package/dist-runtime/delivery/custom-closure.js.map +1 -0
- package/dist-runtime/delivery/custom-format.d.ts +35 -0
- package/dist-runtime/delivery/custom-format.js +383 -0
- package/dist-runtime/delivery/custom-format.js.map +1 -0
- package/dist-runtime/delivery/custom.d.ts +32 -0
- package/dist-runtime/delivery/custom.js +158 -0
- package/dist-runtime/delivery/custom.js.map +1 -0
- package/dist-runtime/delivery/data.d.ts +7 -0
- package/dist-runtime/delivery/data.js +86 -0
- package/dist-runtime/delivery/data.js.map +1 -0
- package/dist-runtime/delivery/development.d.ts +91 -0
- package/dist-runtime/delivery/development.js +395 -0
- package/dist-runtime/delivery/development.js.map +1 -0
- package/dist-runtime/delivery/engine.d.ts +9 -0
- package/dist-runtime/delivery/engine.js +23 -0
- package/dist-runtime/delivery/engine.js.map +1 -0
- package/dist-runtime/delivery/eoa-observation.d.ts +43 -0
- package/dist-runtime/delivery/eoa-observation.js +145 -0
- package/dist-runtime/delivery/eoa-observation.js.map +1 -0
- package/dist-runtime/delivery/eoa-signed.d.ts +2 -0
- package/dist-runtime/delivery/eoa-signed.js +74 -0
- package/dist-runtime/delivery/eoa-signed.js.map +1 -0
- package/dist-runtime/delivery/eoa.d.ts +81 -0
- package/dist-runtime/delivery/eoa.js +274 -0
- package/dist-runtime/delivery/eoa.js.map +1 -0
- package/dist-runtime/delivery/execution-db.d.ts +20 -0
- package/dist-runtime/delivery/execution-db.js +153 -0
- package/dist-runtime/delivery/execution-db.js.map +1 -0
- package/dist-runtime/delivery/execution-files.d.ts +9 -0
- package/dist-runtime/delivery/execution-files.js +138 -0
- package/dist-runtime/delivery/execution-files.js.map +1 -0
- package/dist-runtime/delivery/execution-model.d.ts +56 -0
- package/dist-runtime/delivery/execution-model.js +66 -0
- package/dist-runtime/delivery/execution-model.js.map +1 -0
- package/dist-runtime/delivery/execution-store.d.ts +48 -0
- package/dist-runtime/delivery/execution-store.js +361 -0
- package/dist-runtime/delivery/execution-store.js.map +1 -0
- package/dist-runtime/delivery/existing-code.d.ts +37 -0
- package/dist-runtime/delivery/existing-code.js +75 -0
- package/dist-runtime/delivery/existing-code.js.map +1 -0
- package/dist-runtime/delivery/export.d.ts +51 -0
- package/dist-runtime/delivery/export.js +69 -0
- package/dist-runtime/delivery/export.js.map +1 -0
- package/dist-runtime/delivery/forkAudit.d.ts +119 -0
- package/dist-runtime/delivery/forkAudit.js +473 -0
- package/dist-runtime/delivery/forkAudit.js.map +1 -0
- package/dist-runtime/delivery/hardhat.d.ts +3 -0
- package/dist-runtime/delivery/hardhat.js +45 -0
- package/dist-runtime/delivery/hardhat.js.map +1 -0
- package/dist-runtime/delivery/history-registration.d.ts +2 -0
- package/dist-runtime/delivery/history-registration.js +17 -0
- package/dist-runtime/delivery/history-registration.js.map +1 -0
- package/dist-runtime/delivery/identities.d.ts +22 -0
- package/dist-runtime/delivery/identities.js +97 -0
- package/dist-runtime/delivery/identities.js.map +1 -0
- package/dist-runtime/delivery/input-files.d.ts +5 -0
- package/dist-runtime/delivery/input-files.js +70 -0
- package/dist-runtime/delivery/input-files.js.map +1 -0
- package/dist-runtime/delivery/inputs.d.ts +62 -0
- package/dist-runtime/delivery/inputs.js +187 -0
- package/dist-runtime/delivery/inputs.js.map +1 -0
- package/dist-runtime/delivery/journal.d.ts +35 -0
- package/dist-runtime/delivery/journal.js +270 -0
- package/dist-runtime/delivery/journal.js.map +1 -0
- package/dist-runtime/delivery/manifest.d.ts +14 -0
- package/dist-runtime/delivery/manifest.js +68 -0
- package/dist-runtime/delivery/manifest.js.map +1 -0
- package/dist-runtime/delivery/materialization.d.ts +20 -0
- package/dist-runtime/delivery/materialization.js +138 -0
- package/dist-runtime/delivery/materialization.js.map +1 -0
- package/dist-runtime/delivery/observations.d.ts +31 -0
- package/dist-runtime/delivery/observations.js +38 -0
- package/dist-runtime/delivery/observations.js.map +1 -0
- package/dist-runtime/delivery/parameters.d.ts +53 -0
- package/dist-runtime/delivery/parameters.js +257 -0
- package/dist-runtime/delivery/parameters.js.map +1 -0
- package/dist-runtime/delivery/pending.d.ts +70 -0
- package/dist-runtime/delivery/pending.js +99 -0
- package/dist-runtime/delivery/pending.js.map +1 -0
- package/dist-runtime/delivery/plan.d.ts +50 -0
- package/dist-runtime/delivery/plan.js +209 -0
- package/dist-runtime/delivery/plan.js.map +1 -0
- package/dist-runtime/delivery/planning.d.ts +81 -0
- package/dist-runtime/delivery/planning.js +302 -0
- package/dist-runtime/delivery/planning.js.map +1 -0
- package/dist-runtime/delivery/policy.d.ts +4 -0
- package/dist-runtime/delivery/policy.js +9 -0
- package/dist-runtime/delivery/policy.js.map +1 -0
- package/dist-runtime/delivery/preparation.d.ts +6 -0
- package/dist-runtime/delivery/preparation.js +158 -0
- package/dist-runtime/delivery/preparation.js.map +1 -0
- package/dist-runtime/delivery/production-environment.d.ts +2 -0
- package/dist-runtime/delivery/production-environment.js +12 -0
- package/dist-runtime/delivery/production-environment.js.map +1 -0
- package/dist-runtime/delivery/production-finalization.d.ts +86 -0
- package/dist-runtime/delivery/production-finalization.js +278 -0
- package/dist-runtime/delivery/production-finalization.js.map +1 -0
- package/dist-runtime/delivery/production.d.ts +461 -0
- package/dist-runtime/delivery/production.js +396 -0
- package/dist-runtime/delivery/production.js.map +1 -0
- package/dist-runtime/delivery/project-files.d.ts +8 -0
- package/dist-runtime/delivery/project-files.js +82 -0
- package/dist-runtime/delivery/project-files.js.map +1 -0
- package/dist-runtime/delivery/project.d.ts +15 -0
- package/dist-runtime/delivery/project.js +157 -0
- package/dist-runtime/delivery/project.js.map +1 -0
- package/dist-runtime/delivery/protocol.d.ts +49 -0
- package/dist-runtime/delivery/protocol.js +112 -0
- package/dist-runtime/delivery/protocol.js.map +1 -0
- package/dist-runtime/delivery/references.d.ts +19 -0
- package/dist-runtime/delivery/references.js +84 -0
- package/dist-runtime/delivery/references.js.map +1 -0
- package/dist-runtime/delivery/release-graph.d.ts +93 -0
- package/dist-runtime/delivery/release-graph.js +106 -0
- package/dist-runtime/delivery/release-graph.js.map +1 -0
- package/dist-runtime/delivery/release-history-capture.d.ts +7 -0
- package/dist-runtime/delivery/release-history-capture.js +76 -0
- package/dist-runtime/delivery/release-history-capture.js.map +1 -0
- package/dist-runtime/delivery/release-history.d.ts +43 -0
- package/dist-runtime/delivery/release-history.js +246 -0
- package/dist-runtime/delivery/release-history.js.map +1 -0
- package/dist-runtime/delivery/release.d.ts +172 -0
- package/dist-runtime/delivery/release.js +209 -0
- package/dist-runtime/delivery/release.js.map +1 -0
- package/dist-runtime/delivery/safe-manifest.d.ts +9 -0
- package/dist-runtime/delivery/safe-manifest.js +13 -0
- package/dist-runtime/delivery/safe-manifest.js.map +1 -0
- package/dist-runtime/delivery/safe-observation.d.ts +30 -0
- package/dist-runtime/delivery/safe-observation.js +487 -0
- package/dist-runtime/delivery/safe-observation.js.map +1 -0
- package/dist-runtime/delivery/safe-prepare.d.ts +13 -0
- package/dist-runtime/delivery/safe-prepare.js +81 -0
- package/dist-runtime/delivery/safe-prepare.js.map +1 -0
- package/dist-runtime/delivery/safe.d.ts +91 -0
- package/dist-runtime/delivery/safe.js +243 -0
- package/dist-runtime/delivery/safe.js.map +1 -0
- package/dist-runtime/delivery/same-fork-baseline.d.ts +8 -0
- package/dist-runtime/delivery/same-fork-baseline.js +20 -0
- package/dist-runtime/delivery/same-fork-baseline.js.map +1 -0
- package/dist-runtime/delivery/setup.d.ts +31 -0
- package/dist-runtime/delivery/setup.js +215 -0
- package/dist-runtime/delivery/setup.js.map +1 -0
- package/dist-runtime/delivery/source.d.ts +41 -0
- package/dist-runtime/delivery/source.js +137 -0
- package/dist-runtime/delivery/source.js.map +1 -0
- package/dist-runtime/delivery/target-fields.d.ts +2 -0
- package/dist-runtime/delivery/target-fields.js +11 -0
- package/dist-runtime/delivery/target-fields.js.map +1 -0
- package/dist-runtime/delivery/validation.d.ts +9 -0
- package/dist-runtime/delivery/validation.js +150 -0
- package/dist-runtime/delivery/validation.js.map +1 -0
- package/dist-runtime/delivery/verification.d.ts +16 -0
- package/dist-runtime/delivery/verification.js +65 -0
- package/dist-runtime/delivery/verification.js.map +1 -0
- package/dist-runtime/migrate.js +1 -0
- package/dist-runtime/migrate.js.map +1 -1
- package/dist-runtime/miner/binary.d.ts +2 -0
- package/dist-runtime/miner/binary.js +54 -0
- package/dist-runtime/miner/binary.js.map +1 -0
- package/dist-runtime/miner/cli.d.ts +1 -0
- package/dist-runtime/miner/cli.js +131 -0
- package/dist-runtime/miner/cli.js.map +1 -0
- package/dist-runtime/miner/index.d.ts +5 -0
- package/dist-runtime/miner/index.js +13 -0
- package/dist-runtime/miner/index.js.map +1 -0
- package/dist-runtime/miner/request.d.ts +7 -0
- package/dist-runtime/miner/request.js +73 -0
- package/dist-runtime/miner/request.js.map +1 -0
- package/dist-runtime/miner/runner.d.ts +2 -0
- package/dist-runtime/miner/runner.js +131 -0
- package/dist-runtime/miner/runner.js.map +1 -0
- package/dist-runtime/miner/types.d.ts +89 -0
- package/dist-runtime/miner/types.js +3 -0
- package/dist-runtime/miner/types.js.map +1 -0
- package/dist-runtime/miner/verify.d.ts +2 -0
- package/dist-runtime/miner/verify.js +75 -0
- package/dist-runtime/miner/verify.js.map +1 -0
- package/dist-runtime/runtime-identity.json +2 -2
- package/dist-runtime/vendor/plan-codec/index.cjs +820 -0
- package/dist-runtime/vendor/plan-codec/index.d.cts +32 -0
- package/dist-runtime/vendor/plan-codec/provenance.json +24 -0
- package/dist-runtime/workflow/engine.d.ts +14 -0
- package/dist-runtime/workflow/engine.js +160 -0
- package/dist-runtime/workflow/engine.js.map +1 -0
- package/dist-runtime/workflow/lib/authority.d.ts +6 -3
- package/dist-runtime/workflow/lib/authority.js.map +1 -1
- package/dist-runtime/workflow/lib/calls.d.ts +1 -1
- package/dist-runtime/workflow/lib/calls.js +43 -34
- package/dist-runtime/workflow/lib/calls.js.map +1 -1
- package/dist-runtime/workflow/lib/canonicalData.d.ts +8 -0
- package/dist-runtime/workflow/lib/canonicalData.js +68 -0
- package/dist-runtime/workflow/lib/canonicalData.js.map +1 -0
- package/dist-runtime/workflow/lib/config.d.ts +3 -1
- package/dist-runtime/workflow/lib/config.js.map +1 -1
- package/dist-runtime/workflow/lib/context.d.ts +76 -0
- package/dist-runtime/workflow/lib/context.js +3 -0
- package/dist-runtime/workflow/lib/context.js.map +1 -0
- package/dist-runtime/workflow/lib/create2.d.ts +1 -1
- package/dist-runtime/workflow/lib/create2.js +9 -12
- package/dist-runtime/workflow/lib/create2.js.map +1 -1
- package/dist-runtime/workflow/lib/deployments.d.ts +5 -5
- package/dist-runtime/workflow/lib/deployments.js +5 -13
- package/dist-runtime/workflow/lib/deployments.js.map +1 -1
- package/dist-runtime/workflow/lib/evidencePorts.d.ts +55 -0
- package/dist-runtime/workflow/lib/evidencePorts.js +3 -0
- package/dist-runtime/workflow/lib/evidencePorts.js.map +1 -0
- package/dist-runtime/workflow/lib/executionPlan.d.ts +4 -42
- package/dist-runtime/workflow/lib/executionPlan.js +15 -210
- package/dist-runtime/workflow/lib/executionPlan.js.map +1 -1
- package/dist-runtime/workflow/lib/gateTool.d.ts +6 -2
- package/dist-runtime/workflow/lib/gateTool.js +20 -10
- package/dist-runtime/workflow/lib/gateTool.js.map +1 -1
- package/dist-runtime/workflow/lib/gateToolSync.d.ts +1 -1
- package/dist-runtime/workflow/lib/gateToolSync.js +3 -2
- package/dist-runtime/workflow/lib/gateToolSync.js.map +1 -1
- package/dist-runtime/workflow/lib/operationNames.d.ts +3 -0
- package/dist-runtime/workflow/lib/operationNames.js +34 -0
- package/dist-runtime/workflow/lib/operationNames.js.map +1 -0
- package/dist-runtime/workflow/lib/parameters.d.ts +1 -1
- package/dist-runtime/workflow/lib/parameters.js +6 -22
- package/dist-runtime/workflow/lib/parameters.js.map +1 -1
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js +18 -52
- package/dist-runtime/workflow/lib/pendingDeploymentReuse.js.map +1 -1
- package/dist-runtime/workflow/lib/pendingUupsBinding.d.ts +42 -0
- package/dist-runtime/workflow/lib/pendingUupsBinding.js +39 -0
- package/dist-runtime/workflow/lib/pendingUupsBinding.js.map +1 -0
- package/dist-runtime/workflow/lib/plan.d.ts +55 -0
- package/dist-runtime/workflow/lib/plan.js +324 -0
- package/dist-runtime/workflow/lib/plan.js.map +1 -0
- package/dist-runtime/workflow/lib/planCli.d.ts +14 -0
- package/dist-runtime/workflow/lib/planCli.js +279 -0
- package/dist-runtime/workflow/lib/planCli.js.map +1 -0
- package/dist-runtime/workflow/lib/preparationEvidence.d.ts +4 -0
- package/dist-runtime/workflow/lib/preparationEvidence.js +19 -0
- package/dist-runtime/workflow/lib/preparationEvidence.js.map +1 -0
- package/dist-runtime/workflow/lib/proxy.d.ts +3 -2
- package/dist-runtime/workflow/lib/proxy.js +3 -4
- package/dist-runtime/workflow/lib/proxy.js.map +1 -1
- package/dist-runtime/workflow/lib/runtime.d.ts +6 -0
- package/dist-runtime/workflow/lib/runtime.js +48 -0
- package/dist-runtime/workflow/lib/runtime.js.map +1 -0
- package/dist-runtime/workflow/lib/signer.d.ts +3 -2
- package/dist-runtime/workflow/lib/signer.js +18 -18
- package/dist-runtime/workflow/lib/signer.js.map +1 -1
- package/dist-runtime/workflow/lib/simulation.d.ts +13 -6
- package/dist-runtime/workflow/lib/simulation.js +39 -31
- package/dist-runtime/workflow/lib/simulation.js.map +1 -1
- package/dist-runtime/workflow/lib/state.js +3 -3
- package/dist-runtime/workflow/lib/state.js.map +1 -1
- package/dist-runtime/workflow/lib/staticValidation.d.ts +28 -0
- package/dist-runtime/workflow/lib/staticValidation.js +54 -10
- package/dist-runtime/workflow/lib/staticValidation.js.map +1 -1
- package/dist-runtime/workflow/lib/transactionPlanner.d.ts +62 -0
- package/dist-runtime/workflow/lib/transactionPlanner.js +258 -0
- package/dist-runtime/workflow/lib/transactionPlanner.js.map +1 -0
- package/dist-runtime/workflow/lib/typedValue.d.ts +3 -0
- package/dist-runtime/workflow/lib/typedValue.js +76 -0
- package/dist-runtime/workflow/lib/typedValue.js.map +1 -0
- package/dist-runtime/workflow/lib/validation.d.ts +23 -0
- package/dist-runtime/workflow/lib/validation.js +15 -0
- package/dist-runtime/workflow/lib/validation.js.map +1 -0
- package/dist-runtime/workflow/planAdd.d.ts +1 -0
- package/dist-runtime/workflow/planAdd.js +11 -0
- package/dist-runtime/workflow/planAdd.js.map +1 -0
- package/dist-runtime/workflow/planRead.d.ts +1 -0
- package/dist-runtime/workflow/planRead.js +11 -0
- package/dist-runtime/workflow/planRead.js.map +1 -0
- package/dist-runtime/workflow/planStatus.d.ts +1 -0
- package/dist-runtime/workflow/planStatus.js +11 -0
- package/dist-runtime/workflow/planStatus.js.map +1 -0
- package/dist-runtime/workflow/planWrite.d.ts +1 -0
- package/dist-runtime/workflow/planWrite.js +11 -0
- package/dist-runtime/workflow/planWrite.js.map +1 -0
- package/dist-runtime/workflow/run.d.ts +1 -40
- package/dist-runtime/workflow/run.js +68 -136
- package/dist-runtime/workflow/run.js.map +1 -1
- package/dist-runtime/workflow/staticValidate.js +8 -3
- package/dist-runtime/workflow/staticValidate.js.map +1 -1
- package/dist-runtime/workflow/steps/call.d.ts +1 -1
- package/dist-runtime/workflow/steps/check.d.ts +1 -1
- package/dist-runtime/workflow/steps/custom.d.ts +1 -1
- package/dist-runtime/workflow/steps/deploy.d.ts +1 -1
- package/dist-runtime/workflow/steps/deploy.js +57 -55
- package/dist-runtime/workflow/steps/deploy.js.map +1 -1
- package/dist-runtime/workflow/steps/upgrade.d.ts +1 -1
- package/dist-runtime/workflow/steps/upgrade.js +62 -41
- package/dist-runtime/workflow/steps/upgrade.js.map +1 -1
- package/dist-runtime/workflow/steps/view.d.ts +1 -1
- package/docs/compiler-qualification.md +32 -0
- package/docs/configuration-runtime-observation.md +29 -0
- package/docs/create2-miner.md +100 -0
- package/docs/delivery-aggregate.md +27 -0
- package/docs/delivery-custom-input-closure.md +51 -0
- package/docs/delivery-development.md +32 -0
- package/docs/delivery-eoa.md +46 -0
- package/docs/delivery-evm-manifest.md +20 -0
- package/docs/delivery-execution-store.md +33 -0
- package/docs/delivery-inputs.md +46 -0
- package/docs/delivery-parameters.md +65 -0
- package/docs/delivery-planning.md +140 -0
- package/docs/delivery-release.md +65 -0
- package/docs/delivery-safe.md +72 -0
- package/docs/delivery-setup.md +146 -0
- package/docs/delivery-source.md +67 -0
- package/docs/superpowers/plans/2026-09-24-scheme-aware-static-validation.md +193 -0
- package/docs/superpowers/plans/2026-10-28-create2-miner.md +82 -0
- package/package.json +133 -9
- package/resources/create2/LICENSE +21 -0
- package/resources/create2/README.md +9 -0
- package/resources/create2/darwin-arm64/smartflow_miner +0 -0
- package/resources/create2/darwin-x64/smartflow_miner +0 -0
- package/resources/create2/manifest.json +27 -0
- package/runtime/config/openzeppelin.ts +3 -21
- package/runtime/delivery/abi.ts +225 -0
- package/runtime/delivery/aggregate-bootstrap.ts +29 -0
- package/runtime/delivery/aggregate-channel.ts +85 -0
- package/runtime/delivery/aggregate-inputs.ts +39 -0
- package/runtime/delivery/aggregate-source.ts +53 -0
- package/runtime/delivery/aggregate-worker.ts +133 -0
- package/runtime/delivery/aggregate.ts +139 -0
- package/runtime/delivery/bindings.ts +37 -0
- package/runtime/delivery/check-code.ts +38 -0
- package/runtime/delivery/closure-format.ts +350 -0
- package/runtime/delivery/codec-pin.ts +3 -0
- package/runtime/delivery/codec.ts +50 -0
- package/runtime/delivery/compiler-dependency-pins.ts +1685 -0
- package/runtime/delivery/compiler-files.ts +179 -0
- package/runtime/delivery/compiler-io.ts +10 -0
- package/runtime/delivery/compiler-pins.ts +143 -0
- package/runtime/delivery/compiler.ts +700 -0
- package/runtime/delivery/config.ts +93 -0
- package/runtime/delivery/configuration-definition.ts +133 -0
- package/runtime/delivery/configuration-hre.ts +130 -0
- package/runtime/delivery/configuration-runtime.ts +163 -0
- package/runtime/delivery/configuration.ts +64 -0
- package/runtime/delivery/create2.ts +57 -0
- package/runtime/delivery/custom-closure.ts +993 -0
- package/runtime/delivery/custom-format.ts +464 -0
- package/runtime/delivery/custom.ts +219 -0
- package/runtime/delivery/data.ts +94 -0
- package/runtime/delivery/development.ts +262 -0
- package/runtime/delivery/engine.ts +29 -0
- package/runtime/delivery/eoa-observation.ts +106 -0
- package/runtime/delivery/eoa-signed.ts +55 -0
- package/runtime/delivery/eoa.ts +288 -0
- package/runtime/delivery/execution-db.ts +131 -0
- package/runtime/delivery/execution-files.ts +135 -0
- package/runtime/delivery/execution-model.ts +102 -0
- package/runtime/delivery/execution-store.ts +411 -0
- package/runtime/delivery/existing-code.ts +44 -0
- package/runtime/delivery/export.ts +99 -0
- package/runtime/delivery/forkAudit.ts +620 -0
- package/runtime/delivery/hardhat.ts +38 -0
- package/runtime/delivery/history-registration.ts +10 -0
- package/runtime/delivery/identities.ts +132 -0
- package/runtime/delivery/input-files.ts +46 -0
- package/runtime/delivery/inputs.ts +197 -0
- package/runtime/delivery/journal.ts +201 -0
- package/runtime/delivery/manifest.ts +54 -0
- package/runtime/delivery/materialization.ts +53 -0
- package/runtime/delivery/observations.ts +60 -0
- package/runtime/delivery/parameters.ts +349 -0
- package/runtime/delivery/pending.ts +98 -0
- package/runtime/delivery/plan.ts +337 -0
- package/runtime/delivery/planning.ts +397 -0
- package/runtime/delivery/policy.ts +9 -0
- package/runtime/delivery/preparation.ts +224 -0
- package/runtime/delivery/production-environment.ts +6 -0
- package/runtime/delivery/production-finalization.ts +172 -0
- package/runtime/delivery/production.ts +375 -0
- package/runtime/delivery/project-files.ts +58 -0
- package/runtime/delivery/project.ts +117 -0
- package/runtime/delivery/protocol.ts +94 -0
- package/runtime/delivery/references.ts +106 -0
- package/runtime/delivery/release-graph.ts +49 -0
- package/runtime/delivery/release-history-capture.ts +32 -0
- package/runtime/delivery/release-history.ts +120 -0
- package/runtime/delivery/release.ts +128 -0
- package/runtime/delivery/safe-manifest.ts +11 -0
- package/runtime/delivery/safe-observation.ts +626 -0
- package/runtime/delivery/safe-prepare.ts +101 -0
- package/runtime/delivery/safe.ts +344 -0
- package/runtime/delivery/same-fork-baseline.ts +16 -0
- package/runtime/delivery/setup.ts +172 -0
- package/runtime/delivery/source.ts +130 -0
- package/runtime/delivery/target-fields.ts +7 -0
- package/runtime/delivery/validation.ts +247 -0
- package/runtime/delivery/verification.ts +47 -0
- package/runtime/migrate.ts +1 -0
- package/runtime/miner/binary.ts +41 -0
- package/runtime/miner/cli.ts +87 -0
- package/runtime/miner/index.ts +5 -0
- package/runtime/miner/request.ts +54 -0
- package/runtime/miner/runner.ts +90 -0
- package/runtime/miner/types.ts +71 -0
- package/runtime/miner/verify.ts +61 -0
- package/runtime/vendor/plan-codec/index.cjs +820 -0
- package/runtime/vendor/plan-codec/index.d.cts +32 -0
- package/runtime/vendor/plan-codec/provenance.json +24 -0
- package/runtime/workflow/engine.ts +174 -0
- package/runtime/workflow/lib/authority.ts +3 -3
- package/runtime/workflow/lib/calls.ts +46 -37
- package/runtime/workflow/lib/canonicalData.ts +45 -0
- package/runtime/workflow/lib/config.ts +1 -1
- package/runtime/workflow/lib/context.ts +76 -0
- package/runtime/workflow/lib/create2.ts +10 -12
- package/runtime/workflow/lib/deployments.ts +6 -14
- package/runtime/workflow/lib/evidencePorts.ts +20 -0
- package/runtime/workflow/lib/executionPlan.ts +17 -268
- package/runtime/workflow/lib/gateTool.ts +20 -8
- package/runtime/workflow/lib/gateToolSync.ts +3 -3
- package/runtime/workflow/lib/operationNames.ts +32 -0
- package/runtime/workflow/lib/parameters.ts +4 -21
- package/runtime/workflow/lib/pendingDeploymentReuse.ts +4 -56
- package/runtime/workflow/lib/pendingUupsBinding.ts +43 -0
- package/runtime/workflow/lib/plan.ts +334 -0
- package/runtime/workflow/lib/planCli.ts +279 -0
- package/runtime/workflow/lib/preparationEvidence.ts +14 -0
- package/runtime/workflow/lib/proxy.ts +5 -3
- package/runtime/workflow/lib/runtime.ts +46 -0
- package/runtime/workflow/lib/signer.ts +8 -5
- package/runtime/workflow/lib/simulation.ts +41 -17
- package/runtime/workflow/lib/state.ts +3 -3
- package/runtime/workflow/lib/staticValidation.ts +92 -11
- package/runtime/workflow/lib/transactionPlanner.ts +314 -0
- package/runtime/workflow/lib/typedValue.ts +46 -0
- package/runtime/workflow/lib/validation.ts +50 -0
- package/runtime/workflow/planAdd.ts +8 -0
- package/runtime/workflow/planRead.ts +8 -0
- package/runtime/workflow/planStatus.ts +8 -0
- package/runtime/workflow/planWrite.ts +8 -0
- package/runtime/workflow/run.ts +41 -174
- package/runtime/workflow/staticValidate.ts +8 -3
- package/runtime/workflow/steps/call.ts +1 -1
- package/runtime/workflow/steps/check.ts +1 -1
- package/runtime/workflow/steps/custom.ts +1 -1
- package/runtime/workflow/steps/deploy.ts +57 -58
- package/runtime/workflow/steps/upgrade.ts +69 -46
- package/runtime/workflow/steps/view.ts +1 -1
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
/** Local durable record/claim kernel. No signer, broadcaster or production chain-verification adapter. */
|
|
2
|
+
import { canonicalJson, deepFreeze, digest, nonempty } from '../workflow/lib/canonicalData';
|
|
3
|
+
import { immutableDeliveryPlan } from './export';
|
|
4
|
+
import { prepareStoreFiles, type StoreFiles } from './execution-files';
|
|
5
|
+
import { sqliteConstructor, configure, bootstrapAuthority, initializeBusiness, commit, type Database } from './execution-db';
|
|
6
|
+
import { decimal, parseUnsigned, parseSigned, unsignedHash, same, type ExecutionSnapshot, type TransactionRecord, type TransactionState } from './execution-model';
|
|
7
|
+
import { parseSafeEnvelope } from './safe';
|
|
8
|
+
import { parseObservation, type TransactionObservation, type TrustedObservationPort } from './observations';
|
|
9
|
+
import type { DeliveryPlan } from './plan';
|
|
10
|
+
export { assertExecutionRuntime } from './execution-db';
|
|
11
|
+
export type { ExecutionSnapshot, TransactionRecord, TransactionState, UnsignedEnvelope, SignedRecord } from './execution-model';
|
|
12
|
+
export type { TrustedObservationPort, TransactionObservation } from './observations';
|
|
13
|
+
declare const claimBrand: unique symbol;
|
|
14
|
+
/** Only the original live object issued to an awaited callback is authority. */
|
|
15
|
+
export interface ExecutionClaim {
|
|
16
|
+
readonly [claimBrand]: true;
|
|
17
|
+
}
|
|
18
|
+
interface Session {
|
|
19
|
+
db: Database;
|
|
20
|
+
live: boolean;
|
|
21
|
+
accepting: boolean;
|
|
22
|
+
epoch: string;
|
|
23
|
+
executionId: string;
|
|
24
|
+
pending: Set<Promise<unknown>>;
|
|
25
|
+
}
|
|
26
|
+
interface ExecutionRow {
|
|
27
|
+
execution_id: string;
|
|
28
|
+
context_hash: string;
|
|
29
|
+
plan_hash: string;
|
|
30
|
+
plan_json: string;
|
|
31
|
+
revision: string;
|
|
32
|
+
epoch: string;
|
|
33
|
+
active_transaction_id: string | null;
|
|
34
|
+
completed_count: number;
|
|
35
|
+
blocked_reason: string | null;
|
|
36
|
+
}
|
|
37
|
+
interface TransactionRow {
|
|
38
|
+
execution_id: string;
|
|
39
|
+
transaction_id: string;
|
|
40
|
+
transaction_index: number;
|
|
41
|
+
state: TransactionState;
|
|
42
|
+
unsigned_json: string | null;
|
|
43
|
+
unsigned_digest: string | null;
|
|
44
|
+
signing_request_id: string | null;
|
|
45
|
+
signed_json: string | null;
|
|
46
|
+
observation_json: string | null;
|
|
47
|
+
}
|
|
48
|
+
export interface ClaimRequest {
|
|
49
|
+
plan: unknown;
|
|
50
|
+
contextHash: string;
|
|
51
|
+
expectedRevision: string | null;
|
|
52
|
+
}
|
|
53
|
+
export interface ExecutionStoreOptions {
|
|
54
|
+
/** Canonical absolute private directory selected by the trusted host, shared across CLI/projects/environments.
|
|
55
|
+
* Supported only on a local filesystem implementing SQLite locks and strict file/directory fsync. */
|
|
56
|
+
trustedRoot: string;
|
|
57
|
+
/** Waiting is bounded; expiration reports busy and NEVER steals a lifetime lock. */
|
|
58
|
+
busyTimeoutMs?: number;
|
|
59
|
+
}
|
|
60
|
+
const states = new Set(['claimed', 'signing', 'signed', 'submission-uncertain', 'included-unfinalized', 'finalized-success', 'finalized-reverted', 'blocked']);
|
|
61
|
+
const changes = (result: {
|
|
62
|
+
changes: number | bigint;
|
|
63
|
+
}) => {
|
|
64
|
+
if (BigInt(result.changes) !== 1n)
|
|
65
|
+
throw new Error('Execution revision/epoch/active-transaction CAS conflict');
|
|
66
|
+
};
|
|
67
|
+
function snapshot(db: Database, id: string): ExecutionSnapshot | undefined {
|
|
68
|
+
const row = db.prepare('SELECT * FROM executions WHERE execution_id=?').get(id) as unknown as ExecutionRow | undefined;
|
|
69
|
+
if (!row)
|
|
70
|
+
return;
|
|
71
|
+
const plan = immutableDeliveryPlan(JSON.parse(row.plan_json));
|
|
72
|
+
if (row.blocked_reason !== null)
|
|
73
|
+
nonempty(row.blocked_reason, 'execution block reason');
|
|
74
|
+
digest(row.context_hash, 'context');
|
|
75
|
+
decimal(row.revision, 'revision');
|
|
76
|
+
decimal(row.epoch, 'epoch');
|
|
77
|
+
if (plan.executionId !== row.execution_id || plan.planHash !== row.plan_hash)
|
|
78
|
+
throw new Error('Corrupt execution identity');
|
|
79
|
+
const rows = db.prepare('SELECT * FROM transactions WHERE execution_id=? ORDER BY transaction_index').all(id) as unknown as TransactionRow[];
|
|
80
|
+
if (rows.length !== plan.transactions.length || !Number.isSafeInteger(row.completed_count) || row.completed_count < 0 || row.completed_count > rows.length)
|
|
81
|
+
throw new Error('Corrupt execution transaction prefix');
|
|
82
|
+
const safeEnvelopes = (db.prepare('SELECT * FROM safe_envelopes WHERE execution_id=? ORDER BY start_index').all(id) as {
|
|
83
|
+
envelope_json: string;
|
|
84
|
+
envelope_id: string;
|
|
85
|
+
start_index: number;
|
|
86
|
+
chain_id: string;
|
|
87
|
+
safe_address: string;
|
|
88
|
+
safe_nonce: string;
|
|
89
|
+
outer_hash: string | null;
|
|
90
|
+
}[]).map(r => { const e = parseSafeEnvelope(JSON.parse(r.envelope_json), plan); if (e.envelopeId !== r.envelope_id || e.start !== r.start_index || e.chainId !== r.chain_id || e.safe !== r.safe_address || e.nonce !== r.safe_nonce)
|
|
91
|
+
throw Error('Corrupt Safe envelope reservation'); return e; });
|
|
92
|
+
for (let i = 1; i < safeEnvelopes.length; i++)
|
|
93
|
+
if (safeEnvelopes[i].start < safeEnvelopes[i - 1].start + safeEnvelopes[i - 1].count)
|
|
94
|
+
throw Error('Corrupt overlapping Safe envelopes');
|
|
95
|
+
const transactions: TransactionRecord[] = rows.map((r, i) => {
|
|
96
|
+
if (r.transaction_index !== i || r.transaction_id !== plan.transactions[i].transactionId || !states.has(r.state))
|
|
97
|
+
throw new Error('Corrupt transaction identity/state');
|
|
98
|
+
const unsigned = r.unsigned_json === null ? null : parseUnsigned(JSON.parse(r.unsigned_json), plan, i);
|
|
99
|
+
if ((unsigned ? unsignedHash(unsigned) : null) !== r.unsigned_digest)
|
|
100
|
+
throw new Error('Corrupt unsigned digest');
|
|
101
|
+
if (unsigned) {
|
|
102
|
+
const n = db.prepare('SELECT * FROM nonce_reservations WHERE chain_id=? AND signer=? AND nonce=?').get(unsigned.chainId, unsigned.signer, unsigned.nonce) as {
|
|
103
|
+
execution_id: string;
|
|
104
|
+
transaction_id: string;
|
|
105
|
+
unsigned_digest: string;
|
|
106
|
+
} | undefined;
|
|
107
|
+
if (!n || n.execution_id !== id || n.transaction_id !== r.transaction_id || n.unsigned_digest !== r.unsigned_digest)
|
|
108
|
+
throw new Error('Corrupt nonce reservation');
|
|
109
|
+
}
|
|
110
|
+
const signed = r.signed_json === null ? null : parseSigned(JSON.parse(r.signed_json), r.unsigned_digest ?? '');
|
|
111
|
+
const observation = r.observation_json === null ? null : parseObservation(JSON.parse(r.observation_json), plan, i);
|
|
112
|
+
if (observation?.safe) {
|
|
113
|
+
const e = safeEnvelopes.find(e => e.envelopeId === observation.safe!.envelopeId);
|
|
114
|
+
if (!e || i !== e.start + observation.safe.innerCallIndex || observation.safe.innerCallIndex >= e.count)
|
|
115
|
+
throw Error('Corrupt Safe observation range');
|
|
116
|
+
}
|
|
117
|
+
if (r.signing_request_id !== null)
|
|
118
|
+
nonempty(r.signing_request_id, 'signing request');
|
|
119
|
+
if ((r.state === 'signing' && (!unsigned || !r.signing_request_id || signed)) || (['signed', 'submission-uncertain'].includes(r.state) && !signed) || (signed && (!unsigned || !r.signing_request_id)))
|
|
120
|
+
throw new Error('Corrupt signing state');
|
|
121
|
+
if ((r.state === 'finalized-success') !== (i < row.completed_count) || (['included-unfinalized', 'finalized-success', 'finalized-reverted'].includes(r.state) && observation?.state !== r.state))
|
|
122
|
+
throw new Error('Corrupt observation prefix');
|
|
123
|
+
if (signed && observation && signed.transactionHash !== observation.transactionHash)
|
|
124
|
+
throw new Error('Corrupt signed observation binding');
|
|
125
|
+
return { transactionId: r.transaction_id, index: i, state: r.state, unsigned, unsignedDigest: r.unsigned_digest, signingRequestId: r.signing_request_id, signed, observation };
|
|
126
|
+
});
|
|
127
|
+
if (row.active_transaction_id !== null && row.active_transaction_id !== transactions[row.completed_count]?.transactionId)
|
|
128
|
+
throw new Error('Corrupt active transaction');
|
|
129
|
+
if (transactions.some((t, i) => i > row.completed_count && (t.unsigned || t.signed || t.observation || t.state !== 'claimed')))
|
|
130
|
+
throw new Error('Corrupt noncontiguous progress');
|
|
131
|
+
return deepFreeze({ executionId: id, contextHash: row.context_hash, planHash: row.plan_hash, plan, revision: row.revision, epoch: row.epoch, activeTransactionId: row.active_transaction_id, completedCount: row.completed_count, blockedReason: row.blocked_reason, transactions, safeEnvelopes });
|
|
132
|
+
}
|
|
133
|
+
/** Connections and claim maps never leave this object; JSON snapshots convey no live authority. */
|
|
134
|
+
export class ExecutionStore {
|
|
135
|
+
readonly #files: StoreFiles;
|
|
136
|
+
readonly #busy: number;
|
|
137
|
+
readonly #claims = new WeakMap<object, Session>();
|
|
138
|
+
constructor(files: StoreFiles, busy: number, private readonly DatabaseSync: Awaited<ReturnType<typeof sqliteConstructor>>) { this.#files = files; this.#busy = busy; }
|
|
139
|
+
async #locked<T>(callback: (db: Database) => Promise<T>): Promise<T> {
|
|
140
|
+
this.#files.verify();
|
|
141
|
+
const authority = new this.DatabaseSync(this.#files.authority);
|
|
142
|
+
let business: Database | undefined;
|
|
143
|
+
let held = false;
|
|
144
|
+
try {
|
|
145
|
+
configure(authority, this.#busy);
|
|
146
|
+
const protocol = bootstrapAuthority(authority, this.#files);
|
|
147
|
+
authority.exec('BEGIN IMMEDIATE');
|
|
148
|
+
held = true;
|
|
149
|
+
// Refresh under the bootstrap lock: a competitor may have completed initialization in the gap.
|
|
150
|
+
const actual = authority.prepare('SELECT * FROM protocol WHERE version=1').get() as unknown as typeof protocol;
|
|
151
|
+
if (actual.store_id !== protocol.store_id)
|
|
152
|
+
throw new Error('Authority bootstrap identity changed');
|
|
153
|
+
this.#files.ensureExecution(actual.phase === 'initializing');
|
|
154
|
+
business = new this.DatabaseSync(this.#files.execution);
|
|
155
|
+
configure(business, this.#busy);
|
|
156
|
+
initializeBusiness(authority, business, this.#files, actual);
|
|
157
|
+
authority.exec('COMMIT');
|
|
158
|
+
held = false;
|
|
159
|
+
this.#files.sync();
|
|
160
|
+
// The lifetime lock begins only after all bootstrap writes settle. No SQL on authority
|
|
161
|
+
// during the awaited callback, so business commits cannot end its private transaction.
|
|
162
|
+
authority.exec('BEGIN IMMEDIATE');
|
|
163
|
+
held = true;
|
|
164
|
+
this.#files.verify();
|
|
165
|
+
return await callback(business);
|
|
166
|
+
}
|
|
167
|
+
finally {
|
|
168
|
+
try {
|
|
169
|
+
business?.close();
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
try {
|
|
173
|
+
if (held)
|
|
174
|
+
authority.exec('ROLLBACK');
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
authority.close();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
async initialize(): Promise<void> { await this.#locked(async () => { }); }
|
|
183
|
+
async readExecution(executionId: string): Promise<ExecutionSnapshot | undefined> { nonempty(executionId, 'executionId'); return this.#locked(async (db) => snapshot(db, executionId)); }
|
|
184
|
+
async withExecutionClaim<T>(request: ClaimRequest, callback: (claim: ExecutionClaim, snapshot: ExecutionSnapshot) => Promise<T> | T): Promise<T> {
|
|
185
|
+
const plan = immutableDeliveryPlan(request.plan), contextHash = digest(request.contextHash, 'immutable execution context');
|
|
186
|
+
if (request.expectedRevision !== null)
|
|
187
|
+
decimal(request.expectedRevision, 'expected revision');
|
|
188
|
+
return this.#locked(async (db) => {
|
|
189
|
+
const initial = commit(db, this.#files, () => {
|
|
190
|
+
let previous = snapshot(db, plan.executionId);
|
|
191
|
+
if (previous) {
|
|
192
|
+
if (previous.planHash !== plan.planHash || !same(previous.plan, plan) || previous.contextHash !== contextHash)
|
|
193
|
+
throw new Error('Execution immutable identity conflict');
|
|
194
|
+
if (previous.revision !== request.expectedRevision)
|
|
195
|
+
throw new Error('Execution revision conflict');
|
|
196
|
+
changes(db.prepare('UPDATE executions SET epoch=?,revision=? WHERE execution_id=? AND revision=? AND epoch=? AND active_transaction_id IS ?').run((BigInt(previous.epoch) + 1n).toString(), (BigInt(previous.revision) + 1n).toString(), plan.executionId, previous.revision, previous.epoch, previous.activeTransactionId));
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
if (request.expectedRevision !== null)
|
|
200
|
+
throw new Error('Execution revision conflict');
|
|
201
|
+
db.prepare('INSERT INTO executions VALUES(?,?,?,?,?,?,?,?,?)').run(plan.executionId, contextHash, plan.planHash, canonicalJson(plan), '1', '1', null, 0, null);
|
|
202
|
+
for (const tx of plan.transactions)
|
|
203
|
+
db.prepare('INSERT INTO transactions VALUES(?,?,?,?,?,?,?,?,?)').run(plan.executionId, tx.transactionId, tx.transactionIndex, 'claimed', null, null, null, null, null);
|
|
204
|
+
}
|
|
205
|
+
return snapshot(db, plan.executionId)!;
|
|
206
|
+
});
|
|
207
|
+
const session: Session = { db, live: true, accepting: true, epoch: initial.epoch, executionId: plan.executionId, pending: new Set() };
|
|
208
|
+
const claim = Object.freeze(Object.create(null)) as ExecutionClaim;
|
|
209
|
+
this.#claims.set(claim, session);
|
|
210
|
+
try {
|
|
211
|
+
return await callback(claim, initial);
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
session.accepting = false;
|
|
215
|
+
session.live = false;
|
|
216
|
+
// A detached verification promise may not mutate after callback settlement. Retain the lock
|
|
217
|
+
// until all already-started trusted calls settle, and consume their rejections.
|
|
218
|
+
await Promise.allSettled([...session.pending]);
|
|
219
|
+
this.#claims.delete(claim);
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
#session(claim: ExecutionClaim): Session {
|
|
224
|
+
const s = claim && typeof claim === 'object' ? this.#claims.get(claim) : undefined;
|
|
225
|
+
if (!s?.live || !s.accepting)
|
|
226
|
+
throw new Error('Invalid or revoked live execution claim');
|
|
227
|
+
return s;
|
|
228
|
+
}
|
|
229
|
+
#current(claim: ExecutionClaim, revision: string): {
|
|
230
|
+
session: Session;
|
|
231
|
+
current: ExecutionSnapshot;
|
|
232
|
+
} {
|
|
233
|
+
const session = this.#session(claim);
|
|
234
|
+
decimal(revision, 'expected revision');
|
|
235
|
+
const current = snapshot(session.db, session.executionId)!;
|
|
236
|
+
if (current.blockedReason !== null)
|
|
237
|
+
throw new Error(`Execution blocked: ${current.blockedReason}`);
|
|
238
|
+
if (current.revision !== revision || current.epoch !== session.epoch)
|
|
239
|
+
throw new Error('Execution revision/epoch conflict');
|
|
240
|
+
return { session, current };
|
|
241
|
+
}
|
|
242
|
+
#mutate(session: Session, current: ExecutionSnapshot, active: string | null, completed: number, write: () => void): ExecutionSnapshot {
|
|
243
|
+
try {
|
|
244
|
+
return commit(session.db, this.#files, () => {
|
|
245
|
+
if (!session.live || !session.accepting)
|
|
246
|
+
throw new Error('Revoked execution claim');
|
|
247
|
+
changes(session.db.prepare('UPDATE executions SET revision=?,active_transaction_id=?,completed_count=? WHERE execution_id=? AND revision=? AND epoch=? AND active_transaction_id IS ?').run((BigInt(current.revision) + 1n).toString(), active, completed, current.executionId, current.revision, session.epoch, current.activeTransactionId));
|
|
248
|
+
write();
|
|
249
|
+
return snapshot(session.db, current.executionId)!;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
session.live = false;
|
|
254
|
+
throw e;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** Permanent fail-closed marker after a trusted verifier detects lost finalized progress. */
|
|
258
|
+
blockExecution(claim: ExecutionClaim, revision: string, reason: string): ExecutionSnapshot {
|
|
259
|
+
const { session, current } = this.#current(claim, revision);
|
|
260
|
+
nonempty(reason, 'execution block reason');
|
|
261
|
+
return this.#mutate(session, current, current.activeTransactionId, current.completedCount, () => {
|
|
262
|
+
changes(session.db.prepare('UPDATE executions SET blocked_reason=? WHERE execution_id=? AND blocked_reason IS NULL').run(reason, current.executionId));
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
freezeAndReserve(claim: ExecutionClaim, revision: string, transactionId: string, raw: unknown): ExecutionSnapshot {
|
|
266
|
+
const { session, current } = this.#current(claim, revision), tx = current.transactions[current.completedCount];
|
|
267
|
+
if (!tx || transactionId !== tx.transactionId || (current.activeTransactionId !== null && current.activeTransactionId !== transactionId))
|
|
268
|
+
throw new Error('Only the active contiguous-prefix transaction may freeze');
|
|
269
|
+
const unsigned = parseUnsigned(raw, current.plan, tx.index), unsignedDigest = unsignedHash(unsigned);
|
|
270
|
+
if (tx.unsigned) {
|
|
271
|
+
if (!same(tx.unsigned, unsigned))
|
|
272
|
+
throw new Error('Frozen unsigned envelope conflict');
|
|
273
|
+
return current;
|
|
274
|
+
}
|
|
275
|
+
if (tx.state !== 'claimed')
|
|
276
|
+
throw new Error('Transaction is blocked from freezing');
|
|
277
|
+
const reservation = session.db.prepare('SELECT * FROM nonce_reservations WHERE chain_id=? AND signer=? AND nonce=?').get(unsigned.chainId, unsigned.signer, unsigned.nonce);
|
|
278
|
+
if (reservation)
|
|
279
|
+
throw new Error('Nonce reservation conflict');
|
|
280
|
+
return this.#mutate(session, current, transactionId, current.completedCount, () => {
|
|
281
|
+
changes(session.db.prepare('UPDATE transactions SET unsigned_json=?,unsigned_digest=? WHERE execution_id=? AND transaction_id=? AND unsigned_json IS NULL').run(canonicalJson(unsigned), unsignedDigest, current.executionId, transactionId));
|
|
282
|
+
session.db.prepare('INSERT INTO nonce_reservations VALUES(?,?,?,?,?,?)').run(unsigned.chainId, unsigned.signer, unsigned.nonce, current.executionId, transactionId, unsignedDigest);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
markSigning(claim: ExecutionClaim, revision: string, stableRequestId: string): ExecutionSnapshot {
|
|
286
|
+
const { session, current } = this.#current(claim, revision), tx = this.#active(current);
|
|
287
|
+
nonempty(stableRequestId, 'stable signing request');
|
|
288
|
+
if (tx.state !== 'claimed' || !tx.unsigned)
|
|
289
|
+
throw new Error('Signing uncertainty or existing state forbids new signing permission');
|
|
290
|
+
return this.#mutate(session, current, tx.transactionId, current.completedCount, () => { changes(session.db.prepare("UPDATE transactions SET state='signing',signing_request_id=? WHERE execution_id=? AND transaction_id=? AND state='claimed'").run(stableRequestId, current.executionId, tx.transactionId)); });
|
|
291
|
+
}
|
|
292
|
+
commitSigned(claim: ExecutionClaim, revision: string, raw: unknown): ExecutionSnapshot {
|
|
293
|
+
const { session, current } = this.#current(claim, revision), tx = this.#active(current), signed = parseSigned(raw, tx.unsignedDigest ?? '');
|
|
294
|
+
if (tx.signed) {
|
|
295
|
+
if (!same(tx.signed, signed))
|
|
296
|
+
throw new Error('Original signed record conflict');
|
|
297
|
+
return current;
|
|
298
|
+
}
|
|
299
|
+
if (tx.state !== 'signing')
|
|
300
|
+
throw new Error('Signed record requires durable signing intent');
|
|
301
|
+
return this.#mutate(session, current, tx.transactionId, current.completedCount, () => { changes(session.db.prepare("UPDATE transactions SET state='signed',signed_json=? WHERE execution_id=? AND transaction_id=? AND signed_json IS NULL AND state='signing'").run(canonicalJson(signed), current.executionId, tx.transactionId)); });
|
|
302
|
+
}
|
|
303
|
+
recordSubmissionIntent(claim: ExecutionClaim, revision: string): ExecutionSnapshot {
|
|
304
|
+
const { session, current } = this.#current(claim, revision), tx = this.#active(current);
|
|
305
|
+
if (!tx.signed || tx.state !== 'signed')
|
|
306
|
+
throw new Error('Submission intent requires the original signed record and is not resend permission');
|
|
307
|
+
return this.#mutate(session, current, tx.transactionId, current.completedCount, () => { changes(session.db.prepare("UPDATE transactions SET state='submission-uncertain' WHERE execution_id=? AND transaction_id=? AND state='signed'").run(current.executionId, tx.transactionId)); });
|
|
308
|
+
}
|
|
309
|
+
/** The port, not this structural store, establishes chain truth. Caller-supplied JSON alone is rejected. */
|
|
310
|
+
recordObservation(claim: ExecutionClaim, revision: string, reference: string, trusted?: TrustedObservationPort): Promise<ExecutionSnapshot> {
|
|
311
|
+
let session: Session;
|
|
312
|
+
try {
|
|
313
|
+
session = this.#session(claim);
|
|
314
|
+
}
|
|
315
|
+
catch (e) {
|
|
316
|
+
return Promise.reject(e);
|
|
317
|
+
}
|
|
318
|
+
const run = async () => {
|
|
319
|
+
const { current } = this.#current(claim, revision);
|
|
320
|
+
nonempty(reference, 'observation reference');
|
|
321
|
+
if (typeof trusted?.readObservation !== 'function')
|
|
322
|
+
throw new Error('Observation requires trusted producer port');
|
|
323
|
+
const index = current.completedCount, tx = current.transactions[index];
|
|
324
|
+
if (!tx || tx.state === 'finalized-reverted' || tx.state === 'blocked')
|
|
325
|
+
throw new Error('Finalized or blocked execution cannot advance');
|
|
326
|
+
const observation = parseObservation(await trusted.readObservation(reference), current.plan, index);
|
|
327
|
+
this.#current(claim, revision);
|
|
328
|
+
if (observation.safe || current.safeEnvelopes.some(e => index >= e.start && index < e.start + e.count))
|
|
329
|
+
throw Error('Safe mapping requires atomic envelope observation');
|
|
330
|
+
if (observation.observationId !== reference)
|
|
331
|
+
throw new Error('Observation reference mismatch');
|
|
332
|
+
if (current.transactions.some((t, i) => i < index && t.observation?.transactionHash === observation.transactionHash))
|
|
333
|
+
throw new Error('Duplicate transaction hash already completed another plan entry');
|
|
334
|
+
if (tx.signed && tx.signed.transactionHash !== observation.transactionHash)
|
|
335
|
+
throw new Error('Observation differs from original signed hash');
|
|
336
|
+
if (tx.observation && same(tx.observation, observation))
|
|
337
|
+
return current;
|
|
338
|
+
const success = observation.state === 'finalized-success';
|
|
339
|
+
return this.#mutate(session, current, success ? null : tx.transactionId, index + (success ? 1 : 0), () => {
|
|
340
|
+
changes(session.db.prepare('UPDATE transactions SET state=?,observation_json=? WHERE execution_id=? AND transaction_id=?').run(observation.state, canonicalJson(observation), current.executionId, tx.transactionId));
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
const pending = run();
|
|
344
|
+
session.pending.add(pending);
|
|
345
|
+
pending.then(() => session.pending.delete(pending), () => session.pending.delete(pending));
|
|
346
|
+
return pending;
|
|
347
|
+
}
|
|
348
|
+
/** Freeze only the active original contiguous range; never replace a published nonce/envelope. */
|
|
349
|
+
freezeSafeEnvelope(claim: ExecutionClaim, revision: string, raw: unknown): ExecutionSnapshot {
|
|
350
|
+
const { session, current } = this.#current(claim, revision), e = parseSafeEnvelope(raw, current.plan), old = current.safeEnvelopes.find(x => x.start === e.start);
|
|
351
|
+
if (old) {
|
|
352
|
+
if (!same(old, e))
|
|
353
|
+
throw Error('Frozen Safe envelope conflict');
|
|
354
|
+
return current;
|
|
355
|
+
}
|
|
356
|
+
if (e.start !== current.completedCount || current.transactions.slice(e.start, e.start + e.count).some(t => t.state !== 'claimed' || t.unsigned || t.signed || t.observation) || current.safeEnvelopes.some(x => e.start < x.start + x.count && x.start < e.start + e.count))
|
|
357
|
+
throw Error('Only active pristine Safe range may freeze');
|
|
358
|
+
return this.#mutate(session, current, current.activeTransactionId, current.completedCount, () => { session.db.prepare('INSERT INTO safe_envelopes VALUES(?,?,?,?,?,?,?,?)').run(current.executionId, e.envelopeId, e.start, canonicalJson(e), e.chainId, e.safe, e.nonce, null); });
|
|
359
|
+
}
|
|
360
|
+
/** The complete batch is verified before one SQL commit; pending/reverted batches never map a prefix. */
|
|
361
|
+
recordSafeObservations(claim: ExecutionClaim, revision: string, envelopeId: string, trusted?: {
|
|
362
|
+
readSafeObservations(id: string): Promise<TransactionObservation[] | undefined>;
|
|
363
|
+
}): Promise<ExecutionSnapshot> {
|
|
364
|
+
let session: Session;
|
|
365
|
+
try {
|
|
366
|
+
session = this.#session(claim);
|
|
367
|
+
}
|
|
368
|
+
catch (e) {
|
|
369
|
+
return Promise.reject(e);
|
|
370
|
+
}
|
|
371
|
+
const run = async () => {
|
|
372
|
+
const { current } = this.#current(claim, revision), e = current.safeEnvelopes.find(e => e.envelopeId === envelopeId);
|
|
373
|
+
if (!e || e.start !== current.completedCount || typeof trusted?.readSafeObservations !== 'function')
|
|
374
|
+
throw Error('Active frozen Safe envelope and trusted observer required');
|
|
375
|
+
const raw = await trusted.readSafeObservations(envelopeId);
|
|
376
|
+
this.#current(claim, revision);
|
|
377
|
+
if (!Array.isArray(raw) || raw.length !== e.count)
|
|
378
|
+
throw Error('Incomplete Safe batch observation');
|
|
379
|
+
const observations = raw.map((o, i) => parseObservation(o, current.plan, e.start + i)), first = observations[0];
|
|
380
|
+
if (observations.some((o, i) => !o.safe || o.safe.envelopeId !== e.envelopeId || o.safe.innerCallIndex !== i || o.safe.transactionIndex !== first.safe?.transactionIndex || o.transactionHash !== first.transactionHash || o.blockHash !== first.blockHash || o.blockNumber !== first.blockNumber || o.state !== first.state || o.observationId !== `${e.envelopeId}@${o.transactionHash}/${i}`))
|
|
381
|
+
throw Error('Safe atomic batch identity mismatch');
|
|
382
|
+
if (current.transactions.some(t => t.observation?.transactionHash === first.transactionHash))
|
|
383
|
+
throw Error('Safe outer hash already consumed');
|
|
384
|
+
if (current.transactions.slice(e.start, e.start + e.count).some(t => t.state !== 'claimed' || t.unsigned || t.signed || t.observation))
|
|
385
|
+
throw Error('Safe range has existing independent effects');
|
|
386
|
+
if (first.state !== 'finalized-success')
|
|
387
|
+
return current;
|
|
388
|
+
return this.#mutate(session, current, null, e.start + e.count, () => { changes(session.db.prepare('UPDATE safe_envelopes SET outer_hash=? WHERE envelope_id=? AND outer_hash IS NULL').run(first.transactionHash, e.envelopeId)); for (const o of observations)
|
|
389
|
+
changes(session.db.prepare('UPDATE transactions SET state=?,observation_json=? WHERE execution_id=? AND transaction_id=?').run(o.state, canonicalJson(o), current.executionId, o.transaction.transactionId)); });
|
|
390
|
+
};
|
|
391
|
+
const pending = run();
|
|
392
|
+
session.pending.add(pending);
|
|
393
|
+
pending.then(() => session.pending.delete(pending), () => session.pending.delete(pending));
|
|
394
|
+
return pending;
|
|
395
|
+
}
|
|
396
|
+
#active(current: ExecutionSnapshot): TransactionRecord {
|
|
397
|
+
const tx = current.transactions[current.completedCount];
|
|
398
|
+
if (!tx || current.activeTransactionId !== tx.transactionId)
|
|
399
|
+
throw new Error('No active transaction');
|
|
400
|
+
return tx;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
export async function openExecutionStore(options: ExecutionStoreOptions): Promise<ExecutionStore> {
|
|
404
|
+
const DatabaseSync = await sqliteConstructor();
|
|
405
|
+
const timeout = options.busyTimeoutMs ?? 0;
|
|
406
|
+
if (!Number.isSafeInteger(timeout) || timeout < 0 || timeout > 60000)
|
|
407
|
+
throw new Error('Invalid busy timeout');
|
|
408
|
+
const store = new ExecutionStore(prepareStoreFiles(options.trustedRoot), timeout, DatabaseSync);
|
|
409
|
+
await store.initialize();
|
|
410
|
+
return store;
|
|
411
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Pure-call coverage from the accepted registration and owned compiler witness. No deployments are invented. */
|
|
2
|
+
import {artifactIdentity,parseTargetManifest,hashStorageLayout} from 'gate-evm-tools/workflow';
|
|
3
|
+
import {canonicalJson,semanticHash} from '../workflow/lib/canonicalData';
|
|
4
|
+
import {validateContractInfo} from '../workflow/lib/deployments';
|
|
5
|
+
import {validateDeploymentInfo} from '../workflow/lib/deploymentInfo';
|
|
6
|
+
import {byteHash} from './materialization';
|
|
7
|
+
import type {CompilerEvidence} from './compiler';
|
|
8
|
+
import type {DeliveryCollection} from './planning';
|
|
9
|
+
import type {ExpectedDevelopmentCode} from './check-code';
|
|
10
|
+
export function requiredExistingAddresses(collection:Pick<DeliveryCollection,'verification'>&{plan:Pick<DeliveryCollection['plan'],'transactions'|'transactionBindings'>}):string[]{
|
|
11
|
+
const {plan}=collection;return [...new Set([...collection.verification.map(a=>a.address.toLowerCase()),...plan.transactionBindings.filter(b=>b.role==='call').map(b=>plan.transactions.find(t=>t.transactionId===b.transactionId)!.to.toLowerCase())])];
|
|
12
|
+
}
|
|
13
|
+
export function existingCodeCoverage(input:{target:string;addresses:string[];registry:unknown;metadata:unknown;compiler:CompilerEvidence;manifests:Array<{path:string;contents:string}>}){
|
|
14
|
+
const registry=validateContractInfo(input.registry)[input.target]??{},metadata=validateDeploymentInfo(input.metadata).networks[input.target]??{};
|
|
15
|
+
const effective:Record<string,Record<string,string>>={[input.target]:{}},expected:ExpectedDevelopmentCode[]=[],artifacts:ReturnType<typeof artifactIdentity>[]=[],aliases:string[]=[],manifests:Array<{file:string;hash:string;layoutHash:string;proxy:string;implementation:string}>=[];
|
|
16
|
+
const local=(name:string)=>{
|
|
17
|
+
const entries=input.compiler.artifacts.filter(a=>name.includes(':')?a.fqn===name:a.artifact.contractName===name);if(entries.length!==1)throw Error('Missing unique compiled artifact for existing code');
|
|
18
|
+
const entry=entries[0],artifact=entry.artifact,build=input.compiler.builds.find(b=>b.digest===entry.buildInfo);
|
|
19
|
+
if(semanticHash(artifact)!==entry.digest||canonicalJson(JSON.parse(entry.contents))!==canonicalJson(artifact)||!build||byteHash(build.contents)!==build.digest||!JSON.parse(build.contents).output?.contracts?.[artifact.sourceName]?.[artifact.contractName])throw Error('Existing compiled artifact/build mismatch');
|
|
20
|
+
if(typeof artifact.deployedBytecode!=='string'||!/^0x(?:[a-fA-F0-9]{2})+$/.test(artifact.deployedBytecode))throw Error('Existing compiled runtime bytecode missing');
|
|
21
|
+
return artifact;
|
|
22
|
+
};
|
|
23
|
+
const add=(key:string,contract:string,address:string)=>{if(expected.some(e=>e.key===key))throw Error('Existing code coverage key collision');const artifact=local(contract);expected.push({key,contract:artifact.contractName,address:address.toLowerCase()});const identity=artifactIdentity(artifact,'evm');if(!artifacts.some(a=>canonicalJson(a)===canonicalJson(identity)))artifacts.push(identity);};
|
|
24
|
+
for(const address of new Set(input.addresses.map(a=>a.toLowerCase()))){
|
|
25
|
+
const matches=Object.entries(registry).filter(([,a])=>a.toLowerCase()===address);if(matches.length!==1)throw Error('Existing code target requires unique frozen registration');
|
|
26
|
+
const [key]=matches[0],alias=key.split(':')[0],m=metadata[alias],contract=m?.actualContract??key.split(':').at(-1)!;
|
|
27
|
+
if(m&&(m.contractInfoKey!==key||m.address.toLowerCase()!==address))throw Error('Existing code metadata registration mismatch');
|
|
28
|
+
aliases.push(alias);effective[input.target][key]=address;
|
|
29
|
+
if(m?.proxyKind&&m.proxyKind!=='uups')throw Error('Unsupported existing proxy kind');
|
|
30
|
+
if(m?.proxyKind==='uups'){
|
|
31
|
+
const implementation=m.implementationAddress!.toLowerCase();add(alias,contract,implementation);add(`${alias}_Proxy`,'ERC1967Proxy',address);
|
|
32
|
+
const owned=input.manifests.flatMap(file=>{const manifest=parseTargetManifest(Buffer.from(file.contents));const proxies=manifest.proxies.filter(p=>p.address.toLowerCase()===address),impls=Object.entries(manifest.impls).filter(([,v])=>v&&[v.address,...(v.allAddresses??[])].some(a=>a.toLowerCase()===implementation));return proxies.length===1&&proxies[0].kind==='uups'&&impls.length===1?[{file:file.path,hash:byteHash(file.contents),layoutHash:hashStorageLayout(impls[0][1]!.layout),proxy:address,implementation}]:[];});
|
|
33
|
+
if(owned.length!==1)throw Error('Missing unique sealed existing UUPS manifest');manifests.push(owned[0]);
|
|
34
|
+
}else add(alias,contract,address);
|
|
35
|
+
}
|
|
36
|
+
if(!expected.length)throw Error('Empty existing code coverage');return {effective,expected,artifacts,aliases,manifests};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Called only by the owned worker while the actual compiler artifact reader is installed. */
|
|
40
|
+
export async function collectExistingCodeArtifacts(input:{target:string;addresses:string[];registry:unknown;metadata:unknown;readArtifact(name:string):Promise<unknown>}){
|
|
41
|
+
const registry=validateContractInfo(input.registry)[input.target]??{},metadata=validateDeploymentInfo(input.metadata).networks[input.target]??{},names=new Set<string>();
|
|
42
|
+
for(const address of new Set(input.addresses.map(a=>a.toLowerCase()))){const entries=Object.entries(registry).filter(([,a])=>a.toLowerCase()===address);if(entries.length!==1)throw Error('Existing code target requires unique frozen registration');const [key]=entries[0],m=metadata[key.split(':')[0]];names.add(m?.actualContract??key.split(':').at(-1)!);if(m?.proxyKind==='uups')names.add('@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol:ERC1967Proxy');}
|
|
43
|
+
for(const name of names)await input.readArtifact(name);
|
|
44
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** Independent artifact delivery: no planning, execution, chain access or filesystem effects. */
|
|
2
|
+
import { canonicalJson, deepFreeze, nonempty } from '../workflow/lib/canonicalData';
|
|
3
|
+
import { strictData } from './data';
|
|
4
|
+
import { parseDeliveryPlan, type DeliveryPlan } from './plan';
|
|
5
|
+
import { parseObservation, type TransactionObservation, type TrustedFinalizedProgressPort } from './observations';
|
|
6
|
+
export type { TrustedFinalizedProgressPort, TransactionObservation } from './observations';
|
|
7
|
+
export interface DeliveryExportModel {
|
|
8
|
+
version: 1;
|
|
9
|
+
schema: 'gate-delivery-export';
|
|
10
|
+
status: 'artifact-delivered';
|
|
11
|
+
/** Self-consistency is not host authorization or externally validated release readiness. */
|
|
12
|
+
plan: DeliveryPlan;
|
|
13
|
+
fullRange: {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
};
|
|
17
|
+
actionableRange: {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
} | null;
|
|
21
|
+
completed: TransactionObservation[];
|
|
22
|
+
dependencies: {
|
|
23
|
+
transactionId: string;
|
|
24
|
+
after: string[];
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
27
|
+
/** Require canonical sealed input without silently normalizing quantities, case or ordering. */
|
|
28
|
+
export function immutableDeliveryPlan(raw: unknown): DeliveryPlan {
|
|
29
|
+
const data = strictData(raw, 'sealed delivery plan'), plan = parseDeliveryPlan(data);
|
|
30
|
+
if (canonicalJson(data) !== canonicalJson(plan))
|
|
31
|
+
throw new Error('Expected canonical immutable delivery plan');
|
|
32
|
+
return plan;
|
|
33
|
+
}
|
|
34
|
+
declare const progressBrand: unique symbol;
|
|
35
|
+
export interface ValidatedDeliveryProgress {
|
|
36
|
+
readonly [progressBrand]: true;
|
|
37
|
+
}
|
|
38
|
+
const trustedProgress = new WeakMap<object, TransactionObservation[]>();
|
|
39
|
+
const progressPlans = new WeakMap<object, string>();
|
|
40
|
+
/** Explicit trusted I/O boundary, separate from formatting. Only this live result can mark completion. */
|
|
41
|
+
export async function validateDeliveryProgress(input: {
|
|
42
|
+
plan: unknown;
|
|
43
|
+
completed?: readonly string[];
|
|
44
|
+
finalized?: TrustedFinalizedProgressPort;
|
|
45
|
+
}): Promise<ValidatedDeliveryProgress> {
|
|
46
|
+
const plan = immutableDeliveryPlan(input.plan), references = strictData(input.completed ?? [], 'completed observation references');
|
|
47
|
+
if (!Array.isArray(references) || references.length > plan.transactions.length)
|
|
48
|
+
throw new Error('Invalid completed prefix');
|
|
49
|
+
if (references.length && typeof input.finalized?.readFinalized !== 'function')
|
|
50
|
+
throw new Error('Completed progress requires trusted finalized provenance');
|
|
51
|
+
const completed: TransactionObservation[] = [];
|
|
52
|
+
const seen = new Set<string>();
|
|
53
|
+
for (const [i, ref] of references.entries()) {
|
|
54
|
+
nonempty(ref, 'observation reference');
|
|
55
|
+
if (seen.has(ref))
|
|
56
|
+
throw new Error('Duplicate completed observation');
|
|
57
|
+
seen.add(ref);
|
|
58
|
+
const o = parseObservation(await input.finalized!.readFinalized(ref), plan, i);
|
|
59
|
+
if (o.observationId !== ref || o.state !== 'finalized-success')
|
|
60
|
+
throw new Error('Completed prefix requires verified finalized success');
|
|
61
|
+
completed.push(o);
|
|
62
|
+
}
|
|
63
|
+
const token = Object.freeze(Object.create(null)) as ValidatedDeliveryProgress;
|
|
64
|
+
trustedProgress.set(token, deepFreeze(completed));
|
|
65
|
+
progressPlans.set(token, plan.planHash);
|
|
66
|
+
return token;
|
|
67
|
+
}
|
|
68
|
+
/** Pure renderer. No callback, filesystem or chain access; serialized tokens convey no provenance. */
|
|
69
|
+
export function renderDeliveryExport(rawPlan: unknown, progress?: ValidatedDeliveryProgress): {
|
|
70
|
+
model: DeliveryExportModel;
|
|
71
|
+
json: string;
|
|
72
|
+
markdown: string;
|
|
73
|
+
} {
|
|
74
|
+
const plan = immutableDeliveryPlan(rawPlan);
|
|
75
|
+
const completed = progress === undefined ? [] : trustedProgress.get(progress);
|
|
76
|
+
if (!completed || (progress !== undefined && progressPlans.get(progress) !== plan.planHash))
|
|
77
|
+
throw new Error('Untrusted or mismatched validated progress');
|
|
78
|
+
const start = completed.length;
|
|
79
|
+
let end = start;
|
|
80
|
+
if (start < plan.transactions.length) {
|
|
81
|
+
const first = plan.transactions[start];
|
|
82
|
+
while (end < plan.transactions.length && plan.transactions[end].route === first.route && plan.transactions[end].executor === first.executor)
|
|
83
|
+
end++;
|
|
84
|
+
}
|
|
85
|
+
const model: DeliveryExportModel = deepFreeze({ version: 1, schema: 'gate-delivery-export', status: 'artifact-delivered', plan, fullRange: { start: 0, end: plan.transactions.length }, actionableRange: start === end ? null : { start, end }, completed, dependencies: plan.transactions.map((tx, i) => ({ transactionId: tx.transactionId, after: i ? [plan.transactions[i - 1].transactionId] : [] })) });
|
|
86
|
+
const json = canonicalJson(model);
|
|
87
|
+
// One complete canonical model in both formats prevents abbreviated calldata or split projections.
|
|
88
|
+
const markdown = `# Delivery calldata\n\nArtifact delivered. This export does not indicate deployment or grant execution authority.\n\nFull range: [${model.fullRange.start}, ${model.fullRange.end}).\nCurrent actionable range: ${model.actionableRange ? `[${start}, ${end})` : 'none'}. All transactions follow their predecessors.\n\n\`\`\`json\n${json}\n\`\`\`\n`;
|
|
89
|
+
return deepFreeze({ model, json, markdown });
|
|
90
|
+
}
|
|
91
|
+
/** Convenience wrapper: resolves trusted provenance first, then invokes the pure renderer. */
|
|
92
|
+
export async function exportDelivery(input: {
|
|
93
|
+
plan: unknown;
|
|
94
|
+
completed?: readonly string[];
|
|
95
|
+
finalized?: TrustedFinalizedProgressPort;
|
|
96
|
+
}) {
|
|
97
|
+
const plan = immutableDeliveryPlan(input.plan);
|
|
98
|
+
return renderDeliveryExport(plan, await validateDeliveryProgress({ ...input, plan }));
|
|
99
|
+
}
|