@aztec/stdlib 3.0.0-nightly.20250908 → 3.0.0-nightly.20250911
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/index.d.ts +2 -0
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +2 -0
- package/dest/block/l2_block.d.ts +2 -8
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +5 -3
- package/dest/block/l2_block_info.d.ts +41 -0
- package/dest/block/l2_block_info.d.ts.map +1 -0
- package/dest/block/l2_block_info.js +40 -0
- package/dest/block/l2_block_source.d.ts +1 -428
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +0 -28
- package/dest/block/proposal/attestations_and_signers.d.ts +48 -0
- package/dest/block/proposal/attestations_and_signers.d.ts.map +1 -0
- package/dest/block/proposal/attestations_and_signers.js +99 -0
- package/dest/block/proposal/index.d.ts +1 -0
- package/dest/block/proposal/index.d.ts.map +1 -1
- package/dest/block/proposal/index.js +1 -0
- package/dest/block/published_l2_block.d.ts +25 -1
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +20 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +2 -1
- package/dest/block/validate_block_result.d.ts +222 -0
- package/dest/block/validate_block_result.d.ts.map +1 -0
- package/dest/block/validate_block_result.js +83 -0
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +2 -1
- package/dest/interfaces/block-builder.d.ts +5 -6
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/proving-job.d.ts +24 -24
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/proving-job.js +15 -15
- package/dest/interfaces/server_circuit_prover.d.ts +4 -8
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +3 -0
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/kernel/private_kernel_prover_output.d.ts +1 -1
- package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -1
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts +2 -0
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.js +7 -0
- package/dest/noir/index.d.ts +9 -0
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/p2p/block_attestation.d.ts +1 -0
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +3 -0
- package/dest/p2p/block_proposal.d.ts +2 -2
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +3 -1
- package/dest/p2p/consensus_payload.d.ts +1 -0
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +6 -4
- package/dest/p2p/signature_utils.d.ts +2 -1
- package/dest/p2p/signature_utils.d.ts.map +1 -1
- package/dest/p2p/signature_utils.js +1 -0
- package/dest/proofs/client_ivc_proof.d.ts +5 -8
- package/dest/proofs/client_ivc_proof.d.ts.map +1 -1
- package/dest/proofs/client_ivc_proof.js +27 -20
- package/dest/proofs/index.d.ts +1 -0
- package/dest/proofs/index.d.ts.map +1 -1
- package/dest/proofs/index.js +1 -0
- package/dest/proofs/proof_data.d.ts +20 -0
- package/dest/proofs/proof_data.d.ts.map +1 -0
- package/dest/proofs/proof_data.js +22 -0
- package/dest/proofs/proving_request_type.d.ts +12 -13
- package/dest/proofs/proving_request_type.d.ts.map +1 -1
- package/dest/proofs/proving_request_type.js +12 -12
- package/dest/rollup/index.d.ts +1 -3
- package/dest/rollup/index.d.ts.map +1 -1
- package/dest/rollup/index.js +1 -3
- package/dest/rollup/private_base_rollup_inputs.d.ts +5 -5
- package/dest/rollup/private_base_rollup_inputs.d.ts.map +1 -1
- package/dest/rollup/private_base_rollup_inputs.js +7 -9
- package/dest/rollup/public_base_rollup_inputs.d.ts +5 -5
- package/dest/rollup/public_base_rollup_inputs.d.ts.map +1 -1
- package/dest/rollup/public_base_rollup_inputs.js +7 -9
- package/dest/rollup/public_tube_private_inputs.d.ts +19 -0
- package/dest/rollup/public_tube_private_inputs.d.ts.map +1 -0
- package/dest/rollup/public_tube_private_inputs.js +38 -0
- package/dest/stats/stats.d.ts +1 -1
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +4 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +9 -15
- package/dest/tests/mocks.d.ts +3 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +10 -9
- package/dest/tx/content_commitment.d.ts +1 -0
- package/dest/tx/content_commitment.d.ts.map +1 -1
- package/dest/tx/content_commitment.js +3 -0
- package/dest/tx/partial_state_reference.d.ts +1 -0
- package/dest/tx/partial_state_reference.d.ts.map +1 -1
- package/dest/tx/partial_state_reference.js +3 -0
- package/dest/tx/proposed_block_header.d.ts +1 -0
- package/dest/tx/proposed_block_header.d.ts.map +1 -1
- package/dest/tx/proposed_block_header.js +3 -0
- package/dest/tx/state_reference.d.ts +1 -0
- package/dest/tx/state_reference.d.ts.map +1 -1
- package/dest/tx/state_reference.js +3 -0
- package/dest/tx/tx.d.ts +0 -2
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +2 -3
- package/dest/update-checker/update-checker.d.ts +1 -1
- package/dest/update-checker/update-checker.d.ts.map +1 -1
- package/dest/update-checker/update-checker.js +1 -1
- package/package.json +8 -8
- package/src/block/index.ts +2 -0
- package/src/block/l2_block.ts +6 -11
- package/src/block/l2_block_info.ts +63 -0
- package/src/block/l2_block_source.ts +1 -51
- package/src/block/proposal/attestations_and_signers.ts +121 -0
- package/src/block/proposal/index.ts +1 -0
- package/src/block/published_l2_block.ts +38 -5
- package/src/block/test/l2_tips_store_test_suite.ts +7 -6
- package/src/block/validate_block_result.ts +122 -0
- package/src/interfaces/archiver.ts +2 -1
- package/src/interfaces/block-builder.ts +9 -6
- package/src/interfaces/proving-job.ts +19 -14
- package/src/interfaces/server_circuit_prover.ts +13 -13
- package/src/interfaces/validator.ts +7 -0
- package/src/kernel/private_kernel_prover_output.ts +1 -1
- package/src/kernel/private_to_public_kernel_circuit_public_inputs.ts +9 -0
- package/src/noir/index.ts +9 -0
- package/src/p2p/block_attestation.ts +4 -0
- package/src/p2p/block_proposal.ts +5 -3
- package/src/p2p/consensus_payload.ts +7 -4
- package/src/p2p/signature_utils.ts +1 -0
- package/src/proofs/client_ivc_proof.ts +26 -20
- package/src/proofs/index.ts +1 -0
- package/src/proofs/proof_data.ts +39 -0
- package/src/proofs/proving_request_type.ts +1 -3
- package/src/rollup/index.ts +1 -3
- package/src/rollup/private_base_rollup_inputs.ts +8 -8
- package/src/rollup/public_base_rollup_inputs.ts +5 -8
- package/src/rollup/public_tube_private_inputs.ts +46 -0
- package/src/stats/stats.ts +2 -2
- package/src/tests/factories.ts +20 -23
- package/src/tests/mocks.ts +18 -6
- package/src/tx/content_commitment.ts +4 -0
- package/src/tx/partial_state_reference.ts +8 -0
- package/src/tx/proposed_block_header.ts +13 -0
- package/src/tx/state_reference.ts +4 -0
- package/src/tx/tx.ts +2 -3
- package/src/update-checker/update-checker.ts +1 -1
- package/dest/rollup/private_tube_data.d.ts +0 -15
- package/dest/rollup/private_tube_data.d.ts.map +0 -1
- package/dest/rollup/private_tube_data.js +0 -25
- package/dest/rollup/public_tube_data.d.ts +0 -15
- package/dest/rollup/public_tube_data.d.ts.map +0 -1
- package/dest/rollup/public_tube_data.js +0 -25
- package/dest/rollup/tube_inputs.d.ts +0 -43
- package/dest/rollup/tube_inputs.d.ts.map +0 -1
- package/dest/rollup/tube_inputs.js +0 -63
- package/src/rollup/private_tube_data.ts +0 -35
- package/src/rollup/public_tube_data.ts +0 -35
- package/src/rollup/tube_inputs.ts +0 -77
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ViemCommitteeAttestations } from '@aztec/ethereum';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { Signable, SignatureDomainSeparator } from '../../p2p/signature_utils.js';
|
|
4
|
+
import { CommitteeAttestation } from './committee_attestation.js';
|
|
5
|
+
export declare class CommitteeAttestationsAndSigners implements Signable {
|
|
6
|
+
attestations: CommitteeAttestation[];
|
|
7
|
+
constructor(attestations: CommitteeAttestation[]);
|
|
8
|
+
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
9
|
+
attestations: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
10
|
+
address: z.ZodType<import("./committee_attestation.js").EthAddress, any, string>;
|
|
11
|
+
signature: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>, import("./committee_attestation.js").Signature, string>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
address: import("./committee_attestation.js").EthAddress;
|
|
14
|
+
signature: import("./committee_attestation.js").Signature;
|
|
15
|
+
}, {
|
|
16
|
+
address: string;
|
|
17
|
+
signature: string;
|
|
18
|
+
}>, CommitteeAttestation, {
|
|
19
|
+
address: string;
|
|
20
|
+
signature: string;
|
|
21
|
+
}>, "many">;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
attestations: CommitteeAttestation[];
|
|
24
|
+
}, {
|
|
25
|
+
attestations: {
|
|
26
|
+
address: string;
|
|
27
|
+
signature: string;
|
|
28
|
+
}[];
|
|
29
|
+
}>, CommitteeAttestationsAndSigners, {
|
|
30
|
+
attestations: {
|
|
31
|
+
address: string;
|
|
32
|
+
signature: string;
|
|
33
|
+
}[];
|
|
34
|
+
}>;
|
|
35
|
+
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer;
|
|
36
|
+
static empty(): CommitteeAttestationsAndSigners;
|
|
37
|
+
toString(): void;
|
|
38
|
+
getSigners(): import("./committee_attestation.js").EthAddress[];
|
|
39
|
+
getSignedAttestations(): CommitteeAttestation[];
|
|
40
|
+
/**
|
|
41
|
+
* Packs an array of committee attestations into the format expected by the Solidity contract
|
|
42
|
+
*
|
|
43
|
+
* @param attestations - Array of committee attestations with addresses and signatures
|
|
44
|
+
* @returns Packed attestations with bitmap and tightly packed signature/address data
|
|
45
|
+
*/
|
|
46
|
+
getPackedAttestations(): ViemCommitteeAttestations;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=attestations_and_signers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestations_and_signers.d.ts","sourceRoot":"","sources":["../../../src/block/proposal/attestations_and_signers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAIjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,qBAAa,+BAAgC,YAAW,QAAQ;IAC3C,YAAY,EAAE,oBAAoB,EAAE;gBAApC,YAAY,EAAE,oBAAoB,EAAE;IAEvD,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;OAMhB;IAED,gBAAgB,CAAC,eAAe,EAAE,wBAAwB,GAAG,MAAM;IAanE,MAAM,CAAC,KAAK,IAAI,+BAA+B;IAI/C,QAAQ;IAIR,UAAU;IAIV,qBAAqB;IAIrB;;;;;OAKG;IACH,qBAAqB,IAAI,yBAAyB;CAiEnD"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { hexToBuffer } from '@aztec/foundation/string';
|
|
2
|
+
import { encodeAbiParameters, parseAbiParameters } from 'viem';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { CommitteeAttestation } from './committee_attestation.js';
|
|
5
|
+
export class CommitteeAttestationsAndSigners {
|
|
6
|
+
attestations;
|
|
7
|
+
constructor(attestations){
|
|
8
|
+
this.attestations = attestations;
|
|
9
|
+
}
|
|
10
|
+
static get schema() {
|
|
11
|
+
return z.object({
|
|
12
|
+
attestations: CommitteeAttestation.schema.array()
|
|
13
|
+
}).transform((obj)=>new CommitteeAttestationsAndSigners(obj.attestations));
|
|
14
|
+
}
|
|
15
|
+
getPayloadToSign(domainSeparator) {
|
|
16
|
+
const abi = parseAbiParameters('uint8,(bytes,bytes),address[]');
|
|
17
|
+
const packed = this.getPackedAttestations();
|
|
18
|
+
const encodedData = encodeAbiParameters(abi, [
|
|
19
|
+
domainSeparator,
|
|
20
|
+
[
|
|
21
|
+
packed.signatureIndices,
|
|
22
|
+
packed.signaturesOrAddresses
|
|
23
|
+
],
|
|
24
|
+
this.getSigners().map((s)=>s.toString())
|
|
25
|
+
]);
|
|
26
|
+
return hexToBuffer(encodedData);
|
|
27
|
+
}
|
|
28
|
+
static empty() {
|
|
29
|
+
return new CommitteeAttestationsAndSigners([]);
|
|
30
|
+
}
|
|
31
|
+
toString() {
|
|
32
|
+
throw new Error('Not implemented');
|
|
33
|
+
}
|
|
34
|
+
getSigners() {
|
|
35
|
+
return this.attestations.filter((a)=>!a.signature.isEmpty()).map((a)=>a.address);
|
|
36
|
+
}
|
|
37
|
+
getSignedAttestations() {
|
|
38
|
+
return this.attestations.filter((a)=>!a.signature.isEmpty());
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Packs an array of committee attestations into the format expected by the Solidity contract
|
|
42
|
+
*
|
|
43
|
+
* @param attestations - Array of committee attestations with addresses and signatures
|
|
44
|
+
* @returns Packed attestations with bitmap and tightly packed signature/address data
|
|
45
|
+
*/ getPackedAttestations() {
|
|
46
|
+
const length = this.attestations.length;
|
|
47
|
+
const attestations = this.attestations.map((a)=>a.toViem());
|
|
48
|
+
// Calculate bitmap size (1 bit per attestation, rounded up to nearest byte)
|
|
49
|
+
const bitmapSize = Math.ceil(length / 8);
|
|
50
|
+
const signatureIndices = new Uint8Array(bitmapSize);
|
|
51
|
+
// Calculate total data size needed
|
|
52
|
+
let totalDataSize = 0;
|
|
53
|
+
for(let i = 0; i < length; i++){
|
|
54
|
+
const signature = attestations[i].signature;
|
|
55
|
+
// Check if signature is empty (v = 0)
|
|
56
|
+
const isEmpty = signature.v === 0;
|
|
57
|
+
if (!isEmpty) {
|
|
58
|
+
totalDataSize += 65; // v (1) + r (32) + s (32)
|
|
59
|
+
} else {
|
|
60
|
+
totalDataSize += 20; // address only
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const signaturesOrAddresses = new Uint8Array(totalDataSize);
|
|
64
|
+
let dataIndex = 0;
|
|
65
|
+
// Pack the data
|
|
66
|
+
for(let i = 0; i < length; i++){
|
|
67
|
+
const attestation = attestations[i];
|
|
68
|
+
const signature = attestation.signature;
|
|
69
|
+
// Check if signature is empty
|
|
70
|
+
const isEmpty = signature.v === 0;
|
|
71
|
+
if (!isEmpty) {
|
|
72
|
+
// Set bit in bitmap (bit 7-0 in each byte, left to right)
|
|
73
|
+
const byteIndex = Math.floor(i / 8);
|
|
74
|
+
const bitIndex = 7 - i % 8;
|
|
75
|
+
signatureIndices[byteIndex] |= 1 << bitIndex;
|
|
76
|
+
// Pack signature: v + r + s
|
|
77
|
+
signaturesOrAddresses[dataIndex] = signature.v;
|
|
78
|
+
dataIndex++;
|
|
79
|
+
// Pack r (32 bytes)
|
|
80
|
+
const rBytes = Buffer.from(signature.r.slice(2), 'hex');
|
|
81
|
+
signaturesOrAddresses.set(rBytes, dataIndex);
|
|
82
|
+
dataIndex += 32;
|
|
83
|
+
// Pack s (32 bytes)
|
|
84
|
+
const sBytes = Buffer.from(signature.s.slice(2), 'hex');
|
|
85
|
+
signaturesOrAddresses.set(sBytes, dataIndex);
|
|
86
|
+
dataIndex += 32;
|
|
87
|
+
} else {
|
|
88
|
+
// Pack address only (20 bytes)
|
|
89
|
+
const addrBytes = Buffer.from(attestation.addr.slice(2), 'hex');
|
|
90
|
+
signaturesOrAddresses.set(addrBytes, dataIndex);
|
|
91
|
+
dataIndex += 20;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
signatureIndices: `0x${Buffer.from(signatureIndices).toString('hex')}`,
|
|
96
|
+
signaturesOrAddresses: `0x${Buffer.from(signaturesOrAddresses).toString('hex')}`
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/block/proposal/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/block/proposal/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
2
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
1
3
|
import { z } from 'zod';
|
|
2
4
|
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
3
5
|
import { L2Block } from './l2_block.js';
|
|
@@ -21,13 +23,14 @@ export declare class L1PublishedData {
|
|
|
21
23
|
blockHash: string;
|
|
22
24
|
}>;
|
|
23
25
|
static random(): L1PublishedData;
|
|
26
|
+
static fromFields(fields: FieldsOf<L1PublishedData>): L1PublishedData;
|
|
24
27
|
}
|
|
25
28
|
export declare class PublishedL2Block {
|
|
26
29
|
block: L2Block;
|
|
27
30
|
l1: L1PublishedData;
|
|
28
31
|
attestations: CommitteeAttestation[];
|
|
29
32
|
constructor(block: L2Block, l1: L1PublishedData, attestations: CommitteeAttestation[]);
|
|
30
|
-
static get schema(): z.ZodObject<{
|
|
33
|
+
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
31
34
|
block: z.ZodEffects<z.ZodObject<{
|
|
32
35
|
archive: z.ZodEffects<z.ZodObject<{
|
|
33
36
|
root: z.ZodType<import("@aztec/foundation/schemas").Fr, any, string>;
|
|
@@ -115,7 +118,28 @@ export declare class PublishedL2Block {
|
|
|
115
118
|
address: string;
|
|
116
119
|
signature: string;
|
|
117
120
|
}[];
|
|
121
|
+
}>, PublishedL2Block, {
|
|
122
|
+
block: {
|
|
123
|
+
archive: {
|
|
124
|
+
root: string;
|
|
125
|
+
nextAvailableLeafIndex: string | number | bigint;
|
|
126
|
+
};
|
|
127
|
+
header?: any;
|
|
128
|
+
body?: any;
|
|
129
|
+
};
|
|
130
|
+
l1: {
|
|
131
|
+
blockNumber: string | number | bigint;
|
|
132
|
+
timestamp: string | number | bigint;
|
|
133
|
+
blockHash: string;
|
|
134
|
+
};
|
|
135
|
+
attestations: {
|
|
136
|
+
address: string;
|
|
137
|
+
signature: string;
|
|
138
|
+
}[];
|
|
118
139
|
}>;
|
|
140
|
+
static fromBuffer(bufferOrReader: Buffer | BufferReader): PublishedL2Block;
|
|
141
|
+
static fromFields(fields: FieldsOf<PublishedL2Block>): PublishedL2Block;
|
|
142
|
+
toBuffer(): Buffer;
|
|
119
143
|
}
|
|
120
144
|
export declare function getAttestationsFromPublishedL2Block(block: Pick<PublishedL2Block, 'attestations' | 'block'>): BlockAttestation[];
|
|
121
145
|
//# 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":"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,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,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;AAED,wBAAgB,mCAAmC,CACjD,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,cAAc,GAAG,OAAO,CAAC,GACtD,gBAAgB,EAAE,CAKpB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { randomBigInt } from '@aztec/foundation/crypto';
|
|
4
4
|
import { schemas } from '@aztec/foundation/schemas';
|
|
5
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import { BlockAttestation } from '../p2p/block_attestation.js';
|
|
7
8
|
import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
@@ -26,6 +27,9 @@ export class L1PublishedData {
|
|
|
26
27
|
static random() {
|
|
27
28
|
return new L1PublishedData(randomBigInt(1000n) + 1n, BigInt(Math.floor(Date.now() / 1000)), Buffer32.random().toString());
|
|
28
29
|
}
|
|
30
|
+
static fromFields(fields) {
|
|
31
|
+
return new L1PublishedData(fields.blockNumber, fields.timestamp, fields.blockHash);
|
|
32
|
+
}
|
|
29
33
|
}
|
|
30
34
|
export class PublishedL2Block {
|
|
31
35
|
block;
|
|
@@ -41,7 +45,22 @@ export class PublishedL2Block {
|
|
|
41
45
|
block: L2Block.schema,
|
|
42
46
|
l1: L1PublishedData.schema,
|
|
43
47
|
attestations: z.array(CommitteeAttestation.schema)
|
|
44
|
-
});
|
|
48
|
+
}).transform((obj)=>PublishedL2Block.fromFields(obj));
|
|
49
|
+
}
|
|
50
|
+
static fromBuffer(bufferOrReader) {
|
|
51
|
+
const reader = BufferReader.asReader(bufferOrReader);
|
|
52
|
+
const block = reader.readObject(L2Block);
|
|
53
|
+
const l1BlockNumber = reader.readBigInt();
|
|
54
|
+
const l1BlockHash = reader.readString();
|
|
55
|
+
const l1Timestamp = reader.readBigInt();
|
|
56
|
+
const attestations = reader.readVector(CommitteeAttestation);
|
|
57
|
+
return new PublishedL2Block(block, new L1PublishedData(l1BlockNumber, l1Timestamp, l1BlockHash), attestations);
|
|
58
|
+
}
|
|
59
|
+
static fromFields(fields) {
|
|
60
|
+
return new PublishedL2Block(fields.block, fields.l1, fields.attestations);
|
|
61
|
+
}
|
|
62
|
+
toBuffer() {
|
|
63
|
+
return serializeToBuffer(this.block, this.l1.blockNumber, this.l1.blockHash, this.l1.timestamp, this.attestations.length, this.attestations);
|
|
45
64
|
}
|
|
46
65
|
}
|
|
47
66
|
export function getAttestationsFromPublishedL2Block(block) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l2_tips_store_test_suite.d.ts","sourceRoot":"","sources":["../../../src/block/test/l2_tips_store_test_suite.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"l2_tips_store_test_suite.d.ts","sourceRoot":"","sources":["../../../src/block/test/l2_tips_store_test_suite.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,QA8ExE"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { times } from '@aztec/foundation/collection';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { PublishedL2Block } from '@aztec/stdlib/block';
|
|
3
4
|
import { jestExpect as expect } from '@jest/expect';
|
|
4
5
|
export function testL2TipsStore(makeTipsStore) {
|
|
5
6
|
let tipsStore;
|
|
6
7
|
beforeEach(async ()=>{
|
|
7
8
|
tipsStore = await makeTipsStore();
|
|
8
9
|
});
|
|
9
|
-
const makeBlock = (number)=>({
|
|
10
|
+
const makeBlock = (number)=>PublishedL2Block.fromFields({
|
|
10
11
|
block: {
|
|
11
12
|
number,
|
|
12
13
|
header: {
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { BufferReader } from '@aztec/foundation/serialize';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { type L2BlockInfo } from './l2_block_info.js';
|
|
5
|
+
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
6
|
+
/** Subtype for invalid block validation results */
|
|
7
|
+
export type ValidateBlockNegativeResult = {
|
|
8
|
+
valid: false;
|
|
9
|
+
/** Identifiers from the invalid block */
|
|
10
|
+
block: L2BlockInfo;
|
|
11
|
+
/** Committee members at the epoch this block was proposed */
|
|
12
|
+
committee: EthAddress[];
|
|
13
|
+
/** Epoch in which this block was proposed */
|
|
14
|
+
epoch: bigint;
|
|
15
|
+
/** Proposer selection seed for the epoch */
|
|
16
|
+
seed: bigint;
|
|
17
|
+
/** List of committee members who signed this block proposal */
|
|
18
|
+
attestors: EthAddress[];
|
|
19
|
+
/** Committee attestations for this block as they were posted to L1 */
|
|
20
|
+
attestations: CommitteeAttestation[];
|
|
21
|
+
/** Reason for the block being invalid: not enough attestations were posted */
|
|
22
|
+
reason: 'insufficient-attestations';
|
|
23
|
+
} | {
|
|
24
|
+
valid: false;
|
|
25
|
+
/** Identifiers from the invalid block */
|
|
26
|
+
block: L2BlockInfo;
|
|
27
|
+
/** Committee members at the epoch this block was proposed */
|
|
28
|
+
committee: EthAddress[];
|
|
29
|
+
/** Epoch in which this block was proposed */
|
|
30
|
+
epoch: bigint;
|
|
31
|
+
/** Proposer selection seed for the epoch */
|
|
32
|
+
seed: bigint;
|
|
33
|
+
/** List of committee members who signed this block proposal */
|
|
34
|
+
attestors: EthAddress[];
|
|
35
|
+
/** Committee attestations for this block as they were posted to L1 */
|
|
36
|
+
attestations: CommitteeAttestation[];
|
|
37
|
+
/** Reason for the block being invalid: an invalid attestation was posted */
|
|
38
|
+
reason: 'invalid-attestation';
|
|
39
|
+
/** Index in the attestations array of the invalid attestation posted */
|
|
40
|
+
invalidIndex: number;
|
|
41
|
+
};
|
|
42
|
+
/** Result type for validating a block attestations */
|
|
43
|
+
export type ValidateBlockResult = {
|
|
44
|
+
valid: true;
|
|
45
|
+
} | ValidateBlockNegativeResult;
|
|
46
|
+
export declare const ValidateBlockResultSchema: z.ZodUnion<[z.ZodObject<{
|
|
47
|
+
valid: z.ZodLiteral<true>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
valid: true;
|
|
50
|
+
}, {
|
|
51
|
+
valid: true;
|
|
52
|
+
}>, z.ZodObject<{
|
|
53
|
+
valid: z.ZodLiteral<false>;
|
|
54
|
+
block: z.ZodObject<{
|
|
55
|
+
blockHash: z.ZodOptional<z.ZodType<import("@aztec/foundation/schemas").Fr, any, string>>;
|
|
56
|
+
archive: z.ZodType<import("@aztec/foundation/schemas").Fr, any, string>;
|
|
57
|
+
lastArchive: z.ZodType<import("@aztec/foundation/schemas").Fr, any, string>;
|
|
58
|
+
blockNumber: z.ZodNumber;
|
|
59
|
+
slotNumber: z.ZodNumber;
|
|
60
|
+
txCount: z.ZodNumber;
|
|
61
|
+
timestamp: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
blockNumber: number;
|
|
64
|
+
slotNumber: number;
|
|
65
|
+
timestamp: bigint;
|
|
66
|
+
lastArchive: import("@aztec/foundation/schemas").Fr;
|
|
67
|
+
archive: import("@aztec/foundation/schemas").Fr;
|
|
68
|
+
txCount: number;
|
|
69
|
+
blockHash?: import("@aztec/foundation/schemas").Fr | undefined;
|
|
70
|
+
}, {
|
|
71
|
+
blockNumber: number;
|
|
72
|
+
slotNumber: number;
|
|
73
|
+
timestamp: string | number | bigint;
|
|
74
|
+
lastArchive: string;
|
|
75
|
+
archive: string;
|
|
76
|
+
txCount: number;
|
|
77
|
+
blockHash?: string | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
committee: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
|
|
80
|
+
epoch: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
81
|
+
seed: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
82
|
+
attestors: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
|
|
83
|
+
attestations: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
84
|
+
address: z.ZodType<EthAddress, any, string>;
|
|
85
|
+
signature: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>, import("./proposal/committee_attestation.js").Signature, string>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
address: EthAddress;
|
|
88
|
+
signature: import("./proposal/committee_attestation.js").Signature;
|
|
89
|
+
}, {
|
|
90
|
+
address: string;
|
|
91
|
+
signature: string;
|
|
92
|
+
}>, CommitteeAttestation, {
|
|
93
|
+
address: string;
|
|
94
|
+
signature: string;
|
|
95
|
+
}>, "many">;
|
|
96
|
+
reason: z.ZodLiteral<"insufficient-attestations">;
|
|
97
|
+
}, "strip", z.ZodTypeAny, {
|
|
98
|
+
valid: false;
|
|
99
|
+
block: {
|
|
100
|
+
blockNumber: number;
|
|
101
|
+
slotNumber: number;
|
|
102
|
+
timestamp: bigint;
|
|
103
|
+
lastArchive: import("@aztec/foundation/schemas").Fr;
|
|
104
|
+
archive: import("@aztec/foundation/schemas").Fr;
|
|
105
|
+
txCount: number;
|
|
106
|
+
blockHash?: import("@aztec/foundation/schemas").Fr | undefined;
|
|
107
|
+
};
|
|
108
|
+
attestations: CommitteeAttestation[];
|
|
109
|
+
committee: EthAddress[];
|
|
110
|
+
epoch: bigint;
|
|
111
|
+
seed: bigint;
|
|
112
|
+
attestors: EthAddress[];
|
|
113
|
+
reason: "insufficient-attestations";
|
|
114
|
+
}, {
|
|
115
|
+
valid: false;
|
|
116
|
+
block: {
|
|
117
|
+
blockNumber: number;
|
|
118
|
+
slotNumber: number;
|
|
119
|
+
timestamp: string | number | bigint;
|
|
120
|
+
lastArchive: string;
|
|
121
|
+
archive: string;
|
|
122
|
+
txCount: number;
|
|
123
|
+
blockHash?: string | undefined;
|
|
124
|
+
};
|
|
125
|
+
attestations: {
|
|
126
|
+
address: string;
|
|
127
|
+
signature: string;
|
|
128
|
+
}[];
|
|
129
|
+
committee: string[];
|
|
130
|
+
epoch: string | number | bigint;
|
|
131
|
+
seed: string | number | bigint;
|
|
132
|
+
attestors: string[];
|
|
133
|
+
reason: "insufficient-attestations";
|
|
134
|
+
}>, z.ZodObject<{
|
|
135
|
+
valid: z.ZodLiteral<false>;
|
|
136
|
+
block: z.ZodObject<{
|
|
137
|
+
blockHash: z.ZodOptional<z.ZodType<import("@aztec/foundation/schemas").Fr, any, string>>;
|
|
138
|
+
archive: z.ZodType<import("@aztec/foundation/schemas").Fr, any, string>;
|
|
139
|
+
lastArchive: z.ZodType<import("@aztec/foundation/schemas").Fr, any, string>;
|
|
140
|
+
blockNumber: z.ZodNumber;
|
|
141
|
+
slotNumber: z.ZodNumber;
|
|
142
|
+
txCount: z.ZodNumber;
|
|
143
|
+
timestamp: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
144
|
+
}, "strip", z.ZodTypeAny, {
|
|
145
|
+
blockNumber: number;
|
|
146
|
+
slotNumber: number;
|
|
147
|
+
timestamp: bigint;
|
|
148
|
+
lastArchive: import("@aztec/foundation/schemas").Fr;
|
|
149
|
+
archive: import("@aztec/foundation/schemas").Fr;
|
|
150
|
+
txCount: number;
|
|
151
|
+
blockHash?: import("@aztec/foundation/schemas").Fr | undefined;
|
|
152
|
+
}, {
|
|
153
|
+
blockNumber: number;
|
|
154
|
+
slotNumber: number;
|
|
155
|
+
timestamp: string | number | bigint;
|
|
156
|
+
lastArchive: string;
|
|
157
|
+
archive: string;
|
|
158
|
+
txCount: number;
|
|
159
|
+
blockHash?: string | undefined;
|
|
160
|
+
}>;
|
|
161
|
+
committee: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
|
|
162
|
+
epoch: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
163
|
+
seed: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
|
|
164
|
+
attestors: z.ZodArray<z.ZodType<EthAddress, any, string>, "many">;
|
|
165
|
+
attestations: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
166
|
+
address: z.ZodType<EthAddress, any, string>;
|
|
167
|
+
signature: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>, import("./proposal/committee_attestation.js").Signature, string>;
|
|
168
|
+
}, "strip", z.ZodTypeAny, {
|
|
169
|
+
address: EthAddress;
|
|
170
|
+
signature: import("./proposal/committee_attestation.js").Signature;
|
|
171
|
+
}, {
|
|
172
|
+
address: string;
|
|
173
|
+
signature: string;
|
|
174
|
+
}>, CommitteeAttestation, {
|
|
175
|
+
address: string;
|
|
176
|
+
signature: string;
|
|
177
|
+
}>, "many">;
|
|
178
|
+
reason: z.ZodLiteral<"invalid-attestation">;
|
|
179
|
+
invalidIndex: z.ZodNumber;
|
|
180
|
+
}, "strip", z.ZodTypeAny, {
|
|
181
|
+
valid: false;
|
|
182
|
+
block: {
|
|
183
|
+
blockNumber: number;
|
|
184
|
+
slotNumber: number;
|
|
185
|
+
timestamp: bigint;
|
|
186
|
+
lastArchive: import("@aztec/foundation/schemas").Fr;
|
|
187
|
+
archive: import("@aztec/foundation/schemas").Fr;
|
|
188
|
+
txCount: number;
|
|
189
|
+
blockHash?: import("@aztec/foundation/schemas").Fr | undefined;
|
|
190
|
+
};
|
|
191
|
+
attestations: CommitteeAttestation[];
|
|
192
|
+
committee: EthAddress[];
|
|
193
|
+
epoch: bigint;
|
|
194
|
+
seed: bigint;
|
|
195
|
+
attestors: EthAddress[];
|
|
196
|
+
reason: "invalid-attestation";
|
|
197
|
+
invalidIndex: number;
|
|
198
|
+
}, {
|
|
199
|
+
valid: false;
|
|
200
|
+
block: {
|
|
201
|
+
blockNumber: number;
|
|
202
|
+
slotNumber: number;
|
|
203
|
+
timestamp: string | number | bigint;
|
|
204
|
+
lastArchive: string;
|
|
205
|
+
archive: string;
|
|
206
|
+
txCount: number;
|
|
207
|
+
blockHash?: string | undefined;
|
|
208
|
+
};
|
|
209
|
+
attestations: {
|
|
210
|
+
address: string;
|
|
211
|
+
signature: string;
|
|
212
|
+
}[];
|
|
213
|
+
committee: string[];
|
|
214
|
+
epoch: string | number | bigint;
|
|
215
|
+
seed: string | number | bigint;
|
|
216
|
+
attestors: string[];
|
|
217
|
+
reason: "invalid-attestation";
|
|
218
|
+
invalidIndex: number;
|
|
219
|
+
}>]>;
|
|
220
|
+
export declare function serializeValidateBlockResult(result: ValidateBlockResult): Buffer;
|
|
221
|
+
export declare function deserializeValidateBlockResult(bufferOrReader: Buffer | BufferReader): ValidateBlockResult;
|
|
222
|
+
//# sourceMappingURL=validate_block_result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate_block_result.d.ts","sourceRoot":"","sources":["../../src/block/validate_block_result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAE9E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAmB,KAAK,WAAW,EAA4C,MAAM,oBAAoB,CAAC;AACjH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,mDAAmD;AACnD,MAAM,MAAM,2BAA2B,GACnC;IACE,KAAK,EAAE,KAAK,CAAC;IACb,yCAAyC;IACzC,KAAK,EAAE,WAAW,CAAC;IACnB,6DAA6D;IAC7D,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,sEAAsE;IACtE,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,8EAA8E;IAC9E,MAAM,EAAE,2BAA2B,CAAC;CACrC,GACD;IACE,KAAK,EAAE,KAAK,CAAC;IACb,yCAAyC;IACzC,KAAK,EAAE,WAAW,CAAC;IACnB,6DAA6D;IAC7D,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,SAAS,EAAE,UAAU,EAAE,CAAC;IACxB,sEAAsE;IACtE,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,4EAA4E;IAC5E,MAAM,EAAE,qBAAqB,CAAC;IAC9B,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN,sDAAsD;AACtD,MAAM,MAAM,mBAAmB,GAAG;IAAE,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG,2BAA2B,CAAC;AAEhF,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuBE,CAAC;AAEzC,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAqBhF;AAED,wBAAgB,8BAA8B,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY,GAAG,mBAAmB,CAsBzG"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { schemas } from '@aztec/foundation/schemas';
|
|
3
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { BlockInfoSchema, deserializeBlockInfo, serializeBlockInfo } from './l2_block_info.js';
|
|
6
|
+
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
7
|
+
export const ValidateBlockResultSchema = z.union([
|
|
8
|
+
z.object({
|
|
9
|
+
valid: z.literal(true)
|
|
10
|
+
}),
|
|
11
|
+
z.object({
|
|
12
|
+
valid: z.literal(false),
|
|
13
|
+
block: BlockInfoSchema,
|
|
14
|
+
committee: z.array(schemas.EthAddress),
|
|
15
|
+
epoch: schemas.BigInt,
|
|
16
|
+
seed: schemas.BigInt,
|
|
17
|
+
attestors: z.array(schemas.EthAddress),
|
|
18
|
+
attestations: z.array(CommitteeAttestation.schema),
|
|
19
|
+
reason: z.literal('insufficient-attestations')
|
|
20
|
+
}),
|
|
21
|
+
z.object({
|
|
22
|
+
valid: z.literal(false),
|
|
23
|
+
block: BlockInfoSchema,
|
|
24
|
+
committee: z.array(schemas.EthAddress),
|
|
25
|
+
epoch: schemas.BigInt,
|
|
26
|
+
seed: schemas.BigInt,
|
|
27
|
+
attestors: z.array(schemas.EthAddress),
|
|
28
|
+
attestations: z.array(CommitteeAttestation.schema),
|
|
29
|
+
reason: z.literal('invalid-attestation'),
|
|
30
|
+
invalidIndex: z.number()
|
|
31
|
+
})
|
|
32
|
+
]);
|
|
33
|
+
export function serializeValidateBlockResult(result) {
|
|
34
|
+
if (result.valid) {
|
|
35
|
+
return serializeToBuffer(true);
|
|
36
|
+
}
|
|
37
|
+
const l2Block = serializeBlockInfo(result.block);
|
|
38
|
+
return serializeToBuffer(result.valid, result.reason, l2Block.length, l2Block, result.committee.length, result.committee, result.epoch, result.seed ?? 0n, result.attestors.length, result.attestors, result.attestations.length, result.attestations, result.reason === 'invalid-attestation' ? result.invalidIndex : 0);
|
|
39
|
+
}
|
|
40
|
+
export function deserializeValidateBlockResult(bufferOrReader) {
|
|
41
|
+
const reader = BufferReader.asReader(bufferOrReader);
|
|
42
|
+
const valid = reader.readBoolean();
|
|
43
|
+
if (valid) {
|
|
44
|
+
return {
|
|
45
|
+
valid
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const reason = reader.readString();
|
|
49
|
+
const block = deserializeBlockInfo(reader.readBuffer());
|
|
50
|
+
const committee = reader.readVector(EthAddress);
|
|
51
|
+
const epoch = reader.readBigInt();
|
|
52
|
+
const seed = reader.readBigInt();
|
|
53
|
+
const attestors = reader.readVector(EthAddress);
|
|
54
|
+
const attestations = reader.readVector(CommitteeAttestation);
|
|
55
|
+
const invalidIndex = reader.readNumber();
|
|
56
|
+
if (reason === 'insufficient-attestations') {
|
|
57
|
+
return {
|
|
58
|
+
valid,
|
|
59
|
+
reason,
|
|
60
|
+
block,
|
|
61
|
+
committee,
|
|
62
|
+
epoch,
|
|
63
|
+
seed,
|
|
64
|
+
attestors,
|
|
65
|
+
attestations: attestations
|
|
66
|
+
};
|
|
67
|
+
} else if (reason === 'invalid-attestation') {
|
|
68
|
+
return {
|
|
69
|
+
valid,
|
|
70
|
+
reason,
|
|
71
|
+
block,
|
|
72
|
+
committee,
|
|
73
|
+
epoch,
|
|
74
|
+
seed,
|
|
75
|
+
attestors,
|
|
76
|
+
invalidIndex,
|
|
77
|
+
attestations: attestations
|
|
78
|
+
};
|
|
79
|
+
} else {
|
|
80
|
+
const _ = reason;
|
|
81
|
+
throw new Error(`Unknown reason: ${reason}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/interfaces/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK9D,OAAO,EAAE,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/interfaces/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAK9D,OAAO,EAAE,KAAK,aAAa,EAAgB,MAAM,6BAA6B,CAAC;AAG/E,OAAO,EAEL,KAAK,kBAAkB,EAExB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAOnF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG,IAAI,CAC5B,aAAa,GAAG,YAAY,GAAG,kBAAkB,GAAG,mBAAmB,EACvE,OAAO,GAAG,MAAM,CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,CAiDvD,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { L2Block } from '../block/l2_block.js';
|
|
3
|
-
import { L2TipsSchema
|
|
3
|
+
import { L2TipsSchema } from '../block/l2_block_source.js';
|
|
4
4
|
import { PublishedL2Block } from '../block/published_l2_block.js';
|
|
5
|
+
import { ValidateBlockResultSchema } from '../block/validate_block_result.js';
|
|
5
6
|
import { ContractClassPublicSchema, ContractInstanceWithAddressSchema } from '../contract/index.js';
|
|
6
7
|
import { L1RollupConstantsSchema } from '../epoch-helpers/index.js';
|
|
7
8
|
import { LogFilterSchema } from '../logs/log_filter.js';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { Timer } from '@aztec/foundation/timer';
|
|
3
3
|
import type { L2Block } from '../block/l2_block.js';
|
|
4
|
+
import type { ChainConfig, SequencerConfig } from '../config/chain-config.js';
|
|
5
|
+
import type { L1RollupConstants } from '../epoch-helpers/index.js';
|
|
4
6
|
import type { Gas } from '../gas/gas.js';
|
|
5
7
|
import type { MerkleTreeWriteOperations } from '../trees/index.js';
|
|
6
8
|
import type { BlockHeader } from '../tx/block_header.js';
|
|
@@ -50,13 +52,10 @@ export interface BuildBlockResult {
|
|
|
50
52
|
blockBuildingTimer: Timer;
|
|
51
53
|
usedTxs: Tx[];
|
|
52
54
|
}
|
|
55
|
+
export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'> & Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> & Pick<SequencerConfig, 'txPublicSetupAllowList' | 'fakeProcessingDelayPerTxMs'>;
|
|
53
56
|
export interface IFullNodeBlockBuilder {
|
|
54
|
-
getConfig():
|
|
55
|
-
|
|
56
|
-
slotDuration: number;
|
|
57
|
-
l1ChainId: number;
|
|
58
|
-
rollupVersion: number;
|
|
59
|
-
};
|
|
57
|
+
getConfig(): FullNodeBlockBuilderConfig;
|
|
58
|
+
updateConfig(config: Partial<FullNodeBlockBuilderConfig>): void;
|
|
60
59
|
buildBlock(txs: Iterable<Tx> | AsyncIterable<Tx>, l1ToL2Messages: Fr[], globalVariables: GlobalVariables, options: PublicProcessorLimits, fork?: MerkleTreeWriteOperations): Promise<BuildBlockResult>;
|
|
61
60
|
getFork(blockNumber: number): Promise<MerkleTreeWriteOperations>;
|
|
62
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-builder.d.ts","sourceRoot":"","sources":["../../src/interfaces/block-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,EAA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