@openzeppelin/compact-deployer 0.2.0
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/CHANGELOG.md +33 -0
- package/README.md +304 -0
- package/dist/config/compact-config.d.ts +31 -0
- package/dist/config/compact-config.js +123 -0
- package/dist/config/compact-config.js.map +1 -0
- package/dist/config/schema.d.ts +688 -0
- package/dist/config/schema.js +90 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/deployer.d.ts +154 -0
- package/dist/deployer.js +916 -0
- package/dist/deployer.js.map +1 -0
- package/dist/deployments.d.ts +119 -0
- package/dist/deployments.js +144 -0
- package/dist/deployments.js.map +1 -0
- package/dist/errors.d.ts +94 -0
- package/dist/errors.js +124 -0
- package/dist/errors.js.map +1 -0
- package/dist/loaders/args.d.ts +22 -0
- package/dist/loaders/args.js +72 -0
- package/dist/loaders/args.js.map +1 -0
- package/dist/loaders/argv.d.ts +36 -0
- package/dist/loaders/argv.js +101 -0
- package/dist/loaders/argv.js.map +1 -0
- package/dist/loaders/artifact-path.d.ts +16 -0
- package/dist/loaders/artifact-path.js +35 -0
- package/dist/loaders/artifact-path.js.map +1 -0
- package/dist/loaders/artifact.d.ts +43 -0
- package/dist/loaders/artifact.js +115 -0
- package/dist/loaders/artifact.js.map +1 -0
- package/dist/loaders/constructor-meta.d.ts +17 -0
- package/dist/loaders/constructor-meta.js +99 -0
- package/dist/loaders/constructor-meta.js.map +1 -0
- package/dist/loaders/context.d.ts +14 -0
- package/dist/loaders/context.js +43 -0
- package/dist/loaders/context.js.map +1 -0
- package/dist/loaders/contract-resolve.d.ts +15 -0
- package/dist/loaders/contract-resolve.js +53 -0
- package/dist/loaders/contract-resolve.js.map +1 -0
- package/dist/loaders/init-state.d.ts +8 -0
- package/dist/loaders/init-state.js +37 -0
- package/dist/loaders/init-state.js.map +1 -0
- package/dist/loaders/ref-resolver.d.ts +8 -0
- package/dist/loaders/ref-resolver.js +27 -0
- package/dist/loaders/ref-resolver.js.map +1 -0
- package/dist/loaders/signing-key.d.ts +10 -0
- package/dist/loaders/signing-key.js +23 -0
- package/dist/loaders/signing-key.js.map +1 -0
- package/dist/providers/build.d.ts +20 -0
- package/dist/providers/build.js +41 -0
- package/dist/providers/build.js.map +1 -0
- package/dist/providers/network.d.ts +6 -0
- package/dist/providers/network.js +36 -0
- package/dist/providers/network.js.map +1 -0
- package/dist/providers/private-state-password.d.ts +12 -0
- package/dist/providers/private-state-password.js +27 -0
- package/dist/providers/private-state-password.js.map +1 -0
- package/dist/providers/proof-server.d.ts +29 -0
- package/dist/providers/proof-server.js +97 -0
- package/dist/providers/proof-server.js.map +1 -0
- package/dist/runDeploy.d.ts +167 -0
- package/dist/runDeploy.js +228 -0
- package/dist/runDeploy.js.map +1 -0
- package/dist/services/atomic-json.d.ts +7 -0
- package/dist/services/atomic-json.js +34 -0
- package/dist/services/atomic-json.js.map +1 -0
- package/dist/services/chain-state.d.ts +75 -0
- package/dist/services/chain-state.js +151 -0
- package/dist/services/chain-state.js.map +1 -0
- package/dist/services/contract-state.d.ts +29 -0
- package/dist/services/contract-state.js +54 -0
- package/dist/services/contract-state.js.map +1 -0
- package/dist/services/deploy-plan.d.ts +36 -0
- package/dist/services/deploy-plan.js +45 -0
- package/dist/services/deploy-plan.js.map +1 -0
- package/dist/services/deploy-tx.d.ts +189 -0
- package/dist/services/deploy-tx.js +297 -0
- package/dist/services/deploy-tx.js.map +1 -0
- package/dist/services/error-format.d.ts +10 -0
- package/dist/services/error-format.js +91 -0
- package/dist/services/error-format.js.map +1 -0
- package/dist/services/file-lock.d.ts +23 -0
- package/dist/services/file-lock.js +90 -0
- package/dist/services/file-lock.js.map +1 -0
- package/dist/services/maintenance-tx.d.ts +49 -0
- package/dist/services/maintenance-tx.js +43 -0
- package/dist/services/maintenance-tx.js.map +1 -0
- package/dist/services/wallet-cache.d.ts +99 -0
- package/dist/services/wallet-cache.js +239 -0
- package/dist/services/wallet-cache.js.map +1 -0
- package/dist/services/wallet-sync.d.ts +89 -0
- package/dist/services/wallet-sync.js +249 -0
- package/dist/services/wallet-sync.js.map +1 -0
- package/dist/wallet/handler.d.ts +64 -0
- package/dist/wallet/handler.js +151 -0
- package/dist/wallet/handler.js.map +1 -0
- package/dist/wallet/keystore.d.ts +55 -0
- package/dist/wallet/keystore.js +213 -0
- package/dist/wallet/keystore.js.map +1 -0
- package/dist/wallet/seeds.d.ts +41 -0
- package/dist/wallet/seeds.js +84 -0
- package/dist/wallet/seeds.js.map +1 -0
- package/package.json +133 -0
- package/proof-server.yml +16 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
53
|
+
import pino, {} from 'pino';
|
|
54
|
+
import { CompactConfig } from "./config/compact-config.js";
|
|
55
|
+
import { Deployer } from "./deployer.js";
|
|
56
|
+
import { DeployError, FragmentDeployError } from "./errors.js";
|
|
57
|
+
import { parseDeployArgv } from "./loaders/argv.js";
|
|
58
|
+
import { resolveContractName } from "./loaders/contract-resolve.js";
|
|
59
|
+
import { formatError } from "./services/error-format.js";
|
|
60
|
+
/**
|
|
61
|
+
* Typed constructor-args helper. Returns the args tuple unchanged at
|
|
62
|
+
* runtime; the work happens in the type system: `Contract` anchors
|
|
63
|
+
* the generic so each subsequent arg is checked against the matching
|
|
64
|
+
* position in `initialState`, and the editor shows the param name +
|
|
65
|
+
* type as you type each comma (TypeScript signature help works on
|
|
66
|
+
* function calls but not on tuple literals — that's why this exists
|
|
67
|
+
* instead of just `args: [...]`).
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { runDeploy, constructorArgs } from '@openzeppelin/compact-deployer/run-deploy';
|
|
72
|
+
* import { Contract } from '../artifacts/Token/contract/index.js';
|
|
73
|
+
*
|
|
74
|
+
* await runDeploy({
|
|
75
|
+
* contract: 'Token',
|
|
76
|
+
* args: constructorArgs(Contract,
|
|
77
|
+
* 'OpenZeppelin Token', // _name: string
|
|
78
|
+
* 'OZE', // _symbol: string
|
|
79
|
+
* 18n, // _decimals: bigint
|
|
80
|
+
* ),
|
|
81
|
+
* });
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export function constructorArgs(_Contract, ...args) {
|
|
85
|
+
return args;
|
|
86
|
+
}
|
|
87
|
+
export function runDeploy(arg, opts2) {
|
|
88
|
+
if (isContractClass(arg)) {
|
|
89
|
+
const Contract = arg;
|
|
90
|
+
return (...args) => runDeployImpl({
|
|
91
|
+
...(opts2 ?? {}),
|
|
92
|
+
contract: '',
|
|
93
|
+
args,
|
|
94
|
+
}, Contract);
|
|
95
|
+
}
|
|
96
|
+
return runDeployImpl(arg);
|
|
97
|
+
}
|
|
98
|
+
function isContractClass(x) {
|
|
99
|
+
return (typeof x === 'function' &&
|
|
100
|
+
typeof x.prototype
|
|
101
|
+
?.initialState === 'function');
|
|
102
|
+
}
|
|
103
|
+
async function runDeployImpl(opts, Contract) {
|
|
104
|
+
const argv = parseDeployArgv(process.argv.slice(2));
|
|
105
|
+
const json = opts.json ?? argv.json;
|
|
106
|
+
const verbose = opts.verbose ?? argv.verbose;
|
|
107
|
+
const dryRun = opts.dryRun ?? argv.dryRun;
|
|
108
|
+
const syncTimeoutSec = opts.syncTimeoutSec ?? argv.syncTimeoutSec;
|
|
109
|
+
const txTimeoutSec = opts.txTimeoutSec ?? argv.txTimeoutSec;
|
|
110
|
+
const logger = opts.logger ?? buildLogger({ json, verbose });
|
|
111
|
+
const configPath = opts.configPath ?? argv.configPath;
|
|
112
|
+
try {
|
|
113
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
114
|
+
try {
|
|
115
|
+
// Curried form: resolve the Contract class to the matching
|
|
116
|
+
// [contracts.X] entry in compact.toml by identity.
|
|
117
|
+
let contractName = opts.contract;
|
|
118
|
+
if (Contract) {
|
|
119
|
+
const config = await CompactConfig.load(configPath);
|
|
120
|
+
contractName = await resolveContractName(Contract, config, config.rootDir);
|
|
121
|
+
}
|
|
122
|
+
const deployer = __addDisposableResource(env_1, await Deployer.prepare({
|
|
123
|
+
contract: contractName,
|
|
124
|
+
network: opts.network ?? argv.network,
|
|
125
|
+
configPath,
|
|
126
|
+
seedFile: opts.seedFile ?? argv.seedFile,
|
|
127
|
+
proofServer: opts.proofServer ?? argv.proofServer,
|
|
128
|
+
args: opts.args,
|
|
129
|
+
syncTimeoutMs: syncTimeoutSec !== undefined ? syncTimeoutSec * 1000 : undefined,
|
|
130
|
+
txTimeoutMs: txTimeoutSec !== undefined ? txTimeoutSec * 1000 : undefined,
|
|
131
|
+
force: opts.force ?? argv.force,
|
|
132
|
+
syncBatchSize: opts.syncBatchSize ?? argv.syncBatchSize,
|
|
133
|
+
circuitsPerTx: opts.circuitsPerTx ?? argv.circuitsPerTx,
|
|
134
|
+
skipWalletCache: opts.skipWalletCache ?? argv.noCache,
|
|
135
|
+
seedCacheDust: opts.seedCacheFromDust ?? argv.seedCacheFromDust,
|
|
136
|
+
seedCacheShielded: opts.seedCacheFromShielded ?? argv.seedCacheFromShielded,
|
|
137
|
+
seedCacheUnshielded: opts.seedCacheFromUnshielded ?? argv.seedCacheFromUnshielded,
|
|
138
|
+
promptPassphrase: opts.promptPassphrase,
|
|
139
|
+
logger,
|
|
140
|
+
}), true);
|
|
141
|
+
const result = dryRun ? await deployer.dryRun() : await deployer.deploy();
|
|
142
|
+
printResult(result, { json, logger });
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
catch (e_1) {
|
|
146
|
+
env_1.error = e_1;
|
|
147
|
+
env_1.hasError = true;
|
|
148
|
+
}
|
|
149
|
+
finally {
|
|
150
|
+
const result_1 = __disposeResources(env_1);
|
|
151
|
+
if (result_1)
|
|
152
|
+
await result_1;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
handleError(e, { json, verbose, logger });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
// Helpers
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
function buildLogger(opts) {
|
|
163
|
+
// Always stderr: `--json` reserves stdout for the single result object,
|
|
164
|
+
// and a deploy script's log lines must not corrupt a caller's pipe.
|
|
165
|
+
return pino({
|
|
166
|
+
level: opts.verbose ? 'debug' : 'info',
|
|
167
|
+
}, pino.destination(2));
|
|
168
|
+
}
|
|
169
|
+
function printResult(result, opts) {
|
|
170
|
+
if (opts.json) {
|
|
171
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (result.dryRun) {
|
|
175
|
+
opts.logger.info(`Dry-run for ${result.contractName} on ${result.network} OK`);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
opts.logger.info(`${result.contractName} deployed on ${result.network}: ${result.address}`);
|
|
179
|
+
opts.logger.info(` txId: ${result.txId}`);
|
|
180
|
+
opts.logger.info(` txHash: ${result.txHash}`);
|
|
181
|
+
opts.logger.info(` blockHeight: ${result.blockHeight}`);
|
|
182
|
+
opts.logger.info(` saved to: ${result.deploymentsFile}`);
|
|
183
|
+
if (result.explorerUrl) {
|
|
184
|
+
opts.logger.info(` explorer: ${result.explorerUrl}`);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Report the failure and set the process exit code, then rethrow the
|
|
189
|
+
* original error. Deliberately does not call `process.exit`: `runDeploy` is
|
|
190
|
+
* a library entrypoint, and a script embedding it must keep its own cleanup
|
|
191
|
+
* and error handling. `code` reaches the shell only for a caller that
|
|
192
|
+
* catches and lets the process end normally; an uncaught rethrow takes
|
|
193
|
+
* Node's unhandled-rejection path and exits 1.
|
|
194
|
+
*/
|
|
195
|
+
/**
|
|
196
|
+
* A stopped fragmented deploy is resumable, so a `--json` consumer needs the
|
|
197
|
+
* address and both circuit lists as data rather than parsed out of the message.
|
|
198
|
+
*/
|
|
199
|
+
function fragmentFields(e) {
|
|
200
|
+
if (!(e instanceof FragmentDeployError))
|
|
201
|
+
return {};
|
|
202
|
+
return {
|
|
203
|
+
address: e.address,
|
|
204
|
+
circuitsOnChain: e.circuitsOnChain,
|
|
205
|
+
circuitsPending: e.circuitsPending,
|
|
206
|
+
...(e.txId !== undefined ? { txId: e.txId } : {}),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
function handleError(e, opts) {
|
|
210
|
+
const code = e instanceof DeployError ? e.exitCode : 1;
|
|
211
|
+
const name = e instanceof Error ? e.name : 'Error';
|
|
212
|
+
// `formatError` only on the non-Error arm: a DeployError already embeds its
|
|
213
|
+
// cause in `message`. The arm that matters is the wallet SDK's tagged
|
|
214
|
+
// records, which `String(e)` rendered as `[object Object]`.
|
|
215
|
+
const message = e instanceof Error ? e.message : formatError(e);
|
|
216
|
+
if (opts.json) {
|
|
217
|
+
process.stdout.write(`${JSON.stringify({ error: name, message, exitCode: code, ...fragmentFields(e) })}\n`);
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
opts.logger.error({ err: message }, `Deploy failed: ${name}`);
|
|
221
|
+
if (opts.verbose && e instanceof Error && e.stack) {
|
|
222
|
+
opts.logger.debug(e.stack);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
process.exitCode = code;
|
|
226
|
+
throw e;
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=runDeploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runDeploy.js","sourceRoot":"","sources":["../src/runD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AAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse `path`, or return `fallback` when it is absent or blank. A malformed
|
|
3
|
+
* document is a typed failure naming the file: the raw `SyntaxError` says only
|
|
4
|
+
* "Unexpected token" and leaves the user hunting for which file to fix.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readJson<T>(path: string, fallback: T): Promise<T>;
|
|
7
|
+
export declare function writeJson(path: string, value: unknown): Promise<void>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { dirname } from 'node:path';
|
|
5
|
+
import { DeploymentsFileError } from "../errors.js";
|
|
6
|
+
/**
|
|
7
|
+
* Parse `path`, or return `fallback` when it is absent or blank. A malformed
|
|
8
|
+
* document is a typed failure naming the file: the raw `SyntaxError` says only
|
|
9
|
+
* "Unexpected token" and leaves the user hunting for which file to fix.
|
|
10
|
+
*/
|
|
11
|
+
export async function readJson(path, fallback) {
|
|
12
|
+
if (!existsSync(path))
|
|
13
|
+
return fallback;
|
|
14
|
+
const raw = await readFile(path, 'utf8');
|
|
15
|
+
if (!raw.trim())
|
|
16
|
+
return fallback;
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(raw);
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
throw new DeploymentsFileError(`${path} is not valid JSON: ${e.message}. Repair or delete the file, then re-run.`, { cause: e });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Write atomically: a crash mid-write would otherwise leave a truncated
|
|
25
|
+
// `*.json`, breaking subsequent reads and losing durable deploy state.
|
|
26
|
+
// Write to a sibling temp file, then rename it into place (atomic on the
|
|
27
|
+
// same filesystem).
|
|
28
|
+
export async function writeJson(path, value) {
|
|
29
|
+
await mkdir(dirname(path), { recursive: true });
|
|
30
|
+
const tmp = `${path}.${randomUUID()}.tmp`;
|
|
31
|
+
await writeFile(tmp, `${JSON.stringify(value, null, 2)}\n`);
|
|
32
|
+
await rename(tmp, path);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=atomic-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-json.js","sourceRoot":"","sources":["../../src/services/atomic-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAI,IAAY,EAAE,QAAW;IACzD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC;IACvC,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE;QAAE,OAAO,QAAQ,CAAC;IACjC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAM,CAAC;IAC9B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,oBAAoB,CAC5B,GAAG,IAAI,uBAAwB,CAAW,CAAC,OAAO,2CAA2C,EAC7F,EAAE,KAAK,EAAE,CAAC,EAAE,CACb,CAAC;IACJ,CAAC;AACH,CAAC;AAED,wEAAwE;AACxE,uEAAuE;AACvE,yEAAyE;AACzE,oBAAoB;AACpB,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY,EAAE,KAAc;IAC1D,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,GAAG,IAAI,IAAI,UAAU,EAAE,MAAM,CAAC;IAC1C,MAAM,SAAS,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain-side reads for the fragmented deploy: what is on chain, whether it is
|
|
3
|
+
* ours, and whether it matches the artifact byte for byte.
|
|
4
|
+
*
|
|
5
|
+
* The deployments file is reporting only. Every decision the fragment loop
|
|
6
|
+
* makes about which circuits to insert comes from here.
|
|
7
|
+
*/
|
|
8
|
+
import type { PublicDataProvider } from '@midnight-ntwrk/midnight-js-types';
|
|
9
|
+
import type { ArtifactKeys } from '../loaders/artifact.ts';
|
|
10
|
+
/** One chain read of a contract's operations and maintenance authority. */
|
|
11
|
+
export interface ChainSnapshot {
|
|
12
|
+
readonly circuits: readonly string[];
|
|
13
|
+
readonly verifierKeys: ReadonlyMap<string, Uint8Array>;
|
|
14
|
+
readonly counter: bigint;
|
|
15
|
+
readonly committee: readonly string[];
|
|
16
|
+
readonly threshold: number;
|
|
17
|
+
}
|
|
18
|
+
/** Snapshot of `address`, or `undefined` when no contract exists there. */
|
|
19
|
+
export declare function readSnapshot(publicDataProvider: PublicDataProvider, address: string): Promise<ChainSnapshot | undefined>;
|
|
20
|
+
export interface AwaitCircuitsArgs {
|
|
21
|
+
publicDataProvider: PublicDataProvider;
|
|
22
|
+
address: string;
|
|
23
|
+
/** Circuits the just-finalized fragment inserted. */
|
|
24
|
+
expected: readonly string[];
|
|
25
|
+
timeoutMs: number;
|
|
26
|
+
pollMs?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Poll until every circuit of the landed fragment is visible, then
|
|
30
|
+
* return that snapshot.
|
|
31
|
+
*
|
|
32
|
+
* The indexer trails the node, so the read taken right after finalization can
|
|
33
|
+
* still be the pre-fragment state. Computing the next fragment from it would
|
|
34
|
+
* re-insert keys that are already on chain and abort a healthy deploy.
|
|
35
|
+
*/
|
|
36
|
+
export declare function awaitCircuitsOnChain({ publicDataProvider, address, expected, timeoutMs, pollMs, }: AwaitCircuitsArgs): Promise<ChainSnapshot>;
|
|
37
|
+
export interface VerifyStateArgs {
|
|
38
|
+
address: string;
|
|
39
|
+
artifactKeys: ArtifactKeys;
|
|
40
|
+
snapshot: ChainSnapshot;
|
|
41
|
+
/** The authority read before the first insert. It must not move. */
|
|
42
|
+
authority: Pick<ChainSnapshot, 'committee' | 'threshold'>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Every artifact circuit present on chain with identical key bytes,
|
|
46
|
+
* and no extra on-chain circuit. A count check would pass a state that has the
|
|
47
|
+
* right number of operations under the wrong names.
|
|
48
|
+
*/
|
|
49
|
+
export declare function verifyState({ address, artifactKeys, snapshot, authority, }: VerifyStateArgs): void;
|
|
50
|
+
/**
|
|
51
|
+
* This signing key's slot in the on-chain committee.
|
|
52
|
+
*
|
|
53
|
+
* Rejects a committee this deployer cannot satisfy alone: it holds one key, so
|
|
54
|
+
* a threshold above 1 makes every update unsignable here.
|
|
55
|
+
*/
|
|
56
|
+
export declare function signerIndex({ address, snapshot, verifyingKey, }: {
|
|
57
|
+
address: string;
|
|
58
|
+
snapshot: ChainSnapshot;
|
|
59
|
+
/** Public half of the loaded signing key. Never the signing key. */
|
|
60
|
+
verifyingKey: string;
|
|
61
|
+
}): number;
|
|
62
|
+
export interface AssertResumableArgs {
|
|
63
|
+
address: string;
|
|
64
|
+
artifactKeys: ArtifactKeys;
|
|
65
|
+
snapshot: ChainSnapshot | undefined;
|
|
66
|
+
/** Verifying key derived from the loaded signing key. Never the signing key. */
|
|
67
|
+
verifyingKey: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Gate a resume on the recorded address really being our partially
|
|
71
|
+
* deployed contract. An edited or copied deployments file must not make the deployer
|
|
72
|
+
* append this artifact's keys to someone else's contract, or to a stale build
|
|
73
|
+
* of our own.
|
|
74
|
+
*/
|
|
75
|
+
export declare function assertResumable({ address, artifactKeys, snapshot, verifyingKey, }: AssertResumableArgs): ChainSnapshot;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chain-side reads for the fragmented deploy: what is on chain, whether it is
|
|
3
|
+
* ours, and whether it matches the artifact byte for byte.
|
|
4
|
+
*
|
|
5
|
+
* The deployments file is reporting only. Every decision the fragment loop
|
|
6
|
+
* makes about which circuits to insert comes from here.
|
|
7
|
+
*/
|
|
8
|
+
import { verifierKeysEqual } from '@midnight-ntwrk/midnight-js-contracts';
|
|
9
|
+
import { ConfigError, FragmentDeployError } from "../errors.js";
|
|
10
|
+
import { operationNames } from "./contract-state.js";
|
|
11
|
+
import { remaining, sortCircuits } from "./deploy-plan.js";
|
|
12
|
+
/** Default gap between chain re-reads while waiting for the indexer to catch up. */
|
|
13
|
+
const DEFAULT_STATE_POLL_MS = 2_000;
|
|
14
|
+
/** Snapshot of `address`, or `undefined` when no contract exists there. */
|
|
15
|
+
export async function readSnapshot(publicDataProvider, address) {
|
|
16
|
+
const state = await publicDataProvider.queryContractState(address);
|
|
17
|
+
if (state === null)
|
|
18
|
+
return undefined;
|
|
19
|
+
const circuits = sortCircuits(operationNames(state));
|
|
20
|
+
const verifierKeys = new Map();
|
|
21
|
+
for (const name of circuits) {
|
|
22
|
+
const op = state.operation(name);
|
|
23
|
+
if (op !== undefined)
|
|
24
|
+
verifierKeys.set(name, op.verifierKey);
|
|
25
|
+
}
|
|
26
|
+
const authority = state.maintenanceAuthority;
|
|
27
|
+
return {
|
|
28
|
+
circuits,
|
|
29
|
+
verifierKeys,
|
|
30
|
+
counter: authority.counter,
|
|
31
|
+
committee: [...authority.committee],
|
|
32
|
+
threshold: authority.threshold,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Poll until every circuit of the landed fragment is visible, then
|
|
37
|
+
* return that snapshot.
|
|
38
|
+
*
|
|
39
|
+
* The indexer trails the node, so the read taken right after finalization can
|
|
40
|
+
* still be the pre-fragment state. Computing the next fragment from it would
|
|
41
|
+
* re-insert keys that are already on chain and abort a healthy deploy.
|
|
42
|
+
*/
|
|
43
|
+
export async function awaitCircuitsOnChain({ publicDataProvider, address, expected, timeoutMs, pollMs = DEFAULT_STATE_POLL_MS, }) {
|
|
44
|
+
const deadline = Date.now() + timeoutMs;
|
|
45
|
+
let last;
|
|
46
|
+
for (;;) {
|
|
47
|
+
last = await readSnapshot(publicDataProvider, address);
|
|
48
|
+
if (last !== undefined && remaining(expected, last.circuits).length === 0) {
|
|
49
|
+
return last;
|
|
50
|
+
}
|
|
51
|
+
if (Date.now() >= deadline) {
|
|
52
|
+
const missing = last ? remaining(expected, last.circuits) : [...expected];
|
|
53
|
+
throw new FragmentDeployError({
|
|
54
|
+
address,
|
|
55
|
+
circuitsOnChain: last?.circuits ?? [],
|
|
56
|
+
circuitsPending: missing,
|
|
57
|
+
reason: `chain state still missing ${missing.join(', ')} after ${timeoutMs} ms`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
await delay(pollMs);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Every artifact circuit present on chain with identical key bytes,
|
|
65
|
+
* and no extra on-chain circuit. A count check would pass a state that has the
|
|
66
|
+
* right number of operations under the wrong names.
|
|
67
|
+
*/
|
|
68
|
+
export function verifyState({ address, artifactKeys, snapshot, authority, }) {
|
|
69
|
+
// Inserts are additive and never touch the authority, so a committee
|
|
70
|
+
// or threshold that moved means someone else maintained this contract
|
|
71
|
+
// mid-run.
|
|
72
|
+
if (snapshot.threshold !== authority.threshold ||
|
|
73
|
+
snapshot.committee.length !== authority.committee.length ||
|
|
74
|
+
snapshot.committee.some((key, i) => key !== authority.committee[i])) {
|
|
75
|
+
throw new ConfigError(`Maintenance authority of ${address} changed during the deploy: committee [${authority.committee.join(', ')}] threshold ${authority.threshold} became committee [${snapshot.committee.join(', ')}] threshold ${snapshot.threshold}.`);
|
|
76
|
+
}
|
|
77
|
+
const problems = compare(artifactKeys, snapshot);
|
|
78
|
+
if (problems.length === 0)
|
|
79
|
+
return;
|
|
80
|
+
throw new FragmentDeployError({
|
|
81
|
+
address,
|
|
82
|
+
circuitsOnChain: snapshot.circuits,
|
|
83
|
+
circuitsPending: remaining([...artifactKeys.keys()], snapshot.circuits),
|
|
84
|
+
reason: `on-chain state does not match the artifact: ${problems.join('; ')}`,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* This signing key's slot in the on-chain committee.
|
|
89
|
+
*
|
|
90
|
+
* Rejects a committee this deployer cannot satisfy alone: it holds one key, so
|
|
91
|
+
* a threshold above 1 makes every update unsignable here.
|
|
92
|
+
*/
|
|
93
|
+
export function signerIndex({ address, snapshot, verifyingKey, }) {
|
|
94
|
+
if (snapshot.threshold !== 1) {
|
|
95
|
+
throw new ConfigError(`Contract ${address} needs ${snapshot.threshold} maintenance signatures; the deployer holds one key. Complete this deploy with a multi-signer tool.`);
|
|
96
|
+
}
|
|
97
|
+
const index = snapshot.committee.indexOf(verifyingKey);
|
|
98
|
+
if (index < 0) {
|
|
99
|
+
throw new ConfigError(`Contract ${address} is not maintained by this signing key. Check signing_key_file, or re-run with --force to deploy fresh.`);
|
|
100
|
+
}
|
|
101
|
+
return index;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Gate a resume on the recorded address really being our partially
|
|
105
|
+
* deployed contract. An edited or copied deployments file must not make the deployer
|
|
106
|
+
* append this artifact's keys to someone else's contract, or to a stale build
|
|
107
|
+
* of our own.
|
|
108
|
+
*/
|
|
109
|
+
export function assertResumable({ address, artifactKeys, snapshot, verifyingKey, }) {
|
|
110
|
+
if (snapshot === undefined) {
|
|
111
|
+
throw new ConfigError(`Deployments ledger has a partial deploy at ${address} but no contract exists there. Re-run with --force to deploy fresh.`);
|
|
112
|
+
}
|
|
113
|
+
signerIndex({ address, snapshot, verifyingKey });
|
|
114
|
+
const mismatches = compare(artifactKeys, snapshot, { partial: true });
|
|
115
|
+
if (mismatches.length > 0) {
|
|
116
|
+
throw new ConfigError(`Contract ${address} carries verifier keys from a different build: ${mismatches.join('; ')}. Re-run with --force to deploy fresh.`);
|
|
117
|
+
}
|
|
118
|
+
return snapshot;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Key-by-key comparison. With `partial`, artifact circuits not yet on chain
|
|
122
|
+
* are expected; without it, a missing circuit is a failure.
|
|
123
|
+
*/
|
|
124
|
+
function compare(artifactKeys, snapshot, opts = {}) {
|
|
125
|
+
const problems = [];
|
|
126
|
+
for (const name of snapshot.circuits) {
|
|
127
|
+
const expected = artifactKeys.get(name);
|
|
128
|
+
if (expected === undefined) {
|
|
129
|
+
// Renaming a circuit between runs needs --force, not a
|
|
130
|
+
// silent append onto a state the artifact can no longer describe.
|
|
131
|
+
problems.push(`"${name}" is on chain but not in the artifact`);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const actual = snapshot.verifierKeys.get(name);
|
|
135
|
+
if (actual === undefined || !verifierKeysEqual(expected, actual)) {
|
|
136
|
+
problems.push(`"${name}" has a different verifier key on chain`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (opts.partial !== true) {
|
|
140
|
+
for (const name of remaining([...artifactKeys.keys()], snapshot.circuits)) {
|
|
141
|
+
problems.push(`"${name}" is missing on chain`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return problems;
|
|
145
|
+
}
|
|
146
|
+
function delay(ms) {
|
|
147
|
+
return new Promise((resolve) => {
|
|
148
|
+
setTimeout(resolve, ms);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=chain-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-state.js","sourceRoot":"","sources":["../../src/services/chain-state.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE3D,oFAAoF;AACpF,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAWpC,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,kBAAsC,EACtC,OAAe;IAEf,MAAM,KAAK,GAAG,MAAM,kBAAkB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnE,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACrC,MAAM,QAAQ,GAAG,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,MAAM,YAAY,GAAG,IAAI,GAAG,EAAsB,CAAC;IACnD,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,EAAE,KAAK,SAAS;YAAE,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,oBAAoB,CAAC;I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CAAC;YAC/D,SAAS;QACX,CAAC;QACD,MAAM,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;YACjE,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,yCAAyC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC1B,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1E,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,uBAAuB,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges the constructor's compact-runtime `ContractState` to the ledger-v8
|
|
3
|
+
* one and prunes it down to a single fragment's operations.
|
|
4
|
+
*
|
|
5
|
+
* The two `ContractState` classes are unrelated WASM types with the same name.
|
|
6
|
+
* Everything that reaches `ContractDeploy` or `MaintenanceUpdate` must be the
|
|
7
|
+
* ledger one, so the conversion has exactly one home.
|
|
8
|
+
*/
|
|
9
|
+
import type { ContractState as RuntimeContractState } from '@midnight-ntwrk/compact-runtime';
|
|
10
|
+
import { ContractState as LedgerContractState } from '@midnight-ntwrk/ledger-v8';
|
|
11
|
+
/** Serialize-round-trip a runtime state into its ledger counterpart. */
|
|
12
|
+
export declare function toLedgerContractState(state: RuntimeContractState): LedgerContractState;
|
|
13
|
+
/** Operation names on a ledger state, as strings. */
|
|
14
|
+
export declare function operationNames(state: LedgerContractState): string[];
|
|
15
|
+
export interface PruneStateArgs {
|
|
16
|
+
/** Constructor output, holding one operation per provable circuit. */
|
|
17
|
+
state: RuntimeContractState;
|
|
18
|
+
/** Fragment 0's circuits. Every name must exist on `state`. */
|
|
19
|
+
keep: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Ledger state carrying `data`, `maintenanceAuthority` and `balance` unchanged
|
|
23
|
+
* and only `keep`'s operations.
|
|
24
|
+
*
|
|
25
|
+
* `ContractState` has no operation-removal method, so the pruned state is
|
|
26
|
+
* built fresh and the kept operations copied across. `new ContractDeploy(...)`
|
|
27
|
+
* on the result fixes the contract address; later fragments do not move it.
|
|
28
|
+
*/
|
|
29
|
+
export declare function pruneState({ state, keep, }: PruneStateArgs): LedgerContractState;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridges the constructor's compact-runtime `ContractState` to the ledger-v8
|
|
3
|
+
* one and prunes it down to a single fragment's operations.
|
|
4
|
+
*
|
|
5
|
+
* The two `ContractState` classes are unrelated WASM types with the same name.
|
|
6
|
+
* Everything that reaches `ContractDeploy` or `MaintenanceUpdate` must be the
|
|
7
|
+
* ledger one, so the conversion has exactly one home.
|
|
8
|
+
*/
|
|
9
|
+
import { ContractState as LedgerContractState } from '@midnight-ntwrk/ledger-v8';
|
|
10
|
+
import { DeployError } from "../errors.js";
|
|
11
|
+
/** Serialize-round-trip a runtime state into its ledger counterpart. */
|
|
12
|
+
export function toLedgerContractState(state) {
|
|
13
|
+
return LedgerContractState.deserialize(state.serialize());
|
|
14
|
+
}
|
|
15
|
+
/** Operation names on a ledger state, as strings. */
|
|
16
|
+
export function operationNames(state) {
|
|
17
|
+
return state.operations().map(asOperationName);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Ledger state carrying `data`, `maintenanceAuthority` and `balance` unchanged
|
|
21
|
+
* and only `keep`'s operations.
|
|
22
|
+
*
|
|
23
|
+
* `ContractState` has no operation-removal method, so the pruned state is
|
|
24
|
+
* built fresh and the kept operations copied across. `new ContractDeploy(...)`
|
|
25
|
+
* on the result fixes the contract address; later fragments do not move it.
|
|
26
|
+
*/
|
|
27
|
+
export function pruneState({ state, keep, }) {
|
|
28
|
+
const full = toLedgerContractState(state);
|
|
29
|
+
const available = new Set(operationNames(full));
|
|
30
|
+
const pruned = new LedgerContractState();
|
|
31
|
+
pruned.data = full.data;
|
|
32
|
+
pruned.maintenanceAuthority = full.maintenanceAuthority;
|
|
33
|
+
pruned.balance = full.balance;
|
|
34
|
+
for (const name of keep) {
|
|
35
|
+
const op = full.operation(name);
|
|
36
|
+
if (op === undefined) {
|
|
37
|
+
// A fragment naming a circuit the constructor never produced
|
|
38
|
+
// would deploy a state the artifact cannot describe.
|
|
39
|
+
throw new DeployError(`Constructor state has no operation "${name}"; it carries ${[...available].sort().join(', ') || '(none)'}.`);
|
|
40
|
+
}
|
|
41
|
+
pruned.setOperation(name, op);
|
|
42
|
+
}
|
|
43
|
+
// Pruning must lose the later fragments and nothing else.
|
|
44
|
+
const kept = operationNames(pruned);
|
|
45
|
+
if (kept.length !== keep.length) {
|
|
46
|
+
throw new DeployError(`Pruned state holds ${kept.length} operations, expected ${keep.length}.`);
|
|
47
|
+
}
|
|
48
|
+
return pruned;
|
|
49
|
+
}
|
|
50
|
+
/** Operation keys come back as `string | Uint8Array`; circuit ids are the string arm. */
|
|
51
|
+
function asOperationName(key) {
|
|
52
|
+
return typeof key === 'string' ? key : Buffer.from(key).toString('utf8');
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=contract-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-state.js","sourceRoot":"","sources":["../../src/services/contract-state.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,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ED,0DAA0D;IAC1D,MAAM,IAAI,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,MAAM,IAAI,WAAW,CACnB,sBAAsB,IAAI,CAAC,MAAM,yBAAyB,IAAI,CAAC,MAAM,GAAG,CACzE,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,yFAAyF;AACzF,SAAS,eAAe,CAAC,GAAwB;IAC/C,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Partitions a contract's circuits into deploy fragments. Fragment 0 rides the
|
|
3
|
+
* deploy tx; every later fragment becomes one batched verifier-key insert.
|
|
4
|
+
*
|
|
5
|
+
* The budget is always explicit or derived by halving on a rejection: the node
|
|
6
|
+
* cannot weigh a transaction before submission, so there is nothing to plan
|
|
7
|
+
* against.
|
|
8
|
+
*
|
|
9
|
+
* Pure: no clock, no randomness, no I/O, so a rerun after an interruption
|
|
10
|
+
* rebuilds the same plan.
|
|
11
|
+
*/
|
|
12
|
+
export interface Fragment {
|
|
13
|
+
readonly index: number;
|
|
14
|
+
readonly circuits: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
export interface DeployPlan {
|
|
17
|
+
/** The artifact's circuits, sorted. */
|
|
18
|
+
readonly circuits: readonly string[];
|
|
19
|
+
/** Pairwise-disjoint, jointly equal to {@link DeployPlan.circuits}. */
|
|
20
|
+
readonly fragments: readonly Fragment[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Code-unit sort. `localeCompare` would reorder the same circuit list under a
|
|
24
|
+
* different `LANG`, and the fragment plan has to be reproducible across hosts.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sortCircuits(circuits: readonly string[]): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Split sorted `circuits` into fragments of at most `budget`
|
|
29
|
+
* each. Validated at the edges (TOML schema, argv, `Deployer.prepare`), so
|
|
30
|
+
* `budget` is trusted to be an integer of at least one.
|
|
31
|
+
*/
|
|
32
|
+
export declare function planFragments(circuits: readonly string[], budget: number): DeployPlan;
|
|
33
|
+
/** Artifact circuits absent from `onChain`, sorted. */
|
|
34
|
+
export declare function remaining(circuits: readonly string[], onChain: readonly string[]): string[];
|
|
35
|
+
/** Circuits of `fragment` that are not yet on chain, in plan order. */
|
|
36
|
+
export declare function fragmentRemainder(fragment: Fragment, onChain: readonly string[]): string[];
|