@aztec/ethereum 0.0.1-commit.2f68f620 → 0.0.1-commit.3100065
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/config.d.ts +10 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +24 -0
- package/dest/contracts/gse.d.ts +4 -2
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/gse.js +2 -2
- package/dest/contracts/rollup.d.ts +168 -9
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +15 -5
- package/dest/deploy_aztec_l1_contracts.d.ts +5 -6
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +10 -7
- package/dest/generated/l1-contracts-defaults.d.ts +1 -1
- package/dest/generated/l1-contracts-defaults.js +1 -1
- package/dest/l1_artifacts.d.ts +1219 -77
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +3 -3
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +57 -15
- package/dest/publisher_manager.d.ts +18 -6
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +44 -7
- package/dest/test/blob_kzg_warmup.d.ts +19 -0
- package/dest/test/blob_kzg_warmup.d.ts.map +1 -0
- package/dest/test/blob_kzg_warmup.js +64 -0
- package/dest/test/chain_monitor.d.ts +33 -2
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +71 -6
- package/dest/test/eth_cheat_codes.d.ts +20 -3
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +50 -40
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/rollup_cheat_codes.d.ts +30 -1
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +27 -0
- package/dest/utils.js +11 -8
- package/package.json +5 -5
- package/src/config.ts +35 -0
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/rollup.ts +15 -6
- package/src/deploy_aztec_l1_contracts.ts +10 -9
- package/src/generated/l1-contracts-defaults.ts +1 -1
- package/src/l1_tx_utils/config.ts +3 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +52 -18
- package/src/publisher_manager.ts +54 -18
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +88 -5
- package/src/test/eth_cheat_codes.ts +47 -43
- package/src/test/index.ts +1 -0
- package/src/test/rollup_cheat_codes.ts +51 -0
- package/src/utils.ts +11 -11
|
@@ -72,6 +72,35 @@ export declare class RollupCheatCodes {
|
|
|
72
72
|
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
73
73
|
*/
|
|
74
74
|
markAsProven(maybeCheckpointNumber?: CheckpointNumber): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
|
|
77
|
+
* not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
|
|
78
|
+
*/
|
|
79
|
+
waitForEpoch(epoch: EpochNumber, opts?: {
|
|
80
|
+
timeout?: number;
|
|
81
|
+
interval?: number;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
|
|
85
|
+
* warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
|
|
86
|
+
*/
|
|
87
|
+
waitForSlot(slot: SlotNumber, opts?: {
|
|
88
|
+
timeout?: number;
|
|
89
|
+
interval?: number;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
|
|
93
|
+
* checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
|
|
94
|
+
* rather than a node, since a rollback lands on L1 first.
|
|
95
|
+
*
|
|
96
|
+
* A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
|
|
97
|
+
* replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
|
|
98
|
+
* empty state — hence the non-zero guard.
|
|
99
|
+
*/
|
|
100
|
+
waitForCheckpointBelow(checkpoint: CheckpointNumber, opts?: {
|
|
101
|
+
timeout?: number;
|
|
102
|
+
interval?: number;
|
|
103
|
+
}): Promise<CheckpointNumber>;
|
|
75
104
|
/**
|
|
76
105
|
* Overrides the inProgress field of the Inbox contract state
|
|
77
106
|
* @param howMuch - How many checkpoints to move it forward
|
|
@@ -115,4 +144,4 @@ export declare class RollupCheatCodes {
|
|
|
115
144
|
*/
|
|
116
145
|
clearProvingCostCooldown(): Promise<void>;
|
|
117
146
|
}
|
|
118
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
147
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwX2NoZWF0X2NvZGVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9yb2xsdXBfY2hlYXRfY29kZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQzlELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxXQUFXLEVBQUUsVUFBVSxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFJNUYsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFDNUQsT0FBTyxFQUFFL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sRUFBRSxNQUFNLEtBQUssTUFBTSxpQkFJckU7SUFFRDs7OztPQUlHO0lBQ1UscUJBQXFCLENBQUMsUUFBUSxFQUFFLE1BQU0saUJBaUJsRDtJQUVEOzs7Ozs7Ozs7Ozs7T0FZRztJQUNVLHdCQUF3QixrQkFPcEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI5F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,GAAG,EAOT,MAAM,MAAM,CAAC;AAEd,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,8CAA8C;AAC9C,qBAAa,gBAAgB;IAOzB,OAAO,CAAC,aAAa;IANvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAA4D;IAE1E,OAAO,CAAC,MAAM,CAAuC;IAErD,YACU,aAAa,EAAE,aAAa,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Q,EAAE,MAAM,iBAiBlD;IAED;;;;;;;;;;;;OAYG;IACU,wBAAwB,kBAOpC;CACF"}
|
|
@@ -2,6 +2,7 @@ import { OutboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
|
2
2
|
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
5
6
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
7
|
import { createPublicClient, fallback, getContract, hexToBigInt, http, keccak256 } from 'viem';
|
|
7
8
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
@@ -216,6 +217,32 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
216
217
|
});
|
|
217
218
|
}
|
|
218
219
|
/**
|
|
220
|
+
* Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
|
|
221
|
+
* not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
|
|
222
|
+
*/ async waitForEpoch(epoch, opts = {}) {
|
|
223
|
+
await retryUntil(async ()=>await this.getEpoch() >= epoch || undefined, `rollup epoch >= ${epoch}`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
|
|
227
|
+
* warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
|
|
228
|
+
*/ async waitForSlot(slot, opts = {}) {
|
|
229
|
+
await retryUntil(async ()=>await this.getSlot() >= slot || undefined, `rollup slot >= ${slot}`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
|
|
233
|
+
* checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
|
|
234
|
+
* rather than a node, since a rollback lands on L1 first.
|
|
235
|
+
*
|
|
236
|
+
* A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
|
|
237
|
+
* replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
|
|
238
|
+
* empty state — hence the non-zero guard.
|
|
239
|
+
*/ async waitForCheckpointBelow(checkpoint, opts = {}) {
|
|
240
|
+
return await retryUntil(async ()=>{
|
|
241
|
+
const { pending } = await this.getTips();
|
|
242
|
+
return pending > 0 && pending < checkpoint ? pending : undefined;
|
|
243
|
+
}, `rollup checkpoint in (0, ${checkpoint})`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
219
246
|
* Overrides the inProgress field of the Inbox contract state
|
|
220
247
|
* @param howMuch - How many checkpoints to move it forward
|
|
221
248
|
*/ advanceInboxInProgress(howMuch) {
|
package/dest/utils.js
CHANGED
|
@@ -168,15 +168,18 @@ function getNestedErrorData(error) {
|
|
|
168
168
|
} catch {
|
|
169
169
|
// If decoding fails, we fall back to the original formatting
|
|
170
170
|
}
|
|
171
|
-
// Strip ABI from the error object before formatting
|
|
171
|
+
// Strip ABI from the error object before formatting. We clone first to avoid mutating the
|
|
172
|
+
// caller's error, but structuredClone throws DataCloneError on values it cannot clone (e.g.
|
|
173
|
+
// viem RPC errors carrying function-valued request context). If cloning fails, fall back to
|
|
174
|
+
// formatting the original error untouched rather than letting the clone failure mask it.
|
|
172
175
|
if (error && typeof error === 'object') {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
176
|
+
try {
|
|
177
|
+
const errorClone = structuredClone(error);
|
|
178
|
+
stripAbis(errorClone);
|
|
179
|
+
error = errorClone;
|
|
180
|
+
} catch {
|
|
181
|
+
// Leave `error` as the original; we skip stripAbis to avoid mutating the caller's object.
|
|
182
|
+
}
|
|
180
183
|
}
|
|
181
184
|
// If it's a regular Error instance, return it with its message
|
|
182
185
|
if (error instanceof Error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.3100065",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./account": "./dest/account.js",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"../package.common.json"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
54
|
-
"@aztec/constants": "0.0.1-commit.
|
|
55
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
56
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
53
|
+
"@aztec/blob-lib": "0.0.1-commit.3100065",
|
|
54
|
+
"@aztec/constants": "0.0.1-commit.3100065",
|
|
55
|
+
"@aztec/foundation": "0.0.1-commit.3100065",
|
|
56
|
+
"@aztec/l1-artifacts": "0.0.1-commit.3100065",
|
|
57
57
|
"dotenv": "^16.0.3",
|
|
58
58
|
"lodash.chunk": "^4.2.0",
|
|
59
59
|
"lodash.pickby": "^4.5.0",
|
package/src/config.ts
CHANGED
|
@@ -246,6 +246,41 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
246
246
|
*/
|
|
247
247
|
export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
|
|
248
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Validates that `ethereumSlotDuration` and `aztecSlotDuration` are positive and that the L2 slot is an exact
|
|
251
|
+
* multiple of the L1 slot. Every L2 slot boundary must land on an L1 slot boundary; a non-multiple pairing
|
|
252
|
+
* desyncs the epoch/checkpoint timing math throughout the sequencer, validator client, and timetables. Returns
|
|
253
|
+
* a list of error messages (empty when valid).
|
|
254
|
+
*/
|
|
255
|
+
export function validateSlotDurations(
|
|
256
|
+
config: Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration'>,
|
|
257
|
+
): string[] {
|
|
258
|
+
const errors: string[] = [];
|
|
259
|
+
if (config.ethereumSlotDuration <= 0) {
|
|
260
|
+
errors.push(`ethereumSlotDuration must be positive (got ${config.ethereumSlotDuration})`);
|
|
261
|
+
}
|
|
262
|
+
if (config.aztecSlotDuration <= 0) {
|
|
263
|
+
errors.push(`aztecSlotDuration must be positive (got ${config.aztecSlotDuration})`);
|
|
264
|
+
}
|
|
265
|
+
if (config.ethereumSlotDuration > 0 && config.aztecSlotDuration % config.ethereumSlotDuration !== 0) {
|
|
266
|
+
errors.push(
|
|
267
|
+
`aztecSlotDuration (${config.aztecSlotDuration}s) must be a multiple of ethereumSlotDuration ` +
|
|
268
|
+
`(${config.ethereumSlotDuration}s)`,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
return errors;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** Throws if {@link validateSlotDurations} reports any errors. */
|
|
275
|
+
export function assertValidSlotDurations(
|
|
276
|
+
config: Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration'>,
|
|
277
|
+
): void {
|
|
278
|
+
const errors = validateSlotDurations(config);
|
|
279
|
+
if (errors.length > 0) {
|
|
280
|
+
throw new Error(`Invalid slot duration configuration:\n${errors.map(e => ` - ${e}`).join('\n')}`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
249
284
|
export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
|
|
250
285
|
testAccounts: {
|
|
251
286
|
env: 'TEST_ACCOUNTS',
|
package/src/contracts/gse.ts
CHANGED
|
@@ -47,11 +47,16 @@ export class GSEContract {
|
|
|
47
47
|
return EthAddress.fromString(await this.gse.read.getGovernance());
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
getAttestersFromIndicesAtTime(
|
|
50
|
+
getAttestersFromIndicesAtTime(
|
|
51
|
+
instance: Hex | EthAddress,
|
|
52
|
+
ts: bigint,
|
|
53
|
+
indices: bigint[],
|
|
54
|
+
options?: { blockNumber?: bigint },
|
|
55
|
+
) {
|
|
51
56
|
if (instance instanceof EthAddress) {
|
|
52
57
|
instance = instance.toString();
|
|
53
58
|
}
|
|
54
|
-
return this.gse.read.getAttestersFromIndicesAtTime([instance, ts, indices]);
|
|
59
|
+
return this.gse.read.getAttestersFromIndicesAtTime([instance, ts, indices], options);
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
public async getRegistrationDigest(publicKey: ProjPointType<bigint>): Promise<ProjPointType<bigint>> {
|
package/src/contracts/rollup.ts
CHANGED
|
@@ -83,6 +83,7 @@ export type ViemHeader = {
|
|
|
83
83
|
feeRecipient: `0x${string}`;
|
|
84
84
|
gasFees: ViemGasFees;
|
|
85
85
|
totalManaUsed: bigint;
|
|
86
|
+
accumulatedFees: bigint;
|
|
86
87
|
};
|
|
87
88
|
|
|
88
89
|
export type ViemGasFees = {
|
|
@@ -554,8 +555,9 @@ export class RollupContract {
|
|
|
554
555
|
return EthAddress.fromString(await this.rollup.read.owner());
|
|
555
556
|
}
|
|
556
557
|
|
|
557
|
-
async getActiveAttesterCount(): Promise<number> {
|
|
558
|
-
|
|
558
|
+
async getActiveAttesterCount(options?: { blockNumber?: bigint }): Promise<number> {
|
|
559
|
+
await checkBlockTag(options?.blockNumber, this.client);
|
|
560
|
+
return Number(await this.rollup.read.getActiveAttesterCount(options));
|
|
559
561
|
}
|
|
560
562
|
|
|
561
563
|
public async getSlashingProposerAddress() {
|
|
@@ -812,7 +814,7 @@ export class RollupContract {
|
|
|
812
814
|
}
|
|
813
815
|
|
|
814
816
|
async getEpochProofPublicInputs(
|
|
815
|
-
args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly
|
|
817
|
+
args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly ViemHeader[], `0x${string}`],
|
|
816
818
|
): Promise<Fr[]> {
|
|
817
819
|
const result = await this.rollup.read.getEpochProofPublicInputs(args);
|
|
818
820
|
return result.map(Fr.fromString);
|
|
@@ -1190,13 +1192,20 @@ export class RollupContract {
|
|
|
1190
1192
|
}
|
|
1191
1193
|
|
|
1192
1194
|
async getAttesters(timestamp?: bigint): Promise<EthAddress[]> {
|
|
1193
|
-
|
|
1195
|
+
// Pin every read to a single L1 block so the attester count and the chunked index reads
|
|
1196
|
+
// observe a consistent set. Without this, the count and each chunk default to `latest` and
|
|
1197
|
+
// can straddle a block boundary (or reorg), yielding an inconsistent or truncated set.
|
|
1198
|
+
const block = await this.client.getBlock();
|
|
1199
|
+
const blockNumber = block.number ?? undefined;
|
|
1200
|
+
const ts = timestamp ?? block.timestamp;
|
|
1201
|
+
const attesterSize = await this.getActiveAttesterCount({ blockNumber });
|
|
1194
1202
|
const gse = new GSEContract(this.client, await this.getGSE());
|
|
1195
|
-
const ts = timestamp ?? (await this.client.getBlock()).timestamp;
|
|
1196
1203
|
const indices = Array.from({ length: attesterSize }, (_, i) => BigInt(i));
|
|
1197
1204
|
const chunks = chunk(indices, 1000);
|
|
1198
1205
|
|
|
1199
|
-
const results = await Promise.all(
|
|
1206
|
+
const results = await Promise.all(
|
|
1207
|
+
chunks.map(chunk => gse.getAttestersFromIndicesAtTime(this.address, ts, chunk, { blockNumber })),
|
|
1208
|
+
);
|
|
1200
1209
|
return results.flat().map(addr => EthAddress.fromString(addr));
|
|
1201
1210
|
}
|
|
1202
1211
|
|
|
@@ -5,12 +5,12 @@ import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
7
7
|
import type { Fr } from '@aztec/foundation/schemas';
|
|
8
|
+
import { fileURLToPath } from '@aztec/foundation/url';
|
|
8
9
|
|
|
9
10
|
import { bn254 } from '@noble/curves/bn254';
|
|
10
11
|
import type { Abi, Narrow } from 'abitype';
|
|
11
12
|
import { spawn } from 'child_process';
|
|
12
13
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
13
|
-
import { createRequire } from 'node:module';
|
|
14
14
|
import { tmpdir } from 'os';
|
|
15
15
|
import { dirname, join, resolve } from 'path';
|
|
16
16
|
import readline from 'readline';
|
|
@@ -19,7 +19,7 @@ import { mainnet, sepolia } from 'viem/chains';
|
|
|
19
19
|
|
|
20
20
|
import { createEthereumChain, isAnvilTestChain } from './chain.js';
|
|
21
21
|
import { createExtendedL1Client } from './client.js';
|
|
22
|
-
import type
|
|
22
|
+
import { type L1ContractsConfig, assertValidSlotDurations } from './config.js';
|
|
23
23
|
import { deployMulticall3 } from './contracts/multicall.js';
|
|
24
24
|
import { RollupContract } from './contracts/rollup.js';
|
|
25
25
|
import type { L1ContractAddresses } from './l1_contract_addresses.js';
|
|
@@ -27,8 +27,6 @@ import type { ExtendedViemWalletClient } from './types.js';
|
|
|
27
27
|
|
|
28
28
|
const logger = createLogger('ethereum:deploy_aztec_l1_contracts');
|
|
29
29
|
|
|
30
|
-
const require = createRequire(import.meta.url);
|
|
31
|
-
|
|
32
30
|
const JSON_DEPLOY_RESULT_PREFIX = 'JSON DEPLOY RESULT:';
|
|
33
31
|
|
|
34
32
|
/**
|
|
@@ -125,13 +123,15 @@ export interface ValidatorJson {
|
|
|
125
123
|
}
|
|
126
124
|
|
|
127
125
|
/**
|
|
128
|
-
* Gets the path to the l1-contracts foundry artifacts directory
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* the symlink in the portal case. The bundled foundry subtree sits alongside dest/, at <pkg>/l1-contracts.
|
|
126
|
+
* Gets the path to the l1-contracts foundry artifacts directory.
|
|
127
|
+
* These are copied from l1-contracts to yarn-project/l1-artifacts/l1-contracts
|
|
128
|
+
* during build to make yarn-project self-contained.
|
|
132
129
|
*/
|
|
133
130
|
export function getL1ContractsPath(): string {
|
|
134
|
-
|
|
131
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
132
|
+
// Go up from yarn-project/ethereum/dest to yarn-project, then to l1-artifacts/l1-contracts
|
|
133
|
+
const l1ContractsPath = resolve(currentDir, '..', '..', 'l1-artifacts', 'l1-contracts');
|
|
134
|
+
return l1ContractsPath;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// Cached deployment directory
|
|
@@ -282,6 +282,7 @@ export async function deployAztecL1Contracts(
|
|
|
282
282
|
args: DeployAztecL1ContractsArgs,
|
|
283
283
|
): Promise<DeployAztecL1ContractsReturnType> {
|
|
284
284
|
logger.info(`Deploying L1 contracts with config: ${jsonStringify(args)}`);
|
|
285
|
+
assertValidSlotDurations(args);
|
|
285
286
|
if (args.initialValidators && args.initialValidators.length > 0 && args.existingTokenAddress) {
|
|
286
287
|
throw new Error(
|
|
287
288
|
'Cannot deploy with both initialValidators and existingTokenAddress. ' +
|
|
@@ -13,7 +13,7 @@ export const l1ContractsDefaultEnv = {
|
|
|
13
13
|
AZTEC_EJECTION_THRESHOLD: 50000000000000000000,
|
|
14
14
|
AZTEC_LOCAL_EJECTION_THRESHOLD: 98000000000000000000,
|
|
15
15
|
AZTEC_EXIT_DELAY_SECONDS: 172800,
|
|
16
|
-
AZTEC_INBOX_LAG:
|
|
16
|
+
AZTEC_INBOX_LAG: 2,
|
|
17
17
|
AZTEC_PROOF_SUBMISSION_EPOCHS: 1,
|
|
18
18
|
AZTEC_MANA_TARGET: 100000000,
|
|
19
19
|
AZTEC_PROVING_COST_PER_MANA: 100,
|
|
@@ -73,7 +73,7 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
|
|
|
73
73
|
gasLimitBufferPercentage: {
|
|
74
74
|
description: 'How much to increase calculated gas limit by (percentage)',
|
|
75
75
|
env: 'L1_GAS_LIMIT_BUFFER_PERCENTAGE',
|
|
76
|
-
...
|
|
76
|
+
...floatConfigHelper(20),
|
|
77
77
|
},
|
|
78
78
|
maxGwei: {
|
|
79
79
|
description: 'Maximum gas price in gwei to be used for transactions.',
|
|
@@ -90,12 +90,12 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
|
|
|
90
90
|
priorityFeeBumpPercentage: {
|
|
91
91
|
description: 'How much to increase priority fee by each attempt (percentage)',
|
|
92
92
|
env: 'L1_PRIORITY_FEE_BUMP_PERCENTAGE',
|
|
93
|
-
...
|
|
93
|
+
...floatConfigHelper(20),
|
|
94
94
|
},
|
|
95
95
|
priorityFeeRetryBumpPercentage: {
|
|
96
96
|
description: 'How much to increase priority fee by each retry attempt (percentage)',
|
|
97
97
|
env: 'L1_PRIORITY_FEE_RETRY_BUMP_PERCENTAGE',
|
|
98
|
-
...
|
|
98
|
+
...floatConfigHelper(50),
|
|
99
99
|
},
|
|
100
100
|
minimumPriorityFeePerGas: {
|
|
101
101
|
description:
|
|
@@ -5,7 +5,7 @@ import { InterruptError, TimeoutError } from '@aztec/foundation/error';
|
|
|
5
5
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
6
|
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
7
7
|
import { Semaphore } from '@aztec/foundation/queue';
|
|
8
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
8
|
+
import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry';
|
|
9
9
|
import { sleep } from '@aztec/foundation/sleep';
|
|
10
10
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
11
11
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
@@ -44,6 +44,11 @@ import {
|
|
|
44
44
|
|
|
45
45
|
const MAX_L1_TX_STATES = 32;
|
|
46
46
|
|
|
47
|
+
// Backoff (in seconds) for retrying the read-only RPC calls that prepare a tx cancellation. A
|
|
48
|
+
// cancellation is fired in the background after a tx times out and is important (it frees the stuck
|
|
49
|
+
// nonce), so a transient RPC failure while reading the pending nonce or gas price must not abandon it.
|
|
50
|
+
const CANCELLATION_PREP_RETRY_BACKOFF_S = [1, 2, 4, 8];
|
|
51
|
+
|
|
47
52
|
export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
48
53
|
protected txs: L1TxState[] = [];
|
|
49
54
|
/** Last nonce successfully sent to the chain. Used as a lower bound when a fallback RPC node returns a stale count. */
|
|
@@ -431,10 +436,23 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
431
436
|
|
|
432
437
|
const initialTxHash = txHashes[0];
|
|
433
438
|
let currentTxHash = txHashes.at(-1)!;
|
|
434
|
-
let l1Timestamp
|
|
439
|
+
let l1Timestamp = 0;
|
|
435
440
|
|
|
436
441
|
while (true) {
|
|
437
|
-
|
|
442
|
+
try {
|
|
443
|
+
l1Timestamp = await this.getL1Timestamp();
|
|
444
|
+
} catch (err) {
|
|
445
|
+
// A transient RPC failure here must not abort monitoring with a rejection: callers that
|
|
446
|
+
// fire this loop in the background would surface it as an unhandled rejection (e.g. when a
|
|
447
|
+
// test tears down its L1 node while a monitor iteration is in flight). Exit quietly if we
|
|
448
|
+
// are shutting down, otherwise retry on the next interval.
|
|
449
|
+
if (this.interrupted) {
|
|
450
|
+
break;
|
|
451
|
+
}
|
|
452
|
+
this.logger.error(`Error fetching L1 timestamp while monitoring tx ${currentTxHash}`, err, { nonce, account });
|
|
453
|
+
await sleep(gasConfig.checkIntervalMs!);
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
438
456
|
|
|
439
457
|
try {
|
|
440
458
|
const timePassed = l1Timestamp - state.lastSentAtL1Ts.getTime();
|
|
@@ -706,9 +724,37 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
706
724
|
return;
|
|
707
725
|
}
|
|
708
726
|
|
|
709
|
-
//
|
|
710
|
-
|
|
711
|
-
|
|
727
|
+
// Resolve the pending nonce and cancellation gas price up front. These are read-only RPC calls, so
|
|
728
|
+
// they are safe to retry; a transient RPC failure here must not permanently abandon the cancellation
|
|
729
|
+
// (which would leave the nonce stuck and the tx state stranded short of CANCELLED). We retry with a
|
|
730
|
+
// real backoff before giving up, unlike getGasPrice's tight internal retry which can be exhausted by
|
|
731
|
+
// a brief node hiccup. The retried block performs no state-changing send, so retrying cannot
|
|
732
|
+
// double-send the cancellation tx.
|
|
733
|
+
const { currentNonce, cancelGasPrice } = await retry(
|
|
734
|
+
async () => {
|
|
735
|
+
const currentNonce = await this.client.getTransactionCount({ address: account, blockTag: 'pending' });
|
|
736
|
+
if (currentNonce >= nonce) {
|
|
737
|
+
// Get gas price with higher priority fee for cancellation
|
|
738
|
+
const cancelGasPrice = await this.getGasPrice(
|
|
739
|
+
{
|
|
740
|
+
...this.config,
|
|
741
|
+
// Use high bump for cancellation to ensure it replaces the original tx
|
|
742
|
+
priorityFeeRetryBumpPercentage: 150, // 150% bump should be enough to replace any tx
|
|
743
|
+
},
|
|
744
|
+
isBlobTx,
|
|
745
|
+
state.txHashes.length,
|
|
746
|
+
previousGasPrice,
|
|
747
|
+
);
|
|
748
|
+
return { currentNonce, cancelGasPrice };
|
|
749
|
+
}
|
|
750
|
+
return { currentNonce, cancelGasPrice: undefined };
|
|
751
|
+
},
|
|
752
|
+
`Preparing cancellation for L1 tx from account ${account} with nonce ${nonce}`,
|
|
753
|
+
makeBackoff(CANCELLATION_PREP_RETRY_BACKOFF_S),
|
|
754
|
+
this.logger,
|
|
755
|
+
);
|
|
756
|
+
|
|
757
|
+
if (cancelGasPrice === undefined) {
|
|
712
758
|
this.logger.verbose(
|
|
713
759
|
`Not sending cancellation for L1 tx from account ${account} with nonce ${nonce} as it is dropped`,
|
|
714
760
|
{ nonce, account, currentNonce },
|
|
@@ -717,18 +763,6 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
717
763
|
return;
|
|
718
764
|
}
|
|
719
765
|
|
|
720
|
-
// Get gas price with higher priority fee for cancellation
|
|
721
|
-
const cancelGasPrice = await this.getGasPrice(
|
|
722
|
-
{
|
|
723
|
-
...this.config,
|
|
724
|
-
// Use high bump for cancellation to ensure it replaces the original tx
|
|
725
|
-
priorityFeeRetryBumpPercentage: 150, // 150% bump should be enough to replace any tx
|
|
726
|
-
},
|
|
727
|
-
isBlobTx,
|
|
728
|
-
state.txHashes.length,
|
|
729
|
-
previousGasPrice,
|
|
730
|
-
);
|
|
731
|
-
|
|
732
766
|
const { maxFeePerGas, maxPriorityFeePerGas, maxFeePerBlobGas } = cancelGasPrice;
|
|
733
767
|
this.logger.verbose(
|
|
734
768
|
`Attempting to cancel L1 ${isBlobTx ? 'blob' : 'vanilla'} transaction from account ${account} with nonce ${nonce} after time out`,
|
package/src/publisher_manager.ts
CHANGED
|
@@ -40,11 +40,12 @@ export class PublisherManager<UtilsType extends L1TxUtils = L1TxUtils> {
|
|
|
40
40
|
private log: Logger;
|
|
41
41
|
private config: PublisherManagerConfig;
|
|
42
42
|
private static readonly FUNDING_CHECK_INTERVAL_MS = 2 * 60 * 1000;
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
protected funder?: UtilsType;
|
|
44
|
+
protected readonly fundingPromise?: RunningPromise;
|
|
45
|
+
private started = false;
|
|
45
46
|
|
|
46
47
|
constructor(
|
|
47
|
-
|
|
48
|
+
protected publishers: UtilsType[],
|
|
48
49
|
config: PublisherManagerConfig,
|
|
49
50
|
opts?: { bindings?: LoggerBindings; funder?: UtilsType },
|
|
50
51
|
) {
|
|
@@ -67,34 +68,60 @@ export class PublisherManager<UtilsType extends L1TxUtils = L1TxUtils> {
|
|
|
67
68
|
this.funder = undefined;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
if (this.funder && hasThreshold && hasAmount) {
|
|
73
|
+
this.fundingPromise = new RunningPromise(
|
|
74
|
+
() => this.triggerFundingIfNeeded(),
|
|
75
|
+
this.log,
|
|
76
|
+
PublisherManager.FUNDING_CHECK_INTERVAL_MS,
|
|
77
|
+
);
|
|
78
|
+
}
|
|
70
79
|
}
|
|
71
80
|
|
|
72
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Clears any interrupted flag left by a previous {@link stop} so publishing works again after a restart,
|
|
83
|
+
* loads the state of all publishers and the funder, and starts periodic funding checks. Idempotent: a
|
|
84
|
+
* start while already started is a no-op, so it never re-runs `loadStateAndResumeMonitoring` (which
|
|
85
|
+
* would spawn a duplicate background monitor per pending nonce). Lifecycle calls are expected to be
|
|
86
|
+
* serialized by the caller.
|
|
87
|
+
*/
|
|
73
88
|
public async start(): Promise<void> {
|
|
89
|
+
if (this.started) {
|
|
90
|
+
this.log.debug('PublisherManager already started, ignoring start');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Clear the interrupted flag set by a previous stop() so a restarted manager can publish again.
|
|
95
|
+
// On a first start this is a no-op (the flag is already clear).
|
|
96
|
+
this.publishers.forEach(pub => pub.restart());
|
|
97
|
+
this.funder?.restart();
|
|
98
|
+
|
|
74
99
|
await Promise.all([
|
|
75
100
|
...this.publishers.map(pub => pub.loadStateAndResumeMonitoring()),
|
|
76
101
|
this.funder?.loadStateAndResumeMonitoring(),
|
|
77
102
|
]);
|
|
78
103
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.config.publisherFundingAmount !== undefined
|
|
83
|
-
) {
|
|
84
|
-
this.fundingPromise = new RunningPromise(
|
|
85
|
-
() => this.triggerFundingIfNeeded(),
|
|
86
|
-
this.log,
|
|
87
|
-
PublisherManager.FUNDING_CHECK_INTERVAL_MS,
|
|
88
|
-
);
|
|
89
|
-
this.fundingPromise.start();
|
|
90
|
-
}
|
|
104
|
+
this.fundingPromise?.start();
|
|
105
|
+
// Marked started only once fully up, so a start that failed to load state can be retried.
|
|
106
|
+
this.started = true;
|
|
91
107
|
}
|
|
92
108
|
|
|
93
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Stops the funding loop, interrupts all publishers so no further L1 txs are sent, and waits (bounded)
|
|
111
|
+
* for their in-flight tx monitor loops to wind down. Idempotent, and the manager may be restarted
|
|
112
|
+
* afterwards via {@link start}, which clears the interrupted flag.
|
|
113
|
+
*/
|
|
94
114
|
public async stop(): Promise<void> {
|
|
115
|
+
this.started = false;
|
|
95
116
|
await this.fundingPromise?.stop();
|
|
96
117
|
this.publishers.forEach(pub => pub.interrupt());
|
|
97
118
|
this.funder?.interrupt();
|
|
119
|
+
// Wait for in-flight tx monitor loops to observe the interrupt, so no L1 requests are still
|
|
120
|
+
// being issued after shutdown (e.g. against an anvil instance a test is about to tear down).
|
|
121
|
+
await Promise.all([
|
|
122
|
+
...this.publishers.map(pub => pub.waitMonitoringStopped()),
|
|
123
|
+
this.funder?.waitMonitoringStopped(),
|
|
124
|
+
]);
|
|
98
125
|
}
|
|
99
126
|
|
|
100
127
|
// Finds and prioritises available publishers based on
|
|
@@ -133,8 +160,17 @@ export class PublisherManager<UtilsType extends L1TxUtils = L1TxUtils> {
|
|
|
133
160
|
}),
|
|
134
161
|
);
|
|
135
162
|
|
|
163
|
+
// Discount unfunded publishers: a publisher with no ETH cannot send a tx, so it must never win
|
|
164
|
+
// selection regardless of how favourable its state or last-used time is. Fall back to the full
|
|
165
|
+
// set only if every candidate is unfunded, so behaviour is no worse than before.
|
|
166
|
+
let fundedPublishers = publishersWithBalance.filter(p => p.balance > 0n);
|
|
167
|
+
if (fundedPublishers.length === 0) {
|
|
168
|
+
this.log.warn(`All candidate publishers have zero balance; selecting from unfunded publishers.`);
|
|
169
|
+
fundedPublishers = publishersWithBalance;
|
|
170
|
+
}
|
|
171
|
+
|
|
136
172
|
// Sort based on state, then balance, then time since last use
|
|
137
|
-
const sortedPublishers =
|
|
173
|
+
const sortedPublishers = fundedPublishers.sort((a, b) => {
|
|
138
174
|
const stateComparison = sortOrder.indexOf(a.publisher.state) - sortOrder.indexOf(b.publisher.state);
|
|
139
175
|
if (stateComparison !== 0) {
|
|
140
176
|
return stateComparison;
|