@aztec/ethereum 0.0.1-commit.2ed92850 → 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/client.d.ts +25 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +60 -8
- package/dest/config.d.ts +17 -6
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +39 -11
- 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/fee_asset_handler.d.ts +1 -1
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +2 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +105 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +656 -0
- package/dest/contracts/governance.d.ts +108 -33
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +198 -15
- package/dest/contracts/governance_proposer.d.ts +33 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +57 -3
- 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 +4 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +3 -2
- package/dest/contracts/multicall.d.ts +127 -12
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +201 -93
- 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/registry.d.ts +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +5420 -31
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +406 -75
- 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} +18 -13
- package/dest/deploy_aztec_l1_contracts.d.ts +5 -9
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +41 -26
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/generated/l1-contracts-defaults.d.ts +3 -3
- package/dest/generated/l1-contracts-defaults.js +3 -3
- package/dest/l1_artifacts.d.ts +15524 -15847
- 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 +5 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +9 -7
- package/dest/l1_tx_utils/config.d.ts +7 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +17 -4
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/constants.js +2 -2
- package/dest/l1_tx_utils/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/index-blobs.js +2 -2
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +26 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +158 -81
- 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 +13 -8
- package/dest/l1_tx_utils/tx_delayer.d.ts +58 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +67 -37
- package/dest/publisher_manager.d.ts +34 -7
- 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 +62 -3
- 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 +55 -4
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +104 -3
- package/dest/test/eth_cheat_codes.d.ts +31 -6
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +67 -44
- package/dest/test/index.d.ts +2 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -2
- package/dest/test/rollup_cheat_codes.d.ts +62 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +95 -7
- package/dest/test/start_anvil.d.ts +23 -3
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +143 -29
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +10 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +105 -24
- package/package.json +6 -8
- package/src/client.ts +66 -2
- package/src/config.ts +59 -15
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/fee_asset_handler.ts +2 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +271 -12
- package/src/contracts/governance_proposer.ts +58 -2
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/inbox.ts +13 -5
- package/src/contracts/index.ts +3 -2
- package/src/contracts/multicall.ts +243 -102
- package/src/contracts/outbox.ts +42 -8
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +457 -78
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +16 -14
- package/src/deploy_aztec_l1_contracts.ts +63 -35
- package/src/deploy_l1_contract.ts +3 -3
- package/src/generated/l1-contracts-defaults.ts +3 -3
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -94
- package/src/l1_reader.ts +17 -10
- package/src/l1_tx_utils/config.ts +23 -3
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +1 -1
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
- package/src/l1_tx_utils/index-blobs.ts +2 -2
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +151 -66
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +13 -8
- package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
- package/src/publisher_manager.ts +145 -12
- package/src/queries.ts +70 -4
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +148 -3
- package/src/test/eth_cheat_codes.ts +63 -47
- package/src/test/index.ts +1 -2
- package/src/test/rollup_cheat_codes.ts +124 -6
- package/src/test/start_anvil.ts +177 -29
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +109 -29
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -209
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/contracts/empire_slashing_proposer.ts +0 -270
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
package/dest/utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
|
|
2
2
|
import { BaseError, ContractFunctionRevertedError, decodeErrorResult, decodeEventLog } from 'viem';
|
|
3
|
+
import { formatAbiItem, formatAbiParams } from 'viem/utils';
|
|
3
4
|
export class FormattedViemError extends Error {
|
|
4
5
|
metaMessages;
|
|
5
|
-
constructor(message, metaMessages){
|
|
6
|
-
super(message);
|
|
6
|
+
constructor(message, metaMessages, options){
|
|
7
|
+
super(message, options);
|
|
7
8
|
this.name = 'FormattedViemError';
|
|
8
9
|
this.metaMessages = metaMessages;
|
|
9
10
|
}
|
|
@@ -46,6 +47,51 @@ export function prettyLogViemErrorMsg(err) {
|
|
|
46
47
|
}
|
|
47
48
|
return err?.message ?? err;
|
|
48
49
|
}
|
|
50
|
+
export function mergeAbis(abis) {
|
|
51
|
+
let merged = [];
|
|
52
|
+
const seen = new Set();
|
|
53
|
+
for (const abi of abis){
|
|
54
|
+
for (const item of abi){
|
|
55
|
+
const key = getAbiItemKey(item);
|
|
56
|
+
if (!seen.has(key)) {
|
|
57
|
+
seen.add(key);
|
|
58
|
+
merged = [
|
|
59
|
+
...merged,
|
|
60
|
+
item
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return merged;
|
|
66
|
+
}
|
|
67
|
+
function getAbiItemKey(item) {
|
|
68
|
+
if (item.type === 'function') {
|
|
69
|
+
const signature = formatAbiItem(item);
|
|
70
|
+
const outputs = formatAbiParams(item.outputs);
|
|
71
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
72
|
+
return `function:${signature}:${outputs}:${stateMutability}`;
|
|
73
|
+
}
|
|
74
|
+
if (item.type === 'event') {
|
|
75
|
+
const signature = formatAbiItem(item);
|
|
76
|
+
const indexed = (item.inputs ?? []).map((input)=>input.indexed ? '1' : '0').join('');
|
|
77
|
+
const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
|
|
78
|
+
return `event:${signature}:${indexed}:${anonymous}`;
|
|
79
|
+
}
|
|
80
|
+
if (item.type === 'error') {
|
|
81
|
+
const signature = formatAbiItem(item);
|
|
82
|
+
return `error:${signature}`;
|
|
83
|
+
}
|
|
84
|
+
if (item.type === 'constructor') {
|
|
85
|
+
const inputs = formatAbiParams(item.inputs);
|
|
86
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
87
|
+
return `constructor::${inputs}:${stateMutability}`;
|
|
88
|
+
}
|
|
89
|
+
if (item.type === 'fallback' || item.type === 'receive') {
|
|
90
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
91
|
+
return `${item.type}:::${stateMutability}`;
|
|
92
|
+
}
|
|
93
|
+
return 'unknown';
|
|
94
|
+
}
|
|
49
95
|
function getNestedErrorData(error) {
|
|
50
96
|
// If nothing, bail
|
|
51
97
|
if (!error) {
|
|
@@ -66,6 +112,19 @@ function getNestedErrorData(error) {
|
|
|
66
112
|
// Not found
|
|
67
113
|
return undefined;
|
|
68
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Truncates an error message to a safe length for log renderers.
|
|
117
|
+
* LogExplorer can only render up to 2500 characters in its summary view.
|
|
118
|
+
* We cap at 2000 to leave room for decorating context added by callers.
|
|
119
|
+
*/ function truncateErrorMessage(message) {
|
|
120
|
+
const MAX = 2000;
|
|
121
|
+
const CHUNK = 950;
|
|
122
|
+
if (message.length <= MAX) {
|
|
123
|
+
return message;
|
|
124
|
+
}
|
|
125
|
+
const truncated = message.length - 2 * CHUNK;
|
|
126
|
+
return message.slice(0, CHUNK) + `...${truncated} characters truncated...` + message.slice(-CHUNK);
|
|
127
|
+
}
|
|
69
128
|
/**
|
|
70
129
|
* Formats a Viem error into a FormattedViemError instance.
|
|
71
130
|
* @param error - The error to format.
|
|
@@ -76,6 +135,7 @@ function getNestedErrorData(error) {
|
|
|
76
135
|
if (error instanceof FormattedViemError) {
|
|
77
136
|
return error;
|
|
78
137
|
}
|
|
138
|
+
const originalError = error;
|
|
79
139
|
// First try to decode as a custom error using the ABI
|
|
80
140
|
try {
|
|
81
141
|
const data = getNestedErrorData(error);
|
|
@@ -86,7 +146,9 @@ function getNestedErrorData(error) {
|
|
|
86
146
|
data: data
|
|
87
147
|
});
|
|
88
148
|
if (decoded) {
|
|
89
|
-
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
|
+
});
|
|
90
152
|
}
|
|
91
153
|
}
|
|
92
154
|
// If it's a BaseError, try to get the custom error through ContractFunctionRevertedError
|
|
@@ -98,36 +160,36 @@ function getNestedErrorData(error) {
|
|
|
98
160
|
errorName = revertError.signature ?? '';
|
|
99
161
|
}
|
|
100
162
|
const args = revertError.metaMessages && revertError.metaMessages?.length > 1 ? revertError.metaMessages[1].trimStart() : '';
|
|
101
|
-
return new FormattedViemError(`${errorName}${args}`, error?.metaMessages
|
|
163
|
+
return new FormattedViemError(`${errorName}${args}`, error?.metaMessages, {
|
|
164
|
+
cause: originalError
|
|
165
|
+
});
|
|
102
166
|
}
|
|
103
167
|
}
|
|
104
168
|
} catch {
|
|
105
169
|
// If decoding fails, we fall back to the original formatting
|
|
106
170
|
}
|
|
107
|
-
// 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.
|
|
108
175
|
if (error && typeof error === 'object') {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
//
|
|
115
|
-
|
|
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
|
+
}
|
|
116
183
|
}
|
|
117
184
|
// If it's a regular Error instance, return it with its message
|
|
118
185
|
if (error instanceof Error) {
|
|
119
|
-
return new FormattedViemError(error.message, error?.metaMessages
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const chunk = 950;
|
|
127
|
-
const truncated = length - 2 * chunk;
|
|
128
|
-
return new FormattedViemError(body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk));
|
|
129
|
-
}
|
|
130
|
-
return new FormattedViemError(body);
|
|
186
|
+
return new FormattedViemError(truncateErrorMessage(error.message), error?.metaMessages, {
|
|
187
|
+
cause: originalError
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return new FormattedViemError(truncateErrorMessage(String(error)), undefined, {
|
|
191
|
+
cause: originalError
|
|
192
|
+
});
|
|
131
193
|
}
|
|
132
194
|
function stripAbis(obj) {
|
|
133
195
|
if (!obj || typeof obj !== 'object') {
|
|
@@ -148,6 +210,25 @@ function stripAbis(obj) {
|
|
|
148
210
|
}
|
|
149
211
|
});
|
|
150
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Best-effort decode of a raw revert payload (`0x...`) against an ABI.
|
|
215
|
+
* Returns a human-readable `ErrorName(arg1, arg2, ...)` string, or `undefined` if the selector
|
|
216
|
+
* is unknown or the payload is empty. Use to surface decoded error names alongside the raw
|
|
217
|
+
* payload in log lines for operators.
|
|
218
|
+
*/ export function tryDecodeRevertReason(data, abi) {
|
|
219
|
+
if (!data || data === '0x') {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
try {
|
|
223
|
+
const decoded = decodeErrorResult({
|
|
224
|
+
abi,
|
|
225
|
+
data
|
|
226
|
+
});
|
|
227
|
+
return `${decoded.errorName}(${decoded.args?.join(', ') ?? ''})`;
|
|
228
|
+
} catch {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
151
232
|
export function tryGetCustomErrorName(err) {
|
|
152
233
|
try {
|
|
153
234
|
// 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.3100065",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./account": "./dest/account.js",
|
|
@@ -50,17 +50,16 @@
|
|
|
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.
|
|
57
|
-
"@viem/anvil": "^0.0.10",
|
|
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",
|
|
58
57
|
"dotenv": "^16.0.3",
|
|
59
58
|
"lodash.chunk": "^4.2.0",
|
|
60
59
|
"lodash.pickby": "^4.5.0",
|
|
61
60
|
"tslib": "^2.4.0",
|
|
62
61
|
"viem": "npm:@aztec/viem@2.38.2",
|
|
63
|
-
"zod": "^
|
|
62
|
+
"zod": "^4"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
65
|
"@jest/globals": "^30.0.0",
|
|
@@ -69,7 +68,6 @@
|
|
|
69
68
|
"@types/lodash.pickby": "^4",
|
|
70
69
|
"@types/node": "^22.15.17",
|
|
71
70
|
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
72
|
-
"@viem/anvil": "^0.0.10",
|
|
73
71
|
"get-port": "^7.1.0",
|
|
74
72
|
"jest": "^30.0.0",
|
|
75
73
|
"jest-mock-extended": "^4.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,
|
|
@@ -25,10 +29,69 @@ type Config = {
|
|
|
25
29
|
l1ChainId: number;
|
|
26
30
|
/** The polling interval viem uses in ms */
|
|
27
31
|
viemPollingIntervalMS?: number;
|
|
32
|
+
/** Timeout for HTTP requests to the L1 RPC node in ms. */
|
|
33
|
+
l1HttpTimeoutMS?: number;
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
export type { Config as EthereumClientConfig };
|
|
31
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
|
+
|
|
46
|
+
/** Creates a viem fallback HTTP transport for the given L1 RPC URLs. */
|
|
47
|
+
export function makeL1HttpTransport(rpcUrls: string[], opts?: { timeout?: number }) {
|
|
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] : [];
|
|
93
|
+
}
|
|
94
|
+
|
|
32
95
|
// TODO: Use these methods to abstract the creation of viem clients.
|
|
33
96
|
|
|
34
97
|
/** Returns a viem public client given the L1 config. */
|
|
@@ -36,7 +99,7 @@ export function getPublicClient(config: Config): ViemPublicClient {
|
|
|
36
99
|
const chain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
|
|
37
100
|
return createPublicClient({
|
|
38
101
|
chain: chain.chainInfo,
|
|
39
|
-
transport:
|
|
102
|
+
transport: makeL1HttpTransport(config.l1RpcUrls, { timeout: config.l1HttpTimeoutMS }),
|
|
40
103
|
pollingInterval: config.viemPollingIntervalMS,
|
|
41
104
|
});
|
|
42
105
|
}
|
|
@@ -77,6 +140,7 @@ export function createExtendedL1Client(
|
|
|
77
140
|
chain: Chain = foundry,
|
|
78
141
|
pollingIntervalMS?: number,
|
|
79
142
|
addressIndex?: number,
|
|
143
|
+
opts?: { httpTimeoutMS?: number },
|
|
80
144
|
): ExtendedViemWalletClient {
|
|
81
145
|
const hdAccount =
|
|
82
146
|
typeof mnemonicOrPrivateKeyOrHdAccount === 'string'
|
|
@@ -88,7 +152,7 @@ export function createExtendedL1Client(
|
|
|
88
152
|
const extendedClient = createWalletClient({
|
|
89
153
|
account: hdAccount,
|
|
90
154
|
chain,
|
|
91
|
-
transport:
|
|
155
|
+
transport: makeL1HttpTransport(rpcUrls, { timeout: opts?.httpTimeoutMS }),
|
|
92
156
|
pollingInterval: pollingIntervalMS,
|
|
93
157
|
}).extend(publicActions);
|
|
94
158
|
|
package/src/config.ts
CHANGED
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
type ConfigMappingsType,
|
|
3
3
|
bigintConfigHelper,
|
|
4
4
|
booleanConfigHelper,
|
|
5
|
-
enumConfigHelper,
|
|
6
5
|
getConfigFromMappings,
|
|
7
6
|
getDefaultConfig,
|
|
8
7
|
numberConfigHelper,
|
|
8
|
+
omitConfigMappings,
|
|
9
9
|
optionalNumberConfigHelper,
|
|
10
10
|
} from '@aztec/foundation/config';
|
|
11
11
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -18,6 +18,8 @@ export type GenesisStateConfig = {
|
|
|
18
18
|
testAccounts: boolean;
|
|
19
19
|
/** Whether to populate the genesis state with initial fee juice for the sponsored FPC */
|
|
20
20
|
sponsoredFPC: boolean;
|
|
21
|
+
/** Additional addresses to prefund with fee juice at genesis */
|
|
22
|
+
prefundAddresses: string[];
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
export type L1ContractsConfig = {
|
|
@@ -57,13 +59,13 @@ export type L1ContractsConfig = {
|
|
|
57
59
|
slashingOffsetInRounds: number;
|
|
58
60
|
/** How long slashing can be disabled for in seconds when vetoer disables it */
|
|
59
61
|
slashingDisableDuration: number;
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
/** Minimum amount that can be slashed
|
|
62
|
+
/** Whether to deploy a slasher proposer */
|
|
63
|
+
slasherEnabled: boolean;
|
|
64
|
+
/** Minimum amount that can be slashed */
|
|
63
65
|
slashAmountSmall: bigint;
|
|
64
|
-
/** Medium amount to slash
|
|
66
|
+
/** Medium amount to slash */
|
|
65
67
|
slashAmountMedium: bigint;
|
|
66
|
-
/** Largest amount that can be slashed per round
|
|
68
|
+
/** Largest amount that can be slashed per round */
|
|
67
69
|
slashAmountLarge: bigint;
|
|
68
70
|
/** Governance proposing quorum (defaults to roundSize/2 + 1) */
|
|
69
71
|
governanceProposerQuorum?: number;
|
|
@@ -99,7 +101,7 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
99
101
|
},
|
|
100
102
|
aztecEpochDuration: {
|
|
101
103
|
env: 'AZTEC_EPOCH_DURATION',
|
|
102
|
-
description: `How many L2 slots an epoch lasts (maximum
|
|
104
|
+
description: `How many L2 slots an epoch lasts (maximum MAX_CHECKPOINTS_PER_EPOCH).`,
|
|
103
105
|
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EPOCH_DURATION),
|
|
104
106
|
},
|
|
105
107
|
aztecTargetCommitteeSize: {
|
|
@@ -149,13 +151,10 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
149
151
|
'How many slashing rounds back we slash (ie when slashing in round N, we slash for offenses committed during epochs of round N-offset)',
|
|
150
152
|
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_SLASHING_OFFSET_IN_ROUNDS),
|
|
151
153
|
},
|
|
152
|
-
|
|
153
|
-
env: '
|
|
154
|
-
description: '
|
|
155
|
-
...
|
|
156
|
-
['empire', 'tally', 'none'] as const,
|
|
157
|
-
l1ContractsDefaultEnv.AZTEC_SLASHER_FLAVOR as 'empire' | 'tally' | 'none',
|
|
158
|
-
),
|
|
154
|
+
slasherEnabled: {
|
|
155
|
+
env: 'AZTEC_SLASHER_ENABLED',
|
|
156
|
+
description: 'Whether to deploy a slasher proposer',
|
|
157
|
+
...booleanConfigHelper(true),
|
|
159
158
|
},
|
|
160
159
|
slashAmountSmall: {
|
|
161
160
|
env: 'AZTEC_SLASH_AMOUNT_SMALL',
|
|
@@ -238,7 +237,7 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
238
237
|
description: 'The delay before a validator can exit the set',
|
|
239
238
|
...numberConfigHelper(l1ContractsDefaultEnv.AZTEC_EXIT_DELAY_SECONDS),
|
|
240
239
|
},
|
|
241
|
-
...l1TxUtilsConfigMappings,
|
|
240
|
+
...omitConfigMappings(l1TxUtilsConfigMappings, ['ethereumSlotDuration']),
|
|
242
241
|
};
|
|
243
242
|
|
|
244
243
|
/**
|
|
@@ -247,6 +246,41 @@ export const l1ContractsConfigMappings: ConfigMappingsType<L1ContractsConfig> =
|
|
|
247
246
|
*/
|
|
248
247
|
export const DefaultL1ContractsConfig = getDefaultConfig(l1ContractsConfigMappings);
|
|
249
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
|
+
|
|
250
284
|
export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig> = {
|
|
251
285
|
testAccounts: {
|
|
252
286
|
env: 'TEST_ACCOUNTS',
|
|
@@ -258,6 +292,16 @@ export const genesisStateConfigMappings: ConfigMappingsType<GenesisStateConfig>
|
|
|
258
292
|
description: 'Whether to populate the genesis state with initial fee juice for the sponsored FPC.',
|
|
259
293
|
...booleanConfigHelper(false),
|
|
260
294
|
},
|
|
295
|
+
prefundAddresses: {
|
|
296
|
+
env: 'PREFUND_ADDRESSES',
|
|
297
|
+
description: 'Comma-separated list of Aztec addresses to prefund with fee juice at genesis (local network only).',
|
|
298
|
+
parseEnv: (val: string) =>
|
|
299
|
+
val
|
|
300
|
+
.split(',')
|
|
301
|
+
.map(a => a.trim())
|
|
302
|
+
.filter(a => a.length > 0),
|
|
303
|
+
defaultValue: [],
|
|
304
|
+
},
|
|
261
305
|
};
|
|
262
306
|
|
|
263
307
|
export function getL1ContractsConfigEnvVars(): L1ContractsConfig {
|
|
@@ -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
|
+
}
|
|
@@ -43,6 +43,7 @@ export class FeeAssetHandlerContract {
|
|
|
43
43
|
}
|
|
44
44
|
return txUtils.sendAndMonitorTransaction({
|
|
45
45
|
to: this.address.toString(),
|
|
46
|
+
abi: FeeAssetHandlerAbi,
|
|
46
47
|
data: encodeFunctionData({
|
|
47
48
|
abi: FeeAssetHandlerAbi,
|
|
48
49
|
functionName: 'mint',
|
|
@@ -54,6 +55,7 @@ export class FeeAssetHandlerContract {
|
|
|
54
55
|
public setMintAmount(txUtils: L1TxUtils, amount: bigint) {
|
|
55
56
|
return txUtils.sendAndMonitorTransaction({
|
|
56
57
|
to: this.address.toString(),
|
|
58
|
+
abi: FeeAssetHandlerAbi,
|
|
57
59
|
data: encodeFunctionData({
|
|
58
60
|
abi: FeeAssetHandlerAbi,
|
|
59
61
|
functionName: 'setMintAmount',
|