@aztec/stdlib 0.0.1-commit.e588bc7e5 → 0.0.1-commit.e5a3663dd

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 (338) 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/abi/selector.d.ts +2 -2
  15. package/dest/abi/selector.d.ts.map +1 -1
  16. package/dest/abi/selector.js +1 -1
  17. package/dest/avm/revert_code.d.ts +8 -18
  18. package/dest/avm/revert_code.d.ts.map +1 -1
  19. package/dest/avm/revert_code.js +15 -30
  20. package/dest/aztec-address/index.d.ts +3 -6
  21. package/dest/aztec-address/index.d.ts.map +1 -1
  22. package/dest/aztec-address/index.js +2 -4
  23. package/dest/block/attestation_info.d.ts +3 -2
  24. package/dest/block/attestation_info.d.ts.map +1 -1
  25. package/dest/block/attestation_info.js +7 -5
  26. package/dest/block/block_data.d.ts +297 -8
  27. package/dest/block/block_data.d.ts.map +1 -1
  28. package/dest/block/block_data.js +16 -2
  29. package/dest/block/block_hash.d.ts +11 -10
  30. package/dest/block/block_hash.d.ts.map +1 -1
  31. package/dest/block/block_hash.js +10 -9
  32. package/dest/block/block_parameter.d.ts +30 -3
  33. package/dest/block/block_parameter.d.ts.map +1 -1
  34. package/dest/block/block_parameter.js +36 -2
  35. package/dest/block/l2_block_info.d.ts +6 -5
  36. package/dest/block/l2_block_info.d.ts.map +1 -1
  37. package/dest/block/l2_block_info.js +6 -5
  38. package/dest/block/l2_block_source.d.ts +39 -4
  39. package/dest/block/l2_block_source.d.ts.map +1 -1
  40. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  41. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  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 +1 -1
  45. package/dest/block/proposal/attestations_and_signers.d.ts +13 -6
  46. package/dest/block/proposal/attestations_and_signers.d.ts.map +1 -1
  47. package/dest/block/proposal/attestations_and_signers.js +26 -18
  48. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  49. package/dest/checkpoint/checkpoint_data.d.ts +7 -1
  50. package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
  51. package/dest/checkpoint/checkpoint_data.js +2 -0
  52. package/dest/config/chain-config.d.ts +2 -2
  53. package/dest/config/chain-config.d.ts.map +1 -1
  54. package/dest/config/chain-config.js +9 -3
  55. package/dest/config/sequencer-config.d.ts +5 -3
  56. package/dest/config/sequencer-config.d.ts.map +1 -1
  57. package/dest/config/sequencer-config.js +18 -4
  58. package/dest/contract/contract_address.d.ts +1 -1
  59. package/dest/contract/contract_address.js +2 -2
  60. package/dest/contract/private_function.d.ts +1 -1
  61. package/dest/contract/private_function.d.ts.map +1 -1
  62. package/dest/contract/private_function.js +2 -4
  63. package/dest/gas/fee_math.d.ts +49 -0
  64. package/dest/gas/fee_math.d.ts.map +1 -0
  65. package/dest/gas/fee_math.js +80 -0
  66. package/dest/gas/gas_fees.d.ts +5 -1
  67. package/dest/gas/gas_fees.d.ts.map +1 -1
  68. package/dest/gas/gas_fees.js +10 -1
  69. package/dest/gas/gas_settings.d.ts +40 -3
  70. package/dest/gas/gas_settings.d.ts.map +1 -1
  71. package/dest/gas/gas_settings.js +50 -6
  72. package/dest/gas/index.d.ts +2 -1
  73. package/dest/gas/index.d.ts.map +1 -1
  74. package/dest/gas/index.js +1 -0
  75. package/dest/ha-signing/config.d.ts +6 -6
  76. package/dest/ha-signing/config.d.ts.map +1 -1
  77. package/dest/ha-signing/config.js +4 -3
  78. package/dest/ha-signing/index.d.ts +2 -2
  79. package/dest/ha-signing/index.d.ts.map +1 -1
  80. package/dest/ha-signing/index.js +1 -1
  81. package/dest/ha-signing/local_config.d.ts +1 -1
  82. package/dest/ha-signing/local_config.d.ts.map +1 -1
  83. package/dest/ha-signing/local_config.js +2 -2
  84. package/dest/ha-signing/types.d.ts +37 -32
  85. package/dest/ha-signing/types.d.ts.map +1 -1
  86. package/dest/ha-signing/types.js +13 -6
  87. package/dest/hash/hash.d.ts +16 -1
  88. package/dest/hash/hash.d.ts.map +1 -1
  89. package/dest/hash/hash.js +32 -0
  90. package/dest/interfaces/archiver.d.ts +11 -1
  91. package/dest/interfaces/archiver.d.ts.map +1 -1
  92. package/dest/interfaces/archiver.js +10 -4
  93. package/dest/interfaces/aztec-node-admin.d.ts +22 -14
  94. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  95. package/dest/interfaces/aztec-node-admin.js +5 -4
  96. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  97. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  98. package/dest/interfaces/aztec-node-debug.js +18 -0
  99. package/dest/interfaces/aztec-node.d.ts +54 -55
  100. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  101. package/dest/interfaces/aztec-node.js +20 -16
  102. package/dest/interfaces/block_response.d.ts +156 -0
  103. package/dest/interfaces/block_response.d.ts.map +1 -0
  104. package/dest/interfaces/block_response.js +24 -0
  105. package/dest/interfaces/chain_tips.d.ts +304 -0
  106. package/dest/interfaces/chain_tips.d.ts.map +1 -0
  107. package/dest/interfaces/chain_tips.js +11 -0
  108. package/dest/interfaces/checkpoint_parameter.d.ts +27 -0
  109. package/dest/interfaces/checkpoint_parameter.d.ts.map +1 -0
  110. package/dest/interfaces/checkpoint_parameter.js +20 -0
  111. package/dest/interfaces/checkpoint_response.d.ts +312 -0
  112. package/dest/interfaces/checkpoint_response.d.ts.map +1 -0
  113. package/dest/interfaces/checkpoint_response.js +26 -0
  114. package/dest/interfaces/client.d.ts +7 -1
  115. package/dest/interfaces/client.d.ts.map +1 -1
  116. package/dest/interfaces/client.js +6 -0
  117. package/dest/interfaces/configs.d.ts +12 -2
  118. package/dest/interfaces/configs.d.ts.map +1 -1
  119. package/dest/interfaces/configs.js +3 -1
  120. package/dest/interfaces/l1_publish_info.d.ts +43 -0
  121. package/dest/interfaces/l1_publish_info.d.ts.map +1 -0
  122. package/dest/interfaces/l1_publish_info.js +26 -0
  123. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  124. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  125. package/dest/interfaces/prover-client.d.ts +1 -1
  126. package/dest/interfaces/prover-client.d.ts.map +1 -1
  127. package/dest/interfaces/prover-client.js +0 -3
  128. package/dest/interfaces/proving-job.d.ts +166 -166
  129. package/dest/interfaces/server.d.ts +6 -1
  130. package/dest/interfaces/server.d.ts.map +1 -1
  131. package/dest/interfaces/server.js +5 -0
  132. package/dest/interfaces/slasher.d.ts +1 -10
  133. package/dest/interfaces/slasher.d.ts.map +1 -1
  134. package/dest/interfaces/slasher.js +0 -2
  135. package/dest/interfaces/validator.d.ts +27 -18
  136. package/dest/interfaces/validator.d.ts.map +1 -1
  137. package/dest/interfaces/validator.js +2 -0
  138. package/dest/l1-contracts/index.d.ts +2 -2
  139. package/dest/l1-contracts/index.d.ts.map +1 -1
  140. package/dest/l1-contracts/index.js +1 -1
  141. package/dest/logs/log_id.d.ts +1 -1
  142. package/dest/logs/log_id.d.ts.map +1 -1
  143. package/dest/logs/log_id.js +1 -2
  144. package/dest/logs/siloed_tag.d.ts +5 -7
  145. package/dest/logs/siloed_tag.d.ts.map +1 -1
  146. package/dest/logs/siloed_tag.js +4 -0
  147. package/dest/logs/tag.d.ts +5 -6
  148. package/dest/logs/tag.d.ts.map +1 -1
  149. package/dest/logs/tag.js +4 -0
  150. package/dest/p2p/block_proposal.d.ts +22 -14
  151. package/dest/p2p/block_proposal.d.ts.map +1 -1
  152. package/dest/p2p/block_proposal.js +45 -40
  153. package/dest/p2p/checkpoint_attestation.d.ts +10 -8
  154. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  155. package/dest/p2p/checkpoint_attestation.js +17 -24
  156. package/dest/p2p/checkpoint_proposal.d.ts +20 -14
  157. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  158. package/dest/p2p/checkpoint_proposal.js +34 -51
  159. package/dest/p2p/consensus_payload.d.ts +18 -7
  160. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  161. package/dest/p2p/consensus_payload.js +31 -19
  162. package/dest/p2p/gossipable.d.ts +4 -4
  163. package/dest/p2p/gossipable.d.ts.map +1 -1
  164. package/dest/p2p/signature_utils.d.ts +28 -19
  165. package/dest/p2p/signature_utils.d.ts.map +1 -1
  166. package/dest/p2p/signature_utils.js +118 -21
  167. package/dest/p2p/signed_txs.d.ts +15 -13
  168. package/dest/p2p/signed_txs.d.ts.map +1 -1
  169. package/dest/p2p/signed_txs.js +26 -24
  170. package/dest/parity/parity_base_private_inputs.d.ts +7 -3
  171. package/dest/parity/parity_base_private_inputs.d.ts.map +1 -1
  172. package/dest/parity/parity_base_private_inputs.js +7 -5
  173. package/dest/parity/parity_public_inputs.d.ts +7 -3
  174. package/dest/parity/parity_public_inputs.d.ts.map +1 -1
  175. package/dest/parity/parity_public_inputs.js +6 -3
  176. package/dest/rollup/block_headers_hash.d.ts +1 -1
  177. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  178. package/dest/rollup/block_headers_hash.js +8 -2
  179. package/dest/slashing/index.d.ts +2 -3
  180. package/dest/slashing/index.d.ts.map +1 -1
  181. package/dest/slashing/index.js +1 -2
  182. package/dest/slashing/serialization.d.ts +2 -6
  183. package/dest/slashing/serialization.d.ts.map +1 -1
  184. package/dest/slashing/serialization.js +0 -60
  185. package/dest/slashing/types.d.ts +4 -90
  186. package/dest/slashing/types.d.ts.map +1 -1
  187. package/dest/slashing/types.js +0 -14
  188. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  189. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  190. package/dest/slashing/{tally.js → votes.js} +1 -1
  191. package/dest/tests/factories.d.ts +2 -7
  192. package/dest/tests/factories.d.ts.map +1 -1
  193. package/dest/tests/factories.js +9 -19
  194. package/dest/tests/mocks.d.ts +7 -1
  195. package/dest/tests/mocks.d.ts.map +1 -1
  196. package/dest/tests/mocks.js +39 -30
  197. package/dest/timetable/index.d.ts +51 -1
  198. package/dest/timetable/index.d.ts.map +1 -1
  199. package/dest/timetable/index.js +218 -14
  200. package/dest/trees/nullifier_leaf.d.ts +2 -1
  201. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  202. package/dest/trees/nullifier_leaf.js +3 -0
  203. package/dest/tx/block_header.d.ts +2 -2
  204. package/dest/tx/block_header.d.ts.map +1 -1
  205. package/dest/tx/block_header.js +1 -1
  206. package/dest/tx/fee_provider.d.ts +10 -0
  207. package/dest/tx/fee_provider.d.ts.map +1 -0
  208. package/dest/tx/fee_provider.js +1 -0
  209. package/dest/tx/global_variable_builder.d.ts +3 -16
  210. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  211. package/dest/tx/index.d.ts +2 -1
  212. package/dest/tx/index.d.ts.map +1 -1
  213. package/dest/tx/index.js +1 -0
  214. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  215. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  216. package/dest/tx/indexed_tx_effect.js +1 -2
  217. package/dest/tx/profiling.js +4 -4
  218. package/dest/tx/simulated_tx.d.ts +4 -4
  219. package/dest/tx/simulated_tx.d.ts.map +1 -1
  220. package/dest/tx/simulated_tx.js +3 -3
  221. package/dest/tx/tx.d.ts +3 -3
  222. package/dest/tx/tx.d.ts.map +1 -1
  223. package/dest/tx/tx_receipt.d.ts +8 -4
  224. package/dest/tx/tx_receipt.d.ts.map +1 -1
  225. package/dest/tx/tx_receipt.js +8 -15
  226. package/dest/types/shared.d.ts +1 -10
  227. package/dest/types/shared.d.ts.map +1 -1
  228. package/dest/types/shared.js +0 -9
  229. package/dest/vks/verification_key.d.ts +2 -137
  230. package/dest/vks/verification_key.d.ts.map +1 -1
  231. package/dest/vks/verification_key.js +5 -126
  232. package/dest/world-state/genesis_data.d.ts +11 -0
  233. package/dest/world-state/genesis_data.d.ts.map +1 -0
  234. package/dest/world-state/genesis_data.js +4 -0
  235. package/dest/world-state/index.d.ts +2 -1
  236. package/dest/world-state/index.d.ts.map +1 -1
  237. package/dest/world-state/index.js +1 -0
  238. package/dest/world-state/world_state_revision.d.ts +8 -1
  239. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  240. package/dest/world-state/world_state_revision.js +7 -1
  241. package/package.json +8 -8
  242. package/src/abi/authorization_selector.ts +2 -8
  243. package/src/abi/encoder.ts +42 -6
  244. package/src/abi/event_selector.ts +2 -8
  245. package/src/abi/function_selector.ts +3 -12
  246. package/src/abi/note_selector.ts +3 -12
  247. package/src/abi/selector.ts +1 -1
  248. package/src/avm/revert_code.ts +25 -39
  249. package/src/aztec-address/index.ts +4 -10
  250. package/src/block/attestation_info.ts +11 -11
  251. package/src/block/block_data.ts +20 -4
  252. package/src/block/block_hash.ts +21 -14
  253. package/src/block/block_parameter.ts +35 -2
  254. package/src/block/l2_block_info.ts +8 -6
  255. package/src/block/l2_block_source.ts +43 -3
  256. package/src/block/l2_block_stream/interfaces.ts +6 -2
  257. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  258. package/src/block/proposal/attestations_and_signers.ts +32 -17
  259. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  260. package/src/checkpoint/checkpoint_data.ts +4 -0
  261. package/src/config/chain-config.ts +9 -4
  262. package/src/config/sequencer-config.ts +34 -6
  263. package/src/contract/contract_address.ts +2 -2
  264. package/src/contract/private_function.ts +3 -1
  265. package/src/gas/README.md +31 -0
  266. package/src/gas/fee_math.ts +120 -0
  267. package/src/gas/gas_fees.ts +17 -4
  268. package/src/gas/gas_settings.ts +65 -12
  269. package/src/gas/index.ts +1 -0
  270. package/src/ha-signing/config.ts +5 -2
  271. package/src/ha-signing/index.ts +3 -1
  272. package/src/ha-signing/local_config.ts +2 -2
  273. package/src/ha-signing/types.ts +48 -34
  274. package/src/hash/hash.ts +27 -0
  275. package/src/interfaces/archiver.ts +21 -3
  276. package/src/interfaces/aztec-node-admin.ts +8 -8
  277. package/src/interfaces/aztec-node-debug.ts +40 -0
  278. package/src/interfaces/aztec-node.ts +120 -95
  279. package/src/interfaces/block_response.ts +79 -0
  280. package/src/interfaces/chain_tips.ts +24 -0
  281. package/src/interfaces/checkpoint_parameter.ts +22 -0
  282. package/src/interfaces/checkpoint_response.ts +84 -0
  283. package/src/interfaces/client.ts +6 -0
  284. package/src/interfaces/configs.ts +8 -1
  285. package/src/interfaces/l1_publish_info.ts +40 -0
  286. package/src/interfaces/merkle_tree_operations.ts +3 -2
  287. package/src/interfaces/prover-client.ts +2 -5
  288. package/src/interfaces/server.ts +5 -0
  289. package/src/interfaces/slasher.ts +0 -6
  290. package/src/interfaces/validator.ts +22 -9
  291. package/src/l1-contracts/index.ts +1 -1
  292. package/src/logs/log_id.ts +1 -2
  293. package/src/logs/siloed_tag.ts +8 -9
  294. package/src/logs/tag.ts +8 -8
  295. package/src/p2p/block_proposal.ts +96 -36
  296. package/src/p2p/checkpoint_attestation.ts +20 -29
  297. package/src/p2p/checkpoint_proposal.ts +88 -71
  298. package/src/p2p/consensus_payload.ts +50 -28
  299. package/src/p2p/gossipable.ts +4 -4
  300. package/src/p2p/signature_utils.ts +110 -25
  301. package/src/p2p/signed_txs.ts +46 -28
  302. package/src/parity/parity_base_private_inputs.ts +10 -4
  303. package/src/parity/parity_public_inputs.ts +9 -2
  304. package/src/rollup/block_headers_hash.ts +11 -2
  305. package/src/slashing/index.ts +1 -2
  306. package/src/slashing/serialization.ts +1 -81
  307. package/src/slashing/types.ts +3 -35
  308. package/src/slashing/{tally.ts → votes.ts} +1 -1
  309. package/src/tests/factories.ts +15 -21
  310. package/src/tests/mocks.ts +63 -39
  311. package/src/timetable/index.ts +308 -13
  312. package/src/trees/nullifier_leaf.ts +4 -0
  313. package/src/tx/block_header.ts +2 -2
  314. package/src/tx/fee_provider.ts +10 -0
  315. package/src/tx/global_variable_builder.ts +2 -18
  316. package/src/tx/index.ts +1 -0
  317. package/src/tx/indexed_tx_effect.ts +1 -2
  318. package/src/tx/profiling.ts +4 -4
  319. package/src/tx/simulated_tx.ts +6 -2
  320. package/src/tx/tx.ts +2 -2
  321. package/src/tx/tx_receipt.ts +11 -14
  322. package/src/types/shared.ts +0 -10
  323. package/src/vks/verification_key.ts +5 -184
  324. package/src/world-state/genesis_data.ts +15 -0
  325. package/src/world-state/index.ts +1 -0
  326. package/src/world-state/world_state_revision.ts +9 -1
  327. package/dest/abi/mocked_keys.d.ts +0 -2
  328. package/dest/abi/mocked_keys.d.ts.map +0 -1
  329. package/dest/abi/mocked_keys.js +0 -1
  330. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  331. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  332. package/dest/l1-contracts/slash_factory.js +0 -158
  333. package/dest/slashing/empire.d.ts +0 -31
  334. package/dest/slashing/empire.d.ts.map +0 -1
  335. package/dest/slashing/empire.js +0 -87
  336. package/src/abi/mocked_keys.ts +0 -2
  337. package/src/l1-contracts/slash_factory.ts +0 -180
  338. package/src/slashing/empire.ts +0 -104
@@ -15,6 +15,8 @@ export interface SequencerConfig {
15
15
  maxTxsPerBlock?: number;
16
16
  /** The maximum number of txs across all blocks in a checkpoint. */
17
17
  maxTxsPerCheckpoint?: number;
18
+ /** Maximum number of blocks the sequencer packs into a single checkpoint, and the highest indexWithinCheckpoint accepted on a block proposal. */
19
+ maxBlocksPerCheckpoint?: number;
18
20
  /** The minimum number of txs to include in a block. */
19
21
  minTxsPerBlock?: number;
20
22
  /** The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock. */
@@ -83,6 +85,8 @@ export interface SequencerConfig {
83
85
  minBlocksForCheckpoint?: number;
84
86
  /** Skip publishing checkpoint proposals probability (for testing checkpoint prunes only) */
85
87
  skipPublishingCheckpointsPercent?: number;
88
+ /** Skip broadcasting checkpoint and block proposals via gossipsub when proposer (for testing only) */
89
+ skipBroadcastProposals?: boolean;
86
90
  }
87
91
 
88
92
  export const SequencerConfigSchema = zodFor<SequencerConfig>()(
@@ -90,6 +94,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
90
94
  sequencerPollingIntervalMS: z.number().optional(),
91
95
  maxTxsPerBlock: z.number().optional(),
92
96
  maxTxsPerCheckpoint: z.number().optional(),
97
+ maxBlocksPerCheckpoint: z.number().positive().optional(),
93
98
  minValidTxsPerBlock: z.number().optional(),
94
99
  minTxsPerBlock: z.number().optional(),
95
100
  maxL2BlockGas: z.number().optional(),
@@ -124,6 +129,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
124
129
  skipPushProposedBlocksToArchiver: z.boolean().optional(),
125
130
  minBlocksForCheckpoint: z.number().positive().optional(),
126
131
  skipPublishingCheckpointsPercent: z.number().gte(0).lte(100).optional(),
132
+ skipBroadcastProposals: z.boolean().optional(),
127
133
  }),
128
134
  );
129
135
 
@@ -145,7 +151,8 @@ type SequencerConfigOptionalKeys =
145
151
  | 'maxTxsPerCheckpoint'
146
152
  | 'maxL2BlockGas'
147
153
  | 'maxDABlockGas'
148
- | 'redistributeCheckpointBudget';
154
+ | 'redistributeCheckpointBudget'
155
+ | 'skipBroadcastProposals';
149
156
 
150
157
  export type ResolvedSequencerConfig = Prettify<
151
158
  Required<Omit<SequencerConfig, SequencerConfigOptionalKeys>> & Pick<SequencerConfig, SequencerConfigOptionalKeys>
@@ -0,0 +1,40 @@
1
+ import { schemas } from '@aztec/foundation/schemas';
2
+
3
+ import { z } from 'zod';
4
+
5
+ import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
6
+
7
+ /**
8
+ * L1 publication info for a block or checkpoint.
9
+ *
10
+ * A discriminated union over `published`: when `false`, the block/checkpoint has not yet been
11
+ * published to L1. When `true`, the L1 block info (number, timestamp, hash) is present.
12
+ *
13
+ * Distinct from {@link L1PublishedData}, which is always the "published" case.
14
+ */
15
+ export type L1PublishInfo =
16
+ | { published: false }
17
+ | { published: true; blockNumber: bigint; timestamp: bigint; blockHash: string };
18
+
19
+ export const L1PublishInfoSchema = z.union([
20
+ z.object({ published: z.literal(false) }),
21
+ z.object({
22
+ published: z.literal(true),
23
+ blockNumber: schemas.BigInt,
24
+ timestamp: schemas.BigInt,
25
+ blockHash: z.string(),
26
+ }),
27
+ ]);
28
+
29
+ /** Projects the internal {@link L1PublishedData} (or its absence) to the public {@link L1PublishInfo} shape. */
30
+ export function l1PublishInfoFromL1PublishedData(data: L1PublishedData | undefined): L1PublishInfo {
31
+ if (!data) {
32
+ return { published: false };
33
+ }
34
+ return {
35
+ published: true,
36
+ blockNumber: data.blockNumber,
37
+ timestamp: data.timestamp,
38
+ blockHash: data.blockHash,
39
+ };
40
+ }
@@ -3,6 +3,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { type IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
5
5
 
6
+ import type { BlockHash } from '../block/block_hash.js';
6
7
  import type { MerkleTreeId, TreeHeights } from '../trees/merkle_tree_id.js';
7
8
  import type { NullifierLeaf } from '../trees/nullifier_leaf.js';
8
9
  import type { PublicDataTreeLeaf } from '../trees/public_data_leaf.js';
@@ -99,7 +100,7 @@ type LeafTypes = {
99
100
  [MerkleTreeId.NOTE_HASH_TREE]: Fr;
100
101
  [MerkleTreeId.PUBLIC_DATA_TREE]: Buffer;
101
102
  [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
102
- [MerkleTreeId.ARCHIVE]: Fr;
103
+ [MerkleTreeId.ARCHIVE]: BlockHash;
103
104
  };
104
105
 
105
106
  type LeafValueTypes = {
@@ -107,7 +108,7 @@ type LeafValueTypes = {
107
108
  [MerkleTreeId.NOTE_HASH_TREE]: Fr;
108
109
  [MerkleTreeId.PUBLIC_DATA_TREE]: PublicDataTreeLeaf;
109
110
  [MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
110
- [MerkleTreeId.ARCHIVE]: Fr;
111
+ [MerkleTreeId.ARCHIVE]: BlockHash;
111
112
  };
112
113
 
113
114
  export type MerkleTreeLeafType<ID extends MerkleTreeId> = LeafTypes[ID];
@@ -71,7 +71,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
71
71
  },
72
72
  proverId: {
73
73
  env: 'PROVER_ID',
74
- parseEnv: (val?: string) => parseProverId(val),
74
+ parseEnv: (val: string) => parseProverId(val),
75
75
  description: 'Hex value that identifies the prover. Defaults to the address used for submitting proofs if not set.',
76
76
  },
77
77
  proverTestDelayType: {
@@ -117,10 +117,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
117
117
  },
118
118
  };
119
119
 
120
- function parseProverId(str?: string) {
121
- if (!str) {
122
- return undefined;
123
- }
120
+ function parseProverId(str: string) {
124
121
  return EthAddress.fromString(str);
125
122
  }
126
123
 
@@ -2,6 +2,11 @@ export * from './allowed_element.js';
2
2
  export * from './api_limit.js';
3
3
  export * from './archiver.js';
4
4
  export * from './aztec-node.js';
5
+ export * from './block_response.js';
6
+ export * from './chain_tips.js';
7
+ export * from './checkpoint_parameter.js';
8
+ export * from './checkpoint_response.js';
9
+ export * from './l1_publish_info.js';
5
10
  export * from './block-builder.js';
6
11
  export * from './configs.js';
7
12
  export * from './epoch-prover.js';
@@ -3,12 +3,8 @@ import { schemas, zodFor } from '@aztec/foundation/schemas';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
- export type SlasherClientType = 'empire' | 'tally';
7
-
8
6
  export interface SlasherConfig {
9
7
  slashOverridePayload?: EthAddress;
10
- slashMinPenaltyPercentage: number;
11
- slashMaxPenaltyPercentage: number;
12
8
  slashSelfAllowed?: boolean; // Whether to allow slashes to own validators
13
9
  slashValidatorsAlways: EthAddress[]; // Array of validator addresses
14
10
  slashValidatorsNever: EthAddress[]; // Array of validator addresses
@@ -32,8 +28,6 @@ export interface SlasherConfig {
32
28
  export const SlasherConfigSchema = zodFor<SlasherConfig>()(
33
29
  z.object({
34
30
  slashOverridePayload: schemas.EthAddress.optional(),
35
- slashMinPenaltyPercentage: z.number(),
36
- slashMaxPenaltyPercentage: z.number(),
37
31
  slashValidatorsAlways: z.array(schemas.EthAddress),
38
32
  slashValidatorsNever: z.array(schemas.EthAddress),
39
33
  slashPrunePenalty: schemas.BigInt,
@@ -1,4 +1,4 @@
1
- import type { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
1
+ import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
  import type { SecretValue } from '@aztec/foundation/config';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
@@ -9,7 +9,6 @@ import type {
9
9
  BlockProposal,
10
10
  BlockProposalOptions,
11
11
  CheckpointAttestation,
12
- CheckpointLastBlockData,
13
12
  CheckpointProposal,
14
13
  CheckpointProposalOptions,
15
14
  } from '@aztec/stdlib/p2p';
@@ -20,6 +19,7 @@ import type { PeerId } from '@libp2p/interface';
20
19
  import { z } from 'zod';
21
20
 
22
21
  import type { CommitteeAttestationsAndSigners } from '../block/index.js';
22
+ import type { ChainConfig } from '../config/chain-config.js';
23
23
  import {
24
24
  type LocalSignerConfig,
25
25
  LocalSignerConfigSchema,
@@ -33,6 +33,9 @@ import { AllowedElementSchema } from './allowed_element.js';
33
33
  */
34
34
  export type ValidatorClientConfig = ValidatorHASignerConfig &
35
35
  LocalSignerConfig & {
36
+ /** The L1 chain id used for EIP-712 proposal-path signing. */
37
+ l1ChainId: ChainConfig['l1ChainId'];
38
+
36
39
  /** The private keys of the validators participating in attestation duties */
37
40
  validatorPrivateKeys?: SecretValue<`0x${string}`[]>;
38
41
 
@@ -77,7 +80,7 @@ export type ValidatorClientConfig = ValidatorHASignerConfig &
77
80
  };
78
81
 
79
82
  export type ValidatorClientFullConfig = ValidatorClientConfig &
80
- Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal'> &
83
+ Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal' | 'maxBlocksPerCheckpoint'> &
81
84
  Pick<
82
85
  SlasherConfig,
83
86
  'slashBroadcastedInvalidBlockPenalty' | 'slashDuplicateProposalPenalty' | 'slashDuplicateAttestationPenalty'
@@ -91,6 +94,7 @@ export type ValidatorClientFullConfig = ValidatorClientConfig &
91
94
 
92
95
  export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'validatorPrivateKeys'>>()(
93
96
  ValidatorHASignerConfigSchema.merge(LocalSignerConfigSchema).extend({
97
+ l1ChainId: z.number().int().nonnegative(),
94
98
  validatorAddresses: z.array(schemas.EthAddress).optional(),
95
99
  disableValidator: z.boolean(),
96
100
  disabledValidators: z.array(schemas.EthAddress),
@@ -111,6 +115,7 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
111
115
  ValidatorClientConfigSchema.extend({
112
116
  txPublicSetupAllowListExtend: z.array(AllowedElementSchema).optional(),
113
117
  broadcastInvalidBlockProposal: z.boolean().optional(),
118
+ maxBlocksPerCheckpoint: z.number().positive().optional(),
114
119
  slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
115
120
  slashDuplicateProposalPenalty: schemas.BigInt,
116
121
  slashDuplicateAttestationPenalty: schemas.BigInt,
@@ -118,8 +123,6 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
118
123
  }),
119
124
  );
120
125
 
121
- export type CreateCheckpointProposalLastBlockData = Omit<CheckpointLastBlockData, 'txHashes'> & { txs: Tx[] };
122
-
123
126
  export interface Validator {
124
127
  start(): Promise<void>;
125
128
  updateConfig(config: Partial<ValidatorClientFullConfig>): void;
@@ -127,6 +130,7 @@ export interface Validator {
127
130
  // Block validation responsibilities
128
131
  createBlockProposal(
129
132
  blockHeader: BlockHeader,
133
+ checkpointNumber: CheckpointNumber,
130
134
  indexWithinCheckpoint: number,
131
135
  inHash: Fr,
132
136
  archive: Fr,
@@ -139,8 +143,9 @@ export interface Validator {
139
143
  createCheckpointProposal(
140
144
  checkpointHeader: CheckpointHeader,
141
145
  archive: Fr,
146
+ checkpointNumber: CheckpointNumber,
142
147
  feeAssetPriceModifier: bigint,
143
- lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
148
+ lastBlockProposal: BlockProposal | undefined,
144
149
  proposerAddress: EthAddress | undefined,
145
150
  options: CheckpointProposalOptions,
146
151
  ): Promise<CheckpointProposal>;
@@ -164,15 +169,23 @@ export interface Validator {
164
169
  broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
165
170
 
166
171
  /** Collect own attestations for a checkpoint proposal (used when skipping p2p attestation collection) */
167
- collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]>;
172
+ collectOwnAttestations(
173
+ proposal: CheckpointProposal,
174
+ checkpointNumber: CheckpointNumber,
175
+ ): Promise<CheckpointAttestation[]>;
168
176
 
169
177
  /** Collect attestations from the p2p network for a checkpoint proposal */
170
- collectAttestations(proposal: CheckpointProposal, required: number, deadline: Date): Promise<CheckpointAttestation[]>;
178
+ collectAttestations(
179
+ proposal: CheckpointProposal,
180
+ required: number,
181
+ deadline: Date,
182
+ checkpointNumber: CheckpointNumber,
183
+ ): Promise<CheckpointAttestation[]>;
171
184
 
172
185
  signAttestationsAndSigners(
173
186
  attestationsAndSigners: CommitteeAttestationsAndSigners,
174
187
  proposer: EthAddress,
175
188
  slot: SlotNumber,
176
- blockNumber: BlockNumber | CheckpointNumber,
189
+ checkpointNumber: CheckpointNumber,
177
190
  ): Promise<Signature>;
178
191
  }
@@ -1 +1 @@
1
- export * from './slash_factory.js';
1
+ // No exports.
@@ -1,7 +1,6 @@
1
1
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
2
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
3
3
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
4
- import { Fr } from '@aztec/foundation/curves/bn254';
5
4
  import { BufferReader } from '@aztec/foundation/serialize';
6
5
 
7
6
  import { z } from 'zod';
@@ -83,7 +82,7 @@ export class LogId {
83
82
  const reader = BufferReader.asReader(buffer);
84
83
 
85
84
  const blockNumber = BlockNumber(reader.readNumber());
86
- const blockHash = new BlockHash(reader.readObject(Fr));
85
+ const blockHash = BlockHash.fromBuffer(reader);
87
86
  const txHash = reader.readObject(TxHash);
88
87
  const txIndex = reader.readNumber();
89
88
  const logIndex = reader.readNumber();
@@ -1,5 +1,5 @@
1
1
  import { DomainSeparator } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ZodFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import type { AztecAddress } from '../aztec-address/index.js';
@@ -8,19 +8,14 @@ import { schemas } from '../schemas/schemas.js';
8
8
  import type { PreTag } from './pre_tag.js';
9
9
  import { Tag } from './tag.js';
10
10
 
11
- /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
12
-
13
- /** Branding to ensure fields are not interchangeable types. */
14
- export interface SiloedTag {
15
- /** Brand. */
16
- _branding: 'SiloedTag';
17
- }
18
-
19
11
  /**
20
12
  * Represents a tag used in private log as it "appears on the chain" - that is the tag is siloed with a contract
21
13
  * address that emitted the log.
22
14
  */
23
15
  export class SiloedTag {
16
+ /** Branding for nominal typing. */
17
+ declare private readonly _branding: 'SiloedTag';
18
+
24
19
  constructor(public readonly value: Fr) {}
25
20
 
26
21
  static async compute(preTag: PreTag): Promise<SiloedTag> {
@@ -49,6 +44,10 @@ export class SiloedTag {
49
44
  return this.value.equals(other.value);
50
45
  }
51
46
 
47
+ static random(): SiloedTag {
48
+ return new SiloedTag(Fr.random());
49
+ }
50
+
52
51
  static get schema(): ZodFor<SiloedTag> {
53
52
  return schemas.Fr.transform((fr: Fr) => new SiloedTag(fr));
54
53
  }
package/src/logs/tag.ts CHANGED
@@ -1,22 +1,18 @@
1
1
  import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { ZodFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import { schemas } from '../schemas/schemas.js';
6
6
  import type { PreTag } from './pre_tag.js';
7
7
 
8
- /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
9
-
10
- export interface Tag {
11
- /** Brand. */
12
- _branding: 'Tag';
13
- }
14
-
15
8
  /**
16
9
  * Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
17
10
  * with a contract address by kernels before being included in the final log.
18
11
  */
19
12
  export class Tag {
13
+ /** Branding for nominal typing. */
14
+ declare private readonly _branding: 'Tag';
15
+
20
16
  constructor(public readonly value: Fr) {}
21
17
 
22
18
  static async compute(preTag: PreTag): Promise<Tag> {
@@ -36,6 +32,10 @@ export class Tag {
36
32
  return this.value.equals(other.value);
37
33
  }
38
34
 
35
+ static random(): Tag {
36
+ return new Tag(Fr.random());
37
+ }
38
+
39
39
  static get schema(): ZodFor<Tag> {
40
40
  return schemas.Fr.transform((fr: Fr) => new Tag(fr));
41
41
  }
@@ -1,12 +1,19 @@
1
- import { BlockNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import {
2
+ BlockNumber,
3
+ BlockProposalHash,
4
+ type CheckpointNumber,
5
+ IndexWithinCheckpoint,
6
+ SlotNumber,
7
+ } from '@aztec/foundation/branded-types';
8
+ import type { BaseBuffer32 } from '@aztec/foundation/buffer';
3
9
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
- import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
10
  import { Fr } from '@aztec/foundation/curves/bn254';
6
11
  import type { EthAddress } from '@aztec/foundation/eth-address';
7
12
  import { Signature } from '@aztec/foundation/eth-signature';
8
13
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
9
14
 
15
+ import type { TypedDataDefinition } from 'viem';
16
+
10
17
  import type { L2Block } from '../block/l2_block.js';
11
18
  import type { L2BlockInfo } from '../block/l2_block_info.js';
12
19
  import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
@@ -16,18 +23,20 @@ import { TxHash } from '../tx/index.js';
16
23
  import type { Tx } from '../tx/tx.js';
17
24
  import { Gossipable } from './gossipable.js';
18
25
  import {
19
- SignatureDomainSeparator,
20
- getHashedSignaturePayload,
21
- getHashedSignaturePayloadEthSignedMessage,
26
+ type CoordinationSignatureContext,
27
+ type CoordinationSignatureType,
28
+ EMPTY_COORDINATION_SIGNATURE_CONTEXT,
29
+ type Signable,
30
+ coordinationSignatureContextEquals,
31
+ getCoordinationSignatureTypedData,
32
+ readCoordinationSignatureContext,
33
+ recoverCoordinationSigner,
34
+ serializeCoordinationSignatureContext,
22
35
  } from './signature_utils.js';
23
36
  import { SignedTxs } from './signed_txs.js';
24
37
  import { TopicType } from './topic_type.js';
25
38
 
26
- export class BlockProposalHash extends Buffer32 {
27
- constructor(hash: Buffer) {
28
- super(hash);
29
- }
30
- }
39
+ export type { BlockProposalHash } from '@aztec/foundation/branded-types';
31
40
 
32
41
  export type BlockProposalOptions = {
33
42
  /**
@@ -47,10 +56,12 @@ export type BlockProposalOptions = {
47
56
  * to be included in a block within a checkpoint. This is used for non-last blocks in a slot.
48
57
  * The last block is sent as part of a CheckpointProposal.
49
58
  */
50
- export class BlockProposal extends Gossipable {
59
+ export class BlockProposal extends Gossipable implements Signable {
51
60
  static override p2pTopic = TopicType.block_proposal;
52
61
 
53
- private sender: EthAddress | undefined;
62
+ readonly primaryType: CoordinationSignatureType = 'BlockProposal';
63
+
64
+ private cachedSender: EthAddress | undefined | null = undefined;
54
65
 
55
66
  constructor(
56
67
  /** The per-block header containing block state and global variables */
@@ -71,14 +82,17 @@ export class BlockProposal extends Gossipable {
71
82
  /** The proposer's signature over the block data */
72
83
  public readonly signature: Signature,
73
84
 
85
+ /** The signing domain (chainId + rollupAddress) the signature is bound to */
86
+ public readonly signatureContext: CoordinationSignatureContext,
87
+
74
88
  /** The signed transactions in the block (optional, for DA guarantees) */
75
89
  public readonly signedTxs?: SignedTxs,
76
90
  ) {
77
91
  super();
78
92
  }
79
93
 
80
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
81
- return Promise.resolve(new BlockProposalHash(keccak256(this.signature.toBuffer())));
94
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
95
+ return Promise.resolve(BlockProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
82
96
  }
83
97
 
84
98
  get archive(): Fr {
@@ -112,9 +126,8 @@ export class BlockProposal extends Gossipable {
112
126
  * Get the payload to sign for this block proposal.
113
127
  * The signature is over: blockHeader + indexWithinCheckpoint + inHash + archiveRoot + txHashes
114
128
  */
115
- getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
129
+ getPayloadToSign(): Buffer {
116
130
  return serializeToBuffer([
117
- domainSeparator,
118
131
  this.blockHeader,
119
132
  this.indexWithinCheckpoint,
120
133
  this.inHash,
@@ -126,12 +139,15 @@ export class BlockProposal extends Gossipable {
126
139
 
127
140
  static async createProposalFromSigner(
128
141
  blockHeader: BlockHeader,
142
+ checkpointNumber: CheckpointNumber,
129
143
  indexWithinCheckpoint: IndexWithinCheckpoint,
130
144
  inHash: Fr,
131
145
  archiveRoot: Fr,
132
146
  txHashes: TxHash[],
133
147
  txs: Tx[] | undefined,
134
- payloadSigner: (payload: Buffer32, context: SigningContext) => Promise<Signature>,
148
+ signatureContext: CoordinationSignatureContext,
149
+ proposalSigner: (typedData: TypedDataDefinition, context: SigningContext) => Promise<Signature>,
150
+ txsSigner?: (typedData: TypedDataDefinition, context: SigningContext) => Promise<Signature>,
135
151
  ): Promise<BlockProposal> {
136
152
  // Create a temporary proposal to get the payload to sign
137
153
  const tempProposal = new BlockProposal(
@@ -141,57 +157,76 @@ export class BlockProposal extends Gossipable {
141
157
  archiveRoot,
142
158
  txHashes,
143
159
  Signature.empty(),
160
+ signatureContext,
144
161
  );
145
162
 
146
163
  // Create the block signing context
147
164
  const blockContext: SigningContext = {
148
165
  slot: blockHeader.globalVariables.slotNumber,
149
166
  blockNumber: blockHeader.globalVariables.blockNumber,
167
+ checkpointNumber,
150
168
  blockIndexWithinCheckpoint: indexWithinCheckpoint,
151
169
  dutyType: DutyType.BLOCK_PROPOSAL,
152
170
  };
153
171
 
154
- const hashed = getHashedSignaturePayload(tempProposal, SignatureDomainSeparator.blockProposal);
155
- const sig = await payloadSigner(hashed, blockContext);
172
+ const typedData = getCoordinationSignatureTypedData(tempProposal);
173
+ const sig = await proposalSigner(typedData, blockContext);
156
174
 
157
175
  // If txs are provided, sign them as well
158
176
  let signedTxs: SignedTxs | undefined;
159
177
  if (txs) {
160
178
  const txsSigningContext: SigningContext = { dutyType: DutyType.TXS };
161
- const txsSigner = (payload: Buffer32) => payloadSigner(payload, txsSigningContext);
162
- signedTxs = await SignedTxs.createFromSigner(txs, txsSigner);
179
+ if (!txsSigner) {
180
+ throw new Error('signed_txs requires a typed-data signer');
181
+ }
182
+ signedTxs = await SignedTxs.createFromSigner(txs, signatureContext, typedData =>
183
+ txsSigner(typedData, txsSigningContext),
184
+ );
163
185
  }
164
186
 
165
- return new BlockProposal(blockHeader, indexWithinCheckpoint, inHash, archiveRoot, txHashes, sig, signedTxs);
187
+ return new BlockProposal(
188
+ blockHeader,
189
+ indexWithinCheckpoint,
190
+ inHash,
191
+ archiveRoot,
192
+ txHashes,
193
+ sig,
194
+ signatureContext,
195
+ signedTxs,
196
+ );
166
197
  }
167
198
 
168
199
  /**
169
200
  * Lazily evaluate the sender of the proposal; result is cached.
170
- * If there's signedTxs, also verifies the signedTxs sender matches the block proposal sender.
171
- * @returns The sender address, or undefined if signature recovery fails or senders don't match
201
+ * If there's signedTxs, also verifies that its signing domain matches this proposal's and
202
+ * that the signedTxs sender matches the block proposal sender. This prevents a proposer
203
+ * from wrapping a foreign-chain SignedTxs bundle inside a local-chain proposal.
204
+ * @returns The sender address, or undefined if signature recovery fails or inner/outer mismatch
172
205
  */
173
206
  getSender(): EthAddress | undefined {
174
- if (!this.sender) {
175
- const hashed = getHashedSignaturePayloadEthSignedMessage(this, SignatureDomainSeparator.blockProposal);
176
- const blockSender = tryRecoverAddress(hashed, this.signature);
207
+ if (this.cachedSender === undefined) {
208
+ const blockSender = recoverCoordinationSigner(this, this.signature);
177
209
 
178
- // If there's signedTxs, verify the sender matches
179
210
  if (blockSender && this.signedTxs) {
211
+ if (!coordinationSignatureContextEquals(this.signedTxs.signatureContext, this.signatureContext)) {
212
+ this.cachedSender = null;
213
+ return undefined;
214
+ }
180
215
  const txsSender = this.signedTxs.getSender();
181
216
  if (!txsSender || !txsSender.equals(blockSender)) {
182
- return undefined; // Sender mismatch - fail
217
+ this.cachedSender = null;
218
+ return undefined;
183
219
  }
184
220
  }
185
221
 
186
- // Cache the sender for later use
187
- this.sender = blockSender;
222
+ this.cachedSender = blockSender ?? null;
188
223
  }
189
224
 
190
- return this.sender;
225
+ return this.cachedSender ?? undefined;
191
226
  }
192
227
 
193
228
  getPayload() {
194
- return this.getPayloadToSign(SignatureDomainSeparator.blockProposal);
229
+ return this.getPayloadToSign();
195
230
  }
196
231
 
197
232
  toBuffer(): Buffer {
@@ -201,6 +236,7 @@ export class BlockProposal extends Gossipable {
201
236
  this.inHash,
202
237
  this.archiveRoot,
203
238
  this.signature,
239
+ serializeCoordinationSignatureContext(this.signatureContext),
204
240
  this.txHashes.length,
205
241
  this.txHashes,
206
242
  ];
@@ -221,6 +257,7 @@ export class BlockProposal extends Gossipable {
221
257
  const inHash = reader.readObject(Fr);
222
258
  const archiveRoot = reader.readObject(Fr);
223
259
  const signature = reader.readObject(Signature);
260
+ const signatureContext = readCoordinationSignatureContext(reader);
224
261
  const txHashCount = reader.readNumber();
225
262
  if (txHashCount > MAX_TXS_PER_BLOCK) {
226
263
  throw new Error(`txHashes count ${txHashCount} exceeds maximum ${MAX_TXS_PER_BLOCK}`);
@@ -238,12 +275,21 @@ export class BlockProposal extends Gossipable {
238
275
  archiveRoot,
239
276
  txHashes,
240
277
  signature,
278
+ signatureContext,
241
279
  signedTxs,
242
280
  );
243
281
  }
244
282
  }
245
283
 
246
- return new BlockProposal(blockHeader, indexWithinCheckpoint, inHash, archiveRoot, txHashes, signature);
284
+ return new BlockProposal(
285
+ blockHeader,
286
+ indexWithinCheckpoint,
287
+ inHash,
288
+ archiveRoot,
289
+ txHashes,
290
+ signature,
291
+ signatureContext,
292
+ );
247
293
  }
248
294
 
249
295
  getSize(): number {
@@ -253,6 +299,8 @@ export class BlockProposal extends Gossipable {
253
299
  this.inHash.size +
254
300
  this.archiveRoot.size +
255
301
  this.signature.getSize() +
302
+ 4 /* chainId */ +
303
+ 20 /* rollupAddress */ +
256
304
  4 /* txHashes.length */ +
257
305
  this.txHashes.length * TxHash.SIZE +
258
306
  4 /* hasSignedTxs flag */ +
@@ -261,7 +309,15 @@ export class BlockProposal extends Gossipable {
261
309
  }
262
310
 
263
311
  static empty(): BlockProposal {
264
- return new BlockProposal(BlockHeader.empty(), IndexWithinCheckpoint(0), Fr.ZERO, Fr.ZERO, [], Signature.empty());
312
+ return new BlockProposal(
313
+ BlockHeader.empty(),
314
+ IndexWithinCheckpoint(0),
315
+ Fr.ZERO,
316
+ Fr.ZERO,
317
+ [],
318
+ Signature.empty(),
319
+ EMPTY_COORDINATION_SIGNATURE_CONTEXT,
320
+ );
265
321
  }
266
322
 
267
323
  static random(): BlockProposal {
@@ -272,6 +328,7 @@ export class BlockProposal extends Gossipable {
272
328
  Fr.random(),
273
329
  [TxHash.random(), TxHash.random()],
274
330
  Signature.random(),
331
+ EMPTY_COORDINATION_SIGNATURE_CONTEXT,
275
332
  );
276
333
  }
277
334
 
@@ -283,6 +340,8 @@ export class BlockProposal extends Gossipable {
283
340
  archiveRoot: this.archiveRoot.toString(),
284
341
  signature: this.signature.toString(),
285
342
  txHashes: this.txHashes.map(h => h.toString()),
343
+ chainId: this.signatureContext.chainId,
344
+ rollupAddress: this.signatureContext.rollupAddress.toString(),
286
345
  };
287
346
  }
288
347
 
@@ -308,6 +367,7 @@ export class BlockProposal extends Gossipable {
308
367
  this.archiveRoot,
309
368
  this.txHashes,
310
369
  this.signature,
370
+ this.signatureContext,
311
371
  );
312
372
  }
313
373
  }