@aztec/stdlib 0.86.0-nightly.20250426 → 0.86.0-nightly.20250428

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 (47) hide show
  1. package/dest/block/l2_block.d.ts +0 -17
  2. package/dest/block/l2_block.d.ts.map +1 -1
  3. package/dest/block/l2_block.js +0 -40
  4. package/dest/p2p/block_attestation.d.ts +5 -2
  5. package/dest/p2p/block_attestation.d.ts.map +1 -1
  6. package/dest/p2p/block_attestation.js +11 -10
  7. package/dest/p2p/block_proposal.d.ts +6 -3
  8. package/dest/p2p/block_proposal.d.ts.map +1 -1
  9. package/dest/p2p/block_proposal.js +10 -10
  10. package/dest/p2p/consensus_payload.d.ts +183 -9
  11. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  12. package/dest/p2p/consensus_payload.js +21 -14
  13. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts +8 -0
  14. package/dest/rollup/block_root_or_block_merge_public_inputs.d.ts.map +1 -1
  15. package/dest/rollup/block_root_or_block_merge_public_inputs.js +6 -2
  16. package/dest/rollup/root_rollup.d.ts +5 -2
  17. package/dest/rollup/root_rollup.d.ts.map +1 -1
  18. package/dest/rollup/root_rollup.js +12 -3
  19. package/dest/tests/factories.d.ts.map +1 -1
  20. package/dest/tests/factories.js +2 -2
  21. package/dest/tests/mocks.d.ts +2 -1
  22. package/dest/tests/mocks.d.ts.map +1 -1
  23. package/dest/tests/mocks.js +9 -6
  24. package/dest/tx/block_header.d.ts +2 -0
  25. package/dest/tx/block_header.d.ts.map +1 -1
  26. package/dest/tx/block_header.js +4 -0
  27. package/dest/tx/index.d.ts +1 -0
  28. package/dest/tx/index.d.ts.map +1 -1
  29. package/dest/tx/index.js +1 -0
  30. package/dest/tx/proposed_block_header.d.ts +83 -0
  31. package/dest/tx/proposed_block_header.d.ts.map +1 -0
  32. package/dest/tx/proposed_block_header.js +129 -0
  33. package/dest/types/shared.d.ts +4 -0
  34. package/dest/types/shared.d.ts.map +1 -1
  35. package/package.json +7 -7
  36. package/src/block/l2_block.ts +0 -60
  37. package/src/p2p/block_attestation.ts +15 -11
  38. package/src/p2p/block_proposal.ts +10 -10
  39. package/src/p2p/consensus_payload.ts +29 -16
  40. package/src/rollup/block_root_or_block_merge_public_inputs.ts +6 -0
  41. package/src/rollup/root_rollup.ts +12 -0
  42. package/src/tests/factories.ts +4 -0
  43. package/src/tests/mocks.ts +24 -8
  44. package/src/tx/block_header.ts +14 -0
  45. package/src/tx/index.ts +1 -0
  46. package/src/tx/proposed_block_header.ts +168 -0
  47. package/src/types/shared.ts +5 -0
@@ -100,23 +100,6 @@ export declare class L2Block {
100
100
  * @returns The block's hash.
101
101
  */
102
102
  hash(): Promise<Fr>;
103
- /**
104
- * Computes the public inputs hash for the L2 block.
105
- * The same output as the hash of RootRollupPublicInputs.
106
- * TODO(Miranda): Check where/if this is used (v diff now with epochs and blobs)
107
- * @returns The public input hash for the L2 block as a field element.
108
- */
109
- getPublicInputsHash(): Fr;
110
- /**
111
- * Computes the start state hash (should equal contract data before block).
112
- * @returns The start state hash for the L2 block.
113
- */
114
- getStartStateHash(): Buffer;
115
- /**
116
- * Computes the end state hash (should equal contract data after block).
117
- * @returns The end state hash for the L2 block.
118
- */
119
- getEndStateHash(): Buffer;
120
103
  /**
121
104
  * Returns stats used for logging.
122
105
  * @returns Stats on tx count, number, and log size and count.
@@ -1 +1 @@
1
- {"version":3,"file":"l2_block.d.ts","sourceRoot":"","sources":["../../src/block/l2_block.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAG9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE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;;;;;;;;;IAuBR,MAAM,CAAC,KAAK,EAAE,OAAO;CAGtB"}
@@ -1,5 +1,3 @@
1
- import { sha256, sha256ToField } from '@aztec/foundation/crypto';
2
- import { Fr } from '@aztec/foundation/fields';
3
1
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
2
  import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
5
3
  import { z } from 'zod';
@@ -82,44 +80,6 @@ import { makeAppendOnlyTreeSnapshot, makeHeader } from './l2_block_code_to_purge
82
80
  return this.header.hash();
83
81
  }
84
82
  /**
85
- * Computes the public inputs hash for the L2 block.
86
- * The same output as the hash of RootRollupPublicInputs.
87
- * TODO(Miranda): Check where/if this is used (v diff now with epochs and blobs)
88
- * @returns The public input hash for the L2 block as a field element.
89
- */ // TODO(#4844)
90
- getPublicInputsHash() {
91
- const preimage = [
92
- this.header.globalVariables,
93
- AppendOnlyTreeSnapshot.zero(),
94
- AppendOnlyTreeSnapshot.zero(),
95
- AppendOnlyTreeSnapshot.zero(),
96
- AppendOnlyTreeSnapshot.zero(),
97
- this.header.lastArchive,
98
- this.header.state.partial.noteHashTree,
99
- this.header.state.partial.nullifierTree,
100
- this.header.state.partial.publicDataTree,
101
- this.header.state.l1ToL2MessageTree,
102
- this.archive
103
- ];
104
- return sha256ToField(preimage);
105
- }
106
- /**
107
- * Computes the start state hash (should equal contract data before block).
108
- * @returns The start state hash for the L2 block.
109
- */ // TODO(#4844)
110
- getStartStateHash() {
111
- const inputValue = serializeToBuffer(new Fr(Number(this.header.globalVariables.blockNumber.toBigInt()) - 1), AppendOnlyTreeSnapshot.zero(), AppendOnlyTreeSnapshot.zero(), AppendOnlyTreeSnapshot.zero(), AppendOnlyTreeSnapshot.zero(), this.header.lastArchive);
112
- return sha256(inputValue);
113
- }
114
- /**
115
- * Computes the end state hash (should equal contract data after block).
116
- * @returns The end state hash for the L2 block.
117
- */ // TODO(#4844)
118
- getEndStateHash() {
119
- const inputValue = serializeToBuffer(this.header.globalVariables.blockNumber, this.header.state.partial.noteHashTree, this.header.state.partial.nullifierTree, this.header.state.partial.publicDataTree, this.header.state.l1ToL2MessageTree, this.archive);
120
- return sha256(inputValue);
121
- }
122
- /**
123
83
  * Returns stats used for logging.
124
84
  * @returns Stats on tx count, number, and log size and count.
125
85
  */ getStats() {
@@ -3,7 +3,7 @@
3
3
  import { Buffer32 } from '@aztec/foundation/buffer';
4
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { Signature } from '@aztec/foundation/eth-signature';
6
- import type { Fr } from '@aztec/foundation/fields';
6
+ import { Fr } from '@aztec/foundation/fields';
7
7
  import { BufferReader } from '@aztec/foundation/serialize';
8
8
  import type { ZodFor } from '../schemas/index.js';
9
9
  import { ConsensusPayload } from './consensus_payload.js';
@@ -19,6 +19,8 @@ export declare class BlockAttestationHash extends Buffer32 {
19
19
  * will produce a block attestation over the header of the block
20
20
  */
21
21
  export declare class BlockAttestation extends Gossipable {
22
+ /** The block number of the attestation. */
23
+ readonly blockNumber: Fr;
22
24
  /** The payload of the message, and what the signature is over */
23
25
  readonly payload: ConsensusPayload;
24
26
  /** The signature of the block attester */
@@ -26,6 +28,8 @@ export declare class BlockAttestation extends Gossipable {
26
28
  static p2pTopic: TopicType;
27
29
  private sender;
28
30
  constructor(
31
+ /** The block number of the attestation. */
32
+ blockNumber: Fr,
29
33
  /** The payload of the message, and what the signature is over */
30
34
  payload: ConsensusPayload,
31
35
  /** The signature of the block attester */
@@ -34,7 +38,6 @@ export declare class BlockAttestation extends Gossipable {
34
38
  p2pMessageIdentifier(): Promise<Buffer32>;
35
39
  get archive(): Fr;
36
40
  get slotNumber(): Fr;
37
- get blockNumber(): Fr;
38
41
  /**Get sender
39
42
  *
40
43
  * Lazily evaluate and cache the sender of the attestation
@@ -1 +1 @@
1
- {"version":3,"file":"block_attestation.d.ts","sourceRoot":"","sources":["../../src/p2p/block_attestation.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAA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I,UAAU;IAWvB,UAAU,IAAI,MAAM;IAIpB,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB;IAS/D,MAAM,CAAC,KAAK,IAAI,gBAAgB;IAIhC,OAAO,IAAI,MAAM;CAGlB"}
@@ -1,6 +1,7 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
2
  import { keccak256, recoverAddress } from '@aztec/foundation/crypto';
3
3
  import { Signature } from '@aztec/foundation/eth-signature';
4
+ import { Fr } from '@aztec/foundation/fields';
4
5
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
6
  import { z } from 'zod';
6
7
  import { ConsensusPayload } from './consensus_payload.js';
@@ -18,18 +19,20 @@ export class BlockAttestationHash extends Buffer32 {
18
19
  * A validator that has attested to seeing the contents of a block
19
20
  * will produce a block attestation over the header of the block
20
21
  */ export class BlockAttestation extends Gossipable {
22
+ blockNumber;
21
23
  payload;
22
24
  signature;
23
25
  static p2pTopic = TopicType.block_attestation;
24
26
  sender;
25
- constructor(/** The payload of the message, and what the signature is over */ payload, /** The signature of the block attester */ signature){
26
- super(), this.payload = payload, this.signature = signature;
27
+ constructor(/** The block number of the attestation. */ blockNumber, /** The payload of the message, and what the signature is over */ payload, /** The signature of the block attester */ signature){
28
+ super(), this.blockNumber = blockNumber, this.payload = payload, this.signature = signature;
27
29
  }
28
30
  static get schema() {
29
31
  return z.object({
32
+ blockNumber: Fr.schema,
30
33
  payload: ConsensusPayload.schema,
31
34
  signature: Signature.schema
32
- }).transform((obj)=>new BlockAttestation(obj.payload, obj.signature));
35
+ }).transform((obj)=>new BlockAttestation(obj.blockNumber, obj.payload, obj.signature));
33
36
  }
34
37
  p2pMessageIdentifier() {
35
38
  return Promise.resolve(new BlockAttestationHash(keccak256(this.signature.toBuffer())));
@@ -38,10 +41,7 @@ export class BlockAttestationHash extends Buffer32 {
38
41
  return this.payload.archive;
39
42
  }
40
43
  get slotNumber() {
41
- return this.payload.header.globalVariables.slotNumber;
42
- }
43
- get blockNumber() {
44
- return this.payload.header.globalVariables.blockNumber;
44
+ return this.payload.header.slotNumber;
45
45
  }
46
46
  /**Get sender
47
47
  *
@@ -61,18 +61,19 @@ export class BlockAttestationHash extends Buffer32 {
61
61
  }
62
62
  toBuffer() {
63
63
  return serializeToBuffer([
64
+ this.blockNumber,
64
65
  this.payload,
65
66
  this.signature
66
67
  ]);
67
68
  }
68
69
  static fromBuffer(buf) {
69
70
  const reader = BufferReader.asReader(buf);
70
- return new BlockAttestation(reader.readObject(ConsensusPayload), reader.readObject(Signature));
71
+ return new BlockAttestation(reader.readObject(Fr), reader.readObject(ConsensusPayload), reader.readObject(Signature));
71
72
  }
72
73
  static empty() {
73
- return new BlockAttestation(ConsensusPayload.empty(), Signature.empty());
74
+ return new BlockAttestation(Fr.ZERO, ConsensusPayload.empty(), Signature.empty());
74
75
  }
75
76
  getSize() {
76
- return this.payload.getSize() + this.signature.getSize();
77
+ return this.blockNumber.size + this.payload.getSize() + this.signature.getSize();
77
78
  }
78
79
  }
@@ -3,7 +3,7 @@
3
3
  import { Buffer32 } from '@aztec/foundation/buffer';
4
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { Signature } from '@aztec/foundation/eth-signature';
6
- import type { Fr } from '@aztec/foundation/fields';
6
+ import { Fr } from '@aztec/foundation/fields';
7
7
  import { BufferReader } from '@aztec/foundation/serialize';
8
8
  import { ConsensusPayload } from './consensus_payload.js';
9
9
  import { Gossipable } from './gossipable.js';
@@ -18,6 +18,8 @@ export declare class BlockProposalHash extends Buffer32 {
18
18
  * be included in the head of the chain
19
19
  */
20
20
  export declare class BlockProposal extends Gossipable {
21
+ /** The number of the block */
22
+ readonly blockNumber: Fr;
21
23
  /** The payload of the message, and what the signature is over */
22
24
  readonly payload: ConsensusPayload;
23
25
  /** The signer of the BlockProposal over the header of the new block*/
@@ -25,6 +27,8 @@ export declare class BlockProposal extends Gossipable {
25
27
  static p2pTopic: TopicType;
26
28
  private sender;
27
29
  constructor(
30
+ /** The number of the block */
31
+ blockNumber: Fr,
28
32
  /** The payload of the message, and what the signature is over */
29
33
  payload: ConsensusPayload,
30
34
  /** The signer of the BlockProposal over the header of the new block*/
@@ -32,8 +36,7 @@ export declare class BlockProposal extends Gossipable {
32
36
  p2pMessageIdentifier(): Promise<Buffer32>;
33
37
  get archive(): Fr;
34
38
  get slotNumber(): Fr;
35
- get blockNumber(): Fr;
36
- static createProposalFromSigner(payload: ConsensusPayload, payloadSigner: (payload: Buffer32) => Promise<Signature>): Promise<BlockProposal>;
39
+ static createProposalFromSigner(blockNumber: Fr, payload: ConsensusPayload, payloadSigner: (payload: Buffer32) => Promise<Signature>): Promise<BlockProposal>;
37
40
  /**Get Sender
38
41
  * Lazily evaluate the sender of the proposal; result is cached
39
42
  */
@@ -1 +1 @@
1
- {"version":3,"file":"block_proposal.d.ts","sourceRoot":"","sources":["../../src/p2p/block_proposal.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,IAAI,EAAE,MAAM;CAGzB;AAED;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,UAAU;IAMzC,iEAAiE;aACjD,OAAO,EAAE,gBAAgB;IAEzC,sEAAsE;a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AMzC,8BAA8B;aACd,WAAW,EAAE,EAAE;IAE/B,iEAAiE;aACjD,OAAO,EAAE,gBAAgB;IAEzC,sEAAsE;aACtD,SAAS,EAAE,SAAS;IAZtC,OAAgB,QAAQ,YAA4B;IAEpD,OAAO,CAAC,MAAM,CAAyB;;IAGrC,8BAA8B;IACd,WAAW,EAAE,EAAE;IAE/B,iEAAiE;IACjD,OAAO,EAAE,gBAAgB;IAEzC,sEAAsE;IACtD,SAAS,EAAE,SAAS;IAK7B,oBAAoB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAIlD,IAAI,OAAO,IAAI,EAAE,CAEhB;IAED,IAAI,UAAU,IAAI,EAAE,CAEnB;WAEY,wBAAwB,CACnC,WAAW,EAAE,EAAE,EACf,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,SAAS,CAAC;IAQ1D;;OAEG;IACH,SAAS;IAUT,UAAU;IAIV,QAAQ,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,aAAa;IAK5D,OAAO,IAAI,MAAM;CAGlB"}
@@ -1,6 +1,7 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
2
  import { keccak256, recoverAddress } from '@aztec/foundation/crypto';
3
3
  import { Signature } from '@aztec/foundation/eth-signature';
4
+ import { Fr } from '@aztec/foundation/fields';
4
5
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
6
  import { ConsensusPayload } from './consensus_payload.js';
6
7
  import { Gossipable } from './gossipable.js';
@@ -17,12 +18,13 @@ export class BlockProposalHash extends Buffer32 {
17
18
  * A block proposal is created by the leader of the chain proposing a sequence of transactions to
18
19
  * be included in the head of the chain
19
20
  */ export class BlockProposal extends Gossipable {
21
+ blockNumber;
20
22
  payload;
21
23
  signature;
22
24
  static p2pTopic = TopicType.block_proposal;
23
25
  sender;
24
- constructor(/** The payload of the message, and what the signature is over */ payload, /** The signer of the BlockProposal over the header of the new block*/ signature){
25
- super(), this.payload = payload, this.signature = signature;
26
+ constructor(/** The number of the block */ blockNumber, /** The payload of the message, and what the signature is over */ payload, /** The signer of the BlockProposal over the header of the new block*/ signature){
27
+ super(), this.blockNumber = blockNumber, this.payload = payload, this.signature = signature;
26
28
  }
27
29
  p2pMessageIdentifier() {
28
30
  return Promise.resolve(new BlockProposalHash(keccak256(this.signature.toBuffer())));
@@ -31,15 +33,12 @@ export class BlockProposalHash extends Buffer32 {
31
33
  return this.payload.archive;
32
34
  }
33
35
  get slotNumber() {
34
- return this.payload.header.globalVariables.slotNumber;
36
+ return this.payload.header.slotNumber;
35
37
  }
36
- get blockNumber() {
37
- return this.payload.header.globalVariables.blockNumber;
38
- }
39
- static async createProposalFromSigner(payload, payloadSigner) {
38
+ static async createProposalFromSigner(blockNumber, payload, payloadSigner) {
40
39
  const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
41
40
  const sig = await payloadSigner(hashed);
42
- return new BlockProposal(payload, sig);
41
+ return new BlockProposal(blockNumber, payload, sig);
43
42
  }
44
43
  /**Get Sender
45
44
  * Lazily evaluate the sender of the proposal; result is cached
@@ -56,15 +55,16 @@ export class BlockProposalHash extends Buffer32 {
56
55
  }
57
56
  toBuffer() {
58
57
  return serializeToBuffer([
58
+ this.blockNumber,
59
59
  this.payload,
60
60
  this.signature
61
61
  ]);
62
62
  }
63
63
  static fromBuffer(buf) {
64
64
  const reader = BufferReader.asReader(buf);
65
- return new BlockProposal(reader.readObject(ConsensusPayload), reader.readObject(Signature));
65
+ return new BlockProposal(reader.readObject(Fr), reader.readObject(ConsensusPayload), reader.readObject(Signature));
66
66
  }
67
67
  getSize() {
68
- return this.payload.getSize() + this.signature.getSize();
68
+ return this.blockNumber.size + this.payload.getSize() + this.signature.getSize();
69
69
  }
70
70
  }
@@ -5,39 +5,213 @@ import { BufferReader } from '@aztec/foundation/serialize';
5
5
  import type { FieldsOf } from '@aztec/foundation/types';
6
6
  import { z } from 'zod';
7
7
  import type { L2Block } from '../block/l2_block.js';
8
- import { BlockHeader } from '../tx/block_header.js';
9
- import { TxHash } from '../tx/tx_hash.js';
8
+ import { ProposedBlockHeader, StateReference, TxHash } from '../tx/index.js';
10
9
  import type { Signable, SignatureDomainSeparator } from './signature_utils.js';
11
10
  export declare class ConsensusPayload implements Signable {
12
- /** The block header the attestation is made over */
13
- readonly header: BlockHeader;
11
+ /** The proposed block header the attestation is made over */
12
+ readonly header: ProposedBlockHeader;
13
+ /** The archive root after the block is added */
14
14
  readonly archive: Fr;
15
+ /** The state reference after the block is added */
16
+ readonly stateReference: StateReference;
15
17
  /** The sequence of transactions in the block */
16
18
  readonly txHashes: TxHash[];
17
19
  private size;
18
20
  constructor(
19
- /** The block header the attestation is made over */
20
- header: BlockHeader, archive: Fr,
21
+ /** The proposed block header the attestation is made over */
22
+ header: ProposedBlockHeader,
23
+ /** The archive root after the block is added */
24
+ archive: Fr,
25
+ /** The state reference after the block is added */
26
+ stateReference: StateReference,
21
27
  /** The sequence of transactions in the block */
22
28
  txHashes: TxHash[]);
23
29
  static get schema(): z.ZodEffects<z.ZodObject<{
24
- header: import("@aztec/foundation/schemas").ZodFor<BlockHeader>;
30
+ header: import("@aztec/foundation/schemas").ZodFor<ProposedBlockHeader>;
25
31
  archive: z.ZodType<Fr, any, string>;
32
+ stateReference: z.ZodEffects<z.ZodObject<{
33
+ l1ToL2MessageTree: z.ZodEffects<z.ZodObject<{
34
+ root: z.ZodType<Fr, any, string>;
35
+ nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
36
+ }, "strip", z.ZodTypeAny, {
37
+ root: Fr;
38
+ nextAvailableLeafIndex: number;
39
+ }, {
40
+ root: string;
41
+ nextAvailableLeafIndex: string | number | bigint;
42
+ }>, import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot, {
43
+ root: string;
44
+ nextAvailableLeafIndex: string | number | bigint;
45
+ }>;
46
+ partial: z.ZodEffects<z.ZodObject<{
47
+ noteHashTree: z.ZodEffects<z.ZodObject<{
48
+ root: z.ZodType<Fr, any, string>;
49
+ nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ root: Fr;
52
+ nextAvailableLeafIndex: number;
53
+ }, {
54
+ root: string;
55
+ nextAvailableLeafIndex: string | number | bigint;
56
+ }>, import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot, {
57
+ root: string;
58
+ nextAvailableLeafIndex: string | number | bigint;
59
+ }>;
60
+ nullifierTree: z.ZodEffects<z.ZodObject<{
61
+ root: z.ZodType<Fr, any, string>;
62
+ nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ root: Fr;
65
+ nextAvailableLeafIndex: number;
66
+ }, {
67
+ root: string;
68
+ nextAvailableLeafIndex: string | number | bigint;
69
+ }>, import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot, {
70
+ root: string;
71
+ nextAvailableLeafIndex: string | number | bigint;
72
+ }>;
73
+ publicDataTree: z.ZodEffects<z.ZodObject<{
74
+ root: z.ZodType<Fr, any, string>;
75
+ nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
76
+ }, "strip", z.ZodTypeAny, {
77
+ root: Fr;
78
+ nextAvailableLeafIndex: number;
79
+ }, {
80
+ root: string;
81
+ nextAvailableLeafIndex: string | number | bigint;
82
+ }>, import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot, {
83
+ root: string;
84
+ nextAvailableLeafIndex: string | number | bigint;
85
+ }>;
86
+ }, "strip", z.ZodTypeAny, {
87
+ noteHashTree: import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot;
88
+ nullifierTree: import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot;
89
+ publicDataTree: import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot;
90
+ }, {
91
+ noteHashTree: {
92
+ root: string;
93
+ nextAvailableLeafIndex: string | number | bigint;
94
+ };
95
+ nullifierTree: {
96
+ root: string;
97
+ nextAvailableLeafIndex: string | number | bigint;
98
+ };
99
+ publicDataTree: {
100
+ root: string;
101
+ nextAvailableLeafIndex: string | number | bigint;
102
+ };
103
+ }>, import("../tx/partial_state_reference.js").PartialStateReference, {
104
+ noteHashTree: {
105
+ root: string;
106
+ nextAvailableLeafIndex: string | number | bigint;
107
+ };
108
+ nullifierTree: {
109
+ root: string;
110
+ nextAvailableLeafIndex: string | number | bigint;
111
+ };
112
+ publicDataTree: {
113
+ root: string;
114
+ nextAvailableLeafIndex: string | number | bigint;
115
+ };
116
+ }>;
117
+ }, "strip", z.ZodTypeAny, {
118
+ partial: import("../tx/partial_state_reference.js").PartialStateReference;
119
+ l1ToL2MessageTree: import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot;
120
+ }, {
121
+ partial: {
122
+ noteHashTree: {
123
+ root: string;
124
+ nextAvailableLeafIndex: string | number | bigint;
125
+ };
126
+ nullifierTree: {
127
+ root: string;
128
+ nextAvailableLeafIndex: string | number | bigint;
129
+ };
130
+ publicDataTree: {
131
+ root: string;
132
+ nextAvailableLeafIndex: string | number | bigint;
133
+ };
134
+ };
135
+ l1ToL2MessageTree: {
136
+ root: string;
137
+ nextAvailableLeafIndex: string | number | bigint;
138
+ };
139
+ }>, StateReference, {
140
+ partial: {
141
+ noteHashTree: {
142
+ root: string;
143
+ nextAvailableLeafIndex: string | number | bigint;
144
+ };
145
+ nullifierTree: {
146
+ root: string;
147
+ nextAvailableLeafIndex: string | number | bigint;
148
+ };
149
+ publicDataTree: {
150
+ root: string;
151
+ nextAvailableLeafIndex: string | number | bigint;
152
+ };
153
+ };
154
+ l1ToL2MessageTree: {
155
+ root: string;
156
+ nextAvailableLeafIndex: string | number | bigint;
157
+ };
158
+ }>;
26
159
  txHashes: z.ZodArray<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, Buffer, string>, TxHash, string>, "many">;
27
160
  }, "strip", z.ZodTypeAny, {
28
161
  archive: Fr;
29
- header: BlockHeader;
162
+ header: ProposedBlockHeader;
163
+ stateReference: StateReference;
30
164
  txHashes: TxHash[];
31
165
  }, {
32
166
  archive: string;
167
+ stateReference: {
168
+ partial: {
169
+ noteHashTree: {
170
+ root: string;
171
+ nextAvailableLeafIndex: string | number | bigint;
172
+ };
173
+ nullifierTree: {
174
+ root: string;
175
+ nextAvailableLeafIndex: string | number | bigint;
176
+ };
177
+ publicDataTree: {
178
+ root: string;
179
+ nextAvailableLeafIndex: string | number | bigint;
180
+ };
181
+ };
182
+ l1ToL2MessageTree: {
183
+ root: string;
184
+ nextAvailableLeafIndex: string | number | bigint;
185
+ };
186
+ };
33
187
  txHashes: string[];
34
188
  header?: any;
35
189
  }>, ConsensusPayload, {
36
190
  archive: string;
191
+ stateReference: {
192
+ partial: {
193
+ noteHashTree: {
194
+ root: string;
195
+ nextAvailableLeafIndex: string | number | bigint;
196
+ };
197
+ nullifierTree: {
198
+ root: string;
199
+ nextAvailableLeafIndex: string | number | bigint;
200
+ };
201
+ publicDataTree: {
202
+ root: string;
203
+ nextAvailableLeafIndex: string | number | bigint;
204
+ };
205
+ };
206
+ l1ToL2MessageTree: {
207
+ root: string;
208
+ nextAvailableLeafIndex: string | number | bigint;
209
+ };
210
+ };
37
211
  txHashes: string[];
38
212
  header?: any;
39
213
  }>;
40
- static getFields(fields: FieldsOf<ConsensusPayload>): readonly [BlockHeader, Fr, TxHash[]];
214
+ static getFields(fields: FieldsOf<ConsensusPayload>): readonly [ProposedBlockHeader, Fr, StateReference, TxHash[]];
41
215
  getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer;
42
216
  toBuffer(): Buffer;
43
217
  static fromBuffer(buf: Buffer | BufferReader): ConsensusPayload;
@@ -1 +1 @@
1
- {"version":3,"file":"consensus_payload.d.ts","sourceRoot":"","sources":["../../src/p2p/consensus_payload.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAE/E,qBAAa,gBAAiB,YAAW,QAAQ;IAI7C,oDAAoD;aACpC,MAAM,EAAE,WAAW;aAEnB,OAAO,EAAE,EAAE;IAC3B,gDAAgD;aAChC,QAAQ,EAAE,MAAM,EAAE;IARpC,OAAO,CAAC,IAAI,CAAqB;;IAG/B,oDAAoD;IACpC,MAAM,EAAE,WAAW,EAEnB,OAAO,EAAE,EAAE;IAC3B,gDAAgD;IAChC,QAAQ,EAAE,MAAM,EAAE;IAGpC,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;OAQhB;IAED,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAInD,gBAAgB,CAAC,eAAe,EAAE,wBAAwB,GAAG,MAAM;IAWnE,QAAQ,IAAI,MAAM;IAMlB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB;IAS/D,MAAM,CAAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAShB;IAED,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAInD,gBAAgB,CAAC,eAAe,EAAE,wBAAwB,GAAG,MAAM;IAcnE,QAAQ,IAAI,MAAM;IAYlB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB;IAU/D,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,gBAAgB;IAIvE,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB;IASlD,MAAM,CAAC,KAAK,IAAI,gBAAgB;IAIhC;;;OAGG;IACH,OAAO,IAAI,MAAM;CAQlB"}
@@ -2,46 +2,52 @@ import { Fr } from '@aztec/foundation/fields';
2
2
  import { schemas } from '@aztec/foundation/schemas';
3
3
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
4
  import { hexToBuffer } from '@aztec/foundation/string';
5
- import { encodeAbiParameters, parseAbiParameters } from 'viem';
5
+ import { encodeAbiParameters, parseAbiParameters, toHex } from 'viem';
6
6
  import { z } from 'zod';
7
- import { BlockHeader } from '../tx/block_header.js';
8
- import { TxHash } from '../tx/tx_hash.js';
7
+ import { ProposedBlockHeader, StateReference, TxHash } from '../tx/index.js';
9
8
  export class ConsensusPayload {
10
9
  header;
11
10
  archive;
11
+ stateReference;
12
12
  txHashes;
13
13
  size;
14
- constructor(/** The block header the attestation is made over */ header, // TODO(https://github.com/AztecProtocol/aztec-packages/pull/7727#discussion_r1713670830): temporary
15
- archive, /** The sequence of transactions in the block */ txHashes){
14
+ constructor(/** The proposed block header the attestation is made over */ header, /** The archive root after the block is added */ archive, /** The state reference after the block is added */ stateReference, /** The sequence of transactions in the block */ txHashes){
16
15
  this.header = header;
17
16
  this.archive = archive;
17
+ this.stateReference = stateReference;
18
18
  this.txHashes = txHashes;
19
19
  }
20
20
  static get schema() {
21
21
  return z.object({
22
- header: BlockHeader.schema,
22
+ header: ProposedBlockHeader.schema,
23
23
  archive: schemas.Fr,
24
+ stateReference: StateReference.schema,
24
25
  txHashes: z.array(TxHash.schema)
25
- }).transform((obj)=>new ConsensusPayload(obj.header, obj.archive, obj.txHashes));
26
+ }).transform((obj)=>new ConsensusPayload(obj.header, obj.archive, obj.stateReference, obj.txHashes));
26
27
  }
27
28
  static getFields(fields) {
28
29
  return [
29
30
  fields.header,
30
31
  fields.archive,
32
+ fields.stateReference,
31
33
  fields.txHashes
32
34
  ];
33
35
  }
34
36
  getPayloadToSign(domainSeparator) {
35
- const abi = parseAbiParameters('uint8, (bytes32, (uint256), bytes, bytes32[])');
37
+ const abi = parseAbiParameters('uint8, (bytes32, bytes, (uint256), bytes32, bytes32[])');
38
+ const archiveRoot = this.archive.toString();
39
+ const stateReference = toHex(this.stateReference.toBuffer());
40
+ const headerHash = this.header.hash().toString();
36
41
  const txArray = this.txHashes.map((tx)=>tx.toString());
37
42
  const encodedData = encodeAbiParameters(abi, [
38
43
  domainSeparator,
39
44
  [
40
- this.archive.toString(),
45
+ archiveRoot,
46
+ stateReference,
41
47
  [
42
48
  0n
43
49
  ],
44
- this.header.toString(),
50
+ headerHash,
45
51
  txArray
46
52
  ]
47
53
  ]);
@@ -51,6 +57,7 @@ export class ConsensusPayload {
51
57
  const buffer = serializeToBuffer([
52
58
  this.header,
53
59
  this.archive,
60
+ this.stateReference,
54
61
  this.txHashes.length,
55
62
  this.txHashes
56
63
  ]);
@@ -59,16 +66,16 @@ export class ConsensusPayload {
59
66
  }
60
67
  static fromBuffer(buf) {
61
68
  const reader = BufferReader.asReader(buf);
62
- return new ConsensusPayload(reader.readObject(BlockHeader), reader.readObject(Fr), reader.readArray(reader.readNumber(), TxHash));
69
+ return new ConsensusPayload(reader.readObject(ProposedBlockHeader), reader.readObject(Fr), reader.readObject(StateReference), reader.readArray(reader.readNumber(), TxHash));
63
70
  }
64
71
  static fromFields(fields) {
65
- return new ConsensusPayload(fields.header, fields.archive, fields.txHashes);
72
+ return new ConsensusPayload(fields.header, fields.archive, fields.stateReference, fields.txHashes);
66
73
  }
67
74
  static fromBlock(block) {
68
- return new ConsensusPayload(block.header, block.archive.root, block.body.txEffects.map((tx)=>tx.txHash));
75
+ return new ConsensusPayload(block.header.toPropose(), block.archive.root, block.header.state, block.body.txEffects.map((tx)=>tx.txHash));
69
76
  }
70
77
  static empty() {
71
- return new ConsensusPayload(BlockHeader.empty(), Fr.ZERO, []);
78
+ return new ConsensusPayload(ProposedBlockHeader.empty(), Fr.ZERO, StateReference.empty(), []);
72
79
  }
73
80
  /**
74
81
  * Get the size of the consensus payload in bytes.
@@ -33,6 +33,10 @@ export declare class BlockRootOrBlockMergePublicInputs {
33
33
  * Note: Truncated to 31 bytes to fit in Fr.
34
34
  */
35
35
  outHash: Fr;
36
+ /**
37
+ * The hashes of the proposed block headers of the constituent blocks.
38
+ */
39
+ proposedBlockHeaderHashes: Tuple<Fr, typeof AZTEC_MAX_EPOCH_DURATION>;
36
40
  /**
37
41
  * The summed `transaction_fee`s and recipients of the constituent blocks.
38
42
  */
@@ -75,6 +79,10 @@ export declare class BlockRootOrBlockMergePublicInputs {
75
79
  * Note: Truncated to 31 bytes to fit in Fr.
76
80
  */
77
81
  outHash: Fr,
82
+ /**
83
+ * The hashes of the proposed block headers of the constituent blocks.
84
+ */
85
+ proposedBlockHeaderHashes: Tuple<Fr, typeof AZTEC_MAX_EPOCH_DURATION>,
78
86
  /**
79
87
  * The summed `transaction_fee`s and recipients of the constituent blocks.
80
88
  */