@aztec/ethereum 3.0.0-nightly.20250923 → 3.0.0-nightly.20250924
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/test/eth_cheat_codes.d.ts +10 -3
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +9 -3
- package/dest/test/rollup_cheat_codes.d.ts +3 -8
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +3 -4
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +2 -1
- package/package.json +5 -5
- package/src/test/eth_cheat_codes.ts +11 -5
- package/src/test/rollup_cheat_codes.ts +8 -12
- package/src/test/upgrade_utils.ts +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
2
|
+
import type { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
3
3
|
import { type Hex } from 'viem';
|
|
4
4
|
import type { ViemPublicClient } from '../types.js';
|
|
5
5
|
/**
|
|
@@ -10,6 +10,10 @@ export declare class EthCheatCodes {
|
|
|
10
10
|
* The RPC URL to use for interacting with the chain
|
|
11
11
|
*/
|
|
12
12
|
rpcUrls: string[];
|
|
13
|
+
/**
|
|
14
|
+
* The date provider to use for time operations
|
|
15
|
+
*/
|
|
16
|
+
dateProvider: DateProvider | TestDateProvider;
|
|
13
17
|
/**
|
|
14
18
|
* The logger to use for the eth cheatcodes
|
|
15
19
|
*/
|
|
@@ -20,6 +24,10 @@ export declare class EthCheatCodes {
|
|
|
20
24
|
* The RPC URL to use for interacting with the chain
|
|
21
25
|
*/
|
|
22
26
|
rpcUrls: string[],
|
|
27
|
+
/**
|
|
28
|
+
* The date provider to use for time operations
|
|
29
|
+
*/
|
|
30
|
+
dateProvider: DateProvider | TestDateProvider,
|
|
23
31
|
/**
|
|
24
32
|
* The logger to use for the eth cheatcodes
|
|
25
33
|
*/
|
|
@@ -104,13 +112,12 @@ export declare class EthCheatCodes {
|
|
|
104
112
|
/**
|
|
105
113
|
* Set the next block timestamp and mines the block.
|
|
106
114
|
* Optionally resets interval mining so the next block is mined in `blockInterval` seconds from now.
|
|
107
|
-
*
|
|
115
|
+
* Always updates the injected date provider to follow L1 time.
|
|
108
116
|
* @param timestamp - The timestamp to set the next block to
|
|
109
117
|
*/
|
|
110
118
|
warp(timestamp: number | bigint, opts?: {
|
|
111
119
|
silent?: boolean;
|
|
112
120
|
resetBlockInterval?: boolean;
|
|
113
|
-
updateDateProvider?: TestDateProvider;
|
|
114
121
|
}): Promise<void>;
|
|
115
122
|
/**
|
|
116
123
|
* Load the value at a storage slot of a contract address on eth
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/eth_cheat_codes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"eth_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/eth_cheat_codes.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,KAAK,GAAG,EAAsC,MAAM,MAAM,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,qBAAa,aAAa;IAGtB;;OAEG;IACI,OAAO,EAAE,MAAM,EAAE;IACxB;;OAEG;IACI,YAAY,EAAE,YAAY,GAAG,gBAAgB;IACpD;;OAEG;IACI,MAAM;IAbf,SAAgB,YA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AG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;IAKtE;;;;OAIG;IACU,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;IAKnE;;;;OAIG;IACU,qBAAqB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAK7D;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1C;;;OAGG;IACI,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBlD;;;;;OAKG;IACU,oBAAoB,CAC/B,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,CAAC,GAAG,GAAG;QAAE,EAAE,EAAE,UAAU,GAAG,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,GAAG,CAAC;QAAC,IAAI,CAAC,EAAE,UAAU,GAAG,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,EAAE,EAAO,GAClH,OAAO,CAAC,IAAI,CAAC;IAaT,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAIrC,mBAAmB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAgCtE"}
|
|
@@ -7,14 +7,18 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
7
7
|
* A class that provides utility functions for interacting with ethereum (L1).
|
|
8
8
|
*/ export class EthCheatCodes {
|
|
9
9
|
rpcUrls;
|
|
10
|
+
dateProvider;
|
|
10
11
|
logger;
|
|
11
12
|
publicClient;
|
|
12
13
|
constructor(/**
|
|
13
14
|
* The RPC URL to use for interacting with the chain
|
|
14
15
|
*/ rpcUrls, /**
|
|
16
|
+
* The date provider to use for time operations
|
|
17
|
+
*/ dateProvider, /**
|
|
15
18
|
* The logger to use for the eth cheatcodes
|
|
16
19
|
*/ logger = createLogger('ethereum:cheat_codes')){
|
|
17
20
|
this.rpcUrls = rpcUrls;
|
|
21
|
+
this.dateProvider = dateProvider;
|
|
18
22
|
this.logger = logger;
|
|
19
23
|
this.publicClient = createPublicClient({
|
|
20
24
|
transport: fallback(this.rpcUrls.map((url)=>http(url)))
|
|
@@ -206,7 +210,7 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
206
210
|
/**
|
|
207
211
|
* Set the next block timestamp and mines the block.
|
|
208
212
|
* Optionally resets interval mining so the next block is mined in `blockInterval` seconds from now.
|
|
209
|
-
*
|
|
213
|
+
* Always updates the injected date provider to follow L1 time.
|
|
210
214
|
* @param timestamp - The timestamp to set the next block to
|
|
211
215
|
*/ async warp(timestamp, opts = {}) {
|
|
212
216
|
let blockInterval = null;
|
|
@@ -226,8 +230,10 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
226
230
|
]);
|
|
227
231
|
// And mine a block so the timestamp goes into effect now
|
|
228
232
|
await this.doMine();
|
|
229
|
-
// Update the date provider
|
|
230
|
-
|
|
233
|
+
// Update the injected date provider so it follows L1 time
|
|
234
|
+
if ('setTime' in this.dateProvider) {
|
|
235
|
+
this.dateProvider.setTime(Number(timestamp) * 1000);
|
|
236
|
+
}
|
|
231
237
|
} catch (err) {
|
|
232
238
|
throw new Error(`Error warping: ${err}`);
|
|
233
239
|
} finally{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ViemPublicClient } from '@aztec/ethereum';
|
|
2
2
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
|
-
import type {
|
|
3
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
4
4
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
5
5
|
import { type GetContractReturnType, type Hex } from 'viem';
|
|
6
6
|
import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
@@ -11,7 +11,7 @@ export declare class RollupCheatCodes {
|
|
|
11
11
|
private rollup;
|
|
12
12
|
private logger;
|
|
13
13
|
constructor(ethCheatCodes: EthCheatCodes, addresses: Pick<L1ContractAddresses, 'rollupAddress'>);
|
|
14
|
-
static create(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'
|
|
14
|
+
static create(rpcUrls: string[], addresses: Pick<L1ContractAddresses, 'rollupAddress'>, dateProvider: DateProvider): RollupCheatCodes;
|
|
15
15
|
/** Returns the current slot */
|
|
16
16
|
getSlot(): Promise<bigint>;
|
|
17
17
|
/** Returns the current epoch */
|
|
@@ -39,16 +39,11 @@ export declare class RollupCheatCodes {
|
|
|
39
39
|
* @param opts - Options
|
|
40
40
|
*/
|
|
41
41
|
advanceToEpoch(epoch: bigint | number, opts?: {
|
|
42
|
-
/** Optional test date provider to update with the epoch timestamp */
|
|
43
|
-
updateDateProvider?: TestDateProvider;
|
|
44
42
|
/** Offset in seconds */
|
|
45
43
|
offset?: number;
|
|
46
44
|
}): Promise<bigint>;
|
|
47
45
|
/** Warps time in L1 until the next epoch */
|
|
48
|
-
advanceToNextEpoch(
|
|
49
|
-
/** Optional test date provider to update with the epoch timestamp */
|
|
50
|
-
updateDateProvider?: TestDateProvider;
|
|
51
|
-
}): Promise<void>;
|
|
46
|
+
advanceToNextEpoch(): Promise<void>;
|
|
52
47
|
/** Warps time in L1 until the beginning of the next slot. */
|
|
53
48
|
advanceToNextSlot(): Promise<bigint[]>;
|
|
54
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceRoot":"","sources":["../../src/test/rollup_cheat_codes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"rollup_cheat_codes.d.ts","sourceR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AAM,EACtB,IAAI,GAAE;QACJ,wBAAwB;QACxB,MAAM,CAAC,EAAE,MAAM,CAAC;KACZ;IAcR,4CAA4C;IAC/B,kBAAkB;IAa/B,6DAA6D;IAChD,iBAAiB;IAQ9B;;;OAGG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM;IASzC;;;OAGG;IACI,YAAY,CAAC,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM;IAiCtD;;;OAGG;IACI,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAqCxE;;;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;IAQ1G;;OAEG;IACU,UAAU;IASvB,4CAA4C;IAC/B,oBAAoB;IAQjC;;;OAGG;IACU,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM;IAMtE;;;OAGG;IACU,qBAAqB,CAAC,QAAQ,EAAE,MAAM;CAWpD"}
|
|
@@ -23,8 +23,8 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
23
23
|
client: this.client
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
static create(rpcUrls, addresses) {
|
|
27
|
-
const ethCheatCodes = new EthCheatCodes(rpcUrls);
|
|
26
|
+
static create(rpcUrls, addresses, dateProvider) {
|
|
27
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
28
28
|
return new RollupCheatCodes(ethCheatCodes, addresses);
|
|
29
29
|
}
|
|
30
30
|
/** Returns the current slot */ async getSlot() {
|
|
@@ -99,14 +99,13 @@ import { EthCheatCodes } from './eth_cheat_codes.js';
|
|
|
99
99
|
}
|
|
100
100
|
return timestamp;
|
|
101
101
|
}
|
|
102
|
-
/** Warps time in L1 until the next epoch */ async advanceToNextEpoch(
|
|
102
|
+
/** Warps time in L1 until the next epoch */ async advanceToNextEpoch() {
|
|
103
103
|
const slot = await this.getSlot();
|
|
104
104
|
const { epochDuration, slotDuration } = await this.getConfig();
|
|
105
105
|
const slotsUntilNextEpoch = epochDuration - slot % epochDuration + 1n;
|
|
106
106
|
const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
|
|
107
107
|
const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
|
|
108
108
|
await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
|
|
109
|
-
...opts,
|
|
110
109
|
silent: true,
|
|
111
110
|
resetBlockInterval: true
|
|
112
111
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade_utils.d.ts","sourceRoot":"","sources":["../../src/test/upgrade_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"upgrade_utils.d.ts","sourceRoot":"","sources":["../../src/test/upgrade_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAe,MAAM,MAAM,CAAC;AAGvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9E,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,qBAAqB,CAAC,OAAO,aAAa,EAAE,gBAAgB,CAAC,EACzE,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,iBAAiB,EAC7B,QAAQ,EAAE,wBAAwB,EAClC,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,MAAM,iBAmCf;AAED,wBAAsB,wBAAwB,CAC5C,cAAc,EAAE,KAAK,MAAM,EAAE,EAC7B,SAAS,EAAE,mBAAmB,EAC9B,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,gBAAgB,EAC9B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IACT,UAAU,EAAE,qBAAqB,CAAC,OAAO,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAyCD"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
1
2
|
import { GovernanceAbi } from '@aztec/l1-artifacts/GovernanceAbi';
|
|
2
3
|
import { TestERC20Abi as StakingAssetAbi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
3
4
|
import { getContract } from 'viem';
|
|
@@ -15,7 +16,7 @@ export async function executeGovernanceProposal(proposalId, governance, voteAmou
|
|
|
15
16
|
value: 1n
|
|
16
17
|
});
|
|
17
18
|
};
|
|
18
|
-
const cheatCodes = new EthCheatCodes(rpcUrls, logger);
|
|
19
|
+
const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), logger);
|
|
19
20
|
const timeToActive = proposal.creation + proposal.config.votingDelay;
|
|
20
21
|
logger.info(`Warping to ${timeToActive + 1n}`);
|
|
21
22
|
await cheatCodes.warp(Number(timeToActive + 1n));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20250924",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"../package.common.json"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
35
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
36
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
37
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
34
|
+
"@aztec/blob-lib": "3.0.0-nightly.20250924",
|
|
35
|
+
"@aztec/constants": "3.0.0-nightly.20250924",
|
|
36
|
+
"@aztec/foundation": "3.0.0-nightly.20250924",
|
|
37
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20250924",
|
|
38
38
|
"@viem/anvil": "^0.0.10",
|
|
39
39
|
"dotenv": "^16.0.3",
|
|
40
40
|
"lodash.chunk": "^4.2.0",
|
|
@@ -3,7 +3,7 @@ import { keccak256 } from '@aztec/foundation/crypto';
|
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
6
|
+
import type { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
7
7
|
|
|
8
8
|
import { type Hex, createPublicClient, fallback, http } from 'viem';
|
|
9
9
|
|
|
@@ -19,6 +19,10 @@ export class EthCheatCodes {
|
|
|
19
19
|
* The RPC URL to use for interacting with the chain
|
|
20
20
|
*/
|
|
21
21
|
public rpcUrls: string[],
|
|
22
|
+
/**
|
|
23
|
+
* The date provider to use for time operations
|
|
24
|
+
*/
|
|
25
|
+
public dateProvider: DateProvider | TestDateProvider,
|
|
22
26
|
/**
|
|
23
27
|
* The logger to use for the eth cheatcodes
|
|
24
28
|
*/
|
|
@@ -225,12 +229,12 @@ export class EthCheatCodes {
|
|
|
225
229
|
/**
|
|
226
230
|
* Set the next block timestamp and mines the block.
|
|
227
231
|
* Optionally resets interval mining so the next block is mined in `blockInterval` seconds from now.
|
|
228
|
-
*
|
|
232
|
+
* Always updates the injected date provider to follow L1 time.
|
|
229
233
|
* @param timestamp - The timestamp to set the next block to
|
|
230
234
|
*/
|
|
231
235
|
public async warp(
|
|
232
236
|
timestamp: number | bigint,
|
|
233
|
-
opts: { silent?: boolean; resetBlockInterval?: boolean
|
|
237
|
+
opts: { silent?: boolean; resetBlockInterval?: boolean } = {},
|
|
234
238
|
): Promise<void> {
|
|
235
239
|
let blockInterval: number | null = null;
|
|
236
240
|
try {
|
|
@@ -245,8 +249,10 @@ export class EthCheatCodes {
|
|
|
245
249
|
await this.rpcCall('evm_setNextBlockTimestamp', [Number(timestamp)]);
|
|
246
250
|
// And mine a block so the timestamp goes into effect now
|
|
247
251
|
await this.doMine();
|
|
248
|
-
// Update the date provider
|
|
249
|
-
|
|
252
|
+
// Update the injected date provider so it follows L1 time
|
|
253
|
+
if ('setTime' in this.dateProvider) {
|
|
254
|
+
this.dateProvider.setTime(Number(timestamp) * 1000);
|
|
255
|
+
}
|
|
250
256
|
} catch (err) {
|
|
251
257
|
throw new Error(`Error warping: ${err}`);
|
|
252
258
|
} finally {
|
|
@@ -2,7 +2,7 @@ import { RollupContract, type ViemPublicClient } from '@aztec/ethereum';
|
|
|
2
2
|
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import type {
|
|
5
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
6
6
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
7
7
|
|
|
8
8
|
import {
|
|
@@ -40,8 +40,12 @@ export class RollupCheatCodes {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
static create(
|
|
44
|
-
|
|
43
|
+
static create(
|
|
44
|
+
rpcUrls: string[],
|
|
45
|
+
addresses: Pick<L1ContractAddresses, 'rollupAddress'>,
|
|
46
|
+
dateProvider: DateProvider,
|
|
47
|
+
): RollupCheatCodes {
|
|
48
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
45
49
|
return new RollupCheatCodes(ethCheatCodes, addresses);
|
|
46
50
|
}
|
|
47
51
|
|
|
@@ -114,8 +118,6 @@ export class RollupCheatCodes {
|
|
|
114
118
|
public async advanceToEpoch(
|
|
115
119
|
epoch: bigint | number,
|
|
116
120
|
opts: {
|
|
117
|
-
/** Optional test date provider to update with the epoch timestamp */
|
|
118
|
-
updateDateProvider?: TestDateProvider;
|
|
119
121
|
/** Offset in seconds */
|
|
120
122
|
offset?: number;
|
|
121
123
|
} = {},
|
|
@@ -133,19 +135,13 @@ export class RollupCheatCodes {
|
|
|
133
135
|
}
|
|
134
136
|
|
|
135
137
|
/** Warps time in L1 until the next epoch */
|
|
136
|
-
public async advanceToNextEpoch(
|
|
137
|
-
opts: {
|
|
138
|
-
/** Optional test date provider to update with the epoch timestamp */
|
|
139
|
-
updateDateProvider?: TestDateProvider;
|
|
140
|
-
} = {},
|
|
141
|
-
) {
|
|
138
|
+
public async advanceToNextEpoch() {
|
|
142
139
|
const slot = await this.getSlot();
|
|
143
140
|
const { epochDuration, slotDuration } = await this.getConfig();
|
|
144
141
|
const slotsUntilNextEpoch = epochDuration - (slot % epochDuration) + 1n;
|
|
145
142
|
const timeToNextEpoch = slotsUntilNextEpoch * slotDuration;
|
|
146
143
|
const l1Timestamp = BigInt((await this.client.getBlock()).timestamp);
|
|
147
144
|
await this.ethCheatCodes.warp(Number(l1Timestamp + timeToNextEpoch), {
|
|
148
|
-
...opts,
|
|
149
145
|
silent: true,
|
|
150
146
|
resetBlockInterval: true,
|
|
151
147
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Logger } from '@aztec/foundation/log';
|
|
2
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
2
3
|
import { GovernanceAbi } from '@aztec/l1-artifacts/GovernanceAbi';
|
|
3
4
|
import { TestERC20Abi as StakingAssetAbi } from '@aztec/l1-artifacts/TestERC20Abi';
|
|
4
5
|
|
|
@@ -30,7 +31,7 @@ export async function executeGovernanceProposal(
|
|
|
30
31
|
});
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
const cheatCodes = new EthCheatCodes(rpcUrls, logger);
|
|
34
|
+
const cheatCodes = new EthCheatCodes(rpcUrls, new DateProvider(), logger);
|
|
34
35
|
|
|
35
36
|
const timeToActive = proposal.creation + proposal.config.votingDelay;
|
|
36
37
|
logger.info(`Warping to ${timeToActive + 1n}`);
|