@aztec/stdlib 4.0.0-nightly.20260118 → 4.0.0-nightly.20260120

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 (85) hide show
  1. package/dest/avm/avm.d.ts +300 -300
  2. package/dest/block/block_parameter.d.ts +4 -3
  3. package/dest/block/block_parameter.d.ts.map +1 -1
  4. package/dest/block/block_parameter.js +2 -0
  5. package/dest/block/checkpointed_l2_block.d.ts +10 -127
  6. package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
  7. package/dest/block/checkpointed_l2_block.js +2 -41
  8. package/dest/block/in_block.d.ts +3 -3
  9. package/dest/block/in_block.d.ts.map +1 -1
  10. package/dest/block/index.d.ts +1 -3
  11. package/dest/block/index.d.ts.map +1 -1
  12. package/dest/block/index.js +0 -2
  13. package/dest/block/l2_block_new.d.ts +11 -9
  14. package/dest/block/l2_block_new.d.ts.map +1 -1
  15. package/dest/block/l2_block_new.js +5 -5
  16. package/dest/block/l2_block_source.d.ts +20 -11
  17. package/dest/block/l2_block_source.d.ts.map +1 -1
  18. package/dest/checkpoint/checkpoint.d.ts +10 -8
  19. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  20. package/dest/checkpoint/checkpoint.js +2 -2
  21. package/dest/checkpoint/published_checkpoint.d.ts +11 -9
  22. package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
  23. package/dest/interfaces/archiver.d.ts +1 -1
  24. package/dest/interfaces/archiver.d.ts.map +1 -1
  25. package/dest/interfaces/archiver.js +9 -8
  26. package/dest/interfaces/aztec-node.d.ts +35 -40
  27. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  28. package/dest/interfaces/aztec-node.js +6 -8
  29. package/dest/interfaces/block-builder.d.ts +18 -17
  30. package/dest/interfaces/block-builder.d.ts.map +1 -1
  31. package/dest/interfaces/proving-job.d.ts +166 -166
  32. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +1 -1
  33. package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
  34. package/dest/kernel/hints/build_note_hash_read_request_hints.js +16 -6
  35. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +1 -1
  36. package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
  37. package/dest/kernel/hints/build_nullifier_read_request_hints.js +14 -4
  38. package/dest/p2p/block_proposal.d.ts +9 -9
  39. package/dest/p2p/block_proposal.d.ts.map +1 -1
  40. package/dest/p2p/block_proposal.js +6 -5
  41. package/dest/p2p/checkpoint_proposal.d.ts +4 -4
  42. package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
  43. package/dest/p2p/checkpoint_proposal.js +3 -3
  44. package/dest/p2p/consensus_payload.d.ts +1 -3
  45. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  46. package/dest/p2p/consensus_payload.js +0 -3
  47. package/dest/tests/factories.d.ts +2 -4
  48. package/dest/tests/factories.d.ts.map +1 -1
  49. package/dest/tests/factories.js +3 -13
  50. package/dest/tests/jest.d.ts +4 -4
  51. package/dest/tests/jest.js +9 -9
  52. package/dest/tests/mocks.d.ts +12 -12
  53. package/dest/tests/mocks.d.ts.map +1 -1
  54. package/dest/tests/mocks.js +33 -21
  55. package/package.json +9 -9
  56. package/src/block/block_parameter.ts +4 -2
  57. package/src/block/checkpointed_l2_block.ts +2 -53
  58. package/src/block/in_block.ts +2 -2
  59. package/src/block/index.ts +0 -2
  60. package/src/block/l2_block_new.ts +14 -7
  61. package/src/block/l2_block_source.ts +21 -11
  62. package/src/checkpoint/checkpoint.ts +8 -2
  63. package/src/interfaces/archiver.ts +9 -8
  64. package/src/interfaces/aztec-node.ts +39 -57
  65. package/src/interfaces/block-builder.ts +33 -28
  66. package/src/kernel/hints/build_note_hash_read_request_hints.ts +17 -6
  67. package/src/kernel/hints/build_nullifier_read_request_hints.ts +22 -10
  68. package/src/p2p/block_proposal.ts +10 -10
  69. package/src/p2p/checkpoint_proposal.ts +4 -4
  70. package/src/p2p/consensus_payload.ts +0 -5
  71. package/src/tests/factories.ts +2 -25
  72. package/src/tests/jest.ts +9 -9
  73. package/src/tests/mocks.ts +35 -28
  74. package/dest/block/l2_block.d.ts +0 -150
  75. package/dest/block/l2_block.d.ts.map +0 -1
  76. package/dest/block/l2_block.js +0 -201
  77. package/dest/block/l2_block_code_to_purge.d.ts +0 -11
  78. package/dest/block/l2_block_code_to_purge.d.ts.map +0 -1
  79. package/dest/block/l2_block_code_to_purge.js +0 -55
  80. package/dest/block/l2_block_header.d.ts +0 -106
  81. package/dest/block/l2_block_header.d.ts.map +0 -1
  82. package/dest/block/l2_block_header.js +0 -167
  83. package/src/block/l2_block.ts +0 -274
  84. package/src/block/l2_block_code_to_purge.ts +0 -81
  85. package/src/block/l2_block_header.ts +0 -268
@@ -1,55 +0,0 @@
1
- import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
- import { compact } from '@aztec/foundation/collection';
3
- import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { EthAddress } from '@aztec/foundation/eth-address';
5
- import { AztecAddress } from '../aztec-address/index.js';
6
- import { GasFees } from '../gas/gas_fees.js';
7
- import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
8
- import { GlobalVariables } from '../tx/global_variables.js';
9
- import { PartialStateReference } from '../tx/partial_state_reference.js';
10
- import { StateReference } from '../tx/state_reference.js';
11
- import { L2BlockHeader } from './l2_block_header.js';
12
- export function makeL2BlockHeader(seed = 0, blockNumber, slotNumber, overrides = {}) {
13
- return new L2BlockHeader(makeAppendOnlyTreeSnapshot(seed + 0x100), overrides.blobsHash ?? new Fr(seed + 0x200), overrides.inHash ?? new Fr(seed + 0x300), overrides.epochOutHash ?? new Fr(seed + 0x400), overrides.state ?? makeStateReference(seed + 0x600), makeGlobalVariables(seed += 0x700, {
14
- ...blockNumber ? {
15
- blockNumber: BlockNumber(blockNumber)
16
- } : {},
17
- ...slotNumber ? {
18
- slotNumber: SlotNumber(slotNumber)
19
- } : {}
20
- }), new Fr(seed + 0x300), new Fr(seed + 0x800), new Fr(seed + 0x900), new Fr(seed + 0xa00));
21
- }
22
- /**
23
- * Makes arbitrary append only tree snapshot.
24
- * @param seed - The seed to use for generating the append only tree snapshot.
25
- * @returns An append only tree snapshot.
26
- */ export function makeAppendOnlyTreeSnapshot(seed = 1) {
27
- return new AppendOnlyTreeSnapshot(new Fr(seed), seed);
28
- }
29
- /**
30
- * Makes arbitrary state reference.
31
- * @param seed - The seed to use for generating the state reference.
32
- * @returns A state reference.
33
- */ function makeStateReference(seed = 0) {
34
- return new StateReference(makeAppendOnlyTreeSnapshot(seed), makePartialStateReference(seed + 1));
35
- }
36
- /**
37
- * Makes arbitrary partial state reference.
38
- * @param seed - The seed to use for generating the partial state reference.
39
- * @returns A partial state reference.
40
- */ function makePartialStateReference(seed = 0) {
41
- return new PartialStateReference(makeAppendOnlyTreeSnapshot(seed), makeAppendOnlyTreeSnapshot(seed + 1), makeAppendOnlyTreeSnapshot(seed + 2));
42
- }
43
- function makeGlobalVariables(seed = 1, overrides = {}) {
44
- return GlobalVariables.from({
45
- chainId: new Fr(seed),
46
- version: new Fr(seed + 1),
47
- blockNumber: BlockNumber(seed + 2),
48
- slotNumber: SlotNumber(seed + 3),
49
- timestamp: BigInt(seed + 4),
50
- coinbase: EthAddress.fromField(new Fr(seed + 5)),
51
- feeRecipient: AztecAddress.fromField(new Fr(seed + 6)),
52
- gasFees: new GasFees(seed + 7, seed + 8),
53
- ...compact(overrides)
54
- });
55
- }
@@ -1,106 +0,0 @@
1
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { type ZodFor } from '@aztec/foundation/schemas';
4
- import { BufferReader, FieldReader } from '@aztec/foundation/serialize';
5
- import type { FieldsOf } from '@aztec/foundation/types';
6
- import { inspect } from 'util';
7
- import { CheckpointHeader } from '../rollup/checkpoint_header.js';
8
- import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
9
- import { BlockHeader, GlobalVariables, StateReference } from '../tx/index.js';
10
- /**
11
- * TO BE DELETED
12
- *
13
- * A header of an L2 block combining the block header and the checkpoint header.
14
- * This is a temporary workaround to avoid changing too many things before building in chunks is properly implemented.
15
- * This works for now because we only have one block per checkpoint.
16
- *
17
- * @deprecated Use BlockHeader or CheckpointHeader instead.
18
- */
19
- export declare class L2BlockHeader {
20
- /** Snapshot of archive before the block is applied. */
21
- lastArchive: AppendOnlyTreeSnapshot;
22
- blobsHash: Fr;
23
- inHash: Fr;
24
- /** Root of the epoch out hash tree. Leaves are the out hashes of this block and all previous blocks in the epoch. */
25
- epochOutHash: Fr;
26
- /** State reference. */
27
- state: StateReference;
28
- /** Global variables of an L2 block. */
29
- globalVariables: GlobalVariables;
30
- /** Total fees in the block, computed by the root rollup circuit */
31
- totalFees: Fr;
32
- /** Total mana used in the block, computed by the root rollup circuit */
33
- totalManaUsed: Fr;
34
- /** Hash of the sponge blob of the block. */
35
- spongeBlobHash: Fr;
36
- /** Hash of the block headers in the checkpoint. */
37
- blockHeadersHash: Fr;
38
- constructor(
39
- /** Snapshot of archive before the block is applied. */
40
- lastArchive: AppendOnlyTreeSnapshot, blobsHash: Fr, inHash: Fr,
41
- /** Root of the epoch out hash tree. Leaves are the out hashes of this block and all previous blocks in the epoch. */
42
- epochOutHash: Fr,
43
- /** State reference. */
44
- state: StateReference,
45
- /** Global variables of an L2 block. */
46
- globalVariables: GlobalVariables,
47
- /** Total fees in the block, computed by the root rollup circuit */
48
- totalFees: Fr,
49
- /** Total mana used in the block, computed by the root rollup circuit */
50
- totalManaUsed: Fr,
51
- /** Hash of the sponge blob of the block. */
52
- spongeBlobHash: Fr,
53
- /** Hash of the block headers in the checkpoint. */
54
- blockHeadersHash: Fr);
55
- static get schema(): ZodFor<L2BlockHeader>;
56
- static getFields(fields: FieldsOf<L2BlockHeader>): readonly [AppendOnlyTreeSnapshot, Fr, Fr, Fr, StateReference, GlobalVariables, Fr, Fr, Fr, Fr];
57
- static from(fields: FieldsOf<L2BlockHeader>): L2BlockHeader;
58
- getSlot(): SlotNumber;
59
- getBlockNumber(): import("@aztec/foundation/branded-types").BlockNumber;
60
- getSize(): number;
61
- toBuffer(): Buffer<ArrayBufferLike>;
62
- toFields(): Fr[];
63
- clone(): L2BlockHeader;
64
- static fromBuffer(buffer: Buffer | BufferReader): L2BlockHeader;
65
- static fromFields(fields: Fr[] | FieldReader): L2BlockHeader;
66
- static empty(fields?: Partial<FieldsOf<L2BlockHeader>>): L2BlockHeader;
67
- isEmpty(): boolean;
68
- /**
69
- * Serializes this instance into a string.
70
- * @returns Encoded string.
71
- */
72
- toString(): `0x${string}`;
73
- static fromString(str: string): L2BlockHeader;
74
- toCheckpointHeader(): CheckpointHeader;
75
- toBlockHeader(): BlockHeader;
76
- toInspect(): {
77
- lastArchive: `0x${string}`;
78
- blobsHash: `0x${string}`;
79
- inHash: `0x${string}`;
80
- epochOutHash: `0x${string}`;
81
- state: {
82
- l1ToL2MessageTree: `0x${string}`;
83
- noteHashTree: `0x${string}`;
84
- nullifierTree: `0x${string}`;
85
- publicDataTree: `0x${string}`;
86
- };
87
- globalVariables: {
88
- chainId: number;
89
- version: number;
90
- blockNumber: import("@aztec/foundation/branded-types").BlockNumber;
91
- slotNumber: SlotNumber;
92
- timestamp: bigint;
93
- coinbase: `0x${string}`;
94
- feeRecipient: `0x${string}`;
95
- feePerDaGas: number;
96
- feePerL2Gas: number;
97
- };
98
- totalFees: bigint;
99
- totalManaUsed: bigint;
100
- spongeBlobHash: `0x${string}`;
101
- blockHeadersHash: `0x${string}`;
102
- };
103
- [inspect.custom](): string;
104
- equals(other: this): boolean;
105
- }
106
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfYmxvY2tfaGVhZGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2svbDJfYmxvY2tfaGVhZGVyLnRzIl0sIm5hb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E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAM,iBAczD;IAED,OAAO,IAAI,OAAO,CAajB;IAED;;;OAGG;IACI,QAAQ,kBAEd;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,iBAE5B;IAED,kBAAkB,qBAcjB;IAED,aAAa,gBASZ;IAED,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;MAaR;IAED,CAAC,OAAO,CAAC,MAAM,CAAC,WAgBf;IAEM,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO,CAalC;CACF"}
@@ -1,167 +0,0 @@
1
- var _computedKey;
2
- import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { schemas } from '@aztec/foundation/schemas';
4
- import { BufferReader, FieldReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
5
- import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
6
- import { inspect } from 'util';
7
- import { z } from 'zod';
8
- import { CheckpointHeader } from '../rollup/checkpoint_header.js';
9
- import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
10
- import { BlockHeader, GlobalVariables, StateReference } from '../tx/index.js';
11
- _computedKey = inspect.custom;
12
- /**
13
- * TO BE DELETED
14
- *
15
- * A header of an L2 block combining the block header and the checkpoint header.
16
- * This is a temporary workaround to avoid changing too many things before building in chunks is properly implemented.
17
- * This works for now because we only have one block per checkpoint.
18
- *
19
- * @deprecated Use BlockHeader or CheckpointHeader instead.
20
- */ export class L2BlockHeader {
21
- lastArchive;
22
- blobsHash;
23
- inHash;
24
- epochOutHash;
25
- state;
26
- globalVariables;
27
- totalFees;
28
- totalManaUsed;
29
- spongeBlobHash;
30
- blockHeadersHash;
31
- constructor(/** Snapshot of archive before the block is applied. */ lastArchive, blobsHash, inHash, /** Root of the epoch out hash tree. Leaves are the out hashes of this block and all previous blocks in the epoch. */ epochOutHash, /** State reference. */ state, /** Global variables of an L2 block. */ globalVariables, /** Total fees in the block, computed by the root rollup circuit */ totalFees, /** Total mana used in the block, computed by the root rollup circuit */ totalManaUsed, /** Hash of the sponge blob of the block. */ spongeBlobHash, /** Hash of the block headers in the checkpoint. */ blockHeadersHash){
32
- this.lastArchive = lastArchive;
33
- this.blobsHash = blobsHash;
34
- this.inHash = inHash;
35
- this.epochOutHash = epochOutHash;
36
- this.state = state;
37
- this.globalVariables = globalVariables;
38
- this.totalFees = totalFees;
39
- this.totalManaUsed = totalManaUsed;
40
- this.spongeBlobHash = spongeBlobHash;
41
- this.blockHeadersHash = blockHeadersHash;
42
- }
43
- static get schema() {
44
- return z.object({
45
- lastArchive: AppendOnlyTreeSnapshot.schema,
46
- blobsHash: schemas.Fr,
47
- inHash: schemas.Fr,
48
- epochOutHash: schemas.Fr,
49
- state: StateReference.schema,
50
- globalVariables: GlobalVariables.schema,
51
- totalFees: schemas.Fr,
52
- totalManaUsed: schemas.Fr,
53
- spongeBlobHash: schemas.Fr,
54
- blockHeadersHash: schemas.Fr
55
- }).transform(L2BlockHeader.from);
56
- }
57
- static getFields(fields) {
58
- return [
59
- fields.lastArchive,
60
- fields.blobsHash,
61
- fields.inHash,
62
- fields.epochOutHash,
63
- fields.state,
64
- fields.globalVariables,
65
- fields.totalFees,
66
- fields.totalManaUsed,
67
- fields.spongeBlobHash,
68
- fields.blockHeadersHash
69
- ];
70
- }
71
- static from(fields) {
72
- return new L2BlockHeader(...L2BlockHeader.getFields(fields));
73
- }
74
- getSlot() {
75
- return this.globalVariables.slotNumber;
76
- }
77
- getBlockNumber() {
78
- return this.globalVariables.blockNumber;
79
- }
80
- getSize() {
81
- return this.lastArchive.getSize() + this.blobsHash.size + this.inHash.size + this.epochOutHash.size + this.state.getSize() + this.globalVariables.getSize() + this.totalFees.size + this.totalManaUsed.size + this.spongeBlobHash.size + this.blockHeadersHash.size;
82
- }
83
- toBuffer() {
84
- return serializeToBuffer(...L2BlockHeader.getFields(this));
85
- }
86
- toFields() {
87
- return serializeToFields(...L2BlockHeader.getFields(this));
88
- }
89
- clone() {
90
- return L2BlockHeader.fromBuffer(this.toBuffer());
91
- }
92
- static fromBuffer(buffer) {
93
- const reader = BufferReader.asReader(buffer);
94
- return new L2BlockHeader(reader.readObject(AppendOnlyTreeSnapshot), reader.readObject(Fr), reader.readObject(Fr), reader.readObject(Fr), reader.readObject(StateReference), reader.readObject(GlobalVariables), reader.readObject(Fr), reader.readObject(Fr), reader.readObject(Fr), reader.readObject(Fr));
95
- }
96
- static fromFields(fields) {
97
- const reader = FieldReader.asReader(fields);
98
- return new L2BlockHeader(AppendOnlyTreeSnapshot.fromFields(reader), reader.readField(), reader.readField(), reader.readField(), StateReference.fromFields(reader), GlobalVariables.fromFields(reader), reader.readField(), reader.readField(), reader.readField(), reader.readField());
99
- }
100
- static empty(fields = {}) {
101
- return L2BlockHeader.from({
102
- lastArchive: AppendOnlyTreeSnapshot.empty(),
103
- blobsHash: Fr.ZERO,
104
- inHash: Fr.ZERO,
105
- epochOutHash: Fr.ZERO,
106
- state: StateReference.empty(),
107
- globalVariables: GlobalVariables.empty(),
108
- totalFees: Fr.ZERO,
109
- totalManaUsed: Fr.ZERO,
110
- spongeBlobHash: Fr.ZERO,
111
- blockHeadersHash: Fr.ZERO,
112
- ...fields
113
- });
114
- }
115
- isEmpty() {
116
- return this.lastArchive.isEmpty() && this.blobsHash.isZero() && this.inHash.isZero() && this.epochOutHash.isZero() && this.state.isEmpty() && this.globalVariables.isEmpty() && this.totalFees.isZero() && this.totalManaUsed.isZero() && this.spongeBlobHash.isZero() && this.blockHeadersHash.isZero();
117
- }
118
- /**
119
- * Serializes this instance into a string.
120
- * @returns Encoded string.
121
- */ toString() {
122
- return bufferToHex(this.toBuffer());
123
- }
124
- static fromString(str) {
125
- return L2BlockHeader.fromBuffer(hexToBuffer(str));
126
- }
127
- toCheckpointHeader() {
128
- return new CheckpointHeader(this.lastArchive.root, this.blockHeadersHash, this.blobsHash, this.inHash, this.epochOutHash, this.globalVariables.slotNumber, this.globalVariables.timestamp, this.globalVariables.coinbase, this.globalVariables.feeRecipient, this.globalVariables.gasFees, this.totalManaUsed);
129
- }
130
- toBlockHeader() {
131
- return new BlockHeader(this.lastArchive, this.state, this.spongeBlobHash, this.globalVariables, this.totalFees, this.totalManaUsed);
132
- }
133
- toInspect() {
134
- return {
135
- lastArchive: this.lastArchive.root.toString(),
136
- blobsHash: this.blobsHash.toString(),
137
- inHash: this.inHash.toString(),
138
- epochOutHash: this.epochOutHash.toString(),
139
- state: this.state.toInspect(),
140
- globalVariables: this.globalVariables.toInspect(),
141
- totalFees: this.totalFees.toBigInt(),
142
- totalManaUsed: this.totalManaUsed.toBigInt(),
143
- spongeBlobHash: this.spongeBlobHash.toString(),
144
- blockHeadersHash: this.blockHeadersHash.toString()
145
- };
146
- }
147
- [_computedKey]() {
148
- return `L2BlockHeader {
149
- lastArchive: ${inspect(this.lastArchive)},
150
- blobsHash: ${inspect(this.blobsHash)},
151
- inHash: ${inspect(this.inHash)},
152
- epochOutHash: ${inspect(this.epochOutHash)},
153
- state.l1ToL2MessageTree: ${inspect(this.state.l1ToL2MessageTree)},
154
- state.noteHashTree: ${inspect(this.state.partial.noteHashTree)},
155
- state.nullifierTree: ${inspect(this.state.partial.nullifierTree)},
156
- state.publicDataTree: ${inspect(this.state.partial.publicDataTree)},
157
- globalVariables: ${inspect(this.globalVariables)},
158
- totalFees: ${this.totalFees},
159
- totalManaUsed: ${this.totalManaUsed},
160
- spongeBlobHash: ${this.spongeBlobHash},
161
- blockHeadersHash: ${this.blockHeadersHash},
162
- }`;
163
- }
164
- equals(other) {
165
- return this.lastArchive.equals(other.lastArchive) && this.blobsHash.equals(other.blobsHash) && this.inHash.equals(other.inHash) && this.epochOutHash.equals(other.epochOutHash) && this.state.equals(other.state) && this.globalVariables.equals(other.globalVariables) && this.totalFees.equals(other.totalFees) && this.totalManaUsed.equals(other.totalManaUsed) && this.spongeBlobHash.equals(other.spongeBlobHash) && this.blockHeadersHash.equals(other.blockHeadersHash);
166
- }
167
- }
@@ -1,274 +0,0 @@
1
- import { type BlockBlobData, encodeBlockBlobData, encodeCheckpointBlobDataFromBlocks } from '@aztec/blob-lib/encoding';
2
- import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
- import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
- import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
6
-
7
- import { z } from 'zod';
8
-
9
- import { Checkpoint } from '../checkpoint/checkpoint.js';
10
- import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
11
- import type { BlockHeader } from '../tx/block_header.js';
12
- import { Body } from './body.js';
13
- import { makeAppendOnlyTreeSnapshot, makeL2BlockHeader } from './l2_block_code_to_purge.js';
14
- import { L2BlockHeader } from './l2_block_header.js';
15
- import type { L2BlockInfo } from './l2_block_info.js';
16
- import { L2BlockNew } from './l2_block_new.js';
17
-
18
- /**
19
- * The data that makes up the rollup proof, with encoder decoder functions.
20
- *
21
- * @deprecated Use `L2BlockNew` instead.
22
- */
23
- export class L2Block {
24
- constructor(
25
- /** Snapshot of archive tree after the block is applied. */
26
- public archive: AppendOnlyTreeSnapshot,
27
- /** L2 block header. */
28
- public header: L2BlockHeader,
29
- /** L2 block body. */
30
- public body: Body,
31
- private blockHash: Fr | undefined = undefined,
32
- ) {}
33
-
34
- static get schema() {
35
- return z
36
- .object({
37
- archive: AppendOnlyTreeSnapshot.schema,
38
- header: L2BlockHeader.schema,
39
- body: Body.schema,
40
- })
41
- .transform(({ archive, header, body }) => new L2Block(archive, header, body));
42
- }
43
-
44
- /**
45
- * Deserializes a block from a buffer
46
- * @returns A deserialized L2 block.
47
- */
48
- static fromBuffer(buf: Buffer | BufferReader) {
49
- const reader = BufferReader.asReader(buf);
50
- const header = reader.readObject(L2BlockHeader);
51
- const archive = reader.readObject(AppendOnlyTreeSnapshot);
52
- const body = reader.readObject(Body);
53
-
54
- return new L2Block(archive, header, body);
55
- }
56
-
57
- /**
58
- * Serializes a block
59
- * @returns A serialized L2 block as a Buffer.
60
- */
61
- toBuffer() {
62
- return serializeToBuffer(this.header, this.archive, this.body);
63
- }
64
-
65
- /**
66
- * Deserializes L2 block from a buffer.
67
- * @param str - A serialized L2 block.
68
- * @returns Deserialized L2 block.
69
- */
70
- static fromString(str: string): L2Block {
71
- return L2Block.fromBuffer(hexToBuffer(str));
72
- }
73
-
74
- /**
75
- * Serializes a block to a string.
76
- * @returns A serialized L2 block as a string.
77
- */
78
- toString(): string {
79
- return bufferToHex(this.toBuffer());
80
- }
81
-
82
- /**
83
- * Creates an L2 block containing random data.
84
- * @param l2BlockNum - The number of the L2 block.
85
- * @param txsPerBlock - The number of transactions to include in the block.
86
- * @param numPublicCallsPerTx - The number of public function calls to include in each transaction.
87
- * @param numPublicLogsPerCall - The number of public logs per 1 public function invocation.
88
- * @param inHash - The hash of the L1 to L2 messages subtree which got inserted in this block.
89
- * @returns The L2 block.
90
- */
91
- static async random(
92
- l2BlockNum: BlockNumber,
93
- txsPerBlock = 4,
94
- numPublicCallsPerTx = 3,
95
- numPublicLogsPerCall = 1,
96
- inHash: Fr | undefined = undefined,
97
- slotNumber: number | undefined = undefined,
98
- maxEffects: number | undefined = undefined,
99
- ): Promise<L2Block> {
100
- const body = await Body.random({ txsPerBlock, numPublicCallsPerTx, numPublicLogsPerCall, maxEffects });
101
-
102
- return new L2Block(
103
- makeAppendOnlyTreeSnapshot(l2BlockNum + 1),
104
- makeL2BlockHeader(0, l2BlockNum, slotNumber ?? l2BlockNum, { inHash }),
105
- body,
106
- );
107
- }
108
-
109
- /**
110
- * Creates an L2 block containing empty data.
111
- * @param header - An optional header to assign to the block
112
- * @returns The L2 block.
113
- */
114
- static empty(header?: L2BlockHeader): L2Block {
115
- return new L2Block(AppendOnlyTreeSnapshot.empty(), header ?? L2BlockHeader.empty(), Body.empty());
116
- }
117
-
118
- get number(): BlockNumber {
119
- return this.header.getBlockNumber();
120
- }
121
-
122
- get slot(): SlotNumber {
123
- return this.header.getSlot();
124
- }
125
-
126
- get timestamp(): bigint {
127
- return this.header.globalVariables.timestamp;
128
- }
129
-
130
- /**
131
- * Returns the block's hash (hash of block header).
132
- * @returns The block's hash.
133
- */
134
- public async hash(): Promise<Fr> {
135
- if (this.blockHash === undefined) {
136
- this.blockHash = await this.getBlockHeader().hash();
137
- }
138
- return this.blockHash;
139
- }
140
-
141
- /**
142
- * @deprecated
143
- * This only works when there's one block per checkpoint.
144
- * TODO(#17027): Remove this method from L2Block and create a dedicated Checkpoint class.
145
- */
146
- public getCheckpointHeader() {
147
- return this.header.toCheckpointHeader();
148
- }
149
-
150
- // Temporary helper to get the actual block header.
151
- public getBlockHeader(): BlockHeader {
152
- return this.header.toBlockHeader();
153
- }
154
-
155
- public toL2Block(args: { checkpointNumber?: CheckpointNumber; indexWithinCheckpoint?: number } = {}): L2BlockNew {
156
- return new L2BlockNew(
157
- this.archive,
158
- this.getBlockHeader(),
159
- this.body,
160
- args?.checkpointNumber ?? CheckpointNumber.fromBlockNumber(this.number),
161
- args?.indexWithinCheckpoint ?? 0,
162
- );
163
- }
164
-
165
- public toCheckpoint() {
166
- return new Checkpoint(
167
- this.archive,
168
- this.getCheckpointHeader(),
169
- [this.toL2Block()],
170
- CheckpointNumber.fromBlockNumber(this.number),
171
- );
172
- }
173
-
174
- static fromCheckpoint(checkpoint: Checkpoint) {
175
- const checkpointHeader = checkpoint.header;
176
- const block = checkpoint.blocks.at(-1)!;
177
- const header = new L2BlockHeader(
178
- new AppendOnlyTreeSnapshot(checkpointHeader.lastArchiveRoot, block.number),
179
- checkpointHeader.blobsHash,
180
- checkpointHeader.inHash,
181
- checkpointHeader.epochOutHash,
182
- block.header.state,
183
- block.header.globalVariables,
184
- block.header.totalFees,
185
- checkpointHeader.totalManaUsed,
186
- block.header.spongeBlobHash,
187
- checkpointHeader.blockHeadersHash,
188
- );
189
- return new L2Block(checkpoint.archive, header, block.body);
190
- }
191
-
192
- /**
193
- * @deprecated
194
- * This only works when there's one block per checkpoint.
195
- * TODO(#17027): Remove this method from L2Block and create a dedicated Checkpoint class.
196
- */
197
- public getCheckpointBlobFields() {
198
- const blockBlobData = this.toBlockBlobData();
199
- return encodeCheckpointBlobDataFromBlocks([blockBlobData]);
200
- }
201
-
202
- public toBlobFields(): Fr[] {
203
- const blockBlobData = this.toBlockBlobData();
204
- return encodeBlockBlobData(blockBlobData);
205
- }
206
-
207
- public toBlockBlobData(): BlockBlobData {
208
- // There's only one L2Block per checkpoint, so it's always the first block in the checkpoint.
209
- const isFirstBlock = true;
210
- return {
211
- blockEndMarker: {
212
- numTxs: this.body.txEffects.length,
213
- timestamp: this.header.globalVariables.timestamp,
214
- blockNumber: this.number,
215
- },
216
- blockEndStateField: {
217
- l1ToL2MessageNextAvailableLeafIndex: this.header.state.l1ToL2MessageTree.nextAvailableLeafIndex,
218
- noteHashNextAvailableLeafIndex: this.header.state.partial.noteHashTree.nextAvailableLeafIndex,
219
- nullifierNextAvailableLeafIndex: this.header.state.partial.nullifierTree.nextAvailableLeafIndex,
220
- publicDataNextAvailableLeafIndex: this.header.state.partial.publicDataTree.nextAvailableLeafIndex,
221
- totalManaUsed: this.header.totalManaUsed.toBigInt(),
222
- },
223
- lastArchiveRoot: this.header.lastArchive.root,
224
- noteHashRoot: this.header.state.partial.noteHashTree.root,
225
- nullifierRoot: this.header.state.partial.nullifierTree.root,
226
- publicDataRoot: this.header.state.partial.publicDataTree.root,
227
- l1ToL2MessageRoot: isFirstBlock ? this.header.state.l1ToL2MessageTree.root : undefined,
228
- txs: this.body.toTxBlobData(),
229
- };
230
- }
231
-
232
- /**
233
- * Returns stats used for logging.
234
- * @returns Stats on tx count, number, and log size and count.
235
- */
236
- getStats() {
237
- const logsStats = {
238
- privateLogCount: this.body.txEffects.reduce((logCount, txEffect) => logCount + txEffect.privateLogs.length, 0),
239
- publicLogCount: this.body.txEffects.reduce((logCount, txEffect) => logCount + txEffect.publicLogs.length, 0),
240
- contractClassLogCount: this.body.txEffects.reduce(
241
- (logCount, txEffect) => logCount + txEffect.contractClassLogs.length,
242
- 0,
243
- ),
244
- contractClassLogSize: this.body.txEffects.reduce(
245
- (totalLogSize, txEffect) =>
246
- totalLogSize + txEffect.contractClassLogs.reduce((acc, log) => acc + log.emittedLength, 0),
247
- 0,
248
- ),
249
- };
250
-
251
- return {
252
- txCount: this.body.txEffects.length,
253
- blockNumber: this.number,
254
- blockTimestamp: Number(this.header.globalVariables.timestamp),
255
- ...logsStats,
256
- };
257
- }
258
-
259
- toBlockInfo(): L2BlockInfo {
260
- return {
261
- blockHash: this.blockHash,
262
- archive: this.archive.root,
263
- lastArchive: this.header.lastArchive.root,
264
- blockNumber: this.number,
265
- slotNumber: this.header.getSlot(),
266
- txCount: this.body.txEffects.length,
267
- timestamp: this.header.globalVariables.timestamp,
268
- };
269
- }
270
-
271
- equals(other: L2Block) {
272
- return this.archive.equals(other.archive) && this.header.equals(other.header) && this.body.equals(other.body);
273
- }
274
- }