@aztec/ethereum 0.0.1-commit.a072138 → 0.0.1-commit.a4600f49
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 +29 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +69 -14
- 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_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 +196 -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 +53 -2
- 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 +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/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 +402 -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} +13 -15
- package/dest/deploy_aztec_l1_contracts.d.ts +19 -12
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +54 -35
- package/dest/deploy_l1_contract.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/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_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 +26 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +179 -82
- 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 +10 -5
- 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/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 +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 +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 -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 +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 +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 +9 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +48 -16
- package/package.json +6 -9
- package/src/client.ts +66 -2
- package/src/config.ts +97 -18
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/fee_asset_price_oracle.ts +285 -0
- package/src/contracts/governance.ts +269 -12
- package/src/contracts/governance_proposer.ts +54 -1
- 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 +247 -106
- package/src/contracts/outbox.ts +42 -8
- package/src/contracts/registry.ts +31 -1
- package/src/contracts/rollup.ts +453 -78
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +14 -16
- package/src/deploy_aztec_l1_contracts.ts +76 -43
- package/src/deploy_l1_contract.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/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_fee_analyzer.ts +75 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +164 -62
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +10 -5
- package/src/{test → l1_tx_utils}/tx_delayer.ts +93 -56
- 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 +148 -3
- package/src/test/eth_cheat_codes.ts +82 -45
- package/src/test/index.ts +1 -2
- package/src/test/rollup_cheat_codes.ts +115 -6
- package/src/test/start_anvil.ts +177 -29
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +45 -18
- 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 -207
- 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/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 -259
- package/src/generated/l1-contracts-defaults.ts +0 -32
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
|
@@ -70,9 +70,11 @@ import { foundry } from 'viem/chains';
|
|
|
70
70
|
return parseInt(res, 16);
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* Get the
|
|
74
|
-
*
|
|
75
|
-
|
|
73
|
+
* Get the timestamp of the latest mined L1 block.
|
|
74
|
+
* Note: this is NOT the current time — it's the discrete timestamp of the last block.
|
|
75
|
+
* Between blocks, the actual chain time advances but no new block reflects it.
|
|
76
|
+
* @returns The latest block timestamp in seconds
|
|
77
|
+
*/ async lastBlockTimestamp() {
|
|
76
78
|
const res = await this.doRpcCall('eth_getBlockByNumber', [
|
|
77
79
|
'latest',
|
|
78
80
|
true
|
|
@@ -80,6 +82,17 @@ import { foundry } from 'viem/chains';
|
|
|
80
82
|
return parseInt(res.timestamp, 16);
|
|
81
83
|
}
|
|
82
84
|
/**
|
|
85
|
+
* Get the timestamp of the pending L1 block — the block that anvil will mine next.
|
|
86
|
+
* Reflects any prior `setNextBlockTimestamp` call or the configured block interval.
|
|
87
|
+
* @returns The pending block timestamp in seconds.
|
|
88
|
+
*/ async nextBlockTimestamp() {
|
|
89
|
+
const res = await this.doRpcCall('eth_getBlockByNumber', [
|
|
90
|
+
'pending',
|
|
91
|
+
false
|
|
92
|
+
]);
|
|
93
|
+
return parseInt(res.timestamp, 16);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
83
96
|
* Advance the chain by a number of blocks
|
|
84
97
|
* @param numberOfBlocks - The number of blocks to mine
|
|
85
98
|
*/ async mine(numberOfBlocks = 1) {
|
|
@@ -179,6 +192,21 @@ import { foundry } from 'viem/chains';
|
|
|
179
192
|
}
|
|
180
193
|
}
|
|
181
194
|
/**
|
|
195
|
+
* Starts interval mining from a freshly mined block and syncs the date provider to the block timestamp.
|
|
196
|
+
*/ async startIntervalMiningWithFreshBlock(seconds) {
|
|
197
|
+
if (seconds <= 0) {
|
|
198
|
+
throw new Error(`Interval mining requires a positive interval, got ${seconds}`);
|
|
199
|
+
}
|
|
200
|
+
await this.setAutomine(false);
|
|
201
|
+
await this.setIntervalMining(0, {
|
|
202
|
+
silent: true
|
|
203
|
+
});
|
|
204
|
+
await this.evmMine();
|
|
205
|
+
await this.syncDateProvider();
|
|
206
|
+
await this.setIntervalMining(seconds);
|
|
207
|
+
this.logger.warn(`Started L1 interval mining at ${seconds} seconds from a fresh block`);
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
182
210
|
* Set the automine status of the underlying anvil chain
|
|
183
211
|
* @param automine - The automine status to set
|
|
184
212
|
*/ async setAutomine(automine, opts = {}) {
|
|
@@ -449,52 +477,72 @@ import { foundry } from 'viem/chains';
|
|
|
449
477
|
return mapTxPoolContent(txpoolContent);
|
|
450
478
|
}
|
|
451
479
|
/**
|
|
452
|
-
* Mines
|
|
453
|
-
*
|
|
480
|
+
* Mines empty blocks while leaving any pending transactions untouched in the mempool.
|
|
481
|
+
*
|
|
482
|
+
* Never manipulates the mempool, so it is immune to the race that dropping and re-adding txs has against a
|
|
483
|
+
* concurrent publisher that is monitoring and re-broadcasting the same in-flight tx (with that approach the
|
|
484
|
+
* in-flight tx could reappear in the pool and be swept into the "empty" block, mining a proposal the caller
|
|
485
|
+
* expected to stay pending). Works in two steps: first the block gas limit is temporarily lowered below the
|
|
486
|
+
* intrinsic cost of any transaction (21000 gas) and the blocks are mined, so no pending tx is includable;
|
|
487
|
+
* then those blocks are reorged out and replaced with empty blocks mined at the restored gas limit. The
|
|
488
|
+
* reorg is needed because anvil applies a new gas limit only to future blocks: without it the just-mined
|
|
489
|
+
* blocks would keep the tiny gas limit, and an `eth_call` against `latest` (whose gas is capped by the
|
|
490
|
+
* block gas limit) would revert with "intrinsic gas too high".
|
|
491
|
+
*
|
|
492
|
+
* The replacement blocks advance L1 time. `anvil_reorg` stamps each replacement as `parent + N*interval`,
|
|
493
|
+
* so on its own it would freeze L1 time at the parent timestamp; callers that measure elapsed L1 time
|
|
494
|
+
* (L1TxUtils stall/timeout detection, `syncDateProvider`-driven slot advancement) rely on it moving
|
|
495
|
+
* forward. We reproduce the wall-clock advance the mine step just made (at least 1s per block) via a
|
|
496
|
+
* temporary block-timestamp interval, then restore any pre-existing interval.
|
|
454
497
|
*/ async mineEmptyBlock(blockCount = 1) {
|
|
455
498
|
await this.execWithPausedAnvil(async ()=>{
|
|
456
|
-
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
//
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
if (rawTx) {
|
|
467
|
-
rawTxs.push(rawTx);
|
|
468
|
-
this.logger.debug(`Got raw tx for ${tx.hash}`);
|
|
469
|
-
} else {
|
|
470
|
-
this.logger.warn(`No raw tx found for ${tx.hash}`);
|
|
471
|
-
}
|
|
472
|
-
} catch {
|
|
473
|
-
this.logger.warn(`Failed to get raw transaction for ${tx.hash}`);
|
|
474
|
-
}
|
|
499
|
+
const originalGasLimit = await this.getBlockGasLimit();
|
|
500
|
+
const parentTimestamp = await this.lastBlockTimestamp();
|
|
501
|
+
// anvil has no getter for the block-timestamp interval, but the pending block is stamped
|
|
502
|
+
// `latest + interval`, so this delta is the standing interval (0 when none is set).
|
|
503
|
+
const priorInterval = await this.nextBlockTimestamp() - parentTimestamp;
|
|
504
|
+
try {
|
|
505
|
+
await this.setBlockGasLimit(1n);
|
|
506
|
+
await this.doMine(blockCount);
|
|
507
|
+
} finally{
|
|
508
|
+
await this.setBlockGasLimit(originalGasLimit);
|
|
475
509
|
}
|
|
476
|
-
this.
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
//
|
|
480
|
-
await this.
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
510
|
+
const advance = await this.lastBlockTimestamp() - parentTimestamp;
|
|
511
|
+
const perBlockInterval = Math.max(1, Math.floor(advance / blockCount));
|
|
512
|
+
// Replace the tiny-gas-limit blocks with empty blocks at the restored gas limit, keeping the same
|
|
513
|
+
// height. The reorged-out blocks held no transactions, so nothing returns to the pool.
|
|
514
|
+
await this.doRpcCall('anvil_setBlockTimestampInterval', [
|
|
515
|
+
perBlockInterval
|
|
516
|
+
]);
|
|
517
|
+
try {
|
|
518
|
+
await this.doRpcCall('anvil_reorg', [
|
|
519
|
+
blockCount,
|
|
520
|
+
[]
|
|
521
|
+
]);
|
|
522
|
+
} finally{
|
|
523
|
+
if (priorInterval > 0) {
|
|
524
|
+
await this.doRpcCall('anvil_setBlockTimestampInterval', [
|
|
525
|
+
priorInterval
|
|
486
526
|
]);
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
this.logger.warn(`Failed to re-add transaction: ${err}`);
|
|
527
|
+
} else {
|
|
528
|
+
await this.doRpcCall('anvil_removeBlockTimestampInterval', []);
|
|
490
529
|
}
|
|
491
530
|
}
|
|
492
|
-
if (rawTxs.length !== txs.length) {
|
|
493
|
-
this.logger.warn(`Failed to add all txs back: had ${txs.length} but re-added ${rawTxs.length}`);
|
|
494
|
-
}
|
|
495
531
|
});
|
|
496
532
|
this.logger.warn(`Mined ${blockCount} empty L1 ${pluralize('block', blockCount)}`);
|
|
497
533
|
}
|
|
534
|
+
/** Returns the gas limit of the latest mined L1 block. */ async getBlockGasLimit() {
|
|
535
|
+
const block = await this.doRpcCall('eth_getBlockByNumber', [
|
|
536
|
+
'latest',
|
|
537
|
+
false
|
|
538
|
+
]);
|
|
539
|
+
return BigInt(block.gasLimit);
|
|
540
|
+
}
|
|
541
|
+
/** Sets the block gas limit applied to subsequently mined L1 blocks. */ async setBlockGasLimit(gasLimit) {
|
|
542
|
+
await this.doRpcCall('anvil_setBlockGasLimit', [
|
|
543
|
+
toHex(gasLimit)
|
|
544
|
+
]);
|
|
545
|
+
}
|
|
498
546
|
async execWithPausedAnvil(fn) {
|
|
499
547
|
const [blockInterval, wasAutoMining] = await Promise.all([
|
|
500
548
|
this.getIntervalMining(),
|
|
@@ -536,7 +584,7 @@ import { foundry } from 'viem/chains';
|
|
|
536
584
|
}
|
|
537
585
|
}
|
|
538
586
|
async syncDateProvider() {
|
|
539
|
-
const timestamp = await this.
|
|
587
|
+
const timestamp = await this.lastBlockTimestamp();
|
|
540
588
|
if ('setTime' in this.dateProvider) {
|
|
541
589
|
this.dateProvider.setTime(timestamp * 1000);
|
|
542
590
|
}
|
package/dest/test/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './blob_kzg_warmup.js';
|
|
2
2
|
export * from './eth_cheat_codes.js';
|
|
3
3
|
export * from './eth_cheat_codes_with_state.js';
|
|
4
4
|
export * from './start_anvil.js';
|
|
5
|
-
export * from './tx_delayer.js';
|
|
6
5
|
export * from './upgrade_utils.js';
|
|
7
6
|
export * from './chain_monitor.js';
|
|
8
7
|
export * from './rollup_cheat_codes.js';
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsc0JBQXNCLENBQUM7QUFDckMsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLGlDQUFpQyxDQUFDO0FBQ2hELGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyxvQkFBb0IsQ0FBQztBQUNuQyxjQUFjLG9CQUFvQixDQUFDO0FBQ25DLGNBQWMseUJBQXlCLENBQUMifQ==
|
package/dest/test/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC"}
|
package/dest/test/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './blob_kzg_warmup.js';
|
|
2
2
|
export * from './eth_cheat_codes.js';
|
|
3
3
|
export * from './eth_cheat_codes_with_state.js';
|
|
4
4
|
export * from './start_anvil.js';
|
|
5
|
-
export * from './tx_delayer.js';
|
|
6
5
|
export * from './upgrade_utils.js';
|
|
7
6
|
export * from './chain_monitor.js';
|
|
8
7
|
export * from './rollup_cheat_codes.js';
|
|
@@ -15,6 +15,10 @@ export declare class RollupCheatCodes {
|
|
|
15
15
|
static create(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>, dateProvider: DateProvider): RollupCheatCodes;
|
|
16
16
|
/** Returns the current slot */
|
|
17
17
|
getSlot(): Promise<SlotNumber>;
|
|
18
|
+
/** Returns the slot number at a given timestamp. */
|
|
19
|
+
getSlotAt(timestamp: bigint): Promise<SlotNumber>;
|
|
20
|
+
/** Returns the timestamp for the start of a given slot. */
|
|
21
|
+
getTimestampForSlot(slot: SlotNumber): Promise<bigint>;
|
|
18
22
|
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */
|
|
19
23
|
getSecondsUntilSlot(slot: SlotNumber): Promise<number>;
|
|
20
24
|
/** Returns the current epoch */
|
|
@@ -49,6 +53,15 @@ export declare class RollupCheatCodes {
|
|
|
49
53
|
advanceToNextEpoch(): Promise<void>;
|
|
50
54
|
/** Warps time in L1 until the beginning of the next slot. */
|
|
51
55
|
advanceToNextSlot(): Promise<(bigint | SlotNumber)[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
|
|
58
|
+
* relative to the current L1 timestamp at call time and therefore races with real-time
|
|
59
|
+
* progression between query and warp, this lands at the slot regardless of latency.
|
|
60
|
+
*
|
|
61
|
+
* Throws if the requested slot is in the past relative to current L1 time (anvil cannot
|
|
62
|
+
* rewind).
|
|
63
|
+
*/
|
|
64
|
+
advanceToSlot(slot: SlotNumber): Promise<bigint>;
|
|
52
65
|
/**
|
|
53
66
|
* Warps time in L1 equivalent to however many slots.
|
|
54
67
|
* @param howMany - The number of slots to advance.
|
|
@@ -59,12 +72,41 @@ export declare class RollupCheatCodes {
|
|
|
59
72
|
* @param maybeCheckpointNumber - The checkpoint number to mark as proven (defaults to latest pending)
|
|
60
73
|
*/
|
|
61
74
|
markAsProven(maybeCheckpointNumber?: CheckpointNumber): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
|
|
77
|
+
* not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
|
|
78
|
+
*/
|
|
79
|
+
waitForEpoch(epoch: EpochNumber, opts?: {
|
|
80
|
+
timeout?: number;
|
|
81
|
+
interval?: number;
|
|
82
|
+
}): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
|
|
85
|
+
* warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
|
|
86
|
+
*/
|
|
87
|
+
waitForSlot(slot: SlotNumber, opts?: {
|
|
88
|
+
timeout?: number;
|
|
89
|
+
interval?: number;
|
|
90
|
+
}): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
|
|
93
|
+
* checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
|
|
94
|
+
* rather than a node, since a rollback lands on L1 first.
|
|
95
|
+
*
|
|
96
|
+
* A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
|
|
97
|
+
* replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
|
|
98
|
+
* empty state — hence the non-zero guard.
|
|
99
|
+
*/
|
|
100
|
+
waitForCheckpointBelow(checkpoint: CheckpointNumber, opts?: {
|
|
101
|
+
timeout?: number;
|
|
102
|
+
interval?: number;
|
|
103
|
+
}): Promise<CheckpointNumber>;
|
|
62
104
|
/**
|
|
63
105
|
* Overrides the inProgress field of the Inbox contract state
|
|
64
106
|
* @param howMuch - How many checkpoints to move it forward
|
|
65
107
|
*/
|
|
66
108
|
advanceInboxInProgress(howMuch: number | bigint): Promise<bigint>;
|
|
67
|
-
insertOutbox(epoch: EpochNumber, outHash: bigint): Promise<void>;
|
|
109
|
+
insertOutbox(epoch: EpochNumber, numCheckpointsInEpoch: number, outHash: bigint): Promise<void>;
|
|
68
110
|
/**
|
|
69
111
|
* Executes an action impersonated as the owner of the Rollup contract.
|
|
70
112
|
* @param action - The action to execute
|
|
@@ -82,9 +124,24 @@ export declare class RollupCheatCodes {
|
|
|
82
124
|
*/
|
|
83
125
|
bumpProvingCostPerMana(bumper: (before: bigint) => bigint): Promise<void>;
|
|
84
126
|
/**
|
|
85
|
-
* Directly updates proving cost per mana.
|
|
127
|
+
* Directly updates proving cost per mana. Throws if the on-chain tx reverts
|
|
128
|
+
* (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
|
|
86
129
|
* @param ethValue - The new proving cost per mana in ETH
|
|
87
130
|
*/
|
|
88
131
|
setProvingCostPerMana(ethValue: bigint): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
|
|
134
|
+
* by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
|
|
135
|
+
* successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
|
|
136
|
+
* land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
|
|
137
|
+
*
|
|
138
|
+
* @note This is tightly coupled to the `FeeStore` layout in
|
|
139
|
+
* l1-contracts/src/core/libraries/rollup/FeeLib.sol:
|
|
140
|
+
* slot + 0: CompressedFeeConfig config (uint256)
|
|
141
|
+
* slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
|
|
142
|
+
* slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
|
|
143
|
+
* If the struct layout changes, update the offset below.
|
|
144
|
+
*/
|
|
145
|
+
clearProvingCostCooldown(): Promise<void>;
|
|
89
146
|
}
|
|
90
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
147
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm9sbHVwX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FO0lBRU0sWUFBWSxDQUFDLEtBQUssRUFBRSxXQUFXLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxNQUFNLGlCQVNyRjtJQUVEOzs7T0FHRztJQUNVLE9BQU8sQ0FDbEIsTUFBTSxFQUFFLENBQUMsS0FBSyxFQUFFLEdBQUcsRUFBRSxNQUFNLEVBQUUscUJBQXFCLENBQUMsT0FBTyxTQUFTLEVBQUUsZ0JBQWdCLENBQUMsS0FBSyxPQUFPLENBQUMsSUFBSSxDQUFDLGlCQU16RztJQUVEOztPQUVHO0lBQ1UsVUFBVSxrQkFPdEI7SUFFRCw0Q0FBNEM7SUFDL0Isb0JBQW9CLGtCQU1oQztJQUVEOzs7T0FHRztJQUNVLHNCQUFzQixDQUFDLE1BQU0sRUFBRSxDQUFDLE1BQU0sRUFBRSxNQUFNLEtBQUssTUFBTSxpQkFJckU7SUFFRDs7OztPQUlHO0lBQ1UscUJBQXFCLENBQUMsUUFBUSxFQUFFLE1BQU0saUJBaUJsRDtJQUVEOzs7Ozs7Ozs7Ozs7T0FZRztJQUNVLHdCQUF3QixrQkFPcEM7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AACjF,OAAO,KAAK,EAAE,gBAAgB,EAAE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,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCvE;IAEM,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iBASrF;IAED;;;OAGG;IACU,OAAO,CAClB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,qBAAqB,CAAC,OAAO,SAAS,EAAE,gBAAgB,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,iBAMzG;IAED;;OAEG;IACU,UAAU,kBAOtB;IAED,4CAA4C;IAC/B,oBAAoB,kBAMhC;IAED;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,iBAIrE;IAED;;;;OAIG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM,iBAiBlD;IAED;;;;;;;;;;;;OAYG;IACU,wBAAwB,kBAOpC;CACF"}
|
|
@@ -2,8 +2,9 @@ import { OutboxContract, RollupContract } from '@aztec/ethereum/contracts';
|
|
|
2
2
|
import { CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
5
6
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
|
-
import { createPublicClient, fallback, getContract, hexToBigInt, http } from 'viem';
|
|
7
|
+
import { createPublicClient, fallback, getContract, hexToBigInt, http, keccak256 } from 'viem';
|
|
7
8
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
8
9
|
/** Cheat codes for the L1 rollup contract. */ export class RollupCheatCodes {
|
|
9
10
|
ethCheatCodes;
|
|
@@ -31,10 +32,18 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
31
32
|
}
|
|
32
33
|
/** Returns the current slot */ async getSlot() {
|
|
33
34
|
const ts = BigInt((await this.client.getBlock()).timestamp);
|
|
35
|
+
return this.getSlotAt(ts);
|
|
36
|
+
}
|
|
37
|
+
/** Returns the slot number at a given timestamp. */ async getSlotAt(timestamp) {
|
|
34
38
|
return SlotNumber.fromBigInt(await this.rollup.read.getSlotAt([
|
|
35
|
-
|
|
39
|
+
timestamp
|
|
36
40
|
]));
|
|
37
41
|
}
|
|
42
|
+
/** Returns the timestamp for the start of a given slot. */ async getTimestampForSlot(slot) {
|
|
43
|
+
return await this.rollup.read.getTimestampForSlot([
|
|
44
|
+
BigInt(slot)
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
38
47
|
/** Returns the number of seconds until the start of the given slot based on L1 block timestamp. */ async getSecondsUntilSlot(slot) {
|
|
39
48
|
const [currentTimestamp, targetTimestamp] = await Promise.all([
|
|
40
49
|
this.client.getBlock().then((b)=>BigInt(b.timestamp)),
|
|
@@ -143,6 +152,26 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
143
152
|
];
|
|
144
153
|
}
|
|
145
154
|
/**
|
|
155
|
+
* Warps L1 time to the start of an explicit absolute slot. Unlike `advanceSlots(N)` which is
|
|
156
|
+
* relative to the current L1 timestamp at call time and therefore races with real-time
|
|
157
|
+
* progression between query and warp, this lands at the slot regardless of latency.
|
|
158
|
+
*
|
|
159
|
+
* Throws if the requested slot is in the past relative to current L1 time (anvil cannot
|
|
160
|
+
* rewind).
|
|
161
|
+
*/ async advanceToSlot(slot) {
|
|
162
|
+
const timestamp = await this.rollup.read.getTimestampForSlot([
|
|
163
|
+
BigInt(slot)
|
|
164
|
+
]);
|
|
165
|
+
await this.ethCheatCodes.warp(Number(timestamp), {
|
|
166
|
+
silent: true,
|
|
167
|
+
resetBlockInterval: true
|
|
168
|
+
});
|
|
169
|
+
this.logger.warn(`Advanced to slot ${slot}`, {
|
|
170
|
+
timestamp
|
|
171
|
+
});
|
|
172
|
+
return timestamp;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
146
175
|
* Warps time in L1 equivalent to however many slots.
|
|
147
176
|
* @param howMany - The number of slots to advance.
|
|
148
177
|
*/ async advanceSlots(howMany) {
|
|
@@ -188,6 +217,32 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
188
217
|
});
|
|
189
218
|
}
|
|
190
219
|
/**
|
|
220
|
+
* Polls the rollup until its current epoch reaches `epoch`. Unlike {@link advanceToEpoch} this does
|
|
221
|
+
* not warp the L1 clock; it only waits for the chain to reach `epoch` through external activity.
|
|
222
|
+
*/ async waitForEpoch(epoch, opts = {}) {
|
|
223
|
+
await retryUntil(async ()=>await this.getEpoch() >= epoch || undefined, `rollup epoch >= ${epoch}`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Polls the rollup until its current slot reaches `slot`. Unlike {@link advanceToSlot} this does not
|
|
227
|
+
* warp the L1 clock; it only waits for the chain to reach `slot` through external activity.
|
|
228
|
+
*/ async waitForSlot(slot, opts = {}) {
|
|
229
|
+
await retryUntil(async ()=>await this.getSlot() >= slot || undefined, `rollup slot >= ${slot}`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Polls the rollup until its pending checkpoint settles below `checkpoint` on a freshly mined, non-zero
|
|
233
|
+
* checkpoint, and returns that new pending checkpoint number. Reads the L1 rollup contract directly
|
|
234
|
+
* rather than a node, since a rollback lands on L1 first.
|
|
235
|
+
*
|
|
236
|
+
* A prune can momentarily drop the pending checkpoint to 0 before the post-deadline propose mines its
|
|
237
|
+
* replacement, so a caller detecting a rollback wants the new lower checkpoint, not that transient
|
|
238
|
+
* empty state — hence the non-zero guard.
|
|
239
|
+
*/ async waitForCheckpointBelow(checkpoint, opts = {}) {
|
|
240
|
+
return await retryUntil(async ()=>{
|
|
241
|
+
const { pending } = await this.getTips();
|
|
242
|
+
return pending > 0 && pending < checkpoint ? pending : undefined;
|
|
243
|
+
}, `rollup checkpoint in (0, ${checkpoint})`, opts.timeout ?? 60, opts.interval ?? 1);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
191
246
|
* Overrides the inProgress field of the Inbox contract state
|
|
192
247
|
* @param howMuch - How many checkpoints to move it forward
|
|
193
248
|
*/ advanceInboxInProgress(howMuch) {
|
|
@@ -220,12 +275,12 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
220
275
|
return newInProgress;
|
|
221
276
|
});
|
|
222
277
|
}
|
|
223
|
-
insertOutbox(epoch, outHash) {
|
|
278
|
+
insertOutbox(epoch, numCheckpointsInEpoch, outHash) {
|
|
224
279
|
return this.ethCheatCodes.execWithPausedAnvil(async ()=>{
|
|
225
280
|
const outboxAddress = await this.rollup.read.getOutbox();
|
|
226
|
-
const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch);
|
|
281
|
+
const epochRootSlot = OutboxContract.getEpochRootStorageSlot(epoch, numCheckpointsInEpoch);
|
|
227
282
|
await this.ethCheatCodes.store(EthAddress.fromString(outboxAddress), epochRootSlot, outHash);
|
|
228
|
-
this.logger.warn(`Advanced outbox to epoch ${epoch} with out hash ${outHash}`);
|
|
283
|
+
this.logger.warn(`Advanced outbox to epoch ${epoch} numCheckpointsInEpoch ${numCheckpointsInEpoch} with out hash ${outHash}`);
|
|
229
284
|
});
|
|
230
285
|
}
|
|
231
286
|
/**
|
|
@@ -272,7 +327,8 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
272
327
|
await this.setProvingCostPerMana(newCost);
|
|
273
328
|
}
|
|
274
329
|
/**
|
|
275
|
-
* Directly updates proving cost per mana.
|
|
330
|
+
* Directly updates proving cost per mana. Throws if the on-chain tx reverts
|
|
331
|
+
* (e.g. rate-limit cooldown, step cap, or floor) instead of silently succeeding.
|
|
276
332
|
* @param ethValue - The new proving cost per mana in ETH
|
|
277
333
|
*/ async setProvingCostPerMana(ethValue) {
|
|
278
334
|
await this.asOwner(async (account, rollup)=>{
|
|
@@ -283,10 +339,33 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
283
339
|
chain: this.client.chain,
|
|
284
340
|
gasLimit: 1000000n
|
|
285
341
|
});
|
|
286
|
-
await this.client.waitForTransactionReceipt({
|
|
342
|
+
const receipt = await this.client.waitForTransactionReceipt({
|
|
287
343
|
hash
|
|
288
344
|
});
|
|
345
|
+
if (receipt.status !== 'success') {
|
|
346
|
+
throw new Error(`setProvingCostPerMana(${ethValue}) reverted on L1 (tx ${hash}). ` + `Likely FeeLib rate-limit (30-day cooldown or 1.5x step cap); ` + `use clearProvingCostCooldown() between successive updates.`);
|
|
347
|
+
}
|
|
289
348
|
this.logger.warn(`Updated proving cost per mana to ${ethValue}`);
|
|
290
349
|
});
|
|
291
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Resets the 30-day proving-cost update cooldown enforced by FeeLib.updateProvingCostPerMana
|
|
353
|
+
* by zeroing `FeeStore.provingCostLastUpdate` directly in contract storage. Use between
|
|
354
|
+
* successive setProvingCostPerMana / bumpProvingCostPerMana calls so the later update can
|
|
355
|
+
* land instead of reverting. Does not touch L1 time, so PXE/tx-expiration state stays intact.
|
|
356
|
+
*
|
|
357
|
+
* @note This is tightly coupled to the `FeeStore` layout in
|
|
358
|
+
* l1-contracts/src/core/libraries/rollup/FeeLib.sol:
|
|
359
|
+
* slot + 0: CompressedFeeConfig config (uint256)
|
|
360
|
+
* slot + 1: L1GasOracleValues l1GasOracleValues (14+14+4 bytes, packed)
|
|
361
|
+
* slot + 2: uint64 provingCostLastUpdate (only member — zeroing the slot is safe)
|
|
362
|
+
* If the struct layout changes, update the offset below.
|
|
363
|
+
*/ async clearProvingCostCooldown() {
|
|
364
|
+
const feeStoreBaseSlot = hexToBigInt(keccak256(Buffer.from('aztec.fee.storage', 'utf-8')));
|
|
365
|
+
const provingCostLastUpdateSlot = feeStoreBaseSlot + 2n;
|
|
366
|
+
await this.ethCheatCodes.store(EthAddress.fromString(this.rollup.address), provingCostLastUpdateSlot, 0n, {
|
|
367
|
+
silent: true
|
|
368
|
+
});
|
|
369
|
+
this.logger.warn(`Cleared proving-cost update cooldown`);
|
|
370
|
+
}
|
|
292
371
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
2
|
+
/** Minimal interface matching the @viem/anvil Anvil shape used by callers. */
|
|
3
|
+
export interface Anvil {
|
|
4
|
+
readonly port: number;
|
|
5
|
+
readonly host: string;
|
|
6
|
+
readonly status: 'listening' | 'idle';
|
|
7
|
+
stop(): Promise<void>;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Ensures there's a running Anvil instance and returns the RPC URL.
|
|
4
11
|
*/
|
|
@@ -9,12 +16,25 @@ export declare function startAnvil(opts?: {
|
|
|
9
16
|
captureMethodCalls?: boolean;
|
|
10
17
|
accounts?: number;
|
|
11
18
|
chainId?: number;
|
|
12
|
-
/** The hardfork to use
|
|
19
|
+
/** The hardfork to use (e.g. 'cancun', 'latest'). */
|
|
13
20
|
hardfork?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Number of slots per epoch used by anvil to compute the 'finalized' and 'safe' block tags.
|
|
23
|
+
* Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
|
|
24
|
+
* Defaults to 1 so the finalized block advances immediately, making tests that check
|
|
25
|
+
* L1-finality-based logic work without needing hundreds of mined blocks.
|
|
26
|
+
*/
|
|
27
|
+
slotsInAnEpoch?: number;
|
|
28
|
+
/**
|
|
29
|
+
* If provided, the date provider will be synced to anvil's block time on every mined block.
|
|
30
|
+
* This keeps the dateProvider in lockstep with anvil's chain time, avoiding drift between
|
|
31
|
+
* the wall clock and the L1 chain when computing L1 slot timestamps.
|
|
32
|
+
*/
|
|
33
|
+
dateProvider?: TestDateProvider;
|
|
14
34
|
}): Promise<{
|
|
15
35
|
anvil: Anvil;
|
|
16
36
|
methodCalls?: string[];
|
|
17
37
|
rpcUrl: string;
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c7SUFDSCxZQUFZLENBQUMsRUFBRSxnQkFBZ0IsQ0FBQztDQUM1QixHQUNMLE9BQU8sQ0FBQztJQUFFLEtBQUssRUFBRSxLQUFLLENBQUM7SUFBQyxXQUFXLENBQUMsRUFBRSxNQUFNLEVBQUUsQ0FBQztJQUFDLE1BQU0sRUFBRSxNQUFNLENBQUM7SUFBQyxJQUFJLEVBQUUsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUE7Q0FBRSxDQUFDLENBK0g5RiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start_anvil.d.ts","sourceRoot":"","sources":["../../src/test/start_anvil.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAMhE,8EAA8E;AAC9E,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IACtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,IAAI,GAAE;IACJ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAC5B,GACL,OAAO,CAAC;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CA+H9F"}
|