@aztec/stdlib 0.0.1-commit.f5d02921e → 0.0.1-commit.f7ea82942

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 (267) 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/avm.d.ts +300 -300
  18. package/dest/avm/revert_code.d.ts +8 -18
  19. package/dest/avm/revert_code.d.ts.map +1 -1
  20. package/dest/avm/revert_code.js +15 -30
  21. package/dest/aztec-address/index.d.ts +3 -6
  22. package/dest/aztec-address/index.d.ts.map +1 -1
  23. package/dest/aztec-address/index.js +2 -4
  24. package/dest/block/block_data.d.ts +8 -8
  25. package/dest/block/block_data.d.ts.map +1 -1
  26. package/dest/block/block_data.js +2 -2
  27. package/dest/block/block_hash.d.ts +11 -10
  28. package/dest/block/block_hash.d.ts.map +1 -1
  29. package/dest/block/block_hash.js +10 -9
  30. package/dest/block/l2_block_info.d.ts +6 -5
  31. package/dest/block/l2_block_info.d.ts.map +1 -1
  32. package/dest/block/l2_block_info.js +6 -5
  33. package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
  34. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  35. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  36. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  37. package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
  38. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  39. package/dest/config/chain-config.d.ts +1 -1
  40. package/dest/config/chain-config.d.ts.map +1 -1
  41. package/dest/config/chain-config.js +7 -1
  42. package/dest/config/sequencer-config.d.ts +2 -2
  43. package/dest/config/sequencer-config.d.ts.map +1 -1
  44. package/dest/config/sequencer-config.js +10 -3
  45. package/dest/contract/private_function.d.ts +1 -1
  46. package/dest/contract/private_function.d.ts.map +1 -1
  47. package/dest/contract/private_function.js +2 -4
  48. package/dest/gas/fee_math.d.ts +49 -0
  49. package/dest/gas/fee_math.d.ts.map +1 -0
  50. package/dest/gas/fee_math.js +80 -0
  51. package/dest/gas/gas_fees.d.ts +5 -1
  52. package/dest/gas/gas_fees.d.ts.map +1 -1
  53. package/dest/gas/gas_fees.js +10 -1
  54. package/dest/gas/gas_settings.d.ts +40 -3
  55. package/dest/gas/gas_settings.d.ts.map +1 -1
  56. package/dest/gas/gas_settings.js +50 -6
  57. package/dest/gas/index.d.ts +2 -1
  58. package/dest/gas/index.d.ts.map +1 -1
  59. package/dest/gas/index.js +1 -0
  60. package/dest/ha-signing/config.d.ts +6 -6
  61. package/dest/ha-signing/config.d.ts.map +1 -1
  62. package/dest/ha-signing/config.js +4 -3
  63. package/dest/ha-signing/index.d.ts +2 -2
  64. package/dest/ha-signing/index.d.ts.map +1 -1
  65. package/dest/ha-signing/index.js +1 -1
  66. package/dest/ha-signing/local_config.js +1 -1
  67. package/dest/ha-signing/types.d.ts +37 -32
  68. package/dest/ha-signing/types.d.ts.map +1 -1
  69. package/dest/ha-signing/types.js +13 -6
  70. package/dest/hash/hash.d.ts +16 -1
  71. package/dest/hash/hash.d.ts.map +1 -1
  72. package/dest/hash/hash.js +32 -0
  73. package/dest/interfaces/archiver.d.ts +11 -1
  74. package/dest/interfaces/archiver.d.ts.map +1 -1
  75. package/dest/interfaces/archiver.js +3 -1
  76. package/dest/interfaces/aztec-node-admin.d.ts +9 -14
  77. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  78. package/dest/interfaces/aztec-node-admin.js +3 -3
  79. package/dest/interfaces/aztec-node-debug.d.ts +21 -0
  80. package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
  81. package/dest/interfaces/aztec-node-debug.js +18 -0
  82. package/dest/interfaces/aztec-node.d.ts +10 -1
  83. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  84. package/dest/interfaces/aztec-node.js +2 -0
  85. package/dest/interfaces/client.d.ts +2 -1
  86. package/dest/interfaces/client.d.ts.map +1 -1
  87. package/dest/interfaces/client.js +1 -0
  88. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  89. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  90. package/dest/interfaces/prover-client.d.ts +1 -1
  91. package/dest/interfaces/prover-client.d.ts.map +1 -1
  92. package/dest/interfaces/prover-client.js +0 -3
  93. package/dest/interfaces/slasher.d.ts +1 -10
  94. package/dest/interfaces/slasher.d.ts.map +1 -1
  95. package/dest/interfaces/slasher.js +0 -2
  96. package/dest/interfaces/validator.d.ts +14 -17
  97. package/dest/interfaces/validator.d.ts.map +1 -1
  98. package/dest/l1-contracts/index.d.ts +2 -2
  99. package/dest/l1-contracts/index.d.ts.map +1 -1
  100. package/dest/l1-contracts/index.js +1 -1
  101. package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
  102. package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
  103. package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
  104. package/dest/logs/log_id.d.ts +1 -1
  105. package/dest/logs/log_id.d.ts.map +1 -1
  106. package/dest/logs/log_id.js +1 -2
  107. package/dest/logs/siloed_tag.d.ts +5 -7
  108. package/dest/logs/siloed_tag.d.ts.map +1 -1
  109. package/dest/logs/siloed_tag.js +4 -0
  110. package/dest/logs/tag.d.ts +5 -6
  111. package/dest/logs/tag.d.ts.map +1 -1
  112. package/dest/logs/tag.js +4 -0
  113. package/dest/p2p/block_proposal.d.ts +6 -8
  114. package/dest/p2p/block_proposal.d.ts.map +1 -1
  115. package/dest/p2p/block_proposal.js +4 -9
  116. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  117. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  118. package/dest/p2p/checkpoint_attestation.js +2 -7
  119. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  120. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  121. package/dest/p2p/checkpoint_proposal.js +5 -24
  122. package/dest/p2p/gossipable.d.ts +4 -4
  123. package/dest/p2p/gossipable.d.ts.map +1 -1
  124. package/dest/rollup/block_headers_hash.d.ts +1 -1
  125. package/dest/rollup/block_headers_hash.d.ts.map +1 -1
  126. package/dest/rollup/block_headers_hash.js +8 -2
  127. package/dest/slashing/index.d.ts +2 -3
  128. package/dest/slashing/index.d.ts.map +1 -1
  129. package/dest/slashing/index.js +1 -2
  130. package/dest/slashing/serialization.d.ts +2 -6
  131. package/dest/slashing/serialization.d.ts.map +1 -1
  132. package/dest/slashing/serialization.js +0 -60
  133. package/dest/slashing/types.d.ts +4 -90
  134. package/dest/slashing/types.d.ts.map +1 -1
  135. package/dest/slashing/types.js +0 -14
  136. package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
  137. package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
  138. package/dest/slashing/{tally.js → votes.js} +1 -1
  139. package/dest/tests/factories.d.ts +2 -7
  140. package/dest/tests/factories.d.ts.map +1 -1
  141. package/dest/tests/factories.js +2 -8
  142. package/dest/tests/mocks.d.ts +1 -1
  143. package/dest/tests/mocks.d.ts.map +1 -1
  144. package/dest/tests/mocks.js +14 -19
  145. package/dest/timetable/index.d.ts +51 -1
  146. package/dest/timetable/index.d.ts.map +1 -1
  147. package/dest/timetable/index.js +204 -14
  148. package/dest/trees/nullifier_leaf.d.ts +2 -1
  149. package/dest/trees/nullifier_leaf.d.ts.map +1 -1
  150. package/dest/trees/nullifier_leaf.js +3 -0
  151. package/dest/tx/block_header.d.ts +2 -2
  152. package/dest/tx/block_header.d.ts.map +1 -1
  153. package/dest/tx/block_header.js +1 -1
  154. package/dest/tx/fee_provider.d.ts +10 -0
  155. package/dest/tx/fee_provider.d.ts.map +1 -0
  156. package/dest/tx/fee_provider.js +1 -0
  157. package/dest/tx/global_variable_builder.d.ts +3 -16
  158. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  159. package/dest/tx/index.d.ts +2 -1
  160. package/dest/tx/index.d.ts.map +1 -1
  161. package/dest/tx/index.js +1 -0
  162. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  163. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  164. package/dest/tx/indexed_tx_effect.js +1 -2
  165. package/dest/tx/simulated_tx.d.ts +4 -4
  166. package/dest/tx/simulated_tx.d.ts.map +1 -1
  167. package/dest/tx/simulated_tx.js +3 -3
  168. package/dest/tx/tx.d.ts +3 -3
  169. package/dest/tx/tx.d.ts.map +1 -1
  170. package/dest/tx/tx_receipt.d.ts +8 -4
  171. package/dest/tx/tx_receipt.d.ts.map +1 -1
  172. package/dest/tx/tx_receipt.js +8 -15
  173. package/dest/types/shared.d.ts +1 -10
  174. package/dest/types/shared.d.ts.map +1 -1
  175. package/dest/types/shared.js +0 -9
  176. package/dest/vks/verification_key.d.ts +2 -137
  177. package/dest/vks/verification_key.d.ts.map +1 -1
  178. package/dest/vks/verification_key.js +5 -126
  179. package/dest/world-state/genesis_data.d.ts +11 -0
  180. package/dest/world-state/genesis_data.d.ts.map +1 -0
  181. package/dest/world-state/genesis_data.js +4 -0
  182. package/dest/world-state/index.d.ts +2 -1
  183. package/dest/world-state/index.d.ts.map +1 -1
  184. package/dest/world-state/index.js +1 -0
  185. package/dest/world-state/world_state_revision.d.ts +8 -1
  186. package/dest/world-state/world_state_revision.d.ts.map +1 -1
  187. package/dest/world-state/world_state_revision.js +7 -1
  188. package/package.json +8 -8
  189. package/src/abi/authorization_selector.ts +2 -8
  190. package/src/abi/encoder.ts +42 -6
  191. package/src/abi/event_selector.ts +2 -8
  192. package/src/abi/function_selector.ts +3 -12
  193. package/src/abi/note_selector.ts +3 -12
  194. package/src/abi/selector.ts +1 -1
  195. package/src/avm/revert_code.ts +25 -39
  196. package/src/aztec-address/index.ts +4 -10
  197. package/src/block/block_data.ts +3 -4
  198. package/src/block/block_hash.ts +21 -14
  199. package/src/block/l2_block_info.ts +8 -6
  200. package/src/block/l2_block_stream/interfaces.ts +6 -2
  201. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  202. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  203. package/src/config/chain-config.ts +7 -1
  204. package/src/config/sequencer-config.ts +14 -4
  205. package/src/contract/private_function.ts +3 -1
  206. package/src/gas/README.md +31 -0
  207. package/src/gas/fee_math.ts +120 -0
  208. package/src/gas/gas_fees.ts +17 -4
  209. package/src/gas/gas_settings.ts +65 -12
  210. package/src/gas/index.ts +1 -0
  211. package/src/ha-signing/config.ts +5 -2
  212. package/src/ha-signing/index.ts +3 -1
  213. package/src/ha-signing/local_config.ts +1 -1
  214. package/src/ha-signing/types.ts +48 -34
  215. package/src/hash/hash.ts +27 -0
  216. package/src/interfaces/archiver.ts +8 -0
  217. package/src/interfaces/aztec-node-admin.ts +5 -7
  218. package/src/interfaces/aztec-node-debug.ts +40 -0
  219. package/src/interfaces/aztec-node.ts +15 -0
  220. package/src/interfaces/client.ts +1 -0
  221. package/src/interfaces/merkle_tree_operations.ts +3 -2
  222. package/src/interfaces/prover-client.ts +2 -5
  223. package/src/interfaces/slasher.ts +0 -6
  224. package/src/interfaces/validator.ts +15 -8
  225. package/src/l1-contracts/index.ts +1 -1
  226. package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
  227. package/src/logs/log_id.ts +1 -2
  228. package/src/logs/siloed_tag.ts +8 -9
  229. package/src/logs/tag.ts +8 -8
  230. package/src/p2p/block_proposal.ts +13 -9
  231. package/src/p2p/checkpoint_attestation.ts +5 -9
  232. package/src/p2p/checkpoint_proposal.ts +21 -36
  233. package/src/p2p/gossipable.ts +4 -4
  234. package/src/rollup/block_headers_hash.ts +11 -2
  235. package/src/slashing/index.ts +1 -2
  236. package/src/slashing/serialization.ts +1 -81
  237. package/src/slashing/types.ts +3 -35
  238. package/src/slashing/{tally.ts → votes.ts} +1 -1
  239. package/src/tests/factories.ts +2 -10
  240. package/src/tests/mocks.ts +16 -12
  241. package/src/timetable/index.ts +293 -13
  242. package/src/trees/nullifier_leaf.ts +4 -0
  243. package/src/tx/block_header.ts +2 -2
  244. package/src/tx/fee_provider.ts +10 -0
  245. package/src/tx/global_variable_builder.ts +2 -18
  246. package/src/tx/index.ts +1 -0
  247. package/src/tx/indexed_tx_effect.ts +1 -2
  248. package/src/tx/simulated_tx.ts +6 -2
  249. package/src/tx/tx.ts +2 -2
  250. package/src/tx/tx_receipt.ts +11 -14
  251. package/src/types/shared.ts +0 -10
  252. package/src/vks/verification_key.ts +5 -184
  253. package/src/world-state/genesis_data.ts +15 -0
  254. package/src/world-state/index.ts +1 -0
  255. package/src/world-state/world_state_revision.ts +9 -1
  256. package/dest/abi/mocked_keys.d.ts +0 -2
  257. package/dest/abi/mocked_keys.d.ts.map +0 -1
  258. package/dest/abi/mocked_keys.js +0 -1
  259. package/dest/l1-contracts/slash_factory.d.ts +0 -45
  260. package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
  261. package/dest/l1-contracts/slash_factory.js +0 -158
  262. package/dest/slashing/empire.d.ts +0 -31
  263. package/dest/slashing/empire.d.ts.map +0 -1
  264. package/dest/slashing/empire.js +0 -87
  265. package/src/abi/mocked_keys.ts +0 -2
  266. package/src/l1-contracts/slash_factory.ts +0 -180
  267. package/src/slashing/empire.ts +0 -104
@@ -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
 
@@ -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';
@@ -118,8 +117,6 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
118
117
  }),
119
118
  );
120
119
 
121
- export type CreateCheckpointProposalLastBlockData = Omit<CheckpointLastBlockData, 'txHashes'> & { txs: Tx[] };
122
-
123
120
  export interface Validator {
124
121
  start(): Promise<void>;
125
122
  updateConfig(config: Partial<ValidatorClientFullConfig>): void;
@@ -127,6 +124,7 @@ export interface Validator {
127
124
  // Block validation responsibilities
128
125
  createBlockProposal(
129
126
  blockHeader: BlockHeader,
127
+ checkpointNumber: CheckpointNumber,
130
128
  indexWithinCheckpoint: number,
131
129
  inHash: Fr,
132
130
  archive: Fr,
@@ -139,8 +137,9 @@ export interface Validator {
139
137
  createCheckpointProposal(
140
138
  checkpointHeader: CheckpointHeader,
141
139
  archive: Fr,
140
+ checkpointNumber: CheckpointNumber,
142
141
  feeAssetPriceModifier: bigint,
143
- lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
142
+ lastBlockProposal: BlockProposal | undefined,
144
143
  proposerAddress: EthAddress | undefined,
145
144
  options: CheckpointProposalOptions,
146
145
  ): Promise<CheckpointProposal>;
@@ -164,15 +163,23 @@ export interface Validator {
164
163
  broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
165
164
 
166
165
  /** Collect own attestations for a checkpoint proposal (used when skipping p2p attestation collection) */
167
- collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]>;
166
+ collectOwnAttestations(
167
+ proposal: CheckpointProposal,
168
+ checkpointNumber: CheckpointNumber,
169
+ ): Promise<CheckpointAttestation[]>;
168
170
 
169
171
  /** Collect attestations from the p2p network for a checkpoint proposal */
170
- collectAttestations(proposal: CheckpointProposal, required: number, deadline: Date): Promise<CheckpointAttestation[]>;
172
+ collectAttestations(
173
+ proposal: CheckpointProposal,
174
+ required: number,
175
+ deadline: Date,
176
+ checkpointNumber: CheckpointNumber,
177
+ ): Promise<CheckpointAttestation[]>;
171
178
 
172
179
  signAttestationsAndSigners(
173
180
  attestationsAndSigners: CommitteeAttestationsAndSigners,
174
181
  proposer: EthAddress,
175
182
  slot: SlotNumber,
176
- blockNumber: BlockNumber | CheckpointNumber,
183
+ checkpointNumber: CheckpointNumber,
177
184
  ): Promise<Signature>;
178
185
  }
@@ -1 +1 @@
1
- export * from './slash_factory.js';
1
+ // No exports.
@@ -23,14 +23,14 @@ import { computeAddressSecret, computePreaddress } from '../keys/derivation.js';
23
23
  * doesn't seem to be a good way around this.
24
24
  */
25
25
  export class ExtendedDirectionalAppTaggingSecret {
26
- private constructor(
26
+ constructor(
27
27
  public readonly secret: Fr,
28
28
  public readonly app: AztecAddress,
29
29
  ) {}
30
30
 
31
31
  /**
32
32
  * Derives shared tagging secret and from that, the app address and recipient derives the directional app tagging
33
- * secret.
33
+ * secret. Returns undefined if `externalAddress` is an invalid address.
34
34
  *
35
35
  * @param localAddress - The complete address of entity A in the shared tagging secret derivation scheme
36
36
  * @param localIvsk - The incoming viewing secret key of entity A
@@ -45,8 +45,12 @@ export class ExtendedDirectionalAppTaggingSecret {
45
45
  externalAddress: AztecAddress,
46
46
  app: AztecAddress,
47
47
  recipient: AztecAddress,
48
- ): Promise<ExtendedDirectionalAppTaggingSecret> {
48
+ ): Promise<ExtendedDirectionalAppTaggingSecret | undefined> {
49
49
  const taggingSecretPoint = await computeSharedTaggingSecret(localAddress, localIvsk, externalAddress);
50
+ if (!taggingSecretPoint) {
51
+ return undefined;
52
+ }
53
+
50
54
  const appTaggingSecret = await poseidon2Hash([taggingSecretPoint.x, taggingSecretPoint.y, app]);
51
55
  const directionalAppTaggingSecret = await poseidon2Hash([appTaggingSecret, recipient]);
52
56
 
@@ -63,18 +67,25 @@ export class ExtendedDirectionalAppTaggingSecret {
63
67
  }
64
68
  }
65
69
 
66
- // Returns shared tagging secret computed with Diffie-Hellman key exchange.
70
+ // Returns shared tagging secret computed with Diffie-Hellman key exchange, or undefined if `externalAddress` is an
71
+ // invalid address.
67
72
  async function computeSharedTaggingSecret(
68
73
  localAddress: CompleteAddress,
69
74
  localIvsk: Fq,
70
75
  externalAddress: AztecAddress,
71
- ): Promise<Point> {
72
- const knownPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
73
- // TODO: #8970 - Computation of address point from x coordinate might fail
74
- const externalAddressPoint = await externalAddress.toAddressPoint();
76
+ ): Promise<Point | undefined> {
75
77
  // Given A (local complete address) -> B (external address) and h == preaddress
76
78
  // Compute shared secret as S = (h_A + local_ivsk_A) * Addr_Point_B
77
79
 
80
+ const knownPreaddress = await computePreaddress(await localAddress.publicKeys.hash(), localAddress.partialAddress);
81
+
82
+ // An invalid address has no corresponding address point
83
+ if (!(await externalAddress.isValid())) {
84
+ return undefined;
85
+ }
86
+
87
+ const externalAddressPoint = await externalAddress.toAddressPoint();
88
+
78
89
  // Beware! h_a + local_ivsk_a (also known as the address secret) can lead to an address point with a negative
79
90
  // y-coordinate, since there's two possible candidates computeAddressSecret takes care of selecting the one that
80
91
  // leads to a positive y-coordinate, which is the only valid address point
@@ -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,5 +1,11 @@
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, Buffer32 } from '@aztec/foundation/buffer';
3
9
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
10
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
11
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -23,11 +29,7 @@ import {
23
29
  import { SignedTxs } from './signed_txs.js';
24
30
  import { TopicType } from './topic_type.js';
25
31
 
26
- export class BlockProposalHash extends Buffer32 {
27
- constructor(hash: Buffer) {
28
- super(hash);
29
- }
30
- }
32
+ export type { BlockProposalHash } from '@aztec/foundation/branded-types';
31
33
 
32
34
  export type BlockProposalOptions = {
33
35
  /**
@@ -77,8 +79,8 @@ export class BlockProposal extends Gossipable {
77
79
  super();
78
80
  }
79
81
 
80
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
81
- return Promise.resolve(new BlockProposalHash(keccak256(this.signature.toBuffer())));
82
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
83
+ return Promise.resolve(BlockProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
82
84
  }
83
85
 
84
86
  get archive(): Fr {
@@ -126,6 +128,7 @@ export class BlockProposal extends Gossipable {
126
128
 
127
129
  static async createProposalFromSigner(
128
130
  blockHeader: BlockHeader,
131
+ checkpointNumber: CheckpointNumber,
129
132
  indexWithinCheckpoint: IndexWithinCheckpoint,
130
133
  inHash: Fr,
131
134
  archiveRoot: Fr,
@@ -147,6 +150,7 @@ export class BlockProposal extends Gossipable {
147
150
  const blockContext: SigningContext = {
148
151
  slot: blockHeader.globalVariables.slotNumber,
149
152
  blockNumber: blockHeader.globalVariables.blockNumber,
153
+ checkpointNumber,
150
154
  blockIndexWithinCheckpoint: indexWithinCheckpoint,
151
155
  dutyType: DutyType.BLOCK_PROPOSAL,
152
156
  };
@@ -1,5 +1,5 @@
1
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
1
+ import { CheckpointAttestationHash, SlotNumber } from '@aztec/foundation/branded-types';
2
+ import type { BaseBuffer32 } from '@aztec/foundation/buffer';
3
3
  import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
4
  import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
5
5
  import type { Fr } from '@aztec/foundation/curves/bn254';
@@ -16,11 +16,7 @@ import { Gossipable } from './gossipable.js';
16
16
  import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js';
17
17
  import { TopicType } from './topic_type.js';
18
18
 
19
- export class CheckpointAttestationHash extends Buffer32 {
20
- constructor(hash: Buffer) {
21
- super(hash);
22
- }
23
- }
19
+ export type { CheckpointAttestationHash } from '@aztec/foundation/branded-types';
24
20
 
25
21
  /**
26
22
  * CheckpointAttestation
@@ -57,8 +53,8 @@ export class CheckpointAttestation extends Gossipable {
57
53
  .transform(obj => new CheckpointAttestation(obj.payload, obj.signature, obj.proposerSignature));
58
54
  }
59
55
 
60
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
61
- return Promise.resolve(new CheckpointAttestationHash(keccak256(this.signature.toBuffer())));
56
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
57
+ return Promise.resolve(CheckpointAttestationHash.fromBuffer(keccak256(this.signature.toBuffer())));
62
58
  }
63
59
 
64
60
  get archive(): Fr {
@@ -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,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
- }