@aztec/aztec 0.0.1-commit.42ee6df9b → 0.0.1-commit.431c48d

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.
Files changed (147) hide show
  1. package/dest/bin/index.js +3 -1
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +33 -33
  5. package/dest/cli/aztec_start_options.d.ts +2 -2
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +21 -16
  8. package/dest/cli/cmds/compile.d.ts +1 -1
  9. package/dest/cli/cmds/compile.d.ts.map +1 -1
  10. package/dest/cli/cmds/compile.js +30 -24
  11. package/dest/cli/cmds/profile.d.ts +1 -1
  12. package/dest/cli/cmds/profile.d.ts.map +1 -1
  13. package/dest/cli/cmds/profile.js +1 -1
  14. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  15. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  16. package/dest/cli/cmds/profile_gates.js +21 -3
  17. package/dest/cli/cmds/prover.d.ts +4 -0
  18. package/dest/cli/cmds/prover.d.ts.map +1 -0
  19. package/dest/cli/cmds/prover.js +24 -0
  20. package/dest/cli/cmds/standby.d.ts +30 -6
  21. package/dest/cli/cmds/standby.d.ts.map +1 -1
  22. package/dest/cli/cmds/standby.js +48 -5
  23. package/dest/cli/cmds/start_bot.d.ts +1 -1
  24. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  25. package/dest/cli/cmds/start_bot.js +8 -4
  26. package/dest/cli/cmds/start_node.d.ts +1 -1
  27. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  28. package/dest/cli/cmds/start_node.js +20 -32
  29. package/dest/cli/cmds/start_prover_agent.js +2 -2
  30. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  31. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  32. package/dest/cli/cmds/start_prover_broker.js +11 -8
  33. package/dest/cli/cmds/start_txe.d.ts +2 -2
  34. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  35. package/dest/cli/cmds/start_txe.js +6 -5
  36. package/dest/cli/cmds/utils/artifacts.d.ts +6 -1
  37. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -1
  38. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +2 -2
  39. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -1
  40. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +35 -15
  41. package/dest/cli/util.d.ts +10 -5
  42. package/dest/cli/util.d.ts.map +1 -1
  43. package/dest/cli/util.js +26 -53
  44. package/dest/deploy/bridging.d.ts +84 -0
  45. package/dest/deploy/bridging.d.ts.map +1 -0
  46. package/dest/deploy/bridging.js +121 -0
  47. package/dest/deploy/fees.d.ts +120 -0
  48. package/dest/deploy/fees.d.ts.map +1 -0
  49. package/dest/deploy/fees.js +278 -0
  50. package/dest/deploy/graph.d.ts +40 -0
  51. package/dest/deploy/graph.d.ts.map +1 -0
  52. package/dest/deploy/graph.js +120 -0
  53. package/dest/deploy/index.d.ts +19 -0
  54. package/dest/deploy/index.d.ts.map +1 -0
  55. package/dest/deploy/index.js +15 -0
  56. package/dest/deploy/reporter.d.ts +106 -0
  57. package/dest/deploy/reporter.d.ts.map +1 -0
  58. package/dest/deploy/reporter.js +76 -0
  59. package/dest/deploy/runner.d.ts +8 -0
  60. package/dest/deploy/runner.d.ts.map +1 -0
  61. package/dest/deploy/runner.js +886 -0
  62. package/dest/deploy/state.d.ts +19 -0
  63. package/dest/deploy/state.d.ts.map +1 -0
  64. package/dest/deploy/state.js +59 -0
  65. package/dest/deploy/types.d.ts +233 -0
  66. package/dest/deploy/types.d.ts.map +1 -0
  67. package/dest/deploy/types.js +9 -0
  68. package/dest/examples/token.js +3 -3
  69. package/dest/local-network/auth_registry.d.ts +5 -0
  70. package/dest/local-network/auth_registry.d.ts.map +1 -0
  71. package/dest/local-network/auth_registry.js +17 -0
  72. package/dest/local-network/banana_fpc.d.ts +3 -2
  73. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  74. package/dest/local-network/banana_fpc.js +11 -7
  75. package/dest/local-network/local-network.d.ts +10 -32
  76. package/dest/local-network/local-network.d.ts.map +1 -1
  77. package/dest/local-network/local-network.js +52 -73
  78. package/dest/testing/cheat_codes.d.ts +17 -23
  79. package/dest/testing/cheat_codes.d.ts.map +1 -1
  80. package/dest/testing/cheat_codes.js +17 -43
  81. package/dest/testing/epoch_test_settler.d.ts +2 -2
  82. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  83. package/dest/testing/epoch_test_settler.js +6 -25
  84. package/dest/testing/index.d.ts +2 -2
  85. package/dest/testing/index.d.ts.map +1 -1
  86. package/dest/testing/index.js +1 -1
  87. package/dest/testing/local-network.d.ts +51 -0
  88. package/dest/testing/local-network.d.ts.map +1 -0
  89. package/dest/testing/local-network.js +60 -0
  90. package/dest/testing/token_allowed_setup.d.ts +9 -4
  91. package/dest/testing/token_allowed_setup.d.ts.map +1 -1
  92. package/dest/testing/token_allowed_setup.js +12 -8
  93. package/package.json +37 -34
  94. package/scripts/add_crate.sh +11 -60
  95. package/scripts/aztec.sh +6 -2
  96. package/scripts/init.sh +5 -5
  97. package/scripts/new.sh +2 -2
  98. package/scripts/setup_workspace.sh +3 -2
  99. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  100. package/scripts/templates/blank/contract/src/main.nr +10 -0
  101. package/scripts/templates/blank/test/Nargo.toml +7 -0
  102. package/scripts/templates/blank/test/src/lib.nr +11 -0
  103. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  104. package/scripts/templates/counter/contract/src/main.nr +48 -0
  105. package/scripts/templates/counter/test/Nargo.toml +7 -0
  106. package/scripts/templates/counter/test/src/lib.nr +32 -0
  107. package/src/bin/index.ts +3 -1
  108. package/src/cli/aztec_start_action.ts +38 -25
  109. package/src/cli/aztec_start_options.ts +27 -23
  110. package/src/cli/cmds/compile.ts +35 -24
  111. package/src/cli/cmds/profile.ts +2 -1
  112. package/src/cli/cmds/profile_gates.ts +20 -4
  113. package/src/cli/cmds/prover.ts +42 -0
  114. package/src/cli/cmds/standby.ts +59 -7
  115. package/src/cli/cmds/start_bot.ts +9 -6
  116. package/src/cli/cmds/start_node.ts +25 -32
  117. package/src/cli/cmds/start_prover_agent.ts +2 -2
  118. package/src/cli/cmds/start_prover_broker.ts +10 -11
  119. package/src/cli/cmds/start_txe.ts +7 -5
  120. package/src/cli/cmds/utils/artifacts.ts +5 -0
  121. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +37 -15
  122. package/src/cli/util.ts +27 -68
  123. package/src/deploy/bridging.ts +191 -0
  124. package/src/deploy/fees.ts +322 -0
  125. package/src/deploy/graph.ts +137 -0
  126. package/src/deploy/index.ts +41 -0
  127. package/src/deploy/reporter.ts +184 -0
  128. package/src/deploy/runner.ts +936 -0
  129. package/src/deploy/state.ts +66 -0
  130. package/src/deploy/types.ts +244 -0
  131. package/src/examples/token.ts +11 -3
  132. package/src/local-network/auth_registry.ts +19 -0
  133. package/src/local-network/banana_fpc.ts +12 -8
  134. package/src/local-network/local-network.ts +61 -83
  135. package/src/testing/cheat_codes.ts +18 -49
  136. package/src/testing/epoch_test_settler.ts +8 -31
  137. package/src/testing/index.ts +1 -1
  138. package/src/testing/local-network.ts +97 -0
  139. package/src/testing/token_allowed_setup.ts +15 -8
  140. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  141. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  142. package/dest/cli/cmds/start_archiver.js +0 -48
  143. package/dest/testing/anvil_test_watcher.d.ts +0 -42
  144. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  145. package/dest/testing/anvil_test_watcher.js +0 -181
  146. package/src/cli/cmds/start_archiver.ts +0 -50
  147. package/src/testing/anvil_test_watcher.ts +0 -210
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Resume state for {@link runDeployment}, persisted to `<stateDir>/state.json`.
3
+ *
4
+ * On-chain inventory makes contract deploys and actions idempotent on their own, but a
5
+ * bridge claim lives off-chain between "bridged on L1" and "claimed on L2". We persist
6
+ * pending claims here so a run that dies in that window resumes the claim instead of
7
+ * bridging again. Resolved addresses are stored too, as a human-readable record.
8
+ *
9
+ * The state file is keyed only by `stateDir`; point separate targets (local vs. a remote
10
+ * network) at separate `stateDir`s to keep their state apart.
11
+ */
12
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
13
+ import { join } from 'node:path';
14
+ import { z } from 'zod';
15
+
16
+ const deployStateSchema = z.object({
17
+ addresses: z.record(z.string(), z.string()).default({}),
18
+ pendingClaims: z
19
+ .record(z.string(), z.object({ claimAmount: z.string(), claimSecret: z.string(), messageLeafIndex: z.string() }))
20
+ .default({}),
21
+ });
22
+
23
+ export interface DeployState {
24
+ /** alias → resolved address (informational). */
25
+ addresses: Record<string, string>;
26
+ /** deployer address → a bridge claim that's been funded on L1 but not yet consumed. */
27
+ pendingClaims: Record<string, { claimAmount: string; claimSecret: string; messageLeafIndex: string }>;
28
+ }
29
+
30
+ function statePath(dir: string): string {
31
+ return join(dir, 'state.json');
32
+ }
33
+
34
+ /**
35
+ * Loads the persisted state, or an empty one when no file exists yet. A file that exists but can't
36
+ * be read or doesn't match the schema throws instead of being treated as empty: silently starting
37
+ * fresh would discard `pendingClaims`, and a lost claim secret strands the bridged funds forever.
38
+ */
39
+ export function loadState(dir: string): DeployState {
40
+ let raw: string;
41
+ try {
42
+ raw = readFileSync(statePath(dir), 'utf8');
43
+ } catch (error) {
44
+ if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
45
+ return { addresses: {}, pendingClaims: {} };
46
+ }
47
+ throw new Error(`Failed to read deploy state at ${statePath(dir)}.`, { cause: error });
48
+ }
49
+ try {
50
+ return deployStateSchema.parse(JSON.parse(raw));
51
+ } catch (error) {
52
+ throw new Error(
53
+ `Corrupt deploy state at ${statePath(dir)}. Fix or remove it manually — removing abandons any pending ` +
54
+ `bridge claims recorded in it (their funds become unclaimable).`,
55
+ { cause: error },
56
+ );
57
+ }
58
+ }
59
+
60
+ /** Persists atomically (write + rename), so a crash mid-write can't truncate the previous state. */
61
+ export function saveState(dir: string, state: DeployState): void {
62
+ mkdirSync(dir, { recursive: true });
63
+ const path = statePath(dir);
64
+ writeFileSync(`${path}.tmp`, JSON.stringify(state, null, 2));
65
+ renameSync(`${path}.tmp`, path);
66
+ }
@@ -0,0 +1,244 @@
1
+ /**
2
+ * Declarative deployment spec — the "what", not the "how".
3
+ *
4
+ * A {@link DeploymentSpec} is one graph of {@link StepSpec | steps} — each either a `contract`
5
+ * (published on-chain, or registered privately in the PXE) or an `action` (a tx) — sent from named
6
+ * {@link AccountSpec | accounts}. {@link runDeployment} resolves deterministic addresses upfront,
7
+ * inventories what's on-chain, funds the accounts, and executes only what's missing in dependency
8
+ * order — idempotently and resumably.
9
+ */
10
+ import type { ContractArtifact } from '@aztec/aztec.js/abi';
11
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
12
+ import type { ContractBase, ContractFunctionInteraction } from '@aztec/aztec.js/contracts';
13
+ import type { Fr } from '@aztec/aztec.js/fields';
14
+ import type { AztecNode } from '@aztec/aztec.js/node';
15
+ import type { Wallet } from '@aztec/aztec.js/wallet';
16
+
17
+ import type { DeployReporter } from './reporter.js';
18
+
19
+ /**
20
+ * How txs are paid.
21
+ * - `sponsored`: a SponsoredFPC pays (the local-network default).
22
+ * - `fee-juice`: the account pays from its own Fee Juice; if below `threshold` with work to do,
23
+ * bridge `fundAmount` from L1 and claim it on the first paying tx. `l1FunderKey`/`l1RpcUrl`/
24
+ * `l1ChainId` are caller-supplied; omit `l1FunderKey` for the faucet + ephemeral key. On a
25
+ * non-local network `l1RpcUrl` and `l1ChainId` are required (there are no hardcoded defaults);
26
+ * on local they default to anvil (`127.0.0.1:8545`, chain `31337`).
27
+ */
28
+ export type FeePolicy =
29
+ | { kind: 'sponsored' }
30
+ | {
31
+ kind: 'fee-juice';
32
+ threshold: bigint;
33
+ fundAmount: bigint;
34
+ l1FunderKey?: `0x${string}`;
35
+ l1RpcUrl?: string;
36
+ l1ChainId?: number;
37
+ };
38
+
39
+ /** An account the deployment sends from: a v0 initializerless Schnorr account (no deploy tx). */
40
+ export interface AccountSpec {
41
+ /**
42
+ * The account's privacy master secret — the seed its nullifier, viewing and tagging keys derive
43
+ * from. The signing key is derived from it too, separately (domain-separated as the master
44
+ * message-signing key), so this one value pins the account
45
+ */
46
+ secret: Fr;
47
+ /** Fee policy for this account's txs, overriding {@link DeploymentSpec.fees}. */
48
+ fees?: FeePolicy;
49
+ /** Salt for this account's derivation, overriding {@link DeploymentSpec.salt}. */
50
+ salt?: Fr;
51
+ }
52
+
53
+ /** Resolve addresses of accounts / contracts (for initializer args, action targets, the deployer). */
54
+ export interface Resolver {
55
+ /** The resolved address of the account declared under `alias`. Throws on an unknown alias. */
56
+ account(alias: string): AztecAddress;
57
+ /** The resolved address of the contract step declared under `alias`. Throws on an unknown alias. */
58
+ contract(alias: string): AztecAddress;
59
+ }
60
+
61
+ /**
62
+ * The static side of a codegen'd contract class (e.g. `TokenContract`): the single source of both
63
+ * the artifact and a typed `.at`. Carries the instance type `T`, surfaced by {@link Ctx.instance}.
64
+ */
65
+ export interface GeneratedContractClass<T extends ContractBase = ContractBase> {
66
+ artifact: ContractArtifact;
67
+ at(address: AztecAddress, wallet: Wallet): T;
68
+ }
69
+
70
+ /** What a contract step declares however its initializer args are produced. */
71
+ interface ContractStepBase<T extends ContractBase = ContractBase> {
72
+ kind: 'contract';
73
+ /** The generated contract class — provides the artifact and the typed `.at`. */
74
+ contract: GeneratedContractClass<T>;
75
+ /** Account that salts + sends the deploy, e.g. `(r) => r.account("admin")`. */
76
+ deployer: (resolve: Resolver) => AztecAddress;
77
+ /** Per-contract salt, overriding {@link DeploymentSpec.salt}. */
78
+ salt?: Fr;
79
+ /**
80
+ * For contracts that own private notes (e.g. an FPC): the contract's privacy master secret. The
81
+ * framework derives its `PublicKeys` from it. Omit for ordinary contracts (default keys).
82
+ */
83
+ secret?: Fr;
84
+ /** Name of a non-default `#[initializer]` to call. Defaults to the contract's constructor. */
85
+ initializer?: string;
86
+ }
87
+
88
+ /**
89
+ * A step that puts a contract on-chain (or in the PXE):
90
+ * - `publish` → register the class + deploy the instance + run its initializer (a tx).
91
+ * - `register` → private; only derive the deterministic address and register it in the PXE (no tx).
92
+ *
93
+ * The address is deterministic in (class id, deployer, salt, initializer + its args). The two ways
94
+ * to supply those args are the union's two variants, so a step can only pick one.
95
+ */
96
+ export type ContractStep<C = Steps, T extends ContractBase = ContractBase> =
97
+ | (ContractStepBase<T> & {
98
+ mode: 'publish' | 'register';
99
+ /**
100
+ * Deterministic initializer args — a pure function of resolved addresses + static config. Its
101
+ * contract→contract dependencies are auto-derived and the address is resolved UPFRONT.
102
+ */
103
+ initializerArgs?: (resolve: Resolver) => unknown[];
104
+ deferredInitializerArgs?: never;
105
+ /** Steps that must complete first, on top of those auto-derived from {@link initializerArgs}. */
106
+ dependsOn?: string[];
107
+ })
108
+ | (ContractStepBase<T> & {
109
+ /** Deferred args resolve once the run is underway, so there has to be a tx to defer. */
110
+ mode: 'publish';
111
+ /**
112
+ * Runtime initializer args — may read live state (e.g. `ctx.instance(x).methods.f().simulate()`).
113
+ * Resolved at inventory time when the state it reads already exists (the re-run case, which is
114
+ * what makes re-runs no-ops), and otherwise AT EXECUTION TIME, once {@link dependsOn} has run.
115
+ */
116
+ deferredInitializerArgs: (ctx: Ctx<C>) => unknown[] | Promise<unknown[]>;
117
+ initializerArgs?: never;
118
+ /**
119
+ * The steps whose effects the args read.
120
+ * The initializer args resolve only once these are in place
121
+ */
122
+ dependsOn: string[];
123
+ });
124
+
125
+ /** A step that sends a tx once its dependencies exist. */
126
+ export interface ActionStep<C = Steps> {
127
+ kind: 'action';
128
+ /** Account that sends (and pays for) this tx, e.g. `(r) => r.account("admin")`. */
129
+ from: (resolve: Resolver) => AztecAddress;
130
+ /**
131
+ * Builds the interaction to send. May be async (e.g. to read state first). The EmbeddedWallet
132
+ * creates required authwits at send time, so the interaction usually needs no `.with(...)`.
133
+ */
134
+ call: (ctx: Ctx<C>) => ContractFunctionInteraction | Promise<ContractFunctionInteraction>;
135
+ /**
136
+ * Idempotency gate: if it resolves true, the action is skipped this run. Not consulted until the
137
+ * contracts in {@link dependsOn} are in place. Anything it throws aborts the run.
138
+ */
139
+ done: (ctx: Ctx<C>) => Promise<boolean>;
140
+ /**
141
+ * Steps that must complete first: every contract this action calls or its {@link done} gate
142
+ * reads, plus the actions it follows.
143
+ */
144
+ dependsOn?: string[];
145
+ }
146
+
147
+ /**
148
+ * A step that provisions an address — any address, not just a sending account — with bridged Fee
149
+ * Juice: bridge `amount` from L1, then send a `FeeJuice.claim` tx from {@link from} crediting
150
+ * {@link recipient}. Used to fund contracts that pay for others (e.g. an FPC). Idempotent on the
151
+ * recipient's public balance, and resumable: the bridge claim persists (see ./state.ts) as soon as
152
+ * it exists on L1, so a crash between bridge and claim resumes instead of stranding the funds.
153
+ */
154
+ export interface FundStep {
155
+ kind: 'fund';
156
+ /** Recipient of the bridged Fee Juice, e.g. `(r) => r.contract("fpc")`. */
157
+ recipient: (resolve: Resolver) => AztecAddress;
158
+ /** Bridge + claim only when the recipient's public Fee Juice balance is below this (wei). */
159
+ threshold: bigint;
160
+ /**
161
+ * Amount to bridge (wei). On a network with a fee-asset faucet whose mint amount exceeds the L1
162
+ * funder's balance, the faucet's own mint amount is what arrives.
163
+ */
164
+ amount: bigint;
165
+ /** Account that sends (and pays for) the L2 claim tx, e.g. `(r) => r.account("admin")`. */
166
+ from: (resolve: Resolver) => AztecAddress;
167
+ /** L1 funder key signing the bridge tx; omit for the faucet + an ephemeral key (or anvil's dev key on local). */
168
+ l1FunderKey?: `0x${string}`;
169
+ /** L1 connection for the bridge; required on non-local networks, defaults to anvil on local. */
170
+ l1RpcUrl?: string;
171
+ l1ChainId?: number;
172
+ /** Steps that must complete first (e.g. the contract being funded). */
173
+ dependsOn?: string[];
174
+ }
175
+
176
+ export type StepSpec<C = Steps> = ContractStep<C> | ActionStep<C> | FundStep;
177
+ /**
178
+ * A steps map: alias → step. The element generic is `any` so the alias isn't self-referential
179
+ * (`Steps → StepSpec<Steps> → …`); a concrete spec's `C` is inferred at the {@link runDeployment}
180
+ * call site, which is what types `ctx.instance`.
181
+ */
182
+
183
+ export type Steps = Record<string, StepSpec<any>>;
184
+
185
+ /** The concrete contract type a contract step produces (else the base type). */
186
+ export type InstanceOf<S> = S extends { contract: GeneratedContractClass<infer T> } ? T : ContractBase;
187
+ /** The aliases of the contract steps in C — so `ctx.instance` only accepts those. */
188
+ export type ContractAlias<C> = {
189
+ [K in keyof C]: C[K] extends { kind: 'contract' } ? K : never;
190
+ }[keyof C] &
191
+ string;
192
+
193
+ /** Everything a step needs at build/idempotency time: typed resolution + bound instances + handles. */
194
+ export interface Ctx<C = Steps> extends Resolver {
195
+ /** The contract bound to the wallet, typed from the step's class. */
196
+ instance<K extends ContractAlias<C>>(alias: K): InstanceOf<C[K]>;
197
+ /**
198
+ * Whether step `id` is already satisfied this run — it will NOT do work. Mode-aware: an action
199
+ * whose `done` gate passed, a published contract that's on-chain, or a registered (private)
200
+ * contract that's in the wallet. Can be true without {@link ran} (e.g. a published contract a
201
+ * prior run left on-chain). Lets a step defer to another's gate: `done: (ctx) => ctx.done("amm")`.
202
+ */
203
+ done(id: string): Promise<boolean>;
204
+ /**
205
+ * Whether step `id` did work *this run*: an action that sent its tx, a contract published this
206
+ * run (absent before), or a contract (re)registered this run. Use for "do B because A happened
207
+ * this run", e.g. a mint gated on a fresh token: `done: (ctx) => !ctx.ran("goCoin")`.
208
+ */
209
+ ran(id: string): Promise<boolean>;
210
+ wallet: Wallet;
211
+ node: AztecNode;
212
+ }
213
+
214
+ /** The full declarative input to {@link runDeployment}: target, accounts, steps, fees, and hooks. */
215
+ export interface DeploymentSpec<C extends Steps = Steps> {
216
+ /**
217
+ * The node to deploy against: a JSON-RPC URL, or an already-connected node (e.g. an in-process
218
+ * `AztecNodeService` from a test fixture). Local time-warping while a bridge settles reaches the
219
+ * debug API through whichever is given — a URL builds a debug client, an in-process node serves
220
+ * it directly.
221
+ */
222
+ node: string | AztecNode;
223
+ /**
224
+ * Whether the target is a local (anvil) network. Local uses the deterministic sandbox defaults:
225
+ * sponsored fees, no real proofs, warp-based L1→L2 message advancement, and anvil's dev funder.
226
+ * Everything else (default) uses fee-juice, real proofs, and polling; L1 details for bridging must
227
+ * be supplied on the fee-juice {@link FeePolicy}.
228
+ */
229
+ local?: boolean;
230
+ /** Human label for logs + reporter; defaults to `local`/`network` based on {@link local}. */
231
+ label?: string;
232
+ /** Default salt for account + contract derivation; each can override. Defaults to Fr(0). */
233
+ salt?: Fr;
234
+ /** Directory for the resume-state file. Defaults to `<cwd>/.deploy-state`. */
235
+ stateDir?: string;
236
+ accounts: Record<string, AccountSpec>;
237
+ steps: C;
238
+ /** Default fee policy; per-account {@link AccountSpec.fees} overrides it. Defaults per {@link local}. */
239
+ fees?: FeePolicy;
240
+ /** Where lifecycle events go. Defaults to {@link consoleReporter} (stderr). `{}` silences them. */
241
+ reporter?: DeployReporter;
242
+ /** Hook to write app artifacts (e.g. a frontend manifest) from resolved state; runs after execution. */
243
+ output?: (ctx: Ctx<C>) => void | Promise<void>;
244
+ }
@@ -21,10 +21,18 @@ async function main() {
21
21
 
22
22
  const wallet = await EmbeddedWallet.create(node);
23
23
 
24
- // During local network setup we deploy a few accounts. Below we add them to our wallet.
24
+ // During local network setup we create a few initializerless accounts. Below we add them to our wallet.
25
25
  const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
26
- await wallet.createSchnorrAccount(aliceInitialAccountData.secret, aliceInitialAccountData.salt);
27
- await wallet.createSchnorrAccount(bobInitialAccountData.secret, bobInitialAccountData.salt);
26
+ await wallet.createSchnorrInitializerlessAccount(
27
+ aliceInitialAccountData.secret,
28
+ aliceInitialAccountData.salt,
29
+ aliceInitialAccountData.signingKey,
30
+ );
31
+ await wallet.createSchnorrInitializerlessAccount(
32
+ bobInitialAccountData.secret,
33
+ bobInitialAccountData.salt,
34
+ bobInitialAccountData.signingKey,
35
+ );
28
36
 
29
37
  const alice = aliceInitialAccountData.address;
30
38
  const bob = bobInitialAccountData.address;
@@ -0,0 +1,19 @@
1
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
+ import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
3
+ import type { Wallet } from '@aztec/aztec.js/wallet';
4
+ import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ export async function publishStandardAuthRegistry(
8
+ wallet: Wallet,
9
+ from: AztecAddress,
10
+ waitOpts?: WaitOpts,
11
+ ): Promise<void> {
12
+ const { instance, contractClass } = await getStandardAuthRegistry();
13
+ if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
14
+ await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
15
+ }
16
+ if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
17
+ await publishInstance(wallet, instance).send({ from, wait: waitOpts });
18
+ }
19
+ }
@@ -1,4 +1,5 @@
1
1
  import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import type { WaitOpts } from '@aztec/aztec.js/contracts';
2
3
  import type { Wallet } from '@aztec/aztec.js/wallet';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
4
5
  import type { LogFn } from '@aztec/foundation/log';
@@ -45,19 +46,22 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
45
46
  return (await getBananaFPCInstance(initialAccounts)).address;
46
47
  }
47
48
 
48
- export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
49
+ export async function setupBananaFPC(
50
+ initialAccounts: InitialAccountData[],
51
+ wallet: Wallet,
52
+ log: LogFn,
53
+ waitOpts?: WaitOpts,
54
+ ) {
49
55
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
50
56
  const admin = getBananaAdmin(initialAccounts);
51
57
  const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
52
- TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
53
- from: admin,
54
- contractAddressSalt: BANANA_COIN_SALT,
58
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
59
+ salt: BANANA_COIN_SALT,
55
60
  universalDeploy: true,
56
- }),
57
- FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
61
+ }).send({ from: admin, wait: waitOpts }),
62
+ FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
58
63
  from: admin,
59
- contractAddressSalt: BANANA_FPC_SALT,
60
- universalDeploy: true,
64
+ wait: waitOpts,
61
65
  }),
62
66
  ]);
63
67
 
@@ -1,51 +1,53 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
2
  import { getInitialTestAccountsData } from '@aztec/accounts/testing';
3
- import { AztecNodeService } from '@aztec/aztec-node';
3
+ import { createAztecNodeService } from '@aztec/aztec-node';
4
4
  import { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
5
5
  import { Fr } from '@aztec/aztec.js/fields';
6
6
  import { createLogger } from '@aztec/aztec.js/log';
7
7
  import { type BlobClientInterface, createBlobClient } from '@aztec/blob-client/client';
8
8
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
9
- import { createEthereumChain } from '@aztec/ethereum/chain';
10
9
  import { waitForPublicClient } from '@aztec/ethereum/client';
11
10
  import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
12
11
  import { NULL_KEY } from '@aztec/ethereum/constants';
13
12
  import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
14
- import { EthCheatCodes } from '@aztec/ethereum/test';
13
+ import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
15
14
  import { SecretValue } from '@aztec/foundation/config';
16
15
  import { EthAddress } from '@aztec/foundation/eth-address';
17
16
  import type { LogFn } from '@aztec/foundation/log';
18
17
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
19
18
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
20
19
  import { protocolContractsHash } from '@aztec/protocol-contracts';
21
- import { SequencerState } from '@aztec/sequencer-client';
22
20
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
23
21
  import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
24
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
22
+ import { TxStatus } from '@aztec/stdlib/tx';
23
+ import type { GenesisData } from '@aztec/stdlib/world-state';
25
24
  import {
26
25
  type TelemetryClient,
27
26
  getConfigEnvVars as getTelemetryClientConfig,
28
27
  initTelemetryClient,
29
28
  } from '@aztec/telemetry-client';
30
29
  import { EmbeddedWallet } from '@aztec/wallets/embedded';
31
- import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
30
+ import { createFundedInitializerlessAccounts } from '@aztec/wallets/testing';
32
31
  import { getGenesisValues } from '@aztec/world-state/testing';
33
32
 
34
- import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
33
+ import type { Hex } from 'viem';
35
34
  import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
36
35
  import { foundry } from 'viem/chains';
37
36
 
38
37
  import { createAccountLogs } from '../cli/util.js';
39
38
  import { DefaultMnemonic } from '../mnemonic.js';
40
- import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
41
- import { EpochTestSettler } from '../testing/epoch_test_settler.js';
42
39
  import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
40
+ import { publishStandardAuthRegistry } from './auth_registry.js';
43
41
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
44
42
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
45
43
 
46
44
  const logger = createLogger('local-network');
47
45
 
48
- const localAnvil = foundry;
46
+ // The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
47
+ // proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
48
+ // pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
49
+ // P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
50
+ const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
49
51
 
50
52
  /**
51
53
  * Function to deploy our L1 contracts to the local network L1
@@ -59,7 +61,7 @@ export async function deployContractsToL1(
59
61
  genesisArchiveRoot?: Fr;
60
62
  feeJuicePortalInitialBalance?: bigint;
61
63
  } = {},
62
- ) {
64
+ ): Promise<L1ContractAddresses> {
63
65
  await waitForPublicClient(aztecNodeConfig);
64
66
 
65
67
  const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
@@ -70,14 +72,14 @@ export async function deployContractsToL1(
70
72
  genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
71
73
  feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
72
74
  aztecTargetCommitteeSize: 0, // no committee in local network
73
- slasherFlavor: 'none', // no slashing in local network
75
+ slasherEnabled: false, // no slashing in local network
74
76
  realVerifier: false,
75
77
  });
76
78
 
77
- aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
79
+ Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
78
80
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
79
81
 
80
- return aztecNodeConfig.l1Contracts;
82
+ return l1Contracts.l1ContractAddresses;
81
83
  }
82
84
 
83
85
  /** Local network settings. */
@@ -86,6 +88,8 @@ export type LocalNetworkConfig = AztecNodeConfig & {
86
88
  l1Mnemonic: string;
87
89
  /** Whether to deploy test accounts on local network start.*/
88
90
  testAccounts: boolean;
91
+ /** Override the default per-address fee juice granted at genesis to funded addresses. */
92
+ initialAccountFeeJuice?: Fr;
89
93
  };
90
94
 
91
95
  /**
@@ -107,10 +111,33 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
107
111
  // in the setup allowlist so FPC-based fee payments work out of the box.
108
112
  const tokenAllowList = await getTokenAllowedSetupFunctions();
109
113
 
114
+ const envConfig = getConfigEnvVars();
110
115
  const aztecNodeConfig: AztecNodeConfig = {
111
- ...getConfigEnvVars(),
116
+ ...envConfig,
112
117
  ...config,
118
+ skipOrphanProposedBlockPruning: true,
119
+ // The local network builds node config from env without a DATA_DIRECTORY, so the validator's
120
+ // local signing protection runs against an ephemeral store. That is acceptable for this dev
121
+ // network; production validators must persist it and fail-fast when the data directory is unset.
122
+ allowEphemeralSigningProtection: config.allowEphemeralSigningProtection ?? true,
113
123
  txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
124
+ // The local network runs against anvil with no committee, so it defaults to the deterministic
125
+ // AutomineSequencer, which owns L1 time control (warps the dateProvider and L1 timestamps to slot
126
+ // boundaries as it builds), replacing the deleted AnvilTestWatcher. This remains true when p2p is
127
+ // enabled for local peer testing; local-network is not a mode for connecting to an existing network.
128
+ useAutomineSequencer: config.useAutomineSequencer ?? true,
129
+ // The AutomineSequencer owns epoch proving in the local network — it writes epoch out hashes to
130
+ // the L1 Outbox and advances the proven tip as checkpoints land, through the same serial queue as
131
+ // its builds — replacing the standalone EpochTestSettler that used to race the build loop.
132
+ automineEnableProveEpoch: config.automineEnableProveEpoch ?? true,
133
+ // Defaults for the local network / sandbox; callers (e.g. the CLI) may override. No real proving
134
+ // happens here — the AutomineSequencer synthetically settles epochs. Short epochs let it write out
135
+ // hashes quickly (so users can consume L2-to-L1 messages without a long wait), with a wider
136
+ // proof-submission window so the synthetic settler has headroom before the rollup would prune an
137
+ // unproven checkpoint.
138
+ realProofs: config.realProofs ?? false,
139
+ aztecEpochDuration: config.aztecEpochDuration ?? 4,
140
+ aztecProofSubmissionEpochs: config.aztecProofSubmissionEpochs ?? 2,
114
141
  };
115
142
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
116
143
  if (
@@ -134,7 +161,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
134
161
  const initialAccounts = await (async () => {
135
162
  if (config.testAccounts === true || config.testAccounts === undefined) {
136
163
  if (aztecNodeConfig.p2pEnabled) {
137
- userLog(`Not setting up test accounts as we are connecting to a network`);
164
+ userLog(`Not setting up test accounts when p2p is enabled`);
138
165
  } else {
139
166
  userLog(`Setting up test accounts`);
140
167
  return await getInitialTestAccountsData();
@@ -145,79 +172,30 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
145
172
 
146
173
  const bananaFPC = await getBananaFPCAddress(initialAccounts);
147
174
  const sponsoredFPC = await getSponsoredFPCAddress();
148
- const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
175
+ const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromStringUnsafe(a));
149
176
  const fundedAddresses = [
150
177
  ...initialAccounts.map(a => a.address),
151
178
  ...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
152
179
  ...prefundAddresses,
153
180
  ];
154
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
181
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(
182
+ fundedAddresses,
183
+ config.initialAccountFeeJuice,
184
+ );
155
185
 
156
186
  const dateProvider = new TestDateProvider();
157
187
 
158
- let cheatcodes: EthCheatCodes | undefined;
159
- let rollupAddress: EthAddress | undefined;
160
- let watcher: AnvilTestWatcher | undefined;
161
188
  if (!aztecNodeConfig.p2pEnabled) {
162
- ({ rollupAddress } = await deployContractsToL1(
163
- aztecNodeConfig,
164
- aztecNodeConfig.validatorPrivateKeys.getValue()[0],
165
- {
166
- genesisArchiveRoot,
167
- feeJuicePortalInitialBalance: fundingNeeded,
168
- },
169
- ));
170
-
171
- const chain =
172
- aztecNodeConfig.l1RpcUrls.length > 0
173
- ? createEthereumChain([l1RpcUrl], aztecNodeConfig.l1ChainId)
174
- : { chainInfo: localAnvil };
175
-
176
- const publicClient = createPublicClient({
177
- chain: chain.chainInfo,
178
- transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
189
+ await deployContractsToL1(aztecNodeConfig, aztecNodeConfig.validatorPrivateKeys.getValue()[0], {
190
+ genesisArchiveRoot,
191
+ feeJuicePortalInitialBalance: fundingNeeded,
179
192
  });
180
-
181
- cheatcodes = new EthCheatCodes([l1RpcUrl], dateProvider);
182
-
183
- watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
184
- watcher.setisLocalNetwork(true);
185
- watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
186
-
187
- await watcher.start();
188
193
  }
189
194
 
190
195
  const telemetry = await initTelemetryClient(getTelemetryClientConfig());
191
196
  // Create a local blob client client inside the local network, no http connectivity
192
197
  const blobClient = createBlobClient();
193
- const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
194
-
195
- // Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
196
- // transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
197
- // warping time out from under an in-progress block.
198
- watcher?.setGetPendingTxCount(() => node.getPendingTxCount());
199
- const sequencer = node.getSequencer()?.getSequencer();
200
- if (sequencer) {
201
- const idleStates: Set<string> = new Set([
202
- SequencerState.STOPPED,
203
- SequencerState.STOPPING,
204
- SequencerState.IDLE,
205
- SequencerState.SYNCHRONIZING,
206
- ]);
207
- watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
208
- }
209
-
210
- let epochTestSettler: EpochTestSettler | undefined;
211
- if (!aztecNodeConfig.p2pEnabled) {
212
- epochTestSettler = new EpochTestSettler(
213
- cheatcodes!,
214
- rollupAddress!,
215
- node.getBlockSource(),
216
- logger.createChild('epoch-settler'),
217
- { pollingIntervalMs: 200 },
218
- );
219
- await epochTestSettler.start();
220
- }
198
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
221
199
 
222
200
  if (initialAccounts.length) {
223
201
  const wallet = await EmbeddedWallet.create(node, {
@@ -226,11 +204,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
226
204
  });
227
205
 
228
206
  userLog('Setting up funded test accounts...');
229
- const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
207
+ const accountManagers = await createFundedInitializerlessAccounts(wallet, initialAccounts);
230
208
  const accLogs = await createAccountLogs(accountManagers, wallet);
231
209
  userLog(accLogs.join(''));
232
210
 
233
- await setupBananaFPC(initialAccounts, wallet, userLog);
211
+ userLog('Publishing standard AuthRegistry contract...');
212
+ await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
213
+
214
+ await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
234
215
 
235
216
  userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
236
217
 
@@ -240,8 +221,6 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
240
221
 
241
222
  const stop = async () => {
242
223
  await node.stop();
243
- await watcher?.stop();
244
- await epochTestSettler?.stop();
245
224
  };
246
225
 
247
226
  return { node, stop };
@@ -259,16 +238,15 @@ export async function createAztecNode(
259
238
  dateProvider?: DateProvider;
260
239
  proverBroker?: ProvingJobBroker;
261
240
  } = {},
262
- options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
241
+ options: { genesis?: GenesisData } = {},
263
242
  ) {
264
243
  // TODO(#12272): will clean this up. This is criminal.
265
- const { l1Contracts, ...rest } = getConfigEnvVars();
244
+ // Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
266
245
  const aztecNodeConfig: AztecNodeConfig = {
267
- ...rest,
246
+ ...getConfigEnvVars(),
268
247
  ...config,
269
- l1Contracts: { ...l1Contracts, ...config.l1Contracts },
270
248
  };
271
- const node = await AztecNodeService.createAndSync(
249
+ const node = await createAztecNodeService(
272
250
  aztecNodeConfig,
273
251
  { ...deps, proverNodeDeps: { broker: deps.proverBroker } },
274
252
  options,