@aztec/stdlib 0.0.1-commit.d1da697d6 → 0.0.1-commit.d20b825a7

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 (257) 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/encoder.d.ts +1 -1
  4. package/dest/abi/encoder.d.ts.map +1 -1
  5. package/dest/abi/encoder.js +32 -6
  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 +1 -3
  11. package/dest/abi/note_selector.d.ts +3 -6
  12. package/dest/abi/note_selector.d.ts.map +1 -1
  13. package/dest/abi/note_selector.js +1 -3
  14. package/dest/avm/avm.d.ts +300 -300
  15. package/dest/aztec-address/index.d.ts +3 -6
  16. package/dest/aztec-address/index.d.ts.map +1 -1
  17. package/dest/aztec-address/index.js +2 -4
  18. package/dest/block/block_data.d.ts +8 -8
  19. package/dest/block/block_data.d.ts.map +1 -1
  20. package/dest/block/block_data.js +2 -2
  21. package/dest/block/block_hash.d.ts +11 -10
  22. package/dest/block/block_hash.d.ts.map +1 -1
  23. package/dest/block/block_hash.js +10 -9
  24. package/dest/block/l2_block_info.d.ts +6 -5
  25. package/dest/block/l2_block_info.d.ts.map +1 -1
  26. package/dest/block/l2_block_info.js +6 -5
  27. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  28. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  29. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  30. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  31. package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
  32. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  33. package/dest/config/chain-config.d.ts +1 -1
  34. package/dest/config/chain-config.d.ts.map +1 -1
  35. package/dest/config/chain-config.js +7 -1
  36. package/dest/config/sequencer-config.d.ts +2 -2
  37. package/dest/config/sequencer-config.d.ts.map +1 -1
  38. package/dest/config/sequencer-config.js +10 -3
  39. package/dest/contract/contract_address.d.ts +1 -1
  40. package/dest/contract/contract_address.js +2 -2
  41. package/dest/contract/private_function.d.ts +1 -1
  42. package/dest/contract/private_function.d.ts.map +1 -1
  43. package/dest/contract/private_function.js +2 -4
  44. package/dest/gas/fee_math.d.ts +49 -0
  45. package/dest/gas/fee_math.d.ts.map +1 -0
  46. package/dest/gas/fee_math.js +80 -0
  47. package/dest/gas/gas_fees.d.ts +5 -1
  48. package/dest/gas/gas_fees.d.ts.map +1 -1
  49. package/dest/gas/gas_fees.js +10 -1
  50. package/dest/gas/index.d.ts +2 -1
  51. package/dest/gas/index.d.ts.map +1 -1
  52. package/dest/gas/index.js +1 -0
  53. package/dest/ha-signing/config.d.ts +6 -6
  54. package/dest/ha-signing/config.d.ts.map +1 -1
  55. package/dest/ha-signing/config.js +4 -3
  56. package/dest/ha-signing/index.d.ts +2 -2
  57. package/dest/ha-signing/index.d.ts.map +1 -1
  58. package/dest/ha-signing/index.js +1 -1
  59. package/dest/ha-signing/local_config.js +1 -1
  60. package/dest/ha-signing/types.d.ts +37 -32
  61. package/dest/ha-signing/types.d.ts.map +1 -1
  62. package/dest/ha-signing/types.js +13 -6
  63. package/dest/hash/hash.d.ts +16 -1
  64. package/dest/hash/hash.d.ts.map +1 -1
  65. package/dest/hash/hash.js +32 -0
  66. package/dest/interfaces/archiver.d.ts +11 -1
  67. package/dest/interfaces/archiver.d.ts.map +1 -1
  68. package/dest/interfaces/archiver.js +3 -1
  69. package/dest/interfaces/aztec-node-admin.d.ts +8 -14
  70. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  71. package/dest/interfaces/aztec-node-admin.js +1 -2
  72. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  73. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  74. package/dest/interfaces/aztec-node-debug.js +18 -0
  75. package/dest/interfaces/aztec-node.d.ts +10 -1
  76. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  77. package/dest/interfaces/aztec-node.js +2 -0
  78. package/dest/interfaces/client.d.ts +2 -1
  79. package/dest/interfaces/client.d.ts.map +1 -1
  80. package/dest/interfaces/client.js +1 -0
  81. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  82. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  83. package/dest/interfaces/prover-client.d.ts +1 -1
  84. package/dest/interfaces/prover-client.d.ts.map +1 -1
  85. package/dest/interfaces/prover-client.js +0 -3
  86. package/dest/interfaces/slasher.d.ts +1 -10
  87. package/dest/interfaces/slasher.d.ts.map +1 -1
  88. package/dest/interfaces/slasher.js +0 -2
  89. package/dest/interfaces/validator.d.ts +14 -17
  90. package/dest/interfaces/validator.d.ts.map +1 -1
  91. package/dest/l1-contracts/index.d.ts +2 -2
  92. package/dest/l1-contracts/index.d.ts.map +1 -1
  93. package/dest/l1-contracts/index.js +1 -1
  94. package/dest/logs/log_id.d.ts +1 -1
  95. package/dest/logs/log_id.d.ts.map +1 -1
  96. package/dest/logs/log_id.js +1 -2
  97. package/dest/logs/siloed_tag.d.ts +5 -7
  98. package/dest/logs/siloed_tag.d.ts.map +1 -1
  99. package/dest/logs/siloed_tag.js +4 -0
  100. package/dest/logs/tag.d.ts +5 -6
  101. package/dest/logs/tag.d.ts.map +1 -1
  102. package/dest/logs/tag.js +4 -0
  103. package/dest/p2p/block_proposal.d.ts +6 -8
  104. package/dest/p2p/block_proposal.d.ts.map +1 -1
  105. package/dest/p2p/block_proposal.js +4 -9
  106. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  107. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  108. package/dest/p2p/checkpoint_attestation.js +2 -7
  109. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  110. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  111. package/dest/p2p/checkpoint_proposal.js +5 -24
  112. package/dest/p2p/gossipable.d.ts +4 -4
  113. package/dest/p2p/gossipable.d.ts.map +1 -1
  114. package/dest/parity/parity_base_private_inputs.d.ts +7 -3
  115. package/dest/parity/parity_base_private_inputs.d.ts.map +1 -1
  116. package/dest/parity/parity_base_private_inputs.js +7 -5
  117. package/dest/parity/parity_public_inputs.d.ts +7 -3
  118. package/dest/parity/parity_public_inputs.d.ts.map +1 -1
  119. package/dest/parity/parity_public_inputs.js +6 -3
  120. package/dest/rollup/block_headers_hash.d.ts +1 -1
  121. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  122. package/dest/rollup/block_headers_hash.js +8 -2
  123. package/dest/slashing/index.d.ts +2 -3
  124. package/dest/slashing/index.d.ts.map +1 -1
  125. package/dest/slashing/index.js +1 -2
  126. package/dest/slashing/serialization.d.ts +2 -6
  127. package/dest/slashing/serialization.d.ts.map +1 -1
  128. package/dest/slashing/serialization.js +0 -60
  129. package/dest/slashing/types.d.ts +4 -90
  130. package/dest/slashing/types.d.ts.map +1 -1
  131. package/dest/slashing/types.js +0 -14
  132. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  133. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  134. package/dest/slashing/{tally.js → votes.js} +1 -1
  135. package/dest/tests/factories.d.ts +2 -7
  136. package/dest/tests/factories.d.ts.map +1 -1
  137. package/dest/tests/factories.js +8 -18
  138. package/dest/tests/mocks.d.ts +1 -1
  139. package/dest/tests/mocks.d.ts.map +1 -1
  140. package/dest/tests/mocks.js +12 -17
  141. package/dest/timetable/index.d.ts +51 -1
  142. package/dest/timetable/index.d.ts.map +1 -1
  143. package/dest/timetable/index.js +204 -14
  144. package/dest/trees/nullifier_leaf.d.ts +2 -1
  145. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  146. package/dest/trees/nullifier_leaf.js +3 -0
  147. package/dest/tx/block_header.d.ts +2 -2
  148. package/dest/tx/block_header.d.ts.map +1 -1
  149. package/dest/tx/block_header.js +1 -1
  150. package/dest/tx/fee_provider.d.ts +10 -0
  151. package/dest/tx/fee_provider.d.ts.map +1 -0
  152. package/dest/tx/fee_provider.js +1 -0
  153. package/dest/tx/global_variable_builder.d.ts +3 -16
  154. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  155. package/dest/tx/index.d.ts +2 -1
  156. package/dest/tx/index.d.ts.map +1 -1
  157. package/dest/tx/index.js +1 -0
  158. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  159. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  160. package/dest/tx/indexed_tx_effect.js +1 -2
  161. package/dest/tx/simulated_tx.d.ts +1 -1
  162. package/dest/tx/simulated_tx.js +1 -1
  163. package/dest/tx/tx.d.ts +3 -3
  164. package/dest/tx/tx.d.ts.map +1 -1
  165. package/dest/types/shared.d.ts +1 -10
  166. package/dest/types/shared.d.ts.map +1 -1
  167. package/dest/types/shared.js +0 -9
  168. package/dest/vks/verification_key.d.ts +2 -137
  169. package/dest/vks/verification_key.d.ts.map +1 -1
  170. package/dest/vks/verification_key.js +5 -126
  171. package/dest/world-state/genesis_data.d.ts +11 -0
  172. package/dest/world-state/genesis_data.d.ts.map +1 -0
  173. package/dest/world-state/genesis_data.js +4 -0
  174. package/dest/world-state/index.d.ts +2 -1
  175. package/dest/world-state/index.d.ts.map +1 -1
  176. package/dest/world-state/index.js +1 -0
  177. package/dest/world-state/world_state_revision.d.ts +8 -1
  178. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  179. package/dest/world-state/world_state_revision.js +7 -1
  180. package/package.json +8 -8
  181. package/src/abi/authorization_selector.ts +2 -8
  182. package/src/abi/encoder.ts +42 -6
  183. package/src/abi/event_selector.ts +2 -8
  184. package/src/abi/function_selector.ts +3 -12
  185. package/src/abi/note_selector.ts +3 -12
  186. package/src/aztec-address/index.ts +4 -10
  187. package/src/block/block_data.ts +3 -4
  188. package/src/block/block_hash.ts +21 -14
  189. package/src/block/l2_block_info.ts +8 -6
  190. package/src/block/l2_block_stream/interfaces.ts +6 -2
  191. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  192. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  193. package/src/config/chain-config.ts +7 -1
  194. package/src/config/sequencer-config.ts +14 -4
  195. package/src/contract/contract_address.ts +2 -2
  196. package/src/contract/private_function.ts +3 -1
  197. package/src/gas/README.md +31 -0
  198. package/src/gas/fee_math.ts +120 -0
  199. package/src/gas/gas_fees.ts +17 -4
  200. package/src/gas/index.ts +1 -0
  201. package/src/ha-signing/config.ts +5 -2
  202. package/src/ha-signing/index.ts +3 -1
  203. package/src/ha-signing/local_config.ts +1 -1
  204. package/src/ha-signing/types.ts +48 -34
  205. package/src/hash/hash.ts +27 -0
  206. package/src/interfaces/archiver.ts +8 -0
  207. package/src/interfaces/aztec-node-admin.ts +3 -6
  208. package/src/interfaces/aztec-node-debug.ts +40 -0
  209. package/src/interfaces/aztec-node.ts +15 -0
  210. package/src/interfaces/client.ts +1 -0
  211. package/src/interfaces/merkle_tree_operations.ts +3 -2
  212. package/src/interfaces/prover-client.ts +2 -5
  213. package/src/interfaces/slasher.ts +0 -6
  214. package/src/interfaces/validator.ts +15 -8
  215. package/src/l1-contracts/index.ts +1 -1
  216. package/src/logs/log_id.ts +1 -2
  217. package/src/logs/siloed_tag.ts +8 -9
  218. package/src/logs/tag.ts +8 -8
  219. package/src/p2p/block_proposal.ts +13 -9
  220. package/src/p2p/checkpoint_attestation.ts +5 -9
  221. package/src/p2p/checkpoint_proposal.ts +21 -36
  222. package/src/p2p/gossipable.ts +4 -4
  223. package/src/parity/parity_base_private_inputs.ts +10 -4
  224. package/src/parity/parity_public_inputs.ts +9 -2
  225. package/src/rollup/block_headers_hash.ts +11 -2
  226. package/src/slashing/index.ts +1 -2
  227. package/src/slashing/serialization.ts +1 -81
  228. package/src/slashing/types.ts +3 -35
  229. package/src/slashing/{tally.ts → votes.ts} +1 -1
  230. package/src/tests/factories.ts +14 -20
  231. package/src/tests/mocks.ts +14 -10
  232. package/src/timetable/index.ts +293 -13
  233. package/src/trees/nullifier_leaf.ts +4 -0
  234. package/src/tx/block_header.ts +2 -2
  235. package/src/tx/fee_provider.ts +10 -0
  236. package/src/tx/global_variable_builder.ts +2 -18
  237. package/src/tx/index.ts +1 -0
  238. package/src/tx/indexed_tx_effect.ts +1 -2
  239. package/src/tx/simulated_tx.ts +1 -1
  240. package/src/tx/tx.ts +2 -2
  241. package/src/types/shared.ts +0 -10
  242. package/src/vks/verification_key.ts +5 -184
  243. package/src/world-state/genesis_data.ts +15 -0
  244. package/src/world-state/index.ts +1 -0
  245. package/src/world-state/world_state_revision.ts +9 -1
  246. package/dest/abi/mocked_keys.d.ts +0 -2
  247. package/dest/abi/mocked_keys.d.ts.map +0 -1
  248. package/dest/abi/mocked_keys.js +0 -1
  249. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  250. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  251. package/dest/l1-contracts/slash_factory.js +0 -158
  252. package/dest/slashing/empire.d.ts +0 -31
  253. package/dest/slashing/empire.d.ts.map +0 -1
  254. package/dest/slashing/empire.js +0 -87
  255. package/src/abi/mocked_keys.ts +0 -2
  256. package/src/l1-contracts/slash_factory.ts +0 -180
  257. 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
 
@@ -10,9 +10,11 @@ export class ParityBasePrivateInputs {
10
10
  public readonly msgs: Tuple<Fr, typeof NUM_MSGS_PER_BASE_PARITY>,
11
11
  /** Root of the VK tree */
12
12
  public readonly vkTreeRoot: Fr,
13
+ /** Prover identity committed to by the circuit, for sybil protection. */
14
+ public readonly proverId: Fr,
13
15
  ) {}
14
16
 
15
- public static fromSlice(array: Fr[], index: number, vkTreeRoot: Fr): ParityBasePrivateInputs {
17
+ public static fromSlice(array: Fr[], index: number, vkTreeRoot: Fr, proverId: Fr): ParityBasePrivateInputs {
16
18
  // Can't use Tuple<Fr, typeof NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP> due to length
17
19
  if (array.length !== NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP) {
18
20
  throw new Error(
@@ -22,12 +24,12 @@ export class ParityBasePrivateInputs {
22
24
  const start = index * NUM_MSGS_PER_BASE_PARITY;
23
25
  const end = start + NUM_MSGS_PER_BASE_PARITY;
24
26
  const msgs = array.slice(start, end);
25
- return new ParityBasePrivateInputs(msgs as Tuple<Fr, typeof NUM_MSGS_PER_BASE_PARITY>, vkTreeRoot);
27
+ return new ParityBasePrivateInputs(msgs as Tuple<Fr, typeof NUM_MSGS_PER_BASE_PARITY>, vkTreeRoot, proverId);
26
28
  }
27
29
 
28
30
  /** Serializes the inputs to a buffer. */
29
31
  toBuffer() {
30
- return serializeToBuffer(this.msgs, this.vkTreeRoot);
32
+ return serializeToBuffer(this.msgs, this.vkTreeRoot, this.proverId);
31
33
  }
32
34
 
33
35
  /** Serializes the inputs to a hex string. */
@@ -41,7 +43,11 @@ export class ParityBasePrivateInputs {
41
43
  */
42
44
  static fromBuffer(buffer: Buffer | BufferReader) {
43
45
  const reader = BufferReader.asReader(buffer);
44
- return new ParityBasePrivateInputs(reader.readArray(NUM_MSGS_PER_BASE_PARITY, Fr), Fr.fromBuffer(reader));
46
+ return new ParityBasePrivateInputs(
47
+ reader.readArray(NUM_MSGS_PER_BASE_PARITY, Fr),
48
+ Fr.fromBuffer(reader),
49
+ Fr.fromBuffer(reader),
50
+ );
45
51
  }
46
52
 
47
53
  /**
@@ -12,6 +12,8 @@ export class ParityPublicInputs {
12
12
  public convertedRoot: Fr,
13
13
  /** Root of the VK tree */
14
14
  public vkTreeRoot: Fr,
15
+ /** Prover identity committed to by the circuit, for sybil protection. */
16
+ public proverId: Fr,
15
17
  ) {
16
18
  if (shaRoot.toBuffer()[0] != 0) {
17
19
  throw new Error(`shaRoot buffer must be 31 bytes. Got 32 bytes`);
@@ -54,7 +56,7 @@ export class ParityPublicInputs {
54
56
  * @returns The instance fields.
55
57
  */
56
58
  static getFields(fields: FieldsOf<ParityPublicInputs>) {
57
- return [fields.shaRoot, fields.convertedRoot, fields.vkTreeRoot] as const;
59
+ return [fields.shaRoot, fields.convertedRoot, fields.vkTreeRoot, fields.proverId] as const;
58
60
  }
59
61
 
60
62
  /**
@@ -64,7 +66,12 @@ export class ParityPublicInputs {
64
66
  */
65
67
  static fromBuffer(buffer: Buffer | BufferReader) {
66
68
  const reader = BufferReader.asReader(buffer);
67
- return new ParityPublicInputs(reader.readObject(Fr), reader.readObject(Fr), Fr.fromBuffer(reader));
69
+ return new ParityPublicInputs(
70
+ reader.readObject(Fr),
71
+ reader.readObject(Fr),
72
+ Fr.fromBuffer(reader),
73
+ Fr.fromBuffer(reader),
74
+ );
68
75
  }
69
76
 
70
77
  /**
@@ -1,5 +1,7 @@
1
+ import { DomainSeparator } from '@aztec/constants';
2
+ import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
1
3
  import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { computeUnbalancedPoseidonRoot } from '@aztec/foundation/trees';
4
+ import { computeUnbalancedMerkleTreeRootAsync } from '@aztec/foundation/trees';
3
5
 
4
6
  import type { BlockHeader } from '../tx/block_header.js';
5
7
 
@@ -7,6 +9,13 @@ export async function computeBlockHeadersHash(blockHeaders: BlockHeader[]): Prom
7
9
  const blockHeaderHashes = await Promise.all(blockHeaders.map(header => header.hash()));
8
10
  // Must match the implementation in merge_block_rollups.nr, with the **unbalanced** rollup structure
9
11
  // (see validate_consecutive_block_rollups.nr > assert_rollups_filled_greedily.nr).
10
- const blockHeadersHash = await computeUnbalancedPoseidonRoot(blockHeaderHashes.map(hash => hash.toBuffer()));
12
+ const blockHeadersHasher = async (left: Uint8Array, right: Uint8Array) =>
13
+ (
14
+ await poseidon2HashWithSeparator([Buffer.from(left), Buffer.from(right)], DomainSeparator.BLOCK_HEADERS_HASH)
15
+ ).toBuffer() as Buffer<ArrayBuffer>;
16
+ const blockHeadersHash = await computeUnbalancedMerkleTreeRootAsync(
17
+ blockHeaderHashes.map(hash => hash.toBuffer()),
18
+ blockHeadersHasher,
19
+ );
11
20
  return Fr.fromBuffer(blockHeadersHash);
12
21
  }
@@ -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
 
@@ -9,7 +9,6 @@ import {
9
9
  AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
10
10
  CHONK_PROOF_LENGTH,
11
11
  CONTRACT_CLASS_LOG_SIZE_IN_FIELDS,
12
- DomainSeparator,
13
12
  L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
14
13
  MAX_CHECKPOINTS_PER_EPOCH,
15
14
  MAX_CONTRACT_CLASS_LOGS_PER_TX,
@@ -46,7 +45,6 @@ import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
46
45
  import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
47
46
  import { compact } from '@aztec/foundation/collection';
48
47
  import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
49
- import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
50
48
  import { SchnorrSignature } from '@aztec/foundation/crypto/schnorr';
51
49
  import { sha256 } from '@aztec/foundation/crypto/sha256';
52
50
  import { Fq, Fr } from '@aztec/foundation/curves/bn254';
@@ -95,6 +93,7 @@ import {
95
93
  type PrivateFunction,
96
94
  SerializableContractInstance,
97
95
  computeContractClassId,
96
+ computePartialAddress,
98
97
  computePublicBytecodeCommitment,
99
98
  } from '../contract/index.js';
100
99
  import { Gas, GasFees, GasSettings } from '../gas/index.js';
@@ -176,7 +175,7 @@ import { TxHash } from '../tx/tx_hash.js';
176
175
  import { TxRequest } from '../tx/tx_request.js';
177
176
  import { Vector } from '../types/index.js';
178
177
  import { VkData } from '../vks/index.js';
179
- import { VerificationKey, VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
178
+ import { VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
180
179
 
181
180
  /**
182
181
  * Creates an arbitrary side effect object with the given seed.
@@ -573,14 +572,6 @@ export function makeVerificationKeyAsFields(size: number): VerificationKeyAsFiel
573
572
  return VerificationKeyAsFields.makeFake(size);
574
573
  }
575
574
 
576
- /**
577
- * Creates arbitrary/mocked verification key.
578
- * @returns A verification key object
579
- */
580
- export function makeVerificationKey(): VerificationKey {
581
- return VerificationKey.makeFake();
582
- }
583
-
584
575
  /**
585
576
  * Creates an arbitrary point in a curve.
586
577
  * @param seed - Seed to generate the point values.
@@ -863,11 +854,16 @@ export function makeParityPublicInputs(seed = 0): ParityPublicInputs {
863
854
  new Fr(BigInt(seed + 0x200)),
864
855
  new Fr(BigInt(seed + 0x300)),
865
856
  new Fr(BigInt(seed + 0x400)),
857
+ new Fr(BigInt(seed + 0x500)),
866
858
  );
867
859
  }
868
860
 
869
861
  export function makeParityBasePrivateInputs(seed = 0): ParityBasePrivateInputs {
870
- return new ParityBasePrivateInputs(makeTuple(NUM_MSGS_PER_BASE_PARITY, fr, seed + 0x3000), new Fr(seed + 0x4000));
862
+ return new ParityBasePrivateInputs(
863
+ makeTuple(NUM_MSGS_PER_BASE_PARITY, fr, seed + 0x3000),
864
+ new Fr(seed + 0x4000),
865
+ new Fr(seed + 0x5000),
866
+ );
871
867
  }
872
868
 
873
869
  export function makeParityRootPrivateInputs(seed = 0) {
@@ -1253,14 +1249,12 @@ export async function makeContractInstanceFromClassId(
1253
1249
  const deployer = overrides?.deployer ?? new AztecAddress(new Fr(seed + 2));
1254
1250
  const publicKeys = overrides?.publicKeys ?? (await makePublicKeys(seed + 3));
1255
1251
 
1256
- const saltedInitializationHash = await poseidon2HashWithSeparator(
1257
- [salt, initializationHash, deployer],
1258
- DomainSeparator.PARTIAL_ADDRESS,
1259
- );
1260
- const partialAddress = await poseidon2HashWithSeparator(
1261
- [classId, saltedInitializationHash],
1262
- DomainSeparator.PARTIAL_ADDRESS,
1263
- );
1252
+ const partialAddress = await computePartialAddress({
1253
+ originalContractClassId: classId,
1254
+ salt,
1255
+ initializationHash,
1256
+ deployer,
1257
+ });
1264
1258
  const address = await computeAddress(publicKeys, partialAddress);
1265
1259
  return new SerializableContractInstance({
1266
1260
  version: 1,
@@ -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
  };