@aztec/ethereum 0.84.0-nightly.20250410 → 0.84.0-nightly.20250412
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.
|
@@ -143,5 +143,22 @@ export declare class EthCheatCodes {
|
|
|
143
143
|
* @returns The raw transaction
|
|
144
144
|
*/
|
|
145
145
|
getRawTransaction(txHash: Hex): Promise<`0x${string}`>;
|
|
146
|
+
/**
|
|
147
|
+
* Triggers a reorg of the given depth, removing those blocks from the chain.
|
|
148
|
+
* @param depth - The depth of the reorg
|
|
149
|
+
*/
|
|
150
|
+
reorg(depth: number): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Triggers a reorg of the given depth, optionally replacing it with new blocks.
|
|
153
|
+
* The resulting block height will be the same as the original chain.
|
|
154
|
+
* @param depth - The depth of the reorg
|
|
155
|
+
* @param newBlocks - The blocks to replace the old ones with, each represented as a list of txs.
|
|
156
|
+
*/
|
|
157
|
+
reorgWithReplacement(depth: number, newBlocks?: (Hex | {
|
|
158
|
+
to: EthAddress | Hex;
|
|
159
|
+
input?: Hex;
|
|
160
|
+
from?: EthAddress | Hex;
|
|
161
|
+
value?: number | bigint;
|
|
162
|
+
})[][]): Promise<void>;
|
|
146
163
|
}
|
|
147
164
|
//# sourceMappingURL=eth_cheat_codes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eth_cheat_codes.d.ts","sourceRoot":"","sources":["../src/eth_cheat_codes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"eth_cheat_codes.d.ts","sourceRoot":"","sources":["../src/eth_cheat_codes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,EAAE,KAAK,GAAG,EAAsC,MAAM,MAAM,CAAC;AAIpE;;GAEG;AACH,qBAAa,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C;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC,EAAE,EAAO,GAClH,OAAO,CAAC,IAAI,CAAC;CAWjB"}
|
package/dest/eth_cheat_codes.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer';
|
|
2
2
|
import { keccak256 } from '@aztec/foundation/crypto';
|
|
3
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { createPublicClient, fallback, http } from 'viem';
|
|
5
6
|
/**
|
|
@@ -20,7 +21,7 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
23
|
async rpcCall(method, params) {
|
|
23
|
-
const paramsString =
|
|
24
|
+
const paramsString = jsonStringify(params);
|
|
24
25
|
this.logger.info(`Calling ${method} with params: ${paramsString} on ${this.rpcUrls.join(', ')}`);
|
|
25
26
|
return await this.publicClient.transport.request({
|
|
26
27
|
method,
|
|
@@ -300,4 +301,42 @@ import { createPublicClient, fallback, http } from 'viem';
|
|
|
300
301
|
]);
|
|
301
302
|
return res;
|
|
302
303
|
}
|
|
304
|
+
/**
|
|
305
|
+
* Triggers a reorg of the given depth, removing those blocks from the chain.
|
|
306
|
+
* @param depth - The depth of the reorg
|
|
307
|
+
*/ async reorg(depth) {
|
|
308
|
+
try {
|
|
309
|
+
await this.rpcCall('anvil_rollback', [
|
|
310
|
+
depth
|
|
311
|
+
]);
|
|
312
|
+
} catch (err) {
|
|
313
|
+
throw new Error(`Error rolling back: ${err}`);
|
|
314
|
+
}
|
|
315
|
+
this.logger.warn(`Rolled back L1 chain with depth ${depth}`);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Triggers a reorg of the given depth, optionally replacing it with new blocks.
|
|
319
|
+
* The resulting block height will be the same as the original chain.
|
|
320
|
+
* @param depth - The depth of the reorg
|
|
321
|
+
* @param newBlocks - The blocks to replace the old ones with, each represented as a list of txs.
|
|
322
|
+
*/ async reorgWithReplacement(depth, newBlocks = []) {
|
|
323
|
+
try {
|
|
324
|
+
await this.rpcCall('anvil_reorg', [
|
|
325
|
+
depth,
|
|
326
|
+
newBlocks.flatMap((txs, index)=>txs.map((tx)=>[
|
|
327
|
+
typeof tx === 'string' ? tx : {
|
|
328
|
+
value: 0,
|
|
329
|
+
...tx
|
|
330
|
+
},
|
|
331
|
+
index
|
|
332
|
+
]))
|
|
333
|
+
]);
|
|
334
|
+
} catch (err) {
|
|
335
|
+
throw new Error(`Error reorging: ${err}`);
|
|
336
|
+
}
|
|
337
|
+
this.logger.warn(`Reorged L1 chain with depth ${depth} and ${newBlocks.length} new blocks`, {
|
|
338
|
+
depth,
|
|
339
|
+
newBlocks
|
|
340
|
+
});
|
|
341
|
+
}
|
|
303
342
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "0.84.0-nightly.
|
|
3
|
+
"version": "0.84.0-nightly.20250412",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"../package.common.json"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@aztec/blob-lib": "0.84.0-nightly.
|
|
38
|
-
"@aztec/foundation": "0.84.0-nightly.
|
|
39
|
-
"@aztec/l1-artifacts": "0.84.0-nightly.
|
|
37
|
+
"@aztec/blob-lib": "0.84.0-nightly.20250412",
|
|
38
|
+
"@aztec/foundation": "0.84.0-nightly.20250412",
|
|
39
|
+
"@aztec/l1-artifacts": "0.84.0-nightly.20250412",
|
|
40
40
|
"@viem/anvil": "^0.0.10",
|
|
41
41
|
"dotenv": "^16.0.3",
|
|
42
42
|
"tslib": "^2.4.0",
|
package/src/eth_cheat_codes.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer';
|
|
2
2
|
import { keccak256 } from '@aztec/foundation/crypto';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
4
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
6
|
|
|
6
7
|
import { type Hex, createPublicClient, fallback, http } from 'viem';
|
|
@@ -28,7 +29,7 @@ export class EthCheatCodes {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
async rpcCall(method: string, params: any[]) {
|
|
31
|
-
const paramsString =
|
|
32
|
+
const paramsString = jsonStringify(params);
|
|
32
33
|
this.logger.info(`Calling ${method} with params: ${paramsString} on ${this.rpcUrls.join(', ')}`);
|
|
33
34
|
return (await this.publicClient.transport.request({
|
|
34
35
|
method,
|
|
@@ -311,4 +312,38 @@ export class EthCheatCodes {
|
|
|
311
312
|
const res = await this.rpcCall('debug_getRawTransaction', [txHash]);
|
|
312
313
|
return res;
|
|
313
314
|
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Triggers a reorg of the given depth, removing those blocks from the chain.
|
|
318
|
+
* @param depth - The depth of the reorg
|
|
319
|
+
*/
|
|
320
|
+
public async reorg(depth: number): Promise<void> {
|
|
321
|
+
try {
|
|
322
|
+
await this.rpcCall('anvil_rollback', [depth]);
|
|
323
|
+
} catch (err) {
|
|
324
|
+
throw new Error(`Error rolling back: ${err}`);
|
|
325
|
+
}
|
|
326
|
+
this.logger.warn(`Rolled back L1 chain with depth ${depth}`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Triggers a reorg of the given depth, optionally replacing it with new blocks.
|
|
331
|
+
* The resulting block height will be the same as the original chain.
|
|
332
|
+
* @param depth - The depth of the reorg
|
|
333
|
+
* @param newBlocks - The blocks to replace the old ones with, each represented as a list of txs.
|
|
334
|
+
*/
|
|
335
|
+
public async reorgWithReplacement(
|
|
336
|
+
depth: number,
|
|
337
|
+
newBlocks: (Hex | { to: EthAddress | Hex; input?: Hex; from?: EthAddress | Hex; value?: number | bigint })[][] = [],
|
|
338
|
+
): Promise<void> {
|
|
339
|
+
try {
|
|
340
|
+
await this.rpcCall('anvil_reorg', [
|
|
341
|
+
depth,
|
|
342
|
+
newBlocks.flatMap((txs, index) => txs.map(tx => [typeof tx === 'string' ? tx : { value: 0, ...tx }, index])),
|
|
343
|
+
]);
|
|
344
|
+
} catch (err) {
|
|
345
|
+
throw new Error(`Error reorging: ${err}`);
|
|
346
|
+
}
|
|
347
|
+
this.logger.warn(`Reorged L1 chain with depth ${depth} and ${newBlocks.length} new blocks`, { depth, newBlocks });
|
|
348
|
+
}
|
|
314
349
|
}
|