@aztec/stdlib 0.0.1-commit.35158ae7e → 0.0.1-commit.3750d92a7

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 (290) hide show
  1. package/dest/abi/authorization_selector.d.ts +3 -6
  2. package/dest/abi/authorization_selector.d.ts.map +1 -1
  3. package/dest/abi/decoder.d.ts +5 -44
  4. package/dest/abi/decoder.d.ts.map +1 -1
  5. package/dest/abi/decoder.js +12 -67
  6. package/dest/abi/event_selector.d.ts +3 -6
  7. package/dest/abi/event_selector.d.ts.map +1 -1
  8. package/dest/abi/function_selector.d.ts +3 -6
  9. package/dest/abi/function_selector.d.ts.map +1 -1
  10. package/dest/abi/function_selector.js +2 -4
  11. package/dest/abi/function_signature_decoder.d.ts +43 -0
  12. package/dest/abi/function_signature_decoder.d.ts.map +1 -0
  13. package/dest/abi/function_signature_decoder.js +66 -0
  14. package/dest/abi/index.d.ts +2 -1
  15. package/dest/abi/index.d.ts.map +1 -1
  16. package/dest/abi/index.js +1 -0
  17. package/dest/abi/note_selector.d.ts +3 -6
  18. package/dest/abi/note_selector.d.ts.map +1 -1
  19. package/dest/abi/note_selector.js +1 -3
  20. package/dest/abi/selector.d.ts +2 -2
  21. package/dest/abi/selector.d.ts.map +1 -1
  22. package/dest/abi/selector.js +1 -1
  23. package/dest/avm/avm.d.ts +300 -300
  24. package/dest/avm/revert_code.d.ts +8 -18
  25. package/dest/avm/revert_code.d.ts.map +1 -1
  26. package/dest/avm/revert_code.js +15 -30
  27. package/dest/aztec-address/index.d.ts +3 -6
  28. package/dest/aztec-address/index.d.ts.map +1 -1
  29. package/dest/aztec-address/index.js +2 -4
  30. package/dest/block/block_data.d.ts +8 -8
  31. package/dest/block/block_data.d.ts.map +1 -1
  32. package/dest/block/block_data.js +2 -2
  33. package/dest/block/block_hash.d.ts +11 -10
  34. package/dest/block/block_hash.d.ts.map +1 -1
  35. package/dest/block/block_hash.js +10 -9
  36. package/dest/block/l2_block_info.d.ts +6 -5
  37. package/dest/block/l2_block_info.d.ts.map +1 -1
  38. package/dest/block/l2_block_info.js +6 -5
  39. package/dest/block/l2_block_source.d.ts +80 -3
  40. package/dest/block/l2_block_source.d.ts.map +1 -1
  41. package/dest/block/l2_block_source.js +1 -0
  42. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  43. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  44. package/dest/block/l2_block_stream/l2_tips_store_base.js +18 -5
  45. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  46. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  47. package/dest/block/test/l2_tips_store_test_suite.js +4 -3
  48. package/dest/checkpoint/checkpoint.d.ts +7 -1
  49. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  50. package/dest/checkpoint/checkpoint.js +9 -1
  51. package/dest/checkpoint/checkpoint_data.d.ts +71 -5
  52. package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
  53. package/dest/checkpoint/checkpoint_data.js +10 -0
  54. package/dest/config/chain-config.d.ts +1 -1
  55. package/dest/config/chain-config.d.ts.map +1 -1
  56. package/dest/config/chain-config.js +7 -1
  57. package/dest/config/sequencer-config.d.ts +2 -2
  58. package/dest/config/sequencer-config.d.ts.map +1 -1
  59. package/dest/config/sequencer-config.js +10 -3
  60. package/dest/epoch-helpers/index.d.ts +5 -1
  61. package/dest/epoch-helpers/index.d.ts.map +1 -1
  62. package/dest/epoch-helpers/index.js +6 -0
  63. package/dest/file-store/factory.d.ts +4 -3
  64. package/dest/file-store/factory.d.ts.map +1 -1
  65. package/dest/file-store/factory.js +2 -2
  66. package/dest/file-store/http.d.ts +9 -2
  67. package/dest/file-store/http.d.ts.map +1 -1
  68. package/dest/file-store/http.js +20 -9
  69. package/dest/file-store/index.d.ts +2 -1
  70. package/dest/file-store/index.d.ts.map +1 -1
  71. package/dest/gas/fee_math.d.ts +49 -0
  72. package/dest/gas/fee_math.d.ts.map +1 -0
  73. package/dest/gas/fee_math.js +80 -0
  74. package/dest/gas/gas_fees.d.ts +1 -1
  75. package/dest/gas/gas_fees.d.ts.map +1 -1
  76. package/dest/gas/gas_fees.js +10 -1
  77. package/dest/gas/gas_settings.d.ts +40 -3
  78. package/dest/gas/gas_settings.d.ts.map +1 -1
  79. package/dest/gas/gas_settings.js +50 -6
  80. package/dest/gas/index.d.ts +2 -1
  81. package/dest/gas/index.d.ts.map +1 -1
  82. package/dest/gas/index.js +1 -0
  83. package/dest/ha-signing/index.d.ts +2 -2
  84. package/dest/ha-signing/index.d.ts.map +1 -1
  85. package/dest/ha-signing/index.js +1 -1
  86. package/dest/ha-signing/local_config.js +1 -1
  87. package/dest/ha-signing/types.d.ts +37 -32
  88. package/dest/ha-signing/types.d.ts.map +1 -1
  89. package/dest/ha-signing/types.js +13 -6
  90. package/dest/hash/hash.d.ts +4 -1
  91. package/dest/hash/hash.d.ts.map +1 -1
  92. package/dest/hash/hash.js +5 -0
  93. package/dest/interfaces/archiver.d.ts +1 -1
  94. package/dest/interfaces/archiver.d.ts.map +1 -1
  95. package/dest/interfaces/archiver.js +3 -1
  96. package/dest/interfaces/aztec-node-admin.d.ts +4 -14
  97. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  98. package/dest/interfaces/aztec-node-admin.js +3 -3
  99. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  100. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  101. package/dest/interfaces/aztec-node-debug.js +18 -0
  102. package/dest/interfaces/aztec-node.d.ts +10 -1
  103. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  104. package/dest/interfaces/aztec-node.js +2 -0
  105. package/dest/interfaces/client.d.ts +2 -1
  106. package/dest/interfaces/client.d.ts.map +1 -1
  107. package/dest/interfaces/client.js +1 -0
  108. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  109. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  110. package/dest/interfaces/prover-client.d.ts +1 -1
  111. package/dest/interfaces/prover-client.d.ts.map +1 -1
  112. package/dest/interfaces/prover-client.js +0 -3
  113. package/dest/interfaces/slasher.d.ts +1 -10
  114. package/dest/interfaces/slasher.d.ts.map +1 -1
  115. package/dest/interfaces/slasher.js +0 -2
  116. package/dest/interfaces/validator.d.ts +9 -20
  117. package/dest/interfaces/validator.d.ts.map +1 -1
  118. package/dest/interfaces/validator.js +0 -1
  119. package/dest/l1-contracts/index.d.ts +2 -2
  120. package/dest/l1-contracts/index.d.ts.map +1 -1
  121. package/dest/l1-contracts/index.js +1 -1
  122. package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
  123. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
  124. package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
  125. package/dest/logs/log_id.d.ts +1 -1
  126. package/dest/logs/log_id.d.ts.map +1 -1
  127. package/dest/logs/log_id.js +1 -2
  128. package/dest/logs/message_context.d.ts +4 -7
  129. package/dest/logs/message_context.d.ts.map +1 -1
  130. package/dest/logs/message_context.js +23 -9
  131. package/dest/logs/pending_tagged_log.d.ts +2 -3
  132. package/dest/logs/pending_tagged_log.d.ts.map +1 -1
  133. package/dest/logs/pending_tagged_log.js +2 -2
  134. package/dest/logs/shared_secret_derivation.d.ts +11 -10
  135. package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
  136. package/dest/logs/shared_secret_derivation.js +15 -9
  137. package/dest/logs/siloed_tag.d.ts +8 -7
  138. package/dest/logs/siloed_tag.d.ts.map +1 -1
  139. package/dest/logs/siloed_tag.js +11 -3
  140. package/dest/logs/tag.d.ts +5 -6
  141. package/dest/logs/tag.d.ts.map +1 -1
  142. package/dest/logs/tag.js +4 -0
  143. package/dest/note/note_dao.d.ts +1 -1
  144. package/dest/note/note_dao.d.ts.map +1 -1
  145. package/dest/note/note_dao.js +1 -4
  146. package/dest/p2p/block_proposal.d.ts +6 -8
  147. package/dest/p2p/block_proposal.d.ts.map +1 -1
  148. package/dest/p2p/block_proposal.js +4 -9
  149. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  150. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  151. package/dest/p2p/checkpoint_attestation.js +2 -7
  152. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  153. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  154. package/dest/p2p/checkpoint_proposal.js +5 -24
  155. package/dest/p2p/gossipable.d.ts +4 -4
  156. package/dest/p2p/gossipable.d.ts.map +1 -1
  157. package/dest/slashing/index.d.ts +2 -3
  158. package/dest/slashing/index.d.ts.map +1 -1
  159. package/dest/slashing/index.js +1 -2
  160. package/dest/slashing/serialization.d.ts +2 -6
  161. package/dest/slashing/serialization.d.ts.map +1 -1
  162. package/dest/slashing/serialization.js +0 -60
  163. package/dest/slashing/types.d.ts +4 -90
  164. package/dest/slashing/types.d.ts.map +1 -1
  165. package/dest/slashing/types.js +0 -14
  166. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  167. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  168. package/dest/slashing/{tally.js → votes.js} +1 -1
  169. package/dest/tests/factories.d.ts +1 -1
  170. package/dest/tests/factories.d.ts.map +1 -1
  171. package/dest/tests/factories.js +11 -1
  172. package/dest/tests/mocks.d.ts +1 -1
  173. package/dest/tests/mocks.d.ts.map +1 -1
  174. package/dest/tests/mocks.js +14 -19
  175. package/dest/timetable/index.d.ts +51 -1
  176. package/dest/timetable/index.d.ts.map +1 -1
  177. package/dest/timetable/index.js +204 -14
  178. package/dest/tx/block_header.d.ts +2 -2
  179. package/dest/tx/block_header.d.ts.map +1 -1
  180. package/dest/tx/block_header.js +1 -1
  181. package/dest/tx/capsule.d.ts +6 -2
  182. package/dest/tx/capsule.d.ts.map +1 -1
  183. package/dest/tx/capsule.js +9 -3
  184. package/dest/tx/fee_provider.d.ts +10 -0
  185. package/dest/tx/fee_provider.d.ts.map +1 -0
  186. package/dest/tx/fee_provider.js +1 -0
  187. package/dest/tx/global_variable_builder.d.ts +3 -4
  188. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  189. package/dest/tx/index.d.ts +2 -1
  190. package/dest/tx/index.d.ts.map +1 -1
  191. package/dest/tx/index.js +1 -0
  192. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  193. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  194. package/dest/tx/indexed_tx_effect.js +1 -2
  195. package/dest/tx/simulated_tx.d.ts +4 -4
  196. package/dest/tx/simulated_tx.d.ts.map +1 -1
  197. package/dest/tx/simulated_tx.js +3 -3
  198. package/dest/tx/tx.d.ts +3 -3
  199. package/dest/tx/tx.d.ts.map +1 -1
  200. package/dest/tx/tx_receipt.d.ts +8 -4
  201. package/dest/tx/tx_receipt.d.ts.map +1 -1
  202. package/dest/tx/tx_receipt.js +8 -15
  203. package/dest/world-state/genesis_data.d.ts +11 -0
  204. package/dest/world-state/genesis_data.d.ts.map +1 -0
  205. package/dest/world-state/genesis_data.js +4 -0
  206. package/dest/world-state/index.d.ts +2 -1
  207. package/dest/world-state/index.d.ts.map +1 -1
  208. package/dest/world-state/index.js +1 -0
  209. package/package.json +8 -8
  210. package/src/abi/authorization_selector.ts +2 -8
  211. package/src/abi/decoder.ts +23 -78
  212. package/src/abi/event_selector.ts +2 -8
  213. package/src/abi/function_selector.ts +4 -13
  214. package/src/abi/function_signature_decoder.ts +77 -0
  215. package/src/abi/index.ts +1 -0
  216. package/src/abi/note_selector.ts +3 -12
  217. package/src/abi/selector.ts +1 -1
  218. package/src/avm/revert_code.ts +25 -39
  219. package/src/aztec-address/index.ts +4 -10
  220. package/src/block/block_data.ts +3 -4
  221. package/src/block/block_hash.ts +21 -14
  222. package/src/block/l2_block_info.ts +8 -6
  223. package/src/block/l2_block_source.ts +10 -2
  224. package/src/block/l2_block_stream/l2_tips_store_base.ts +25 -13
  225. package/src/block/test/l2_tips_store_test_suite.ts +9 -2
  226. package/src/checkpoint/checkpoint.ts +11 -1
  227. package/src/checkpoint/checkpoint_data.ts +40 -4
  228. package/src/config/chain-config.ts +7 -1
  229. package/src/config/sequencer-config.ts +14 -4
  230. package/src/epoch-helpers/index.ts +13 -0
  231. package/src/file-store/factory.ts +13 -4
  232. package/src/file-store/http.ts +29 -10
  233. package/src/file-store/index.ts +1 -0
  234. package/src/gas/README.md +31 -0
  235. package/src/gas/fee_math.ts +120 -0
  236. package/src/gas/gas_fees.ts +12 -4
  237. package/src/gas/gas_settings.ts +65 -12
  238. package/src/gas/index.ts +1 -0
  239. package/src/ha-signing/index.ts +3 -1
  240. package/src/ha-signing/local_config.ts +1 -1
  241. package/src/ha-signing/types.ts +48 -34
  242. package/src/hash/hash.ts +5 -0
  243. package/src/interfaces/archiver.ts +3 -1
  244. package/src/interfaces/aztec-node-admin.ts +5 -7
  245. package/src/interfaces/aztec-node-debug.ts +40 -0
  246. package/src/interfaces/aztec-node.ts +15 -0
  247. package/src/interfaces/client.ts +1 -0
  248. package/src/interfaces/merkle_tree_operations.ts +3 -2
  249. package/src/interfaces/prover-client.ts +2 -5
  250. package/src/interfaces/slasher.ts +0 -6
  251. package/src/interfaces/validator.ts +16 -13
  252. package/src/l1-contracts/index.ts +1 -1
  253. package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
  254. package/src/logs/log_id.ts +1 -2
  255. package/src/logs/message_context.ts +17 -7
  256. package/src/logs/pending_tagged_log.ts +1 -3
  257. package/src/logs/shared_secret_derivation.ts +21 -10
  258. package/src/logs/siloed_tag.ts +15 -11
  259. package/src/logs/tag.ts +8 -8
  260. package/src/note/note_dao.ts +1 -4
  261. package/src/p2p/block_proposal.ts +13 -9
  262. package/src/p2p/checkpoint_attestation.ts +5 -9
  263. package/src/p2p/checkpoint_proposal.ts +21 -36
  264. package/src/p2p/gossipable.ts +4 -4
  265. package/src/slashing/index.ts +1 -2
  266. package/src/slashing/serialization.ts +1 -81
  267. package/src/slashing/types.ts +3 -35
  268. package/src/slashing/{tally.ts → votes.ts} +1 -1
  269. package/src/tests/factories.ts +5 -1
  270. package/src/tests/mocks.ts +16 -12
  271. package/src/timetable/index.ts +293 -13
  272. package/src/tx/block_header.ts +2 -2
  273. package/src/tx/capsule.ts +10 -2
  274. package/src/tx/fee_provider.ts +10 -0
  275. package/src/tx/global_variable_builder.ts +2 -3
  276. package/src/tx/index.ts +1 -0
  277. package/src/tx/indexed_tx_effect.ts +1 -2
  278. package/src/tx/simulated_tx.ts +6 -2
  279. package/src/tx/tx.ts +2 -2
  280. package/src/tx/tx_receipt.ts +11 -14
  281. package/src/world-state/genesis_data.ts +15 -0
  282. package/src/world-state/index.ts +1 -0
  283. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  284. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  285. package/dest/l1-contracts/slash_factory.js +0 -158
  286. package/dest/slashing/empire.d.ts +0 -31
  287. package/dest/slashing/empire.d.ts.map +0 -1
  288. package/dest/slashing/empire.js +0 -87
  289. package/src/l1-contracts/slash_factory.ts +0 -180
  290. package/src/slashing/empire.ts +0 -104
@@ -1,5 +1,10 @@
1
- import { BlockNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import {
2
+ type CheckpointNumber,
3
+ CheckpointProposalHash,
4
+ IndexWithinCheckpoint,
5
+ SlotNumber,
6
+ } from '@aztec/foundation/branded-types';
7
+ import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
3
8
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
9
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
10
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -24,12 +29,7 @@ import {
24
29
  import { SignedTxs } from './signed_txs.js';
25
30
  import { TopicType } from './topic_type.js';
26
31
 
27
- // REFACTOR(palla): Use a branded type instead of a subclass of Buffer32
28
- export class CheckpointProposalHash extends Buffer32 {
29
- constructor(hash: Buffer) {
30
- super(hash);
31
- }
32
- }
32
+ export type { CheckpointProposalHash } from '@aztec/foundation/branded-types';
33
33
 
34
34
  export type CheckpointProposalOptions = {
35
35
  /**
@@ -93,8 +93,8 @@ export class CheckpointProposal extends Gossipable {
93
93
  super();
94
94
  }
95
95
 
96
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
97
- return Promise.resolve(new CheckpointProposalHash(keccak256(this.signature.toBuffer())));
96
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
97
+ return Promise.resolve(CheckpointProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
98
98
  }
99
99
 
100
100
  get slotNumber(): SlotNumber {
@@ -160,8 +160,9 @@ export class CheckpointProposal extends Gossipable {
160
160
  static async createProposalFromSigner(
161
161
  checkpointHeader: CheckpointHeader,
162
162
  archiveRoot: Fr,
163
+ checkpointNumber: CheckpointNumber,
163
164
  feeAssetPriceModifier: bigint,
164
- lastBlockInfo: CheckpointLastBlockData | undefined,
165
+ lastBlockProposal: BlockProposal | undefined,
165
166
  payloadSigner: (payload: Buffer32, context: SigningContext) => Promise<Signature>,
166
167
  ): Promise<CheckpointProposal> {
167
168
  // Sign the checkpoint payload with CHECKPOINT_PROPOSAL duty type
@@ -175,35 +176,19 @@ export class CheckpointProposal extends Gossipable {
175
176
 
176
177
  const checkpointContext: SigningContext = {
177
178
  slot: checkpointHeader.slotNumber,
178
- blockNumber: lastBlockInfo?.blockHeader?.globalVariables.blockNumber ?? BlockNumber(0),
179
+ checkpointNumber,
179
180
  dutyType: DutyType.CHECKPOINT_PROPOSAL,
180
181
  };
181
182
 
182
- if (lastBlockInfo) {
183
- // Sign block proposal before signing checkpoint proposal to ensure HA protection
184
- const lastBlockProposal = await BlockProposal.createProposalFromSigner(
185
- lastBlockInfo.blockHeader,
186
- lastBlockInfo.indexWithinCheckpoint,
187
- checkpointHeader.inHash,
188
- archiveRoot,
189
- lastBlockInfo.txHashes,
190
- lastBlockInfo.txs,
191
- payloadSigner,
192
- );
193
-
194
- const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
195
-
196
- return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
197
- blockHeader: lastBlockInfo.blockHeader,
198
- indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
199
- txHashes: lastBlockInfo.txHashes,
200
- signature: lastBlockProposal.signature,
201
- signedTxs: lastBlockProposal.signedTxs,
202
- });
203
- }
204
-
205
183
  const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
206
- return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
184
+
185
+ return new CheckpointProposal(
186
+ checkpointHeader,
187
+ archiveRoot,
188
+ feeAssetPriceModifier,
189
+ checkpointSignature,
190
+ lastBlockProposal,
191
+ );
207
192
  }
208
193
 
209
194
  /**
@@ -1,4 +1,4 @@
1
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import { BaseBuffer32 } from '@aztec/foundation/buffer';
2
2
  import { BufferReader, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize';
3
3
 
4
4
  import type { TopicType } from './topic_type.js';
@@ -46,7 +46,7 @@ export class P2PMessage {
46
46
  * Any class which extends gossipable will be able to be Gossiped over the p2p network
47
47
  */
48
48
  export abstract class Gossipable {
49
- private cachedId: Buffer32 | undefined;
49
+ private cachedId: BaseBuffer32 | undefined;
50
50
  /** The p2p topic identifier, this determines how the message is handled */
51
51
  static p2pTopic: TopicType;
52
52
 
@@ -54,7 +54,7 @@ export abstract class Gossipable {
54
54
  * A digest of the message information **used for logging only**.
55
55
  * The identifier used for deduplication is `getMsgIdFn` as defined in `encoding.ts` which is a hash over topic and data.
56
56
  */
57
- async p2pMessageLoggingIdentifier(): Promise<Buffer32> {
57
+ async p2pMessageLoggingIdentifier(): Promise<BaseBuffer32> {
58
58
  if (this.cachedId) {
59
59
  return this.cachedId;
60
60
  }
@@ -62,7 +62,7 @@ export abstract class Gossipable {
62
62
  return this.cachedId;
63
63
  }
64
64
 
65
- abstract generateP2PMessageIdentifier(): Promise<Buffer32>;
65
+ abstract generateP2PMessageIdentifier(): Promise<BaseBuffer32>;
66
66
 
67
67
  abstract toBuffer(): Buffer;
68
68
 
@@ -1,6 +1,5 @@
1
1
  export * from './types.js';
2
2
  export * from './interfaces.js';
3
3
  export * from './helpers.js';
4
- export * from './empire.js';
5
- export * from './tally.js';
4
+ export * from './votes.js';
6
5
  export * from './serialization.js';
@@ -1,15 +1,7 @@
1
- import { times } from '@aztec/foundation/collection';
2
1
  import { EthAddress } from '@aztec/foundation/eth-address';
3
2
  import { BufferReader, bigintToUInt64BE, bigintToUInt128BE, serializeToBuffer } from '@aztec/foundation/serialize';
4
3
 
5
- import type {
6
- Offense,
7
- OffenseType,
8
- SlashPayload,
9
- SlashPayloadRound,
10
- ValidatorSlash,
11
- ValidatorSlashOffense,
12
- } from './types.js';
4
+ import type { Offense, OffenseType } from './types.js';
13
5
 
14
6
  export function serializeOffense(offense: Offense): Buffer {
15
7
  return serializeToBuffer(
@@ -29,75 +21,3 @@ export function deserializeOffense(buffer: Buffer): Offense {
29
21
 
30
22
  return { validator, amount, offenseType: offense, epochOrSlot };
31
23
  }
32
-
33
- function serializeValidatorSlashOffense(offense: ValidatorSlashOffense): Buffer {
34
- return serializeToBuffer(bigintToUInt64BE(offense.epochOrSlot), offense.offenseType);
35
- }
36
-
37
- function deserializeValidatorSlashOffense(buffer: Buffer | BufferReader): ValidatorSlashOffense {
38
- const reader = BufferReader.asReader(buffer);
39
- return {
40
- epochOrSlot: reader.readUInt64(),
41
- offenseType: reader.readNumber() as OffenseType,
42
- };
43
- }
44
-
45
- function serializeValidatorSlash(slash: ValidatorSlash): Buffer {
46
- return serializeToBuffer(
47
- slash.validator,
48
- bigintToUInt128BE(slash.amount),
49
- slash.offenses.length,
50
- slash.offenses.map(serializeValidatorSlashOffense),
51
- );
52
- }
53
-
54
- function deserializeValidatorSlash(buffer: Buffer | BufferReader): ValidatorSlash {
55
- const reader = BufferReader.asReader(buffer);
56
- const validator = reader.readObject(EthAddress);
57
- const amount = reader.readUInt128();
58
- const offensesCount = reader.readNumber();
59
- const offenses = times(offensesCount, () => deserializeValidatorSlashOffense(reader));
60
-
61
- return { validator, amount, offenses };
62
- }
63
-
64
- export function serializeSlashPayload(payload: SlashPayload): Buffer {
65
- return serializeToBuffer(
66
- payload.address,
67
- payload.slashes.length,
68
- payload.slashes.map(serializeValidatorSlash),
69
- bigintToUInt64BE(payload.timestamp),
70
- );
71
- }
72
-
73
- export function deserializeSlashPayload(buffer: Buffer): SlashPayload {
74
- const reader = BufferReader.asReader(buffer);
75
- const address = reader.readObject(EthAddress);
76
- const slashesCount = reader.readNumber();
77
- const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
78
- const timestamp = reader.readUInt64();
79
- return { address, slashes, timestamp };
80
- }
81
-
82
- export function serializeSlashPayloadRound(payload: SlashPayloadRound): Buffer {
83
- return serializeToBuffer(
84
- payload.address,
85
- payload.slashes.length,
86
- payload.slashes.map(serializeValidatorSlash),
87
- bigintToUInt64BE(payload.timestamp),
88
- Number(payload.votes),
89
- bigintToUInt64BE(payload.round),
90
- );
91
- }
92
-
93
- export function deserializeSlashPayloadRound(buffer: Buffer): SlashPayloadRound {
94
- const reader = BufferReader.asReader(buffer);
95
- const address = reader.readObject(EthAddress);
96
- const slashesCount = reader.readNumber();
97
- const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
98
- const timestamp = reader.readUInt64();
99
- const votes = BigInt(reader.readNumber());
100
- const round = reader.readUInt64();
101
-
102
- return { address, slashes, timestamp, votes, round };
103
- }
@@ -126,45 +126,13 @@ export type ValidatorSlash = {
126
126
  offenses: ValidatorSlashOffense[];
127
127
  };
128
128
 
129
- /** Slash payload as published by the empire slash proposer */
130
- export type SlashPayload = {
131
- address: EthAddress;
132
- slashes: ValidatorSlash[];
133
- timestamp: bigint;
134
- };
135
-
136
- /** Slash payload with round information from empire slash proposer */
137
- export type SlashPayloadRound = SlashPayload & { votes: bigint; round: bigint };
138
-
139
- export const SlashPayloadRoundSchema = zodFor<SlashPayloadRound>()(
140
- z.object({
141
- address: schemas.EthAddress,
142
- timestamp: schemas.BigInt,
143
- votes: schemas.BigInt,
144
- round: schemas.BigInt,
145
- slashes: z.array(
146
- z.object({
147
- validator: schemas.EthAddress,
148
- amount: schemas.BigInt,
149
- offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
150
- }),
151
- ),
152
- }),
153
- );
154
-
155
- /** Votes for a validator slash in the consensus slash proposer */
129
+ /** Votes for a validator slash in the slashing proposer */
156
130
  export type ValidatorSlashVote = number;
157
131
 
158
132
  export type ProposerSlashAction =
159
- /** Create a new slash payload on an empire-based slash proposer */
160
- | { type: 'create-empire-payload'; data: ValidatorSlash[] }
161
- /** Vote for a slashing payload on an empire-based slash proposer */
162
- | { type: 'vote-empire-payload'; payload: EthAddress }
163
- /** Execute a slashing payload on an empire-based slash proposer */
164
- | { type: 'execute-empire-payload'; round: bigint }
165
- /** Vote for offenses on a consensus slashing proposer */
133
+ /** Vote for offenses on the slashing proposer */
166
134
  | { type: 'vote-offenses'; votes: ValidatorSlashVote[]; committees: EthAddress[][]; round: bigint }
167
- /** Execute a slashing round on a consensus slashing proposer */
135
+ /** Execute a slashing round on the slashing proposer */
168
136
  | { type: 'execute-slash'; committees: EthAddress[][]; round: bigint };
169
137
 
170
138
  export type ProposerSlashActionType = ProposerSlashAction['type'];
@@ -28,7 +28,7 @@ export function getSlashConsensusVotesFromOffenses(
28
28
  targetCommitteeSize: number;
29
29
  maxSlashedValidators?: number;
30
30
  },
31
- logger: Logger = createLogger('slasher:tally'),
31
+ logger: Logger = createLogger('slasher:votes'),
32
32
  ): ValidatorSlashVote[] {
33
33
  const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
34
34
 
@@ -232,7 +232,7 @@ export function makeTxContext(seed: number = 1): TxContext {
232
232
  * Creates a default instance of gas settings. No seed value is used to ensure we allocate a sensible amount of gas for testing.
233
233
  */
234
234
  export function makeGasSettings() {
235
- return GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) });
235
+ return GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) });
236
236
  }
237
237
 
238
238
  /**
@@ -1715,6 +1715,10 @@ export function makeL2Tips(
1715
1715
  block: { number: bn, hash },
1716
1716
  checkpoint: { number: cpn, hash: cph },
1717
1717
  },
1718
+ proposedCheckpoint: {
1719
+ block: { number: bn, hash },
1720
+ checkpoint: { number: cpn, hash: cph },
1721
+ },
1718
1722
  proven: {
1719
1723
  block: { number: bn, hash },
1720
1724
  checkpoint: { number: cpn, hash: cph },
@@ -134,7 +134,7 @@ export const mockTx = async (
134
134
  const data = PrivateKernelTailCircuitPublicInputs.empty();
135
135
  const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
136
136
  data.constants.anchorBlockHeader = anchorBlockHeader;
137
- data.constants.txContext.gasSettings = GasSettings.default({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
137
+ data.constants.txContext.gasSettings = GasSettings.fallback({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
138
138
  data.feePayer = feePayer ?? (await AztecAddress.random());
139
139
  data.gasUsed = gasUsed;
140
140
  data.constants.txContext.chainId = chainId;
@@ -200,7 +200,7 @@ export async function mockProcessedTx({
200
200
  db,
201
201
  chainId = Fr.ZERO,
202
202
  version = Fr.ZERO,
203
- gasSettings = GasSettings.default({ maxFeesPerGas: new GasFees(10, 10) }),
203
+ gasSettings = GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) }),
204
204
  vkTreeRoot = Fr.ZERO,
205
205
  protocolContracts = makeProtocolContracts(seed + 0x100),
206
206
  globalVariables = GlobalVariables.empty(),
@@ -587,6 +587,7 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
587
587
 
588
588
  return BlockProposal.createProposalFromSigner(
589
589
  blockHeader,
590
+ CheckpointNumber(1),
590
591
  indexWithinCheckpoint,
591
592
  inHash,
592
593
  archiveRoot,
@@ -596,28 +597,31 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
596
597
  );
597
598
  };
598
599
 
599
- export const makeCheckpointProposal = (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
600
- const blockHeader = options?.lastBlock?.blockHeader ?? makeBlockHeader(1);
600
+ export const makeCheckpointProposal = async (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
601
601
  const checkpointHeader = options?.checkpointHeader ?? makeCheckpointHeader(1);
602
602
  const archiveRoot = options?.archiveRoot ?? Fr.random();
603
603
  const feeAssetPriceModifier = options?.feeAssetPriceModifier ?? 0n;
604
604
  const signer = options?.signer ?? Secp256k1Signer.random();
605
605
 
606
- // Build lastBlock info if provided
607
- const lastBlockInfo = options?.lastBlock
608
- ? {
609
- blockHeader,
610
- indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4), // Last block in a 5-block checkpoint
611
- txHashes: options.lastBlock.txHashes ?? [0, 1, 2, 3, 4, 5].map(() => TxHash.random()),
606
+ // Build a signed block proposal if lastBlock options are provided
607
+ const lastBlockProposal = options?.lastBlock
608
+ ? await makeBlockProposal({
609
+ blockHeader: options.lastBlock.blockHeader,
610
+ indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4),
611
+ inHash: checkpointHeader.inHash,
612
+ archiveRoot,
613
+ txHashes: options.lastBlock.txHashes,
612
614
  txs: options.lastBlock.txs,
613
- }
615
+ signer,
616
+ })
614
617
  : undefined;
615
618
 
616
619
  return CheckpointProposal.createProposalFromSigner(
617
620
  checkpointHeader,
618
621
  archiveRoot,
622
+ CheckpointNumber(1),
619
623
  feeAssetPriceModifier,
620
- lastBlockInfo,
624
+ lastBlockProposal,
621
625
  payload => Promise.resolve(signer.signMessage(payload)),
622
626
  );
623
627
  };