@aztec/ethereum 0.0.1-commit.a5db02d → 0.0.1-commit.aa0c64f
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 +13 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +30 -3
- package/dest/contracts/multicall.d.ts +5 -3
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +7 -5
- package/dest/deploy_aztec_l1_contracts.d.ts +15 -4
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +13 -9
- 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 +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +27 -7
- 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/queries.d.ts +1 -1
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +7 -1
- package/dest/test/eth_cheat_codes.d.ts +7 -1
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +29 -4
- package/dest/utils.js +8 -11
- package/package.json +5 -6
- package/src/config.ts +38 -3
- package/src/contracts/multicall.ts +8 -5
- package/src/deploy_aztec_l1_contracts.ts +13 -8
- package/src/l1_tx_utils/l1_fee_analyzer.ts +75 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +19 -2
- package/src/l1_tx_utils/types.ts +32 -0
- package/src/queries.ts +6 -0
- package/src/test/eth_cheat_codes.ts +23 -2
- package/src/utils.ts +11 -11
- 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/generated/l1-contracts-defaults.ts +0 -32
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
type L1TxConfig,
|
|
37
37
|
type L1TxRequest,
|
|
38
38
|
type L1TxState,
|
|
39
|
+
L1TxTimeoutError,
|
|
39
40
|
type SigningCallback,
|
|
40
41
|
TerminalTxUtilsState,
|
|
41
42
|
TxUtilsState,
|
|
@@ -306,6 +307,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
306
307
|
txConfigOverrides: gasConfigOverrides ?? {},
|
|
307
308
|
sentAtL1Ts: now,
|
|
308
309
|
lastSentAtL1Ts: now,
|
|
310
|
+
gasPriceHistory: [baseState.gasPrice],
|
|
309
311
|
};
|
|
310
312
|
|
|
311
313
|
// And persist it
|
|
@@ -504,6 +506,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
504
506
|
if (timePassed >= stallTimeMs && attempts <= maxSpeedUpAttempts) {
|
|
505
507
|
const newGasPrice = await this.getGasPrice(gasConfig, isBlobTx, attempts, state.gasPrice);
|
|
506
508
|
state.gasPrice = newGasPrice;
|
|
509
|
+
state.gasPriceHistory?.push(newGasPrice);
|
|
507
510
|
|
|
508
511
|
this.logger.debug(
|
|
509
512
|
`Tx ${currentTxHash} with nonce ${nonce} from ${account} appears stuck. ` +
|
|
@@ -672,8 +675,22 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
672
675
|
blobInputs?: L1BlobInputs,
|
|
673
676
|
): Promise<{ receipt: TransactionReceipt; state: L1TxState }> {
|
|
674
677
|
const { state } = await this.sendTransaction(request, gasConfig, blobInputs);
|
|
675
|
-
|
|
676
|
-
|
|
678
|
+
try {
|
|
679
|
+
const receipt = await this.monitorTransaction(state);
|
|
680
|
+
return { receipt, state };
|
|
681
|
+
} catch (err) {
|
|
682
|
+
if (err instanceof TimeoutError) {
|
|
683
|
+
// Snapshot the ladder now: the fire-and-forget cancellation mutates state.gasPrice moments later.
|
|
684
|
+
throw new L1TxTimeoutError(err.message, {
|
|
685
|
+
gasPriceHistory: state.gasPriceHistory ? [...state.gasPriceHistory] : undefined,
|
|
686
|
+
finalGasPrice: state.gasPrice,
|
|
687
|
+
attempts: state.txHashes.length,
|
|
688
|
+
nonce: state.nonce,
|
|
689
|
+
gasLimit: state.gasLimit,
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
throw err;
|
|
693
|
+
}
|
|
677
694
|
}
|
|
678
695
|
|
|
679
696
|
public override async simulate(
|
package/src/l1_tx_utils/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BlobKzgInstance } from '@aztec/blob-lib/types';
|
|
2
|
+
import { TimeoutError } from '@aztec/foundation/error';
|
|
2
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import type { ViemTransactionSignature } from '@aztec/foundation/eth-signature';
|
|
4
5
|
|
|
@@ -55,6 +56,12 @@ export type L1TxState = {
|
|
|
55
56
|
cancelTxHashes: Hex[];
|
|
56
57
|
gasLimit: bigint;
|
|
57
58
|
gasPrice: GasPrice;
|
|
59
|
+
/**
|
|
60
|
+
* Prices used for each attempt (initial send followed by each speed-up), in order. Always set on
|
|
61
|
+
* newly sent txs; optional because states restored from the state store predate the field.
|
|
62
|
+
* In-memory only — not persisted by the state store.
|
|
63
|
+
*/
|
|
64
|
+
gasPriceHistory?: GasPrice[];
|
|
58
65
|
txConfigOverrides: L1TxConfig;
|
|
59
66
|
request: L1TxRequest;
|
|
60
67
|
status: TxUtilsState;
|
|
@@ -83,3 +90,28 @@ export class DroppedTransactionError extends Error {
|
|
|
83
90
|
this.name = 'DroppedTransactionError';
|
|
84
91
|
}
|
|
85
92
|
}
|
|
93
|
+
|
|
94
|
+
/** Snapshot of what a timed-out L1 tx tried to pay, taken when the timeout is raised. */
|
|
95
|
+
export type TimedOutTxState = {
|
|
96
|
+
/** Prices used across the initial send and each speed-up, in order (undefined only for restored states). */
|
|
97
|
+
gasPriceHistory?: GasPrice[];
|
|
98
|
+
/** The last price the tx was sent at before timing out. */
|
|
99
|
+
finalGasPrice: GasPrice;
|
|
100
|
+
/** Number of send attempts (initial + speed-ups). */
|
|
101
|
+
attempts: number;
|
|
102
|
+
nonce: number;
|
|
103
|
+
gasLimit: bigint;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Thrown by sendAndMonitorTransaction when a tx times out. Subclasses TimeoutError so existing
|
|
108
|
+
* `instanceof TimeoutError` checks keep working, while carrying the gas-price ladder for diagnostics.
|
|
109
|
+
*/
|
|
110
|
+
export class L1TxTimeoutError extends TimeoutError {
|
|
111
|
+
constructor(
|
|
112
|
+
message: string,
|
|
113
|
+
public readonly txState: TimedOutTxState,
|
|
114
|
+
) {
|
|
115
|
+
super(message);
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/queries.ts
CHANGED
|
@@ -186,5 +186,11 @@ export async function getL1ContractsConfig(
|
|
|
186
186
|
slashAmountMedium: slashingAmounts[1],
|
|
187
187
|
slashAmountLarge: slashingAmounts[2],
|
|
188
188
|
initialEthPerFeeAsset: DefaultL1ContractsConfig.initialEthPerFeeAsset,
|
|
189
|
+
// Not exposed by the rollup contract; fall back to defaults like the other non-on-chain fields above.
|
|
190
|
+
entryQueueBootstrapValidatorSetSize: DefaultL1ContractsConfig.entryQueueBootstrapValidatorSetSize,
|
|
191
|
+
entryQueueBootstrapFlushSize: DefaultL1ContractsConfig.entryQueueBootstrapFlushSize,
|
|
192
|
+
entryQueueFlushSizeMin: DefaultL1ContractsConfig.entryQueueFlushSizeMin,
|
|
193
|
+
entryQueueFlushSizeQuotient: DefaultL1ContractsConfig.entryQueueFlushSizeQuotient,
|
|
194
|
+
entryQueueMaxFlushSize: DefaultL1ContractsConfig.entryQueueMaxFlushSize,
|
|
189
195
|
};
|
|
190
196
|
}
|
|
@@ -505,19 +505,40 @@ export class EthCheatCodes {
|
|
|
505
505
|
* reorg is needed because anvil applies a new gas limit only to future blocks: without it the just-mined
|
|
506
506
|
* blocks would keep the tiny gas limit, and an `eth_call` against `latest` (whose gas is capped by the
|
|
507
507
|
* block gas limit) would revert with "intrinsic gas too high".
|
|
508
|
+
*
|
|
509
|
+
* The replacement blocks advance L1 time. `anvil_reorg` stamps each replacement as `parent + N*interval`,
|
|
510
|
+
* so on its own it would freeze L1 time at the parent timestamp; callers that measure elapsed L1 time
|
|
511
|
+
* (L1TxUtils stall/timeout detection, `syncDateProvider`-driven slot advancement) rely on it moving
|
|
512
|
+
* forward. We reproduce the wall-clock advance the mine step just made (at least 1s per block) via a
|
|
513
|
+
* temporary block-timestamp interval, then restore any pre-existing interval.
|
|
508
514
|
*/
|
|
509
515
|
public async mineEmptyBlock(blockCount: number = 1): Promise<void> {
|
|
510
516
|
await this.execWithPausedAnvil(async () => {
|
|
511
517
|
const originalGasLimit = await this.getBlockGasLimit();
|
|
518
|
+
const parentTimestamp = await this.lastBlockTimestamp();
|
|
519
|
+
// anvil has no getter for the block-timestamp interval, but the pending block is stamped
|
|
520
|
+
// `latest + interval`, so this delta is the standing interval (0 when none is set).
|
|
521
|
+
const priorInterval = (await this.nextBlockTimestamp()) - parentTimestamp;
|
|
512
522
|
try {
|
|
513
523
|
await this.setBlockGasLimit(1n);
|
|
514
524
|
await this.doMine(blockCount);
|
|
515
525
|
} finally {
|
|
516
526
|
await this.setBlockGasLimit(originalGasLimit);
|
|
517
527
|
}
|
|
528
|
+
const advance = (await this.lastBlockTimestamp()) - parentTimestamp;
|
|
529
|
+
const perBlockInterval = Math.max(1, Math.floor(advance / blockCount));
|
|
518
530
|
// Replace the tiny-gas-limit blocks with empty blocks at the restored gas limit, keeping the same
|
|
519
|
-
// height
|
|
520
|
-
await this.doRpcCall('
|
|
531
|
+
// height. The reorged-out blocks held no transactions, so nothing returns to the pool.
|
|
532
|
+
await this.doRpcCall('anvil_setBlockTimestampInterval', [perBlockInterval]);
|
|
533
|
+
try {
|
|
534
|
+
await this.doRpcCall('anvil_reorg', [blockCount, []]);
|
|
535
|
+
} finally {
|
|
536
|
+
if (priorInterval > 0) {
|
|
537
|
+
await this.doRpcCall('anvil_setBlockTimestampInterval', [priorInterval]);
|
|
538
|
+
} else {
|
|
539
|
+
await this.doRpcCall('anvil_removeBlockTimestampInterval', []);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
521
542
|
});
|
|
522
543
|
|
|
523
544
|
this.logger.warn(`Mined ${blockCount} empty L1 ${pluralize('block', blockCount)}`);
|
package/src/utils.ts
CHANGED
|
@@ -235,18 +235,18 @@ export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViem
|
|
|
235
235
|
// If decoding fails, we fall back to the original formatting
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
// Strip ABI from the error object before formatting
|
|
239
|
-
// caller's error, but structuredClone throws DataCloneError on values it cannot clone (e.g.
|
|
240
|
-
// viem RPC errors carrying function-valued request context). If cloning fails, fall back to
|
|
241
|
-
// formatting the original error untouched rather than letting the clone failure mask it.
|
|
238
|
+
// Strip ABI from the error object before formatting
|
|
242
239
|
if (error && typeof error === 'object') {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
240
|
+
// Create a clone to avoid modifying the original
|
|
241
|
+
const errorClone = structuredClone(error);
|
|
242
|
+
|
|
243
|
+
// Helper function to recursively remove ABI properties
|
|
244
|
+
|
|
245
|
+
// Strip ABIs from the clone
|
|
246
|
+
stripAbis(errorClone);
|
|
247
|
+
|
|
248
|
+
// Use the cleaned clone for further processing
|
|
249
|
+
error = errorClone;
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
// If it's a regular Error instance, return it with its message
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/** Default L1 contracts configuration values from network-defaults.yml */
|
|
2
|
-
export declare const l1ContractsDefaultEnv: {
|
|
3
|
-
readonly ETHEREUM_SLOT_DURATION: 12;
|
|
4
|
-
readonly AZTEC_SLOT_DURATION: 72;
|
|
5
|
-
readonly AZTEC_EPOCH_DURATION: 32;
|
|
6
|
-
readonly AZTEC_TARGET_COMMITTEE_SIZE: 48;
|
|
7
|
-
readonly AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: 2;
|
|
8
|
-
readonly AZTEC_LAG_IN_EPOCHS_FOR_RANDAO: 2;
|
|
9
|
-
readonly AZTEC_ACTIVATION_THRESHOLD: 100000000000000000000;
|
|
10
|
-
readonly AZTEC_EJECTION_THRESHOLD: 50000000000000000000;
|
|
11
|
-
readonly AZTEC_LOCAL_EJECTION_THRESHOLD: 98000000000000000000;
|
|
12
|
-
readonly AZTEC_EXIT_DELAY_SECONDS: 172800;
|
|
13
|
-
readonly AZTEC_INBOX_LAG: 2;
|
|
14
|
-
readonly AZTEC_PROOF_SUBMISSION_EPOCHS: 1;
|
|
15
|
-
readonly AZTEC_MANA_TARGET: 100000000;
|
|
16
|
-
readonly AZTEC_PROVING_COST_PER_MANA: 100;
|
|
17
|
-
readonly AZTEC_INITIAL_ETH_PER_FEE_ASSET: 10000000;
|
|
18
|
-
readonly AZTEC_SLASHER_ENABLED: true;
|
|
19
|
-
readonly AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: 4;
|
|
20
|
-
readonly AZTEC_SLASHING_LIFETIME_IN_ROUNDS: 5;
|
|
21
|
-
readonly AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS: 0;
|
|
22
|
-
readonly AZTEC_SLASHING_OFFSET_IN_ROUNDS: 2;
|
|
23
|
-
readonly AZTEC_SLASHING_VETOER: "0x0000000000000000000000000000000000000000";
|
|
24
|
-
readonly AZTEC_SLASHING_DISABLE_DURATION: 432000;
|
|
25
|
-
readonly AZTEC_SLASH_AMOUNT_SMALL: 10000000000000000000;
|
|
26
|
-
readonly AZTEC_SLASH_AMOUNT_MEDIUM: 20000000000000000000;
|
|
27
|
-
readonly AZTEC_SLASH_AMOUNT_LARGE: 50000000000000000000;
|
|
28
|
-
readonly AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE: 300;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDEtY29udHJhY3RzLWRlZmF1bHRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZ2VuZXJhdGVkL2wxLWNvbnRyYWN0cy1kZWZhdWx0cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHQSwwRUFBMEU7QUFDMUUsZUFBTyxNQUFNLHFCQUFxQjs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0NBMkJ4QixDQUFDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"l1-contracts-defaults.d.ts","sourceRoot":"","sources":["../../src/generated/l1-contracts-defaults.ts"],"names":[],"mappings":"AAGA,0EAA0E;AAC1E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BxB,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Auto-generated from spartan/environments/network-defaults.yml
|
|
2
|
-
// Do not edit manually - run yarn generate to regenerate
|
|
3
|
-
/** Default L1 contracts configuration values from network-defaults.yml */ export const l1ContractsDefaultEnv = {
|
|
4
|
-
ETHEREUM_SLOT_DURATION: 12,
|
|
5
|
-
AZTEC_SLOT_DURATION: 72,
|
|
6
|
-
AZTEC_EPOCH_DURATION: 32,
|
|
7
|
-
AZTEC_TARGET_COMMITTEE_SIZE: 48,
|
|
8
|
-
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: 2,
|
|
9
|
-
AZTEC_LAG_IN_EPOCHS_FOR_RANDAO: 2,
|
|
10
|
-
AZTEC_ACTIVATION_THRESHOLD: 100000000000000000000,
|
|
11
|
-
AZTEC_EJECTION_THRESHOLD: 50000000000000000000,
|
|
12
|
-
AZTEC_LOCAL_EJECTION_THRESHOLD: 98000000000000000000,
|
|
13
|
-
AZTEC_EXIT_DELAY_SECONDS: 172800,
|
|
14
|
-
AZTEC_INBOX_LAG: 2,
|
|
15
|
-
AZTEC_PROOF_SUBMISSION_EPOCHS: 1,
|
|
16
|
-
AZTEC_MANA_TARGET: 100000000,
|
|
17
|
-
AZTEC_PROVING_COST_PER_MANA: 100,
|
|
18
|
-
AZTEC_INITIAL_ETH_PER_FEE_ASSET: 10000000,
|
|
19
|
-
AZTEC_SLASHER_ENABLED: true,
|
|
20
|
-
AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: 4,
|
|
21
|
-
AZTEC_SLASHING_LIFETIME_IN_ROUNDS: 5,
|
|
22
|
-
AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS: 0,
|
|
23
|
-
AZTEC_SLASHING_OFFSET_IN_ROUNDS: 2,
|
|
24
|
-
AZTEC_SLASHING_VETOER: '0x0000000000000000000000000000000000000000',
|
|
25
|
-
AZTEC_SLASHING_DISABLE_DURATION: 432000,
|
|
26
|
-
AZTEC_SLASH_AMOUNT_SMALL: 10000000000000000000,
|
|
27
|
-
AZTEC_SLASH_AMOUNT_MEDIUM: 20000000000000000000,
|
|
28
|
-
AZTEC_SLASH_AMOUNT_LARGE: 50000000000000000000,
|
|
29
|
-
AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE: 300
|
|
30
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Auto-generated from spartan/environments/network-defaults.yml
|
|
2
|
-
// Do not edit manually - run yarn generate to regenerate
|
|
3
|
-
|
|
4
|
-
/** Default L1 contracts configuration values from network-defaults.yml */
|
|
5
|
-
export const l1ContractsDefaultEnv = {
|
|
6
|
-
ETHEREUM_SLOT_DURATION: 12,
|
|
7
|
-
AZTEC_SLOT_DURATION: 72,
|
|
8
|
-
AZTEC_EPOCH_DURATION: 32,
|
|
9
|
-
AZTEC_TARGET_COMMITTEE_SIZE: 48,
|
|
10
|
-
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: 2,
|
|
11
|
-
AZTEC_LAG_IN_EPOCHS_FOR_RANDAO: 2,
|
|
12
|
-
AZTEC_ACTIVATION_THRESHOLD: 100000000000000000000,
|
|
13
|
-
AZTEC_EJECTION_THRESHOLD: 50000000000000000000,
|
|
14
|
-
AZTEC_LOCAL_EJECTION_THRESHOLD: 98000000000000000000,
|
|
15
|
-
AZTEC_EXIT_DELAY_SECONDS: 172800,
|
|
16
|
-
AZTEC_INBOX_LAG: 2,
|
|
17
|
-
AZTEC_PROOF_SUBMISSION_EPOCHS: 1,
|
|
18
|
-
AZTEC_MANA_TARGET: 100000000,
|
|
19
|
-
AZTEC_PROVING_COST_PER_MANA: 100,
|
|
20
|
-
AZTEC_INITIAL_ETH_PER_FEE_ASSET: 10000000,
|
|
21
|
-
AZTEC_SLASHER_ENABLED: true,
|
|
22
|
-
AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: 4,
|
|
23
|
-
AZTEC_SLASHING_LIFETIME_IN_ROUNDS: 5,
|
|
24
|
-
AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS: 0,
|
|
25
|
-
AZTEC_SLASHING_OFFSET_IN_ROUNDS: 2,
|
|
26
|
-
AZTEC_SLASHING_VETOER: '0x0000000000000000000000000000000000000000',
|
|
27
|
-
AZTEC_SLASHING_DISABLE_DURATION: 432000,
|
|
28
|
-
AZTEC_SLASH_AMOUNT_SMALL: 10000000000000000000,
|
|
29
|
-
AZTEC_SLASH_AMOUNT_MEDIUM: 20000000000000000000,
|
|
30
|
-
AZTEC_SLASH_AMOUNT_LARGE: 50000000000000000000,
|
|
31
|
-
AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE: 300,
|
|
32
|
-
} as const;
|