@aztec/ethereum 0.87.2 → 0.87.3-nightly.20250529

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.js CHANGED
@@ -2,10 +2,10 @@ import { bigintConfigHelper, booleanConfigHelper, getConfigFromMappings, numberC
2
2
  import { l1TxUtilsConfigMappings } from './l1_tx_utils.js';
3
3
  export const DefaultL1ContractsConfig = {
4
4
  ethereumSlotDuration: 12,
5
- aztecSlotDuration: 24,
6
- aztecEpochDuration: 16,
5
+ aztecSlotDuration: 36,
6
+ aztecEpochDuration: 32,
7
7
  aztecTargetCommitteeSize: 48,
8
- aztecProofSubmissionWindow: 31,
8
+ aztecProofSubmissionWindow: 64,
9
9
  minimumStake: BigInt(100e18),
10
10
  slashingQuorum: 6,
11
11
  slashingRoundSize: 10,
@@ -51,7 +51,7 @@ export declare class ReadOnlyGovernanceContract {
51
51
  };
52
52
  state: number;
53
53
  payload: `0x${string}`;
54
- governanceProposer: `0x${string}`;
54
+ proposer: `0x${string}`;
55
55
  creation: bigint;
56
56
  summedBallot: {
57
57
  yea: bigint;
@@ -5,14 +5,17 @@ import { type Account, type GetContractReturnType, type Hex } 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
9
  import type { ViemClient } from '../types.js';
9
10
  import { SlashingProposerContract } from './slashing_proposer.js';
10
- export type L1RollupContractAddresses = Pick<L1ContractAddresses, 'rollupAddress' | 'inboxAddress' | 'outboxAddress' | 'feeJuicePortalAddress' | 'feeJuiceAddress' | 'stakingAssetAddress' | 'rewardDistributorAddress' | 'slashFactoryAddress'>;
11
+ export type ViemCommitteeAttestation = {
12
+ addr: `0x${string}`;
13
+ signature: ViemSignature;
14
+ };
15
+ export type L1RollupContractAddresses = Pick<L1ContractAddresses, 'rollupAddress' | 'inboxAddress' | 'outboxAddress' | 'feeJuicePortalAddress' | 'feeJuiceAddress' | 'stakingAssetAddress' | 'rewardDistributorAddress' | 'slashFactoryAddress' | 'gseAddress'>;
11
16
  export type EpochProofPublicInputArgs = {
12
17
  previousArchive: `0x${string}`;
13
18
  endArchive: `0x${string}`;
14
- endTimestamp: bigint;
15
- outHash: `0x${string}`;
16
19
  proverId: `0x${string}`;
17
20
  };
18
21
  export declare class RollupContract {
@@ -73,7 +76,7 @@ export declare class RollupContract {
73
76
  getEpochProofPublicInputs(args: readonly [bigint, bigint, EpochProofPublicInputArgs, readonly `0x${string}`[], `0x${string}`]): Promise<readonly `0x${string}`[]>;
74
77
  validateHeader(args: readonly [
75
78
  `0x${string}`,
76
- ViemSignature[],
79
+ ViemCommitteeAttestation[],
77
80
  `0x${string}`,
78
81
  bigint,
79
82
  `0x${string}`,
@@ -107,14 +110,28 @@ export declare class RollupContract {
107
110
  getSequencerRewards(address: Hex | EthAddress): Promise<bigint>;
108
111
  getSpecificProverRewardsForEpoch(epoch: bigint, prover: Hex | EthAddress): Promise<bigint>;
109
112
  getAttesters(): Promise<readonly `0x${string}`[]>;
110
- getInfo(address: Hex | EthAddress): Promise<{
111
- stake: bigint;
112
- withdrawer: `0x${string}`;
113
- proposer: `0x${string}`;
113
+ getAttesterView(address: Hex | EthAddress): Promise<{
114
114
  status: number;
115
+ effectiveBalance: bigint;
116
+ exit: {
117
+ amount: bigint;
118
+ exitableAt: bigint;
119
+ recipientOrWithdrawer: `0x${string}`;
120
+ isRecipient: boolean;
121
+ exists: boolean;
122
+ };
123
+ config: {
124
+ withdrawer: `0x${string}`;
125
+ proposer: `0x${string}`;
126
+ };
115
127
  }>;
128
+ getStatus(address: Hex | EthAddress): Promise<number>;
116
129
  getBlobPublicInputsHash(blockNumber: bigint): Promise<`0x${string}`>;
117
130
  getStakingAsset(): Promise<`0x${string}`>;
118
131
  getProposerForAttester(attester: Hex | EthAddress): Promise<`0x${string}`>;
132
+ setupEpoch(l1TxUtils: L1TxUtils): Promise<{
133
+ receipt: import("viem").TransactionReceipt;
134
+ gasPrice: import("../l1_tx_utils.js").GasPrice;
135
+ }>;
119
136
  }
120
137
  //# 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,EAAE,KAAK,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,GAAG,EAA2B,MAAM,MAAM,CAAC;AAGnG,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAC1C,mBAAmB,EACjB,eAAe,GACf,cAAc,GACd,eAAe,GACf,uBAAuB,GACvB,iBAAiB,GACjB,qBAAqB,GACrB,0BAA0B,GAC1B,qBAAqB,CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;IAC/B,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF,qBAAa,cAAc;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B,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,uBAAuB,CAAC,WAAW,EAAE,MAAM;IAI3C,eAAe;IAIf,sBAAsB,CAAC,QAAQ,EAAE,GAAG,GAAG,UAAU;IAOjD,UAAU,CAAC,SAAS,EAAE,SAAS;;;;CAUhC"}
@@ -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 { getAddress, getContract } from 'viem';
12
+ import { encodeFunctionData, getAddress, getContract } from 'viem';
13
13
  import { getPublicClient } from '../client.js';
14
14
  import { formatViemError } from '../utils.js';
15
15
  import { SlashingProposerContract } from './slashing_proposer.js';
@@ -213,13 +213,14 @@ export class RollupContract {
213
213
  ]);
214
214
  }
215
215
  async getRollupAddresses() {
216
- const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress] = (await Promise.all([
216
+ const [inboxAddress, outboxAddress, feeJuicePortalAddress, rewardDistributorAddress, feeJuiceAddress, stakingAssetAddress, gseAddress] = (await Promise.all([
217
217
  this.rollup.read.getInbox(),
218
218
  this.rollup.read.getOutbox(),
219
219
  this.rollup.read.getFeeAssetPortal(),
220
220
  this.rollup.read.getRewardDistributor(),
221
221
  this.rollup.read.getFeeAsset(),
222
- this.rollup.read.getStakingAsset()
222
+ this.rollup.read.getStakingAsset(),
223
+ this.rollup.read.getGSE()
223
224
  ])).map(EthAddress.fromString);
224
225
  return {
225
226
  rollupAddress: EthAddress.fromString(this.address),
@@ -228,7 +229,8 @@ export class RollupContract {
228
229
  feeJuicePortalAddress,
229
230
  feeJuiceAddress,
230
231
  stakingAssetAddress,
231
- rewardDistributorAddress
232
+ rewardDistributorAddress,
233
+ gseAddress
232
234
  };
233
235
  }
234
236
  async getFeeJuicePortal() {
@@ -348,11 +350,19 @@ export class RollupContract {
348
350
  getAttesters() {
349
351
  return this.rollup.read.getAttesters();
350
352
  }
351
- getInfo(address) {
353
+ getAttesterView(address) {
352
354
  if (address instanceof EthAddress) {
353
355
  address = address.toString();
354
356
  }
355
- return this.rollup.read.getInfo([
357
+ return this.rollup.read.getAttesterView([
358
+ address
359
+ ]);
360
+ }
361
+ getStatus(address) {
362
+ if (address instanceof EthAddress) {
363
+ address = address.toString();
364
+ }
365
+ return this.rollup.read.getStatus([
356
366
  address
357
367
  ]);
358
368
  }
@@ -372,6 +382,16 @@ export class RollupContract {
372
382
  attester
373
383
  ]);
374
384
  }
385
+ setupEpoch(l1TxUtils) {
386
+ return l1TxUtils.sendAndMonitorTransaction({
387
+ to: this.address,
388
+ data: encodeFunctionData({
389
+ abi: RollupAbi,
390
+ functionName: 'setupEpoch',
391
+ args: []
392
+ })
393
+ });
394
+ }
375
395
  }
376
396
  _ts_decorate([
377
397
  memoize
@@ -1,9 +1,13 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import EventEmitter from 'events';
2
3
  import { type Hex } from 'viem';
3
- import type { L1TxRequest } from '../l1_tx_utils.js';
4
+ import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
4
5
  import type { ViemClient } from '../types.js';
5
6
  import { type IEmpireBase } from './empire_base.js';
6
- export declare class SlashingProposerContract implements IEmpireBase {
7
+ export declare class ProposalAlreadyExecutedError extends Error {
8
+ constructor(round: bigint);
9
+ }
10
+ export declare class SlashingProposerContract extends EventEmitter implements IEmpireBase {
7
11
  readonly client: ViemClient;
8
12
  private readonly proposer;
9
13
  constructor(client: ViemClient, address: Hex);
@@ -16,6 +20,17 @@ export declare class SlashingProposerContract implements IEmpireBase {
16
20
  leader: Hex;
17
21
  executed: boolean;
18
22
  }>;
23
+ getProposalVotes(rollupAddress: Hex, round: bigint, proposal: Hex): Promise<bigint>;
19
24
  createVoteRequest(payload: Hex): L1TxRequest;
25
+ listenToExecutableProposals(callback: (args: {
26
+ proposal: `0x${string}`;
27
+ round: bigint;
28
+ }) => unknown): import("viem").WatchContractEventReturnType;
29
+ listenToProposalExecuted(callback: (args: {
30
+ round: bigint;
31
+ proposal: `0x${string}`;
32
+ }) => unknown): import("viem").WatchContractEventReturnType;
33
+ waitForRound(round: bigint, pollingIntervalSeconds?: number): Promise<boolean>;
34
+ executeRound(txUtils: L1TxUtils, round: bigint | number): Promise<void>;
20
35
  }
21
36
  //# sourceMappingURL=slashing_proposer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAG3D,OAAO,EAA8B,KAAK,GAAG,EAAe,MAAM,MAAM,CAAC;AAEzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,KAAK,WAAW,EAAc,MAAM,kBAAkB,CAAC;AAEhE,qBAAa,wBAAyB,YAAW,WAAW;aAIxC,MAAM,EAAE,UAAU;IAHpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgE;gBAGvE,MAAM,EAAE,UAAU,EAClC,OAAO,EAAE,GAAG;IAKd,IAAW,OAAO,eAEjB;IAEM,aAAa;IAIb,YAAY;IAIZ,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIrC,YAAY,CACvB,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE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AAO,CAAC,MAAM,CAAC;IAInF,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW;IAO5C,2BAA2B,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO;IAiBnG,wBAAwB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,KAAK,OAAO;IAgBhG,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,sBAAsB,GAAE,MAAU;IAYxD,YAAY,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CA4CrF"}
@@ -1,12 +1,20 @@
1
1
  import { EthAddress } from '@aztec/foundation/eth-address';
2
+ import { retryUntil } from '@aztec/foundation/retry';
2
3
  import { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
3
- import { getContract } from 'viem';
4
+ import EventEmitter from 'events';
5
+ import { encodeFunctionData, getContract } from 'viem';
6
+ import { FormattedViemError } from '../utils.js';
4
7
  import { encodeVote } from './empire_base.js';
5
- export class SlashingProposerContract {
8
+ export class ProposalAlreadyExecutedError extends Error {
9
+ constructor(round){
10
+ super(`Proposal already executed: ${round}`);
11
+ }
12
+ }
13
+ export class SlashingProposerContract extends EventEmitter {
6
14
  client;
7
15
  proposer;
8
16
  constructor(client, address){
9
- this.client = client;
17
+ super(), this.client = client;
10
18
  this.proposer = getContract({
11
19
  address,
12
20
  abi: SlashingProposerAbi,
@@ -38,10 +46,83 @@ export class SlashingProposerContract {
38
46
  executed: roundInfo[2]
39
47
  };
40
48
  }
49
+ getProposalVotes(rollupAddress, round, proposal) {
50
+ return this.proposer.read.yeaCount([
51
+ rollupAddress,
52
+ round,
53
+ proposal
54
+ ]);
55
+ }
41
56
  createVoteRequest(payload) {
42
57
  return {
43
58
  to: this.address.toString(),
44
59
  data: encodeVote(payload)
45
60
  };
46
61
  }
62
+ listenToExecutableProposals(callback) {
63
+ return this.proposer.watchEvent.ProposalExecutable({}, {
64
+ onLogs: (logs)=>{
65
+ for (const payload of logs){
66
+ const args = payload.args;
67
+ if (args.proposal && args.round) {
68
+ // why compiler can't figure it out? no one knows
69
+ callback(args);
70
+ }
71
+ }
72
+ }
73
+ });
74
+ }
75
+ listenToProposalExecuted(callback) {
76
+ return this.proposer.watchEvent.ProposalExecuted({}, {
77
+ onLogs: (logs)=>{
78
+ for (const payload of logs){
79
+ const args = payload.args;
80
+ if (args.round && args.proposal) {
81
+ callback(args);
82
+ }
83
+ }
84
+ }
85
+ });
86
+ }
87
+ waitForRound(round, pollingIntervalSeconds = 1) {
88
+ return retryUntil(async ()=>{
89
+ const currentRound = await this.proposer.read.getCurrentRound();
90
+ return currentRound >= round;
91
+ }, `Waiting for round ${round} to be reached`, 0, pollingIntervalSeconds);
92
+ }
93
+ async executeRound(txUtils, round) {
94
+ if (typeof round === 'number') {
95
+ round = BigInt(round);
96
+ }
97
+ const args = {
98
+ abi: SlashingProposerAbi,
99
+ functionName: 'executeProposal',
100
+ args: [
101
+ round
102
+ ]
103
+ };
104
+ const data = encodeFunctionData(args);
105
+ const response = await txUtils.sendAndMonitorTransaction({
106
+ to: this.address.toString(),
107
+ data
108
+ }, {
109
+ // Gas estimation is more than 20% off for this tx.
110
+ gasLimitBufferPercentage: 100
111
+ }).catch((err)=>{
112
+ if (err instanceof FormattedViemError && err.message.includes('ProposalAlreadyExecuted')) {
113
+ throw new ProposalAlreadyExecutedError(round);
114
+ }
115
+ throw err;
116
+ });
117
+ if (response.receipt.status === 'reverted') {
118
+ const error = await txUtils.tryGetErrorFromRevertedTx(data, {
119
+ ...args,
120
+ address: this.address.toString()
121
+ }, undefined, []);
122
+ if (error?.includes('ProposalAlreadyExecuted')) {
123
+ throw new ProposalAlreadyExecutedError(round);
124
+ }
125
+ throw new Error(error ?? 'Unknown error');
126
+ }
127
+ }
47
128
  }