@aztec/aztec 0.0.1-commit.f2ce05ee → 0.0.1-commit.f5a9928
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/bin/index.js +9 -3
- package/dest/cli/admin_api_key_store.d.ts +45 -0
- package/dest/cli/admin_api_key_store.d.ts.map +1 -0
- package/dest/cli/admin_api_key_store.js +98 -0
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +79 -34
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +45 -24
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +3 -4
- package/dest/cli/cmds/compile.d.ts +4 -0
- package/dest/cli/cmds/compile.d.ts.map +1 -0
- package/dest/cli/cmds/compile.js +174 -0
- package/dest/cli/cmds/profile.d.ts +4 -0
- package/dest/cli/cmds/profile.d.ts.map +1 -0
- package/dest/cli/cmds/profile.js +8 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
- package/dest/cli/cmds/profile_flamegraph.js +52 -0
- package/dest/cli/cmds/profile_gates.d.ts +4 -0
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
- package/dest/cli/cmds/profile_gates.js +76 -0
- package/dest/cli/cmds/profile_utils.d.ts +18 -0
- package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
- package/dest/cli/cmds/profile_utils.js +50 -0
- package/dest/cli/cmds/prover.d.ts +4 -0
- package/dest/cli/cmds/prover.d.ts.map +1 -0
- package/dest/cli/cmds/prover.js +24 -0
- package/dest/cli/cmds/standby.d.ts +56 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +140 -0
- package/dest/cli/cmds/start_bot.d.ts +3 -3
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +17 -9
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +83 -51
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +5 -17
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +22 -13
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +6 -5
- package/dest/cli/cmds/utils/artifacts.d.ts +26 -0
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
- package/dest/cli/cmds/utils/artifacts.js +24 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +90 -0
- package/dest/cli/cmds/utils/spawn.d.ts +3 -0
- package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
- package/dest/cli/cmds/utils/spawn.js +16 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
- package/dest/cli/util.d.ts +13 -19
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +37 -100
- package/dest/deploy/bridging.d.ts +84 -0
- package/dest/deploy/bridging.d.ts.map +1 -0
- package/dest/deploy/bridging.js +121 -0
- package/dest/deploy/fees.d.ts +120 -0
- package/dest/deploy/fees.d.ts.map +1 -0
- package/dest/deploy/fees.js +278 -0
- package/dest/deploy/graph.d.ts +40 -0
- package/dest/deploy/graph.d.ts.map +1 -0
- package/dest/deploy/graph.js +120 -0
- package/dest/deploy/index.d.ts +19 -0
- package/dest/deploy/index.d.ts.map +1 -0
- package/dest/deploy/index.js +15 -0
- package/dest/deploy/reporter.d.ts +106 -0
- package/dest/deploy/reporter.d.ts.map +1 -0
- package/dest/deploy/reporter.js +76 -0
- package/dest/deploy/runner.d.ts +8 -0
- package/dest/deploy/runner.d.ts.map +1 -0
- package/dest/deploy/runner.js +886 -0
- package/dest/deploy/state.d.ts +19 -0
- package/dest/deploy/state.d.ts.map +1 -0
- package/dest/deploy/state.js +59 -0
- package/dest/deploy/types.d.ts +233 -0
- package/dest/deploy/types.d.ts.map +1 -0
- package/dest/deploy/types.js +9 -0
- package/dest/examples/token.js +9 -9
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +3 -2
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +12 -8
- package/dest/local-network/local-network.d.ts +12 -32
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +83 -72
- package/dest/testing/cheat_codes.d.ts +17 -23
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +17 -43
- package/dest/testing/epoch_test_settler.d.ts +2 -2
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +6 -26
- package/dest/testing/index.d.ts +3 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +2 -1
- package/dest/testing/local-network.d.ts +51 -0
- package/dest/testing/local-network.d.ts.map +1 -0
- package/dest/testing/local-network.js +60 -0
- package/dest/testing/token_allowed_setup.d.ts +12 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +24 -0
- package/package.json +38 -35
- package/scripts/add_crate.sh +53 -0
- package/scripts/aztec.sh +15 -5
- package/scripts/init.sh +23 -19
- package/scripts/new.sh +48 -24
- package/scripts/setup_workspace.sh +69 -0
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +9 -3
- package/src/cli/admin_api_key_store.ts +128 -0
- package/src/cli/aztec_start_action.ts +87 -26
- package/src/cli/aztec_start_options.ts +53 -30
- package/src/cli/cli.ts +3 -4
- package/src/cli/cmds/compile.ts +205 -0
- package/src/cli/cmds/profile.ts +26 -0
- package/src/cli/cmds/profile_flamegraph.ts +64 -0
- package/src/cli/cmds/profile_gates.ts +84 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/prover.ts +42 -0
- package/src/cli/cmds/standby.ts +184 -0
- package/src/cli/cmds/start_bot.ts +17 -11
- package/src/cli/cmds/start_node.ts +96 -53
- package/src/cli/cmds/start_prover_agent.ts +5 -8
- package/src/cli/cmds/start_prover_broker.ts +23 -24
- package/src/cli/cmds/start_txe.ts +7 -5
- package/src/cli/cmds/utils/artifacts.ts +49 -0
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
- package/src/cli/util.ts +39 -118
- package/src/deploy/bridging.ts +191 -0
- package/src/deploy/fees.ts +322 -0
- package/src/deploy/graph.ts +137 -0
- package/src/deploy/index.ts +41 -0
- package/src/deploy/reporter.ts +184 -0
- package/src/deploy/runner.ts +936 -0
- package/src/deploy/state.ts +66 -0
- package/src/deploy/types.ts +244 -0
- package/src/examples/token.ts +19 -9
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +13 -9
- package/src/local-network/local-network.ts +96 -81
- package/src/testing/cheat_codes.ts +18 -49
- package/src/testing/epoch_test_settler.ts +8 -32
- package/src/testing/index.ts +2 -1
- package/src/testing/local-network.ts +97 -0
- package/src/testing/token_allowed_setup.ts +26 -0
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -48
- package/dest/cli/cmds/start_prover_node.d.ts +0 -7
- package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
- package/dest/cli/cmds/start_prover_node.js +0 -108
- package/dest/cli/release_version.d.ts +0 -2
- package/dest/cli/release_version.d.ts.map +0 -1
- package/dest/cli/release_version.js +0 -14
- package/dest/testing/anvil_test_watcher.d.ts +0 -34
- package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
- package/dest/testing/anvil_test_watcher.js +0 -144
- package/scripts/compile.sh +0 -44
- package/scripts/extract_function.js +0 -47
- package/scripts/flamegraph.sh +0 -59
- package/scripts/setup_project.sh +0 -31
- package/src/cli/cmds/start_archiver.ts +0 -50
- package/src/cli/cmds/start_prover_node.ts +0 -124
- package/src/cli/release_version.ts +0 -21
- package/src/testing/anvil_test_watcher.ts +0 -166
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fee-juice bridging for the `fee-juice` deploy policy: bridge Fee Juice from L1
|
|
3
|
+
* ({@link bridgeFeeJuice}) and wait for the L1→L2 message to become available
|
|
4
|
+
* ({@link waitForL1ToL2Message}). Fee Juice only — this is not a generic L1→L2 asset bridge.
|
|
5
|
+
* Node-only (pulls in `@aztec/aztec.js/ethereum` + viem).
|
|
6
|
+
*
|
|
7
|
+
* Nothing here sends the L2 claim tx — the caller feeds the returned claim into
|
|
8
|
+
* `FeeJuicePaymentMethodWithClaim` so the claim lands inside whatever tx the recipient is already
|
|
9
|
+
* sending.
|
|
10
|
+
*/
|
|
11
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
12
|
+
import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
13
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
14
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
15
|
+
import type { Hex } from 'viem';
|
|
16
|
+
/** Local vs. remote L1→L2 message advancement: warp cheats time forward, poll just waits. */
|
|
17
|
+
export type BridgeTimingMode = 'warp' | 'poll';
|
|
18
|
+
/** The claim produced by bridging: exactly the shape `FeeJuicePaymentMethodWithClaim` expects. */
|
|
19
|
+
export type FeeJuiceClaim = Awaited<ReturnType<L1FeeJuicePortalManager['bridgeTokensPublic']>>;
|
|
20
|
+
/**
|
|
21
|
+
* Decides how the L1 signer funds a bridge: mint from the fee-asset faucet handler, or transfer
|
|
22
|
+
* its existing Fee Juice. Pure — exercised directly by unit tests.
|
|
23
|
+
*
|
|
24
|
+
* - Balance covers the requested amount → transfer it (no mint, even when a faucet exists).
|
|
25
|
+
* - Balance short of the amount + faucet available → mint (the faucet path bridges the handler's
|
|
26
|
+
* own mint amount and ignores `amount`).
|
|
27
|
+
* - Balance short + no faucet → throw, reporting the shortfall.
|
|
28
|
+
* - No `amount` requested → the faucet is required (there is nothing to size a transfer by).
|
|
29
|
+
*/
|
|
30
|
+
export declare function pickBridgeRoute(opts: {
|
|
31
|
+
hasFaucet: boolean;
|
|
32
|
+
l1Balance: bigint;
|
|
33
|
+
amount?: bigint;
|
|
34
|
+
}): {
|
|
35
|
+
useFaucet: boolean;
|
|
36
|
+
amount?: bigint;
|
|
37
|
+
};
|
|
38
|
+
export interface BridgeFeeJuiceParams {
|
|
39
|
+
node: AztecNode;
|
|
40
|
+
l1RpcUrl: string;
|
|
41
|
+
l1ChainId: number;
|
|
42
|
+
recipient: AztecAddress;
|
|
43
|
+
/** Desired amount in wei. Optional only when a faucet exists (whose `mintAmount()` then wins). */
|
|
44
|
+
amount?: bigint;
|
|
45
|
+
/** L1 private key signing the bridge tx. When omitted, a fresh ephemeral key is generated. */
|
|
46
|
+
l1PrivateKey?: Hex;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Bridges fee juice to an L2 recipient, minting from the faucet handler or transferring the
|
|
50
|
+
* signer's balance per {@link pickBridgeRoute}. Returns the claim; the L1→L2 message it references
|
|
51
|
+
* becomes available later — see {@link waitForL1ToL2Message}.
|
|
52
|
+
*/
|
|
53
|
+
export declare function bridgeFeeJuice(params: BridgeFeeJuiceParams): Promise<FeeJuiceClaim>;
|
|
54
|
+
export interface WaitForClaimParams {
|
|
55
|
+
node: AztecNode;
|
|
56
|
+
messageHash: Fr;
|
|
57
|
+
/**
|
|
58
|
+
* On `warp` (local) we cheat L1+L2 time forward via the node debug API until the message shows as
|
|
59
|
+
* available; on `poll` (every other network) we just check periodically.
|
|
60
|
+
*/
|
|
61
|
+
mode: BridgeTimingMode;
|
|
62
|
+
/** Timeout before giving up (default 30 min for poll, 2 min for warp). */
|
|
63
|
+
timeoutMs?: number;
|
|
64
|
+
/** Warp-only: options for reaching the node's debug API. */
|
|
65
|
+
warpOpts?: {
|
|
66
|
+
nodeUrl?: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Waits until an L1→L2 message is available on the node (warping time forward in `warp` mode). */
|
|
70
|
+
export declare function waitForL1ToL2Message(params: WaitForClaimParams): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Local-network helper: advances L1 + L2 time via the node debug API until the given L1→L2 message
|
|
73
|
+
* shows up as available, warping by one L2 slot (read from the node's rollup constants) per check.
|
|
74
|
+
* An in-process node (e.g. a test fixture's `AztecNodeService`) implements the debug interface
|
|
75
|
+
* directly; a remote node is reached via its debug RPC at `nodeUrl` — `warpL2TimeAtLeastBy` needs
|
|
76
|
+
* `AztecNode & AztecNodeDebug` (it reads the current L1 timestamp via the regular API before
|
|
77
|
+
* warping), and both clients target the same URL and expose their methods as own properties on the
|
|
78
|
+
* rpc proxy, so a shallow merge is safe.
|
|
79
|
+
*/
|
|
80
|
+
export declare function warpToL1ToL2Message(node: AztecNode, messageHash: Fr, opts?: {
|
|
81
|
+
nodeUrl?: string;
|
|
82
|
+
timeoutMs?: number;
|
|
83
|
+
}): Promise<void>;
|
|
84
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJpZGdpbmcuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kZXBsb3kvYnJpZGdpbmcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7OztHQVNHO0FBQ0gsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFDOUQsT0FBTyxFQUFFLHVCQUF1QixFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFbkUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFHdEQsT0FBTyxFQUFFLEVBQUUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBS3BELE9BQU8sS0FBSyxFQUFFLEdBQUcsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQVloQywrRkFBNkY7QUFDN0YsTUFBTSxNQUFNLGdCQUFnQixHQUFHLE1BQU0sR0FBRyxNQUFNLENBQUM7QUFFL0Msa0dBQWtHO0FBQ2xHLE1BQU0sTUFBTSxhQUFhLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyx1QkFBdUIsQ0FBQyxvQkFBb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,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAkBA;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,YAAY,CAAC;IACxB,kGAAkG;IAClG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8FAA8F;IAC9F,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,CAezF;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,EAAE,CAAC;IAChB;;;OAGG;IACH,IAAI,EAAE,gBAAgB,CAAC;IACvB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACjC;AAED,qGAAmG;AACnG,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCpF;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,EAAE,EACf,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAClD,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fee-juice bridging for the `fee-juice` deploy policy: bridge Fee Juice from L1
|
|
3
|
+
* ({@link bridgeFeeJuice}) and wait for the L1→L2 message to become available
|
|
4
|
+
* ({@link waitForL1ToL2Message}). Fee Juice only — this is not a generic L1→L2 asset bridge.
|
|
5
|
+
* Node-only (pulls in `@aztec/aztec.js/ethereum` + viem).
|
|
6
|
+
*
|
|
7
|
+
* Nothing here sends the L2 claim tx — the caller feeds the returned claim into
|
|
8
|
+
* `FeeJuicePaymentMethodWithClaim` so the claim lands inside whatever tx the recipient is already
|
|
9
|
+
* sending.
|
|
10
|
+
*/ import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
|
|
11
|
+
import { isL1ToL2MessageReady } from '@aztec/aztec.js/messaging';
|
|
12
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
13
|
+
import { createExtendedL1Client } from '@aztec/ethereum/client';
|
|
14
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
15
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
16
|
+
import { createAztecNodeDebugClient } from '@aztec/stdlib/interfaces/client';
|
|
17
|
+
import { generatePrivateKey } from 'viem/accounts';
|
|
18
|
+
const logger = createLogger('deploy:bridging');
|
|
19
|
+
/** Wait between availability checks in `warp` mode — each iteration also warps the clock forward. */ const WARP_POLL_INTERVAL_MS = 1000;
|
|
20
|
+
/** Wait between availability checks in `poll` mode (a real network; nothing to do but wait). */ const POLL_INTERVAL_MS = 5_000;
|
|
21
|
+
/** Throttle for the "still waiting" progress log in the poll loop. */ const POLL_LOG_INTERVAL_MS = 30_000;
|
|
22
|
+
/**
|
|
23
|
+
* Decides how the L1 signer funds a bridge: mint from the fee-asset faucet handler, or transfer
|
|
24
|
+
* its existing Fee Juice. Pure — exercised directly by unit tests.
|
|
25
|
+
*
|
|
26
|
+
* - Balance covers the requested amount → transfer it (no mint, even when a faucet exists).
|
|
27
|
+
* - Balance short of the amount + faucet available → mint (the faucet path bridges the handler's
|
|
28
|
+
* own mint amount and ignores `amount`).
|
|
29
|
+
* - Balance short + no faucet → throw, reporting the shortfall.
|
|
30
|
+
* - No `amount` requested → the faucet is required (there is nothing to size a transfer by).
|
|
31
|
+
*/ export function pickBridgeRoute(opts) {
|
|
32
|
+
const { hasFaucet, l1Balance, amount } = opts;
|
|
33
|
+
if (amount === undefined) {
|
|
34
|
+
if (!hasFaucet) {
|
|
35
|
+
throw new Error('bridgeFeeJuice: `amount` is required when no fee-asset faucet is available.');
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
useFaucet: true
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
if (l1Balance >= amount) {
|
|
42
|
+
return {
|
|
43
|
+
useFaucet: false,
|
|
44
|
+
amount
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (hasFaucet) {
|
|
48
|
+
return {
|
|
49
|
+
useFaucet: true
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`L1 signer holds ${l1Balance} wei of Fee Juice but ${amount} was requested, and no fee-asset faucet is ` + `available to mint the difference.`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Bridges fee juice to an L2 recipient, minting from the faucet handler or transferring the
|
|
56
|
+
* signer's balance per {@link pickBridgeRoute}. Returns the claim; the L1→L2 message it references
|
|
57
|
+
* becomes available later — see {@link waitForL1ToL2Message}.
|
|
58
|
+
*/ export async function bridgeFeeJuice(params) {
|
|
59
|
+
const { node, l1RpcUrl, l1ChainId, recipient } = params;
|
|
60
|
+
const l1PrivateKey = params.l1PrivateKey ?? generatePrivateKey();
|
|
61
|
+
const chain = createEthereumChain([
|
|
62
|
+
l1RpcUrl
|
|
63
|
+
], l1ChainId);
|
|
64
|
+
const l1Client = createExtendedL1Client(chain.rpcUrls, l1PrivateKey, chain.chainInfo);
|
|
65
|
+
const portalManager = await L1FeeJuicePortalManager.new(node, l1Client, logger);
|
|
66
|
+
const tokenManager = portalManager.getTokenManager();
|
|
67
|
+
const route = pickBridgeRoute({
|
|
68
|
+
hasFaucet: tokenManager.handlerAddress !== undefined,
|
|
69
|
+
l1Balance: await tokenManager.getL1TokenBalance(l1Client.account.address),
|
|
70
|
+
amount: params.amount
|
|
71
|
+
});
|
|
72
|
+
return await portalManager.bridgeTokensPublic(recipient, route.amount, route.useFaucet);
|
|
73
|
+
}
|
|
74
|
+
/** Waits until an L1→L2 message is available on the node (warping time forward in `warp` mode). */ export async function waitForL1ToL2Message(params) {
|
|
75
|
+
const { node, messageHash, mode } = params;
|
|
76
|
+
if (mode === 'warp') {
|
|
77
|
+
await warpToL1ToL2Message(node, messageHash, {
|
|
78
|
+
...params.warpOpts,
|
|
79
|
+
timeoutMs: params.timeoutMs ?? 120_000
|
|
80
|
+
});
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const timeoutMs = params.timeoutMs ?? 30 * 60_000;
|
|
84
|
+
const startedAt = Date.now();
|
|
85
|
+
let lastLog = startedAt;
|
|
86
|
+
await retryUntil(async ()=>{
|
|
87
|
+
if (await isL1ToL2MessageReady(node, messageHash)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (Date.now() - lastLog > POLL_LOG_INTERVAL_MS) {
|
|
91
|
+
lastLog = Date.now();
|
|
92
|
+
logger.info('Still waiting for L1→L2 message to become available', {
|
|
93
|
+
messageHash: messageHash.toString(),
|
|
94
|
+
elapsedMs: Date.now() - startedAt,
|
|
95
|
+
timeoutMs
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return undefined;
|
|
99
|
+
}, `L1→L2 message ${messageHash.toString()}`, timeoutMs / 1000, POLL_INTERVAL_MS / 1000);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Local-network helper: advances L1 + L2 time via the node debug API until the given L1→L2 message
|
|
103
|
+
* shows up as available, warping by one L2 slot (read from the node's rollup constants) per check.
|
|
104
|
+
* An in-process node (e.g. a test fixture's `AztecNodeService`) implements the debug interface
|
|
105
|
+
* directly; a remote node is reached via its debug RPC at `nodeUrl` — `warpL2TimeAtLeastBy` needs
|
|
106
|
+
* `AztecNode & AztecNodeDebug` (it reads the current L1 timestamp via the regular API before
|
|
107
|
+
* warping), and both clients target the same URL and expose their methods as own properties on the
|
|
108
|
+
* rpc proxy, so a shallow merge is safe.
|
|
109
|
+
*/ export async function warpToL1ToL2Message(node, messageHash, opts = {}) {
|
|
110
|
+
const nodeUrl = opts.nodeUrl ?? 'http://localhost:8080';
|
|
111
|
+
const timeoutMs = opts.timeoutMs ?? 120_000;
|
|
112
|
+
const fullNode = typeof node.warpL2TimeAtLeastBy === 'function' ? node : Object.assign({}, node, createAztecNodeDebugClient(nodeUrl));
|
|
113
|
+
const { slotDuration } = await node.getL1Constants();
|
|
114
|
+
await retryUntil(async ()=>{
|
|
115
|
+
if (await isL1ToL2MessageReady(node, messageHash)) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
await fullNode.warpL2TimeAtLeastBy(slotDuration);
|
|
119
|
+
return undefined;
|
|
120
|
+
}, `L1→L2 message ${messageHash.toString()} (warping)`, timeoutMs / 1000, WARP_POLL_INTERVAL_MS / 1000);
|
|
121
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fee handling for the deploy framework. Each account pays per its own {@link FeePolicy} — which
|
|
3
|
+
* may override the spec-wide default:
|
|
4
|
+
*
|
|
5
|
+
* - `sponsored` → a SponsoredFPC pays (the local-network default). All sponsored accounts share
|
|
6
|
+
* one payment method.
|
|
7
|
+
* - `fee-juice` → the account pays from its own Fee Juice; if below `threshold` with work to do,
|
|
8
|
+
* bridge `fundAmount` from L1. The bridge claim is single-use: the first paying tx claims it
|
|
9
|
+
* (`FeeJuicePaymentMethodWithClaim`) and the rest spend the balance. Pending claims are persisted
|
|
10
|
+
* (see ./state.ts) so a crash between bridge and claim resumes.
|
|
11
|
+
*/
|
|
12
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
13
|
+
import { type FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
14
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
15
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
16
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
17
|
+
import type { GasFees } from '@aztec/stdlib/gas';
|
|
18
|
+
import type { Hex } from 'viem';
|
|
19
|
+
import type { AccountFunding, DeployReporter } from './reporter.js';
|
|
20
|
+
import type { DeployState } from './state.js';
|
|
21
|
+
import type { FeePolicy } from './types.js';
|
|
22
|
+
/** The `fee` field of a send-options object. */
|
|
23
|
+
export interface SendFee {
|
|
24
|
+
paymentMethod?: FeePaymentMethod;
|
|
25
|
+
gasSettings?: {
|
|
26
|
+
maxFeesPerGas: GasFees;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sane fee defaults: local pays via SponsoredFPC; every other network pays from bridged Fee Juice.
|
|
31
|
+
* The threshold/fundAmount pair trades off L1 round-trips (too low → frequent re-bridges) against
|
|
32
|
+
* stranding Fee Juice, which is non-transferable, on the account (too high).
|
|
33
|
+
*/
|
|
34
|
+
export declare function defaultFeePolicy(local: boolean): FeePolicy;
|
|
35
|
+
/** The public Fee Juice balance of `address` (any address — contract or account), read via `from`. */
|
|
36
|
+
export declare function publicFeeJuiceBalance(wallet: Wallet, address: AztecAddress, from: AztecAddress): Promise<bigint>;
|
|
37
|
+
/**
|
|
38
|
+
* Resolves an account's funding posture under `policy` — what the plan reports and what
|
|
39
|
+
* {@link prepareFeeSession} acts on. `idle` accounts (no pending work) are never funded; sponsored
|
|
40
|
+
* accounts never read a balance; fee-juice accounts are `funded` iff their balance clears the
|
|
41
|
+
* threshold, else `not-funded` (a bridge will top them up).
|
|
42
|
+
*/
|
|
43
|
+
export declare function accountFunding(policy: FeePolicy, wallet: Wallet, account: AztecAddress, hasWork: boolean): Promise<AccountFunding>;
|
|
44
|
+
/** What {@link obtainFeeJuiceClaim} needs to produce a consumable claim for a recipient. */
|
|
45
|
+
export interface ObtainFeeJuiceClaimOpts {
|
|
46
|
+
/** Whether the target is a local (anvil) network — drives warp-vs-poll + L1 defaults. */
|
|
47
|
+
local: boolean;
|
|
48
|
+
node: AztecNode;
|
|
49
|
+
/** The node's URL — reaches its debug API for local time-warping while the bridge settles. */
|
|
50
|
+
nodeUrl?: string;
|
|
51
|
+
recipient: AztecAddress;
|
|
52
|
+
/** Amount to bridge (wei). */
|
|
53
|
+
amount: bigint;
|
|
54
|
+
/** L1 connection + funder, defaulted per {@link resolveL1Config}. */
|
|
55
|
+
l1: {
|
|
56
|
+
l1FunderKey?: Hex;
|
|
57
|
+
l1RpcUrl?: string;
|
|
58
|
+
l1ChainId?: number;
|
|
59
|
+
};
|
|
60
|
+
state: DeployState;
|
|
61
|
+
persist: () => void;
|
|
62
|
+
reporter: DeployReporter;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A single-use Fee Juice claim for `recipient` (used by `fund` steps): resumes the persisted claim
|
|
66
|
+
* when present, else bridges `amount` from L1 and waits for the L1→L2 message. The claim persists
|
|
67
|
+
* before the wait, so a crash mid-wait resumes it instead of stranding the bridged funds. The
|
|
68
|
+
* caller consumes it (e.g. via `FeeJuice.claim`) and calls `onConsumed` once that tx mines.
|
|
69
|
+
*/
|
|
70
|
+
export declare function obtainFeeJuiceClaim(opts: ObtainFeeJuiceClaimOpts): Promise<{
|
|
71
|
+
claimAmount: bigint;
|
|
72
|
+
claimSecret: Fr;
|
|
73
|
+
messageLeafIndex: bigint;
|
|
74
|
+
/** Drops the persisted resume entry — call once the consuming tx mines. */
|
|
75
|
+
onConsumed: () => void;
|
|
76
|
+
}>;
|
|
77
|
+
/** Per-account fee dispensing for one run, prepared by {@link prepareFeeSession}. */
|
|
78
|
+
export interface FeeSession {
|
|
79
|
+
/**
|
|
80
|
+
* Fee options for the next tx from `account`, plus `onConsumed` to call after it lands (clears a
|
|
81
|
+
* one-time bridge claim from persisted state). Subsequent calls pay from balance.
|
|
82
|
+
*/
|
|
83
|
+
next(account: AztecAddress): {
|
|
84
|
+
fee: SendFee;
|
|
85
|
+
onConsumed: () => void;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Whether `account`'s next tx will carry its one-time bridge claim. The runner serializes such an
|
|
89
|
+
* account's first tx: the claim must mine before its balance-paying txs fan out.
|
|
90
|
+
*/
|
|
91
|
+
hasPendingClaim(account: AztecAddress): boolean;
|
|
92
|
+
}
|
|
93
|
+
/** What {@link prepareFeeSession} needs to fund a run's working accounts. */
|
|
94
|
+
export interface PrepareFeeSessionOpts {
|
|
95
|
+
/** Whether the target is a local (anvil) network — drives warp-vs-poll + L1 defaults. */
|
|
96
|
+
local: boolean;
|
|
97
|
+
node: AztecNode;
|
|
98
|
+
/** The node's URL — reaches its debug API for local time-warping while a bridge settles. */
|
|
99
|
+
nodeUrl?: string;
|
|
100
|
+
wallet: Wallet;
|
|
101
|
+
/**
|
|
102
|
+
* Working accounts (those with pending work) with their resolved {@link FeePolicy} + funding (from
|
|
103
|
+
* {@link accountFunding}) — so this function doesn't re-read balances.
|
|
104
|
+
*/
|
|
105
|
+
accounts: {
|
|
106
|
+
address: AztecAddress;
|
|
107
|
+
policy: FeePolicy;
|
|
108
|
+
funding: AccountFunding;
|
|
109
|
+
}[];
|
|
110
|
+
state: DeployState;
|
|
111
|
+
persist: () => void;
|
|
112
|
+
reporter: DeployReporter;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Resolves fees ahead of execution, per account: registers the shared SponsoredFPC (for sponsored
|
|
116
|
+
* accounts), or tops up a fee-juice account via a bridge (reusing a persisted pending claim when
|
|
117
|
+
* present). Returns a {@link FeeSession} that dispenses the right fee per tx, by sending account.
|
|
118
|
+
*/
|
|
119
|
+
export declare function prepareFeeSession(opts: PrepareFeeSessionOpts): Promise<FeeSession>;
|
|
120
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmVlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2RlcGxveS9mZWVzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7O0dBVUc7QUFDS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ACnB,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,CAyGxF"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fee handling for the deploy framework. Each account pays per its own {@link FeePolicy} — which
|
|
3
|
+
* may override the spec-wide default:
|
|
4
|
+
*
|
|
5
|
+
* - `sponsored` → a SponsoredFPC pays (the local-network default). All sponsored accounts share
|
|
6
|
+
* one payment method.
|
|
7
|
+
* - `fee-juice` → the account pays from its own Fee Juice; if below `threshold` with work to do,
|
|
8
|
+
* bridge `fundAmount` from L1. The bridge claim is single-use: the first paying tx claims it
|
|
9
|
+
* (`FeeJuicePaymentMethodWithClaim`) and the rest spend the balance. Pending claims are persisted
|
|
10
|
+
* (see ./state.ts) so a crash between bridge and claim resumes.
|
|
11
|
+
*/ import { FeeJuicePaymentMethodWithClaim, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
12
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
13
|
+
import { FeeJuiceContract } from '@aztec/aztec.js/protocol';
|
|
14
|
+
import { registerDeployedSponsoredFPCInWalletAndGetAddress } from '../local-network/sponsored_fpc.js';
|
|
15
|
+
import { bridgeFeeJuice, waitForL1ToL2Message } from './bridging.js';
|
|
16
|
+
/** Anvil's first pre-funded dev key — used as the local-network L1 funder. Published, non-secret. */ const ANVIL_DEV_KEY = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
|
|
17
|
+
const DEFAULT_LOCAL_L1_RPC_URL = 'http://localhost:8545';
|
|
18
|
+
const DEFAULT_LOCAL_L1_CHAIN_ID = 31337;
|
|
19
|
+
/**
|
|
20
|
+
* Sane fee defaults: local pays via SponsoredFPC; every other network pays from bridged Fee Juice.
|
|
21
|
+
* The threshold/fundAmount pair trades off L1 round-trips (too low → frequent re-bridges) against
|
|
22
|
+
* stranding Fee Juice, which is non-transferable, on the account (too high).
|
|
23
|
+
*/ export function defaultFeePolicy(local) {
|
|
24
|
+
if (local) {
|
|
25
|
+
return {
|
|
26
|
+
kind: 'sponsored'
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
kind: 'fee-juice',
|
|
31
|
+
threshold: 100n * 10n ** 18n,
|
|
32
|
+
fundAmount: 1000n * 10n ** 18n
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** The public Fee Juice balance of `address` (any address — contract or account), read via `from`. */ export async function publicFeeJuiceBalance(wallet, address, from) {
|
|
36
|
+
const { result } = await FeeJuiceContract.at(wallet).methods.balance_of_public(address).simulate({
|
|
37
|
+
from
|
|
38
|
+
});
|
|
39
|
+
return BigInt(result.toString());
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolves an account's funding posture under `policy` — what the plan reports and what
|
|
43
|
+
* {@link prepareFeeSession} acts on. `idle` accounts (no pending work) are never funded; sponsored
|
|
44
|
+
* accounts never read a balance; fee-juice accounts are `funded` iff their balance clears the
|
|
45
|
+
* threshold, else `not-funded` (a bridge will top them up).
|
|
46
|
+
*/ export async function accountFunding(policy, wallet, account, hasWork) {
|
|
47
|
+
if (!hasWork) {
|
|
48
|
+
return {
|
|
49
|
+
kind: 'idle'
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (policy.kind === 'sponsored') {
|
|
53
|
+
return {
|
|
54
|
+
kind: 'sponsored'
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const balance = await publicFeeJuiceBalance(wallet, account, account);
|
|
58
|
+
return balance >= policy.threshold ? {
|
|
59
|
+
kind: 'funded',
|
|
60
|
+
balance
|
|
61
|
+
} : {
|
|
62
|
+
kind: 'not-funded',
|
|
63
|
+
balance,
|
|
64
|
+
fundAmount: policy.fundAmount
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolves the L1 connection + funder for a bridge from caller-supplied config, defaulting to anvil
|
|
69
|
+
* on local. The funder key falls back to anvil's dev key on local (its faucet `mint` is owner-gated,
|
|
70
|
+
* so an ephemeral key is rejected there); elsewhere an omitted key means an ephemeral key + the
|
|
71
|
+
* public faucet. Deliberately no env fallback — the framework never reads the environment.
|
|
72
|
+
*/ function resolveL1Config(local, cfg) {
|
|
73
|
+
const l1RpcUrl = cfg.l1RpcUrl ?? (local ? DEFAULT_LOCAL_L1_RPC_URL : undefined);
|
|
74
|
+
const l1ChainId = cfg.l1ChainId ?? (local ? DEFAULT_LOCAL_L1_CHAIN_ID : undefined);
|
|
75
|
+
if (l1RpcUrl === undefined || l1ChainId === undefined) {
|
|
76
|
+
throw new Error('Bridging on a non-local network requires `l1RpcUrl` and `l1ChainId` (no hardcoded defaults).');
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
l1RpcUrl,
|
|
80
|
+
l1ChainId,
|
|
81
|
+
l1PrivateKey: cfg.l1FunderKey ?? (local ? ANVIL_DEV_KEY : undefined)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A single-use Fee Juice claim for `recipient` (used by `fund` steps): resumes the persisted claim
|
|
86
|
+
* when present, else bridges `amount` from L1 and waits for the L1→L2 message. The claim persists
|
|
87
|
+
* before the wait, so a crash mid-wait resumes it instead of stranding the bridged funds. The
|
|
88
|
+
* caller consumes it (e.g. via `FeeJuice.claim`) and calls `onConsumed` once that tx mines.
|
|
89
|
+
*/ export async function obtainFeeJuiceClaim(opts) {
|
|
90
|
+
const { local, node, nodeUrl, recipient, state, persist, reporter } = opts;
|
|
91
|
+
// Prefixed so a recipient that is also an auto-funded sender doesn't collide with its account claim.
|
|
92
|
+
const key = `fund:${recipient.toString()}`;
|
|
93
|
+
let claim;
|
|
94
|
+
const stored = state.pendingClaims[key];
|
|
95
|
+
if (stored) {
|
|
96
|
+
reporter.onBridge?.({
|
|
97
|
+
recipient,
|
|
98
|
+
amount: BigInt(stored.claimAmount),
|
|
99
|
+
reused: true
|
|
100
|
+
});
|
|
101
|
+
claim = {
|
|
102
|
+
claimAmount: BigInt(stored.claimAmount),
|
|
103
|
+
claimSecret: Fr.fromString(stored.claimSecret),
|
|
104
|
+
messageLeafIndex: BigInt(stored.messageLeafIndex)
|
|
105
|
+
};
|
|
106
|
+
} else {
|
|
107
|
+
reporter.onBridge?.({
|
|
108
|
+
recipient,
|
|
109
|
+
amount: opts.amount,
|
|
110
|
+
reused: false
|
|
111
|
+
});
|
|
112
|
+
const { l1RpcUrl, l1ChainId, l1PrivateKey } = resolveL1Config(local, opts.l1);
|
|
113
|
+
const bridged = await bridgeFeeJuice({
|
|
114
|
+
node,
|
|
115
|
+
recipient,
|
|
116
|
+
l1RpcUrl,
|
|
117
|
+
l1ChainId,
|
|
118
|
+
amount: opts.amount,
|
|
119
|
+
l1PrivateKey
|
|
120
|
+
});
|
|
121
|
+
state.pendingClaims[key] = {
|
|
122
|
+
claimAmount: bridged.claimAmount.toString(),
|
|
123
|
+
claimSecret: bridged.claimSecret.toString(),
|
|
124
|
+
messageLeafIndex: bridged.messageLeafIndex.toString()
|
|
125
|
+
};
|
|
126
|
+
persist();
|
|
127
|
+
await waitForL1ToL2Message({
|
|
128
|
+
node,
|
|
129
|
+
messageHash: Fr.fromHexString(bridged.messageHash),
|
|
130
|
+
mode: local ? 'warp' : 'poll',
|
|
131
|
+
...nodeUrl ? {
|
|
132
|
+
warpOpts: {
|
|
133
|
+
nodeUrl
|
|
134
|
+
}
|
|
135
|
+
} : {}
|
|
136
|
+
});
|
|
137
|
+
claim = {
|
|
138
|
+
claimAmount: bridged.claimAmount,
|
|
139
|
+
claimSecret: bridged.claimSecret,
|
|
140
|
+
messageLeafIndex: bridged.messageLeafIndex
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
return {
|
|
144
|
+
...claim,
|
|
145
|
+
onConsumed: ()=>{
|
|
146
|
+
delete state.pendingClaims[key];
|
|
147
|
+
persist();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Resolves fees ahead of execution, per account: registers the shared SponsoredFPC (for sponsored
|
|
153
|
+
* accounts), or tops up a fee-juice account via a bridge (reusing a persisted pending claim when
|
|
154
|
+
* present). Returns a {@link FeeSession} that dispenses the right fee per tx, by sending account.
|
|
155
|
+
*/ export async function prepareFeeSession(opts) {
|
|
156
|
+
const { local, node, nodeUrl, wallet, accounts, state, persist, reporter } = opts;
|
|
157
|
+
// Shared sponsored payment method: register the SponsoredFPC + read gas once, if anyone uses it.
|
|
158
|
+
let sponsoredFee;
|
|
159
|
+
if (accounts.some((a)=>a.policy.kind === 'sponsored')) {
|
|
160
|
+
const sponsoredFPCAddress = await registerDeployedSponsoredFPCInWalletAndGetAddress(wallet);
|
|
161
|
+
sponsoredFee = {
|
|
162
|
+
paymentMethod: new SponsoredFeePaymentMethod(sponsoredFPCAddress),
|
|
163
|
+
// 10x headroom because this one quote is reused for every tx in the run (the wallet's default would re-quote
|
|
164
|
+
// per tx at 1.5x min): congestion pricing can push the min fee well past the starting quote over a run of
|
|
165
|
+
// parallel layers. Overstating the cap is free — txs pay the going rate, not the cap, and the FPC pays anyway.
|
|
166
|
+
gasSettings: {
|
|
167
|
+
maxFeesPerGas: (await node.getCurrentMinFees()).mul(10)
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
// Bridge fee-juice top-ups. The L1 sends stay sequential — a shared funder key would collide on
|
|
172
|
+
// nonces — but the L1→L2 availability waits (the minutes-long part on a real network) run
|
|
173
|
+
// concurrently afterwards. Warp-mode waits run inline instead: warping manipulates global time,
|
|
174
|
+
// so concurrent warps would fight. Each claim persists as soon as it exists on L1, so a crash
|
|
175
|
+
// mid-wait resumes it instead of stranding the bridged funds; a resumed claim skips the wait (by
|
|
176
|
+
// resume time the message is available on any live network).
|
|
177
|
+
const claims = new Map();
|
|
178
|
+
const messageWaits = [];
|
|
179
|
+
for (const { address, policy, funding } of accounts){
|
|
180
|
+
if (policy.kind !== 'fee-juice' || funding.kind === 'funded') {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const key = address.toString();
|
|
184
|
+
let stored = state.pendingClaims[key];
|
|
185
|
+
if (stored) {
|
|
186
|
+
reporter.onBridge?.({
|
|
187
|
+
recipient: address,
|
|
188
|
+
amount: BigInt(stored.claimAmount),
|
|
189
|
+
reused: true
|
|
190
|
+
});
|
|
191
|
+
} else {
|
|
192
|
+
reporter.onBridge?.({
|
|
193
|
+
recipient: address,
|
|
194
|
+
amount: policy.fundAmount,
|
|
195
|
+
reused: false
|
|
196
|
+
});
|
|
197
|
+
// Local defaults to anvil; a non-local network must supply L1 connection details.
|
|
198
|
+
const { l1ChainId, l1RpcUrl, l1PrivateKey } = resolveL1Config(local, policy);
|
|
199
|
+
const bridged = await bridgeFeeJuice({
|
|
200
|
+
node,
|
|
201
|
+
recipient: address,
|
|
202
|
+
l1RpcUrl,
|
|
203
|
+
l1ChainId,
|
|
204
|
+
amount: policy.fundAmount,
|
|
205
|
+
l1PrivateKey
|
|
206
|
+
});
|
|
207
|
+
stored = {
|
|
208
|
+
claimAmount: bridged.claimAmount.toString(),
|
|
209
|
+
claimSecret: bridged.claimSecret.toString(),
|
|
210
|
+
messageLeafIndex: bridged.messageLeafIndex.toString()
|
|
211
|
+
};
|
|
212
|
+
state.pendingClaims[key] = stored;
|
|
213
|
+
persist();
|
|
214
|
+
const wait = waitForL1ToL2Message({
|
|
215
|
+
node,
|
|
216
|
+
messageHash: Fr.fromHexString(bridged.messageHash),
|
|
217
|
+
mode: local ? 'warp' : 'poll',
|
|
218
|
+
...nodeUrl ? {
|
|
219
|
+
warpOpts: {
|
|
220
|
+
nodeUrl
|
|
221
|
+
}
|
|
222
|
+
} : {}
|
|
223
|
+
});
|
|
224
|
+
if (local) {
|
|
225
|
+
await wait;
|
|
226
|
+
} else {
|
|
227
|
+
messageWaits.push(wait);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
claims.set(key, new FeeJuicePaymentMethodWithClaim(address, {
|
|
231
|
+
claimAmount: BigInt(stored.claimAmount),
|
|
232
|
+
claimSecret: Fr.fromString(stored.claimSecret),
|
|
233
|
+
messageLeafIndex: BigInt(stored.messageLeafIndex)
|
|
234
|
+
}));
|
|
235
|
+
}
|
|
236
|
+
await Promise.all(messageWaits);
|
|
237
|
+
// Per-account dispenser state. A claim is single-use: the first `next()` for its account carries
|
|
238
|
+
// it, and `onConsumed` (invoked by the runner once that tx mines) drops the persisted resume entry.
|
|
239
|
+
const sessions = new Map();
|
|
240
|
+
for (const { address, policy } of accounts){
|
|
241
|
+
const key = address.toString();
|
|
242
|
+
sessions.set(key, {
|
|
243
|
+
sponsored: policy.kind === 'sponsored',
|
|
244
|
+
claim: claims.get(key)
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
next: (account)=>{
|
|
249
|
+
const key = account.toString();
|
|
250
|
+
const session = sessions.get(key);
|
|
251
|
+
if (session?.sponsored) {
|
|
252
|
+
return {
|
|
253
|
+
fee: sponsoredFee ?? {},
|
|
254
|
+
onConsumed: ()=>{}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
if (session?.claim) {
|
|
258
|
+
const claim = session.claim;
|
|
259
|
+
session.claim = undefined; // single-use: only this first tx carries it
|
|
260
|
+
return {
|
|
261
|
+
fee: {
|
|
262
|
+
paymentMethod: claim
|
|
263
|
+
},
|
|
264
|
+
onConsumed: ()=>{
|
|
265
|
+
// claim is now spent on-chain; drop its resume entry
|
|
266
|
+
delete state.pendingClaims[key];
|
|
267
|
+
persist();
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
fee: {},
|
|
273
|
+
onConsumed: ()=>{}
|
|
274
|
+
}; // later txs (or already-funded): pay from the account's balance
|
|
275
|
+
},
|
|
276
|
+
hasPendingClaim: (account)=>sessions.get(account.toString())?.claim !== undefined
|
|
277
|
+
};
|
|
278
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency-graph utilities for the deploy framework: topological layering (which steps
|
|
3
|
+
* can run together) and a pretty-printer for the resulting plan.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Group `nodes` into dependency layers (Kahn's algorithm). Each layer contains nodes whose
|
|
7
|
+
* dependencies all sit in earlier layers, so a layer's nodes are mutually independent and
|
|
8
|
+
* may run in parallel. Dependencies pointing outside `nodes` (e.g. already-satisfied work)
|
|
9
|
+
* are treated as satisfied. Throws on a cycle.
|
|
10
|
+
*/
|
|
11
|
+
export declare function topologicalLayers(nodes: string[], dependencies: Map<string, string[]>): string[][];
|
|
12
|
+
/**
|
|
13
|
+
* Like {@link topologicalLayers}, but nodes for which `floatLate(node)` is true are scheduled as
|
|
14
|
+
* LATE as their dependents allow (ALAP) instead of as early as possible. Used to push batchable
|
|
15
|
+
* actions into the latest layer they can share, so same-account actions in adjacent layers coalesce
|
|
16
|
+
* into one tx. Fixed nodes (e.g. contract publishes, which unblock dependents and don't batch) keep
|
|
17
|
+
* their earliest layer; the relative order — and so the critical-path length — is unchanged. Throws
|
|
18
|
+
* on a cycle (via {@link topologicalLayers}).
|
|
19
|
+
*/
|
|
20
|
+
export declare function scheduleLayers(nodes: string[], dependencies: Map<string, string[]>, floatLate: (node: string) => boolean): string[][];
|
|
21
|
+
/** One node in the printed plan. */
|
|
22
|
+
export interface PlanRow {
|
|
23
|
+
/** e.g. "goCoin" */
|
|
24
|
+
name: string;
|
|
25
|
+
/** short tag, e.g. "Token · publishes class" */
|
|
26
|
+
tag?: string;
|
|
27
|
+
/** dependency names to show as `← a, b` */
|
|
28
|
+
dependencies?: string[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Render a titled flat list of plan rows (no layer grouping). Use for the declared-contracts
|
|
32
|
+
* overview, whose `← ...` arrows are constructor-arg references — not an execution order.
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatList(title: string, rows: PlanRow[]): string;
|
|
35
|
+
/**
|
|
36
|
+
* Render a titled, layer-grouped section of the plan as an indented tree. Each layer's txs are
|
|
37
|
+
* submitted in parallel.
|
|
38
|
+
*/
|
|
39
|
+
export declare function formatLayers(title: string, layers: PlanRow[][]): string;
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JhcGguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9kZXBsb3kvZ3JhcGgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBRUg7Ozs7O0dBS0c7QUFDSCx3QkFBZ0IsaUJBQWlCLENBQUMsS0FBSyxFQUFFLE1BQU0sRUFBRSxFQUFFLFlBQVksRUFBRSxHQUFHLENBQUMsTUFBTSxFQUFFLE1BQU0sRUFBRSxDQUFDLEdBQUcsTUFBTSxFQUFFLEVBQUUsQ0FpQmxHO0FBRUQ7Ozs7Ozs7R0FPRztBQUNILHdCQUFnQixjQUFjLENBQzVCLEtBQUssRUFBRSxNQUFNLEVBQUUsRUFDZixZQUFZLEVBQUUsR0FBRyxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsQ0FBQyxFQUNuQyxTQUFTLEVBQUUsQ0FBQyxJQUFJLEVBQUUsTUFBTSxLQUFLLE9BQU8sR0FDbkMsTUFBTSxFQUFFLEVBQUUsQ0ErQ1o7QUFFRCxvQ0FBb0M7QUFDcEMsTUFBTSxXQUFXLE9BQU87SUFDdEIsb0JBQW9CO0lBQ3BCLElBQUksRUFBRSxNQUFNLENBQUM7SUFDYixpREFBZ0Q7SUFDaEQsR0FBRyxDQUFDLEVBQUUsTUFBTSxDQUFDO0lBQ2IsNkNBQTJDO0lBQzNDLFlBQVksQ0FB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