@aztec/stdlib 2.1.0-rc.2 → 2.1.0-rc.21

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 (62) hide show
  1. package/dest/block/attestation_info.d.ts +30 -0
  2. package/dest/block/attestation_info.d.ts.map +1 -0
  3. package/dest/block/attestation_info.js +39 -0
  4. package/dest/block/index.d.ts +1 -0
  5. package/dest/block/index.d.ts.map +1 -1
  6. package/dest/block/index.js +1 -0
  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/block/published_l2_block.d.ts +0 -2
  10. package/dest/block/published_l2_block.d.ts.map +1 -1
  11. package/dest/block/published_l2_block.js +0 -6
  12. package/dest/interfaces/archiver.d.ts.map +1 -1
  13. package/dest/interfaces/archiver.js +7 -0
  14. package/dest/interfaces/aztec-node-admin.d.ts +38 -34
  15. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  16. package/dest/interfaces/aztec-node-admin.js +2 -2
  17. package/dest/interfaces/aztec-node.d.ts +24 -0
  18. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  19. package/dest/interfaces/aztec-node.js +4 -0
  20. package/dest/interfaces/configs.d.ts +5 -0
  21. package/dest/interfaces/configs.d.ts.map +1 -1
  22. package/dest/interfaces/configs.js +2 -1
  23. package/dest/interfaces/p2p.d.ts +2 -0
  24. package/dest/interfaces/p2p.d.ts.map +1 -1
  25. package/dest/interfaces/p2p.js +2 -1
  26. package/dest/interfaces/tx_provider.d.ts +1 -1
  27. package/dest/interfaces/tx_provider.d.ts.map +1 -1
  28. package/dest/interfaces/validator.d.ts +93 -1
  29. package/dest/interfaces/validator.d.ts.map +1 -1
  30. package/dest/interfaces/validator.js +6 -0
  31. package/dest/p2p/block_attestation.d.ts +44 -9
  32. package/dest/p2p/block_attestation.d.ts.map +1 -1
  33. package/dest/p2p/block_attestation.js +35 -16
  34. package/dest/p2p/block_proposal.d.ts +4 -8
  35. package/dest/p2p/block_proposal.d.ts.map +1 -1
  36. package/dest/p2p/block_proposal.js +10 -13
  37. package/dest/p2p/gossipable.d.ts +2 -4
  38. package/dest/p2p/gossipable.d.ts.map +1 -1
  39. package/dest/p2p/gossipable.js +5 -14
  40. package/dest/tests/mocks.d.ts +3 -1
  41. package/dest/tests/mocks.d.ts.map +1 -1
  42. package/dest/tests/mocks.js +33 -11
  43. package/dest/zkpassport/index.d.ts +15 -9
  44. package/dest/zkpassport/index.d.ts.map +1 -1
  45. package/dest/zkpassport/index.js +17 -11
  46. package/package.json +9 -9
  47. package/src/block/attestation_info.ts +62 -0
  48. package/src/block/index.ts +1 -0
  49. package/src/block/l2_block_source.ts +32 -0
  50. package/src/block/published_l2_block.ts +0 -11
  51. package/src/interfaces/archiver.ts +8 -0
  52. package/src/interfaces/aztec-node-admin.ts +2 -2
  53. package/src/interfaces/aztec-node.ts +36 -0
  54. package/src/interfaces/configs.ts +3 -0
  55. package/src/interfaces/p2p.ts +4 -0
  56. package/src/interfaces/tx_provider.ts +1 -0
  57. package/src/interfaces/validator.ts +14 -1
  58. package/src/p2p/block_attestation.ts +43 -16
  59. package/src/p2p/block_proposal.ts +9 -16
  60. package/src/p2p/gossipable.ts +6 -16
  61. package/src/tests/mocks.ts +53 -17
  62. package/src/zkpassport/index.ts +40 -28
@@ -2,6 +2,7 @@ import type { SecretValue } from '@aztec/foundation/config';
2
2
  import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import type { Signature } from '@aztec/foundation/eth-signature';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
+ import { type ZodFor } from '@aztec/foundation/schemas';
5
6
  import type { SequencerConfig, SlasherConfig } from '@aztec/stdlib/interfaces/server';
6
7
  import type { BlockAttestation, BlockProposal, BlockProposalOptions } from '@aztec/stdlib/p2p';
7
8
  import type { ProposedBlockHeader, StateReference, Tx } from '@aztec/stdlib/tx';
@@ -29,7 +30,13 @@ export interface ValidatorClientConfig {
29
30
  /** Whether to always reexecute block proposals, even for non-validator nodes or when out of the currnet committee */
30
31
  alwaysReexecuteBlockProposals?: boolean;
31
32
  }
32
- export type ValidatorClientFullConfig = ValidatorClientConfig & Pick<SequencerConfig, 'txPublicSetupAllowList'> & Pick<SlasherConfig, 'slashBroadcastedInvalidBlockPenalty'>;
33
+ export type ValidatorClientFullConfig = ValidatorClientConfig & Pick<SequencerConfig, 'txPublicSetupAllowList'> & Pick<SlasherConfig, 'slashBroadcastedInvalidBlockPenalty'> & {
34
+ /**
35
+ * Whether transactions are disabled for this node
36
+ * @remarks This should match the property in P2PConfig. It's not picked from there to avoid circular dependencies.
37
+ */
38
+ disableTransactions?: boolean;
39
+ };
33
40
  export declare const ValidatorClientConfigSchema: z.ZodObject<{
34
41
  validatorAddresses: z.ZodOptional<z.ZodArray<z.ZodType<EthAddress, any, string>, "many">>;
35
42
  disableValidator: z.ZodBoolean;
@@ -55,6 +62,91 @@ export declare const ValidatorClientConfigSchema: z.ZodObject<{
55
62
  validatorAddresses?: string[] | undefined;
56
63
  alwaysReexecuteBlockProposals?: boolean | undefined;
57
64
  }>;
65
+ export declare const ValidatorClientFullConfigSchema: z.ZodObject<{
66
+ validatorAddresses: z.ZodOptional<z.ZodArray<z.ZodType<EthAddress, any, string>, "many">>;
67
+ disableValidator: z.ZodBoolean;
68
+ disabledValidators: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
69
+ attestationPollingIntervalMs: z.ZodNumber;
70
+ validatorReexecute: z.ZodBoolean;
71
+ validatorReexecuteDeadlineMs: z.ZodNumber;
72
+ alwaysReexecuteBlockProposals: z.ZodOptional<z.ZodBoolean>;
73
+ } & {
74
+ txPublicSetupAllowList: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
75
+ address: ZodFor<import("../aztec-address/index.js").AztecAddress>;
76
+ selector: ZodFor<import("../abi/function_selector.js").FunctionSelector>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ selector: import("../abi/function_selector.js").FunctionSelector;
79
+ address: import("../aztec-address/index.js").AztecAddress;
80
+ }, {
81
+ selector?: any;
82
+ address?: any;
83
+ }>, z.ZodObject<{
84
+ address: ZodFor<import("../aztec-address/index.js").AztecAddress>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ address: import("../aztec-address/index.js").AztecAddress;
87
+ }, {
88
+ address?: any;
89
+ }>, z.ZodObject<{
90
+ classId: ZodFor<Fr>;
91
+ selector: ZodFor<import("../abi/function_selector.js").FunctionSelector>;
92
+ }, "strip", z.ZodTypeAny, {
93
+ selector: import("../abi/function_selector.js").FunctionSelector;
94
+ classId: Fr;
95
+ }, {
96
+ selector?: any;
97
+ classId?: any;
98
+ }>, z.ZodObject<{
99
+ classId: ZodFor<Fr>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ classId: Fr;
102
+ }, {
103
+ classId?: any;
104
+ }>]>, "many">>;
105
+ slashBroadcastedInvalidBlockPenalty: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
106
+ disableTransactions: z.ZodOptional<z.ZodBoolean>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ slashBroadcastedInvalidBlockPenalty: bigint;
109
+ disableValidator: boolean;
110
+ disabledValidators: EthAddress[];
111
+ attestationPollingIntervalMs: number;
112
+ validatorReexecute: boolean;
113
+ validatorReexecuteDeadlineMs: number;
114
+ txPublicSetupAllowList?: ({
115
+ selector: import("../abi/function_selector.js").FunctionSelector;
116
+ address: import("../aztec-address/index.js").AztecAddress;
117
+ } | {
118
+ address: import("../aztec-address/index.js").AztecAddress;
119
+ } | {
120
+ selector: import("../abi/function_selector.js").FunctionSelector;
121
+ classId: Fr;
122
+ } | {
123
+ classId: Fr;
124
+ })[] | undefined;
125
+ validatorAddresses?: EthAddress[] | undefined;
126
+ alwaysReexecuteBlockProposals?: boolean | undefined;
127
+ disableTransactions?: boolean | undefined;
128
+ }, {
129
+ slashBroadcastedInvalidBlockPenalty: string | number | bigint;
130
+ disableValidator: boolean;
131
+ disabledValidators: string[];
132
+ attestationPollingIntervalMs: number;
133
+ validatorReexecute: boolean;
134
+ validatorReexecuteDeadlineMs: number;
135
+ txPublicSetupAllowList?: ({
136
+ selector?: any;
137
+ address?: any;
138
+ } | {
139
+ address?: any;
140
+ } | {
141
+ selector?: any;
142
+ classId?: any;
143
+ } | {
144
+ classId?: any;
145
+ })[] | undefined;
146
+ validatorAddresses?: string[] | undefined;
147
+ alwaysReexecuteBlockProposals?: boolean | undefined;
148
+ disableTransactions?: boolean | undefined;
149
+ }>;
58
150
  export interface Validator {
59
151
  start(): Promise<void>;
60
152
  updateConfig(config: Partial<ValidatorClientFullConfig>): void;
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../src/interfaces/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,mBAAmB,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,6EAA6E;IAC7E,oBAAoB,CAAC,EAAE,WAAW,CAAC,KAAK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OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;IAC5G,0BAA0B,CACxB,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,GACnB,OAAO,CAAC,SAAS,CAAC,CAAC;CACvB"}
@@ -1,5 +1,6 @@
1
1
  import { schemas } from '@aztec/foundation/schemas';
2
2
  import { z } from 'zod';
3
+ import { AllowedElementSchema } from './allowed_element.js';
3
4
  export const ValidatorClientConfigSchema = z.object({
4
5
  validatorAddresses: z.array(schemas.EthAddress).optional(),
5
6
  disableValidator: z.boolean(),
@@ -9,3 +10,8 @@ export const ValidatorClientConfigSchema = z.object({
9
10
  validatorReexecuteDeadlineMs: z.number().min(0),
10
11
  alwaysReexecuteBlockProposals: z.boolean().optional()
11
12
  });
13
+ export const ValidatorClientFullConfigSchema = ValidatorClientConfigSchema.extend({
14
+ txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
15
+ slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
16
+ disableTransactions: z.boolean().optional()
17
+ });
@@ -3,8 +3,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { Signature } from '@aztec/foundation/eth-signature';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
5
  import { BufferReader } from '@aztec/foundation/serialize';
6
- import { type ZodFor } from '../schemas/index.js';
7
- import type { UInt32 } from '../types/index.js';
6
+ import type { ZodFor } from '../schemas/index.js';
8
7
  import { ConsensusPayload } from './consensus_payload.js';
9
8
  import { Gossipable } from './gossipable.js';
10
9
  import { TopicType } from './topic_type.js';
@@ -18,35 +17,71 @@ export declare class BlockAttestationHash extends Buffer32 {
18
17
  * will produce a block attestation over the header of the block
19
18
  */
20
19
  export declare class BlockAttestation extends Gossipable {
21
- /** The block number of the attestation. */
22
- readonly blockNumber: UInt32;
23
20
  /** The payload of the message, and what the signature is over */
24
21
  readonly payload: ConsensusPayload;
25
22
  /** The signature of the block attester */
26
23
  readonly signature: Signature;
24
+ /** The signature from the block proposer */
25
+ readonly proposerSignature: Signature;
27
26
  static p2pTopic: TopicType;
28
27
  private sender;
28
+ private proposer;
29
29
  constructor(
30
- /** The block number of the attestation. */
31
- blockNumber: UInt32,
32
30
  /** The payload of the message, and what the signature is over */
33
31
  payload: ConsensusPayload,
34
32
  /** The signature of the block attester */
35
- signature: Signature);
33
+ signature: Signature,
34
+ /** The signature from the block proposer */
35
+ proposerSignature: Signature);
36
36
  static get schema(): ZodFor<BlockAttestation>;
37
37
  generateP2PMessageIdentifier(): Promise<Buffer32>;
38
38
  get archive(): Fr;
39
39
  get slotNumber(): Fr;
40
40
  /**
41
41
  * Lazily evaluate and cache the signer of the attestation
42
- * @returns The signer of the attestation
42
+ * @returns The signer of the attestation, or undefined if signature recovery fails
43
43
  */
44
- getSender(): EthAddress;
44
+ getSender(): EthAddress | undefined;
45
+ /**
46
+ * Lazily evaluate and cache the proposer of the block
47
+ * @returns The proposer of the block
48
+ */
49
+ getProposer(): EthAddress | undefined;
45
50
  getPayload(): Buffer;
46
51
  toBuffer(): Buffer;
47
52
  static fromBuffer(buf: Buffer | BufferReader): BlockAttestation;
48
53
  static empty(): BlockAttestation;
49
54
  static random(): BlockAttestation;
50
55
  getSize(): number;
56
+ toInspect(): {
57
+ payload: {
58
+ header: {
59
+ lastArchive: `0x${string}`;
60
+ contentCommitment: {
61
+ blobsHash: `0x${string}`;
62
+ inHash: `0x${string}`;
63
+ outHash: `0x${string}`;
64
+ };
65
+ slotNumber: bigint;
66
+ timestamp: bigint;
67
+ coinbase: `0x${string}`;
68
+ feeRecipient: `0x${string}`;
69
+ gasFees: {
70
+ feePerDaGas: bigint;
71
+ feePerL2Gas: bigint;
72
+ };
73
+ totalManaUsed: bigint;
74
+ };
75
+ archive: `0x${string}`;
76
+ stateReference: {
77
+ l1ToL2MessageTree: `0x${string}`;
78
+ noteHashTree: `0x${string}`;
79
+ nullifierTree: `0x${string}`;
80
+ publicDataTree: `0x${string}`;
81
+ };
82
+ };
83
+ signature: `0x${string}`;
84
+ proposerSignature: `0x${string}`;
85
+ };
51
86
  }
52
87
  //# sourceMappingURL=block_attestation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block_attestation.d.ts","sourceRoot":"","sources":["../../src/p2p/block_attestation.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,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAI9E,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,qBAAa,oBAAqB,SAAQ,QAAQ;gBACpC,IAAI,EAAE,MAAM;CAGzB;AAED;;;;;GAKG;AACH,qBAAa,gBAAiB,SAAQ,UAAU;IAM5C,2CAA2C;aAC3B,WAAW,EAAE,MAAM;IAEnC,iEAAiE;aACjD,OAAO,EAAE,gBAAgB;IAEzC,0CAA0C;aAC1B,SAAS,EAAE,SAAS;IAZtC,OAAgB,QAAQ,YAA+B;IAEvD,OAAO,CAAC,MAAM,CAAyB;;IAGrC,2CAA2C;IAC3B,WAAW,EAAE,MAAM;IAEnC,iEAAiE;IACjD,OAAO,EAAE,gBAAgB;IAEzC,0CAA0C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1B,SAAS,EAAE,SAAS;IAEpC,4CAA4C;aAC5B,iBAAiB,EAAE,SAAS;IAb9C,OAAgB,QAAQ,YAA+B;IAEvD,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,QAAQ,CAAyB;;IAGvC,iEAAiE;IACjD,OAAO,EAAE,gBAAgB;IAEzC,0CAA0C;IAC1B,SAAS,EAAE,SAAS;IAEpC,4CAA4C;IAC5B,iBAAiB,EAAE,SAAS;IAK9C,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAQ5C;IAEQ,4BAA4B,IAAI,OAAO,CAAC,QAAQ,CAAC;IAI1D,IAAI,OAAO,IAAI,EAAE,CAEhB;IAED,IAAI,UAAU,IAAI,EAAE,CAEnB;IAED;;;OAGG;IACH,SAAS,IAAI,UAAU,GAAG,SAAS;IAWnC;;;OAGG;IACH,WAAW,IAAI,UAAU,GAAG,SAAS;IAWrC,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,MAAM,CAAC,MAAM,IAAI,gBAAgB;IAIjC,OAAO,IAAI,MAAM;IAIjB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOV"}
@@ -1,9 +1,8 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
- import { keccak256, recoverAddress } from '@aztec/foundation/crypto';
2
+ import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
3
3
  import { Signature } from '@aztec/foundation/eth-signature';
4
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
5
  import { z } from 'zod';
6
- import { schemas } from '../schemas/index.js';
7
6
  import { ConsensusPayload } from './consensus_payload.js';
8
7
  import { Gossipable } from './gossipable.js';
9
8
  import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from './signature_utils.js';
@@ -19,20 +18,21 @@ export class BlockAttestationHash extends Buffer32 {
19
18
  * A validator that has attested to seeing the contents of a block
20
19
  * will produce a block attestation over the header of the block
21
20
  */ export class BlockAttestation extends Gossipable {
22
- blockNumber;
23
21
  payload;
24
22
  signature;
23
+ proposerSignature;
25
24
  static p2pTopic = TopicType.block_attestation;
26
25
  sender;
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;
26
+ proposer;
27
+ constructor(/** The payload of the message, and what the signature is over */ payload, /** The signature of the block attester */ signature, /** The signature from the block proposer */ proposerSignature){
28
+ super(), this.payload = payload, this.signature = signature, this.proposerSignature = proposerSignature;
29
29
  }
30
30
  static get schema() {
31
31
  return z.object({
32
- blockNumber: schemas.UInt32,
33
32
  payload: ConsensusPayload.schema,
34
- signature: Signature.schema
35
- }).transform((obj)=>new BlockAttestation(obj.blockNumber, obj.payload, obj.signature));
33
+ signature: Signature.schema,
34
+ proposerSignature: Signature.schema
35
+ }).transform((obj)=>new BlockAttestation(obj.payload, obj.signature, obj.proposerSignature));
36
36
  }
37
37
  generateP2PMessageIdentifier() {
38
38
  return Promise.resolve(new BlockAttestationHash(keccak256(this.signature.toBuffer())));
@@ -45,37 +45,56 @@ export class BlockAttestationHash extends Buffer32 {
45
45
  }
46
46
  /**
47
47
  * Lazily evaluate and cache the signer of the attestation
48
- * @returns The signer of the attestation
48
+ * @returns The signer of the attestation, or undefined if signature recovery fails
49
49
  */ getSender() {
50
50
  if (!this.sender) {
51
51
  // Recover the sender from the attestation
52
52
  const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockAttestation);
53
53
  // Cache the sender for later use
54
- this.sender = recoverAddress(hashed, this.signature);
54
+ this.sender = tryRecoverAddress(hashed, this.signature);
55
55
  }
56
56
  return this.sender;
57
57
  }
58
+ /**
59
+ * Lazily evaluate and cache the proposer of the block
60
+ * @returns The proposer of the block
61
+ */ getProposer() {
62
+ if (!this.proposer) {
63
+ // Recover the proposer from the proposal signature
64
+ const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
65
+ // Cache the proposer for later use
66
+ this.proposer = tryRecoverAddress(hashed, this.proposerSignature);
67
+ }
68
+ return this.proposer;
69
+ }
58
70
  getPayload() {
59
71
  return this.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation);
60
72
  }
61
73
  toBuffer() {
62
74
  return serializeToBuffer([
63
- this.blockNumber,
64
75
  this.payload,
65
- this.signature
76
+ this.signature,
77
+ this.proposerSignature
66
78
  ]);
67
79
  }
68
80
  static fromBuffer(buf) {
69
81
  const reader = BufferReader.asReader(buf);
70
- return new BlockAttestation(reader.readNumber(), reader.readObject(ConsensusPayload), reader.readObject(Signature));
82
+ return new BlockAttestation(reader.readObject(ConsensusPayload), reader.readObject(Signature), reader.readObject(Signature));
71
83
  }
72
84
  static empty() {
73
- return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty());
85
+ return new BlockAttestation(ConsensusPayload.empty(), Signature.empty(), Signature.empty());
74
86
  }
75
87
  static random() {
76
- return new BlockAttestation(Math.floor(Math.random() * 1000) + 1, ConsensusPayload.random(), Signature.random());
88
+ return new BlockAttestation(ConsensusPayload.random(), Signature.random(), Signature.random());
77
89
  }
78
90
  getSize() {
79
- return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize();
91
+ return this.payload.getSize() + this.signature.getSize() + this.proposerSignature.getSize();
92
+ }
93
+ toInspect() {
94
+ return {
95
+ payload: this.payload.toInspect(),
96
+ signature: this.signature.toString(),
97
+ proposerSignature: this.proposerSignature.toString()
98
+ };
80
99
  }
81
100
  }
@@ -6,7 +6,6 @@ import { BufferReader } from '@aztec/foundation/serialize';
6
6
  import type { L2BlockInfo } from '../block/l2_block_info.js';
7
7
  import { TxHash } from '../tx/index.js';
8
8
  import { Tx } from '../tx/tx.js';
9
- import type { UInt32 } from '../types/index.js';
10
9
  import { ConsensusPayload } from './consensus_payload.js';
11
10
  import { Gossipable } from './gossipable.js';
12
11
  import { TopicType } from './topic_type.js';
@@ -23,8 +22,6 @@ export type BlockProposalOptions = {
23
22
  * be included in the head of the chain
24
23
  */
25
24
  export declare class BlockProposal extends Gossipable {
26
- /** The number of the block */
27
- readonly blockNumber: UInt32;
28
25
  /** The payload of the message, and what the signature is over */
29
26
  readonly payload: ConsensusPayload;
30
27
  /** The signer of the BlockProposal over the header of the new block*/
@@ -36,8 +33,6 @@ export declare class BlockProposal extends Gossipable {
36
33
  static p2pTopic: TopicType;
37
34
  private sender;
38
35
  constructor(
39
- /** The number of the block */
40
- blockNumber: UInt32,
41
36
  /** The payload of the message, and what the signature is over */
42
37
  payload: ConsensusPayload,
43
38
  /** The signer of the BlockProposal over the header of the new block*/
@@ -49,12 +44,13 @@ export declare class BlockProposal extends Gossipable {
49
44
  generateP2PMessageIdentifier(): Promise<Buffer32>;
50
45
  get archive(): Fr;
51
46
  get slotNumber(): Fr;
52
- toBlockInfo(): L2BlockInfo;
53
- static createProposalFromSigner(blockNumber: UInt32, payload: ConsensusPayload, txHashes: TxHash[], txs: Tx[] | undefined, payloadSigner: (payload: Buffer32) => Promise<Signature>): Promise<BlockProposal>;
47
+ toBlockInfo(): Omit<L2BlockInfo, 'blockNumber'>;
48
+ static createProposalFromSigner(payload: ConsensusPayload, txHashes: TxHash[], txs: Tx[] | undefined, payloadSigner: (payload: Buffer32) => Promise<Signature>): Promise<BlockProposal>;
54
49
  /**Get Sender
55
50
  * Lazily evaluate the sender of the proposal; result is cached
51
+ * @returns The sender address, or undefined if signature recovery fails
56
52
  */
57
- getSender(): EthAddress;
53
+ getSender(): EthAddress | undefined;
58
54
  getPayload(): Buffer<ArrayBufferLike>;
59
55
  toBuffer(): Buffer;
60
56
  static fromBuffer(buf: Buffer | BufferReader): BlockProposal;
@@ -1 +1 @@
1
- {"version":3,"file":"block_proposal.d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AAM,GAAG,YAAY,GAAG,aAAa;IAe5D,OAAO,IAAI,MAAM;CASlB"}
@@ -1,5 +1,5 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
- import { keccak256, recoverAddress } from '@aztec/foundation/crypto';
2
+ import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
3
3
  import { Signature } from '@aztec/foundation/eth-signature';
4
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
5
5
  import { TxHash } from '../tx/index.js';
@@ -19,16 +19,15 @@ export class BlockProposalHash extends Buffer32 {
19
19
  * A block proposal is created by the leader of the chain proposing a sequence of transactions to
20
20
  * be included in the head of the chain
21
21
  */ export class BlockProposal extends Gossipable {
22
- blockNumber;
23
22
  payload;
24
23
  signature;
25
24
  txHashes;
26
25
  txs;
27
26
  static p2pTopic = TopicType.block_proposal;
28
27
  sender;
29
- 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, /** The sequence of transactions in the block */ txHashes, // Note(md): this is placed after the txs payload in order to be backwards compatible with previous versions
28
+ 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, /** The sequence of transactions in the block */ txHashes, // Note(md): this is placed after the txs payload in order to be backwards compatible with previous versions
30
29
  /** The transactions in the block */ txs){
31
- super(), this.blockNumber = blockNumber, this.payload = payload, this.signature = signature, this.txHashes = txHashes, this.txs = txs;
30
+ super(), this.payload = payload, this.signature = signature, this.txHashes = txHashes, this.txs = txs;
32
31
  }
33
32
  generateP2PMessageIdentifier() {
34
33
  return Promise.resolve(new BlockProposalHash(keccak256(this.signature.toBuffer())));
@@ -41,7 +40,6 @@ export class BlockProposalHash extends Buffer32 {
41
40
  }
42
41
  toBlockInfo() {
43
42
  return {
44
- blockNumber: this.blockNumber,
45
43
  slotNumber: this.slotNumber.toNumber(),
46
44
  lastArchive: this.payload.header.lastArchiveRoot,
47
45
  timestamp: this.payload.header.timestamp,
@@ -49,19 +47,20 @@ export class BlockProposalHash extends Buffer32 {
49
47
  txCount: this.txHashes.length
50
48
  };
51
49
  }
52
- static async createProposalFromSigner(blockNumber, payload, txHashes, // Note(md): Provided separately to tx hashes such that this function can be optional
50
+ static async createProposalFromSigner(payload, txHashes, // Note(md): Provided separately to tx hashes such that this function can be optional
53
51
  txs, payloadSigner) {
54
52
  const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
55
53
  const sig = await payloadSigner(hashed);
56
- return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
54
+ return new BlockProposal(payload, sig, txHashes, txs);
57
55
  }
58
56
  /**Get Sender
59
57
  * Lazily evaluate the sender of the proposal; result is cached
58
+ * @returns The sender address, or undefined if signature recovery fails
60
59
  */ getSender() {
61
60
  if (!this.sender) {
62
61
  const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
63
62
  // Cache the sender for later use
64
- this.sender = recoverAddress(hashed, this.signature);
63
+ this.sender = tryRecoverAddress(hashed, this.signature);
65
64
  }
66
65
  return this.sender;
67
66
  }
@@ -70,7 +69,6 @@ export class BlockProposalHash extends Buffer32 {
70
69
  }
71
70
  toBuffer() {
72
71
  const buffer = [
73
- this.blockNumber,
74
72
  this.payload,
75
73
  this.signature,
76
74
  this.txHashes.length,
@@ -84,17 +82,16 @@ export class BlockProposalHash extends Buffer32 {
84
82
  }
85
83
  static fromBuffer(buf) {
86
84
  const reader = BufferReader.asReader(buf);
87
- const blockNumber = reader.readNumber();
88
85
  const payload = reader.readObject(ConsensusPayload);
89
86
  const sig = reader.readObject(Signature);
90
87
  const txHashes = reader.readArray(reader.readNumber(), TxHash);
91
88
  if (!reader.isEmpty()) {
92
89
  const txs = reader.readArray(reader.readNumber(), Tx);
93
- return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
90
+ return new BlockProposal(payload, sig, txHashes, txs);
94
91
  }
95
- return new BlockProposal(blockNumber, payload, sig, txHashes);
92
+ return new BlockProposal(payload, sig, txHashes);
96
93
  }
97
94
  getSize() {
98
- return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize() + 4 /* txHashes.length */ + this.txHashes.length * TxHash.SIZE + (this.txs ? 4 /* txs.length */ + this.txs.reduce((acc, tx)=>acc + tx.getSize(), 0) : 0);
95
+ return this.payload.getSize() + this.signature.getSize() + 4 /* txHashes.length */ + this.txHashes.length * TxHash.SIZE + (this.txs ? 4 /* txs.length */ + this.txs.reduce((acc, tx)=>acc + tx.getSize(), 0) : 0);
99
96
  }
100
97
  }
@@ -1,11 +1,9 @@
1
1
  import { Buffer32 } from '@aztec/foundation/buffer';
2
2
  import type { TopicType } from './topic_type.js';
3
3
  export declare class P2PMessage {
4
- readonly publishTime: Date;
5
- readonly id: Buffer32;
6
4
  readonly payload: Buffer;
7
- constructor(publishTime: Date, id: Buffer32, payload: Buffer);
8
- static fromGossipable(message: Gossipable): Promise<P2PMessage>;
5
+ constructor(payload: Buffer);
6
+ static fromGossipable(message: Gossipable): P2PMessage;
9
7
  static fromMessageData(messageData: Buffer): P2PMessage;
10
8
  toMessageData(): Buffer;
11
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gossipable.d.ts","sourceRoot":"","sources":["../../src/p2p/gossipable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAAa,UAAU;aAEH,WAAW,EAAE,IAAI;aACjB,EAAE,EAAE,QAAQ;aACZ,OAAO,EAAE,MAAM;gBAFf,WAAW,EAAE,IAAI,EACjB,EAAE,EAAE,QAAQ,EACZ,OAAO,EAAE,MAAM;WAGpB,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAIrE,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAQvD,aAAa,IAAI,M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ec/foundation/buffer';
2
- import { BufferReader, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize';
1
+ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
2
  export class P2PMessage {
4
- publishTime;
5
- id;
6
3
  payload;
7
- constructor(publishTime, id, payload){
8
- this.publishTime = publishTime;
9
- this.id = id;
4
+ constructor(payload){
10
5
  this.payload = payload;
11
6
  }
12
- static async fromGossipable(message) {
13
- return new P2PMessage(new Date(), await message.p2pMessageIdentifier(), message.toBuffer());
7
+ static fromGossipable(message) {
8
+ return new P2PMessage(message.toBuffer());
14
9
  }
15
10
  static fromMessageData(messageData) {
16
11
  const reader = new BufferReader(messageData);
17
- const publishTime = reader.readUInt64();
18
- const id = Buffer32.fromBuffer(reader);
19
12
  const payload = reader.readBuffer();
20
- return new P2PMessage(new Date(Number(publishTime)), id, payload);
13
+ return new P2PMessage(payload);
21
14
  }
22
15
  toMessageData() {
23
16
  return serializeToBuffer([
24
- bigintToUInt64BE(BigInt(this.publishTime.getTime())),
25
- this.id,
26
17
  serializeToBuffer(this.payload.length, this.payload)
27
18
  ]);
28
19
  }
@@ -43,6 +43,8 @@ export declare const randomDeployedContract: () => Promise<{
43
43
  }>;
44
44
  export interface MakeConsensusPayloadOptions {
45
45
  signer?: Secp256k1Signer;
46
+ attesterSigner?: Secp256k1Signer;
47
+ proposerSigner?: Secp256k1Signer;
46
48
  header?: BlockHeader;
47
49
  archive?: Fr;
48
50
  stateReference?: StateReference;
@@ -52,7 +54,7 @@ export interface MakeConsensusPayloadOptions {
52
54
  export declare const makeAndSignCommitteeAttestationsAndSigners: (attestationsAndSigners: CommitteeAttestationsAndSigners, signer?: Secp256k1Signer) => import("../block/index.js").Signature;
53
55
  export declare const makeBlockProposal: (options?: MakeConsensusPayloadOptions) => BlockProposal;
54
56
  export declare const makeBlockAttestation: (options?: MakeConsensusPayloadOptions) => BlockAttestation;
55
- export declare const makeBlockAttestationFromBlock: (block: L2Block, signer?: Secp256k1Signer) => BlockAttestation;
57
+ export declare const makeBlockAttestationFromBlock: (block: L2Block, attesterSigner?: Secp256k1Signer, proposerSigner?: Secp256k1Signer) => BlockAttestation;
56
58
  export declare function randomPublishedL2Block(l2BlockNumber: number, opts?: {
57
59
  signers?: Secp256k1Signer[];
58
60
  }): Promise<PublishedL2Block>;
@@ -1 +1 @@
1
- {"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAe,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIlE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS7C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EACL,WAAW,EAIX,cAAc,EACd,EAAE,EACH,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAiC,MAAM,uBAAuB,CAAC;AAE1F,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,eAAO,MAAM,YAAY,QAAO,MAAyB,CAAC;AAE1D,eAAO,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,MAAM,iCAAiC,GAC5C,OAAM;IAAE,eAAe,CAAC,EAAE,EAAE,CAAA;CAAO,EACnC,UAAU,YAAY,KACrB,OAAO,CAAC,2BAA2B,CAUrC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;EAIlC,CAAC;AAEF,MAAM,WAAW,2BAA2B;IAC1C,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,EAAE,CAAC;IACb,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC;CACZ;AAqBD,eAAO,MAAM,0CAA0C,GACrD,wBAAwB,+BAA+B,EACvD,SAAQ,eAA0C,0CAOnD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,2BAA2B,KAAG,aAIzE,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,UAAU,2BAA2B,KAAG,gBAyB5E,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,OAAO,OAAO,EACd,iBAAiB,eAAe,EAChC,iBAAiB,eAAe,KAC/B,gBAsBF,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAA;CAAO,GACzC,OAAO,CAAC,gBAAgB,CAAC,CAc3B"}
@@ -153,7 +153,7 @@ export const makeAndSignCommitteeAttestationsAndSigners = (attestationsAndSigner
153
153
  return signer.sign(hash);
154
154
  };
155
155
  export const makeBlockProposal = (options)=>{
156
- const { blockNumber, payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options);
156
+ const { payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockProposal, options);
157
157
  const txHashes = options?.txHashes ?? [
158
158
  0,
159
159
  1,
@@ -162,21 +162,43 @@ export const makeBlockProposal = (options)=>{
162
162
  4,
163
163
  5
164
164
  ].map(()=>TxHash.random());
165
- return new BlockProposal(blockNumber, payload, signature, txHashes, options?.txs ?? []);
165
+ return new BlockProposal(payload, signature, txHashes, options?.txs ?? []);
166
166
  };
167
167
  // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
168
168
  export const makeBlockAttestation = (options)=>{
169
- const { blockNumber, payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockAttestation, options);
170
- return new BlockAttestation(blockNumber, payload, signature);
169
+ const header = options?.header ?? makeHeader(1);
170
+ const { signer, attesterSigner = signer ?? Secp256k1Signer.random(), proposerSigner = signer ?? Secp256k1Signer.random(), archive = Fr.random(), stateReference = header.state } = options ?? {};
171
+ const payload = ConsensusPayload.fromFields({
172
+ header: header.toPropose(),
173
+ archive,
174
+ stateReference
175
+ });
176
+ // Sign as attester
177
+ const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
178
+ const attestationSignature = attesterSigner.sign(attestationHash);
179
+ // Sign as proposer
180
+ const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
181
+ const proposerSignature = proposerSigner.sign(proposalHash);
182
+ return new BlockAttestation(payload, attestationSignature, proposerSignature);
171
183
  };
172
- export const makeBlockAttestationFromBlock = (block, signer)=>{
173
- return makeBlockAttestation({
174
- signer,
175
- header: block.header,
176
- archive: block.archive.root,
177
- stateReference: block.header.state,
178
- txHashes: block.body.txEffects.map((tx)=>tx.txHash)
184
+ export const makeBlockAttestationFromBlock = (block, attesterSigner, proposerSigner)=>{
185
+ const header = block.header;
186
+ const archive = block.archive.root;
187
+ const stateReference = block.header.state;
188
+ const payload = ConsensusPayload.fromFields({
189
+ header: header.toPropose(),
190
+ archive,
191
+ stateReference
179
192
  });
193
+ // Sign as attester
194
+ const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
195
+ const attestationSigner = attesterSigner ?? Secp256k1Signer.random();
196
+ const attestationSignature = attestationSigner.sign(attestationHash);
197
+ // Sign as proposer
198
+ const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
199
+ const proposalSignerToUse = proposerSigner ?? Secp256k1Signer.random();
200
+ const proposerSignature = proposalSignerToUse.sign(proposalHash);
201
+ return new BlockAttestation(payload, attestationSignature, proposerSignature);
180
202
  };
181
203
  export async function randomPublishedL2Block(l2BlockNumber, opts = {}) {
182
204
  const block = await L2Block.random(l2BlockNumber);