@aztec/ethereum 0.0.1-commit.e2b2873ed → 0.0.1-commit.e304674f1

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.
Files changed (142) hide show
  1. package/dest/client.d.ts +10 -2
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +13 -7
  4. package/dest/config.d.ts +8 -6
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +14 -10
  7. package/dest/contracts/empire_base.d.ts +3 -1
  8. package/dest/contracts/empire_base.d.ts.map +1 -1
  9. package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
  10. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  11. package/dest/contracts/fee_asset_price_oracle.js +651 -0
  12. package/dest/contracts/governance.js +3 -3
  13. package/dest/contracts/governance_proposer.d.ts +3 -1
  14. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  15. package/dest/contracts/governance_proposer.js +9 -0
  16. package/dest/contracts/inbox.d.ts +3 -3
  17. package/dest/contracts/inbox.d.ts.map +1 -1
  18. package/dest/contracts/inbox.js +5 -6
  19. package/dest/contracts/index.d.ts +3 -3
  20. package/dest/contracts/index.d.ts.map +1 -1
  21. package/dest/contracts/index.js +2 -2
  22. package/dest/contracts/multicall.d.ts +51 -2
  23. package/dest/contracts/multicall.d.ts.map +1 -1
  24. package/dest/contracts/multicall.js +85 -0
  25. package/dest/contracts/registry.d.ts +3 -1
  26. package/dest/contracts/registry.d.ts.map +1 -1
  27. package/dest/contracts/registry.js +30 -1
  28. package/dest/contracts/rollup.d.ts +48 -18
  29. package/dest/contracts/rollup.d.ts.map +1 -1
  30. package/dest/contracts/rollup.js +213 -52
  31. package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
  32. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  33. package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +13 -15
  34. package/dest/deploy_aztec_l1_contracts.d.ts +4 -8
  35. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  36. package/dest/deploy_aztec_l1_contracts.js +35 -23
  37. package/dest/deploy_l1_contract.js +3 -3
  38. package/dest/generated/l1-contracts-defaults.d.ts +2 -2
  39. package/dest/generated/l1-contracts-defaults.js +2 -2
  40. package/dest/l1_artifacts.d.ts +9214 -15208
  41. package/dest/l1_artifacts.d.ts.map +1 -1
  42. package/dest/l1_artifacts.js +9 -24
  43. package/dest/l1_contract_addresses.d.ts +1 -5
  44. package/dest/l1_contract_addresses.d.ts.map +1 -1
  45. package/dest/l1_contract_addresses.js +0 -6
  46. package/dest/l1_reader.d.ts +3 -1
  47. package/dest/l1_reader.d.ts.map +1 -1
  48. package/dest/l1_reader.js +6 -1
  49. package/dest/l1_tx_utils/config.d.ts +7 -1
  50. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  51. package/dest/l1_tx_utils/config.js +14 -1
  52. package/dest/l1_tx_utils/factory.d.ts +18 -10
  53. package/dest/l1_tx_utils/factory.d.ts.map +1 -1
  54. package/dest/l1_tx_utils/factory.js +17 -7
  55. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
  56. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
  57. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
  58. package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
  59. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
  60. package/dest/l1_tx_utils/index-blobs.js +2 -2
  61. package/dest/l1_tx_utils/index.d.ts +2 -1
  62. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  63. package/dest/l1_tx_utils/index.js +1 -0
  64. package/dest/l1_tx_utils/l1_tx_utils.d.ts +20 -7
  65. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  66. package/dest/l1_tx_utils/l1_tx_utils.js +75 -51
  67. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
  68. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  69. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +8 -4
  70. package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
  71. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  72. package/dest/{test → l1_tx_utils}/tx_delayer.js +62 -34
  73. package/dest/publisher_manager.d.ts +21 -7
  74. package/dest/publisher_manager.d.ts.map +1 -1
  75. package/dest/publisher_manager.js +81 -7
  76. package/dest/queries.js +3 -3
  77. package/dest/test/chain_monitor.d.ts +22 -3
  78. package/dest/test/chain_monitor.d.ts.map +1 -1
  79. package/dest/test/chain_monitor.js +33 -2
  80. package/dest/test/eth_cheat_codes.d.ts +6 -4
  81. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  82. package/dest/test/eth_cheat_codes.js +6 -4
  83. package/dest/test/index.d.ts +1 -3
  84. package/dest/test/index.d.ts.map +1 -1
  85. package/dest/test/index.js +0 -2
  86. package/dest/test/start_anvil.d.ts +23 -3
  87. package/dest/test/start_anvil.d.ts.map +1 -1
  88. package/dest/test/start_anvil.js +143 -29
  89. package/dest/test/upgrade_utils.js +2 -2
  90. package/dest/utils.d.ts +1 -1
  91. package/dest/utils.d.ts.map +1 -1
  92. package/dest/utils.js +16 -12
  93. package/package.json +5 -7
  94. package/src/client.ts +10 -2
  95. package/src/config.ts +23 -14
  96. package/src/contracts/empire_base.ts +2 -0
  97. package/src/contracts/fee_asset_price_oracle.ts +280 -0
  98. package/src/contracts/governance.ts +3 -3
  99. package/src/contracts/governance_proposer.ts +6 -0
  100. package/src/contracts/inbox.ts +4 -4
  101. package/src/contracts/index.ts +2 -2
  102. package/src/contracts/multicall.ts +65 -1
  103. package/src/contracts/registry.ts +31 -1
  104. package/src/contracts/rollup.ts +250 -59
  105. package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +14 -16
  106. package/src/deploy_aztec_l1_contracts.ts +57 -34
  107. package/src/deploy_l1_contract.ts +3 -3
  108. package/src/generated/l1-contracts-defaults.ts +2 -2
  109. package/src/l1_artifacts.ts +12 -35
  110. package/src/l1_contract_addresses.ts +0 -7
  111. package/src/l1_reader.ts +13 -1
  112. package/src/l1_tx_utils/config.ts +20 -0
  113. package/src/l1_tx_utils/factory.ts +31 -31
  114. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
  115. package/src/l1_tx_utils/index-blobs.ts +2 -2
  116. package/src/l1_tx_utils/index.ts +1 -0
  117. package/src/l1_tx_utils/l1_tx_utils.ts +68 -30
  118. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +8 -4
  119. package/src/{test → l1_tx_utils}/tx_delayer.ts +78 -50
  120. package/src/publisher_manager.ts +105 -10
  121. package/src/queries.ts +3 -3
  122. package/src/test/chain_monitor.ts +60 -3
  123. package/src/test/eth_cheat_codes.ts +6 -4
  124. package/src/test/index.ts +0 -2
  125. package/src/test/start_anvil.ts +177 -29
  126. package/src/test/upgrade_utils.ts +2 -2
  127. package/src/utils.ts +17 -14
  128. package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
  129. package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
  130. package/dest/contracts/empire_slashing_proposer.js +0 -207
  131. package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
  132. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
  133. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
  134. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
  135. package/dest/test/delayed_tx_utils.d.ts +0 -13
  136. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  137. package/dest/test/delayed_tx_utils.js +0 -28
  138. package/dest/test/tx_delayer.d.ts +0 -36
  139. package/dest/test/tx_delayer.d.ts.map +0 -1
  140. package/src/contracts/empire_slashing_proposer.ts +0 -259
  141. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
  142. package/src/test/delayed_tx_utils.ts +0 -52
@@ -1,207 +0,0 @@
1
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
- import { EthAddress } from '@aztec/foundation/eth-address';
3
- import { createLogger } from '@aztec/foundation/log';
4
- import { retryUntil } from '@aztec/foundation/retry';
5
- import { EmpireSlashingProposerAbi } from '@aztec/l1-artifacts/EmpireSlashingProposerAbi';
6
- import EventEmitter from 'events';
7
- import { encodeFunctionData, getContract } from 'viem';
8
- import { FormattedViemError, tryExtractEvent } from '../utils.js';
9
- import { encodeSignal, encodeSignalWithSignature, signSignalWithSig } from './empire_base.js';
10
- export class ProposalAlreadyExecutedError extends Error {
11
- constructor(round){
12
- super(`Proposal already executed: ${round}`);
13
- }
14
- }
15
- export class EmpireSlashingProposerContract extends EventEmitter {
16
- client;
17
- logger;
18
- proposer;
19
- type;
20
- constructor(client, address){
21
- super(), this.client = client, this.logger = createLogger('ethereum:contracts:empire_slashing_proposer'), this.type = 'empire';
22
- this.proposer = getContract({
23
- address: typeof address === 'string' ? address : address.toString(),
24
- abi: EmpireSlashingProposerAbi,
25
- client
26
- });
27
- }
28
- get address() {
29
- return EthAddress.fromString(this.proposer.address);
30
- }
31
- getQuorumSize() {
32
- return this.proposer.read.QUORUM_SIZE();
33
- }
34
- getRoundSize() {
35
- return this.proposer.read.ROUND_SIZE();
36
- }
37
- getLifetimeInRounds() {
38
- return this.proposer.read.LIFETIME_IN_ROUNDS();
39
- }
40
- getExecutionDelayInRounds() {
41
- return this.proposer.read.EXECUTION_DELAY_IN_ROUNDS();
42
- }
43
- getCurrentRound() {
44
- return this.proposer.read.getCurrentRound();
45
- }
46
- computeRound(slot) {
47
- return this.proposer.read.computeRound([
48
- BigInt(slot)
49
- ]);
50
- }
51
- getInstance() {
52
- return this.proposer.read.getInstance();
53
- }
54
- async getRoundInfo(rollupAddress, round) {
55
- const result = await this.proposer.read.getRoundData([
56
- rollupAddress,
57
- round
58
- ]);
59
- const [signalCount, quorum] = await Promise.all([
60
- this.proposer.read.signalCount([
61
- rollupAddress,
62
- round,
63
- result.payloadWithMostSignals
64
- ]),
65
- this.getQuorumSize()
66
- ]);
67
- return {
68
- lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
69
- payloadWithMostSignals: result.payloadWithMostSignals,
70
- quorumReached: signalCount >= quorum,
71
- executed: result.executed
72
- };
73
- }
74
- getPayloadSignals(rollupAddress, round, payload) {
75
- return this.proposer.read.signalCount([
76
- rollupAddress,
77
- round,
78
- payload
79
- ]);
80
- }
81
- createSignalRequest(payload) {
82
- return {
83
- to: this.address.toString(),
84
- abi: EmpireSlashingProposerAbi,
85
- data: encodeSignal(payload)
86
- };
87
- }
88
- async createSignalRequestWithSignature(payload, slot, chainId, signerAddress, signer) {
89
- const signature = await signSignalWithSig(signer, payload, slot, await this.getInstance(), this.address.toString(), chainId);
90
- return {
91
- to: this.address.toString(),
92
- abi: EmpireSlashingProposerAbi,
93
- data: encodeSignalWithSignature(payload, signature)
94
- };
95
- }
96
- listenToSubmittablePayloads(callback) {
97
- return this.proposer.watchEvent.PayloadSubmittable({}, {
98
- strict: true,
99
- onLogs: (logs)=>{
100
- for (const log of logs){
101
- const { payload, round } = log.args;
102
- if (payload && round) {
103
- callback({
104
- payload,
105
- round
106
- });
107
- }
108
- }
109
- }
110
- });
111
- }
112
- listenToPayloadSubmitted(callback) {
113
- return this.proposer.watchEvent.PayloadSubmitted({}, {
114
- onLogs: (logs)=>{
115
- for (const log of logs){
116
- const { payload, round } = log.args;
117
- if (round && payload) {
118
- callback({
119
- round,
120
- payload
121
- });
122
- }
123
- }
124
- }
125
- });
126
- }
127
- listenToSignalCasted(callback) {
128
- return this.proposer.watchEvent.SignalCast({}, {
129
- onLogs: (logs)=>{
130
- for (const log of logs){
131
- const { round, payload, signaler } = log.args;
132
- if (round && payload && signaler) {
133
- callback({
134
- round,
135
- payload,
136
- signaler
137
- });
138
- }
139
- }
140
- }
141
- });
142
- }
143
- /** Creates an L1TxRequest to submit the round winner for the given round. */ buildExecuteRoundRequest(round) {
144
- return {
145
- to: this.address.toString(),
146
- abi: EmpireSlashingProposerAbi,
147
- data: encodeFunctionData({
148
- abi: EmpireSlashingProposerAbi,
149
- functionName: 'submitRoundWinner',
150
- args: [
151
- round
152
- ]
153
- })
154
- };
155
- }
156
- /** Tries to extract a PayloadSubmitted event from the given logs. */ tryExtractPayloadSubmittedEvent(logs) {
157
- return tryExtractEvent(logs, this.address.toString(), EmpireSlashingProposerAbi, 'PayloadSubmitted');
158
- }
159
- /**
160
- * Wait for a round to be reached.
161
- *
162
- * @param round - The round to wait for.
163
- * @param pollingIntervalSeconds - The interval in seconds to poll for the round.
164
- * @returns True if the round was reached, false otherwise.
165
- */ waitForRound(round, pollingIntervalSeconds = 1) {
166
- return retryUntil(async ()=>{
167
- const currentRound = await this.proposer.read.getCurrentRound().catch((e)=>{
168
- this.logger.error('Error getting current round', e);
169
- return undefined;
170
- });
171
- return currentRound !== undefined && currentRound >= round;
172
- }, `Waiting for round ${round} to be reached`, 0, pollingIntervalSeconds).catch(()=>false);
173
- }
174
- async executeRound(txUtils, round) {
175
- if (typeof round === 'number') {
176
- round = BigInt(round);
177
- }
178
- const request = this.buildExecuteRoundRequest(round);
179
- const response = await txUtils.sendAndMonitorTransaction(request, {
180
- // Gas estimation is way off for this, likely because we are creating the contract/selector to call
181
- // for the actual slashing dynamically.
182
- gasLimitBufferPercentage: 50
183
- }).catch((err)=>{
184
- if (err instanceof FormattedViemError && err.message.includes('ProposalAlreadyExecuted')) {
185
- throw new ProposalAlreadyExecutedError(round);
186
- }
187
- throw err;
188
- });
189
- if (response.receipt.status === 'reverted') {
190
- const args = {
191
- abi: EmpireSlashingProposerAbi,
192
- functionName: 'submitRoundWinner',
193
- args: [
194
- round
195
- ],
196
- address: this.address.toString()
197
- };
198
- const error = await txUtils.tryGetErrorFromRevertedTx(request.data, args, undefined, []);
199
- if (error?.includes('ProposalAlreadyExecuted')) {
200
- throw new ProposalAlreadyExecutedError(round);
201
- }
202
- const errorMessage = `Failed to execute round ${round}, TxHash: ${response.receipt.transactionHash}, Error: ${error ?? 'Unknown error'}`;
203
- throw new Error(errorMessage);
204
- }
205
- return response;
206
- }
207
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"tally_slashing_proposer.d.ts","sourceRoot":"","sources":["../../src/contracts/tally_slashing_proposer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAM3D,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,GAAG,EACR,KAAK,mBAAmB,EAGzB,MAAM,MAAM,CAAC;AAEd;;;GAGG;AACH,qBAAa,6BAA6B;aAMtB,MAAM,EAAE,UAAU;IALpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqE;IAE9F,SAAgB,IAAI,UAAoB;IAExC,YACkB,MAAM,EAAE,UAAU,EAClC,OAAO,EAAE,GAAG,GAAG,UAAU,EAO1B;IAED,IAAW,OAAO,eAEjB;IAEM,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAEtC;IAEM,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAErC;IAEM,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAEzC;IAEM,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAE7C;IAEM,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC,CAE5C;IAEM,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC,CAElD;IAEM,kBAAkB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAM7D;IAEM,sBAAsB,IAAI,OAAO,CAA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ED,oEAAoE;IACvD,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAE9E;IAED;;;;;OAKG;IACI,6BAA6B,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,GAAG,CAAC;QAAC,CAAC,EAAE,GAAG,CAAA;KAAE,GAAG,WAAW,CAUtG;IAED;;;;;OAKG;IACI,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,GAAG,WAAW,CAUtF;IAED,uDAAuD;IAC1C,WAAW,CAAC,KAAK,EAAE,MAAM;;;SAYrC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,GAAG,MAAM,IAAI,CAcjG;IAED;;;;OAIG;IACI,qBAAqB,CAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,GAAG,CAAA;KAAE,KAAK,IAAI,GAChF,MAAM,IAAI,CAcZ;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAelE"}
@@ -1,26 +0,0 @@
1
- import type { Logger } from '@aztec/foundation/log';
2
- import { DateProvider } from '@aztec/foundation/timer';
3
- import type { EthSigner } from '../eth-signer/eth-signer.js';
4
- import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
5
- import type { L1TxUtilsConfig } from './config.js';
6
- import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
7
- import { L1TxUtils } from './l1_tx_utils.js';
8
- import type { L1BlobInputs } from './types.js';
9
- /** Extends L1TxUtils with the capability to cancel blobs. This needs to be a separate class so we don't require a dependency on blob-lib unnecessarily. */
10
- export declare class L1TxUtilsWithBlobs extends L1TxUtils {
11
- /** Makes empty blob inputs for the cancellation tx. */
12
- protected makeEmptyBlobInputs(maxFeePerBlobGas: bigint): Required<L1BlobInputs>;
13
- }
14
- export declare function createL1TxUtilsWithBlobsFromViemWallet(client: ExtendedViemWalletClient, deps?: {
15
- logger?: Logger;
16
- dateProvider?: DateProvider;
17
- store?: IL1TxStore;
18
- metrics?: IL1TxMetrics;
19
- }, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): L1TxUtilsWithBlobs;
20
- export declare function createL1TxUtilsWithBlobsFromEthSigner(client: ViemClient, signer: EthSigner, deps?: {
21
- logger?: Logger;
22
- dateProvider?: DateProvider;
23
- store?: IL1TxStore;
24
- metrics?: IL1TxMetrics;
25
- }, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): L1TxUtilsWithBlobs;
26
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDFfdHhfdXRpbHNfd2l0aF9ibG9icy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2wxX3R4X3V0aWxzL2wxX3R4X3V0aWxzX3dpdGhfYmxvYnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDcEQsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBSXZELE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzdELE9BQU8sS0FBSyxFQUFFLHdCQUF3QixFQUFFLFVBQVUsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUN4RSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSxhQUF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CAAC,EAAE,YAAY,CAAC;IAC5B,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,CAAC;CACnB,EACN,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,gBAAgB,GAAE,OAAe,sBAiBlC"}
@@ -1,26 +0,0 @@
1
- import { Blob } from '@aztec/blob-lib';
2
- import { EthAddress } from '@aztec/foundation/eth-address';
3
- import { L1TxUtils } from './l1_tx_utils.js';
4
- import { createViemSigner } from './signer.js';
5
- /** Extends L1TxUtils with the capability to cancel blobs. This needs to be a separate class so we don't require a dependency on blob-lib unnecessarily. */ export class L1TxUtilsWithBlobs extends L1TxUtils {
6
- /** Makes empty blob inputs for the cancellation tx. */ makeEmptyBlobInputs(maxFeePerBlobGas) {
7
- const blobData = new Uint8Array(131072).fill(0);
8
- const kzg = Blob.getViemKzgInstance();
9
- return {
10
- blobs: [
11
- blobData
12
- ],
13
- kzg,
14
- maxFeePerBlobGas
15
- };
16
- }
17
- }
18
- export function createL1TxUtilsWithBlobsFromViemWallet(client, deps = {}, config = {}, debugMaxGasLimit = false) {
19
- return new L1TxUtilsWithBlobs(client, EthAddress.fromString(client.account.address), createViemSigner(client), deps.logger, deps.dateProvider, config, debugMaxGasLimit, deps.store, deps.metrics);
20
- }
21
- export function createL1TxUtilsWithBlobsFromEthSigner(client, signer, deps = {}, config = {}, debugMaxGasLimit = false) {
22
- const callback = async (transaction, _signingAddress)=>{
23
- return (await signer.signTransaction(transaction)).toViemTransactionSignature();
24
- };
25
- return new L1TxUtilsWithBlobs(client, signer.address, callback, deps.logger, deps.dateProvider, config, debugMaxGasLimit, deps.store, deps.metrics);
26
- }
@@ -1,13 +0,0 @@
1
- import { type Logger } from '@aztec/foundation/log';
2
- import { DateProvider } from '@aztec/foundation/timer';
3
- import { type L1TxUtilsConfig } from '../l1_tx_utils/index.js';
4
- import { L1TxUtilsWithBlobs } from '../l1_tx_utils/l1_tx_utils_with_blobs.js';
5
- import type { ExtendedViemWalletClient } from '../types.js';
6
- import { type Delayer } from './tx_delayer.js';
7
- export declare class DelayedTxUtils extends L1TxUtilsWithBlobs {
8
- delayer: Delayer | undefined;
9
- static fromL1TxUtils(l1TxUtils: L1TxUtilsWithBlobs, ethereumSlotDuration: number, wallet: ExtendedViemWalletClient): DelayedTxUtils;
10
- enableDelayer(ethereumSlotDuration: number): void;
11
- }
12
- export declare function createDelayedL1TxUtilsFromViemWallet(client: ExtendedViemWalletClient, logger?: Logger, dateProvider?: DateProvider, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): DelayedTxUtils;
13
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVsYXllZF90eF91dGlscy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvZGVsYXllZF90eF91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFDbEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRXZELE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBb0IsTUFBTSx5QkFBeUIsQ0FBQztBQUNqRixPQUFPLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSwwQ0FBMEMsQ0FBQztBQUM5RSxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUM1RCxPQUFPLEVBQUUsS0FBSyxPQUFPLEVBQWUsTUFBTSxpQkFBaUIsQ0FBQztBQUU1RCxxQkFBYSxjQUFlLFNBQVEsa0JBQWtCO0lBQzdDLE9BQU8sRUFBRSxPQUFPLEdBQUcsU0FBUyxDQUFDO0lBRXBDLE9BQWMsYUFBYSxDQUN6QixTQUFTLEVBQUUsa0JBQWtCLEVBQzdCLG9CQUFvQix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E,OAAe,kBAWlC"}
@@ -1,28 +0,0 @@
1
- import { EthAddress } from '@aztec/foundation/eth-address';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { DateProvider } from '@aztec/foundation/timer';
4
- import { createViemSigner } from '../l1_tx_utils/index.js';
5
- import { L1TxUtilsWithBlobs } from '../l1_tx_utils/l1_tx_utils_with_blobs.js';
6
- import { withDelayer } from './tx_delayer.js';
7
- export class DelayedTxUtils extends L1TxUtilsWithBlobs {
8
- delayer;
9
- static fromL1TxUtils(l1TxUtils, ethereumSlotDuration, wallet) {
10
- const { client, delayer } = withDelayer(wallet, l1TxUtils.dateProvider, {
11
- ethereumSlotDuration
12
- });
13
- const casted = l1TxUtils;
14
- casted.delayer = delayer;
15
- casted.client = client;
16
- return casted;
17
- }
18
- enableDelayer(ethereumSlotDuration) {
19
- const { client, delayer } = withDelayer(this.client, this.dateProvider, {
20
- ethereumSlotDuration
21
- });
22
- this.delayer = delayer;
23
- this.client = client;
24
- }
25
- }
26
- export function createDelayedL1TxUtilsFromViemWallet(client, logger = createLogger('L1TxUtils'), dateProvider = new DateProvider(), config, debugMaxGasLimit = false) {
27
- return new DelayedTxUtils(client, EthAddress.fromString(client.account.address), createViemSigner(client), logger, dateProvider, config, debugMaxGasLimit);
28
- }
@@ -1,36 +0,0 @@
1
- import { type Logger } from '@aztec/foundation/log';
2
- import type { DateProvider } from '@aztec/foundation/timer';
3
- import { type Client, type Hex } from 'viem';
4
- import { type ViemClient } from '../types.js';
5
- export declare function waitUntilBlock<T extends Client>(client: T, blockNumber: number | bigint, logger?: Logger, timeout?: number): Promise<boolean>;
6
- export declare function waitUntilL1Timestamp<T extends Client>(client: T, timestamp: number | bigint, logger?: Logger, timeout?: number): Promise<boolean>;
7
- export interface Delayer {
8
- /** Returns the hashes of all effectively sent txs. */
9
- getSentTxHashes(): Hex[];
10
- /** Returns the raw hex for all cancelled txs. */
11
- getCancelledTxs(): Hex[];
12
- /** Delays the next tx to be sent so it lands on the given L1 block number. */
13
- pauseNextTxUntilBlock(l1BlockNumber: number | bigint | undefined): void;
14
- /** Delays the next tx to be sent so it lands on the given timestamp. */
15
- pauseNextTxUntilTimestamp(l1Timestamp: number | bigint | undefined): void;
16
- /** Delays the next tx to be sent indefinitely. */
17
- cancelNextTx(): void;
18
- /**
19
- * Sets max inclusion time into slot. If more than this many seconds have passed
20
- * since the last L1 block was mined, then any tx will not be mined in the current
21
- * L1 slot but will be deferred for the next one.
22
- */
23
- setMaxInclusionTimeIntoSlot(seconds: number | bigint | undefined): void;
24
- }
25
- /**
26
- * Returns a new client (without modifying the one passed in) with an injected tx delayer.
27
- * The delayer can be used to hold off the next tx to be sent until a given block number.
28
- * TODO(#10824): This doesn't play along well with blob txs for some reason.
29
- */
30
- export declare function withDelayer<T extends ViemClient>(client: T, dateProvider: DateProvider, opts: {
31
- ethereumSlotDuration: bigint | number;
32
- }): {
33
- client: T;
34
- delayer: Delayer;
35
- };
36
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfZGVsYXllci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3Rlc3QvdHhfZGVsYXllci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFFbEUsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFHNUQsT0FBTyxFQUNMLEtBQUssTUFBTSxFQUNYLEtBQUssR0FBRyxFQVFULE1BQU0sTUFBTSxDQUFDO0FBRWQsT0FBTyxFQUFFLEtBQUssVUFBVSxFQUFvQixNQUFNLGFBQWEsQ0FBQztBQUloRSx3QkFBZ0IsY0FBYyxDQUFDLENBQUMsU0FBUyxNQUFNLEVBQzdDLE1BQU0sRUFBRSxDQUFDLEVBQ1QsV0FBVyxFQUFFLE1BQU0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0CD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,UAAU,EAC9C,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE;IAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC9C;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA0GjC"}
@@ -1,259 +0,0 @@
1
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
- import { EthAddress } from '@aztec/foundation/eth-address';
3
- import { createLogger } from '@aztec/foundation/log';
4
- import { retryUntil } from '@aztec/foundation/retry';
5
- import { EmpireSlashingProposerAbi } from '@aztec/l1-artifacts/EmpireSlashingProposerAbi';
6
-
7
- import EventEmitter from 'events';
8
- import {
9
- type GetContractReturnType,
10
- type Hex,
11
- type Log,
12
- type TypedDataDefinition,
13
- encodeFunctionData,
14
- getContract,
15
- } from 'viem';
16
-
17
- import type { L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
18
- import type { ViemClient } from '../types.js';
19
- import { FormattedViemError, tryExtractEvent } from '../utils.js';
20
- import { type IEmpireBase, encodeSignal, encodeSignalWithSignature, signSignalWithSig } from './empire_base.js';
21
-
22
- export class ProposalAlreadyExecutedError extends Error {
23
- constructor(round: bigint) {
24
- super(`Proposal already executed: ${round}`);
25
- }
26
- }
27
-
28
- export class EmpireSlashingProposerContract extends EventEmitter implements IEmpireBase {
29
- private readonly logger = createLogger('ethereum:contracts:empire_slashing_proposer');
30
- private readonly proposer: GetContractReturnType<typeof EmpireSlashingProposerAbi, ViemClient>;
31
-
32
- public readonly type = 'empire' as const;
33
-
34
- constructor(
35
- public readonly client: ViemClient,
36
- address: Hex | EthAddress,
37
- ) {
38
- super();
39
- this.proposer = getContract({
40
- address: typeof address === 'string' ? address : address.toString(),
41
- abi: EmpireSlashingProposerAbi,
42
- client,
43
- });
44
- }
45
-
46
- public get address() {
47
- return EthAddress.fromString(this.proposer.address);
48
- }
49
-
50
- public getQuorumSize() {
51
- return this.proposer.read.QUORUM_SIZE();
52
- }
53
-
54
- public getRoundSize() {
55
- return this.proposer.read.ROUND_SIZE();
56
- }
57
-
58
- public getLifetimeInRounds() {
59
- return this.proposer.read.LIFETIME_IN_ROUNDS();
60
- }
61
-
62
- public getExecutionDelayInRounds() {
63
- return this.proposer.read.EXECUTION_DELAY_IN_ROUNDS();
64
- }
65
-
66
- public getCurrentRound() {
67
- return this.proposer.read.getCurrentRound();
68
- }
69
-
70
- public computeRound(slot: SlotNumber): Promise<bigint> {
71
- return this.proposer.read.computeRound([BigInt(slot)]);
72
- }
73
-
74
- public getInstance() {
75
- return this.proposer.read.getInstance();
76
- }
77
-
78
- public async getRoundInfo(
79
- rollupAddress: Hex,
80
- round: bigint,
81
- ): Promise<{ lastSignalSlot: SlotNumber; payloadWithMostSignals: Hex; quorumReached: boolean; executed: boolean }> {
82
- const result = await this.proposer.read.getRoundData([rollupAddress, round]);
83
- const [signalCount, quorum] = await Promise.all([
84
- this.proposer.read.signalCount([rollupAddress, round, result.payloadWithMostSignals]),
85
- this.getQuorumSize(),
86
- ]);
87
- return {
88
- lastSignalSlot: SlotNumber.fromBigInt(result.lastSignalSlot),
89
- payloadWithMostSignals: result.payloadWithMostSignals,
90
- quorumReached: signalCount >= quorum,
91
- executed: result.executed,
92
- };
93
- }
94
-
95
- public getPayloadSignals(rollupAddress: Hex, round: bigint, payload: Hex): Promise<bigint> {
96
- return this.proposer.read.signalCount([rollupAddress, round, payload]);
97
- }
98
-
99
- public createSignalRequest(payload: Hex): L1TxRequest {
100
- return {
101
- to: this.address.toString(),
102
- abi: EmpireSlashingProposerAbi,
103
- data: encodeSignal(payload),
104
- };
105
- }
106
-
107
- public async createSignalRequestWithSignature(
108
- payload: Hex,
109
- slot: SlotNumber,
110
- chainId: number,
111
- signerAddress: Hex,
112
- signer: (msg: TypedDataDefinition) => Promise<Hex>,
113
- ): Promise<L1TxRequest> {
114
- const signature = await signSignalWithSig(
115
- signer,
116
- payload,
117
- slot,
118
- await this.getInstance(),
119
- this.address.toString(),
120
- chainId,
121
- );
122
- return {
123
- to: this.address.toString(),
124
- abi: EmpireSlashingProposerAbi,
125
- data: encodeSignalWithSignature(payload, signature),
126
- };
127
- }
128
-
129
- public listenToSubmittablePayloads(callback: (args: { payload: `0x${string}`; round: bigint }) => unknown) {
130
- return this.proposer.watchEvent.PayloadSubmittable(
131
- {},
132
- {
133
- strict: true,
134
- onLogs: logs => {
135
- for (const log of logs) {
136
- const { payload, round } = log.args;
137
- if (payload && round) {
138
- callback({ payload, round });
139
- }
140
- }
141
- },
142
- },
143
- );
144
- }
145
-
146
- public listenToPayloadSubmitted(callback: (args: { round: bigint; payload: `0x${string}` }) => unknown) {
147
- return this.proposer.watchEvent.PayloadSubmitted(
148
- {},
149
- {
150
- onLogs: logs => {
151
- for (const log of logs) {
152
- const { payload, round } = log.args;
153
- if (round && payload) {
154
- callback({ round, payload });
155
- }
156
- }
157
- },
158
- },
159
- );
160
- }
161
-
162
- public listenToSignalCasted(
163
- callback: (args: { round: bigint; payload: `0x${string}`; signaler: `0x${string}` }) => unknown,
164
- ) {
165
- return this.proposer.watchEvent.SignalCast(
166
- {},
167
- {
168
- onLogs: logs => {
169
- for (const log of logs) {
170
- const { round, payload, signaler } = log.args;
171
- if (round && payload && signaler) {
172
- callback({ round, payload, signaler });
173
- }
174
- }
175
- },
176
- },
177
- );
178
- }
179
-
180
- /** Creates an L1TxRequest to submit the round winner for the given round. */
181
- public buildExecuteRoundRequest(round: bigint): L1TxRequest {
182
- return {
183
- to: this.address.toString(),
184
- abi: EmpireSlashingProposerAbi,
185
- data: encodeFunctionData({
186
- abi: EmpireSlashingProposerAbi,
187
- functionName: 'submitRoundWinner',
188
- args: [round],
189
- }),
190
- };
191
- }
192
-
193
- /** Tries to extract a PayloadSubmitted event from the given logs. */
194
- public tryExtractPayloadSubmittedEvent(logs: Log[]) {
195
- return tryExtractEvent(logs, this.address.toString(), EmpireSlashingProposerAbi, 'PayloadSubmitted');
196
- }
197
-
198
- /**
199
- * Wait for a round to be reached.
200
- *
201
- * @param round - The round to wait for.
202
- * @param pollingIntervalSeconds - The interval in seconds to poll for the round.
203
- * @returns True if the round was reached, false otherwise.
204
- */
205
- public waitForRound(round: bigint, pollingIntervalSeconds: number = 1): Promise<boolean> {
206
- return retryUntil(
207
- async () => {
208
- const currentRound = await this.proposer.read.getCurrentRound().catch(e => {
209
- this.logger.error('Error getting current round', e);
210
- return undefined;
211
- });
212
- return currentRound !== undefined && currentRound >= round;
213
- },
214
- `Waiting for round ${round} to be reached`,
215
- 0, // no timeout
216
- pollingIntervalSeconds,
217
- ).catch(() => false);
218
- }
219
-
220
- public async executeRound(
221
- txUtils: L1TxUtils,
222
- round: bigint | number,
223
- ): ReturnType<typeof txUtils.sendAndMonitorTransaction> {
224
- if (typeof round === 'number') {
225
- round = BigInt(round);
226
- }
227
- const request = this.buildExecuteRoundRequest(round);
228
- const response = await txUtils
229
- .sendAndMonitorTransaction(request, {
230
- // Gas estimation is way off for this, likely because we are creating the contract/selector to call
231
- // for the actual slashing dynamically.
232
- gasLimitBufferPercentage: 50, // +50% gas
233
- })
234
- .catch(err => {
235
- if (err instanceof FormattedViemError && err.message.includes('ProposalAlreadyExecuted')) {
236
- throw new ProposalAlreadyExecutedError(round);
237
- }
238
- throw err;
239
- });
240
-
241
- if (response.receipt.status === 'reverted') {
242
- const args = {
243
- abi: EmpireSlashingProposerAbi,
244
- functionName: 'submitRoundWinner' as const,
245
- args: [round] as const,
246
- address: this.address.toString(),
247
- };
248
- const error = await txUtils.tryGetErrorFromRevertedTx(request.data!, args, undefined, []);
249
- if (error?.includes('ProposalAlreadyExecuted')) {
250
- throw new ProposalAlreadyExecutedError(round);
251
- }
252
- const errorMessage = `Failed to execute round ${round}, TxHash: ${response.receipt.transactionHash}, Error: ${
253
- error ?? 'Unknown error'
254
- }`;
255
- throw new Error(errorMessage);
256
- }
257
- return response;
258
- }
259
- }