@aztec/ethereum 0.0.1-commit.b6e433891 → 0.0.1-commit.b8a057fa
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/client.d.ts +17 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +49 -3
- package/dest/config.d.ts +27 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +59 -12
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/empire_base.d.ts +1 -3
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/fee_asset_price_oracle.d.ts +6 -2
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -1
- package/dest/contracts/fee_asset_price_oracle.js +11 -6
- package/dest/contracts/governance.d.ts +108 -33
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +193 -12
- package/dest/contracts/governance_proposer.d.ts +33 -3
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +51 -9
- 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/inbox.d.ts +3 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +12 -7
- package/dest/contracts/index.d.ts +3 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -2
- package/dest/contracts/multicall.d.ts +130 -13
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +203 -94
- package/dest/contracts/outbox.d.ts +27 -4
- package/dest/contracts/outbox.d.ts.map +1 -1
- package/dest/contracts/outbox.js +34 -7
- package/dest/contracts/rollup.d.ts +5401 -26
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +343 -69
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +13 -15
- package/dest/deploy_aztec_l1_contracts.d.ts +18 -10
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +17 -13
- package/dest/l1_artifacts.d.ts +14941 -16273
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +61 -65
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +101 -82
- package/dest/l1_reader.d.ts +3 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +3 -6
- package/dest/l1_tx_utils/config.js +3 -3
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +23 -4
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +65 -3
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +9 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +138 -57
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +2 -1
- package/dest/l1_tx_utils/tx_delayer.d.ts +5 -3
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -1
- package/dest/l1_tx_utils/tx_delayer.js +7 -5
- package/dest/l1_tx_utils/types.d.ts +27 -1
- package/dest/l1_tx_utils/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/types.js +10 -0
- package/dest/publisher_manager.d.ts +34 -8
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +119 -8
- package/dest/queries.d.ts +13 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +69 -4
- 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 +34 -2
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +76 -6
- package/dest/test/eth_cheat_codes.d.ts +37 -6
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +89 -41
- 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 +60 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +86 -7
- package/dest/test/start_anvil.d.ts +8 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +16 -2
- package/dest/utils.d.ts +9 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +34 -6
- package/package.json +6 -7
- package/src/client.ts +57 -1
- package/src/config.ts +82 -16
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/empire_base.ts +0 -2
- package/src/contracts/fee_asset_price_oracle.ts +10 -5
- package/src/contracts/governance.ts +266 -9
- package/src/contracts/governance_proposer.ts +52 -5
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/inbox.ts +13 -5
- package/src/contracts/index.ts +2 -2
- package/src/contracts/multicall.ts +247 -106
- package/src/contracts/outbox.ts +42 -8
- package/src/contracts/rollup.ts +382 -69
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +14 -16
- package/src/deploy_aztec_l1_contracts.ts +16 -14
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -94
- package/src/l1_reader.ts +4 -9
- package/src/l1_tx_utils/config.ts +3 -3
- package/src/l1_tx_utils/l1_fee_analyzer.ts +75 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +122 -48
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +2 -1
- package/src/l1_tx_utils/tx_delayer.ts +16 -7
- package/src/l1_tx_utils/types.ts +32 -0
- package/src/publisher_manager.ts +143 -12
- package/src/queries.ts +76 -4
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +93 -5
- package/src/test/eth_cheat_codes.ts +82 -45
- package/src/test/index.ts +1 -0
- package/src/test/rollup_cheat_codes.ts +115 -6
- package/src/test/start_anvil.ts +25 -2
- package/src/utils.ts +30 -6
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -69
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -216
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/generated/l1-contracts-defaults.d.ts +0 -30
- package/dest/generated/l1-contracts-defaults.d.ts.map +0 -1
- package/dest/generated/l1-contracts-defaults.js +0 -30
- package/src/contracts/empire_slashing_proposer.ts +0 -265
- package/src/generated/l1-contracts-defaults.ts +0 -32
package/dest/test/start_anvil.js
CHANGED
|
@@ -75,12 +75,15 @@ import { dirname, resolve } from 'path';
|
|
|
75
75
|
child.stderr?.on('data', onStderr);
|
|
76
76
|
child.once('close', onClose);
|
|
77
77
|
});
|
|
78
|
-
// Continue piping for logging
|
|
79
|
-
if (logger || opts.captureMethodCalls) {
|
|
78
|
+
// Continue piping for logging, method-call capture, and/or dateProvider sync after startup.
|
|
79
|
+
if (logger || opts.captureMethodCalls || opts.dateProvider) {
|
|
80
80
|
child.stdout?.on('data', (data)=>{
|
|
81
81
|
const text = data.toString();
|
|
82
82
|
logger?.debug(text.trim());
|
|
83
83
|
methodCalls?.push(...text.match(/eth_[^\s]+/g) || []);
|
|
84
|
+
if (opts.dateProvider) {
|
|
85
|
+
syncDateProviderFromAnvilOutput(text, opts.dateProvider);
|
|
86
|
+
}
|
|
84
87
|
});
|
|
85
88
|
child.stderr?.on('data', (data)=>{
|
|
86
89
|
logger?.debug(data.toString().trim());
|
|
@@ -125,6 +128,17 @@ import { dirname, resolve } from 'path';
|
|
|
125
128
|
rpcUrl: `http://127.0.0.1:${port}`
|
|
126
129
|
};
|
|
127
130
|
}
|
|
131
|
+
/** Extracts block time from anvil stdout and syncs the dateProvider. */ function syncDateProviderFromAnvilOutput(text, dateProvider) {
|
|
132
|
+
// Anvil logs mined blocks as:
|
|
133
|
+
// Block Time: "Fri, 20 Mar 2026 02:10:46 +0000"
|
|
134
|
+
const match = text.match(/Block Time:\s*"([^"]+)"/);
|
|
135
|
+
if (match) {
|
|
136
|
+
const blockTimeMs = new Date(match[1]).getTime();
|
|
137
|
+
if (!isNaN(blockTimeMs)) {
|
|
138
|
+
dateProvider.setTime(blockTimeMs);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
128
142
|
/** Send SIGTERM, wait up to 5 s, then SIGKILL. All timers are always cleared. */ function killChild(child) {
|
|
129
143
|
return new Promise((resolve)=>{
|
|
130
144
|
if (child.exitCode !== null || child.killed) {
|
package/dest/utils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface L2Claim {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class FormattedViemError extends Error {
|
|
11
11
|
metaMessages?: any[];
|
|
12
|
-
constructor(message: string, metaMessages?: any[]);
|
|
12
|
+
constructor(message: string, metaMessages?: any[], options?: ErrorOptions);
|
|
13
13
|
}
|
|
14
14
|
export declare function extractEvent<const TAbi extends Abi | readonly unknown[], TEventName extends ContractEventName<TAbi>, TEventType = DecodeEventLogReturnType<TAbi, TEventName, Hex[], undefined, true>>(logs: Log[], address: Hex, abi: TAbi, eventName: TEventName, filter?: (log: TEventType) => boolean, logger?: Logger): TEventType;
|
|
15
15
|
export declare function tryExtractEvent<const TAbi extends Abi | readonly unknown[], TEventName extends ContractEventName<TAbi>, TEventType = DecodeEventLogReturnType<TAbi, TEventName, Hex[], undefined, true>>(logs: Log[], address: Hex, abi: TAbi, eventName: TEventName, filter?: (log: TEventType) => boolean, logger?: Logger): TEventType | undefined;
|
|
@@ -22,6 +22,13 @@ export declare function mergeAbis(abis: Abi[]): Abi;
|
|
|
22
22
|
* @returns A FormattedViemError instance.
|
|
23
23
|
*/
|
|
24
24
|
export declare function formatViemError(error: any, abi?: Abi): FormattedViemError;
|
|
25
|
+
/**
|
|
26
|
+
* Best-effort decode of a raw revert payload (`0x...`) against an ABI.
|
|
27
|
+
* Returns a human-readable `ErrorName(arg1, arg2, ...)` string, or `undefined` if the selector
|
|
28
|
+
* is unknown or the payload is empty. Use to surface decoded error names alongside the raw
|
|
29
|
+
* payload in log lines for operators.
|
|
30
|
+
*/
|
|
31
|
+
export declare function tryDecodeRevertReason(data: Hex | undefined, abi: Abi): string | undefined;
|
|
25
32
|
export declare function tryGetCustomErrorName(err: any): string | undefined;
|
|
26
33
|
/**
|
|
27
34
|
* Type guard to check if a transaction is a blob transaction (EIP-4844).
|
|
@@ -35,4 +42,4 @@ export declare function isBlobTransaction(tx: FormattedTransaction): tx is Forma
|
|
|
35
42
|
* Calculates a percentile from an array of bigints
|
|
36
43
|
*/
|
|
37
44
|
export declare function calculatePercentile(values: bigint[], percentile: number): bigint;
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
45
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUdwRCxPQUFPLEVBQ0wsS0FBSyxHQUFHLEVBR1IsS0FBSyxpQkFBaUIsRUFFdEIsS0FB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CLEVBQUUsTUFBTSxDQUFDO0lBQ3pCLG1CQUFtQixFQUFFLFNBQVMsR0FBRyxFQUFFLENBQUM7Q0FDckMsQ0FPQTtBQUVEOztHQUVHO0FBQ0gsd0JBQWdCLG1CQUFtQixDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsRUFBRSxVQUFVLEVBQUUsTUFBTSxHQUFHLE1BQU0sQ0FPaEYifQ==
|
package/dest/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,GAAG,EAGR,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,GAAG,EACR,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAGd,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;IAErB,YAAY,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,GAAG,EAGR,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KA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AAE,MAAM,GACd,UAAU,GAAG,SAAS,CAgBxB;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,OAW7C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAe1C;AA2ED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAE,GAAe,GAAG,kBAAkB,CAkEpF;AAyBD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,GAAG,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAUzF;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,sBAa7C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,oBAAoB,GAAG,EAAE,IAAI,oBAAoB,GAAG;IACxF,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,SAAS,GAAG,EAAE,CAAC;CACrC,CAOA;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAOhF"}
|
package/dest/utils.js
CHANGED
|
@@ -3,8 +3,8 @@ import { BaseError, ContractFunctionRevertedError, decodeErrorResult, decodeEven
|
|
|
3
3
|
import { formatAbiItem, formatAbiParams } from 'viem/utils';
|
|
4
4
|
export class FormattedViemError extends Error {
|
|
5
5
|
metaMessages;
|
|
6
|
-
constructor(message, metaMessages){
|
|
7
|
-
super(message);
|
|
6
|
+
constructor(message, metaMessages, options){
|
|
7
|
+
super(message, options);
|
|
8
8
|
this.name = 'FormattedViemError';
|
|
9
9
|
this.metaMessages = metaMessages;
|
|
10
10
|
}
|
|
@@ -135,6 +135,7 @@ function getNestedErrorData(error) {
|
|
|
135
135
|
if (error instanceof FormattedViemError) {
|
|
136
136
|
return error;
|
|
137
137
|
}
|
|
138
|
+
const originalError = error;
|
|
138
139
|
// First try to decode as a custom error using the ABI
|
|
139
140
|
try {
|
|
140
141
|
const data = getNestedErrorData(error);
|
|
@@ -145,7 +146,9 @@ function getNestedErrorData(error) {
|
|
|
145
146
|
data: data
|
|
146
147
|
});
|
|
147
148
|
if (decoded) {
|
|
148
|
-
return new FormattedViemError(`${decoded.errorName}(${decoded.args?.join(', ') ?? ''})`, error?.metaMessages
|
|
149
|
+
return new FormattedViemError(`${decoded.errorName}(${decoded.args?.join(', ') ?? ''})`, error?.metaMessages, {
|
|
150
|
+
cause: originalError
|
|
151
|
+
});
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
// If it's a BaseError, try to get the custom error through ContractFunctionRevertedError
|
|
@@ -157,7 +160,9 @@ function getNestedErrorData(error) {
|
|
|
157
160
|
errorName = revertError.signature ?? '';
|
|
158
161
|
}
|
|
159
162
|
const args = revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : '';
|
|
160
|
-
return new FormattedViemError(`${errorName}${args}`, error?.metaMessages
|
|
163
|
+
return new FormattedViemError(`${errorName}${args}`, error?.metaMessages, {
|
|
164
|
+
cause: originalError
|
|
165
|
+
});
|
|
161
166
|
}
|
|
162
167
|
}
|
|
163
168
|
} catch {
|
|
@@ -175,9 +180,13 @@ function getNestedErrorData(error) {
|
|
|
175
180
|
}
|
|
176
181
|
// If it's a regular Error instance, return it with its message
|
|
177
182
|
if (error instanceof Error) {
|
|
178
|
-
return new FormattedViemError(truncateErrorMessage(error.message), error?.metaMessages
|
|
183
|
+
return new FormattedViemError(truncateErrorMessage(error.message), error?.metaMessages, {
|
|
184
|
+
cause: originalError
|
|
185
|
+
});
|
|
179
186
|
}
|
|
180
|
-
return new FormattedViemError(truncateErrorMessage(String(error))
|
|
187
|
+
return new FormattedViemError(truncateErrorMessage(String(error)), undefined, {
|
|
188
|
+
cause: originalError
|
|
189
|
+
});
|
|
181
190
|
}
|
|
182
191
|
function stripAbis(obj) {
|
|
183
192
|
if (!obj || typeof obj !== 'object') {
|
|
@@ -198,6 +207,25 @@ function stripAbis(obj) {
|
|
|
198
207
|
}
|
|
199
208
|
});
|
|
200
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Best-effort decode of a raw revert payload (`0x...`) against an ABI.
|
|
212
|
+
* Returns a human-readable `ErrorName(arg1, arg2, ...)` string, or `undefined` if the selector
|
|
213
|
+
* is unknown or the payload is empty. Use to surface decoded error names alongside the raw
|
|
214
|
+
* payload in log lines for operators.
|
|
215
|
+
*/ export function tryDecodeRevertReason(data, abi) {
|
|
216
|
+
if (!data || data === '0x') {
|
|
217
|
+
return undefined;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const decoded = decodeErrorResult({
|
|
221
|
+
abi,
|
|
222
|
+
data
|
|
223
|
+
});
|
|
224
|
+
return `${decoded.errorName}(${decoded.args?.join(', ') ?? ''})`;
|
|
225
|
+
} catch {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
201
229
|
export function tryGetCustomErrorName(err) {
|
|
202
230
|
try {
|
|
203
231
|
// See https://viem.sh/docs/contract/simulateContract#handling-custom-errors
|
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.b8a057fa",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./account": "./dest/account.js",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"build": "yarn clean && ../scripts/tsc.sh",
|
|
41
41
|
"build:dev": "../scripts/tsc.sh --watch",
|
|
42
42
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
43
|
-
"generate": "./scripts/generate.sh",
|
|
44
43
|
"start:dev": "concurrently -k \"../scripts/tsc.sh --watch\" \"nodemon --watch dest --exec yarn start\"",
|
|
45
44
|
"start": "node ./dest/index.js",
|
|
46
45
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
@@ -50,16 +49,16 @@
|
|
|
50
49
|
"../package.common.json"
|
|
51
50
|
],
|
|
52
51
|
"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.
|
|
52
|
+
"@aztec/blob-lib": "0.0.1-commit.b8a057fa",
|
|
53
|
+
"@aztec/constants": "0.0.1-commit.b8a057fa",
|
|
54
|
+
"@aztec/foundation": "0.0.1-commit.b8a057fa",
|
|
55
|
+
"@aztec/l1-artifacts": "0.0.1-commit.b8a057fa",
|
|
57
56
|
"dotenv": "^16.0.3",
|
|
58
57
|
"lodash.chunk": "^4.2.0",
|
|
59
58
|
"lodash.pickby": "^4.5.0",
|
|
60
59
|
"tslib": "^2.4.0",
|
|
61
60
|
"viem": "npm:@aztec/viem@2.38.2",
|
|
62
|
-
"zod": "^
|
|
61
|
+
"zod": "^4"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
64
|
"@jest/globals": "^30.0.0",
|
package/src/client.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
2
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
|
+
import { getErrorCause } from '@aztec/foundation/types';
|
|
3
4
|
|
|
4
5
|
import {
|
|
5
6
|
type Chain,
|
|
7
|
+
type FallbackTransport,
|
|
6
8
|
type HDAccount,
|
|
9
|
+
HttpRequestError,
|
|
10
|
+
type HttpTransport,
|
|
7
11
|
type LocalAccount,
|
|
8
12
|
type PrivateKeyAccount,
|
|
9
13
|
createPublicClient,
|
|
@@ -31,9 +35,61 @@ type Config = {
|
|
|
31
35
|
|
|
32
36
|
export type { Config as EthereumClientConfig };
|
|
33
37
|
|
|
38
|
+
/** Error exposed by L1 RPC transports without including provider URLs in its message. */
|
|
39
|
+
export class L1RpcError extends Error {
|
|
40
|
+
constructor(message: string, options?: ErrorOptions) {
|
|
41
|
+
super(message, options);
|
|
42
|
+
this.name = 'L1RpcError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
/** Creates a viem fallback HTTP transport for the given L1 RPC URLs. */
|
|
35
47
|
export function makeL1HttpTransport(rpcUrls: string[], opts?: { timeout?: number }) {
|
|
36
|
-
return fallback(rpcUrls.map(url => http(url, { batch: false, timeout: opts?.timeout })));
|
|
48
|
+
return wrapL1RpcTransport(fallback(rpcUrls.map(url => http(url, { batch: false, timeout: opts?.timeout }))));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Returns the HTTP status from an L1 RPC error's cause chain, if one is available. */
|
|
52
|
+
export function getL1RpcHttpStatus(err: unknown): number | undefined {
|
|
53
|
+
return getErrorCause(err, HttpRequestError)?.status;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Returns true when an L1 RPC error's cause chain contains the given HTTP status. */
|
|
57
|
+
export function isL1RpcHttpStatus(err: unknown, status: number): boolean {
|
|
58
|
+
return getL1RpcHttpStatus(err) === status;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function wrapL1RpcTransport(transport: FallbackTransport<HttpTransport[]>): FallbackTransport<HttpTransport[]> {
|
|
62
|
+
const wrappedTransport: FallbackTransport<HttpTransport[]> = parameters => {
|
|
63
|
+
const fallbackTransport = transport(parameters);
|
|
64
|
+
const request: typeof fallbackTransport.request = async args => {
|
|
65
|
+
try {
|
|
66
|
+
return await fallbackTransport.request(args);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
throw err instanceof L1RpcError ? err : new L1RpcError('L1 RPC request failed', { cause: err });
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return { ...fallbackTransport, request };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return wrappedTransport;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns the individual RPC URLs underlying a viem public client that was constructed with a
|
|
79
|
+
* fallback HTTP transport (see {@link makeL1HttpTransport}). Returns an empty array if the
|
|
80
|
+
* transport shape is not recognized (e.g. mock clients in tests, or non-fallback transports).
|
|
81
|
+
*/
|
|
82
|
+
export function getRpcUrlsFromClient(client: ViemPublicClient): string[] {
|
|
83
|
+
const transport = client.transport as unknown as {
|
|
84
|
+
transports?: { value?: { url?: string } }[];
|
|
85
|
+
value?: { url?: string };
|
|
86
|
+
url?: string;
|
|
87
|
+
};
|
|
88
|
+
if (Array.isArray(transport?.transports)) {
|
|
89
|
+
return transport.transports.map(t => t?.value?.url).filter((url): url is string => typeof url === 'string');
|
|
90
|
+
}
|
|
91
|
+
const singleUrl = transport?.value?.url ?? transport?.url;
|
|
92
|
+
return typeof singleUrl === 'string' ? [singleUrl] : [];
|
|
37
93
|
}
|
|
38
94
|
|
|
39
95
|
// TODO: Use these methods to abstract the creation of viem clients.
|
package/src/config.ts
CHANGED
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
bigintConfigHelper,
|
|
4
4
|
booleanConfigHelper,
|
|
5
|
-
enumConfigHelper,
|
|
6
5
|
getConfigFromMappings,
|
|
7
6
|
getDefaultConfig,
|
|
8
7
|
numberConfigHelper,
|
|
@@ -10,8 +9,8 @@ import {
|
|
|
10
9
|
optionalNumberConfigHelper,
|
|
11
10
|
} from '@aztec/foundation/config';
|
|
12
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
|
+
import l1ContractsDefaultEnv from '@aztec/l1-artifacts/network-defaults.json' with { type: 'json' };
|
|
13
13
|
|
|
14
|
-
import { l1ContractsDefaultEnv } from './generated/l1-contracts-defaults.js';
|
|
15
14
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './l1_tx_utils/config.js';
|
|
16
15
|
|
|
17
16
|
export type GenesisStateConfig = {
|
|
@@ -60,13 +59,13 @@ export type L1ContractsConfig = {
|
|
|
60
59
|
slashingOffsetInRounds: number;
|
|
61
60
|
/** How long slashing can be disabled for in seconds when vetoer disables it */
|
|
62
61
|
slashingDisableDuration: number;
|
|
63
|
-
/**
|
|
64
|
-
|
|
65
|
-
/** Minimum amount that can be slashed
|
|
62
|
+
/** Whether to deploy a slasher proposer */
|
|
63
|
+
slasherEnabled: boolean;
|
|
64
|
+
/** Minimum amount that can be slashed */
|
|
66
65
|
slashAmountSmall: bigint;
|
|
67
|
-
/** Medium amount to slash
|
|
66
|
+
/** Medium amount to slash */
|
|
68
67
|
slashAmountMedium: bigint;
|
|
69
|
-
/** Largest amount that can be slashed per round
|
|
68
|
+
/** Largest amount that can be slashed per round */
|
|
70
69
|
slashAmountLarge: bigint;
|
|
71
70
|
/** Governance proposing quorum (defaults to roundSize/2 + 1) */
|
|
72
71
|
governanceProposerQuorum?: number;
|
|
@@ -82,11 +81,21 @@ export type L1ContractsConfig = {
|
|
|
82
81
|
initialEthPerFeeAsset: bigint;
|
|
83
82
|
/** The number of seconds to wait for an exit */
|
|
84
83
|
exitDelaySeconds: number;
|
|
84
|
+
/** Validator set size at or below which the entry queue uses the bootstrap flush size. */
|
|
85
|
+
entryQueueBootstrapValidatorSetSize: number;
|
|
86
|
+
/** Number of validators admitted from the entry queue per flush during the bootstrap phase. */
|
|
87
|
+
entryQueueBootstrapFlushSize: number;
|
|
88
|
+
/** Minimum number of validators admitted from the entry queue per flush. */
|
|
89
|
+
entryQueueFlushSizeMin: number;
|
|
90
|
+
/** Divisor applied to the queue size to derive the normal per-flush admission count. */
|
|
91
|
+
entryQueueFlushSizeQuotient: number;
|
|
92
|
+
/** Maximum number of validators admitted from the entry queue per flush. */
|
|
93
|
+
entryQueueMaxFlushSize: number;
|
|
85
94
|
} & L1TxUtilsConfig;
|
|
86
95
|
|
|
87
96
|
/**
|
|
88
97
|
* Config mappings for L1ContractsConfig.
|
|
89
|
-
* Default values come from
|
|
98
|
+
* Default values come from l1-contracts/scripts/network-defaults.json (published via @aztec/l1-artifacts).
|
|
90
99
|
* Real deployments use forge scripts which require explicit env vars (vm.envUint).
|
|
91
100
|
*/
|
|
92
101
|
export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> = {
|
|
@@ -152,13 +161,10 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
152
161
|
'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
|
|
153
162
|
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
154
163
|
},
|
|
155
|
-
|
|
156
|
-
env: '
|
|
157
|
-
description: '
|
|
158
|
-
...
|
|
159
|
-
['empire', 'tally', 'none'] as const,
|
|
160
|
-
l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
|
|
161
|
-
),
|
|
164
|
+
slasherEnabled: {
|
|
165
|
+
env: 'AZTEC_SLASHER_ENABLED',
|
|
166
|
+
description: 'Whether to deploy a slasher proposer',
|
|
167
|
+
...booleanConfigHelper(true),
|
|
162
168
|
},
|
|
163
169
|
slashAmountSmall: {
|
|
164
170
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
@@ -241,15 +247,75 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
241
247
|
description: 'The delay before a validator can exit the set',
|
|
242
248
|
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
|
|
243
249
|
},
|
|
250
|
+
entryQueueBootstrapValidatorSetSize: {
|
|
251
|
+
env: 'AZTEC_ENTRY_QUEUE_BOOTSTRAP_VALIDATOR_SET_SIZE',
|
|
252
|
+
description: 'Validator set size at or below which the entry queue uses the bootstrap flush size.',
|
|
253
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_BOOTSTRAP_VALIDATOR_SET_SIZE),
|
|
254
|
+
},
|
|
255
|
+
entryQueueBootstrapFlushSize: {
|
|
256
|
+
env: 'AZTEC_ENTRY_QUEUE_BOOTSTRAP_FLUSH_SIZE',
|
|
257
|
+
description: 'Number of validators admitted from the entry queue per flush during the bootstrap phase.',
|
|
258
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_BOOTSTRAP_FLUSH_SIZE),
|
|
259
|
+
},
|
|
260
|
+
entryQueueFlushSizeMin: {
|
|
261
|
+
env: 'AZTEC_ENTRY_QUEUE_FLUSH_SIZE_MIN',
|
|
262
|
+
description: 'Minimum number of validators admitted from the entry queue per flush.',
|
|
263
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_FLUSH_SIZE_MIN),
|
|
264
|
+
},
|
|
265
|
+
entryQueueFlushSizeQuotient: {
|
|
266
|
+
env: 'AZTEC_ENTRY_QUEUE_FLUSH_SIZE_QUOTIENT',
|
|
267
|
+
description: 'Divisor applied to the queue size to derive the normal per-flush admission count.',
|
|
268
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_FLUSH_SIZE_QUOTIENT),
|
|
269
|
+
},
|
|
270
|
+
entryQueueMaxFlushSize: {
|
|
271
|
+
env: 'AZTEC_ENTRY_QUEUE_MAX_FLUSH_SIZE',
|
|
272
|
+
description: 'Maximum number of validators admitted from the entry queue per flush.',
|
|
273
|
+
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_ENTRY_QUEUE_MAX_FLUSH_SIZE),
|
|
274
|
+
},
|
|
244
275
|
...omitConfigMappings(l1TxUtilsConfigMappings, ['ethereumSlotDuration']),
|
|
245
276
|
};
|
|
246
277
|
|
|
247
278
|
/**
|
|
248
279
|
* Default L1 contracts configuration derived from l1ContractsConfigMappings.
|
|
249
|
-
* Source of truth:
|
|
280
|
+
* Source of truth: l1-contracts/scripts/network-defaults.json (published via @aztec/l1-artifacts).
|
|
250
281
|
*/
|
|
251
282
|
export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
|
|
252
283
|
|
|
284
|
+
/**
|
|
285
|
+
* Validates that `ethereumSlotDuration` and `aztecSlotDuration` are positive and that the L2 slot is an exact
|
|
286
|
+
* multiple of the L1 slot. Every L2 slot boundary must land on an L1 slot boundary; a non-multiple pairing
|
|
287
|
+
* desyncs the epoch/checkpoint timing math throughout the sequencer, validator client, and timetables. Returns
|
|
288
|
+
* a list of error messages (empty when valid).
|
|
289
|
+
*/
|
|
290
|
+
export function validateSlotDurations(
|
|
291
|
+
config: Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration'>,
|
|
292
|
+
): string[] {
|
|
293
|
+
const errors: string[] = [];
|
|
294
|
+
if (config.ethereumSlotDuration <= 0) {
|
|
295
|
+
errors.push(`ethereumSlotDuration must be positive (got ${config.ethereumSlotDuration})`);
|
|
296
|
+
}
|
|
297
|
+
if (config.aztecSlotDuration <= 0) {
|
|
298
|
+
errors.push(`aztecSlotDuration must be positive (got ${config.aztecSlotDuration})`);
|
|
299
|
+
}
|
|
300
|
+
if (config.ethereumSlotDuration > 0 && config.aztecSlotDuration % config.ethereumSlotDuration !== 0) {
|
|
301
|
+
errors.push(
|
|
302
|
+
`aztecSlotDuration (${config.aztecSlotDuration}s) must be a multiple of ethereumSlotDuration ` +
|
|
303
|
+
`(${config.ethereumSlotDuration}s)`,
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
return errors;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** Throws if {@link validateSlotDurations} reports any errors. */
|
|
310
|
+
export function assertValidSlotDurations(
|
|
311
|
+
config: Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration'>,
|
|
312
|
+
): void {
|
|
313
|
+
const errors = validateSlotDurations(config);
|
|
314
|
+
if (errors.length > 0) {
|
|
315
|
+
throw new Error(`Invalid slot duration configuration:\n${errors.map(e => ` - ${e}`).join('\n')}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
253
319
|
export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
|
|
254
320
|
testAccounts: {
|
|
255
321
|
env: 'TEST_ACCOUNTS',
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
|
|
2
|
+
import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Buffer32 } from '@aztec/foundation/buffer';
|
|
4
|
+
import { merge } from '@aztec/foundation/collection';
|
|
5
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
|
|
7
|
+
import type { StateOverride } from 'viem';
|
|
8
|
+
|
|
9
|
+
import { type FeeHeader, RollupContract } from './rollup.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Override values for the pending checkpoint that the simulation should treat as already applied.
|
|
13
|
+
* Every field is optional at plan-building time so callers can populate them incrementally; whatever
|
|
14
|
+
* is present at translation time is forwarded to the partial `tempCheckpointLogs` helper so the
|
|
15
|
+
* load-bearing `slotNumber` can land even if other fields could not be derived locally.
|
|
16
|
+
*/
|
|
17
|
+
export type PendingCheckpointOverrideState = {
|
|
18
|
+
archive?: Fr;
|
|
19
|
+
feeHeader?: FeeHeader;
|
|
20
|
+
headerHash?: Fr;
|
|
21
|
+
outHash?: Fr;
|
|
22
|
+
payloadDigest?: Buffer32;
|
|
23
|
+
slotNumber?: SlotNumber;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ChainTipsOverride = {
|
|
27
|
+
pending?: CheckpointNumber;
|
|
28
|
+
proven?: CheckpointNumber;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** Describes the simulated L1 rollup state that downstream calls should observe. */
|
|
32
|
+
export type SimulationOverridesPlan = {
|
|
33
|
+
chainTipsOverride?: ChainTipsOverride;
|
|
34
|
+
pendingCheckpointState?: PendingCheckpointOverrideState;
|
|
35
|
+
disableBlobCheck?: boolean;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Builds a single-checkpoint simulation plan before it is translated into a viem state override. */
|
|
39
|
+
export class SimulationOverridesBuilder {
|
|
40
|
+
private chainTipsOverride?: ChainTipsOverride;
|
|
41
|
+
private pendingCheckpointState?: PendingCheckpointOverrideState;
|
|
42
|
+
private disableBlobCheck = false;
|
|
43
|
+
|
|
44
|
+
/** Starts from an existing plan so callers can extend or specialize it. */
|
|
45
|
+
public static from(plan: SimulationOverridesPlan | undefined): SimulationOverridesBuilder {
|
|
46
|
+
return new SimulationOverridesBuilder().merge(plan);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Merges another plan into this builder. Later values win on a per-half basis for chain tips,
|
|
51
|
+
* but explicit `undefined` fields in the incoming plan are ignored so they cannot erase a
|
|
52
|
+
* previously-set value.
|
|
53
|
+
*/
|
|
54
|
+
public merge(plan: SimulationOverridesPlan | undefined): this {
|
|
55
|
+
if (!plan) {
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (plan.chainTipsOverride) {
|
|
60
|
+
this.chainTipsOverride = merge(this.chainTipsOverride ?? {}, plan.chainTipsOverride);
|
|
61
|
+
}
|
|
62
|
+
if (plan.pendingCheckpointState) {
|
|
63
|
+
this.pendingCheckpointState = merge(this.pendingCheckpointState ?? {}, plan.pendingCheckpointState);
|
|
64
|
+
}
|
|
65
|
+
this.disableBlobCheck = this.disableBlobCheck || (plan.disableBlobCheck ?? false);
|
|
66
|
+
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Sets the pending and/or proven checkpoint number overrides. Subsequent calls merge into the existing
|
|
72
|
+
* override on a per-half basis, so callers can set pending in one call and proven in another without
|
|
73
|
+
* clobbering each other.
|
|
74
|
+
*/
|
|
75
|
+
public withChainTips(override: ChainTipsOverride): this {
|
|
76
|
+
this.chainTipsOverride = { ...(this.chainTipsOverride ?? {}), ...override };
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Overrides the archive root for the configured pending checkpoint. */
|
|
81
|
+
public withPendingArchive(archive: Fr): this {
|
|
82
|
+
this.assertPendingCheckpointNumber();
|
|
83
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), archive };
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Overrides the fee header for the configured pending checkpoint. */
|
|
88
|
+
public withPendingFeeHeader(feeHeader: FeeHeader): this {
|
|
89
|
+
this.assertPendingCheckpointNumber();
|
|
90
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), feeHeader };
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Overrides one or more `tempCheckpointLogs` cell fields for the configured pending checkpoint.
|
|
96
|
+
* Fields are independent: any subset can be provided. The translator (`makeTempCheckpointLogOverride`)
|
|
97
|
+
* emits a stateDiff entry per field actually set, so unspecified fields stay at their on-chain
|
|
98
|
+
* values.
|
|
99
|
+
*
|
|
100
|
+
* `slotNumber` is load-bearing for `STFLib.canPruneAtTime`: when the simulation overrides `pending`
|
|
101
|
+
* to a checkpoint that has no on-chain `tempCheckpointLogs` entry yet, the missing slotNumber falls
|
|
102
|
+
* back to 0 and the contract treats the pending tip as belonging to epoch 0, triggering a phantom
|
|
103
|
+
* prune that silently undoes the `pending` override.
|
|
104
|
+
*/
|
|
105
|
+
public withPendingTempCheckpointLogFields(fields: {
|
|
106
|
+
headerHash?: Fr;
|
|
107
|
+
outHash?: Fr;
|
|
108
|
+
payloadDigest?: Buffer32;
|
|
109
|
+
slotNumber?: SlotNumber;
|
|
110
|
+
}): this {
|
|
111
|
+
this.assertPendingCheckpointNumber();
|
|
112
|
+
this.pendingCheckpointState = { ...(this.pendingCheckpointState ?? {}), ...fields };
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Disables blob checking for simulations that cannot provide DA inputs. */
|
|
117
|
+
public withoutBlobCheck(): this {
|
|
118
|
+
this.disableBlobCheck = true;
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Builds the final plan, or `undefined` when no overrides were configured. */
|
|
123
|
+
public build(): SimulationOverridesPlan | undefined {
|
|
124
|
+
if (!this.pendingCheckpointState && !this.chainTipsOverride && !this.disableBlobCheck) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
chainTipsOverride: this.chainTipsOverride,
|
|
130
|
+
pendingCheckpointState: this.pendingCheckpointState,
|
|
131
|
+
disableBlobCheck: this.disableBlobCheck || undefined,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private assertPendingCheckpointNumber(): void {
|
|
136
|
+
if (this.chainTipsOverride?.pending === undefined) {
|
|
137
|
+
throw new Error('withChainTips({ pending }) must be called before attaching archive or fee header overrides');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Translates a simulation plan into the viem state override shape expected by rollup calls. */
|
|
143
|
+
export async function buildSimulationOverridesStateOverride(
|
|
144
|
+
rollup: RollupContract,
|
|
145
|
+
plan: SimulationOverridesPlan | undefined,
|
|
146
|
+
): Promise<StateOverride> {
|
|
147
|
+
if (!plan) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const rollupStateDiff: NonNullable<StateOverride[number]['stateDiff']> = [];
|
|
152
|
+
|
|
153
|
+
if (plan.chainTipsOverride) {
|
|
154
|
+
rollupStateDiff.push(...extractRollupStateDiff(await rollup.makeChainTipsOverride(plan.chainTipsOverride)));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (plan.pendingCheckpointState && plan.chainTipsOverride?.pending === undefined) {
|
|
158
|
+
throw new Error('pendingCheckpointState requires chainTipsOverride.pending to be set');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (plan.pendingCheckpointState?.archive) {
|
|
162
|
+
rollupStateDiff.push(
|
|
163
|
+
...extractRollupStateDiff(
|
|
164
|
+
rollup.makeArchiveOverride(plan.chainTipsOverride!.pending!, plan.pendingCheckpointState.archive),
|
|
165
|
+
),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (plan.pendingCheckpointState) {
|
|
170
|
+
rollupStateDiff.push(
|
|
171
|
+
...extractRollupStateDiff(
|
|
172
|
+
await rollup.makeTempCheckpointLogOverride(plan.chainTipsOverride!.pending!, {
|
|
173
|
+
headerHash: plan.pendingCheckpointState.headerHash,
|
|
174
|
+
outHash: plan.pendingCheckpointState.outHash,
|
|
175
|
+
payloadDigest: plan.pendingCheckpointState.payloadDigest,
|
|
176
|
+
slotNumber: plan.pendingCheckpointState.slotNumber,
|
|
177
|
+
feeHeader: plan.pendingCheckpointState.feeHeader,
|
|
178
|
+
}),
|
|
179
|
+
),
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (plan.disableBlobCheck) {
|
|
184
|
+
rollupStateDiff.push({
|
|
185
|
+
slot: toPaddedHex(RollupContract.checkBlobStorageSlot, true),
|
|
186
|
+
value: toPaddedHex(0n, true),
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (rollupStateDiff.length === 0) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return [{ address: rollup.address, stateDiff: rollupStateDiff }];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function extractRollupStateDiff(override: StateOverride | StateOverride[number] | undefined) {
|
|
198
|
+
const entries = Array.isArray(override) ? override : override ? [override] : [];
|
|
199
|
+
return entries.flatMap(entry => entry.stateDiff ?? []);
|
|
200
|
+
}
|
|
@@ -22,8 +22,6 @@ export interface IEmpireBase {
|
|
|
22
22
|
signerAddress: Hex,
|
|
23
23
|
signer: (msg: TypedDataDefinition) => Promise<Hex>,
|
|
24
24
|
): Promise<L1TxRequest>;
|
|
25
|
-
/** Checks if a payload was ever submitted to governance via submitRoundWinner. */
|
|
26
|
-
hasPayloadBeenProposed(payload: Hex, fromBlock: bigint): Promise<boolean>;
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
export function encodeSignal(payload: Hex): Hex {
|