@aztec/ethereum 0.0.1-commit.9372f48 → 0.0.1-commit.949a33fd8

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 (156) hide show
  1. package/dest/client.d.ts +16 -2
  2. package/dest/client.d.ts.map +1 -1
  3. package/dest/client.js +27 -7
  4. package/dest/config.d.ts +8 -6
  5. package/dest/config.d.ts.map +1 -1
  6. package/dest/config.js +15 -11
  7. package/dest/contracts/chain_state_override.d.ts +38 -0
  8. package/dest/contracts/chain_state_override.d.ts.map +1 -0
  9. package/dest/contracts/chain_state_override.js +100 -0
  10. package/dest/contracts/empire_base.d.ts +3 -1
  11. package/dest/contracts/empire_base.d.ts.map +1 -1
  12. package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
  13. package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
  14. package/dest/contracts/fee_asset_price_oracle.js +651 -0
  15. package/dest/contracts/governance.js +3 -3
  16. package/dest/contracts/governance_proposer.d.ts +3 -1
  17. package/dest/contracts/governance_proposer.d.ts.map +1 -1
  18. package/dest/contracts/governance_proposer.js +9 -0
  19. package/dest/contracts/inbox.d.ts +3 -3
  20. package/dest/contracts/inbox.d.ts.map +1 -1
  21. package/dest/contracts/inbox.js +11 -6
  22. package/dest/contracts/index.d.ts +4 -3
  23. package/dest/contracts/index.d.ts.map +1 -1
  24. package/dest/contracts/index.js +3 -2
  25. package/dest/contracts/multicall.d.ts +51 -2
  26. package/dest/contracts/multicall.d.ts.map +1 -1
  27. package/dest/contracts/multicall.js +85 -0
  28. package/dest/contracts/registry.d.ts +3 -1
  29. package/dest/contracts/registry.d.ts.map +1 -1
  30. package/dest/contracts/registry.js +30 -1
  31. package/dest/contracts/rollup.d.ts +5015 -25
  32. package/dest/contracts/rollup.d.ts.map +1 -1
  33. package/dest/contracts/rollup.js +316 -61
  34. package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
  35. package/dest/contracts/slashing_proposer.d.ts.map +1 -0
  36. package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +13 -15
  37. package/dest/deploy_aztec_l1_contracts.d.ts +4 -8
  38. package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
  39. package/dest/deploy_aztec_l1_contracts.js +39 -26
  40. package/dest/deploy_l1_contract.js +3 -3
  41. package/dest/generated/l1-contracts-defaults.d.ts +2 -2
  42. package/dest/generated/l1-contracts-defaults.js +2 -2
  43. package/dest/l1_artifacts.d.ts +9404 -15792
  44. package/dest/l1_artifacts.d.ts.map +1 -1
  45. package/dest/l1_artifacts.js +9 -24
  46. package/dest/l1_contract_addresses.d.ts +1 -5
  47. package/dest/l1_contract_addresses.d.ts.map +1 -1
  48. package/dest/l1_contract_addresses.js +0 -6
  49. package/dest/l1_reader.d.ts +3 -1
  50. package/dest/l1_reader.d.ts.map +1 -1
  51. package/dest/l1_reader.js +7 -2
  52. package/dest/l1_tx_utils/config.d.ts +7 -1
  53. package/dest/l1_tx_utils/config.d.ts.map +1 -1
  54. package/dest/l1_tx_utils/config.js +14 -1
  55. package/dest/l1_tx_utils/factory.d.ts +18 -10
  56. package/dest/l1_tx_utils/factory.d.ts.map +1 -1
  57. package/dest/l1_tx_utils/factory.js +17 -7
  58. package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +1 -1
  59. package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +1 -1
  60. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
  61. package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
  62. package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
  63. package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
  64. package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
  65. package/dest/l1_tx_utils/index-blobs.js +2 -2
  66. package/dest/l1_tx_utils/index.d.ts +2 -1
  67. package/dest/l1_tx_utils/index.d.ts.map +1 -1
  68. package/dest/l1_tx_utils/index.js +1 -0
  69. package/dest/l1_tx_utils/l1_tx_utils.d.ts +20 -7
  70. package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
  71. package/dest/l1_tx_utils/l1_tx_utils.js +75 -51
  72. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
  73. package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
  74. package/dest/l1_tx_utils/readonly_l1_tx_utils.js +8 -4
  75. package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
  76. package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
  77. package/dest/{test → l1_tx_utils}/tx_delayer.js +62 -34
  78. package/dest/publisher_manager.d.ts +21 -7
  79. package/dest/publisher_manager.d.ts.map +1 -1
  80. package/dest/publisher_manager.js +81 -7
  81. package/dest/queries.d.ts +13 -2
  82. package/dest/queries.d.ts.map +1 -1
  83. package/dest/queries.js +62 -3
  84. package/dest/test/chain_monitor.d.ts +23 -3
  85. package/dest/test/chain_monitor.d.ts.map +1 -1
  86. package/dest/test/chain_monitor.js +38 -2
  87. package/dest/test/eth_cheat_codes.d.ts +6 -4
  88. package/dest/test/eth_cheat_codes.d.ts.map +1 -1
  89. package/dest/test/eth_cheat_codes.js +6 -4
  90. package/dest/test/index.d.ts +1 -3
  91. package/dest/test/index.d.ts.map +1 -1
  92. package/dest/test/index.js +0 -2
  93. package/dest/test/rollup_cheat_codes.d.ts +5 -1
  94. package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
  95. package/dest/test/rollup_cheat_codes.js +9 -1
  96. package/dest/test/start_anvil.d.ts +23 -3
  97. package/dest/test/start_anvil.d.ts.map +1 -1
  98. package/dest/test/start_anvil.js +143 -29
  99. package/dest/test/upgrade_utils.js +2 -2
  100. package/dest/utils.d.ts +1 -1
  101. package/dest/utils.d.ts.map +1 -1
  102. package/dest/utils.js +16 -12
  103. package/package.json +5 -7
  104. package/src/client.ts +28 -2
  105. package/src/config.ts +24 -15
  106. package/src/contracts/chain_state_override.ts +147 -0
  107. package/src/contracts/empire_base.ts +2 -0
  108. package/src/contracts/fee_asset_price_oracle.ts +280 -0
  109. package/src/contracts/governance.ts +3 -3
  110. package/src/contracts/governance_proposer.ts +6 -0
  111. package/src/contracts/inbox.ts +12 -4
  112. package/src/contracts/index.ts +3 -2
  113. package/src/contracts/multicall.ts +65 -1
  114. package/src/contracts/registry.ts +31 -1
  115. package/src/contracts/rollup.ts +345 -61
  116. package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +14 -16
  117. package/src/deploy_aztec_l1_contracts.ts +61 -34
  118. package/src/deploy_l1_contract.ts +3 -3
  119. package/src/generated/l1-contracts-defaults.ts +2 -2
  120. package/src/l1_artifacts.ts +12 -35
  121. package/src/l1_contract_addresses.ts +0 -7
  122. package/src/l1_reader.ts +14 -2
  123. package/src/l1_tx_utils/config.ts +20 -0
  124. package/src/l1_tx_utils/factory.ts +31 -31
  125. package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +1 -1
  126. package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +1 -1
  127. package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
  128. package/src/l1_tx_utils/index-blobs.ts +2 -2
  129. package/src/l1_tx_utils/index.ts +1 -0
  130. package/src/l1_tx_utils/l1_tx_utils.ts +68 -30
  131. package/src/l1_tx_utils/readonly_l1_tx_utils.ts +8 -4
  132. package/src/{test → l1_tx_utils}/tx_delayer.ts +78 -50
  133. package/src/publisher_manager.ts +105 -10
  134. package/src/queries.ts +70 -4
  135. package/src/test/chain_monitor.ts +65 -3
  136. package/src/test/eth_cheat_codes.ts +6 -4
  137. package/src/test/index.ts +0 -2
  138. package/src/test/rollup_cheat_codes.ts +11 -1
  139. package/src/test/start_anvil.ts +177 -29
  140. package/src/test/upgrade_utils.ts +2 -2
  141. package/src/utils.ts +17 -14
  142. package/dest/contracts/empire_slashing_proposer.d.ts +0 -67
  143. package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
  144. package/dest/contracts/empire_slashing_proposer.js +0 -207
  145. package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
  146. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
  147. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
  148. package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
  149. package/dest/test/delayed_tx_utils.d.ts +0 -13
  150. package/dest/test/delayed_tx_utils.d.ts.map +0 -1
  151. package/dest/test/delayed_tx_utils.js +0 -28
  152. package/dest/test/tx_delayer.d.ts +0 -36
  153. package/dest/test/tx_delayer.d.ts.map +0 -1
  154. package/src/contracts/empire_slashing_proposer.ts +0 -259
  155. package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
  156. package/src/test/delayed_tx_utils.ts +0 -52
@@ -1,3 +1,4 @@
1
+ import { maxBigint } from '@aztec/foundation/bigint';
1
2
  import { CheckpointNumber } from '@aztec/foundation/branded-types';
2
3
  import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
3
4
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -82,10 +83,17 @@ export class InboxContract {
82
83
  .map(log => this.mapMessageSentLog(log));
83
84
  }
84
85
 
85
- /** Fetches MessageSent events for a specific message hash within the given block range. */
86
- async getMessageSentEventByHash(hash: Hex, fromBlock: bigint, toBlock: bigint): Promise<MessageSentLog[]> {
87
- const logs = await this.inbox.getEvents.MessageSent({ hash }, { fromBlock, toBlock });
88
- return logs.map(log => this.mapMessageSentLog(log));
86
+ /** Fetches MessageSent events for a specific message hash around a specific block. */
87
+ async getMessageSentEventByHash(msgHash: Hex, aroundL1BlockNumber: bigint): Promise<MessageSentLog> {
88
+ // We don't use blockHash here because we don't want the query to throw if the L1 block number no longer exists on chain
89
+ // due to an L1 reorg. The use case for this method is usually checking if a message still exists on the Inbox after
90
+ // a reorg, so it's possible the message was moved one block up or down, and that the original L1 block where we
91
+ // saw it no longer exists, rendering the block-by-hash approach invalid.
92
+ const [log] = await this.inbox.getEvents.MessageSent(
93
+ { hash: msgHash },
94
+ { fromBlock: maxBigint(aroundL1BlockNumber - 5n, 1n), toBlock: aroundL1BlockNumber + 5n },
95
+ );
96
+ return log && this.mapMessageSentLog(log);
89
97
  }
90
98
 
91
99
  private mapMessageSentLog(log: {
@@ -1,6 +1,8 @@
1
+ export * from './chain_state_override.js';
1
2
  export * from './empire_base.js';
2
3
  export * from './errors.js';
3
4
  export * from './fee_asset_handler.js';
5
+ export * from './fee_asset_price_oracle.js';
4
6
  export * from './fee_juice.js';
5
7
  export * from './governance.js';
6
8
  export * from './governance_proposer.js';
@@ -11,6 +13,5 @@ export * from './multicall.js';
11
13
  export * from './outbox.js';
12
14
  export * from './registry.js';
13
15
  export * from './rollup.js';
14
- export * from './empire_slashing_proposer.js';
15
- export * from './tally_slashing_proposer.js';
16
+ export * from './slashing_proposer.js';
16
17
  export * from './slasher_contract.js';
@@ -2,7 +2,7 @@ import { toHex as toPaddedHex } from '@aztec/foundation/bigint-buffer';
2
2
  import { TimeoutError } from '@aztec/foundation/error';
3
3
  import type { Logger } from '@aztec/foundation/log';
4
4
 
5
- import { type EncodeFunctionDataParameters, type Hex, encodeFunctionData, multicall3Abi } from 'viem';
5
+ import { type Address, type EncodeFunctionDataParameters, type Hex, encodeFunctionData, multicall3Abi } from 'viem';
6
6
 
7
7
  import type { L1BlobInputs, L1TxConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils/index.js';
8
8
  import type { ExtendedViemWalletClient } from '../types.js';
@@ -11,6 +11,39 @@ import { RollupContract } from './rollup.js';
11
11
 
12
12
  export const MULTI_CALL_3_ADDRESS = '0xcA11bde05977b3631167028862bE2a173976CA11' as const;
13
13
 
14
+ /** ABI fragment for aggregate3Value — not included in viem's multicall3Abi. */
15
+ export const aggregate3ValueAbi = [
16
+ {
17
+ inputs: [
18
+ {
19
+ components: [
20
+ { internalType: 'address', name: 'target', type: 'address' },
21
+ { internalType: 'bool', name: 'allowFailure', type: 'bool' },
22
+ { internalType: 'uint256', name: 'value', type: 'uint256' },
23
+ { internalType: 'bytes', name: 'callData', type: 'bytes' },
24
+ ],
25
+ internalType: 'struct Multicall3.Call3Value[]',
26
+ name: 'calls',
27
+ type: 'tuple[]',
28
+ },
29
+ ],
30
+ name: 'aggregate3Value',
31
+ outputs: [
32
+ {
33
+ components: [
34
+ { internalType: 'bool', name: 'success', type: 'bool' },
35
+ { internalType: 'bytes', name: 'returnData', type: 'bytes' },
36
+ ],
37
+ internalType: 'struct Multicall3.Result[]',
38
+ name: 'returnData',
39
+ type: 'tuple[]',
40
+ },
41
+ ],
42
+ stateMutability: 'payable',
43
+ type: 'function',
44
+ },
45
+ ] as const;
46
+
14
47
  export class Multicall3 {
15
48
  static async forward(
16
49
  requests: L1TxRequest[],
@@ -122,6 +155,37 @@ export class Multicall3 {
122
155
  throw err;
123
156
  }
124
157
  }
158
+
159
+ /** Batch multiple value transfers into a single aggregate3Value call on Multicall3. */
160
+ static async forwardValue(calls: { to: Address; value: bigint }[], l1TxUtils: L1TxUtils, logger: Logger) {
161
+ const args = calls.map(c => ({
162
+ target: c.to,
163
+ allowFailure: false,
164
+ value: c.value,
165
+ callData: '0x' as Hex,
166
+ }));
167
+
168
+ const data = encodeFunctionData({
169
+ abi: aggregate3ValueAbi,
170
+ functionName: 'aggregate3Value',
171
+ args: [args],
172
+ });
173
+
174
+ const totalValue = calls.reduce((sum, c) => sum + c.value, 0n);
175
+
176
+ logger.info(`Sending aggregate3Value with ${calls.length} calls`, { totalValue });
177
+ const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
178
+ to: MULTI_CALL_3_ADDRESS,
179
+ data,
180
+ value: totalValue,
181
+ });
182
+
183
+ if (receipt.status !== 'success') {
184
+ throw new Error(`aggregate3Value transaction reverted: ${receipt.transactionHash}`);
185
+ }
186
+
187
+ return { receipt };
188
+ }
125
189
  }
126
190
 
127
191
  export async function deployMulticall3(l1Client: ExtendedViemWalletClient, logger: Logger) {
@@ -3,7 +3,7 @@ import { createLogger } from '@aztec/foundation/log';
3
3
  import { RegistryAbi } from '@aztec/l1-artifacts/RegistryAbi';
4
4
  import { TestERC20Abi } from '@aztec/l1-artifacts/TestERC20Abi';
5
5
 
6
- import { type GetContractReturnType, type Hex, getContract } from 'viem';
6
+ import { type GetContractReturnType, type Hex, getAbiItem, getContract } from 'viem';
7
7
 
8
8
  import type { L1ContractAddresses } from '../l1_contract_addresses.js';
9
9
  import type { ViemClient } from '../types.js';
@@ -128,4 +128,34 @@ export class RegistryContract {
128
128
  public async getRewardDistributor(): Promise<EthAddress> {
129
129
  return EthAddress.fromString(await this.registry.read.getRewardDistributor());
130
130
  }
131
+
132
+ /** Returns the L1 timestamp at which the given rollup was registered via addRollup(). */
133
+ public async getCanonicalRollupRegistrationTimestamp(
134
+ rollupAddress: EthAddress,
135
+ fromBlock?: bigint,
136
+ ): Promise<bigint | undefined> {
137
+ const event = getAbiItem({ abi: RegistryAbi, name: 'CanonicalRollupUpdated' });
138
+ const start = fromBlock ?? 0n;
139
+ const latestBlock = await this.client.getBlockNumber();
140
+ const chunkSize = 1_000n;
141
+
142
+ for (let from = start; from <= latestBlock; from += chunkSize) {
143
+ const to = from + chunkSize - 1n > latestBlock ? latestBlock : from + chunkSize - 1n;
144
+ const logs = await this.client.getLogs({
145
+ address: this.address.toString(),
146
+ fromBlock: from,
147
+ toBlock: to,
148
+ strict: true,
149
+ event,
150
+ args: { instance: rollupAddress.toString() },
151
+ });
152
+
153
+ if (logs.length > 0) {
154
+ const block = await this.client.getBlock({ blockNumber: logs[0].blockNumber });
155
+ return block.timestamp;
156
+ }
157
+ }
158
+
159
+ return undefined;
160
+ }
131
161
  }