@aztec/ethereum 1.2.0 → 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
|
@@ -8,6 +8,7 @@ export declare class RegistryContract {
|
|
|
8
8
|
private readonly log;
|
|
9
9
|
private readonly registry;
|
|
10
10
|
constructor(client: ViemClient, address: Hex | EthAddress);
|
|
11
|
+
getOwner(): Promise<EthAddress>;
|
|
11
12
|
/**
|
|
12
13
|
* Returns the address of the rollup for a given version.
|
|
13
14
|
* @param version - The version of the rollup. 'canonical' can be used to get the canonical address (i.e. the latest version).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/contracts/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAK3D,OAAO,EAA8B,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,qBAAa,gBAAgB;aAOT,MAAM,EAAE,UAAU;IAN7B,OAAO,EAAE,UAAU,CAAC;IAE3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA+C;IACnE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwD;gBAG/D,MAAM,EAAE,UAAU,EAClC,OAAO,EAAE,G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24
|
});
|
|
25
25
|
}
|
|
26
|
+
async getOwner() {
|
|
27
|
+
return EthAddress.fromString(await this.registry.read.owner());
|
|
28
|
+
}
|
|
26
29
|
/**
|
|
27
30
|
* Returns the address of the rollup for a given version.
|
|
28
31
|
* @param version - The version of the rollup. 'canonical' can be used to get the canonical address (i.e. the latest version).
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { ViemSignature } from '@aztec/foundation/eth-signature';
|
|
3
3
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
4
|
-
import { type Account, type GetContractReturnType, type Hex } from 'viem';
|
|
4
|
+
import { type Account, type GetContractReturnType, type Hex, type StateOverride } from 'viem';
|
|
5
5
|
import type { DeployL1ContractsReturnType } from '../deploy_l1_contracts.js';
|
|
6
6
|
import type { L1ContractAddresses } from '../l1_contract_addresses.js';
|
|
7
7
|
import type { L1ReaderConfig } from '../l1_reader.js';
|
|
8
|
-
import type { L1TxUtils } from '../l1_tx_utils.js';
|
|
8
|
+
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
|
|
9
9
|
import type { ViemClient } from '../types.js';
|
|
10
10
|
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
11
11
|
export type ViemCommitteeAttestation = {
|
|
@@ -57,7 +57,9 @@ export type ViemAppendOnlyTreeSnapshot = {
|
|
|
57
57
|
export declare class RollupContract {
|
|
58
58
|
readonly client: ViemClient;
|
|
59
59
|
private readonly rollup;
|
|
60
|
+
private static cachedStfStorageSlot;
|
|
60
61
|
static get checkBlobStorageSlot(): bigint;
|
|
62
|
+
static get stfStorageSlot(): Hex;
|
|
61
63
|
static getFromL1ContractsValues(deployL1ContractsValues: DeployL1ContractsReturnType): RollupContract;
|
|
62
64
|
static getFromConfig(config: L1ReaderConfig): RollupContract;
|
|
63
65
|
constructor(client: ViemClient, address: Hex | EthAddress);
|
|
@@ -71,8 +73,8 @@ export declare class RollupContract {
|
|
|
71
73
|
getEpochDuration(): Promise<bigint>;
|
|
72
74
|
getSlotDuration(): Promise<bigint>;
|
|
73
75
|
getTargetCommitteeSize(): Promise<bigint>;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
getEjectionThreshold(): Promise<bigint>;
|
|
77
|
+
getActivationThreshold(): Promise<bigint>;
|
|
76
78
|
getExitDelay(): Promise<bigint>;
|
|
77
79
|
getManaTarget(): Promise<bigint>;
|
|
78
80
|
getProvingCostPerMana(): Promise<bigint>;
|
|
@@ -81,7 +83,9 @@ export declare class RollupContract {
|
|
|
81
83
|
getVersion(): Promise<bigint>;
|
|
82
84
|
getGenesisArchiveTreeRoot(): Promise<`0x${string}`>;
|
|
83
85
|
getSlasher(): Promise<`0x${string}`>;
|
|
86
|
+
getOwner(): Promise<`0x${string}`>;
|
|
84
87
|
getSlashingProposerAddress(): Promise<EthAddress>;
|
|
88
|
+
getBlockReward(): Promise<bigint>;
|
|
85
89
|
getBlockNumber(): Promise<bigint>;
|
|
86
90
|
getProvenBlockNumber(): Promise<bigint>;
|
|
87
91
|
getSlotNumber(): Promise<bigint>;
|
|
@@ -101,7 +105,16 @@ export declare class RollupContract {
|
|
|
101
105
|
archive: `0x${string}`;
|
|
102
106
|
headerHash: `0x${string}`;
|
|
103
107
|
blobCommitmentsHash: `0x${string}`;
|
|
108
|
+
attestationsHash: `0x${string}`;
|
|
109
|
+
payloadDigest: `0x${string}`;
|
|
104
110
|
slotNumber: bigint;
|
|
111
|
+
feeHeader: {
|
|
112
|
+
excessMana: bigint;
|
|
113
|
+
manaUsed: bigint;
|
|
114
|
+
feeAssetPriceNumerator: bigint;
|
|
115
|
+
congestionCost: bigint;
|
|
116
|
+
proverCost: bigint;
|
|
117
|
+
};
|
|
105
118
|
}>;
|
|
106
119
|
getTips(): Promise<{
|
|
107
120
|
pendingBlockNumber: bigint;
|
|
@@ -116,6 +129,7 @@ export declare class RollupContract {
|
|
|
116
129
|
validateHeader(args: readonly [
|
|
117
130
|
ViemHeader,
|
|
118
131
|
ViemCommitteeAttestations,
|
|
132
|
+
`0x${string}`[],
|
|
119
133
|
`0x${string}`,
|
|
120
134
|
`0x${string}`,
|
|
121
135
|
{
|
|
@@ -139,11 +153,23 @@ export declare class RollupContract {
|
|
|
139
153
|
* @return [slot, blockNumber] - If you can propose, the L2 slot number and L2 block number of the next Ethereum block,
|
|
140
154
|
* @throws otherwise
|
|
141
155
|
*/
|
|
142
|
-
canProposeAtNextEthBlock(archive: Buffer, account: `0x${string}` | Account, slotDuration: bigint | number
|
|
156
|
+
canProposeAtNextEthBlock(archive: Buffer, account: `0x${string}` | Account, slotDuration: bigint | number, opts?: {
|
|
157
|
+
forcePendingBlockNumber?: number;
|
|
158
|
+
}): Promise<{
|
|
143
159
|
slot: bigint;
|
|
144
160
|
blockNumber: bigint;
|
|
145
161
|
timeOfNextL1Slot: bigint;
|
|
146
162
|
}>;
|
|
163
|
+
/**
|
|
164
|
+
* Returns a state override that sets the pending block number to the specified value. Useful for simulations.
|
|
165
|
+
* Requires querying the current state of the contract to get the current proven block number, as they are both
|
|
166
|
+
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
167
|
+
*/
|
|
168
|
+
makePendingBlockNumberOverride(forcePendingBlockNumber: number | undefined): Promise<StateOverride>;
|
|
169
|
+
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */
|
|
170
|
+
buildInvalidateBadAttestationRequest(blockNumber: number, attestations: ViemCommitteeAttestation[], committee: EthAddress[], invalidIndex: number): L1TxRequest;
|
|
171
|
+
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */
|
|
172
|
+
buildInvalidateInsufficientAttestationsRequest(blockNumber: number, attestations: ViemCommitteeAttestation[], committee: EthAddress[]): L1TxRequest;
|
|
147
173
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */
|
|
148
174
|
getHasSubmittedProof(epochNumber: number, numberOfBlocksInEpoch: number, prover: Hex | EthAddress): Promise<boolean>;
|
|
149
175
|
getManaBaseFeeAt(timestamp: bigint, inFeeAsset: boolean): Promise<bigint>;
|
|
@@ -171,6 +197,10 @@ export declare class RollupContract {
|
|
|
171
197
|
exists: boolean;
|
|
172
198
|
};
|
|
173
199
|
config: {
|
|
200
|
+
publicKey: {
|
|
201
|
+
x: bigint;
|
|
202
|
+
y: bigint;
|
|
203
|
+
};
|
|
174
204
|
withdrawer: `0x${string}`;
|
|
175
205
|
};
|
|
176
206
|
}>;
|
|
@@ -186,5 +216,9 @@ export declare class RollupContract {
|
|
|
186
216
|
receipt: import("viem").TransactionReceipt;
|
|
187
217
|
gasPrice: import("../l1_tx_utils.js").GasPrice;
|
|
188
218
|
}>;
|
|
219
|
+
listenToSlasherChanged(callback: (args: {
|
|
220
|
+
oldSlasher: `0x${string}`;
|
|
221
|
+
newSlasher: `0x${string}`;
|
|
222
|
+
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
189
223
|
}
|
|
190
224
|
//# sourceMappingURL=rollup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/contracts/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI1D,OAAO,
|
|
1
|
+
{"version":3,"file":"rollup.d.ts","sourceRoot":"","sources":["../../src/contracts/rollup.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAI1D,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAC1B,KAAK,GAAG,EACR,KAAK,aAAa,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,MAAM;IAIrB,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAK9D,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE;IAK1E,OAAO;IAIP,SAAS,CAAC,WAAW,EAAE,MAAM;IAI7B,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,UAAU;IAO7C,gCAAgC,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,UAAU;IAOxE,YAAY;IAIZ,eAAe,CAAC,OAAO,EAAE,GAAG,GAAG,UAAU;;;;;;;;;;;;;;;;;;;IAOzC,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG,UAAU;IAOnC,sBAAsB,CAAC,WAAW,EAAE,MAAM;IAI1C,6BAA6B;IAI7B,eAAe;IAIf,UAAU,CAAC,SAAS,EAAE,SAAS;;;;IAW/B,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM;;;;IAWtC,sBAAsB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO;CAepH"}
|
package/dest/contracts/rollup.js
CHANGED
|
@@ -9,7 +9,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
9
9
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
10
10
|
import { RollupStorage } from '@aztec/l1-artifacts/RollupStorage';
|
|
11
11
|
import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
|
|
12
|
-
import { encodeFunctionData, getAddress, getContract } from 'viem';
|
|
12
|
+
import { encodeFunctionData, getAddress, getContract, hexToBigInt, keccak256 } from 'viem';
|
|
13
13
|
import { getPublicClient } from '../client.js';
|
|
14
14
|
import { formatViemError } from '../utils.js';
|
|
15
15
|
import { SlashingProposerContract } from './slashing_proposer.js';
|
|
@@ -17,6 +17,7 @@ import { checkBlockTag } from './utils.js';
|
|
|
17
17
|
export class RollupContract {
|
|
18
18
|
client;
|
|
19
19
|
rollup;
|
|
20
|
+
static cachedStfStorageSlot;
|
|
20
21
|
static get checkBlobStorageSlot() {
|
|
21
22
|
const asString = RollupStorage.find((storage)=>storage.label === 'checkBlob')?.slot;
|
|
22
23
|
if (asString === undefined) {
|
|
@@ -24,6 +25,9 @@ export class RollupContract {
|
|
|
24
25
|
}
|
|
25
26
|
return BigInt(asString);
|
|
26
27
|
}
|
|
28
|
+
static get stfStorageSlot() {
|
|
29
|
+
return RollupContract.cachedStfStorageSlot ??= keccak256(Buffer.from('aztec.stf.storage', 'utf-8'));
|
|
30
|
+
}
|
|
27
31
|
static getFromL1ContractsValues(deployL1ContractsValues) {
|
|
28
32
|
const { l1Client, l1ContractAddresses: { rollupAddress } } = deployL1ContractsValues;
|
|
29
33
|
return new RollupContract(l1Client, rollupAddress.toString());
|
|
@@ -81,11 +85,11 @@ export class RollupContract {
|
|
|
81
85
|
getTargetCommitteeSize() {
|
|
82
86
|
return this.rollup.read.getTargetCommitteeSize();
|
|
83
87
|
}
|
|
84
|
-
|
|
85
|
-
return this.rollup.read.
|
|
88
|
+
getEjectionThreshold() {
|
|
89
|
+
return this.rollup.read.getEjectionThreshold();
|
|
86
90
|
}
|
|
87
|
-
|
|
88
|
-
return this.rollup.read.
|
|
91
|
+
getActivationThreshold() {
|
|
92
|
+
return this.rollup.read.getActivationThreshold();
|
|
89
93
|
}
|
|
90
94
|
getExitDelay() {
|
|
91
95
|
return this.rollup.read.getExitDelay();
|
|
@@ -114,6 +118,9 @@ export class RollupContract {
|
|
|
114
118
|
getSlasher() {
|
|
115
119
|
return this.rollup.read.getSlasher();
|
|
116
120
|
}
|
|
121
|
+
getOwner() {
|
|
122
|
+
return this.rollup.read.owner();
|
|
123
|
+
}
|
|
117
124
|
async getSlashingProposerAddress() {
|
|
118
125
|
const slasherAddress = await this.getSlasher();
|
|
119
126
|
const slasher = getContract({
|
|
@@ -123,6 +130,9 @@ export class RollupContract {
|
|
|
123
130
|
});
|
|
124
131
|
return EthAddress.fromString(await slasher.read.PROPOSER());
|
|
125
132
|
}
|
|
133
|
+
getBlockReward() {
|
|
134
|
+
return this.rollup.read.getBlockReward();
|
|
135
|
+
}
|
|
126
136
|
getBlockNumber() {
|
|
127
137
|
return this.rollup.read.getPendingBlockNumber();
|
|
128
138
|
}
|
|
@@ -261,7 +271,7 @@ export class RollupContract {
|
|
|
261
271
|
await this.client.simulateContract({
|
|
262
272
|
address: this.address,
|
|
263
273
|
abi: RollupAbi,
|
|
264
|
-
functionName: '
|
|
274
|
+
functionName: 'validateHeaderWithAttestations',
|
|
265
275
|
args,
|
|
266
276
|
account
|
|
267
277
|
});
|
|
@@ -335,12 +345,13 @@ export class RollupContract {
|
|
|
335
345
|
* @param archive - The archive that we expect to be current state
|
|
336
346
|
* @return [slot, blockNumber] - If you can propose, the L2 slot number and L2 block number of the next Ethereum block,
|
|
337
347
|
* @throws otherwise
|
|
338
|
-
*/ async canProposeAtNextEthBlock(archive, account, slotDuration) {
|
|
348
|
+
*/ async canProposeAtNextEthBlock(archive, account, slotDuration, opts = {}) {
|
|
339
349
|
if (typeof slotDuration === 'number') {
|
|
340
350
|
slotDuration = BigInt(slotDuration);
|
|
341
351
|
}
|
|
342
352
|
const latestBlock = await this.client.getBlock();
|
|
343
353
|
const timeOfNextL1Slot = latestBlock.timestamp + slotDuration;
|
|
354
|
+
const who = typeof account === 'string' ? account : account.address;
|
|
344
355
|
try {
|
|
345
356
|
const { result: [slot, blockNumber] } = await this.client.simulateContract({
|
|
346
357
|
address: this.address,
|
|
@@ -348,9 +359,11 @@ export class RollupContract {
|
|
|
348
359
|
functionName: 'canProposeAtTime',
|
|
349
360
|
args: [
|
|
350
361
|
timeOfNextL1Slot,
|
|
351
|
-
`0x${archive.toString('hex')}
|
|
362
|
+
`0x${archive.toString('hex')}`,
|
|
363
|
+
who
|
|
352
364
|
],
|
|
353
|
-
account
|
|
365
|
+
account,
|
|
366
|
+
stateOverride: await this.makePendingBlockNumberOverride(opts.forcePendingBlockNumber)
|
|
354
367
|
});
|
|
355
368
|
return {
|
|
356
369
|
slot,
|
|
@@ -361,6 +374,62 @@ export class RollupContract {
|
|
|
361
374
|
throw formatViemError(err);
|
|
362
375
|
}
|
|
363
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* Returns a state override that sets the pending block number to the specified value. Useful for simulations.
|
|
379
|
+
* Requires querying the current state of the contract to get the current proven block number, as they are both
|
|
380
|
+
* stored in the same slot. If the argument is undefined, it returns an empty override.
|
|
381
|
+
*/ async makePendingBlockNumberOverride(forcePendingBlockNumber) {
|
|
382
|
+
if (forcePendingBlockNumber === undefined) {
|
|
383
|
+
return [];
|
|
384
|
+
}
|
|
385
|
+
const slot = RollupContract.stfStorageSlot;
|
|
386
|
+
const currentValue = await this.client.getStorageAt({
|
|
387
|
+
address: this.address,
|
|
388
|
+
slot
|
|
389
|
+
});
|
|
390
|
+
const currentProvenBlockNumber = currentValue ? hexToBigInt(currentValue) & (1n << 128n) - 1n : 0n;
|
|
391
|
+
const newValue = BigInt(forcePendingBlockNumber) << 128n | currentProvenBlockNumber;
|
|
392
|
+
return [
|
|
393
|
+
{
|
|
394
|
+
address: this.address,
|
|
395
|
+
stateDiff: [
|
|
396
|
+
{
|
|
397
|
+
slot,
|
|
398
|
+
value: `0x${newValue.toString(16).padStart(64, '0')}`
|
|
399
|
+
}
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
];
|
|
403
|
+
}
|
|
404
|
+
/** Creates a request to Rollup#invalidateBadAttestation to be simulated or sent */ buildInvalidateBadAttestationRequest(blockNumber, attestations, committee, invalidIndex) {
|
|
405
|
+
return {
|
|
406
|
+
to: this.address,
|
|
407
|
+
data: encodeFunctionData({
|
|
408
|
+
abi: RollupAbi,
|
|
409
|
+
functionName: 'invalidateBadAttestation',
|
|
410
|
+
args: [
|
|
411
|
+
BigInt(blockNumber),
|
|
412
|
+
RollupContract.packAttestations(attestations),
|
|
413
|
+
committee.map((addr)=>addr.toString()),
|
|
414
|
+
BigInt(invalidIndex)
|
|
415
|
+
]
|
|
416
|
+
})
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
/** Creates a request to Rollup#invalidateInsufficientAttestations to be simulated or sent */ buildInvalidateInsufficientAttestationsRequest(blockNumber, attestations, committee) {
|
|
420
|
+
return {
|
|
421
|
+
to: this.address,
|
|
422
|
+
data: encodeFunctionData({
|
|
423
|
+
abi: RollupAbi,
|
|
424
|
+
functionName: 'invalidateInsufficientAttestations',
|
|
425
|
+
args: [
|
|
426
|
+
BigInt(blockNumber),
|
|
427
|
+
RollupContract.packAttestations(attestations),
|
|
428
|
+
committee.map((addr)=>addr.toString())
|
|
429
|
+
]
|
|
430
|
+
})
|
|
431
|
+
};
|
|
432
|
+
}
|
|
364
433
|
/** Calls getHasSubmitted directly. Returns whether the given prover has submitted a proof with the given length for the given epoch. */ getHasSubmittedProof(epochNumber, numberOfBlocksInEpoch, prover) {
|
|
365
434
|
if (prover instanceof EthAddress) {
|
|
366
435
|
prover = prover.toString();
|
|
@@ -471,10 +540,19 @@ export class RollupContract {
|
|
|
471
540
|
})
|
|
472
541
|
});
|
|
473
542
|
}
|
|
543
|
+
listenToSlasherChanged(callback) {
|
|
544
|
+
return this.rollup.watchEvent.SlasherUpdated({}, {
|
|
545
|
+
onLogs: (logs)=>{
|
|
546
|
+
for (const log of logs){
|
|
547
|
+
const args = log.args;
|
|
548
|
+
if (args.oldSlasher && args.newSlasher) {
|
|
549
|
+
callback(args);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
474
555
|
}
|
|
475
|
-
_ts_decorate([
|
|
476
|
-
memoize
|
|
477
|
-
], RollupContract.prototype, "getSlashingProposer", null);
|
|
478
556
|
_ts_decorate([
|
|
479
557
|
memoize
|
|
480
558
|
], RollupContract.prototype, "getL1StartBlock", null);
|
|
@@ -495,10 +573,10 @@ _ts_decorate([
|
|
|
495
573
|
], RollupContract.prototype, "getTargetCommitteeSize", null);
|
|
496
574
|
_ts_decorate([
|
|
497
575
|
memoize
|
|
498
|
-
], RollupContract.prototype, "
|
|
576
|
+
], RollupContract.prototype, "getEjectionThreshold", null);
|
|
499
577
|
_ts_decorate([
|
|
500
578
|
memoize
|
|
501
|
-
], RollupContract.prototype, "
|
|
579
|
+
], RollupContract.prototype, "getActivationThreshold", null);
|
|
502
580
|
_ts_decorate([
|
|
503
581
|
memoize
|
|
504
582
|
], RollupContract.prototype, "getExitDelay", null);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import EventEmitter from 'events';
|
|
3
|
-
import { type Hex } from 'viem';
|
|
3
|
+
import { type Hex, type TypedDataDefinition } from 'viem';
|
|
4
4
|
import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
|
|
5
5
|
import type { ViemClient } from '../types.js';
|
|
6
6
|
import { type IEmpireBase } from './empire_base.js';
|
|
@@ -9,29 +9,40 @@ export declare class ProposalAlreadyExecutedError extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
export declare class SlashingProposerContract extends EventEmitter implements IEmpireBase {
|
|
11
11
|
readonly client: ViemClient;
|
|
12
|
+
private readonly logger;
|
|
12
13
|
private readonly proposer;
|
|
13
14
|
constructor(client: ViemClient, address: Hex);
|
|
14
15
|
get address(): EthAddress;
|
|
15
16
|
getQuorumSize(): Promise<bigint>;
|
|
16
17
|
getRoundSize(): Promise<bigint>;
|
|
18
|
+
getLifetimeInRounds(): Promise<bigint>;
|
|
19
|
+
getExecutionDelayInRounds(): Promise<bigint>;
|
|
20
|
+
getCurrentRound(): Promise<bigint>;
|
|
17
21
|
computeRound(slot: bigint): Promise<bigint>;
|
|
18
22
|
getNonce(proposer: Hex): Promise<bigint>;
|
|
19
23
|
getRoundInfo(rollupAddress: Hex, round: bigint): Promise<{
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
lastSignalSlot: bigint;
|
|
25
|
+
payloadWithMostSignals: Hex;
|
|
22
26
|
executed: boolean;
|
|
23
27
|
}>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint>;
|
|
29
|
+
createSignalRequest(payload: Hex): L1TxRequest;
|
|
30
|
+
createSignalRequestWithSignature(payload: Hex, round: bigint, chainId: number, signerAddress: Hex, signer: (msg: TypedDataDefinition) => Promise<Hex>): Promise<L1TxRequest>;
|
|
31
|
+
listenToSubmittablePayloads(callback: (args: {
|
|
32
|
+
payload: `0x${string}`;
|
|
29
33
|
round: bigint;
|
|
30
34
|
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
31
|
-
|
|
35
|
+
listenToPayloadSubmitted(callback: (args: {
|
|
32
36
|
round: bigint;
|
|
33
|
-
|
|
37
|
+
payload: `0x${string}`;
|
|
34
38
|
}) => unknown): import("viem").WatchContractEventReturnType;
|
|
39
|
+
/**
|
|
40
|
+
* Wait for a round to be reached.
|
|
41
|
+
*
|
|
42
|
+
* @param round - The round to wait for.
|
|
43
|
+
* @param pollingIntervalSeconds - The interval in seconds to poll for the round.
|
|
44
|
+
* @returns True if the round was reached, false otherwise.
|
|
45
|
+
*/
|
|
35
46
|
waitForRound(round: bigint, pollingIntervalSeconds?: number): Promise<boolean>;
|
|
36
47
|
executeRound(txUtils: L1TxUtils, round: bigint | number): ReturnType<typeof txUtils.sendAndMonitorTransaction>;
|
|
37
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,U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AE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;IAInF,mBAAmB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW;IAOxC,gCAAgC,CAC3C,OAAO,EAAE,GAAG,EACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,GAAG,EAClB,MAAM,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,GAAG,CAAC,GACjD,OAAO,CAAC,WAAW,CAAC;IAShB,2BAA2B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;IAiBlG,wBAAwB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO;IAgBtG;;;;;;OAMG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAsB,GAAE,MAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAe3E,YAAY,CACvB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,MAAM,GAAG,MAAM,GACrB,UAAU,CAAC,OAAO,OAAO,CAAC,yBAAyB,CAAC;CAiDxD"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
3
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
3
4
|
import { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
|
|
4
5
|
import EventEmitter from 'events';
|
|
5
6
|
import { encodeFunctionData, getContract } from 'viem';
|
|
6
7
|
import { FormattedViemError } from '../utils.js';
|
|
7
|
-
import {
|
|
8
|
+
import { encodeSignal, encodeSignalWithSignature, signSignalWithSig } from './empire_base.js';
|
|
8
9
|
export class ProposalAlreadyExecutedError extends Error {
|
|
9
10
|
constructor(round){
|
|
10
11
|
super(`Proposal already executed: ${round}`);
|
|
@@ -12,9 +13,10 @@ export class ProposalAlreadyExecutedError extends Error {
|
|
|
12
13
|
}
|
|
13
14
|
export class SlashingProposerContract extends EventEmitter {
|
|
14
15
|
client;
|
|
16
|
+
logger;
|
|
15
17
|
proposer;
|
|
16
18
|
constructor(client, address){
|
|
17
|
-
super(), this.client = client;
|
|
19
|
+
super(), this.client = client, this.logger = createLogger('SlashingProposerContract');
|
|
18
20
|
this.proposer = getContract({
|
|
19
21
|
address,
|
|
20
22
|
abi: SlashingProposerAbi,
|
|
@@ -25,10 +27,19 @@ export class SlashingProposerContract extends EventEmitter {
|
|
|
25
27
|
return EthAddress.fromString(this.proposer.address);
|
|
26
28
|
}
|
|
27
29
|
getQuorumSize() {
|
|
28
|
-
return this.proposer.read.
|
|
30
|
+
return this.proposer.read.QUORUM_SIZE();
|
|
29
31
|
}
|
|
30
32
|
getRoundSize() {
|
|
31
|
-
return this.proposer.read.
|
|
33
|
+
return this.proposer.read.ROUND_SIZE();
|
|
34
|
+
}
|
|
35
|
+
getLifetimeInRounds() {
|
|
36
|
+
return this.proposer.read.LIFETIME_IN_ROUNDS();
|
|
37
|
+
}
|
|
38
|
+
getExecutionDelayInRounds() {
|
|
39
|
+
return this.proposer.read.EXECUTION_DELAY_IN_ROUNDS();
|
|
40
|
+
}
|
|
41
|
+
getCurrentRound() {
|
|
42
|
+
return this.proposer.read.getCurrentRound();
|
|
32
43
|
}
|
|
33
44
|
computeRound(slot) {
|
|
34
45
|
return this.proposer.read.computeRound([
|
|
@@ -46,33 +57,33 @@ export class SlashingProposerContract extends EventEmitter {
|
|
|
46
57
|
round
|
|
47
58
|
]);
|
|
48
59
|
}
|
|
49
|
-
|
|
50
|
-
return this.proposer.read.
|
|
60
|
+
getPayloadSignals(rollupAddress, round, payload) {
|
|
61
|
+
return this.proposer.read.signalCount([
|
|
51
62
|
rollupAddress,
|
|
52
63
|
round,
|
|
53
|
-
|
|
64
|
+
payload
|
|
54
65
|
]);
|
|
55
66
|
}
|
|
56
|
-
|
|
67
|
+
createSignalRequest(payload) {
|
|
57
68
|
return {
|
|
58
69
|
to: this.address.toString(),
|
|
59
|
-
data:
|
|
70
|
+
data: encodeSignal(payload)
|
|
60
71
|
};
|
|
61
72
|
}
|
|
62
|
-
async
|
|
73
|
+
async createSignalRequestWithSignature(payload, round, chainId, signerAddress, signer) {
|
|
63
74
|
const nonce = await this.getNonce(signerAddress);
|
|
64
|
-
const signature = await
|
|
75
|
+
const signature = await signSignalWithSig(signer, payload, nonce, round, this.address.toString(), chainId);
|
|
65
76
|
return {
|
|
66
77
|
to: this.address.toString(),
|
|
67
|
-
data:
|
|
78
|
+
data: encodeSignalWithSignature(payload, signature)
|
|
68
79
|
};
|
|
69
80
|
}
|
|
70
|
-
|
|
71
|
-
return this.proposer.watchEvent.
|
|
81
|
+
listenToSubmittablePayloads(callback) {
|
|
82
|
+
return this.proposer.watchEvent.PayloadSubmittable({}, {
|
|
72
83
|
onLogs: (logs)=>{
|
|
73
84
|
for (const payload of logs){
|
|
74
85
|
const args = payload.args;
|
|
75
|
-
if (args.
|
|
86
|
+
if (args.payload && args.round) {
|
|
76
87
|
// why compiler can't figure it out? no one knows
|
|
77
88
|
callback(args);
|
|
78
89
|
}
|
|
@@ -80,23 +91,32 @@ export class SlashingProposerContract extends EventEmitter {
|
|
|
80
91
|
}
|
|
81
92
|
});
|
|
82
93
|
}
|
|
83
|
-
|
|
84
|
-
return this.proposer.watchEvent.
|
|
94
|
+
listenToPayloadSubmitted(callback) {
|
|
95
|
+
return this.proposer.watchEvent.PayloadSubmitted({}, {
|
|
85
96
|
onLogs: (logs)=>{
|
|
86
97
|
for (const payload of logs){
|
|
87
98
|
const args = payload.args;
|
|
88
|
-
if (args.round && args.
|
|
99
|
+
if (args.round && args.payload) {
|
|
89
100
|
callback(args);
|
|
90
101
|
}
|
|
91
102
|
}
|
|
92
103
|
}
|
|
93
104
|
});
|
|
94
105
|
}
|
|
95
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Wait for a round to be reached.
|
|
108
|
+
*
|
|
109
|
+
* @param round - The round to wait for.
|
|
110
|
+
* @param pollingIntervalSeconds - The interval in seconds to poll for the round.
|
|
111
|
+
* @returns True if the round was reached, false otherwise.
|
|
112
|
+
*/ waitForRound(round, pollingIntervalSeconds = 1) {
|
|
96
113
|
return retryUntil(async ()=>{
|
|
97
|
-
const currentRound = await this.proposer.read.getCurrentRound()
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
const currentRound = await this.proposer.read.getCurrentRound().catch((e)=>{
|
|
115
|
+
this.logger.error('Error getting current round', e);
|
|
116
|
+
return undefined;
|
|
117
|
+
});
|
|
118
|
+
return currentRound !== undefined && currentRound >= round;
|
|
119
|
+
}, `Waiting for round ${round} to be reached`, 0, pollingIntervalSeconds).catch(()=>false);
|
|
100
120
|
}
|
|
101
121
|
async executeRound(txUtils, round) {
|
|
102
122
|
if (typeof round === 'number') {
|
|
@@ -104,7 +124,7 @@ export class SlashingProposerContract extends EventEmitter {
|
|
|
104
124
|
}
|
|
105
125
|
const args = {
|
|
106
126
|
abi: SlashingProposerAbi,
|
|
107
|
-
functionName: '
|
|
127
|
+
functionName: 'submitRoundWinner',
|
|
108
128
|
args: [
|
|
109
129
|
round
|
|
110
130
|
]
|