@aztec/stdlib 2.1.0-rc.2 → 2.1.0-rc.20
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.
- package/dest/block/attestation_info.d.ts +30 -0
- package/dest/block/attestation_info.d.ts.map +1 -0
- package/dest/block/attestation_info.js +39 -0
- package/dest/block/index.d.ts +1 -0
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -0
- package/dest/block/published_l2_block.d.ts +0 -2
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +0 -6
- package/dest/interfaces/aztec-node-admin.d.ts +3 -0
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +5 -0
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/p2p.d.ts +2 -0
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +2 -1
- package/dest/p2p/block_attestation.d.ts +47 -1
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +43 -9
- package/dest/p2p/gossipable.d.ts +2 -4
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/p2p/gossipable.js +5 -14
- package/dest/tests/mocks.d.ts +3 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +31 -9
- package/package.json +9 -9
- package/src/block/attestation_info.ts +62 -0
- package/src/block/index.ts +1 -0
- package/src/block/published_l2_block.ts +0 -11
- package/src/interfaces/configs.ts +3 -0
- package/src/interfaces/p2p.ts +4 -0
- package/src/p2p/block_attestation.ts +57 -6
- package/src/p2p/gossipable.ts +6 -16
- package/src/tests/mocks.ts +51 -12
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { L2Block } from './l2_block.js';
|
|
3
|
+
import type { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
4
|
+
/**
|
|
5
|
+
* Status indicating how the attestation address was determined
|
|
6
|
+
*/
|
|
7
|
+
export type AttestationStatus = 'recovered-from-signature' | 'provided-as-address' | 'invalid-signature' | 'empty';
|
|
8
|
+
/**
|
|
9
|
+
* Information about an attestation extracted from a published block
|
|
10
|
+
*/
|
|
11
|
+
export type AttestationInfo = {
|
|
12
|
+
/** The validator's address, undefined if signature recovery failed or empty */
|
|
13
|
+
address?: undefined;
|
|
14
|
+
/** How the attestation address was determined */
|
|
15
|
+
status: Extract<AttestationStatus, 'invalid-signature' | 'empty'>;
|
|
16
|
+
} | {
|
|
17
|
+
/** The validator's address */
|
|
18
|
+
address: EthAddress;
|
|
19
|
+
/** How the attestation address was determined */
|
|
20
|
+
status: Extract<AttestationStatus, 'provided-as-address' | 'recovered-from-signature'>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Extracts attestation information from a published L2 block.
|
|
24
|
+
* Returns info for each attestation, preserving array indices.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAttestationInfoFromPublishedL2Block(block: {
|
|
27
|
+
attestations: CommitteeAttestation[];
|
|
28
|
+
block: L2Block;
|
|
29
|
+
}): AttestationInfo[];
|
|
30
|
+
//# sourceMappingURL=attestation_info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation_info.d.ts","sourceRoot":"","sources":["../../src/block/attestation_info.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,0BAA0B,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,OAAO,CAAC;AAEnH;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB;IACE,+EAA+E;IAC/E,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,iDAAiD;IACjD,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,mBAAmB,GAAG,OAAO,CAAC,CAAC;CACnE,GACD;IACE,8BAA8B;IAC9B,OAAO,EAAE,UAAU,CAAC;IACpB,iDAAiD;IACjD,MAAM,EAAE,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,GAAG,0BAA0B,CAAC,CAAC;CACxF,CAAC;AAEN;;;GAGG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,EAAE;IAC5D,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,eAAe,EAAE,CAwBpB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { recoverAddress } from '@aztec/foundation/crypto';
|
|
2
|
+
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
3
|
+
import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '../p2p/signature_utils.js';
|
|
4
|
+
/**
|
|
5
|
+
* Extracts attestation information from a published L2 block.
|
|
6
|
+
* Returns info for each attestation, preserving array indices.
|
|
7
|
+
*/ export function getAttestationInfoFromPublishedL2Block(block) {
|
|
8
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
9
|
+
const hashedPayload = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
10
|
+
return block.attestations.map((attestation)=>{
|
|
11
|
+
// If signature is empty, check if we have an address directly
|
|
12
|
+
if (attestation.signature.isEmpty()) {
|
|
13
|
+
if (attestation.address.isZero()) {
|
|
14
|
+
// No signature and no address - empty
|
|
15
|
+
return {
|
|
16
|
+
status: 'empty'
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
// Address provided without signature
|
|
20
|
+
return {
|
|
21
|
+
address: attestation.address,
|
|
22
|
+
status: 'provided-as-address'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Try to recover address from signature
|
|
26
|
+
try {
|
|
27
|
+
const recoveredAddress = recoverAddress(hashedPayload, attestation.signature);
|
|
28
|
+
return {
|
|
29
|
+
address: recoveredAddress,
|
|
30
|
+
status: 'recovered-from-signature'
|
|
31
|
+
};
|
|
32
|
+
} catch {
|
|
33
|
+
// Signature present but recovery failed
|
|
34
|
+
return {
|
|
35
|
+
status: 'invalid-signature'
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
package/dest/block/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/block/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC"}
|
package/dest/block/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
2
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
5
4
|
import { L2Block } from './l2_block.js';
|
|
6
5
|
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
7
6
|
export declare class L1PublishedData {
|
|
@@ -141,5 +140,4 @@ export declare class PublishedL2Block {
|
|
|
141
140
|
static fromFields(fields: FieldsOf<PublishedL2Block>): PublishedL2Block;
|
|
142
141
|
toBuffer(): Buffer;
|
|
143
142
|
}
|
|
144
|
-
export declare function getAttestationsFromPublishedL2Block(block: Pick<PublishedL2Block, 'attestations' | 'block'>): BlockAttestation[];
|
|
145
143
|
//# sourceMappingURL=published_l2_block.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"published_l2_block.d.ts","sourceRoot":"","sources":["../../src/block/published_l2_block.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"published_l2_block.d.ts","sourceRoot":"","sources":["../../src/block/published_l2_block.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,qBAAa,eAAe;IAEjB,WAAW,EAAE,MAAM;IACnB,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;gBAFjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM;IAG1B,MAAM,KAAK,MAAM;;;;;;;;;;;;OAMhB;IAED,MAAM,CAAC,MAAM;IAQb,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC;CAGpD;AAED,qBAAa,gBAAgB;IAElB,KAAK,EAAE,OAAO;IACd,EAAE,EAAE,eAAe;IACnB,YAAY,EAAE,oBAAoB,EAAE;gBAFpC,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,eAAe,EACnB,YAAY,EAAE,oBAAoB,EAAE;IAG7C,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAQhB;IAED,MAAM,CAAC,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB;IAU1E,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC;IAI7C,QAAQ,IAAI,MAAM;CAU1B"}
|
|
@@ -4,8 +4,6 @@ import { randomBigInt } from '@aztec/foundation/crypto';
|
|
|
4
4
|
import { schemas } from '@aztec/foundation/schemas';
|
|
5
5
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
8
|
-
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
9
7
|
import { L2Block } from './l2_block.js';
|
|
10
8
|
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
11
9
|
export class L1PublishedData {
|
|
@@ -63,7 +61,3 @@ export class PublishedL2Block {
|
|
|
63
61
|
return serializeToBuffer(this.block, this.l1.blockNumber, this.l1.blockHash, this.l1.timestamp, this.attestations.length, this.attestations);
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
|
-
export function getAttestationsFromPublishedL2Block(block) {
|
|
67
|
-
const payload = ConsensusPayload.fromBlock(block.block);
|
|
68
|
-
return block.attestations.filter((attestation)=>!attestation.signature.isEmpty()).map((attestation)=>new BlockAttestation(block.block.number, payload, attestation.signature));
|
|
69
|
-
}
|
|
@@ -95,6 +95,7 @@ export declare const AztecNodeAdminConfigSchema: z.ZodObject<{
|
|
|
95
95
|
skipCollectingAttestations: z.ZodOptional<z.ZodBoolean>;
|
|
96
96
|
secondsBeforeInvalidatingBlockAsCommitteeMember: z.ZodNumber;
|
|
97
97
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.ZodNumber;
|
|
98
|
+
injectFakeAttestation: z.ZodOptional<z.ZodBoolean>;
|
|
98
99
|
} & {
|
|
99
100
|
nodeUrl: z.ZodOptional<z.ZodString>;
|
|
100
101
|
realProofs: z.ZodBoolean;
|
|
@@ -199,6 +200,7 @@ export declare const AztecNodeAdminConfigSchema: z.ZodObject<{
|
|
|
199
200
|
fakeProcessingDelayPerTxMs?: number | undefined;
|
|
200
201
|
attestationPropagationTime?: number | undefined;
|
|
201
202
|
skipCollectingAttestations?: boolean | undefined;
|
|
203
|
+
injectFakeAttestation?: boolean | undefined;
|
|
202
204
|
proverId?: import("@aztec/foundation/schemas").EthAddress | undefined;
|
|
203
205
|
archiverPollingIntervalMS?: number | undefined;
|
|
204
206
|
archiverBatchSize?: number | undefined;
|
|
@@ -267,6 +269,7 @@ export declare const AztecNodeAdminConfigSchema: z.ZodObject<{
|
|
|
267
269
|
fakeProcessingDelayPerTxMs?: number | undefined;
|
|
268
270
|
attestationPropagationTime?: number | undefined;
|
|
269
271
|
skipCollectingAttestations?: boolean | undefined;
|
|
272
|
+
injectFakeAttestation?: boolean | undefined;
|
|
270
273
|
proverId?: any;
|
|
271
274
|
archiverPollingIntervalMS?: string | number | bigint | undefined;
|
|
272
275
|
archiverBatchSize?: string | number | bigint | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec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AM,EACX,QAAQ,GAAE,OAAO,CAAC,kBAAkB,CAAM,EAC1C,KAAK,sBAAe,GACnB,cAAc,CAMhB"}
|
|
@@ -49,6 +49,8 @@ export interface SequencerConfig {
|
|
|
49
49
|
skipCollectingAttestations?: boolean;
|
|
50
50
|
/** Do not invalidate the previous block if invalid when we are the proposer (for testing only) */
|
|
51
51
|
skipInvalidateBlockAsProposer?: boolean;
|
|
52
|
+
/** Inject a fake attestation (for testing only) */
|
|
53
|
+
injectFakeAttestation?: boolean;
|
|
52
54
|
}
|
|
53
55
|
export declare const SequencerConfigSchema: z.ZodObject<{
|
|
54
56
|
transactionPollingIntervalMS: z.ZodOptional<z.ZodNumber>;
|
|
@@ -101,6 +103,7 @@ export declare const SequencerConfigSchema: z.ZodObject<{
|
|
|
101
103
|
skipCollectingAttestations: z.ZodOptional<z.ZodBoolean>;
|
|
102
104
|
secondsBeforeInvalidatingBlockAsCommitteeMember: z.ZodNumber;
|
|
103
105
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.ZodNumber;
|
|
106
|
+
injectFakeAttestation: z.ZodOptional<z.ZodBoolean>;
|
|
104
107
|
}, "strip", z.ZodTypeAny, {
|
|
105
108
|
secondsBeforeInvalidatingBlockAsCommitteeMember: number;
|
|
106
109
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: number;
|
|
@@ -132,6 +135,7 @@ export declare const SequencerConfigSchema: z.ZodObject<{
|
|
|
132
135
|
fakeProcessingDelayPerTxMs?: number | undefined;
|
|
133
136
|
attestationPropagationTime?: number | undefined;
|
|
134
137
|
skipCollectingAttestations?: boolean | undefined;
|
|
138
|
+
injectFakeAttestation?: boolean | undefined;
|
|
135
139
|
}, {
|
|
136
140
|
secondsBeforeInvalidatingBlockAsCommitteeMember: number;
|
|
137
141
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: number;
|
|
@@ -163,5 +167,6 @@ export declare const SequencerConfigSchema: z.ZodObject<{
|
|
|
163
167
|
fakeProcessingDelayPerTxMs?: number | undefined;
|
|
164
168
|
attestationPropagationTime?: number | undefined;
|
|
165
169
|
skipCollectingAttestations?: boolean | undefined;
|
|
170
|
+
injectFakeAttestation?: boolean | undefined;
|
|
166
171
|
}>;
|
|
167
172
|
//# sourceMappingURL=configs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/interfaces/configs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,sBAAsB,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,gCAAgC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gCAAgC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,sBAAsB,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1C,qBAAqB;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC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,CAAC;IACtB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,0DAA0D;IAC1D,sBAAsB,CAAC,EAAE,cAAc,EAAE,CAAC;IAC1C,qBAAqB;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kCAAkC;IAClC,yBAAyB,CAAC,EAAE,UAAU,CAAC;IACvC,6DAA6D;IAC7D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gFAAgF;IAChF,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,0EAA0E;IAC1E,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,wGAAwG;IACxG,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,oGAAoG;IACpG,+CAA+C,CAAC,EAAE,MAAM,CAAC;IACzD,wGAAwG;IACxG,kDAAkD,CAAC,EAAE,MAAM,CAAC;IAC5D,sDAAsD;IACtD,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,kGAAkG;IAClG,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,mDAAmD;IACnD,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBE,CAAC"}
|
|
@@ -21,5 +21,6 @@ export const SequencerConfigSchema = z.object({
|
|
|
21
21
|
attestationPropagationTime: z.number().optional(),
|
|
22
22
|
skipCollectingAttestations: z.boolean().optional(),
|
|
23
23
|
secondsBeforeInvalidatingBlockAsCommitteeMember: z.number(),
|
|
24
|
-
secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number()
|
|
24
|
+
secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number(),
|
|
25
|
+
injectFakeAttestation: z.boolean().optional()
|
|
25
26
|
});
|
package/dest/interfaces/p2p.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface P2PApiWithAttestations extends P2PApiWithoutAttestations {
|
|
|
48
48
|
* @returns BlockAttestations
|
|
49
49
|
*/
|
|
50
50
|
getAttestationsForSlot(slot: bigint, proposalId?: string): Promise<BlockAttestation[]>;
|
|
51
|
+
/** Deletes a given attestation manually from the p2p client attestation pool. */
|
|
52
|
+
deleteAttestation(attestation: BlockAttestation): Promise<void>;
|
|
51
53
|
}
|
|
52
54
|
export interface P2PClient extends P2PApiWithAttestations {
|
|
53
55
|
/** Manually adds an attestation to the p2p client attestation pool. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"p2p.d.ts","sourceRoot":"","sources":["../../src/interfaces/p2p.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,KAAK,YAAY,EAAqB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,MAAM,MAAM,QAAQ,GAChB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,GAC1E;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAA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AAS,aAAa,GAAG,aAAa,CAAC,IAAI,IAAI,CAAC,SAAS,aAAa,CAAC,IAAI,GAC/F,sBAAsB,GAAG,SAAS,GAClC,yBAAyB,CAAC;AAE9B,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,MAAM,CAc7C,CAAC"}
|
package/dest/interfaces/p2p.js
CHANGED
|
@@ -29,5 +29,6 @@ export const P2PApiSchema = {
|
|
|
29
29
|
getPendingTxs: z.function().args(optional(z.number().gte(1).lte(MAX_RPC_TXS_LEN).default(MAX_RPC_TXS_LEN)), optional(TxHash.schema)).returns(z.array(Tx.schema)),
|
|
30
30
|
getPendingTxCount: z.function().returns(schemas.Integer),
|
|
31
31
|
getEncodedEnr: z.function().returns(z.string().optional()),
|
|
32
|
-
getPeers: z.function().args(optional(z.boolean())).returns(z.array(PeerInfoSchema))
|
|
32
|
+
getPeers: z.function().args(optional(z.boolean())).returns(z.array(PeerInfoSchema)),
|
|
33
|
+
deleteAttestation: z.function().args(BlockAttestation.schema).returns(z.void())
|
|
33
34
|
};
|
|
@@ -24,15 +24,20 @@ export declare class BlockAttestation extends Gossipable {
|
|
|
24
24
|
readonly payload: ConsensusPayload;
|
|
25
25
|
/** The signature of the block attester */
|
|
26
26
|
readonly signature: Signature;
|
|
27
|
+
/** The signature from the block proposer */
|
|
28
|
+
readonly proposerSignature: Signature;
|
|
27
29
|
static p2pTopic: TopicType;
|
|
28
30
|
private sender;
|
|
31
|
+
private proposer;
|
|
29
32
|
constructor(
|
|
30
33
|
/** The block number of the attestation. */
|
|
31
34
|
blockNumber: UInt32,
|
|
32
35
|
/** The payload of the message, and what the signature is over */
|
|
33
36
|
payload: ConsensusPayload,
|
|
34
37
|
/** The signature of the block attester */
|
|
35
|
-
signature: Signature
|
|
38
|
+
signature: Signature,
|
|
39
|
+
/** The signature from the block proposer */
|
|
40
|
+
proposerSignature: Signature);
|
|
36
41
|
static get schema(): ZodFor<BlockAttestation>;
|
|
37
42
|
generateP2PMessageIdentifier(): Promise<Buffer32>;
|
|
38
43
|
get archive(): Fr;
|
|
@@ -42,11 +47,52 @@ export declare class BlockAttestation extends Gossipable {
|
|
|
42
47
|
* @returns The signer of the attestation
|
|
43
48
|
*/
|
|
44
49
|
getSender(): EthAddress;
|
|
50
|
+
/**
|
|
51
|
+
* Tries to get the sender of the attestation
|
|
52
|
+
* @returns The sender of the attestation or undefined if it fails during recovery
|
|
53
|
+
*/
|
|
54
|
+
tryGetSender(): EthAddress | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Lazily evaluate and cache the proposer of the block
|
|
57
|
+
* @returns The proposer of the block
|
|
58
|
+
*/
|
|
59
|
+
getProposer(): EthAddress;
|
|
45
60
|
getPayload(): Buffer;
|
|
46
61
|
toBuffer(): Buffer;
|
|
47
62
|
static fromBuffer(buf: Buffer | BufferReader): BlockAttestation;
|
|
48
63
|
static empty(): BlockAttestation;
|
|
49
64
|
static random(): BlockAttestation;
|
|
50
65
|
getSize(): number;
|
|
66
|
+
toInspect(): {
|
|
67
|
+
blockNumber: number;
|
|
68
|
+
payload: {
|
|
69
|
+
header: {
|
|
70
|
+
lastArchive: `0x${string}`;
|
|
71
|
+
contentCommitment: {
|
|
72
|
+
blobsHash: `0x${string}`;
|
|
73
|
+
inHash: `0x${string}`;
|
|
74
|
+
outHash: `0x${string}`;
|
|
75
|
+
};
|
|
76
|
+
slotNumber: bigint;
|
|
77
|
+
timestamp: bigint;
|
|
78
|
+
coinbase: `0x${string}`;
|
|
79
|
+
feeRecipient: `0x${string}`;
|
|
80
|
+
gasFees: {
|
|
81
|
+
feePerDaGas: bigint;
|
|
82
|
+
feePerL2Gas: bigint;
|
|
83
|
+
};
|
|
84
|
+
totalManaUsed: bigint;
|
|
85
|
+
};
|
|
86
|
+
archive: `0x${string}`;
|
|
87
|
+
stateReference: {
|
|
88
|
+
l1ToL2MessageTree: `0x${string}`;
|
|
89
|
+
noteHashTree: `0x${string}`;
|
|
90
|
+
nullifierTree: `0x${string}`;
|
|
91
|
+
publicDataTree: `0x${string}`;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
signature: `0x${string}`;
|
|
95
|
+
proposerSignature: `0x${string}`;
|
|
96
|
+
};
|
|
51
97
|
}
|
|
52
98
|
//# 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;
|
|
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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,IAAI,MAAM;IAIlB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,gBAAgB;IAU/D,MAAM,CAAC,KAAK,IAAI,gBAAgB;IAIhC,MAAM,CAAC,MAAM,IAAI,gBAAgB;IASjC,OAAO,IAAI,MAAM;IAIjB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQV"}
|
|
@@ -22,17 +22,20 @@ export class BlockAttestationHash extends Buffer32 {
|
|
|
22
22
|
blockNumber;
|
|
23
23
|
payload;
|
|
24
24
|
signature;
|
|
25
|
+
proposerSignature;
|
|
25
26
|
static p2pTopic = TopicType.block_attestation;
|
|
26
27
|
sender;
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
proposer;
|
|
29
|
+
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, /** The signature from the block proposer */ proposerSignature){
|
|
30
|
+
super(), this.blockNumber = blockNumber, this.payload = payload, this.signature = signature, this.proposerSignature = proposerSignature;
|
|
29
31
|
}
|
|
30
32
|
static get schema() {
|
|
31
33
|
return z.object({
|
|
32
34
|
blockNumber: schemas.UInt32,
|
|
33
35
|
payload: ConsensusPayload.schema,
|
|
34
|
-
signature: Signature.schema
|
|
35
|
-
|
|
36
|
+
signature: Signature.schema,
|
|
37
|
+
proposerSignature: Signature.schema
|
|
38
|
+
}).transform((obj)=>new BlockAttestation(obj.blockNumber, obj.payload, obj.signature, obj.proposerSignature));
|
|
36
39
|
}
|
|
37
40
|
generateP2PMessageIdentifier() {
|
|
38
41
|
return Promise.resolve(new BlockAttestationHash(keccak256(this.signature.toBuffer())));
|
|
@@ -55,6 +58,28 @@ export class BlockAttestationHash extends Buffer32 {
|
|
|
55
58
|
}
|
|
56
59
|
return this.sender;
|
|
57
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Tries to get the sender of the attestation
|
|
63
|
+
* @returns The sender of the attestation or undefined if it fails during recovery
|
|
64
|
+
*/ tryGetSender() {
|
|
65
|
+
try {
|
|
66
|
+
return this.getSender();
|
|
67
|
+
} catch {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Lazily evaluate and cache the proposer of the block
|
|
73
|
+
* @returns The proposer of the block
|
|
74
|
+
*/ getProposer() {
|
|
75
|
+
if (!this.proposer) {
|
|
76
|
+
// Recover the proposer from the proposal signature
|
|
77
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
|
|
78
|
+
// Cache the proposer for later use
|
|
79
|
+
this.proposer = recoverAddress(hashed, this.proposerSignature);
|
|
80
|
+
}
|
|
81
|
+
return this.proposer;
|
|
82
|
+
}
|
|
58
83
|
getPayload() {
|
|
59
84
|
return this.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation);
|
|
60
85
|
}
|
|
@@ -62,20 +87,29 @@ export class BlockAttestationHash extends Buffer32 {
|
|
|
62
87
|
return serializeToBuffer([
|
|
63
88
|
this.blockNumber,
|
|
64
89
|
this.payload,
|
|
65
|
-
this.signature
|
|
90
|
+
this.signature,
|
|
91
|
+
this.proposerSignature
|
|
66
92
|
]);
|
|
67
93
|
}
|
|
68
94
|
static fromBuffer(buf) {
|
|
69
95
|
const reader = BufferReader.asReader(buf);
|
|
70
|
-
return new BlockAttestation(reader.readNumber(), reader.readObject(ConsensusPayload), reader.readObject(Signature));
|
|
96
|
+
return new BlockAttestation(reader.readNumber(), reader.readObject(ConsensusPayload), reader.readObject(Signature), reader.readObject(Signature));
|
|
71
97
|
}
|
|
72
98
|
static empty() {
|
|
73
|
-
return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty());
|
|
99
|
+
return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty(), Signature.empty());
|
|
74
100
|
}
|
|
75
101
|
static random() {
|
|
76
|
-
return new BlockAttestation(Math.floor(Math.random() * 1000) + 1, ConsensusPayload.random(), Signature.random());
|
|
102
|
+
return new BlockAttestation(Math.floor(Math.random() * 1000) + 1, ConsensusPayload.random(), Signature.random(), Signature.random());
|
|
77
103
|
}
|
|
78
104
|
getSize() {
|
|
79
|
-
return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize();
|
|
105
|
+
return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize() + this.proposerSignature.getSize();
|
|
106
|
+
}
|
|
107
|
+
toInspect() {
|
|
108
|
+
return {
|
|
109
|
+
blockNumber: this.blockNumber,
|
|
110
|
+
payload: this.payload.toInspect(),
|
|
111
|
+
signature: this.signature.toString(),
|
|
112
|
+
proposerSignature: this.proposerSignature.toString()
|
|
113
|
+
};
|
|
80
114
|
}
|
|
81
115
|
}
|
package/dest/p2p/gossipable.d.ts
CHANGED
|
@@ -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(
|
|
8
|
-
static fromGossipable(message: Gossipable):
|
|
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;
|
|
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;aACO,OAAO,EAAE,MAAM;gBAAf,OAAO,EAAE,MAAM;IAE3C,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU;IAItD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU;IAMvD,aAAa,IAAI,MAAM;CAGxB;AAED;;;;GAIG;AACH,8BAAsB,UAAU;IAC9B,OAAO,CAAC,QAAQ,CAAuB;IACvC;;;OAGG;IACH,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC;IAE3B;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAQ/C,QAAQ,CAAC,4BAA4B,IAAI,OAAO,CAAC,QAAQ,CAAC;IAE1D;;;OAGG;IACH,QAAQ,CAAC,QAAQ,IAAI,MAAM;IAE3B,SAAS,IAAI,MAAM;IAInB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,IAAI,MAAM;CAC3B"}
|
package/dest/p2p/gossipable.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import {
|
|
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(
|
|
8
|
-
this.publishTime = publishTime;
|
|
9
|
-
this.id = id;
|
|
4
|
+
constructor(payload){
|
|
10
5
|
this.payload = payload;
|
|
11
6
|
}
|
|
12
|
-
static
|
|
13
|
-
return new P2PMessage(
|
|
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(
|
|
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
|
}
|
package/dest/tests/mocks.d.ts
CHANGED
|
@@ -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,
|
|
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>;
|
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AAE,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,aAOzE,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"}
|
package/dest/tests/mocks.js
CHANGED
|
@@ -166,17 +166,39 @@ export const makeBlockProposal = (options)=>{
|
|
|
166
166
|
};
|
|
167
167
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
|
|
168
168
|
export const makeBlockAttestation = (options)=>{
|
|
169
|
-
const
|
|
170
|
-
|
|
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(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
171
183
|
};
|
|
172
|
-
export const makeBlockAttestationFromBlock = (block,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
180
202
|
};
|
|
181
203
|
export async function randomPublishedL2Block(l2BlockNumber, opts = {}) {
|
|
182
204
|
const block = await L2Block.random(l2BlockNumber);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "2.1.0-rc.
|
|
3
|
+
"version": "2.1.0-rc.20",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
73
|
-
"@aztec/bb.js": "2.1.0-rc.
|
|
74
|
-
"@aztec/blob-lib": "2.1.0-rc.
|
|
75
|
-
"@aztec/constants": "2.1.0-rc.
|
|
76
|
-
"@aztec/ethereum": "2.1.0-rc.
|
|
77
|
-
"@aztec/foundation": "2.1.0-rc.
|
|
78
|
-
"@aztec/l1-artifacts": "2.1.0-rc.
|
|
79
|
-
"@aztec/noir-noirc_abi": "2.1.0-rc.
|
|
73
|
+
"@aztec/bb.js": "2.1.0-rc.20",
|
|
74
|
+
"@aztec/blob-lib": "2.1.0-rc.20",
|
|
75
|
+
"@aztec/constants": "2.1.0-rc.20",
|
|
76
|
+
"@aztec/ethereum": "2.1.0-rc.20",
|
|
77
|
+
"@aztec/foundation": "2.1.0-rc.20",
|
|
78
|
+
"@aztec/l1-artifacts": "2.1.0-rc.20",
|
|
79
|
+
"@aztec/noir-noirc_abi": "2.1.0-rc.20",
|
|
80
80
|
"@google-cloud/storage": "^7.15.0",
|
|
81
81
|
"axios": "^1.12.0",
|
|
82
82
|
"json-stringify-deterministic": "1.0.12",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"msgpackr": "^1.11.2",
|
|
88
88
|
"pako": "^2.1.0",
|
|
89
89
|
"tslib": "^2.4.0",
|
|
90
|
-
"viem": "2.
|
|
90
|
+
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0",
|
|
91
91
|
"zod": "^3.23.8"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { recoverAddress } from '@aztec/foundation/crypto';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
|
|
4
|
+
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
5
|
+
import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '../p2p/signature_utils.js';
|
|
6
|
+
import type { L2Block } from './l2_block.js';
|
|
7
|
+
import type { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Status indicating how the attestation address was determined
|
|
11
|
+
*/
|
|
12
|
+
export type AttestationStatus = 'recovered-from-signature' | 'provided-as-address' | 'invalid-signature' | 'empty';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Information about an attestation extracted from a published block
|
|
16
|
+
*/
|
|
17
|
+
export type AttestationInfo =
|
|
18
|
+
| {
|
|
19
|
+
/** The validator's address, undefined if signature recovery failed or empty */
|
|
20
|
+
address?: undefined;
|
|
21
|
+
/** How the attestation address was determined */
|
|
22
|
+
status: Extract<AttestationStatus, 'invalid-signature' | 'empty'>;
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
/** The validator's address */
|
|
26
|
+
address: EthAddress;
|
|
27
|
+
/** How the attestation address was determined */
|
|
28
|
+
status: Extract<AttestationStatus, 'provided-as-address' | 'recovered-from-signature'>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Extracts attestation information from a published L2 block.
|
|
33
|
+
* Returns info for each attestation, preserving array indices.
|
|
34
|
+
*/
|
|
35
|
+
export function getAttestationInfoFromPublishedL2Block(block: {
|
|
36
|
+
attestations: CommitteeAttestation[];
|
|
37
|
+
block: L2Block;
|
|
38
|
+
}): AttestationInfo[] {
|
|
39
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
40
|
+
const hashedPayload = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
41
|
+
|
|
42
|
+
return block.attestations.map(attestation => {
|
|
43
|
+
// If signature is empty, check if we have an address directly
|
|
44
|
+
if (attestation.signature.isEmpty()) {
|
|
45
|
+
if (attestation.address.isZero()) {
|
|
46
|
+
// No signature and no address - empty
|
|
47
|
+
return { status: 'empty' as const };
|
|
48
|
+
}
|
|
49
|
+
// Address provided without signature
|
|
50
|
+
return { address: attestation.address, status: 'provided-as-address' as const };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Try to recover address from signature
|
|
54
|
+
try {
|
|
55
|
+
const recoveredAddress = recoverAddress(hashedPayload, attestation.signature);
|
|
56
|
+
return { address: recoveredAddress, status: 'recovered-from-signature' as const };
|
|
57
|
+
} catch {
|
|
58
|
+
// Signature present but recovery failed
|
|
59
|
+
return { status: 'invalid-signature' as const };
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
package/src/block/index.ts
CHANGED
|
@@ -7,8 +7,6 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
7
7
|
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
|
-
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
11
|
-
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
12
10
|
import { L2Block } from './l2_block.js';
|
|
13
11
|
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
14
12
|
|
|
@@ -82,12 +80,3 @@ export class PublishedL2Block {
|
|
|
82
80
|
);
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
|
-
|
|
86
|
-
export function getAttestationsFromPublishedL2Block(
|
|
87
|
-
block: Pick<PublishedL2Block, 'attestations' | 'block'>,
|
|
88
|
-
): BlockAttestation[] {
|
|
89
|
-
const payload = ConsensusPayload.fromBlock(block.block);
|
|
90
|
-
return block.attestations
|
|
91
|
-
.filter(attestation => !attestation.signature.isEmpty())
|
|
92
|
-
.map(attestation => new BlockAttestation(block.block.number, payload, attestation.signature));
|
|
93
|
-
}
|
|
@@ -52,6 +52,8 @@ export interface SequencerConfig {
|
|
|
52
52
|
skipCollectingAttestations?: boolean;
|
|
53
53
|
/** Do not invalidate the previous block if invalid when we are the proposer (for testing only) */
|
|
54
54
|
skipInvalidateBlockAsProposer?: boolean;
|
|
55
|
+
/** Inject a fake attestation (for testing only) */
|
|
56
|
+
injectFakeAttestation?: boolean;
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export const SequencerConfigSchema = z.object({
|
|
@@ -75,4 +77,5 @@ export const SequencerConfigSchema = z.object({
|
|
|
75
77
|
skipCollectingAttestations: z.boolean().optional(),
|
|
76
78
|
secondsBeforeInvalidatingBlockAsCommitteeMember: z.number(),
|
|
77
79
|
secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number(),
|
|
80
|
+
injectFakeAttestation: z.boolean().optional(),
|
|
78
81
|
}) satisfies ZodFor<SequencerConfig>;
|
package/src/interfaces/p2p.ts
CHANGED
|
@@ -57,6 +57,9 @@ export interface P2PApiWithAttestations extends P2PApiWithoutAttestations {
|
|
|
57
57
|
* @returns BlockAttestations
|
|
58
58
|
*/
|
|
59
59
|
getAttestationsForSlot(slot: bigint, proposalId?: string): Promise<BlockAttestation[]>;
|
|
60
|
+
|
|
61
|
+
/** Deletes a given attestation manually from the p2p client attestation pool. */
|
|
62
|
+
deleteAttestation(attestation: BlockAttestation): Promise<void>;
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
export interface P2PClient extends P2PApiWithAttestations {
|
|
@@ -85,4 +88,5 @@ export const P2PApiSchema: ApiSchemaFor<P2PApi> = {
|
|
|
85
88
|
getPendingTxCount: z.function().returns(schemas.Integer),
|
|
86
89
|
getEncodedEnr: z.function().returns(z.string().optional()),
|
|
87
90
|
getPeers: z.function().args(optional(z.boolean())).returns(z.array(PeerInfoSchema)),
|
|
91
|
+
deleteAttestation: z.function().args(BlockAttestation.schema).returns(z.void()),
|
|
88
92
|
};
|
|
@@ -30,6 +30,7 @@ export class BlockAttestation extends Gossipable {
|
|
|
30
30
|
static override p2pTopic = TopicType.block_attestation;
|
|
31
31
|
|
|
32
32
|
private sender: EthAddress | undefined;
|
|
33
|
+
private proposer: EthAddress | undefined;
|
|
33
34
|
|
|
34
35
|
constructor(
|
|
35
36
|
/** The block number of the attestation. */
|
|
@@ -40,6 +41,9 @@ export class BlockAttestation extends Gossipable {
|
|
|
40
41
|
|
|
41
42
|
/** The signature of the block attester */
|
|
42
43
|
public readonly signature: Signature,
|
|
44
|
+
|
|
45
|
+
/** The signature from the block proposer */
|
|
46
|
+
public readonly proposerSignature: Signature,
|
|
43
47
|
) {
|
|
44
48
|
super();
|
|
45
49
|
}
|
|
@@ -50,8 +54,9 @@ export class BlockAttestation extends Gossipable {
|
|
|
50
54
|
blockNumber: schemas.UInt32,
|
|
51
55
|
payload: ConsensusPayload.schema,
|
|
52
56
|
signature: Signature.schema,
|
|
57
|
+
proposerSignature: Signature.schema,
|
|
53
58
|
})
|
|
54
|
-
.transform(obj => new BlockAttestation(obj.blockNumber, obj.payload, obj.signature));
|
|
59
|
+
.transform(obj => new BlockAttestation(obj.blockNumber, obj.payload, obj.signature, obj.proposerSignature));
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
override generateP2PMessageIdentifier(): Promise<Buffer32> {
|
|
@@ -81,28 +86,74 @@ export class BlockAttestation extends Gossipable {
|
|
|
81
86
|
return this.sender;
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Tries to get the sender of the attestation
|
|
91
|
+
* @returns The sender of the attestation or undefined if it fails during recovery
|
|
92
|
+
*/
|
|
93
|
+
tryGetSender(): EthAddress | undefined {
|
|
94
|
+
try {
|
|
95
|
+
return this.getSender();
|
|
96
|
+
} catch {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Lazily evaluate and cache the proposer of the block
|
|
103
|
+
* @returns The proposer of the block
|
|
104
|
+
*/
|
|
105
|
+
getProposer(): EthAddress {
|
|
106
|
+
if (!this.proposer) {
|
|
107
|
+
// Recover the proposer from the proposal signature
|
|
108
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this.payload, SignatureDomainSeparator.blockProposal);
|
|
109
|
+
// Cache the proposer for later use
|
|
110
|
+
this.proposer = recoverAddress(hashed, this.proposerSignature);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return this.proposer;
|
|
114
|
+
}
|
|
115
|
+
|
|
84
116
|
getPayload(): Buffer {
|
|
85
117
|
return this.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation);
|
|
86
118
|
}
|
|
87
119
|
|
|
88
120
|
toBuffer(): Buffer {
|
|
89
|
-
return serializeToBuffer([this.blockNumber, this.payload, this.signature]);
|
|
121
|
+
return serializeToBuffer([this.blockNumber, this.payload, this.signature, this.proposerSignature]);
|
|
90
122
|
}
|
|
91
123
|
|
|
92
124
|
static fromBuffer(buf: Buffer | BufferReader): BlockAttestation {
|
|
93
125
|
const reader = BufferReader.asReader(buf);
|
|
94
|
-
return new BlockAttestation(
|
|
126
|
+
return new BlockAttestation(
|
|
127
|
+
reader.readNumber(),
|
|
128
|
+
reader.readObject(ConsensusPayload),
|
|
129
|
+
reader.readObject(Signature),
|
|
130
|
+
reader.readObject(Signature),
|
|
131
|
+
);
|
|
95
132
|
}
|
|
96
133
|
|
|
97
134
|
static empty(): BlockAttestation {
|
|
98
|
-
return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty());
|
|
135
|
+
return new BlockAttestation(0, ConsensusPayload.empty(), Signature.empty(), Signature.empty());
|
|
99
136
|
}
|
|
100
137
|
|
|
101
138
|
static random(): BlockAttestation {
|
|
102
|
-
return new BlockAttestation(
|
|
139
|
+
return new BlockAttestation(
|
|
140
|
+
Math.floor(Math.random() * 1000) + 1,
|
|
141
|
+
ConsensusPayload.random(),
|
|
142
|
+
Signature.random(),
|
|
143
|
+
Signature.random(),
|
|
144
|
+
);
|
|
103
145
|
}
|
|
104
146
|
|
|
105
147
|
getSize(): number {
|
|
106
|
-
return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize();
|
|
148
|
+
return 4 /* blockNumber */ + this.payload.getSize() + this.signature.getSize() + this.proposerSignature.getSize();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
toInspect() {
|
|
152
|
+
return {
|
|
153
|
+
blockNumber: this.blockNumber,
|
|
154
|
+
payload: this.payload.toInspect(),
|
|
155
|
+
signature: this.signature.toString(),
|
|
156
|
+
proposerSignature: this.proposerSignature.toString(),
|
|
157
|
+
};
|
|
107
158
|
}
|
|
108
159
|
}
|
package/src/p2p/gossipable.ts
CHANGED
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { BufferReader,
|
|
2
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
3
|
|
|
4
4
|
import type { TopicType } from './topic_type.js';
|
|
5
5
|
|
|
6
6
|
export class P2PMessage {
|
|
7
|
-
constructor(
|
|
8
|
-
public readonly publishTime: Date,
|
|
9
|
-
public readonly id: Buffer32,
|
|
10
|
-
public readonly payload: Buffer,
|
|
11
|
-
) {}
|
|
7
|
+
constructor(public readonly payload: Buffer) {}
|
|
12
8
|
|
|
13
|
-
static
|
|
14
|
-
return new P2PMessage(
|
|
9
|
+
static fromGossipable(message: Gossipable): P2PMessage {
|
|
10
|
+
return new P2PMessage(message.toBuffer());
|
|
15
11
|
}
|
|
16
12
|
|
|
17
13
|
static fromMessageData(messageData: Buffer): P2PMessage {
|
|
18
14
|
const reader = new BufferReader(messageData);
|
|
19
|
-
const publishTime = reader.readUInt64();
|
|
20
|
-
const id = Buffer32.fromBuffer(reader);
|
|
21
15
|
const payload = reader.readBuffer();
|
|
22
|
-
return new P2PMessage(
|
|
16
|
+
return new P2PMessage(payload);
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
toMessageData(): Buffer {
|
|
26
|
-
return serializeToBuffer([
|
|
27
|
-
bigintToUInt64BE(BigInt(this.publishTime.getTime())),
|
|
28
|
-
this.id,
|
|
29
|
-
serializeToBuffer(this.payload.length, this.payload),
|
|
30
|
-
]);
|
|
20
|
+
return serializeToBuffer([serializeToBuffer(this.payload.length, this.payload)]);
|
|
31
21
|
}
|
|
32
22
|
}
|
|
33
23
|
|
package/src/tests/mocks.ts
CHANGED
|
@@ -248,6 +248,8 @@ export const randomDeployedContract = async () => {
|
|
|
248
248
|
|
|
249
249
|
export interface MakeConsensusPayloadOptions {
|
|
250
250
|
signer?: Secp256k1Signer;
|
|
251
|
+
attesterSigner?: Secp256k1Signer;
|
|
252
|
+
proposerSigner?: Secp256k1Signer;
|
|
251
253
|
header?: BlockHeader;
|
|
252
254
|
archive?: Fr;
|
|
253
255
|
stateReference?: StateReference;
|
|
@@ -296,21 +298,58 @@ export const makeBlockProposal = (options?: MakeConsensusPayloadOptions): BlockP
|
|
|
296
298
|
|
|
297
299
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/8028)
|
|
298
300
|
export const makeBlockAttestation = (options?: MakeConsensusPayloadOptions): BlockAttestation => {
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
const header = options?.header ?? makeHeader(1);
|
|
302
|
+
const {
|
|
303
|
+
signer,
|
|
304
|
+
attesterSigner = signer ?? Secp256k1Signer.random(),
|
|
305
|
+
proposerSigner = signer ?? Secp256k1Signer.random(),
|
|
306
|
+
archive = Fr.random(),
|
|
307
|
+
stateReference = header.state,
|
|
308
|
+
} = options ?? {};
|
|
309
|
+
|
|
310
|
+
const payload = ConsensusPayload.fromFields({
|
|
311
|
+
header: header.toPropose(),
|
|
312
|
+
archive,
|
|
313
|
+
stateReference,
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Sign as attester
|
|
317
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
318
|
+
const attestationSignature = attesterSigner.sign(attestationHash);
|
|
319
|
+
|
|
320
|
+
// Sign as proposer
|
|
321
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
322
|
+
const proposerSignature = proposerSigner.sign(proposalHash);
|
|
323
|
+
|
|
324
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
304
325
|
};
|
|
305
326
|
|
|
306
|
-
export const makeBlockAttestationFromBlock = (
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
327
|
+
export const makeBlockAttestationFromBlock = (
|
|
328
|
+
block: L2Block,
|
|
329
|
+
attesterSigner?: Secp256k1Signer,
|
|
330
|
+
proposerSigner?: Secp256k1Signer,
|
|
331
|
+
): BlockAttestation => {
|
|
332
|
+
const header = block.header;
|
|
333
|
+
const archive = block.archive.root;
|
|
334
|
+
const stateReference = block.header.state;
|
|
335
|
+
|
|
336
|
+
const payload = ConsensusPayload.fromFields({
|
|
337
|
+
header: header.toPropose(),
|
|
338
|
+
archive,
|
|
339
|
+
stateReference,
|
|
313
340
|
});
|
|
341
|
+
|
|
342
|
+
// Sign as attester
|
|
343
|
+
const attestationHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockAttestation);
|
|
344
|
+
const attestationSigner = attesterSigner ?? Secp256k1Signer.random();
|
|
345
|
+
const attestationSignature = attestationSigner.sign(attestationHash);
|
|
346
|
+
|
|
347
|
+
// Sign as proposer
|
|
348
|
+
const proposalHash = getHashedSignaturePayloadEthSignedMessage(payload, SignatureDomainSeparator.blockProposal);
|
|
349
|
+
const proposalSignerToUse = proposerSigner ?? Secp256k1Signer.random();
|
|
350
|
+
const proposerSignature = proposalSignerToUse.sign(proposalHash);
|
|
351
|
+
|
|
352
|
+
return new BlockAttestation(header.globalVariables.blockNumber, payload, attestationSignature, proposerSignature);
|
|
314
353
|
};
|
|
315
354
|
|
|
316
355
|
export async function randomPublishedL2Block(
|