@aztec/stdlib 0.86.0-nightly.20250430 → 0.86.0-nightly.20250501
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/published_l2_block.d.ts +2 -1
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +5 -18
- package/dest/tests/mocks.d.ts +4 -0
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +24 -0
- package/dest/validators/schemas.d.ts +24 -24
- package/dest/validators/schemas.js +1 -1
- package/dest/validators/types.d.ts +2 -2
- package/dest/validators/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/block/published_l2_block.ts +8 -16
- package/src/tests/mocks.ts +30 -0
- package/src/validators/schemas.ts +1 -1
- package/src/validators/types.ts +2 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
2
2
|
import { L2Block } from '@aztec/stdlib/block';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
+
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
4
5
|
export type L1PublishedData = {
|
|
5
6
|
blockNumber: bigint;
|
|
6
7
|
timestamp: bigint;
|
|
@@ -85,5 +86,5 @@ export declare const PublishedL2BlockSchema: z.ZodObject<{
|
|
|
85
86
|
};
|
|
86
87
|
signatures: string[];
|
|
87
88
|
}>;
|
|
88
|
-
export declare function
|
|
89
|
+
export declare function getAttestationsFromPublishedL2Block(block: PublishedL2Block): BlockAttestation[];
|
|
89
90
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"published_l2_block.d.ts","sourceRoot":"","sources":["../../src/block/published_l2_block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,OAAO,CAAC;IACf,EAAE,EAAE,eAAe,CAAC;IACpB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQjC,CAAC;AAEH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,gBAAgB,sBAK1E"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
4
1
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
2
|
import { schemas } from '@aztec/foundation/schemas';
|
|
6
3
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
4
|
import { z } from 'zod';
|
|
5
|
+
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
6
|
+
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
8
7
|
export const PublishedL2BlockSchema = z.object({
|
|
9
8
|
block: L2Block.schema,
|
|
10
9
|
l1: z.object({
|
|
@@ -14,19 +13,7 @@ export const PublishedL2BlockSchema = z.object({
|
|
|
14
13
|
}),
|
|
15
14
|
signatures: z.array(Signature.schema)
|
|
16
15
|
});
|
|
17
|
-
export
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
blockNumber: BigInt(block.number),
|
|
21
|
-
timestamp: block.header.globalVariables.timestamp.toBigInt(),
|
|
22
|
-
blockHash: Buffer32.random().toString()
|
|
23
|
-
};
|
|
24
|
-
// Create valid signatures
|
|
25
|
-
const signers = times(3, ()=>Secp256k1Signer.random());
|
|
26
|
-
const signatures = await Promise.all(times(3, async (i)=>signers[i].signMessage(Buffer32.fromField(await block.hash()))));
|
|
27
|
-
return {
|
|
28
|
-
block,
|
|
29
|
-
l1,
|
|
30
|
-
signatures
|
|
31
|
-
};
|
|
16
|
+
export function getAttestationsFromPublishedL2Block(block) {
|
|
17
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
18
|
+
return block.signatures.filter((sig)=>!sig.isEmpty).map((signature)=>new BlockAttestation(block.block.header.globalVariables.blockNumber, payload, signature));
|
|
32
19
|
}
|
package/dest/tests/mocks.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { ContractArtifact } from '../abi/abi.js';
|
|
4
4
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
5
|
+
import type { PublishedL2Block } from '../block/published_l2_block.js';
|
|
5
6
|
import type { ContractInstanceWithAddress } from '../contract/index.js';
|
|
6
7
|
import { GasFees } from '../gas/gas_fees.js';
|
|
7
8
|
import { ExtendedNote, UniqueNote } from '../note/extended_note.js';
|
|
@@ -47,4 +48,7 @@ export interface MakeConsensusPayloadOptions {
|
|
|
47
48
|
}
|
|
48
49
|
export declare const makeBlockProposal: (options?: MakeConsensusPayloadOptions) => BlockProposal;
|
|
49
50
|
export declare const makeBlockAttestation: (options?: MakeConsensusPayloadOptions) => BlockAttestation;
|
|
51
|
+
export declare function randomPublishedL2Block(l2BlockNumber: number, opts?: {
|
|
52
|
+
signers?: Secp256k1Signer[];
|
|
53
|
+
}): Promise<PublishedL2Block>;
|
|
50
54
|
//# sourceMappingURL=mocks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"
|
|
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,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAIvE,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,MAAM,kBAAkB,gEAM5B,QAAQ,YAAY,CAAC,0BAQvB,CAAC;AAEF,eAAO,MAAM,gBAAgB,uEAO1B,QAAQ,UAAU,CAAC,wBASrB,CAAC;AAEF,eAAO,MAAM,MAAM,gSAed;IACD,uCAAuC,CAAC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,CAAA;CAAO,GACzC,OAAO,CAAC,gBAAgB,CAAC,CAsB3B"}
|
package/dest/tests/mocks.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { MAX_ENQUEUED_CALLS_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
3
4
|
import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
|
|
4
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
6
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
7
|
+
import { L2Block } from '../block/l2_block.js';
|
|
6
8
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
7
9
|
import { getContractClassFromArtifact } from '../contract/contract_class.js';
|
|
8
10
|
import { SerializableContractInstance } from '../contract/contract_instance.js';
|
|
@@ -155,3 +157,25 @@ export const makeBlockAttestation = (options)=>{
|
|
|
155
157
|
const { blockNumber, payload, signature } = makeAndSignConsensusPayload(SignatureDomainSeparator.blockAttestation, options);
|
|
156
158
|
return new BlockAttestation(blockNumber, payload, signature);
|
|
157
159
|
};
|
|
160
|
+
export async function randomPublishedL2Block(l2BlockNumber, opts = {}) {
|
|
161
|
+
const block = await L2Block.random(l2BlockNumber);
|
|
162
|
+
const l1 = {
|
|
163
|
+
blockNumber: BigInt(block.number),
|
|
164
|
+
timestamp: block.header.globalVariables.timestamp.toBigInt(),
|
|
165
|
+
blockHash: Buffer32.random().toString()
|
|
166
|
+
};
|
|
167
|
+
const signers = opts.signers ?? times(3, ()=>Secp256k1Signer.random());
|
|
168
|
+
const attestations = await Promise.all(signers.map((signer)=>makeBlockAttestation({
|
|
169
|
+
signer,
|
|
170
|
+
header: block.header,
|
|
171
|
+
archive: block.archive.root,
|
|
172
|
+
stateReference: block.header.state,
|
|
173
|
+
txHashes: block.body.txEffects.map((tx)=>tx.txHash)
|
|
174
|
+
})));
|
|
175
|
+
const signatures = attestations.map((attestation)=>attestation.signature);
|
|
176
|
+
return {
|
|
177
|
+
block,
|
|
178
|
+
l1,
|
|
179
|
+
signatures
|
|
180
|
+
};
|
|
181
|
+
}
|
|
@@ -61,29 +61,29 @@ export declare const ValidatorStatsSchema: z.ZodObject<{
|
|
|
61
61
|
totalSlots: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
62
62
|
missedProposals: z.ZodObject<{
|
|
63
63
|
currentStreak: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
64
|
-
rate: z.ZodNumber
|
|
64
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
65
65
|
count: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
66
66
|
}, "strip", z.ZodTypeAny, {
|
|
67
67
|
currentStreak: number;
|
|
68
|
-
rate: number;
|
|
69
68
|
count: number;
|
|
69
|
+
rate?: number | undefined;
|
|
70
70
|
}, {
|
|
71
71
|
currentStreak: string | number | bigint;
|
|
72
|
-
rate: number;
|
|
73
72
|
count: string | number | bigint;
|
|
73
|
+
rate?: number | undefined;
|
|
74
74
|
}>;
|
|
75
75
|
missedAttestations: z.ZodObject<{
|
|
76
76
|
currentStreak: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
77
|
-
rate: z.ZodNumber
|
|
77
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
78
78
|
count: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
79
79
|
}, "strip", z.ZodTypeAny, {
|
|
80
80
|
currentStreak: number;
|
|
81
|
-
rate: number;
|
|
82
81
|
count: number;
|
|
82
|
+
rate?: number | undefined;
|
|
83
83
|
}, {
|
|
84
84
|
currentStreak: string | number | bigint;
|
|
85
|
-
rate: number;
|
|
86
85
|
count: string | number | bigint;
|
|
86
|
+
rate?: number | undefined;
|
|
87
87
|
}>;
|
|
88
88
|
history: z.ZodArray<z.ZodObject<{
|
|
89
89
|
slot: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
@@ -100,13 +100,13 @@ export declare const ValidatorStatsSchema: z.ZodObject<{
|
|
|
100
100
|
totalSlots: number;
|
|
101
101
|
missedProposals: {
|
|
102
102
|
currentStreak: number;
|
|
103
|
-
rate: number;
|
|
104
103
|
count: number;
|
|
104
|
+
rate?: number | undefined;
|
|
105
105
|
};
|
|
106
106
|
missedAttestations: {
|
|
107
107
|
currentStreak: number;
|
|
108
|
-
rate: number;
|
|
109
108
|
count: number;
|
|
109
|
+
rate?: number | undefined;
|
|
110
110
|
};
|
|
111
111
|
history: {
|
|
112
112
|
status: "block-mined" | "block-proposed" | "block-missed" | "attestation-sent" | "attestation-missed";
|
|
@@ -127,13 +127,13 @@ export declare const ValidatorStatsSchema: z.ZodObject<{
|
|
|
127
127
|
totalSlots: string | number | bigint;
|
|
128
128
|
missedProposals: {
|
|
129
129
|
currentStreak: string | number | bigint;
|
|
130
|
-
rate: number;
|
|
131
130
|
count: string | number | bigint;
|
|
131
|
+
rate?: number | undefined;
|
|
132
132
|
};
|
|
133
133
|
missedAttestations: {
|
|
134
134
|
currentStreak: string | number | bigint;
|
|
135
|
-
rate: number;
|
|
136
135
|
count: string | number | bigint;
|
|
136
|
+
rate?: number | undefined;
|
|
137
137
|
};
|
|
138
138
|
history: {
|
|
139
139
|
status: "block-mined" | "block-proposed" | "block-missed" | "attestation-sent" | "attestation-missed";
|
|
@@ -182,29 +182,29 @@ export declare const ValidatorsStatsSchema: z.ZodObject<{
|
|
|
182
182
|
totalSlots: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
183
183
|
missedProposals: z.ZodObject<{
|
|
184
184
|
currentStreak: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
185
|
-
rate: z.ZodNumber
|
|
185
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
186
186
|
count: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
187
187
|
}, "strip", z.ZodTypeAny, {
|
|
188
188
|
currentStreak: number;
|
|
189
|
-
rate: number;
|
|
190
189
|
count: number;
|
|
190
|
+
rate?: number | undefined;
|
|
191
191
|
}, {
|
|
192
192
|
currentStreak: string | number | bigint;
|
|
193
|
-
rate: number;
|
|
194
193
|
count: string | number | bigint;
|
|
194
|
+
rate?: number | undefined;
|
|
195
195
|
}>;
|
|
196
196
|
missedAttestations: z.ZodObject<{
|
|
197
197
|
currentStreak: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
198
|
-
rate: z.ZodNumber
|
|
198
|
+
rate: z.ZodOptional<z.ZodNumber>;
|
|
199
199
|
count: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
200
200
|
}, "strip", z.ZodTypeAny, {
|
|
201
201
|
currentStreak: number;
|
|
202
|
-
rate: number;
|
|
203
202
|
count: number;
|
|
203
|
+
rate?: number | undefined;
|
|
204
204
|
}, {
|
|
205
205
|
currentStreak: string | number | bigint;
|
|
206
|
-
rate: number;
|
|
207
206
|
count: string | number | bigint;
|
|
207
|
+
rate?: number | undefined;
|
|
208
208
|
}>;
|
|
209
209
|
history: z.ZodArray<z.ZodObject<{
|
|
210
210
|
slot: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
@@ -221,13 +221,13 @@ export declare const ValidatorsStatsSchema: z.ZodObject<{
|
|
|
221
221
|
totalSlots: number;
|
|
222
222
|
missedProposals: {
|
|
223
223
|
currentStreak: number;
|
|
224
|
-
rate: number;
|
|
225
224
|
count: number;
|
|
225
|
+
rate?: number | undefined;
|
|
226
226
|
};
|
|
227
227
|
missedAttestations: {
|
|
228
228
|
currentStreak: number;
|
|
229
|
-
rate: number;
|
|
230
229
|
count: number;
|
|
230
|
+
rate?: number | undefined;
|
|
231
231
|
};
|
|
232
232
|
history: {
|
|
233
233
|
status: "block-mined" | "block-proposed" | "block-missed" | "attestation-sent" | "attestation-missed";
|
|
@@ -248,13 +248,13 @@ export declare const ValidatorsStatsSchema: z.ZodObject<{
|
|
|
248
248
|
totalSlots: string | number | bigint;
|
|
249
249
|
missedProposals: {
|
|
250
250
|
currentStreak: string | number | bigint;
|
|
251
|
-
rate: number;
|
|
252
251
|
count: string | number | bigint;
|
|
252
|
+
rate?: number | undefined;
|
|
253
253
|
};
|
|
254
254
|
missedAttestations: {
|
|
255
255
|
currentStreak: string | number | bigint;
|
|
256
|
-
rate: number;
|
|
257
256
|
count: string | number | bigint;
|
|
257
|
+
rate?: number | undefined;
|
|
258
258
|
};
|
|
259
259
|
history: {
|
|
260
260
|
status: "block-mined" | "block-proposed" | "block-missed" | "attestation-sent" | "attestation-missed";
|
|
@@ -280,13 +280,13 @@ export declare const ValidatorsStatsSchema: z.ZodObject<{
|
|
|
280
280
|
totalSlots: number;
|
|
281
281
|
missedProposals: {
|
|
282
282
|
currentStreak: number;
|
|
283
|
-
rate: number;
|
|
284
283
|
count: number;
|
|
284
|
+
rate?: number | undefined;
|
|
285
285
|
};
|
|
286
286
|
missedAttestations: {
|
|
287
287
|
currentStreak: number;
|
|
288
|
-
rate: number;
|
|
289
288
|
count: number;
|
|
289
|
+
rate?: number | undefined;
|
|
290
290
|
};
|
|
291
291
|
history: {
|
|
292
292
|
status: "block-mined" | "block-proposed" | "block-missed" | "attestation-sent" | "attestation-missed";
|
|
@@ -312,13 +312,13 @@ export declare const ValidatorsStatsSchema: z.ZodObject<{
|
|
|
312
312
|
totalSlots: string | number | bigint;
|
|
313
313
|
missedProposals: {
|
|
314
314
|
currentStreak: string | number | bigint;
|
|
315
|
-
rate: number;
|
|
316
315
|
count: string | number | bigint;
|
|
316
|
+
rate?: number | undefined;
|
|
317
317
|
};
|
|
318
318
|
missedAttestations: {
|
|
319
319
|
currentStreak: string | number | bigint;
|
|
320
|
-
rate: number;
|
|
321
320
|
count: string | number | bigint;
|
|
321
|
+
rate?: number | undefined;
|
|
322
322
|
};
|
|
323
323
|
history: {
|
|
324
324
|
status: "block-mined" | "block-proposed" | "block-missed" | "attestation-sent" | "attestation-missed";
|
|
@@ -20,7 +20,7 @@ const ValidatorTimeStatSchema = z.object({
|
|
|
20
20
|
});
|
|
21
21
|
const ValidatorFilteredHistorySchema = z.object({
|
|
22
22
|
currentStreak: schemas.Integer,
|
|
23
|
-
rate: z.number(),
|
|
23
|
+
rate: z.number().optional(),
|
|
24
24
|
count: schemas.Integer
|
|
25
25
|
});
|
|
26
26
|
export const ValidatorStatsSchema = z.object({
|
|
@@ -20,12 +20,12 @@ export type ValidatorStats = {
|
|
|
20
20
|
totalSlots: number;
|
|
21
21
|
missedProposals: {
|
|
22
22
|
currentStreak: number;
|
|
23
|
-
rate
|
|
23
|
+
rate?: number;
|
|
24
24
|
count: number;
|
|
25
25
|
};
|
|
26
26
|
missedAttestations: {
|
|
27
27
|
currentStreak: number;
|
|
28
|
-
rate
|
|
28
|
+
rate?: number;
|
|
29
29
|
count: number;
|
|
30
30
|
};
|
|
31
31
|
history: ValidatorStatusHistory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/validators/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,aAAa,CAAC;AAE1D,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,gBAAgB,GAChB,cAAc,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EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE;QACf,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,kBAAkB,EAAE;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,OAAO,EAAE,sBAAsB,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.86.0-nightly.
|
|
3
|
+
"version": "0.86.0-nightly.20250501",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@aztec/bb.js": "0.86.0-nightly.
|
|
70
|
-
"@aztec/blob-lib": "0.86.0-nightly.
|
|
71
|
-
"@aztec/constants": "0.86.0-nightly.
|
|
72
|
-
"@aztec/ethereum": "0.86.0-nightly.
|
|
73
|
-
"@aztec/foundation": "0.86.0-nightly.
|
|
74
|
-
"@aztec/noir-noirc_abi": "0.86.0-nightly.
|
|
69
|
+
"@aztec/bb.js": "0.86.0-nightly.20250501",
|
|
70
|
+
"@aztec/blob-lib": "0.86.0-nightly.20250501",
|
|
71
|
+
"@aztec/constants": "0.86.0-nightly.20250501",
|
|
72
|
+
"@aztec/ethereum": "0.86.0-nightly.20250501",
|
|
73
|
+
"@aztec/foundation": "0.86.0-nightly.20250501",
|
|
74
|
+
"@aztec/noir-noirc_abi": "0.86.0-nightly.20250501",
|
|
75
75
|
"@google-cloud/storage": "^7.15.0",
|
|
76
76
|
"lodash.chunk": "^4.2.0",
|
|
77
77
|
"lodash.isequal": "^4.5.0",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import { Secp256k1Signer } from '@aztec/foundation/crypto';
|
|
4
1
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
2
|
import { schemas } from '@aztec/foundation/schemas';
|
|
6
3
|
import { L2Block } from '@aztec/stdlib/block';
|
|
7
4
|
|
|
8
5
|
import { z } from 'zod';
|
|
9
6
|
|
|
7
|
+
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
8
|
+
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
9
|
+
|
|
10
10
|
export type L1PublishedData = {
|
|
11
11
|
blockNumber: bigint;
|
|
12
12
|
timestamp: bigint;
|
|
@@ -29,17 +29,9 @@ export const PublishedL2BlockSchema = z.object({
|
|
|
29
29
|
signatures: z.array(Signature.schema),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
-
export
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
blockHash: Buffer32.random().toString(),
|
|
38
|
-
};
|
|
39
|
-
// Create valid signatures
|
|
40
|
-
const signers = times(3, () => Secp256k1Signer.random());
|
|
41
|
-
const signatures = await Promise.all(
|
|
42
|
-
times(3, async i => signers[i].signMessage(Buffer32.fromField(await block.hash()))),
|
|
43
|
-
);
|
|
44
|
-
return { block, l1, signatures };
|
|
32
|
+
export function getAttestationsFromPublishedL2Block(block: PublishedL2Block) {
|
|
33
|
+
const payload = ConsensusPayload.fromBlock(block.block);
|
|
34
|
+
return block.signatures
|
|
35
|
+
.filter(sig => !sig.isEmpty)
|
|
36
|
+
.map(signature => new BlockAttestation(block.block.header.globalVariables.blockNumber, payload, signature));
|
|
45
37
|
}
|
package/src/tests/mocks.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { MAX_ENQUEUED_CALLS_PER_TX } from '@aztec/constants';
|
|
2
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
3
4
|
import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
|
|
4
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
6
|
|
|
6
7
|
import type { ContractArtifact } from '../abi/abi.js';
|
|
7
8
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
|
+
import { L2Block } from '../block/l2_block.js';
|
|
10
|
+
import type { PublishedL2Block } from '../block/published_l2_block.js';
|
|
8
11
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
9
12
|
import { getContractClassFromArtifact } from '../contract/contract_class.js';
|
|
10
13
|
import { SerializableContractInstance } from '../contract/contract_instance.js';
|
|
@@ -282,3 +285,30 @@ export const makeBlockAttestation = (options?: MakeConsensusPayloadOptions): Blo
|
|
|
282
285
|
);
|
|
283
286
|
return new BlockAttestation(blockNumber, payload, signature);
|
|
284
287
|
};
|
|
288
|
+
|
|
289
|
+
export async function randomPublishedL2Block(
|
|
290
|
+
l2BlockNumber: number,
|
|
291
|
+
opts: { signers?: Secp256k1Signer[] } = {},
|
|
292
|
+
): Promise<PublishedL2Block> {
|
|
293
|
+
const block = await L2Block.random(l2BlockNumber);
|
|
294
|
+
const l1 = {
|
|
295
|
+
blockNumber: BigInt(block.number),
|
|
296
|
+
timestamp: block.header.globalVariables.timestamp.toBigInt(),
|
|
297
|
+
blockHash: Buffer32.random().toString(),
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
const signers = opts.signers ?? times(3, () => Secp256k1Signer.random());
|
|
301
|
+
const attestations = await Promise.all(
|
|
302
|
+
signers.map(signer =>
|
|
303
|
+
makeBlockAttestation({
|
|
304
|
+
signer,
|
|
305
|
+
header: block.header,
|
|
306
|
+
archive: block.archive.root,
|
|
307
|
+
stateReference: block.header.state,
|
|
308
|
+
txHashes: block.body.txEffects.map(tx => tx.txHash),
|
|
309
|
+
}),
|
|
310
|
+
),
|
|
311
|
+
);
|
|
312
|
+
const signatures = attestations.map(attestation => attestation.signature);
|
|
313
|
+
return { block, l1, signatures };
|
|
314
|
+
}
|
package/src/validators/types.ts
CHANGED
|
@@ -18,12 +18,12 @@ export type ValidatorStats = {
|
|
|
18
18
|
totalSlots: number;
|
|
19
19
|
missedProposals: {
|
|
20
20
|
currentStreak: number;
|
|
21
|
-
rate
|
|
21
|
+
rate?: number;
|
|
22
22
|
count: number;
|
|
23
23
|
};
|
|
24
24
|
missedAttestations: {
|
|
25
25
|
currentStreak: number;
|
|
26
|
-
rate
|
|
26
|
+
rate?: number;
|
|
27
27
|
count: number;
|
|
28
28
|
};
|
|
29
29
|
history: ValidatorStatusHistory;
|