@aztec-labs/aztec 6.0.0-nightly.20261021 → 6.0.0-nightly.20261022
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/dest/deploy/fees.d.ts +1 -1
- package/dest/deploy/fees.d.ts.map +1 -1
- package/dest/deploy/fees.js +2 -9
- package/dest/deploy/index.d.ts +2 -2
- package/dest/deploy/index.d.ts.map +1 -1
- package/dest/deploy/runner.d.ts +1 -1
- package/dest/deploy/runner.d.ts.map +1 -1
- package/dest/deploy/runner.js +256 -97
- package/dest/deploy/types.d.ts +63 -47
- package/dest/deploy/types.d.ts.map +1 -1
- package/dest/deploy/types.js +1 -5
- package/package.json +31 -31
- package/src/deploy/fees.ts +2 -11
- package/src/deploy/index.ts +1 -1
- package/src/deploy/runner.ts +274 -96
- package/src/deploy/types.ts +80 -58
package/dest/deploy/fees.d.ts
CHANGED
|
@@ -124,4 +124,4 @@ export interface PrepareFeeSessionOpts {
|
|
|
124
124
|
* when present). Returns a {@link FeeSession} that dispenses the right fee per tx, by sending account.
|
|
125
125
|
*/
|
|
126
126
|
export declare function prepareFeeSession(opts: PrepareFeeSessionOpts): Promise<FeeSession>;
|
|
127
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
127
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2RlcGxveS9mZWVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7R0FZRztBQUNILE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ25FLE9BQU8sRUFFTCxLQUFLLGdCQUFnQixFQUV0QixNQUFNLDBCQUEwQixDQUFDO0FBQ2xDLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSw2Qk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EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IACpC,2FAAyF;IACzF,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;IAChB,8FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,EAAE;QAAE,OAAO,EAAE,YAAY,CAAC;QAAC,MAAM,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,cAAc,CAAA;KAAE,EAAE,CAAC;IAClF,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,CAmIxF"}
|
package/dest/deploy/fees.js
CHANGED
|
@@ -212,21 +212,14 @@ const DEFAULT_LOCAL_L1_CHAIN_ID = 31337;
|
|
|
212
212
|
reused: false
|
|
213
213
|
});
|
|
214
214
|
// Local defaults to anvil; a non-local network must supply L1 connection details.
|
|
215
|
-
const l1RpcUrl
|
|
216
|
-
const l1ChainId = policy.l1ChainId ?? (local ? DEFAULT_LOCAL_L1_CHAIN_ID : undefined);
|
|
217
|
-
if (l1RpcUrl === undefined || l1ChainId === undefined) {
|
|
218
|
-
throw new Error('fee-juice policy on a non-local network requires `l1RpcUrl` and `l1ChainId` (no hardcoded defaults).');
|
|
219
|
-
}
|
|
215
|
+
const { l1RpcUrl, l1ChainId, l1PrivateKey } = resolveL1Config(local, policy);
|
|
220
216
|
const bridged = await bridgeFeeJuice({
|
|
221
217
|
node,
|
|
222
218
|
recipient: address,
|
|
223
219
|
l1RpcUrl,
|
|
224
220
|
l1ChainId,
|
|
225
221
|
amount: policy.fundAmount,
|
|
226
|
-
|
|
227
|
-
// Non-local: the policy's key, else an ephemeral key + the faucet. Deliberately no env
|
|
228
|
-
// fallback — the framework never reads the environment; callers pipe keys in via the policy.
|
|
229
|
-
l1PrivateKey: policy.l1FunderKey ?? (local ? ANVIL_DEV_KEY : undefined)
|
|
222
|
+
l1PrivateKey
|
|
230
223
|
});
|
|
231
224
|
stored = {
|
|
232
225
|
claimAmount: bridged.claimAmount.toString(),
|
package/dest/deploy/index.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export { runDeployment } from './runner.js';
|
|
|
15
15
|
export { defaultFeePolicy } from './fees.js';
|
|
16
16
|
export { consoleReporter } from './reporter.js';
|
|
17
17
|
export type { DeployReporter, DeployPlan, DeployPlanAccount, DeployPlanStep, AccountFunding, DeploySummary, DeployUnitInfo, DeployUnitResult, DeployUnitKind, BridgeEvent, } from './reporter.js';
|
|
18
|
-
export type { DeploymentSpec, AccountSpec, ContractStep, ActionStep, FundStep, StepSpec, Steps,
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
export type { DeploymentSpec, AccountSpec, ContractStep, ActionStep, FundStep, StepSpec, Steps, GeneratedContractClass, FeePolicy, Resolver, Ctx, } from './types.js';
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kZXBsb3kvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUM1QyxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxXQUFXLENBQUM7QUFDN0MsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUNoRCxZQUFZLEVBQ1YsY0FBYyxFQUNkLFVBQVUsRUFDVixpQkFBaUIsRUFDakIsY0FBYyxFQUNkLGNBQWMsRUFDZCxhQUFhLEVBQ2IsY0FBYyxFQUNkLGdCQUFnQixFQUNoQixjQUFjLEVBQ2QsV0FBVyxHQUNaLE1BQU0sZUFBZSxDQUFDO0FBQ3ZCLFlBQVksRUFDVixjQUFjLEVBQ2QsV0FBVyxFQUNYLFlBQVksRUFDWixVQUFVLEVBQ1YsUUFBUSxFQUNSLFFBQVEsRUFDUixLQUFLLEVBQ0wsc0JBQXNCLEVBQ3RCLFNBQVMsRUFDVCxRQUFRLEVBQ1IsR0FBRyxHQUNKLE1BQU0sWUFBWSxDQUFDIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/deploy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EACV,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/deploy/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EACV,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,WAAW,GACZ,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,cAAc,EACd,WAAW,EACX,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,sBAAsB,EACtB,SAAS,EACT,QAAQ,EACR,GAAG,GACJ,MAAM,YAAY,CAAC"}
|
package/dest/deploy/runner.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import type { DeploymentSpec, Steps } from './types.js';
|
|
|
5
5
|
* dependency layers. Idempotent — a re-run sends nothing when everything is already in place.
|
|
6
6
|
*/
|
|
7
7
|
export declare function runDeployment<C extends Steps>(spec: DeploymentSpec<C>): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVubmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZGVwbG95L3J1bm5lci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUF3REEsT0FBTyxLQUFLLEVBSVYsY0FBYyxFQUtkLEtBQUssRUFDTixNQUFNLFlBQVksQ0FBQztBQXFEcEI7Ozs7R0FJRztBQUNILHdCQUFzQixhQUFhLENBQUMsQ0FBQyxTQUFTLEtBQUssRUFBRSxJQUFJLEVBQUUsY0FBYyxDQUFDLENBQUMsQ0FBQyxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FjM0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/deploy/runner.ts"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAIV,cAAc,EAKd,KAAK,EACN,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/deploy/runner.ts"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAIV,cAAc,EAKd,KAAK,EACN,MAAM,YAAY,CAAC;AAqDpB;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,CAAC,SAAS,KAAK,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3F"}
|
package/dest/deploy/runner.js
CHANGED
|
@@ -36,7 +36,7 @@ import { accountFunding, defaultFeePolicy, obtainFeeJuiceClaim, prepareFeeSessio
|
|
|
36
36
|
import { scheduleLayers, topologicalLayers } from './graph.js';
|
|
37
37
|
import { consoleReporter } from './reporter.js';
|
|
38
38
|
import { loadState, saveState } from './state.js';
|
|
39
|
-
/** A step's
|
|
39
|
+
/** A step's inventory check (an action's gate, a fund step's balance, a deferred contract's args) waits on itself. */ class GateCycleError extends Error {
|
|
40
40
|
constructor(message){
|
|
41
41
|
super(message);
|
|
42
42
|
this.name = 'GateCycleError';
|
|
@@ -55,6 +55,24 @@ function isDeferred(step) {
|
|
|
55
55
|
/** The account that sends (and pays for) a contract step's publish tx. */ function contractSender(step) {
|
|
56
56
|
return step.universal ? step.from : step.deployer;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* The contract aliases a pure resolver callback looks up, extracted by dry-running it against a
|
|
60
|
+
* resolver that records each `contract(alias)` lookup instead of resolving it. The callback's return
|
|
61
|
+
* value is discarded and the ZERO addresses never leave this function — which is what requires such
|
|
62
|
+
* callbacks to be pure: they run here with fake addresses and again later with real ones.
|
|
63
|
+
*/ function referencedContracts(run) {
|
|
64
|
+
const references = new Set();
|
|
65
|
+
run({
|
|
66
|
+
account: ()=>AztecAddress.ZERO,
|
|
67
|
+
contract: (alias)=>{
|
|
68
|
+
references.add(alias);
|
|
69
|
+
return AztecAddress.ZERO;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return [
|
|
73
|
+
...references
|
|
74
|
+
];
|
|
75
|
+
}
|
|
58
76
|
/**
|
|
59
77
|
* Runs a {@link DeploymentSpec}: resolves accounts and deterministic addresses, inventories what's
|
|
60
78
|
* already on-chain, reports the plan, funds the working accounts, and executes the missing steps in
|
|
@@ -107,8 +125,9 @@ function isDeferred(step) {
|
|
|
107
125
|
classesPublishedThisRun;
|
|
108
126
|
publishedCache;
|
|
109
127
|
gateCache;
|
|
110
|
-
|
|
128
|
+
deferredCache;
|
|
111
129
|
fundGateCache;
|
|
130
|
+
/** Which pending inventory checks each in-flight check is waiting on — see {@link memoizedCheck}. */ waitingOn;
|
|
112
131
|
// Populated by the resolve / inventory / plan phases.
|
|
113
132
|
resolveOrder;
|
|
114
133
|
actionsToRun;
|
|
@@ -117,6 +136,7 @@ function isDeferred(step) {
|
|
|
117
136
|
layers;
|
|
118
137
|
resolver;
|
|
119
138
|
ctx;
|
|
139
|
+
/** Set only when the spec gave a URL — a connected node serves the debug API for warping itself. */ nodeUrl;
|
|
120
140
|
constructor(spec, node, wallet){
|
|
121
141
|
this.spec = spec;
|
|
122
142
|
this.node = node;
|
|
@@ -134,13 +154,15 @@ function isDeferred(step) {
|
|
|
134
154
|
this.classesPublishedThisRun = new Set();
|
|
135
155
|
this.publishedCache = new Map();
|
|
136
156
|
this.gateCache = new Map();
|
|
137
|
-
this.
|
|
157
|
+
this.deferredCache = new Map();
|
|
138
158
|
this.fundGateCache = new Map();
|
|
159
|
+
this.waitingOn = new Map();
|
|
139
160
|
this.resolveOrder = [];
|
|
140
161
|
this.actionsToRun = new Set();
|
|
141
162
|
this.fundsToRun = new Set();
|
|
142
163
|
this.execAliases = [];
|
|
143
164
|
this.layers = [];
|
|
165
|
+
this.nodeUrl = typeof spec.node === 'string' ? spec.node : undefined;
|
|
144
166
|
this.local = spec.local ?? false;
|
|
145
167
|
this.label = spec.label ?? (this.local ? 'local' : 'network');
|
|
146
168
|
this.reporter = spec.reporter ?? consoleReporter();
|
|
@@ -166,15 +188,15 @@ function isDeferred(step) {
|
|
|
166
188
|
this.ctx = {
|
|
167
189
|
...this.resolver,
|
|
168
190
|
instance: (alias)=>getOrThrow(this.contractInstances, alias, 'contract instance'),
|
|
169
|
-
done: (id)=>this.done(id),
|
|
170
|
-
ran: (id)=>this.ran(id),
|
|
191
|
+
done: (id)=>this.done(id, undefined),
|
|
192
|
+
ran: (id)=>this.ran(id, undefined),
|
|
171
193
|
wallet,
|
|
172
194
|
node
|
|
173
195
|
};
|
|
174
196
|
}
|
|
175
197
|
/** Validates the spec, connects the node + ephemeral wallet, then resolves accounts and class ids. */ static async create(spec) {
|
|
176
198
|
DeploymentRun.validateSpec(spec);
|
|
177
|
-
const node = spec.node
|
|
199
|
+
const node = typeof spec.node === 'string' ? createAztecNodeClient(spec.node) : spec.node;
|
|
178
200
|
const wallet = await EmbeddedWallet.create(node, {
|
|
179
201
|
ephemeral: true,
|
|
180
202
|
pxeConfig: {
|
|
@@ -188,8 +210,8 @@ function isDeferred(step) {
|
|
|
188
210
|
return run;
|
|
189
211
|
}
|
|
190
212
|
/** Static spec validation — everything that can be rejected before touching the network. */ static validateSpec(spec) {
|
|
191
|
-
if (!spec.node
|
|
192
|
-
throw new Error('runDeployment requires
|
|
213
|
+
if (!spec.node) {
|
|
214
|
+
throw new Error('runDeployment requires a `node` on the spec — a JSON-RPC URL or a connected node.');
|
|
193
215
|
}
|
|
194
216
|
const steps = Object.entries(spec.steps);
|
|
195
217
|
const aliases = new Set(steps.map(([alias])=>alias));
|
|
@@ -218,6 +240,14 @@ function isDeferred(step) {
|
|
|
218
240
|
throw new Error(`Contract "${alias}" has deferred args but no dependsOn. Declare the steps whose effects the args read,` + ` or an explicit empty array if they only read pre-existing state.`);
|
|
219
241
|
}
|
|
220
242
|
}
|
|
243
|
+
// A declared cycle never becomes ready, and inventory only notices it when the checks involved
|
|
244
|
+
// happen to consult each other — so reject it before touching the network.
|
|
245
|
+
topologicalLayers([
|
|
246
|
+
...aliases
|
|
247
|
+
], new Map(steps.map(([alias, step])=>[
|
|
248
|
+
alias,
|
|
249
|
+
step.dependsOn ?? []
|
|
250
|
+
])));
|
|
221
251
|
}
|
|
222
252
|
/** Resolves every deterministic contract upfront, layer by layer in constructor-arg dependency order. */ async resolveDeterministicContracts() {
|
|
223
253
|
const deterministicAliases = [
|
|
@@ -242,27 +272,27 @@ function isDeferred(step) {
|
|
|
242
272
|
for (const alias of compactArray(missing)){
|
|
243
273
|
this.publishedThisRun.add(alias);
|
|
244
274
|
}
|
|
245
|
-
//
|
|
246
|
-
// on
|
|
247
|
-
//
|
|
248
|
-
//
|
|
249
|
-
//
|
|
275
|
+
// The remaining checks consult each other (a deferred contract waits on the steps it declares, a
|
|
276
|
+
// gate on the contracts it reads, `ctx.done`/`ctx.ran` on any step), so each is evaluated on
|
|
277
|
+
// demand and memoized: whichever check reaches a step first decides it, and every later one
|
|
278
|
+
// reuses that answer. These loops only make sure every step is decided, in any order.
|
|
279
|
+
// Deferred contracts. On a re-run the state their args read is already on-chain, so the address
|
|
280
|
+
// derives and publication is checked like any other contract (which is what makes re-runs
|
|
281
|
+
// no-ops); otherwise the contract publishes this run and re-resolves at execution time.
|
|
250
282
|
for (const [alias, step] of this.contractSteps){
|
|
251
|
-
if (isDeferred(step) &&
|
|
283
|
+
if (isDeferred(step) && await this.deferredPublishes(alias, undefined)) {
|
|
252
284
|
this.publishedThisRun.add(alias);
|
|
253
285
|
}
|
|
254
286
|
}
|
|
255
|
-
// Fund gates: recipients whose public Fee Juice balance is below the step's threshold.
|
|
256
|
-
// before the action gates so `ctx.done`/`ctx.ran` on a fund step answer correctly inside them.
|
|
287
|
+
// Fund gates: recipients whose public Fee Juice balance is below the step's threshold.
|
|
257
288
|
for (const alias of this.fundSteps.keys()){
|
|
258
|
-
if (!await this.fundGate(alias)) {
|
|
289
|
+
if (!await this.fundGate(alias, undefined)) {
|
|
259
290
|
this.fundsToRun.add(alias);
|
|
260
291
|
}
|
|
261
292
|
}
|
|
262
|
-
// Action gates.
|
|
263
|
-
// detection (gateInProgress) into a silent deadlock of promises awaiting each other.
|
|
293
|
+
// Action gates.
|
|
264
294
|
for (const alias of this.actionSteps.keys()){
|
|
265
|
-
if (!await this.actionGate(alias)) {
|
|
295
|
+
if (!await this.actionGate(alias, undefined)) {
|
|
266
296
|
this.actionsToRun.add(alias);
|
|
267
297
|
}
|
|
268
298
|
}
|
|
@@ -342,7 +372,7 @@ function isDeferred(step) {
|
|
|
342
372
|
return prepareFeeSession({
|
|
343
373
|
local: this.local,
|
|
344
374
|
node: this.node,
|
|
345
|
-
nodeUrl: this.
|
|
375
|
+
nodeUrl: this.nodeUrl,
|
|
346
376
|
wallet: this.wallet,
|
|
347
377
|
state: this.state,
|
|
348
378
|
persist: ()=>this.persist(),
|
|
@@ -421,24 +451,7 @@ function isDeferred(step) {
|
|
|
421
451
|
/** Contract→contract address deps, auto-derived from each deterministic `initializerArgs`. */ recordContractRefs() {
|
|
422
452
|
const contractRefs = new Map();
|
|
423
453
|
for (const [alias, step] of this.contractSteps){
|
|
424
|
-
|
|
425
|
-
if (step.initializerArgs) {
|
|
426
|
-
// Dry-run `initializerArgs` with a resolver that records each `contract(alias)` lookup instead of resolving
|
|
427
|
-
// it. The returned args are discarded — this call only extracts references — and the ZERO addresses never
|
|
428
|
-
// leave this block. This is what requires `initializerArgs` to be pure: it runs here with fake addresses and
|
|
429
|
-
// again later (in resolveDeterministicContracts) with real ones.
|
|
430
|
-
const recording = {
|
|
431
|
-
account: ()=>AztecAddress.ZERO,
|
|
432
|
-
contract: (referenced)=>{
|
|
433
|
-
refs.add(referenced);
|
|
434
|
-
return AztecAddress.ZERO;
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
step.initializerArgs(recording);
|
|
438
|
-
}
|
|
439
|
-
contractRefs.set(alias, [
|
|
440
|
-
...refs
|
|
441
|
-
]);
|
|
454
|
+
contractRefs.set(alias, step.initializerArgs ? referencedContracts(step.initializerArgs) : []);
|
|
442
455
|
}
|
|
443
456
|
return contractRefs;
|
|
444
457
|
}
|
|
@@ -498,14 +511,156 @@ function isDeferred(step) {
|
|
|
498
511
|
}
|
|
499
512
|
}
|
|
500
513
|
/**
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
|
|
514
|
+
* Whether a deferred contract publishes this run, decided once per run. It resolves from current
|
|
515
|
+
* on-chain state only once every step it declares is in place, actions included: its args read
|
|
516
|
+
* their effects, so resolving earlier would derive the address from state that does not exist
|
|
517
|
+
* yet. It has no work left when the args resolve AND the instance is already published.
|
|
518
|
+
*/ deferredPublishes(alias, waiter) {
|
|
519
|
+
const step = getOrThrow(this.contractSteps, alias, 'contract');
|
|
520
|
+
return this.memoizedCheck(this.deferredCache, alias, waiter, async ()=>{
|
|
521
|
+
if (!await this.dependenciesReady(alias, {
|
|
522
|
+
contractsOnly: false
|
|
523
|
+
})) {
|
|
524
|
+
return true;
|
|
525
|
+
}
|
|
526
|
+
await this.resolveDeferred(alias, step, {
|
|
527
|
+
inventory: true
|
|
528
|
+
});
|
|
529
|
+
return !await this.isPublished(alias);
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* Evaluates the inventory check for `alias` at most once per run, on behalf of `waiter` — the check
|
|
534
|
+
* awaiting it, or undefined at the top level. Checks consult each other, possibly from parallel
|
|
535
|
+
* branches of one gate, so a check still in flight is shared, and only a wait that would close a
|
|
536
|
+
* loop in the waiting-on graph is a cycle: it throws {@link GateCycleError} instead of deadlocking.
|
|
537
|
+
*/ memoizedCheck(cache, alias, waiter, evaluate) {
|
|
538
|
+
if (waiter === undefined) {
|
|
539
|
+
return this.getOrEvaluate(cache, alias, evaluate);
|
|
540
|
+
}
|
|
541
|
+
if (this.waitsOn(alias, waiter)) {
|
|
542
|
+
return Promise.reject(new GateCycleError(`Cyclic dependency: "${waiter}" and "${alias}" wait on each other.`));
|
|
543
|
+
}
|
|
544
|
+
// Recorded before evaluating: the evaluation can reach back to `waiter` synchronously.
|
|
545
|
+
let edges = this.waitingOn.get(waiter);
|
|
546
|
+
if (!edges) {
|
|
547
|
+
edges = new Set();
|
|
548
|
+
this.waitingOn.set(waiter, edges);
|
|
549
|
+
}
|
|
550
|
+
edges.add(alias);
|
|
551
|
+
return this.getOrEvaluate(cache, alias, evaluate).finally(()=>edges.delete(alias));
|
|
552
|
+
}
|
|
553
|
+
getOrEvaluate(cache, alias, evaluate) {
|
|
554
|
+
let pending = cache.get(alias);
|
|
555
|
+
if (!pending) {
|
|
556
|
+
pending = evaluate();
|
|
557
|
+
cache.set(alias, pending);
|
|
558
|
+
}
|
|
559
|
+
return pending;
|
|
560
|
+
}
|
|
561
|
+
/** Whether check `from` is (transitively) waiting on check `to` — or is it. */ waitsOn(from, to) {
|
|
562
|
+
const seen = new Set();
|
|
563
|
+
const stack = [
|
|
564
|
+
from
|
|
565
|
+
];
|
|
566
|
+
while(stack.length > 0){
|
|
567
|
+
const current = stack.pop();
|
|
568
|
+
if (current === to) {
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
571
|
+
if (!seen.has(current)) {
|
|
572
|
+
seen.add(current);
|
|
573
|
+
stack.push(...this.waitingOn.get(current) ?? []);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
return false;
|
|
577
|
+
}
|
|
578
|
+
/** Resolves a deferred contract's address from its args, read against the current state. */ async resolveDeferred(alias, step, { inventory }) {
|
|
579
|
+
const args = await this.runRecorded(alias, `Deferred initializer args for contract "${alias}"`, {
|
|
580
|
+
inventory
|
|
581
|
+
}, (ctx)=>step.deferredInitializerArgs(ctx));
|
|
582
|
+
await this.resolveContract(alias, step, args);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Whether the steps `alias` declares as dependencies are all in place: a contract published or
|
|
586
|
+
* registered per its mode, a fund step above its threshold, an action already done. With
|
|
587
|
+
* `contractsOnly`, contracts alone — a gate exists to observe whether the actions and funds it
|
|
588
|
+
* follows landed, so it must still run once the contracts it reads are there.
|
|
589
|
+
*/ async dependenciesReady(alias, { contractsOnly }) {
|
|
590
|
+
const step = getOrThrow(this.steps, alias, 'step');
|
|
591
|
+
for (const dependency of [
|
|
592
|
+
...this.contractRefs.get(alias) ?? [],
|
|
593
|
+
...step.dependsOn ?? []
|
|
594
|
+
]){
|
|
595
|
+
if (contractsOnly && getOrThrow(this.steps, dependency, 'step').kind !== 'contract') {
|
|
596
|
+
continue;
|
|
597
|
+
}
|
|
598
|
+
if (!await this.done(dependency, alias)) {
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
return true;
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Runs a user callback against a ctx that records every contract alias it looks up, then requires
|
|
606
|
+
* those to be declared in the step's `dependsOn` — an undeclared read is state nothing checked was
|
|
607
|
+
* in place. The check runs even when the callback throws, so a callback that catches its own
|
|
608
|
+
* errors (the usual shape for a getter that reverts when unset) can't hide one — nor a
|
|
609
|
+
* {@link GateCycleError} from a step it consults. With `inventory`,
|
|
610
|
+
* the callback is part of `alias`'s inventory check, so the steps it consults are waited on by
|
|
611
|
+
* that check (see {@link memoizedCheck}); at execution time every check is already decided.
|
|
612
|
+
*/ async runRecorded(alias, description, { inventory }, run) {
|
|
613
|
+
const references = new Set();
|
|
614
|
+
const waiter = inventory ? alias : undefined;
|
|
615
|
+
let cycle;
|
|
616
|
+
const surfaceCycle = (status)=>status.catch((error)=>{
|
|
617
|
+
if (error instanceof GateCycleError) {
|
|
618
|
+
cycle ??= error;
|
|
619
|
+
}
|
|
620
|
+
throw error;
|
|
621
|
+
});
|
|
622
|
+
const ctx = {
|
|
623
|
+
...this.ctx,
|
|
624
|
+
done: (id)=>surfaceCycle(this.done(id, waiter)),
|
|
625
|
+
ran: (id)=>surfaceCycle(this.ran(id, waiter)),
|
|
626
|
+
contract: (reference)=>{
|
|
627
|
+
references.add(reference);
|
|
628
|
+
return this.resolver.contract(reference);
|
|
629
|
+
},
|
|
630
|
+
instance: (reference)=>{
|
|
631
|
+
references.add(reference);
|
|
632
|
+
return getOrThrow(this.contractInstances, reference, 'contract instance');
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
let result;
|
|
504
636
|
try {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
637
|
+
result = await run(ctx);
|
|
638
|
+
} catch (error) {
|
|
639
|
+
this.assertReferencesDeclared(alias, description, references, error);
|
|
640
|
+
throw cycle ?? error;
|
|
641
|
+
}
|
|
642
|
+
this.assertReferencesDeclared(alias, description, references);
|
|
643
|
+
if (cycle) {
|
|
644
|
+
throw cycle;
|
|
645
|
+
}
|
|
646
|
+
return result;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Rejects contract aliases the callback read but the step doesn't declare. `cause` carries the
|
|
650
|
+
* error the callback threw, since an undeclared read is the likeliest reason it did.
|
|
651
|
+
*/ assertReferencesDeclared(alias, description, references, cause) {
|
|
652
|
+
const step = getOrThrow(this.steps, alias, 'step');
|
|
653
|
+
const declared = new Set([
|
|
654
|
+
...this.contractRefs.get(alias) ?? [],
|
|
655
|
+
...step.dependsOn ?? []
|
|
656
|
+
]);
|
|
657
|
+
const undeclared = [
|
|
658
|
+
...references
|
|
659
|
+
].filter((reference)=>!declared.has(reference));
|
|
660
|
+
if (undeclared.length > 0) {
|
|
661
|
+
throw new Error(`${description} reads ${undeclared.map((reference)=>`"${reference}"`).join(', ')} but does not declare it in` + ` dependsOn. Declare every step it reads, so it only runs once they are in place.`, {
|
|
662
|
+
cause
|
|
663
|
+
});
|
|
509
664
|
}
|
|
510
665
|
}
|
|
511
666
|
/** Whether the alias's resolved instance is published on-chain. Memoized — one node read per address. */ isPublished(alias) {
|
|
@@ -522,92 +677,92 @@ function isDeferred(step) {
|
|
|
522
677
|
}
|
|
523
678
|
/**
|
|
524
679
|
* A fund step's idempotency gate: whether the recipient's public Fee Juice balance already
|
|
525
|
-
* clears the step's threshold.
|
|
526
|
-
|
|
680
|
+
* clears the step's threshold. A recipient this run has yet to put in place holds nothing, so the
|
|
681
|
+
* balance is read only once the contracts its selector references are there. Memoized per run.
|
|
682
|
+
*/ fundGate(alias, waiter) {
|
|
527
683
|
const step = getOrThrow(this.fundSteps, alias, 'fund step');
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
const recipient = step.recipient(this.resolver);
|
|
533
|
-
return await publicFeeJuiceBalance(this.wallet, recipient, step.from(this.resolver)) >= step.threshold;
|
|
534
|
-
} catch {
|
|
535
|
-
return false; // recipient not resolvable yet (e.g. a deferred contract) ⇒ fund this run
|
|
684
|
+
return this.memoizedCheck(this.fundGateCache, alias, waiter, async ()=>{
|
|
685
|
+
for (const reference of referencedContracts(step.recipient)){
|
|
686
|
+
if (!await this.done(reference, alias)) {
|
|
687
|
+
return false;
|
|
536
688
|
}
|
|
537
|
-
}
|
|
538
|
-
this.
|
|
539
|
-
|
|
540
|
-
|
|
689
|
+
}
|
|
690
|
+
const recipient = step.recipient(this.resolver);
|
|
691
|
+
return await publicFeeJuiceBalance(this.wallet, recipient, step.from(this.resolver)) >= step.threshold;
|
|
692
|
+
});
|
|
541
693
|
}
|
|
542
694
|
/**
|
|
543
|
-
* An action's `done` gate, memoized per run.
|
|
544
|
-
*
|
|
545
|
-
|
|
695
|
+
* An action's `done` gate, memoized per run. Invoked only once the contracts the action declares
|
|
696
|
+
* are in place: until then the action cannot have run, and the gate would read state that does not
|
|
697
|
+
* exist. Gates may consult other steps via `ctx.done`.
|
|
698
|
+
*/ actionGate(alias, waiter) {
|
|
546
699
|
const step = this.actionSteps.get(alias);
|
|
547
700
|
if (!step) {
|
|
548
701
|
throw new Error(`Unknown action "${alias}".`);
|
|
549
702
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
return cached;
|
|
556
|
-
}
|
|
557
|
-
this.gateInProgress.add(alias);
|
|
558
|
-
const pending = (async ()=>{
|
|
559
|
-
try {
|
|
560
|
-
return await step.done(this.ctx);
|
|
561
|
-
} catch (error) {
|
|
562
|
-
if (error instanceof GateCycleError) {
|
|
563
|
-
throw error;
|
|
564
|
-
}
|
|
565
|
-
return false; // e.g. a target contract isn't published yet ⇒ not done
|
|
703
|
+
return this.memoizedCheck(this.gateCache, alias, waiter, async ()=>{
|
|
704
|
+
if (!await this.dependenciesReady(alias, {
|
|
705
|
+
contractsOnly: true
|
|
706
|
+
})) {
|
|
707
|
+
return false;
|
|
566
708
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
709
|
+
return this.runRecorded(alias, `Idempotency gate for action "${alias}"`, {
|
|
710
|
+
inventory: true
|
|
711
|
+
}, (ctx)=>step.done(ctx));
|
|
712
|
+
});
|
|
570
713
|
}
|
|
571
|
-
/** `ctx.done`: whether step `id` is already satisfied this run — mode-aware. */ done(id) {
|
|
714
|
+
/** `ctx.done`: whether step `id` is already satisfied this run — mode-aware. `waiter` is the check asking. */ done(id, waiter) {
|
|
572
715
|
const step = this.steps.get(id);
|
|
573
716
|
if (!step) {
|
|
574
717
|
throw new Error(`Unknown step "${id}".`);
|
|
575
718
|
}
|
|
576
719
|
if (step.kind === 'action') {
|
|
577
|
-
return this.actionGate(id);
|
|
720
|
+
return this.actionGate(id, waiter);
|
|
578
721
|
}
|
|
579
722
|
if (step.kind === 'fund') {
|
|
580
|
-
return this.fundGate(id);
|
|
723
|
+
return this.fundGate(id, waiter);
|
|
581
724
|
}
|
|
582
725
|
if (step.mode === 'register') {
|
|
583
726
|
return Promise.resolve(this.contractAddresses.has(id)); // registered in the PXE
|
|
584
727
|
}
|
|
728
|
+
if (isDeferred(step)) {
|
|
729
|
+
// Its address only exists once it resolves; publication itself is read live, so a publish
|
|
730
|
+
// later in this run still shows.
|
|
731
|
+
return this.deferredPublishes(id, waiter).then(()=>this.isPublished(id));
|
|
732
|
+
}
|
|
585
733
|
return this.isPublished(id);
|
|
586
734
|
}
|
|
587
|
-
/** `ctx.ran`: whether step `id` did (or will do) work this run — mode-aware. */ async ran(id) {
|
|
735
|
+
/** `ctx.ran`: whether step `id` did (or will do) work this run — mode-aware. `waiter` is the check asking. */ async ran(id, waiter) {
|
|
588
736
|
const step = this.steps.get(id);
|
|
589
737
|
if (!step) {
|
|
590
738
|
throw new Error(`Unknown step "${id}".`);
|
|
591
739
|
}
|
|
592
740
|
if (step.kind === 'action') {
|
|
593
|
-
return !await this.actionGate(id);
|
|
741
|
+
return !await this.actionGate(id, waiter);
|
|
594
742
|
}
|
|
595
743
|
if (step.kind === 'fund') {
|
|
596
|
-
return this.
|
|
744
|
+
return !await this.fundGate(id, waiter);
|
|
597
745
|
}
|
|
598
746
|
if (step.mode === 'register') {
|
|
599
747
|
return this.contractAddresses.has(id); // (re)registered this run
|
|
600
748
|
}
|
|
601
|
-
return this.publishedThisRun.has(id);
|
|
749
|
+
return isDeferred(step) ? this.deferredPublishes(id, waiter) : this.publishedThisRun.has(id);
|
|
602
750
|
}
|
|
603
751
|
/**
|
|
604
752
|
* Builds the execution graph over the steps that run and groups it into layers. Exactly one
|
|
605
|
-
* contract per class publishes it
|
|
606
|
-
*
|
|
753
|
+
* contract per class publishes it; every other same-class contract — deterministic or deferred —
|
|
754
|
+
* is ordered after it. The publisher is the class's first contract in `dependsOn` order, so the
|
|
755
|
+
* ordering can't run against a dependency (a same-class contract declared earlier but depending on
|
|
756
|
+
* a later one would otherwise close a cycle).
|
|
607
757
|
*/ buildLayers() {
|
|
758
|
+
const dependsOn = new Map(this.execAliases.map((alias)=>[
|
|
759
|
+
alias,
|
|
760
|
+
getOrThrow(this.steps, alias, 'step').dependsOn ?? []
|
|
761
|
+
]));
|
|
608
762
|
const publisherByClass = new Map();
|
|
609
|
-
for (const
|
|
610
|
-
|
|
763
|
+
for (const alias of topologicalLayers(this.execAliases, dependsOn).flat()){
|
|
764
|
+
const step = this.contractSteps.get(alias);
|
|
765
|
+
if (step?.mode !== 'publish') {
|
|
611
766
|
continue;
|
|
612
767
|
}
|
|
613
768
|
const classId = getOrThrow(this.classIds, alias, 'class id').toString();
|
|
@@ -648,9 +803,11 @@ function isDeferred(step) {
|
|
|
648
803
|
account,
|
|
649
804
|
send: async (fee)=>{
|
|
650
805
|
if (isDeferred(step)) {
|
|
651
|
-
// Re-resolve with post-`dependsOn` state: the inventory attempt
|
|
806
|
+
// Re-resolve with post-`dependsOn` state: the inventory attempt was skipped or ran
|
|
652
807
|
// before this run's earlier layers landed.
|
|
653
|
-
await this.
|
|
808
|
+
await this.resolveDeferred(alias, step, {
|
|
809
|
+
inventory: false
|
|
810
|
+
});
|
|
654
811
|
}
|
|
655
812
|
const classId = getOrThrow(this.classIds, alias, 'class id');
|
|
656
813
|
const deployMethod = getOrThrow(this.deployMethods, alias, 'deploy method');
|
|
@@ -690,7 +847,7 @@ function isDeferred(step) {
|
|
|
690
847
|
const claim = await obtainFeeJuiceClaim({
|
|
691
848
|
local: this.local,
|
|
692
849
|
node: this.node,
|
|
693
|
-
nodeUrl: this.
|
|
850
|
+
nodeUrl: this.nodeUrl,
|
|
694
851
|
recipient,
|
|
695
852
|
amount: step.amount,
|
|
696
853
|
l1: {
|
|
@@ -743,7 +900,9 @@ function isDeferred(step) {
|
|
|
743
900
|
kind: 'action',
|
|
744
901
|
account,
|
|
745
902
|
send: async (fee)=>{
|
|
746
|
-
const interactions = await Promise.all(batch.map((alias)=>
|
|
903
|
+
const interactions = await Promise.all(batch.map((alias)=>this.runRecorded(alias, `Call for action "${alias}"`, {
|
|
904
|
+
inventory: false
|
|
905
|
+
}, (ctx)=>getOrThrow(this.actionSteps, alias, 'action').call(ctx))));
|
|
747
906
|
const sendOptions = {
|
|
748
907
|
from: account,
|
|
749
908
|
fee,
|