@aztec/ethereum 1.2.1 → 2.0.0-nightly.20250813
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 +22 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +49 -14
- package/dest/contracts/empire_base.d.ts +12 -10
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +21 -16
- package/dest/contracts/governance.d.ts +4 -4
- package/dest/contracts/governance.js +2 -2
- package/dest/contracts/governance_proposer.d.ts +7 -7
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +13 -13
- package/dest/contracts/gse.d.ts +29 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +56 -0
- package/dest/contracts/index.d.ts +1 -0
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +1 -0
- package/dest/contracts/multicall.d.ts +3 -1
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +11 -2
- package/dest/contracts/registry.d.ts +1 -0
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +3 -0
- package/dest/contracts/rollup.d.ts +39 -5
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +92 -14
- package/dest/contracts/slashing_proposer.d.ts +21 -10
- package/dest/contracts/slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/slashing_proposer.js +43 -23
- package/dest/deploy_l1_contracts.d.ts +11 -36664
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +92 -177
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/l1_artifacts.d.ts +51869 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +141 -0
- package/dest/l1_tx_utils.d.ts +4 -2
- package/dest/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils.js +46 -21
- package/dest/queries.d.ts +1 -8
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +20 -15
- package/dest/test/chain_monitor.d.ts +4 -2
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +12 -3
- package/dest/test/delayed_tx_utils.js +2 -2
- package/dest/{eth_cheat_codes.d.ts → test/eth_cheat_codes.d.ts} +8 -4
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/{eth_cheat_codes.js → test/eth_cheat_codes.js} +27 -11
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +2 -0
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +2 -0
- package/dest/test/rollup_cheat_codes.d.ts +81 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +234 -0
- package/dest/test/start_anvil.d.ts +1 -0
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +6 -1
- package/dest/test/tx_delayer.d.ts +8 -1
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +51 -11
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +1 -1
- package/dest/utils.d.ts +1 -0
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +1 -1
- package/package.json +5 -5
- package/src/config.ts +62 -18
- package/src/contracts/empire_base.ts +28 -19
- package/src/contracts/governance.ts +2 -2
- package/src/contracts/governance_proposer.ts +23 -15
- package/src/contracts/gse.ts +73 -0
- package/src/contracts/index.ts +1 -0
- package/src/contracts/multicall.ts +8 -1
- package/src/contracts/registry.ts +4 -0
- package/src/contracts/rollup.ts +115 -9
- package/src/contracts/slashing_proposer.ts +55 -27
- package/src/deploy_l1_contracts.ts +151 -238
- package/src/index.ts +1 -1
- package/src/l1_artifacts.ts +216 -0
- package/src/l1_tx_utils.ts +52 -26
- package/src/queries.ts +20 -31
- package/src/test/chain_monitor.ts +9 -2
- package/src/test/delayed_tx_utils.ts +2 -2
- package/src/{eth_cheat_codes.ts → test/eth_cheat_codes.ts} +20 -14
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +2 -0
- package/src/test/rollup_cheat_codes.ts +257 -0
- package/src/test/start_anvil.ts +9 -1
- package/src/test/tx_delayer.ts +55 -9
- package/src/test/upgrade_utils.ts +1 -1
- package/src/utils.ts +1 -1
- package/dest/eth_cheat_codes.d.ts.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './constants.js';
|
|
2
2
|
export * from './deploy_l1_contracts.js';
|
|
3
3
|
export * from './chain.js';
|
|
4
|
-
export * from './eth_cheat_codes.js';
|
|
5
4
|
export * from './l1_tx_utils.js';
|
|
6
5
|
export * from './l1_contract_addresses.js';
|
|
7
6
|
export * from './l1_reader.js';
|
|
@@ -13,3 +12,4 @@ export * from './queries.js';
|
|
|
13
12
|
export * from './client.js';
|
|
14
13
|
export * from './account.js';
|
|
15
14
|
export * from './l1_types.js';
|
|
15
|
+
export * from './l1_artifacts.js';
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CoinIssuerAbi,
|
|
3
|
+
CoinIssuerBytecode,
|
|
4
|
+
ExtRollupLib2Abi,
|
|
5
|
+
ExtRollupLib2Bytecode,
|
|
6
|
+
ExtRollupLib3Abi,
|
|
7
|
+
ExtRollupLib3Bytecode,
|
|
8
|
+
ExtRollupLibAbi,
|
|
9
|
+
ExtRollupLibBytecode,
|
|
10
|
+
FeeAssetHandlerAbi,
|
|
11
|
+
FeeAssetHandlerBytecode,
|
|
12
|
+
FeeJuicePortalAbi,
|
|
13
|
+
FeeJuicePortalBytecode,
|
|
14
|
+
GSEAbi,
|
|
15
|
+
GSEBytecode,
|
|
16
|
+
GovernanceAbi,
|
|
17
|
+
GovernanceBytecode,
|
|
18
|
+
GovernanceProposerAbi,
|
|
19
|
+
GovernanceProposerBytecode,
|
|
20
|
+
HonkVerifierAbi,
|
|
21
|
+
HonkVerifierBytecode,
|
|
22
|
+
InboxAbi,
|
|
23
|
+
InboxBytecode,
|
|
24
|
+
MockVerifierAbi,
|
|
25
|
+
MockVerifierBytecode,
|
|
26
|
+
MockZKPassportVerifierAbi,
|
|
27
|
+
MockZKPassportVerifierBytecode,
|
|
28
|
+
MultiAdderAbi,
|
|
29
|
+
MultiAdderBytecode,
|
|
30
|
+
OutboxAbi,
|
|
31
|
+
OutboxBytecode,
|
|
32
|
+
RegisterNewRollupVersionPayloadAbi,
|
|
33
|
+
RegisterNewRollupVersionPayloadBytecode,
|
|
34
|
+
RegistryAbi,
|
|
35
|
+
RegistryBytecode,
|
|
36
|
+
RewardDistributorAbi,
|
|
37
|
+
RewardDistributorBytecode,
|
|
38
|
+
RollupAbi,
|
|
39
|
+
RollupBytecode,
|
|
40
|
+
RollupLinkReferences,
|
|
41
|
+
SlashFactoryAbi,
|
|
42
|
+
SlashFactoryBytecode,
|
|
43
|
+
SlasherAbi,
|
|
44
|
+
SlasherBytecode,
|
|
45
|
+
StakingAssetHandlerAbi,
|
|
46
|
+
StakingAssetHandlerBytecode,
|
|
47
|
+
TestERC20Abi,
|
|
48
|
+
TestERC20Bytecode,
|
|
49
|
+
ValidatorSelectionLibAbi,
|
|
50
|
+
ValidatorSelectionLibBytecode,
|
|
51
|
+
} from '@aztec/l1-artifacts';
|
|
52
|
+
|
|
53
|
+
import type { Hex } from 'viem';
|
|
54
|
+
|
|
55
|
+
export const RegistryArtifact = {
|
|
56
|
+
name: 'Registry',
|
|
57
|
+
contractAbi: RegistryAbi,
|
|
58
|
+
contractBytecode: RegistryBytecode as Hex,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const InboxArtifact = {
|
|
62
|
+
name: 'Inbox',
|
|
63
|
+
contractAbi: InboxAbi,
|
|
64
|
+
contractBytecode: InboxBytecode as Hex,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const OutboxArtifact = {
|
|
68
|
+
name: 'Outbox',
|
|
69
|
+
contractAbi: OutboxAbi,
|
|
70
|
+
contractBytecode: OutboxBytecode as Hex,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const RollupArtifact = {
|
|
74
|
+
name: 'Rollup',
|
|
75
|
+
contractAbi: RollupAbi,
|
|
76
|
+
contractBytecode: RollupBytecode as Hex,
|
|
77
|
+
libraries: {
|
|
78
|
+
linkReferences: RollupLinkReferences,
|
|
79
|
+
libraryCode: {
|
|
80
|
+
ValidatorSelectionLib: {
|
|
81
|
+
name: 'ValidatorSelectionLib',
|
|
82
|
+
contractAbi: ValidatorSelectionLibAbi,
|
|
83
|
+
contractBytecode: ValidatorSelectionLibBytecode as Hex,
|
|
84
|
+
},
|
|
85
|
+
ExtRollupLib: {
|
|
86
|
+
name: 'ExtRollupLib',
|
|
87
|
+
contractAbi: ExtRollupLibAbi,
|
|
88
|
+
contractBytecode: ExtRollupLibBytecode as Hex,
|
|
89
|
+
},
|
|
90
|
+
ExtRollupLib2: {
|
|
91
|
+
name: 'ExtRollupLib2',
|
|
92
|
+
contractAbi: ExtRollupLib2Abi,
|
|
93
|
+
contractBytecode: ExtRollupLib2Bytecode as Hex,
|
|
94
|
+
},
|
|
95
|
+
ExtRollupLib3: {
|
|
96
|
+
name: 'ExtRollupLib3',
|
|
97
|
+
contractAbi: ExtRollupLib3Abi,
|
|
98
|
+
contractBytecode: ExtRollupLib3Bytecode as Hex,
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const StakingAssetArtifact = {
|
|
105
|
+
name: 'StakingAsset',
|
|
106
|
+
contractAbi: TestERC20Abi,
|
|
107
|
+
contractBytecode: TestERC20Bytecode as Hex,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const FeeAssetArtifact = {
|
|
111
|
+
name: 'FeeAsset',
|
|
112
|
+
contractAbi: TestERC20Abi,
|
|
113
|
+
contractBytecode: TestERC20Bytecode as Hex,
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const FeeJuicePortalArtifact = {
|
|
117
|
+
name: 'FeeJuicePortal',
|
|
118
|
+
contractAbi: FeeJuicePortalAbi,
|
|
119
|
+
contractBytecode: FeeJuicePortalBytecode as Hex,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const RewardDistributorArtifact = {
|
|
123
|
+
name: 'RewardDistributor',
|
|
124
|
+
contractAbi: RewardDistributorAbi,
|
|
125
|
+
contractBytecode: RewardDistributorBytecode as Hex,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const CoinIssuerArtifact = {
|
|
129
|
+
name: 'CoinIssuer',
|
|
130
|
+
contractAbi: CoinIssuerAbi,
|
|
131
|
+
contractBytecode: CoinIssuerBytecode as Hex,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const GovernanceProposerArtifact = {
|
|
135
|
+
name: 'GovernanceProposer',
|
|
136
|
+
contractAbi: GovernanceProposerAbi,
|
|
137
|
+
contractBytecode: GovernanceProposerBytecode as Hex,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const GovernanceArtifact = {
|
|
141
|
+
name: 'Governance',
|
|
142
|
+
contractAbi: GovernanceAbi,
|
|
143
|
+
contractBytecode: GovernanceBytecode as Hex,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const SlasherArtifact = {
|
|
147
|
+
name: 'Slasher',
|
|
148
|
+
contractAbi: SlasherAbi,
|
|
149
|
+
contractBytecode: SlasherBytecode as Hex,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export const SlashFactoryArtifact = {
|
|
153
|
+
name: 'SlashFactory',
|
|
154
|
+
contractAbi: SlashFactoryAbi,
|
|
155
|
+
contractBytecode: SlashFactoryBytecode as Hex,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const RegisterNewRollupVersionPayloadArtifact = {
|
|
159
|
+
name: 'RegisterNewRollupVersionPayload',
|
|
160
|
+
contractAbi: RegisterNewRollupVersionPayloadAbi,
|
|
161
|
+
contractBytecode: RegisterNewRollupVersionPayloadBytecode as Hex,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const FeeAssetHandlerArtifact = {
|
|
165
|
+
name: 'FeeAssetHandler',
|
|
166
|
+
contractAbi: FeeAssetHandlerAbi,
|
|
167
|
+
contractBytecode: FeeAssetHandlerBytecode as Hex,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export const StakingAssetHandlerArtifact = {
|
|
171
|
+
name: 'StakingAssetHandler',
|
|
172
|
+
contractAbi: StakingAssetHandlerAbi,
|
|
173
|
+
contractBytecode: StakingAssetHandlerBytecode as Hex,
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export const MultiAdderArtifact = {
|
|
177
|
+
name: 'MultiAdder',
|
|
178
|
+
contractAbi: MultiAdderAbi,
|
|
179
|
+
contractBytecode: MultiAdderBytecode as Hex,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const GSEArtifact = {
|
|
183
|
+
name: 'GSE',
|
|
184
|
+
contractAbi: GSEAbi,
|
|
185
|
+
contractBytecode: GSEBytecode as Hex,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Verifier artifacts
|
|
189
|
+
export const HonkVerifierArtifact = {
|
|
190
|
+
name: 'HonkVerifier',
|
|
191
|
+
contractAbi: HonkVerifierAbi,
|
|
192
|
+
contractBytecode: HonkVerifierBytecode as Hex,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const MockVerifierArtifact = {
|
|
196
|
+
name: 'MockVerifier',
|
|
197
|
+
contractAbi: MockVerifierAbi,
|
|
198
|
+
contractBytecode: MockVerifierBytecode as Hex,
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
export const MockZkPassportVerifierArtifact = {
|
|
202
|
+
name: 'MockZkPassportVerifier',
|
|
203
|
+
contractAbi: MockZKPassportVerifierAbi,
|
|
204
|
+
contractBytecode: MockZKPassportVerifierBytecode as Hex,
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
// Re-export the verifier artifacts for backwards compatibility
|
|
208
|
+
export const l1ArtifactsVerifiers = {
|
|
209
|
+
honkVerifier: HonkVerifierArtifact,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// Re-export the mock verifiers for backwards compatibility
|
|
213
|
+
export const mockVerifiers = {
|
|
214
|
+
mockVerifier: MockVerifierArtifact,
|
|
215
|
+
mockZkPassportVerifier: MockZkPassportVerifierArtifact,
|
|
216
|
+
};
|
package/src/l1_tx_utils.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
11
11
|
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
12
12
|
import { sleep } from '@aztec/foundation/sleep';
|
|
13
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
13
14
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
14
15
|
|
|
15
16
|
import pickBy from 'lodash.pickby';
|
|
@@ -215,6 +216,7 @@ export class ReadOnlyL1TxUtils {
|
|
|
215
216
|
constructor(
|
|
216
217
|
public client: ViemClient,
|
|
217
218
|
protected logger: Logger = createLogger('ReadOnlyL1TxUtils'),
|
|
219
|
+
public readonly dateProvider: DateProvider,
|
|
218
220
|
config?: Partial<L1TxUtilsConfig>,
|
|
219
221
|
protected debugMaxGasLimit: boolean = false,
|
|
220
222
|
) {
|
|
@@ -501,20 +503,15 @@ export class ReadOnlyL1TxUtils {
|
|
|
501
503
|
],
|
|
502
504
|
});
|
|
503
505
|
|
|
504
|
-
this.logger?.debug(`L1 gas used in simulation: ${result[0].calls[0].gasUsed}`, {
|
|
505
|
-
result,
|
|
506
|
-
});
|
|
507
506
|
if (result[0].calls[0].status === 'failure') {
|
|
508
|
-
this.logger?.error('L1 transaction
|
|
509
|
-
|
|
510
|
-
});
|
|
511
|
-
const decodedError = decodeErrorResult({
|
|
512
|
-
abi,
|
|
513
|
-
data: result[0].calls[0].data,
|
|
514
|
-
});
|
|
507
|
+
this.logger?.error('L1 transaction simulation failed', result[0].calls[0].error);
|
|
508
|
+
const decodedError = decodeErrorResult({ abi, data: result[0].calls[0].data });
|
|
515
509
|
|
|
516
|
-
throw new Error(
|
|
510
|
+
throw new Error(
|
|
511
|
+
`L1 transaction simulation failed with error ${decodedError.errorName}(${decodedError.args?.join(',')})`,
|
|
512
|
+
);
|
|
517
513
|
}
|
|
514
|
+
this.logger?.debug(`L1 transaction simulation succeeded`, { ...result[0].calls[0] });
|
|
518
515
|
return { gasUsed: result[0].gasUsed, result: result[0].calls[0].data as `0x${string}` };
|
|
519
516
|
} catch (err) {
|
|
520
517
|
if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) {
|
|
@@ -544,10 +541,11 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
544
541
|
constructor(
|
|
545
542
|
public override client: ExtendedViemWalletClient,
|
|
546
543
|
protected override logger: Logger = createLogger('L1TxUtils'),
|
|
544
|
+
dateProvider: DateProvider = new DateProvider(),
|
|
547
545
|
config?: Partial<L1TxUtilsConfig>,
|
|
548
546
|
debugMaxGasLimit: boolean = false,
|
|
549
547
|
) {
|
|
550
|
-
super(client, logger, config, debugMaxGasLimit);
|
|
548
|
+
super(client, logger, dateProvider, config, debugMaxGasLimit);
|
|
551
549
|
if (!isExtendedClient(this.client)) {
|
|
552
550
|
throw new Error('L1TxUtils has to be instantiated with a wallet client.');
|
|
553
551
|
}
|
|
@@ -577,8 +575,8 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
577
575
|
try {
|
|
578
576
|
const gasConfig = { ...this.config, ..._gasConfig };
|
|
579
577
|
const account = this.client.account;
|
|
580
|
-
let gasLimit: bigint;
|
|
581
578
|
|
|
579
|
+
let gasLimit: bigint;
|
|
582
580
|
if (this.debugMaxGasLimit) {
|
|
583
581
|
gasLimit = LARGE_GAS_LIMIT;
|
|
584
582
|
} else if (gasConfig.gasLimit) {
|
|
@@ -586,12 +584,11 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
586
584
|
} else {
|
|
587
585
|
gasLimit = await this.estimateGas(account, request, gasConfig);
|
|
588
586
|
}
|
|
589
|
-
|
|
590
|
-
this.logger?.debug('Gas limit', { gasLimit });
|
|
587
|
+
this.logger?.debug(`Gas limit for request is ${gasLimit}`, { gasLimit, ...request });
|
|
591
588
|
|
|
592
589
|
const gasPrice = await this.getGasPrice(gasConfig, !!blobInputs);
|
|
593
590
|
|
|
594
|
-
if (gasConfig.txTimeoutAt &&
|
|
591
|
+
if (gasConfig.txTimeoutAt && this.dateProvider.now() > gasConfig.txTimeoutAt.getTime()) {
|
|
595
592
|
throw new Error('Transaction timed out before sending');
|
|
596
593
|
}
|
|
597
594
|
|
|
@@ -676,7 +673,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
676
673
|
const txHashes = new Set<Hex>([initialTxHash]);
|
|
677
674
|
let currentTxHash = initialTxHash;
|
|
678
675
|
let attempts = 0;
|
|
679
|
-
let lastAttemptSent =
|
|
676
|
+
let lastAttemptSent = this.dateProvider.now();
|
|
680
677
|
let lastGasPrice: GasPrice = {
|
|
681
678
|
maxFeePerGas: tx.maxFeePerGas!,
|
|
682
679
|
maxPriorityFeePerGas: tx.maxPriorityFeePerGas!,
|
|
@@ -685,14 +682,26 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
685
682
|
const initialTxTime = lastAttemptSent;
|
|
686
683
|
|
|
687
684
|
let txTimedOut = false;
|
|
685
|
+
let latestBlockTimestamp: bigint | undefined;
|
|
686
|
+
|
|
687
|
+
// We check against the latestBlockTimestamp as opposed to the current time to avoid a race condition where
|
|
688
|
+
// the tx is mined in a block with the same timestamp as txTimeoutAt, but our execution node has not yet processed it,
|
|
689
|
+
// or the loop here has not yet checked the tx before that timeout.
|
|
688
690
|
const isTimedOut = () =>
|
|
689
|
-
(gasConfig.txTimeoutAt &&
|
|
690
|
-
|
|
691
|
+
(gasConfig.txTimeoutAt &&
|
|
692
|
+
latestBlockTimestamp !== undefined &&
|
|
693
|
+
Number(latestBlockTimestamp) * 1000 >= gasConfig.txTimeoutAt.getTime()) ||
|
|
694
|
+
(gasConfig.txTimeoutMs !== undefined && this.dateProvider.now() - initialTxTime > gasConfig.txTimeoutMs) ||
|
|
691
695
|
this.interrupted ||
|
|
692
696
|
false;
|
|
693
697
|
|
|
694
698
|
while (!txTimedOut) {
|
|
695
699
|
try {
|
|
700
|
+
({ timestamp: latestBlockTimestamp } = await this.client.getBlock({
|
|
701
|
+
blockTag: 'latest',
|
|
702
|
+
includeTransactions: false,
|
|
703
|
+
}));
|
|
704
|
+
|
|
696
705
|
const currentNonce = await this.client.getTransactionCount({ address: account.address });
|
|
697
706
|
if (currentNonce > nonce) {
|
|
698
707
|
for (const hash of txHashes) {
|
|
@@ -714,6 +723,16 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
714
723
|
}
|
|
715
724
|
}
|
|
716
725
|
|
|
726
|
+
this.logger?.trace(`Tx timeout check for ${currentTxHash}: ${isTimedOut()}`, {
|
|
727
|
+
latestBlockTimestamp: Number(latestBlockTimestamp) * 1000,
|
|
728
|
+
lastAttemptSent,
|
|
729
|
+
initialTxTime,
|
|
730
|
+
now: this.dateProvider.now(),
|
|
731
|
+
txTimeoutAt: gasConfig.txTimeoutAt?.getTime(),
|
|
732
|
+
txTimeoutMs: gasConfig.txTimeoutMs,
|
|
733
|
+
txStallTime: gasConfig.stallTimeMs,
|
|
734
|
+
});
|
|
735
|
+
|
|
717
736
|
// Retry a few times, in case the tx is not yet propagated.
|
|
718
737
|
const tx = await retry<GetTransactionReturnType>(
|
|
719
738
|
() => this.client.getTransaction({ hash: currentTxHash }),
|
|
@@ -722,7 +741,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
722
741
|
this.logger,
|
|
723
742
|
true,
|
|
724
743
|
);
|
|
725
|
-
const timePassed =
|
|
744
|
+
const timePassed = this.dateProvider.now() - lastAttemptSent;
|
|
726
745
|
|
|
727
746
|
if (tx && timePassed < gasConfig.stallTimeMs!) {
|
|
728
747
|
this.logger?.debug(`L1 transaction ${currentTxHash} pending. Time passed: ${timePassed}ms.`);
|
|
@@ -784,7 +803,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
784
803
|
currentTxHash = newHash;
|
|
785
804
|
|
|
786
805
|
txHashes.add(currentTxHash);
|
|
787
|
-
lastAttemptSent =
|
|
806
|
+
lastAttemptSent = this.dateProvider.now();
|
|
788
807
|
}
|
|
789
808
|
await sleep(gasConfig.checkIntervalMs!);
|
|
790
809
|
} catch (err: any) {
|
|
@@ -807,12 +826,19 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
807
826
|
metaMessages: viemError.metaMessages,
|
|
808
827
|
});
|
|
809
828
|
});
|
|
810
|
-
|
|
811
|
-
this.logger?.error(`L1 transaction ${currentTxHash} timed out`, {
|
|
812
|
-
txHash: currentTxHash,
|
|
813
|
-
...tx,
|
|
814
|
-
});
|
|
815
829
|
}
|
|
830
|
+
|
|
831
|
+
this.logger?.error(`L1 transaction ${currentTxHash} timed out`, {
|
|
832
|
+
txHash: currentTxHash,
|
|
833
|
+
txTimeoutAt: gasConfig.txTimeoutAt,
|
|
834
|
+
txTimeoutMs: gasConfig.txTimeoutMs,
|
|
835
|
+
txInitialTime: initialTxTime,
|
|
836
|
+
now: this.dateProvider.now(),
|
|
837
|
+
attempts,
|
|
838
|
+
isInterrupted: this.interrupted,
|
|
839
|
+
...tx,
|
|
840
|
+
});
|
|
841
|
+
|
|
816
842
|
throw new Error(`L1 transaction ${currentTxHash} timed out`);
|
|
817
843
|
}
|
|
818
844
|
|
package/src/queries.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { getContract } from 'viem';
|
|
5
5
|
|
|
6
6
|
import type { L1ContractsConfig } from './config.js';
|
|
7
7
|
import { ReadOnlyGovernanceContract } from './contracts/governance.js';
|
|
@@ -27,6 +27,8 @@ export async function getL1ContractsConfig(
|
|
|
27
27
|
const rollupAddress = addresses.rollupAddress ?? (await governanceProposer.getRollupAddress());
|
|
28
28
|
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
29
29
|
const slasherProposer = await rollup.getSlashingProposer();
|
|
30
|
+
const slasherAddress = await rollup.getSlasher();
|
|
31
|
+
const slasher = getContract({ address: slasherAddress, abi: SlasherAbi, client: publicClient });
|
|
30
32
|
|
|
31
33
|
const [
|
|
32
34
|
l1StartBlock,
|
|
@@ -35,12 +37,15 @@ export async function getL1ContractsConfig(
|
|
|
35
37
|
aztecSlotDuration,
|
|
36
38
|
aztecProofSubmissionEpochs,
|
|
37
39
|
aztecTargetCommitteeSize,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
activationThreshold,
|
|
41
|
+
ejectionThreshold,
|
|
40
42
|
governanceProposerQuorum,
|
|
41
43
|
governanceProposerRoundSize,
|
|
42
44
|
slashingQuorum,
|
|
43
45
|
slashingRoundSize,
|
|
46
|
+
slashingLifetimeInRounds,
|
|
47
|
+
slashingExecutionDelayInRounds,
|
|
48
|
+
slashingVetoer,
|
|
44
49
|
manaTarget,
|
|
45
50
|
provingCostPerMana,
|
|
46
51
|
rollupVersion,
|
|
@@ -53,12 +58,15 @@ export async function getL1ContractsConfig(
|
|
|
53
58
|
rollup.getSlotDuration(),
|
|
54
59
|
rollup.getProofSubmissionEpochs(),
|
|
55
60
|
rollup.getTargetCommitteeSize(),
|
|
56
|
-
rollup.
|
|
57
|
-
rollup.
|
|
61
|
+
rollup.getActivationThreshold(),
|
|
62
|
+
rollup.getEjectionThreshold(),
|
|
58
63
|
governanceProposer.getQuorumSize(),
|
|
59
64
|
governanceProposer.getRoundSize(),
|
|
60
65
|
slasherProposer.getQuorumSize(),
|
|
61
66
|
slasherProposer.getRoundSize(),
|
|
67
|
+
slasherProposer.getLifetimeInRounds(),
|
|
68
|
+
slasherProposer.getExecutionDelayInRounds(),
|
|
69
|
+
slasher.read.VETOER(),
|
|
62
70
|
rollup.getManaTarget(),
|
|
63
71
|
rollup.getProvingCostPerMana(),
|
|
64
72
|
rollup.getVersion(),
|
|
@@ -75,10 +83,13 @@ export async function getL1ContractsConfig(
|
|
|
75
83
|
aztecTargetCommitteeSize: Number(aztecTargetCommitteeSize),
|
|
76
84
|
governanceProposerQuorum: Number(governanceProposerQuorum),
|
|
77
85
|
governanceProposerRoundSize: Number(governanceProposerRoundSize),
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
activationThreshold,
|
|
87
|
+
ejectionThreshold,
|
|
80
88
|
slashingQuorum: Number(slashingQuorum),
|
|
81
89
|
slashingRoundSize: Number(slashingRoundSize),
|
|
90
|
+
slashingLifetimeInRounds: Number(slashingLifetimeInRounds),
|
|
91
|
+
slashingExecutionDelayInRounds: Number(slashingExecutionDelayInRounds),
|
|
92
|
+
slashingVetoer: EthAddress.fromString(slashingVetoer),
|
|
82
93
|
manaTarget: manaTarget,
|
|
83
94
|
provingCostPerMana: provingCostPerMana,
|
|
84
95
|
rollupVersion: Number(rollupVersion),
|
|
@@ -86,25 +97,3 @@ export async function getL1ContractsConfig(
|
|
|
86
97
|
exitDelaySeconds: Number(exitDelay),
|
|
87
98
|
};
|
|
88
99
|
}
|
|
89
|
-
|
|
90
|
-
export type L2BlockProposedEvent = {
|
|
91
|
-
versionedBlobHashes: readonly Hex[];
|
|
92
|
-
archive: Hex;
|
|
93
|
-
blockNumber: bigint;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export async function getL2BlockProposalEvents(
|
|
97
|
-
client: ViemPublicClient,
|
|
98
|
-
blockId: Hex,
|
|
99
|
-
rollupAddress?: EthAddress,
|
|
100
|
-
): Promise<L2BlockProposedEvent[]> {
|
|
101
|
-
return (
|
|
102
|
-
await client.getContractEvents({
|
|
103
|
-
abi: RollupAbi,
|
|
104
|
-
address: rollupAddress?.toString(),
|
|
105
|
-
blockHash: blockId,
|
|
106
|
-
eventName: 'L2BlockProposed',
|
|
107
|
-
strict: true,
|
|
108
|
-
})
|
|
109
|
-
).map(log => log.args);
|
|
110
|
-
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { InboxContract, type RollupContract } from '@aztec/ethereum/contracts';
|
|
2
2
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
3
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
4
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
|
|
5
6
|
import { EventEmitter } from 'events';
|
|
6
7
|
|
|
@@ -18,6 +19,7 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
18
19
|
private readonly l1Client: ViemClient;
|
|
19
20
|
private inbox: InboxContract | undefined;
|
|
20
21
|
private handle: NodeJS.Timeout | undefined;
|
|
22
|
+
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
21
23
|
private running: Set<Promise<void>> = new Set();
|
|
22
24
|
|
|
23
25
|
/** Current L1 block number */
|
|
@@ -35,7 +37,8 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
35
37
|
|
|
36
38
|
constructor(
|
|
37
39
|
private readonly rollup: RollupContract,
|
|
38
|
-
private
|
|
40
|
+
private readonly dateProvider: DateProvider = new DateProvider(),
|
|
41
|
+
private readonly logger = createLogger('aztecjs:utils:chain_monitor'),
|
|
39
42
|
private readonly intervalMs = 200,
|
|
40
43
|
) {
|
|
41
44
|
super();
|
|
@@ -129,10 +132,14 @@ export class ChainMonitor extends EventEmitter<ChainMonitorEventMap> {
|
|
|
129
132
|
this.emit('l2-messages', { totalL2Messages: newTotalL2Messages, l1BlockNumber: newL1BlockNumber });
|
|
130
133
|
}
|
|
131
134
|
|
|
135
|
+
const [l2SlotNumber, l2Epoch] = await Promise.all([this.rollup.getSlotNumber(), this.rollup.getCurrentEpoch()]);
|
|
136
|
+
|
|
132
137
|
this.logger.info(msg, {
|
|
138
|
+
currentTimestamp: this.dateProvider.nowInSeconds(),
|
|
133
139
|
l1Timestamp: timestamp,
|
|
134
140
|
l1BlockNumber: this.l1BlockNumber,
|
|
135
|
-
l2SlotNumber
|
|
141
|
+
l2SlotNumber,
|
|
142
|
+
l2Epoch,
|
|
136
143
|
l2BlockNumber: this.l2BlockNumber,
|
|
137
144
|
l2ProvenBlockNumber: this.l2ProvenBlockNumber,
|
|
138
145
|
totalL2Messages: this.totalL2Messages,
|
|
@@ -5,7 +5,7 @@ export class DelayedTxUtils extends L1TxUtilsWithBlobs {
|
|
|
5
5
|
public delayer: Delayer | undefined;
|
|
6
6
|
|
|
7
7
|
public static fromL1TxUtils(l1TxUtils: L1TxUtilsWithBlobs, ethereumSlotDuration: number) {
|
|
8
|
-
const { client, delayer } = withDelayer(l1TxUtils.client, {
|
|
8
|
+
const { client, delayer } = withDelayer(l1TxUtils.client, l1TxUtils.dateProvider, {
|
|
9
9
|
ethereumSlotDuration,
|
|
10
10
|
});
|
|
11
11
|
const casted = l1TxUtils as unknown as DelayedTxUtils;
|
|
@@ -15,7 +15,7 @@ export class DelayedTxUtils extends L1TxUtilsWithBlobs {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
public enableDelayer(ethereumSlotDuration: number) {
|
|
18
|
-
const { client, delayer } = withDelayer(this.client, {
|
|
18
|
+
const { client, delayer } = withDelayer(this.client, this.dateProvider, {
|
|
19
19
|
ethereumSlotDuration,
|
|
20
20
|
});
|
|
21
21
|
this.delayer = delayer;
|
|
@@ -7,7 +7,7 @@ import type { TestDateProvider } from '@aztec/foundation/timer';
|
|
|
7
7
|
|
|
8
8
|
import { type Hex, createPublicClient, fallback, http } from 'viem';
|
|
9
9
|
|
|
10
|
-
import type { ViemPublicClient } from '
|
|
10
|
+
import type { ViemPublicClient } from '../types.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* A class that provides utility functions for interacting with ethereum (L1).
|
|
@@ -163,26 +163,30 @@ export class EthCheatCodes {
|
|
|
163
163
|
* Enable interval mining at the given interval (block time)
|
|
164
164
|
* @param seconds - The interval to use between blocks
|
|
165
165
|
*/
|
|
166
|
-
public async setIntervalMining(seconds: number): Promise<void> {
|
|
166
|
+
public async setIntervalMining(seconds: number, opts: { silent?: boolean } = {}): Promise<void> {
|
|
167
167
|
try {
|
|
168
168
|
await this.rpcCall('anvil_setIntervalMining', [seconds]);
|
|
169
169
|
} catch (err) {
|
|
170
170
|
throw new Error(`Error setting interval mining: ${err}`);
|
|
171
171
|
}
|
|
172
|
-
|
|
172
|
+
if (!opts.silent) {
|
|
173
|
+
this.logger.warn(`Set L1 interval mining to ${seconds} seconds`);
|
|
174
|
+
}
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
/**
|
|
176
178
|
* Set the automine status of the underlying anvil chain
|
|
177
179
|
* @param automine - The automine status to set
|
|
178
180
|
*/
|
|
179
|
-
public async setAutomine(automine: boolean): Promise<void> {
|
|
181
|
+
public async setAutomine(automine: boolean, opts: { silent?: boolean } = {}): Promise<void> {
|
|
180
182
|
try {
|
|
181
183
|
await this.rpcCall('anvil_setAutomine', [automine]);
|
|
182
184
|
} catch (err) {
|
|
183
185
|
throw new Error(`Error setting automine: ${err}`);
|
|
184
186
|
}
|
|
185
|
-
|
|
187
|
+
if (!opts.silent) {
|
|
188
|
+
this.logger.warn(`Set L1 automine to ${automine}`);
|
|
189
|
+
}
|
|
186
190
|
}
|
|
187
191
|
|
|
188
192
|
/**
|
|
@@ -202,9 +206,11 @@ export class EthCheatCodes {
|
|
|
202
206
|
* Set the next block timestamp
|
|
203
207
|
* @param timestamp - The timestamp to set the next block to
|
|
204
208
|
*/
|
|
205
|
-
public async setNextBlockTimestamp(timestamp: number): Promise<void> {
|
|
209
|
+
public async setNextBlockTimestamp(timestamp: number | Date): Promise<void> {
|
|
206
210
|
try {
|
|
207
|
-
await this.rpcCall('evm_setNextBlockTimestamp', [
|
|
211
|
+
await this.rpcCall('evm_setNextBlockTimestamp', [
|
|
212
|
+
timestamp instanceof Date ? Math.floor(timestamp.getTime() / 1000) : timestamp,
|
|
213
|
+
]);
|
|
208
214
|
} catch (err: any) {
|
|
209
215
|
throw new Error(`Error setting next block timestamp: ${err.message}`);
|
|
210
216
|
}
|
|
@@ -227,7 +233,7 @@ export class EthCheatCodes {
|
|
|
227
233
|
if (opts.resetBlockInterval) {
|
|
228
234
|
blockInterval = await this.getIntervalMining();
|
|
229
235
|
if (blockInterval !== null) {
|
|
230
|
-
await this.setIntervalMining(0);
|
|
236
|
+
await this.setIntervalMining(0, { silent: true });
|
|
231
237
|
}
|
|
232
238
|
}
|
|
233
239
|
// Set the timestamp of the next block to be mined
|
|
@@ -241,7 +247,7 @@ export class EthCheatCodes {
|
|
|
241
247
|
} finally {
|
|
242
248
|
// Restore interval mining so the next block is mined in `blockInterval` seconds from this one
|
|
243
249
|
if (opts.resetBlockInterval && blockInterval !== null && blockInterval > 0) {
|
|
244
|
-
await this.setIntervalMining(blockInterval);
|
|
250
|
+
await this.setIntervalMining(blockInterval, { silent: true });
|
|
245
251
|
}
|
|
246
252
|
}
|
|
247
253
|
if (!opts.silent) {
|
|
@@ -418,15 +424,15 @@ export class EthCheatCodes {
|
|
|
418
424
|
return this.rpcCall('trace_transaction', [txHash]);
|
|
419
425
|
}
|
|
420
426
|
|
|
421
|
-
|
|
427
|
+
public async execWithPausedAnvil(fn: () => Promise<void>): Promise<void> {
|
|
422
428
|
const [blockInterval, wasAutoMining] = await Promise.all([this.getIntervalMining(), this.isAutoMining()]);
|
|
423
429
|
try {
|
|
424
430
|
if (blockInterval !== null) {
|
|
425
|
-
await this.setIntervalMining(0);
|
|
431
|
+
await this.setIntervalMining(0, { silent: true });
|
|
426
432
|
}
|
|
427
433
|
|
|
428
434
|
if (wasAutoMining) {
|
|
429
|
-
await this.setAutomine(false);
|
|
435
|
+
await this.setAutomine(false, { silent: true });
|
|
430
436
|
}
|
|
431
437
|
|
|
432
438
|
await fn();
|
|
@@ -434,7 +440,7 @@ export class EthCheatCodes {
|
|
|
434
440
|
try {
|
|
435
441
|
// restore automine if necessary
|
|
436
442
|
if (wasAutoMining) {
|
|
437
|
-
await this.setAutomine(true);
|
|
443
|
+
await this.setAutomine(true, { silent: true });
|
|
438
444
|
}
|
|
439
445
|
} catch (err) {
|
|
440
446
|
this.logger.warn(`Failed to reenable automining: ${err}`);
|
|
@@ -443,7 +449,7 @@ export class EthCheatCodes {
|
|
|
443
449
|
try {
|
|
444
450
|
// restore automine if necessary
|
|
445
451
|
if (blockInterval !== null) {
|
|
446
|
-
await this.setIntervalMining(blockInterval);
|
|
452
|
+
await this.setIntervalMining(blockInterval, { silent: true });
|
|
447
453
|
}
|
|
448
454
|
} catch (err) {
|
|
449
455
|
this.logger.warn(`Failed to reenable interval mining: ${err}`);
|
package/src/test/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './delayed_tx_utils.js';
|
|
2
|
+
export * from './eth_cheat_codes.js';
|
|
2
3
|
export * from './eth_cheat_codes_with_state.js';
|
|
3
4
|
export * from './start_anvil.js';
|
|
4
5
|
export * from './tx_delayer.js';
|
|
5
6
|
export * from './upgrade_utils.js';
|
|
6
7
|
export * from './chain_monitor.js';
|
|
8
|
+
export * from './rollup_cheat_codes.js';
|