@aztec/stdlib 5.0.0-nightly.20260413 → 5.0.0-nightly.20260415

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 (105) 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/event_selector.d.ts +3 -6
  4. package/dest/abi/event_selector.d.ts.map +1 -1
  5. package/dest/abi/function_selector.d.ts +3 -6
  6. package/dest/abi/function_selector.d.ts.map +1 -1
  7. package/dest/abi/function_selector.js +1 -3
  8. package/dest/abi/note_selector.d.ts +3 -6
  9. package/dest/abi/note_selector.d.ts.map +1 -1
  10. package/dest/abi/note_selector.js +1 -3
  11. package/dest/aztec-address/index.d.ts +3 -6
  12. package/dest/aztec-address/index.d.ts.map +1 -1
  13. package/dest/aztec-address/index.js +2 -4
  14. package/dest/block/block_data.d.ts +8 -8
  15. package/dest/block/block_data.d.ts.map +1 -1
  16. package/dest/block/block_data.js +2 -2
  17. package/dest/block/block_hash.d.ts +11 -10
  18. package/dest/block/block_hash.d.ts.map +1 -1
  19. package/dest/block/block_hash.js +10 -9
  20. package/dest/block/l2_block_info.d.ts +6 -5
  21. package/dest/block/l2_block_info.d.ts.map +1 -1
  22. package/dest/block/l2_block_info.js +6 -5
  23. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
  24. package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
  25. package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
  26. package/dest/block/test/l2_tips_store_test_suite.js +1 -1
  27. package/dest/config/chain-config.d.ts +1 -1
  28. package/dest/config/chain-config.d.ts.map +1 -1
  29. package/dest/config/chain-config.js +7 -1
  30. package/dest/config/sequencer-config.js +4 -4
  31. package/dest/ha-signing/index.d.ts +2 -2
  32. package/dest/ha-signing/index.d.ts.map +1 -1
  33. package/dest/ha-signing/index.js +1 -1
  34. package/dest/ha-signing/local_config.js +1 -1
  35. package/dest/ha-signing/types.d.ts +37 -32
  36. package/dest/ha-signing/types.d.ts.map +1 -1
  37. package/dest/ha-signing/types.js +13 -6
  38. package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
  39. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  40. package/dest/interfaces/prover-client.d.ts +1 -1
  41. package/dest/interfaces/prover-client.d.ts.map +1 -1
  42. package/dest/interfaces/prover-client.js +0 -3
  43. package/dest/interfaces/validator.d.ts +7 -7
  44. package/dest/interfaces/validator.d.ts.map +1 -1
  45. package/dest/logs/log_id.d.ts +1 -1
  46. package/dest/logs/log_id.d.ts.map +1 -1
  47. package/dest/logs/log_id.js +1 -2
  48. package/dest/logs/siloed_tag.d.ts +5 -7
  49. package/dest/logs/siloed_tag.d.ts.map +1 -1
  50. package/dest/logs/siloed_tag.js +4 -0
  51. package/dest/logs/tag.d.ts +5 -6
  52. package/dest/logs/tag.d.ts.map +1 -1
  53. package/dest/logs/tag.js +4 -0
  54. package/dest/p2p/block_proposal.d.ts +6 -8
  55. package/dest/p2p/block_proposal.d.ts.map +1 -1
  56. package/dest/p2p/block_proposal.js +4 -9
  57. package/dest/p2p/checkpoint_attestation.d.ts +4 -6
  58. package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
  59. package/dest/p2p/checkpoint_attestation.js +2 -7
  60. package/dest/p2p/checkpoint_proposal.d.ts +8 -10
  61. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  62. package/dest/p2p/checkpoint_proposal.js +4 -11
  63. package/dest/p2p/gossipable.d.ts +4 -4
  64. package/dest/p2p/gossipable.d.ts.map +1 -1
  65. package/dest/tests/mocks.d.ts +1 -1
  66. package/dest/tests/mocks.d.ts.map +1 -1
  67. package/dest/tests/mocks.js +2 -2
  68. package/dest/tx/block_header.d.ts +2 -2
  69. package/dest/tx/block_header.d.ts.map +1 -1
  70. package/dest/tx/block_header.js +1 -1
  71. package/dest/tx/indexed_tx_effect.d.ts +1 -1
  72. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  73. package/dest/tx/indexed_tx_effect.js +1 -2
  74. package/dest/tx/tx.d.ts +3 -3
  75. package/dest/tx/tx.d.ts.map +1 -1
  76. package/package.json +8 -8
  77. package/src/abi/authorization_selector.ts +2 -8
  78. package/src/abi/event_selector.ts +2 -8
  79. package/src/abi/function_selector.ts +3 -12
  80. package/src/abi/note_selector.ts +3 -12
  81. package/src/aztec-address/index.ts +4 -10
  82. package/src/block/block_data.ts +3 -4
  83. package/src/block/block_hash.ts +21 -14
  84. package/src/block/l2_block_info.ts +8 -6
  85. package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
  86. package/src/block/test/l2_tips_store_test_suite.ts +1 -1
  87. package/src/config/chain-config.ts +7 -1
  88. package/src/config/sequencer-config.ts +4 -4
  89. package/src/ha-signing/index.ts +3 -1
  90. package/src/ha-signing/local_config.ts +1 -1
  91. package/src/ha-signing/types.ts +48 -34
  92. package/src/interfaces/merkle_tree_operations.ts +3 -2
  93. package/src/interfaces/prover-client.ts +2 -5
  94. package/src/interfaces/validator.ts +14 -4
  95. package/src/logs/log_id.ts +1 -2
  96. package/src/logs/siloed_tag.ts +8 -9
  97. package/src/logs/tag.ts +8 -8
  98. package/src/p2p/block_proposal.ts +13 -9
  99. package/src/p2p/checkpoint_attestation.ts +5 -9
  100. package/src/p2p/checkpoint_proposal.ts +12 -11
  101. package/src/p2p/gossipable.ts +4 -4
  102. package/src/tests/mocks.ts +2 -0
  103. package/src/tx/block_header.ts +2 -2
  104. package/src/tx/indexed_tx_effect.ts +1 -2
  105. package/src/tx/tx.ts +2 -2
@@ -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,6 +160,7 @@ 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
165
  lastBlockProposal: BlockProposal | undefined,
165
166
  payloadSigner: (payload: Buffer32, context: SigningContext) => Promise<Signature>,
@@ -175,7 +176,7 @@ export class CheckpointProposal extends Gossipable {
175
176
 
176
177
  const checkpointContext: SigningContext = {
177
178
  slot: checkpointHeader.slotNumber,
178
- blockNumber: lastBlockProposal?.blockNumber ?? BlockNumber(0),
179
+ checkpointNumber,
179
180
  dutyType: DutyType.CHECKPOINT_PROPOSAL,
180
181
  };
181
182
 
@@ -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
 
@@ -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,
@@ -618,6 +619,7 @@ export const makeCheckpointProposal = async (options?: MakeCheckpointProposalOpt
618
619
  return CheckpointProposal.createProposalFromSigner(
619
620
  checkpointHeader,
620
621
  archiveRoot,
622
+ CheckpointNumber(1),
621
623
  feeAssetPriceModifier,
622
624
  lastBlockProposal,
623
625
  payload => Promise.resolve(signer.signMessage(payload)),
@@ -172,8 +172,8 @@ export class BlockHeader {
172
172
  }
173
173
 
174
174
  /** Manually set the hash for this block header if already computed */
175
- setHash(hashed: Fr) {
176
- this._cachedHash = Promise.resolve(new BlockHash(hashed));
175
+ setHash(hashed: BlockHash) {
176
+ this._cachedHash = Promise.resolve(hashed);
177
177
  }
178
178
 
179
179
  /** Recomputes the cached hash. Used for testing when header fields are mutated via unfreeze. */
@@ -1,5 +1,4 @@
1
1
  import { BlockNumber } from '@aztec/foundation/branded-types';
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
2
  import { schemas } from '@aztec/foundation/schemas';
4
3
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
4
 
@@ -27,7 +26,7 @@ export function serializeIndexedTxEffect(effect: IndexedTxEffect): Buffer {
27
26
  export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
28
27
  const reader = BufferReader.asReader(buffer);
29
28
 
30
- const l2BlockHash = new BlockHash(reader.readObject(Fr));
29
+ const l2BlockHash = BlockHash.fromBuffer(reader);
31
30
  const l2BlockNumber = BlockNumber(reader.readNumber());
32
31
  const txIndexInBlock = reader.readNumber();
33
32
  const data = reader.readObject(TxEffect);
package/src/tx/tx.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { DA_GAS_PER_FIELD, TX_DA_GAS_OVERHEAD } from '@aztec/constants';
2
- import { Buffer32 } from '@aztec/foundation/buffer';
2
+ import { type BaseBuffer32, Buffer32 } from '@aztec/foundation/buffer';
3
3
  import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { ZodFor } from '@aztec/foundation/schemas';
5
5
  import { BufferReader, serializeArrayOfBufferableToVector, serializeToBuffer } from '@aztec/foundation/serialize';
@@ -64,7 +64,7 @@ export class Tx extends Gossipable {
64
64
  // docs:end:tx_class
65
65
 
66
66
  // Gossipable method
67
- override generateP2PMessageIdentifier(): Promise<Buffer32> {
67
+ override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
68
68
  return Promise.resolve(new Buffer32(this.getTxHash().toBuffer()));
69
69
  }
70
70