@aztec/stdlib 3.0.0-nightly.20251024 → 3.0.0-nightly.20251025

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 (45) hide show
  1. package/dest/avm/index.d.ts +1 -0
  2. package/dest/avm/index.d.ts.map +1 -1
  3. package/dest/avm/index.js +1 -0
  4. package/dest/avm/message_pack.d.ts +1 -0
  5. package/dest/avm/message_pack.d.ts.map +1 -1
  6. package/dest/avm/message_pack.js +28 -5
  7. package/dest/block/l2_block_source.d.ts +29 -0
  8. package/dest/block/l2_block_source.d.ts.map +1 -1
  9. package/dest/interfaces/archiver.d.ts +1 -1
  10. package/dest/interfaces/archiver.d.ts.map +1 -1
  11. package/dest/interfaces/archiver.js +7 -0
  12. package/dest/interfaces/aztec-node.d.ts +24 -0
  13. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  14. package/dest/interfaces/aztec-node.js +4 -0
  15. package/dest/interfaces/merkle_tree_operations.d.ts +5 -0
  16. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  17. package/dest/interfaces/tx_provider.d.ts +1 -1
  18. package/dest/interfaces/tx_provider.d.ts.map +1 -1
  19. package/dest/p2p/block_attestation.d.ts +2 -8
  20. package/dest/p2p/block_attestation.d.ts.map +1 -1
  21. package/dest/p2p/block_attestation.js +7 -12
  22. package/dest/p2p/block_proposal.d.ts +2 -7
  23. package/dest/p2p/block_proposal.d.ts.map +1 -1
  24. package/dest/p2p/block_proposal.js +7 -11
  25. package/dest/tests/mocks.d.ts.map +1 -1
  26. package/dest/tests/mocks.js +4 -4
  27. package/dest/world-state/index.d.ts +2 -0
  28. package/dest/world-state/index.d.ts.map +1 -0
  29. package/dest/world-state/index.js +1 -0
  30. package/dest/world-state/world_state_revision.d.ts +22 -0
  31. package/dest/world-state/world_state_revision.d.ts.map +1 -0
  32. package/dest/world-state/world_state_revision.js +21 -0
  33. package/package.json +10 -9
  34. package/src/avm/index.ts +1 -0
  35. package/src/avm/message_pack.ts +25 -1
  36. package/src/block/l2_block_source.ts +32 -0
  37. package/src/interfaces/archiver.ts +9 -1
  38. package/src/interfaces/aztec-node.ts +36 -0
  39. package/src/interfaces/merkle_tree_operations.ts +6 -0
  40. package/src/interfaces/tx_provider.ts +1 -0
  41. package/src/p2p/block_attestation.ts +8 -20
  42. package/src/p2p/block_proposal.ts +5 -13
  43. package/src/tests/mocks.ts +4 -7
  44. package/src/world-state/index.ts +1 -0
  45. package/src/world-state/world_state_revision.ts +21 -0
@@ -152,7 +152,7 @@ export const makeAndSignCommitteeAttestationsAndSigners = (attestationsAndSigner
152
152
  return signer.sign(hash);
153
153
  };
154
154
  export const makeBlockProposal = (options)=>{
155
- const { blockNumber, payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options);
155
+ const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options);
156
156
  const txHashes = options?.txHashes ?? [
157
157
  0,
158
158
  1,
@@ -161,7 +161,7 @@ export const makeBlockProposal = (options)=>{
161
161
  4,
162
162
  5
163
163
  ].map(()=>TxHash.random());
164
- return new BlockProposal(blockNumber, payload, signature, txHashes, options?.txs ?? []);
164
+ return new BlockProposal(payload, signature, txHashes, options?.txs ?? []);
165
165
  };
166
166
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
167
167
  export const makeBlockAttestation = (options)=>{
@@ -178,7 +178,7 @@ export const makeBlockAttestation = (options)=>{
178
178
  // Sign as proposer
179
179
  const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
180
180
  const proposerSignature = proposerSigner.sign(proposalHash);
181
- return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
181
+ return new BlockAttestation(payload, attestationSignature, proposerSignature);
182
182
  };
183
183
  export const makeBlockAttestationFromBlock = (block, attesterSigner, proposerSigner)=>{
184
184
  const header = block.header;
@@ -197,7 +197,7 @@ export const makeBlockAttestationFromBlock = (block, attesterSigner, proposerSig
197
197
  const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
198
198
  const proposalSignerToUse = proposerSigner ?? Secp256k1Signer.random();
199
199
  const proposerSignature = proposalSignerToUse.sign(proposalHash);
200
- return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
200
+ return new BlockAttestation(payload, attestationSignature, proposerSignature);
201
201
  };
202
202
  export async function randomPublishedL2Block(l2BlockNumber, opts = {}) {
203
203
  const block = await L2Block.random(l2BlockNumber);
@@ -0,0 +1,2 @@
1
+ export * from './world_state_revision.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/world-state/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './world_state_revision.js';
@@ -0,0 +1,22 @@
1
+ import { z } from 'zod';
2
+ export declare class WorldStateRevision {
3
+ readonly forkId: number;
4
+ readonly blockNumber: number;
5
+ readonly includeUncommitted: boolean;
6
+ constructor(forkId: number, blockNumber: number, includeUncommitted: boolean);
7
+ static empty(): WorldStateRevision;
8
+ static get schema(): z.ZodObject<{
9
+ forkId: z.ZodNumber;
10
+ blockNumber: z.ZodNumber;
11
+ includeUncommitted: z.ZodBoolean;
12
+ }, "strip", z.ZodTypeAny, {
13
+ blockNumber: number;
14
+ forkId: number;
15
+ includeUncommitted: boolean;
16
+ }, {
17
+ blockNumber: number;
18
+ forkId: number;
19
+ includeUncommitted: boolean;
20
+ }>;
21
+ }
22
+ //# sourceMappingURL=world_state_revision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"world_state_revision.d.ts","sourceRoot":"","sources":["../../src/world-state/world_state_revision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,qBAAa,kBAAkB;aAEX,MAAM,EAAE,MAAM;aACd,WAAW,EAAE,MAAM;aACnB,kBAAkB,EAAE,OAAO;gBAF3B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,kBAAkB,EAAE,OAAO;IAG7C,MAAM,CAAC,KAAK;IAIZ,MAAM,KAAK,MAAM;;;;;;;;;;;;OAMhB;CACF"}
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export class WorldStateRevision {
3
+ forkId;
4
+ blockNumber;
5
+ includeUncommitted;
6
+ constructor(forkId, blockNumber, includeUncommitted){
7
+ this.forkId = forkId;
8
+ this.blockNumber = blockNumber;
9
+ this.includeUncommitted = includeUncommitted;
10
+ }
11
+ static empty() {
12
+ return new WorldStateRevision(0, 0, false);
13
+ }
14
+ static get schema() {
15
+ return z.object({
16
+ forkId: z.number(),
17
+ blockNumber: z.number(),
18
+ includeUncommitted: z.boolean()
19
+ });
20
+ }
21
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/stdlib",
3
- "version": "3.0.0-nightly.20251024",
3
+ "version": "3.0.0-nightly.20251025",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json",
@@ -52,7 +52,8 @@
52
52
  "./update-checker": "./dest/update-checker/index.js",
53
53
  "./zkpassport": "./dest/zkpassport/index.js",
54
54
  "./slashing": "./dest/slashing/index.js",
55
- "./l1-contracts": "./dest/l1-contracts/index.js"
55
+ "./l1-contracts": "./dest/l1-contracts/index.js",
56
+ "./world-state": "./dest/world-state/index.js"
56
57
  },
57
58
  "typedocOptions": {
58
59
  "entryPoints": [
@@ -70,13 +71,13 @@
70
71
  },
71
72
  "dependencies": {
72
73
  "@aws-sdk/client-s3": "^3.892.0",
73
- "@aztec/bb.js": "3.0.0-nightly.20251024",
74
- "@aztec/blob-lib": "3.0.0-nightly.20251024",
75
- "@aztec/constants": "3.0.0-nightly.20251024",
76
- "@aztec/ethereum": "3.0.0-nightly.20251024",
77
- "@aztec/foundation": "3.0.0-nightly.20251024",
78
- "@aztec/l1-artifacts": "3.0.0-nightly.20251024",
79
- "@aztec/noir-noirc_abi": "3.0.0-nightly.20251024",
74
+ "@aztec/bb.js": "3.0.0-nightly.20251025",
75
+ "@aztec/blob-lib": "3.0.0-nightly.20251025",
76
+ "@aztec/constants": "3.0.0-nightly.20251025",
77
+ "@aztec/ethereum": "3.0.0-nightly.20251025",
78
+ "@aztec/foundation": "3.0.0-nightly.20251025",
79
+ "@aztec/l1-artifacts": "3.0.0-nightly.20251025",
80
+ "@aztec/noir-noirc_abi": "3.0.0-nightly.20251025",
80
81
  "@google-cloud/storage": "^7.15.0",
81
82
  "axios": "^1.12.0",
82
83
  "json-stringify-deterministic": "1.0.12",
package/src/avm/index.ts CHANGED
@@ -9,3 +9,4 @@ export * from './contract_storage_read.js';
9
9
  export * from './public_inner_call_request.js';
10
10
  export * from './public_call_stack_item_compressed.js';
11
11
  export * from './avm_proving_request.js';
12
+ export * from './message_pack.js';
@@ -2,7 +2,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
2
2
  import { Fq, Fr, Point } from '@aztec/foundation/fields';
3
3
 
4
4
  import { strict as assert } from 'assert';
5
- import { Encoder, addExtension } from 'msgpackr';
5
+ import { Decoder, Encoder, addExtension } from 'msgpackr';
6
6
 
7
7
  import { AztecAddress } from '../aztec-address/index.js';
8
8
 
@@ -18,6 +18,16 @@ export function serializeWithMessagePack(obj: any): Buffer {
18
18
  return encoder.encode(obj);
19
19
  }
20
20
 
21
+ export function deserializeFromMessagePack<T>(buffer: Buffer): T {
22
+ setUpMessagePackExtensions();
23
+ const decoder = new Decoder({
24
+ useRecords: false,
25
+ int64AsType: 'bigint',
26
+ largeBigIntToString: true,
27
+ });
28
+ return decoder.decode(buffer);
29
+ }
30
+
21
31
  let messagePackWasSetUp = false;
22
32
  function setUpMessagePackExtensions() {
23
33
  if (messagePackWasSetUp) {
@@ -27,15 +37,24 @@ function setUpMessagePackExtensions() {
27
37
  addExtension({
28
38
  Class: Fr,
29
39
  write: (fr: Fr) => fr.toBuffer(),
40
+ read: (data: Buffer) => Fr.fromBuffer(data),
30
41
  });
31
42
  addExtension({
32
43
  Class: Fq,
33
44
  write: (fq: Fq) => fq.toBuffer(),
45
+ read: (data: Buffer) => Fq.fromBuffer(data),
34
46
  });
35
47
  // AztecAddress is a class that has a field in TS, but is itself a field in C++.
36
48
  addExtension({
37
49
  Class: AztecAddress,
38
50
  write: (addr: AztecAddress) => addr.toField(),
51
+ read: (data: Fr | Buffer) => {
52
+ // If C++ sent it as Fr, wrap it. If as buffer, construct from buffer.
53
+ if (data instanceof Fr) {
54
+ return new AztecAddress(data);
55
+ }
56
+ return new AztecAddress(Fr.fromBuffer(data));
57
+ },
39
58
  });
40
59
  // Affine points are a mess, we do our best.
41
60
  addExtension({
@@ -45,11 +64,16 @@ function setUpMessagePackExtensions() {
45
64
  // TODO: should these be Frs?
46
65
  return { x: new Fq(p.x.toBigInt()), y: new Fq(p.y.toBigInt()) };
47
66
  },
67
+ read: (data: { x: Fq; y: Fq }) => {
68
+ // Convert Fq back to Fr for Point constructor
69
+ return new Point(new Fr(data.x.toBigInt()), new Fr(data.y.toBigInt()), false);
70
+ },
48
71
  });
49
72
  // EthAddress is a class that has a buffer in TS, but is itself just a field in C++.
50
73
  addExtension({
51
74
  Class: EthAddress,
52
75
  write: (addr: EthAddress) => addr.toField().toBuffer(),
76
+ read: (data: Buffer) => EthAddress.fromField(Fr.fromBuffer(data)),
53
77
  });
54
78
  messagePackWasSetUp = true;
55
79
  }
@@ -1,4 +1,5 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
+ import type { Fr } from '@aztec/foundation/fields';
2
3
  import type { TypedEventEmitter } from '@aztec/foundation/types';
3
4
 
4
5
  import { z } from 'zod';
@@ -66,6 +67,34 @@ export interface L2BlockSource {
66
67
  /** Equivalent to getBlocks but includes publish data. */
67
68
  getPublishedBlocks(from: number, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
68
69
 
70
+ /**
71
+ * Gets a published block by its hash.
72
+ * @param blockHash - The block hash to retrieve.
73
+ * @returns The requested published block (or undefined if not found).
74
+ */
75
+ getPublishedBlockByHash(blockHash: Fr): Promise<PublishedL2Block | undefined>;
76
+
77
+ /**
78
+ * Gets a published block by its archive root.
79
+ * @param archive - The archive root to retrieve.
80
+ * @returns The requested published block (or undefined if not found).
81
+ */
82
+ getPublishedBlockByArchive(archive: Fr): Promise<PublishedL2Block | undefined>;
83
+
84
+ /**
85
+ * Gets a block header by its hash.
86
+ * @param blockHash - The block hash to retrieve.
87
+ * @returns The requested block header (or undefined if not found).
88
+ */
89
+ getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined>;
90
+
91
+ /**
92
+ * Gets a block header by its archive root.
93
+ * @param archive - The archive root to retrieve.
94
+ * @returns The requested block header (or undefined if not found).
95
+ */
96
+ getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined>;
97
+
69
98
  /**
70
99
  * Gets a tx effect.
71
100
  * @param txHash - The hash of the tx corresponding to the tx effect.
@@ -120,6 +149,9 @@ export interface L2BlockSource {
120
149
  */
121
150
  getL1Constants(): Promise<L1RollupConstants>;
122
151
 
152
+ /** Returns values for the genesis block */
153
+ getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }>;
154
+
123
155
  /** Latest synced L1 timestamp. */
124
156
  getL1Timestamp(): Promise<bigint>;
125
157
 
@@ -44,7 +44,7 @@ export type ArchiverSpecificConfig = {
44
44
  /** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
45
45
  maxLogs?: number;
46
46
 
47
- /** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB. */
47
+ /** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKb. */
48
48
  archiverStoreMapSizeKb?: number;
49
49
 
50
50
  /** Whether to skip validating block attestations (use only for testing). */
@@ -83,6 +83,10 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
83
83
  .function()
84
84
  .args(schemas.Integer, schemas.Integer, optional(z.boolean()))
85
85
  .returns(z.array(PublishedL2Block.schema)),
86
+ getPublishedBlockByHash: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
87
+ getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
88
+ getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
89
+ getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
86
90
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
87
91
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
88
92
  getL2SlotNumber: z.function().args().returns(schemas.BigInt),
@@ -110,6 +114,10 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
110
114
  getL1ToL2MessageIndex: z.function().args(schemas.Fr).returns(schemas.BigInt.optional()),
111
115
  getDebugFunctionName: z.function().args(schemas.AztecAddress, schemas.FunctionSelector).returns(optional(z.string())),
112
116
  getL1Constants: z.function().args().returns(L1RollupConstantsSchema),
117
+ getGenesisValues: z
118
+ .function()
119
+ .args()
120
+ .returns(z.object({ genesisArchiveRoot: schemas.Fr })),
113
121
  getL1Timestamp: z.function().args().returns(schemas.BigInt),
114
122
  syncImmediate: z.function().args().returns(z.void()),
115
123
  isPendingChainInvalid: z.function().args().returns(z.boolean()),
@@ -225,6 +225,20 @@ export interface AztecNode
225
225
  */
226
226
  getBlock(number: L2BlockNumber): Promise<L2Block | undefined>;
227
227
 
228
+ /**
229
+ * Get a block specified by its hash.
230
+ * @param blockHash - The block hash being requested.
231
+ * @returns The requested block.
232
+ */
233
+ getBlockByHash(blockHash: Fr): Promise<L2Block | undefined>;
234
+
235
+ /**
236
+ * Get a block specified by its archive root.
237
+ * @param archive - The archive root being requested.
238
+ * @returns The requested block.
239
+ */
240
+ getBlockByArchive(archive: Fr): Promise<L2Block | undefined>;
241
+
228
242
  /**
229
243
  * Method to fetch the latest block number synchronized by the node.
230
244
  * @returns The block number.
@@ -400,6 +414,20 @@ export interface AztecNode
400
414
  */
401
415
  getBlockHeader(blockNumber?: L2BlockNumber): Promise<BlockHeader | undefined>;
402
416
 
417
+ /**
418
+ * Get a block header specified by its hash.
419
+ * @param blockHash - The block hash being requested.
420
+ * @returns The requested block header.
421
+ */
422
+ getBlockHeaderByHash(blockHash: Fr): Promise<BlockHeader | undefined>;
423
+
424
+ /**
425
+ * Get a block header specified by its archive root.
426
+ * @param archive - The archive root being requested.
427
+ * @returns The requested block header.
428
+ */
429
+ getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined>;
430
+
403
431
  /** Returns stats for validators if enabled. */
404
432
  getValidatorsStats(): Promise<ValidatorsStats>;
405
433
 
@@ -523,6 +551,10 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
523
551
 
524
552
  getBlock: z.function().args(L2BlockNumberSchema).returns(L2Block.schema.optional()),
525
553
 
554
+ getBlockByHash: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
555
+
556
+ getBlockByArchive: z.function().args(schemas.Fr).returns(L2Block.schema.optional()),
557
+
526
558
  getBlockNumber: z.function().returns(z.number()),
527
559
 
528
560
  getProvenBlockNumber: z.function().returns(z.number()),
@@ -596,6 +628,10 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
596
628
 
597
629
  getBlockHeader: z.function().args(optional(L2BlockNumberSchema)).returns(BlockHeader.schema.optional()),
598
630
 
631
+ getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
632
+
633
+ getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
634
+
599
635
  getValidatorsStats: z.function().returns(ValidatorsStatsSchema),
600
636
 
601
637
  getValidatorStats: z
@@ -7,6 +7,7 @@ import type { NullifierLeaf } from '../trees/nullifier_leaf.js';
7
7
  import type { PublicDataTreeLeaf } from '../trees/public_data_leaf.js';
8
8
  import type { BlockHeader } from '../tx/block_header.js';
9
9
  import type { StateReference } from '../tx/state_reference.js';
10
+ import type { WorldStateRevision } from '../world-state/world_state_revision.js';
10
11
 
11
12
  /**
12
13
  * Type alias for the nullifier tree ID.
@@ -132,6 +133,11 @@ export interface MerkleTreeReadOperations {
132
133
  */
133
134
  getInitialHeader(): BlockHeader;
134
135
 
136
+ /**
137
+ * Gets the current revision.
138
+ */
139
+ getRevision(): WorldStateRevision;
140
+
135
141
  /**
136
142
  * Gets sibling path for a leaf.
137
143
  * @param treeId - The tree to be queried for a sibling path.
@@ -9,6 +9,7 @@ export interface ITxProvider {
9
9
 
10
10
  getTxsForBlockProposal(
11
11
  blockProposal: BlockProposal,
12
+ blockNumber: number,
12
13
  opts: { pinnedPeer: PeerId | undefined; deadline: Date },
13
14
  ): Promise<{ txs: Tx[]; missingTxs: TxHash[] }>;
14
15
 
@@ -7,8 +7,7 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
7
7
 
8
8
  import { z } from 'zod';
9
9
 
10
- import { type ZodFor, schemas } from '../schemas/index.js';
11
- import type { UInt32 } from '../types/index.js';
10
+ import type { ZodFor } from '../schemas/index.js';
12
11
  import { ConsensusPayload } from './consensus_payload.js';
13
12
  import { Gossipable } from './gossipable.js';
14
13
  import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js';
@@ -33,9 +32,6 @@ export class BlockAttestation extends Gossipable {
33
32
  private proposer: EthAddress | undefined;
34
33
 
35
34
  constructor(
36
- /** The block number of the attestation. */
37
- public readonly blockNumber: UInt32,
38
-
39
35
  /** The payload of the message, and what the signature is over */
40
36
  public readonly payload: ConsensusPayload,
41
37
 
@@ -51,12 +47,11 @@ export class BlockAttestation extends Gossipable {
51
47
  static get schema(): ZodFor<BlockAttestation> {
52
48
  return z
53
49
  .object({
54
- blockNumber: schemas.UInt32,
55
50
  payload: ConsensusPayload.schema,
56
51
  signature: Signature.schema,
57
52
  proposerSignature: Signature.schema,
58
53
  })
59
- .transform(obj => new BlockAttestation(obj.blockNumber, obj.payload, obj.signature, obj.proposerSignature));
54
+ .transform(obj => new BlockAttestation(obj.payload, obj.signature, obj.proposerSignature));
60
55
  }
61
56
 
62
57
  override generateP2PMessageIdentifier(): Promise<Buffer32> {
@@ -90,12 +85,12 @@ export class BlockAttestation extends Gossipable {
90
85
  * Lazily evaluate and cache the proposer of the block
91
86
  * @returns The proposer of the block
92
87
  */
93
- getProposer(): EthAddress {
88
+ getProposer(): EthAddress | undefined {
94
89
  if (!this.proposer) {
95
90
  // Recover the proposer from the proposal signature
96
91
  const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
97
92
  // Cache the proposer for later use
98
- this.proposer = tryRecoverAddress(hashed, this.proposerSignature)!;
93
+ this.proposer = tryRecoverAddress(hashed, this.proposerSignature);
99
94
  }
100
95
 
101
96
  return this.proposer;
@@ -106,13 +101,12 @@ export class BlockAttestation extends Gossipable {
106
101
  }
107
102
 
108
103
  toBuffer(): Buffer {
109
- return serializeToBuffer([this.blockNumber, this.payload, this.signature, this.proposerSignature]);
104
+ return serializeToBuffer([this.payload, this.signature, this.proposerSignature]);
110
105
  }
111
106
 
112
107
  static fromBuffer(buf: Buffer | BufferReader): BlockAttestation {
113
108
  const reader = BufferReader.asReader(buf);
114
109
  return new BlockAttestation(
115
- reader.readNumber(),
116
110
  reader.readObject(ConsensusPayload),
117
111
  reader.readObject(Signature),
118
112
  reader.readObject(Signature),
@@ -120,25 +114,19 @@ export class BlockAttestation extends Gossipable {
120
114
  }
121
115
 
122
116
  static empty(): BlockAttestation {
123
- return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty(), Signature.empty());
117
+ return new BlockAttestation(ConsensusPayload.empty(), Signature.empty(), Signature.empty());
124
118
  }
125
119
 
126
120
  static random(): BlockAttestation {
127
- return new BlockAttestation(
128
- Math.floor(Math.random() * 1000) + 1,
129
- ConsensusPayload.random(),
130
- Signature.random(),
131
- Signature.random(),
132
- );
121
+ return new BlockAttestation(ConsensusPayload.random(), Signature.random(), Signature.random());
133
122
  }
134
123
 
135
124
  getSize(): number {
136
- return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize() + this.proposerSignature.getSize();
125
+ return this.payload.getSize() + this.signature.getSize() + this.proposerSignature.getSize();
137
126
  }
138
127
 
139
128
  toInspect() {
140
129
  return {
141
- blockNumber: this.blockNumber,
142
130
  payload: this.payload.toInspect(),
143
131
  signature: this.signature.toString(),
144
132
  proposerSignature: this.proposerSignature.toString(),
@@ -8,7 +8,6 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
8
8
  import type { L2BlockInfo } from '../block/l2_block_info.js';
9
9
  import { TxHash } from '../tx/index.js';
10
10
  import { Tx } from '../tx/tx.js';
11
- import type { UInt32 } from '../types/index.js';
12
11
  import { ConsensusPayload } from './consensus_payload.js';
13
12
  import { Gossipable } from './gossipable.js';
14
13
  import {
@@ -42,9 +41,6 @@ export class BlockProposal extends Gossipable {
42
41
  private sender: EthAddress | undefined;
43
42
 
44
43
  constructor(
45
- /** The number of the block */
46
- public readonly blockNumber: UInt32,
47
-
48
44
  /** The payload of the message, and what the signature is over */
49
45
  public readonly payload: ConsensusPayload,
50
46
 
@@ -73,9 +69,8 @@ export class BlockProposal extends Gossipable {
73
69
  return this.payload.header.slotNumber;
74
70
  }
75
71
 
76
- toBlockInfo(): L2BlockInfo {
72
+ toBlockInfo(): Omit<L2BlockInfo, 'blockNumber'> {
77
73
  return {
78
- blockNumber: this.blockNumber,
79
74
  slotNumber: this.slotNumber.toNumber(),
80
75
  lastArchive: this.payload.header.lastArchiveRoot,
81
76
  timestamp: this.payload.header.timestamp,
@@ -85,7 +80,6 @@ export class BlockProposal extends Gossipable {
85
80
  }
86
81
 
87
82
  static async createProposalFromSigner(
88
- blockNumber: UInt32,
89
83
  payload: ConsensusPayload,
90
84
  txHashes: TxHash[],
91
85
  // Note(md): Provided separately to tx hashes such that this function can be optional
@@ -95,7 +89,7 @@ export class BlockProposal extends Gossipable {
95
89
  const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
96
90
  const sig = await payloadSigner(hashed);
97
91
 
98
- return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
92
+ return new BlockProposal(payload, sig, txHashes, txs);
99
93
  }
100
94
 
101
95
  /**Get Sender
@@ -117,7 +111,7 @@ export class BlockProposal extends Gossipable {
117
111
  }
118
112
 
119
113
  toBuffer(): Buffer {
120
- const buffer: any[] = [this.blockNumber, this.payload, this.signature, this.txHashes.length, this.txHashes];
114
+ const buffer: any[] = [this.payload, this.signature, this.txHashes.length, this.txHashes];
121
115
  if (this.txs) {
122
116
  buffer.push(this.txs.length);
123
117
  buffer.push(this.txs);
@@ -128,22 +122,20 @@ export class BlockProposal extends Gossipable {
128
122
  static fromBuffer(buf: Buffer | BufferReader): BlockProposal {
129
123
  const reader = BufferReader.asReader(buf);
130
124
 
131
- const blockNumber = reader.readNumber();
132
125
  const payload = reader.readObject(ConsensusPayload);
133
126
  const sig = reader.readObject(Signature);
134
127
  const txHashes = reader.readArray(reader.readNumber(), TxHash);
135
128
 
136
129
  if (!reader.isEmpty()) {
137
130
  const txs = reader.readArray(reader.readNumber(), Tx);
138
- return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
131
+ return new BlockProposal(payload, sig, txHashes, txs);
139
132
  }
140
133
 
141
- return new BlockProposal(blockNumber, payload, sig, txHashes);
134
+ return new BlockProposal(payload, sig, txHashes);
142
135
  }
143
136
 
144
137
  getSize(): number {
145
138
  return (
146
- 4 /* blockNumber */ +
147
139
  this.payload.getSize() +
148
140
  this.signature.getSize() +
149
141
  4 /* txHashes.length */ +
@@ -270,12 +270,9 @@ export const makeAndSignCommitteeAttestationsAndSigners = (
270
270
  };
271
271
 
272
272
  export const makeBlockProposal = (options?: MakeConsensusPayloadOptions): BlockProposal => {
273
- const { blockNumber, payload, signature } = makeAndSignConsensusPayload(
274
- SignatureDomainSeparator.blockProposal,
275
- options,
276
- );
273
+ const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options);
277
274
  const txHashes = options?.txHashes ?? [0, 1, 2, 3, 4, 5].map(() => TxHash.random());
278
- return new BlockProposal(blockNumber, payload, signature, txHashes, options?.txs ?? []);
275
+ return new BlockProposal(payload, signature, txHashes, options?.txs ?? []);
279
276
  };
280
277
 
281
278
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
@@ -303,7 +300,7 @@ export const makeBlockAttestation = (options?: MakeConsensusPayloadOptions): Blo
303
300
  const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
304
301
  const proposerSignature = proposerSigner.sign(proposalHash);
305
302
 
306
- return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
303
+ return new BlockAttestation(payload, attestationSignature, proposerSignature);
307
304
  };
308
305
 
309
306
  export const makeBlockAttestationFromBlock = (
@@ -331,7 +328,7 @@ export const makeBlockAttestationFromBlock = (
331
328
  const proposalSignerToUse = proposerSigner ?? Secp256k1Signer.random();
332
329
  const proposerSignature = proposalSignerToUse.sign(proposalHash);
333
330
 
334
- return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
331
+ return new BlockAttestation(payload, attestationSignature, proposerSignature);
335
332
  };
336
333
 
337
334
  export async function randomPublishedL2Block(
@@ -0,0 +1 @@
1
+ export * from './world_state_revision.js';
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+
3
+ export class WorldStateRevision {
4
+ constructor(
5
+ public readonly forkId: number,
6
+ public readonly blockNumber: number,
7
+ public readonly includeUncommitted: boolean,
8
+ ) {}
9
+
10
+ static empty() {
11
+ return new WorldStateRevision(0, 0, false);
12
+ }
13
+
14
+ static get schema() {
15
+ return z.object({
16
+ forkId: z.number(),
17
+ blockNumber: z.number(),
18
+ includeUncommitted: z.boolean(),
19
+ });
20
+ }
21
+ }