@aztec/stdlib 4.0.0-nightly.20260119 → 4.0.0-nightly.20260121
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/avm/avm.d.ts +300 -300
- package/dest/block/block_hash.d.ts +7 -1
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +12 -0
- package/dest/block/block_parameter.d.ts +4 -3
- package/dest/block/block_parameter.d.ts.map +1 -1
- package/dest/block/block_parameter.js +2 -0
- package/dest/block/checkpointed_l2_block.d.ts +10 -127
- package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
- package/dest/block/checkpointed_l2_block.js +2 -41
- package/dest/block/in_block.d.ts +3 -3
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/index.d.ts +1 -3
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +0 -2
- package/dest/block/l2_block_new.d.ts +11 -9
- package/dest/block/l2_block_new.d.ts.map +1 -1
- package/dest/block/l2_block_new.js +5 -5
- package/dest/block/l2_block_source.d.ts +20 -11
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.d.ts +10 -8
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +2 -2
- package/dest/checkpoint/published_checkpoint.d.ts +11 -9
- package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +9 -8
- package/dest/interfaces/aztec-node.d.ts +35 -40
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +6 -8
- package/dest/interfaces/block-builder.d.ts +18 -17
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +16 -6
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +14 -4
- package/dest/p2p/block_proposal.d.ts +9 -9
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +6 -5
- package/dest/p2p/checkpoint_proposal.d.ts +4 -4
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +3 -3
- package/dest/p2p/consensus_payload.d.ts +1 -3
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +0 -3
- package/dest/tests/factories.d.ts +2 -4
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +3 -13
- package/dest/tests/jest.d.ts +4 -4
- package/dest/tests/jest.js +9 -9
- package/dest/tests/mocks.d.ts +12 -12
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +33 -21
- package/package.json +9 -9
- package/src/block/block_hash.ts +22 -0
- package/src/block/block_parameter.ts +4 -2
- package/src/block/checkpointed_l2_block.ts +2 -53
- package/src/block/in_block.ts +2 -2
- package/src/block/index.ts +0 -2
- package/src/block/l2_block_new.ts +14 -7
- package/src/block/l2_block_source.ts +21 -11
- package/src/checkpoint/checkpoint.ts +8 -2
- package/src/interfaces/archiver.ts +9 -8
- package/src/interfaces/aztec-node.ts +39 -57
- package/src/interfaces/block-builder.ts +33 -28
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +17 -6
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +22 -10
- package/src/p2p/block_proposal.ts +10 -10
- package/src/p2p/checkpoint_proposal.ts +4 -4
- package/src/p2p/consensus_payload.ts +0 -5
- package/src/tests/factories.ts +2 -25
- package/src/tests/jest.ts +9 -9
- package/src/tests/mocks.ts +35 -28
- package/dest/block/l2_block.d.ts +0 -150
- package/dest/block/l2_block.d.ts.map +0 -1
- package/dest/block/l2_block.js +0 -201
- package/dest/block/l2_block_code_to_purge.d.ts +0 -11
- package/dest/block/l2_block_code_to_purge.d.ts.map +0 -1
- package/dest/block/l2_block_code_to_purge.js +0 -55
- package/dest/block/l2_block_header.d.ts +0 -106
- package/dest/block/l2_block_header.d.ts.map +0 -1
- package/dest/block/l2_block_header.js +0 -167
- package/src/block/l2_block.ts +0 -274
- package/src/block/l2_block_code_to_purge.ts +0 -81
- package/src/block/l2_block_header.ts +0 -268
package/src/tests/mocks.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
8
8
|
} from '@aztec/constants';
|
|
9
9
|
import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
|
|
10
|
-
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
10
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
11
11
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
12
12
|
import { padArrayEnd, times } from '@aztec/foundation/collection';
|
|
13
13
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
@@ -22,8 +22,7 @@ import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
|
|
|
22
22
|
import { PublicDataWrite } from '../avm/public_data_write.js';
|
|
23
23
|
import { RevertCode } from '../avm/revert_code.js';
|
|
24
24
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
25
|
-
import {
|
|
26
|
-
import { L2Block } from '../block/l2_block.js';
|
|
25
|
+
import { CheckpointedL2Block, CommitteeAttestation, L2BlockNew } from '../block/index.js';
|
|
27
26
|
import type { CommitteeAttestationsAndSigners } from '../block/proposal/attestations_and_signers.js';
|
|
28
27
|
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
29
28
|
import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
|
|
@@ -76,9 +75,9 @@ import {
|
|
|
76
75
|
makeAvmCircuitInputs,
|
|
77
76
|
makeAztecAddress,
|
|
78
77
|
makeBlockHeader,
|
|
78
|
+
makeCheckpointHeader,
|
|
79
79
|
makeGas,
|
|
80
80
|
makeGlobalVariables,
|
|
81
|
-
makeL2BlockHeader,
|
|
82
81
|
makePrivateToPublicAccumulatedData,
|
|
83
82
|
makePrivateToRollupAccumulatedData,
|
|
84
83
|
makeProtocolContracts,
|
|
@@ -429,7 +428,7 @@ export async function mockCheckpointAndMessages(
|
|
|
429
428
|
blocks?.[i] ??
|
|
430
429
|
(await L2BlockNew.random(blockNumber, {
|
|
431
430
|
checkpointNumber,
|
|
432
|
-
indexWithinCheckpoint: i,
|
|
431
|
+
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
433
432
|
txsPerBlock: numTxsPerBlock,
|
|
434
433
|
slotNumber,
|
|
435
434
|
...options,
|
|
@@ -493,7 +492,7 @@ export interface MakeConsensusPayloadOptions {
|
|
|
493
492
|
signer?: Secp256k1Signer;
|
|
494
493
|
attesterSigner?: Secp256k1Signer;
|
|
495
494
|
proposerSigner?: Secp256k1Signer;
|
|
496
|
-
header?:
|
|
495
|
+
header?: CheckpointHeader;
|
|
497
496
|
archive?: Fr;
|
|
498
497
|
txHashes?: TxHash[];
|
|
499
498
|
txs?: Tx[];
|
|
@@ -501,8 +500,8 @@ export interface MakeConsensusPayloadOptions {
|
|
|
501
500
|
|
|
502
501
|
export interface MakeBlockProposalOptions {
|
|
503
502
|
signer?: Secp256k1Signer;
|
|
504
|
-
blockHeader?:
|
|
505
|
-
indexWithinCheckpoint?:
|
|
503
|
+
blockHeader?: BlockHeader;
|
|
504
|
+
indexWithinCheckpoint?: IndexWithinCheckpoint;
|
|
506
505
|
inHash?: Fr;
|
|
507
506
|
archiveRoot?: Fr;
|
|
508
507
|
txHashes?: TxHash[];
|
|
@@ -515,8 +514,8 @@ export interface MakeCheckpointProposalOptions {
|
|
|
515
514
|
archiveRoot?: Fr;
|
|
516
515
|
/** Options for the lastBlock - if undefined, no lastBlock is included */
|
|
517
516
|
lastBlock?: {
|
|
518
|
-
blockHeader?:
|
|
519
|
-
indexWithinCheckpoint?:
|
|
517
|
+
blockHeader?: BlockHeader;
|
|
518
|
+
indexWithinCheckpoint?: IndexWithinCheckpoint;
|
|
520
519
|
txHashes?: TxHash[];
|
|
521
520
|
txs?: Tx[];
|
|
522
521
|
};
|
|
@@ -527,18 +526,18 @@ const makeAndSignConsensusPayload = (
|
|
|
527
526
|
domainSeparator: SignatureDomainSeparator,
|
|
528
527
|
options?: MakeConsensusPayloadOptions,
|
|
529
528
|
) => {
|
|
530
|
-
const header = options?.header ??
|
|
529
|
+
const header = options?.header ?? makeCheckpointHeader(1);
|
|
531
530
|
const { signer = Secp256k1Signer.random(), archive = Fr.random() } = options ?? {};
|
|
532
531
|
|
|
533
532
|
const payload = ConsensusPayload.fromFields({
|
|
534
|
-
header
|
|
533
|
+
header,
|
|
535
534
|
archive,
|
|
536
535
|
});
|
|
537
536
|
|
|
538
537
|
const hash = getHashedSignaturePayloadEthSignedMessage(payload, domainSeparator);
|
|
539
538
|
const signature = signer.sign(hash);
|
|
540
539
|
|
|
541
|
-
return { blockNumber: header.
|
|
540
|
+
return { blockNumber: header.slotNumber, payload, signature };
|
|
542
541
|
};
|
|
543
542
|
|
|
544
543
|
export const makeAndSignCommitteeAttestationsAndSigners = (
|
|
@@ -553,9 +552,8 @@ export const makeAndSignCommitteeAttestationsAndSigners = (
|
|
|
553
552
|
};
|
|
554
553
|
|
|
555
554
|
export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<BlockProposal> => {
|
|
556
|
-
const
|
|
557
|
-
const
|
|
558
|
-
const indexWithinCheckpoint = options?.indexWithinCheckpoint ?? 0;
|
|
555
|
+
const blockHeader = options?.blockHeader ?? makeBlockHeader(1);
|
|
556
|
+
const indexWithinCheckpoint = options?.indexWithinCheckpoint ?? IndexWithinCheckpoint(0);
|
|
559
557
|
const inHash = options?.inHash ?? Fr.random();
|
|
560
558
|
const archiveRoot = options?.archiveRoot ?? Fr.random();
|
|
561
559
|
const txHashes = options?.txHashes ?? [0, 1, 2, 3, 4, 5].map(() => TxHash.random());
|
|
@@ -574,16 +572,16 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
|
|
|
574
572
|
};
|
|
575
573
|
|
|
576
574
|
export const makeCheckpointProposal = (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
|
|
577
|
-
const
|
|
578
|
-
const checkpointHeader = options?.checkpointHeader ??
|
|
575
|
+
const blockHeader = options?.lastBlock?.blockHeader ?? makeBlockHeader(1);
|
|
576
|
+
const checkpointHeader = options?.checkpointHeader ?? makeCheckpointHeader(1);
|
|
579
577
|
const archiveRoot = options?.archiveRoot ?? Fr.random();
|
|
580
578
|
const signer = options?.signer ?? Secp256k1Signer.random();
|
|
581
579
|
|
|
582
580
|
// Build lastBlock info if provided
|
|
583
581
|
const lastBlockInfo = options?.lastBlock
|
|
584
582
|
? {
|
|
585
|
-
blockHeader
|
|
586
|
-
indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? 4, // Last block in a 5-block checkpoint
|
|
583
|
+
blockHeader,
|
|
584
|
+
indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4), // Last block in a 5-block checkpoint
|
|
587
585
|
txHashes: options.lastBlock.txHashes ?? [0, 1, 2, 3, 4, 5].map(() => TxHash.random()),
|
|
588
586
|
txs: options.lastBlock.txs,
|
|
589
587
|
}
|
|
@@ -609,7 +607,7 @@ export type MakeCheckpointAttestationOptions = {
|
|
|
609
607
|
* Create a checkpoint attestation for testing
|
|
610
608
|
*/
|
|
611
609
|
export const makeCheckpointAttestation = (options: MakeCheckpointAttestationOptions = {}): CheckpointAttestation => {
|
|
612
|
-
const header = options.header ??
|
|
610
|
+
const header = options.header ?? makeCheckpointHeader(1);
|
|
613
611
|
const archive = options.archive ?? Fr.random();
|
|
614
612
|
const { signer, attesterSigner = signer, proposerSigner = signer } = options;
|
|
615
613
|
|
|
@@ -672,14 +670,21 @@ export const makeCheckpointAttestationFromCheckpoint = (
|
|
|
672
670
|
};
|
|
673
671
|
|
|
674
672
|
/**
|
|
675
|
-
* Create a checkpoint attestation from an
|
|
673
|
+
* Create a checkpoint attestation from an L2BlockNew
|
|
674
|
+
* Note: This is a compatibility function for tests. L2BlockNew doesn't have a checkpoint header directly.
|
|
676
675
|
*/
|
|
677
676
|
export const makeCheckpointAttestationFromBlock = (
|
|
678
|
-
block:
|
|
677
|
+
block: L2BlockNew,
|
|
679
678
|
attesterSigner?: Secp256k1Signer,
|
|
680
679
|
proposerSigner?: Secp256k1Signer,
|
|
681
680
|
): CheckpointAttestation => {
|
|
682
|
-
|
|
681
|
+
// For L2BlockNew, we create a minimal checkpoint header for testing purposes
|
|
682
|
+
const header = CheckpointHeader.empty({
|
|
683
|
+
lastArchiveRoot: block.header.lastArchive.root,
|
|
684
|
+
slotNumber: block.slot,
|
|
685
|
+
timestamp: block.timestamp,
|
|
686
|
+
blockHeadersHash: Fr.ZERO, // Would need to compute from block header hash
|
|
687
|
+
});
|
|
683
688
|
const archive = block.archive.root;
|
|
684
689
|
|
|
685
690
|
return makeCheckpointAttestation({ header, archive, attesterSigner, proposerSigner });
|
|
@@ -688,8 +693,8 @@ export const makeCheckpointAttestationFromBlock = (
|
|
|
688
693
|
export async function randomPublishedL2Block(
|
|
689
694
|
l2BlockNumber: number,
|
|
690
695
|
opts: { signers?: Secp256k1Signer[] } = {},
|
|
691
|
-
): Promise<
|
|
692
|
-
const block = await
|
|
696
|
+
): Promise<CheckpointedL2Block> {
|
|
697
|
+
const block = await L2BlockNew.random(BlockNumber(l2BlockNumber));
|
|
693
698
|
const l1 = L1PublishedData.fromFields({
|
|
694
699
|
blockNumber: BigInt(block.number),
|
|
695
700
|
timestamp: block.header.globalVariables.timestamp,
|
|
@@ -697,15 +702,17 @@ export async function randomPublishedL2Block(
|
|
|
697
702
|
});
|
|
698
703
|
|
|
699
704
|
const signers = opts.signers ?? times(3, () => Secp256k1Signer.random());
|
|
705
|
+
const checkpoint = await Checkpoint.random(CheckpointNumber(l2BlockNumber), { numBlocks: 0 });
|
|
706
|
+
checkpoint.blocks = [block];
|
|
700
707
|
const atts = signers.map(signer =>
|
|
701
708
|
makeCheckpointAttestation({
|
|
702
709
|
signer,
|
|
703
710
|
archive: block.archive.root,
|
|
704
|
-
header:
|
|
711
|
+
header: checkpoint.header,
|
|
705
712
|
}),
|
|
706
713
|
);
|
|
707
714
|
const attestations = atts.map(
|
|
708
715
|
(attestation, i) => new CommitteeAttestation(signers[i].address, attestation.signature),
|
|
709
716
|
);
|
|
710
|
-
return new
|
|
717
|
+
return new CheckpointedL2Block(CheckpointNumber(l2BlockNumber), block, l1, attestations);
|
|
711
718
|
}
|
package/dest/block/l2_block.d.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { type BlockBlobData } from '@aztec/blob-lib/encoding';
|
|
2
|
-
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { BufferReader } from '@aztec/foundation/serialize';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
7
|
-
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
8
|
-
import type { BlockHeader } from '../tx/block_header.js';
|
|
9
|
-
import { Body } from './body.js';
|
|
10
|
-
import { L2BlockHeader } from './l2_block_header.js';
|
|
11
|
-
import type { L2BlockInfo } from './l2_block_info.js';
|
|
12
|
-
import { L2BlockNew } from './l2_block_new.js';
|
|
13
|
-
/**
|
|
14
|
-
* The data that makes up the rollup proof, with encoder decoder functions.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated Use `L2BlockNew` instead.
|
|
17
|
-
*/
|
|
18
|
-
export declare class L2Block {
|
|
19
|
-
/** Snapshot of archive tree after the block is applied. */
|
|
20
|
-
archive: AppendOnlyTreeSnapshot;
|
|
21
|
-
/** L2 block header. */
|
|
22
|
-
header: L2BlockHeader;
|
|
23
|
-
/** L2 block body. */
|
|
24
|
-
body: Body;
|
|
25
|
-
private blockHash;
|
|
26
|
-
constructor(
|
|
27
|
-
/** Snapshot of archive tree after the block is applied. */
|
|
28
|
-
archive: AppendOnlyTreeSnapshot,
|
|
29
|
-
/** L2 block header. */
|
|
30
|
-
header: L2BlockHeader,
|
|
31
|
-
/** L2 block body. */
|
|
32
|
-
body: Body, blockHash?: Fr | undefined);
|
|
33
|
-
static get schema(): z.ZodEffects<z.ZodObject<{
|
|
34
|
-
archive: z.ZodEffects<z.ZodObject<{
|
|
35
|
-
root: z.ZodType<Fr, any, string>;
|
|
36
|
-
nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
|
|
37
|
-
}, "strip", z.ZodTypeAny, {
|
|
38
|
-
root: Fr;
|
|
39
|
-
nextAvailableLeafIndex: number;
|
|
40
|
-
}, {
|
|
41
|
-
root: string;
|
|
42
|
-
nextAvailableLeafIndex: string | number | bigint;
|
|
43
|
-
}>, AppendOnlyTreeSnapshot, {
|
|
44
|
-
root: string;
|
|
45
|
-
nextAvailableLeafIndex: string | number | bigint;
|
|
46
|
-
}>;
|
|
47
|
-
header: import("@aztec/foundation/schemas").ZodFor<L2BlockHeader>;
|
|
48
|
-
body: import("@aztec/foundation/schemas").ZodFor<Body>;
|
|
49
|
-
}, "strip", z.ZodTypeAny, {
|
|
50
|
-
archive: AppendOnlyTreeSnapshot;
|
|
51
|
-
header: L2BlockHeader;
|
|
52
|
-
body: Body;
|
|
53
|
-
}, {
|
|
54
|
-
archive: {
|
|
55
|
-
root: string;
|
|
56
|
-
nextAvailableLeafIndex: string | number | bigint;
|
|
57
|
-
};
|
|
58
|
-
header?: any;
|
|
59
|
-
body?: any;
|
|
60
|
-
}>, L2Block, {
|
|
61
|
-
archive: {
|
|
62
|
-
root: string;
|
|
63
|
-
nextAvailableLeafIndex: string | number | bigint;
|
|
64
|
-
};
|
|
65
|
-
header?: any;
|
|
66
|
-
body?: any;
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* Deserializes a block from a buffer
|
|
70
|
-
* @returns A deserialized L2 block.
|
|
71
|
-
*/
|
|
72
|
-
static fromBuffer(buf: Buffer | BufferReader): L2Block;
|
|
73
|
-
/**
|
|
74
|
-
* Serializes a block
|
|
75
|
-
* @returns A serialized L2 block as a Buffer.
|
|
76
|
-
*/
|
|
77
|
-
toBuffer(): Buffer<ArrayBufferLike>;
|
|
78
|
-
/**
|
|
79
|
-
* Deserializes L2 block from a buffer.
|
|
80
|
-
* @param str - A serialized L2 block.
|
|
81
|
-
* @returns Deserialized L2 block.
|
|
82
|
-
*/
|
|
83
|
-
static fromString(str: string): L2Block;
|
|
84
|
-
/**
|
|
85
|
-
* Serializes a block to a string.
|
|
86
|
-
* @returns A serialized L2 block as a string.
|
|
87
|
-
*/
|
|
88
|
-
toString(): string;
|
|
89
|
-
/**
|
|
90
|
-
* Creates an L2 block containing random data.
|
|
91
|
-
* @param l2BlockNum - The number of the L2 block.
|
|
92
|
-
* @param txsPerBlock - The number of transactions to include in the block.
|
|
93
|
-
* @param numPublicCallsPerTx - The number of public function calls to include in each transaction.
|
|
94
|
-
* @param numPublicLogsPerCall - The number of public logs per 1 public function invocation.
|
|
95
|
-
* @param inHash - The hash of the L1 to L2 messages subtree which got inserted in this block.
|
|
96
|
-
* @returns The L2 block.
|
|
97
|
-
*/
|
|
98
|
-
static random(l2BlockNum: BlockNumber, txsPerBlock?: number, numPublicCallsPerTx?: number, numPublicLogsPerCall?: number, inHash?: Fr | undefined, slotNumber?: number | undefined, maxEffects?: number | undefined): Promise<L2Block>;
|
|
99
|
-
/**
|
|
100
|
-
* Creates an L2 block containing empty data.
|
|
101
|
-
* @param header - An optional header to assign to the block
|
|
102
|
-
* @returns The L2 block.
|
|
103
|
-
*/
|
|
104
|
-
static empty(header?: L2BlockHeader): L2Block;
|
|
105
|
-
get number(): BlockNumber;
|
|
106
|
-
get slot(): SlotNumber;
|
|
107
|
-
get timestamp(): bigint;
|
|
108
|
-
/**
|
|
109
|
-
* Returns the block's hash (hash of block header).
|
|
110
|
-
* @returns The block's hash.
|
|
111
|
-
*/
|
|
112
|
-
hash(): Promise<Fr>;
|
|
113
|
-
/**
|
|
114
|
-
* @deprecated
|
|
115
|
-
* This only works when there's one block per checkpoint.
|
|
116
|
-
* TODO(#17027): Remove this method from L2Block and create a dedicated Checkpoint class.
|
|
117
|
-
*/
|
|
118
|
-
getCheckpointHeader(): import("../rollup/checkpoint_header.js").CheckpointHeader;
|
|
119
|
-
getBlockHeader(): BlockHeader;
|
|
120
|
-
toL2Block(args?: {
|
|
121
|
-
checkpointNumber?: CheckpointNumber;
|
|
122
|
-
indexWithinCheckpoint?: number;
|
|
123
|
-
}): L2BlockNew;
|
|
124
|
-
toCheckpoint(): Checkpoint;
|
|
125
|
-
static fromCheckpoint(checkpoint: Checkpoint): L2Block;
|
|
126
|
-
/**
|
|
127
|
-
* @deprecated
|
|
128
|
-
* This only works when there's one block per checkpoint.
|
|
129
|
-
* TODO(#17027): Remove this method from L2Block and create a dedicated Checkpoint class.
|
|
130
|
-
*/
|
|
131
|
-
getCheckpointBlobFields(): Fr[];
|
|
132
|
-
toBlobFields(): Fr[];
|
|
133
|
-
toBlockBlobData(): BlockBlobData;
|
|
134
|
-
/**
|
|
135
|
-
* Returns stats used for logging.
|
|
136
|
-
* @returns Stats on tx count, number, and log size and count.
|
|
137
|
-
*/
|
|
138
|
-
getStats(): {
|
|
139
|
-
privateLogCount: number;
|
|
140
|
-
publicLogCount: number;
|
|
141
|
-
contractClassLogCount: number;
|
|
142
|
-
contractClassLogSize: number;
|
|
143
|
-
txCount: number;
|
|
144
|
-
blockNumber: BlockNumber;
|
|
145
|
-
blockTimestamp: number;
|
|
146
|
-
};
|
|
147
|
-
toBlockInfo(): L2BlockInfo;
|
|
148
|
-
equals(other: L2Block): boolean;
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfYmxvY2suZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ibG9jay9sMl9ibG9jay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxhQUFhLEVBQTJELE1BQU0sMEJBQTBCLENBQUM7QUFDdkgsT0FBTyxFQUFFLFdBQVcsRUFBRSxnQkFBZ0IsRUFBRSxVQUFVLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM1RixPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUFFLFlBQVksRUFBcUIsTUFBTSw2QkFBNkIsQ0FBQztBQUc5RSxPQUFPLEVBQUUsQ0FBQyxFQUFFLE1BQU0sS0FBSyxDQUFDO0FBRXhCLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUN6RCxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSx1Q0FBdUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUN6RCxPQUFPLEVBQUUsSUFBSSxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBRWpDLE9BQU8sRUFBRSxhQUFhLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUN0RCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sbUJBQW1CLENBQ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MAAM,CAEjB;IAED;;;;;;;;OAQG;IACH,OAAa,MAAM,CACjB,UAAU,EAAE,WAAW,EACvB,WAAW,SAAI,EACf,mBAAmB,SAAI,EACvB,oBAAoB,SAAI,EACxB,MAAM,GAAE,EAAE,GAAG,SAAqB,EAClC,UAAU,GAAE,MAAM,GAAG,SAAqB,EAC1C,UAAU,GAAE,MAAM,GAAG,SAAqB,GACzC,OAAO,CAAC,OAAO,CAAC,CAQlB;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAE5C;IAED,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,IAAI,IAAI,IAAI,UAAU,CAErB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,EAAE,CAAC,CAK/B;IAED;;;;OAIG;IACI,mBAAmB,8DAEzB;IAGM,cAAc,IAAI,WAAW,CAEnC;IAEM,SAAS,CAAC,IAAI,GAAE;QAAE,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QAAC,qBAAqB,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,UAAU,CAQ/G;IAEM,YAAY,eAOlB;IAED,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,UAAU,WAgB3C;IAED;;;;OAIG;IACI,uBAAuB,SAG7B;IAEM,YAAY,IAAI,EAAE,EAAE,CAG1B;IAEM,eAAe,IAAI,aAAa,CAuBtC;IAED;;;OAGG;IACH,QAAQ;;;;;;;;MAqBP;IAED,WAAW,IAAI,WAAW,CAUzB;IAED,MAAM,CAAC,KAAK,EAAE,OAAO,WAEpB;CACF"}
|
package/dest/block/l2_block.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { encodeBlockBlobData, encodeCheckpointBlobDataFromBlocks } from '@aztec/blob-lib/encoding';
|
|
2
|
-
import { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
|
-
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
7
|
-
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
8
|
-
import { Body } from './body.js';
|
|
9
|
-
import { makeAppendOnlyTreeSnapshot, makeL2BlockHeader } from './l2_block_code_to_purge.js';
|
|
10
|
-
import { L2BlockHeader } from './l2_block_header.js';
|
|
11
|
-
import { L2BlockNew } from './l2_block_new.js';
|
|
12
|
-
/**
|
|
13
|
-
* The data that makes up the rollup proof, with encoder decoder functions.
|
|
14
|
-
*
|
|
15
|
-
* @deprecated Use `L2BlockNew` instead.
|
|
16
|
-
*/ export class L2Block {
|
|
17
|
-
archive;
|
|
18
|
-
header;
|
|
19
|
-
body;
|
|
20
|
-
blockHash;
|
|
21
|
-
constructor(/** Snapshot of archive tree after the block is applied. */ archive, /** L2 block header. */ header, /** L2 block body. */ body, blockHash = undefined){
|
|
22
|
-
this.archive = archive;
|
|
23
|
-
this.header = header;
|
|
24
|
-
this.body = body;
|
|
25
|
-
this.blockHash = blockHash;
|
|
26
|
-
}
|
|
27
|
-
static get schema() {
|
|
28
|
-
return z.object({
|
|
29
|
-
archive: AppendOnlyTreeSnapshot.schema,
|
|
30
|
-
header: L2BlockHeader.schema,
|
|
31
|
-
body: Body.schema
|
|
32
|
-
}).transform(({ archive, header, body })=>new L2Block(archive, header, body));
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Deserializes a block from a buffer
|
|
36
|
-
* @returns A deserialized L2 block.
|
|
37
|
-
*/ static fromBuffer(buf) {
|
|
38
|
-
const reader = BufferReader.asReader(buf);
|
|
39
|
-
const header = reader.readObject(L2BlockHeader);
|
|
40
|
-
const archive = reader.readObject(AppendOnlyTreeSnapshot);
|
|
41
|
-
const body = reader.readObject(Body);
|
|
42
|
-
return new L2Block(archive, header, body);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Serializes a block
|
|
46
|
-
* @returns A serialized L2 block as a Buffer.
|
|
47
|
-
*/ toBuffer() {
|
|
48
|
-
return serializeToBuffer(this.header, this.archive, this.body);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Deserializes L2 block from a buffer.
|
|
52
|
-
* @param str - A serialized L2 block.
|
|
53
|
-
* @returns Deserialized L2 block.
|
|
54
|
-
*/ static fromString(str) {
|
|
55
|
-
return L2Block.fromBuffer(hexToBuffer(str));
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Serializes a block to a string.
|
|
59
|
-
* @returns A serialized L2 block as a string.
|
|
60
|
-
*/ toString() {
|
|
61
|
-
return bufferToHex(this.toBuffer());
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Creates an L2 block containing random data.
|
|
65
|
-
* @param l2BlockNum - The number of the L2 block.
|
|
66
|
-
* @param txsPerBlock - The number of transactions to include in the block.
|
|
67
|
-
* @param numPublicCallsPerTx - The number of public function calls to include in each transaction.
|
|
68
|
-
* @param numPublicLogsPerCall - The number of public logs per 1 public function invocation.
|
|
69
|
-
* @param inHash - The hash of the L1 to L2 messages subtree which got inserted in this block.
|
|
70
|
-
* @returns The L2 block.
|
|
71
|
-
*/ static async random(l2BlockNum, txsPerBlock = 4, numPublicCallsPerTx = 3, numPublicLogsPerCall = 1, inHash = undefined, slotNumber = undefined, maxEffects = undefined) {
|
|
72
|
-
const body = await Body.random({
|
|
73
|
-
txsPerBlock,
|
|
74
|
-
numPublicCallsPerTx,
|
|
75
|
-
numPublicLogsPerCall,
|
|
76
|
-
maxEffects
|
|
77
|
-
});
|
|
78
|
-
return new L2Block(makeAppendOnlyTreeSnapshot(l2BlockNum + 1), makeL2BlockHeader(0, l2BlockNum, slotNumber ?? l2BlockNum, {
|
|
79
|
-
inHash
|
|
80
|
-
}), body);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Creates an L2 block containing empty data.
|
|
84
|
-
* @param header - An optional header to assign to the block
|
|
85
|
-
* @returns The L2 block.
|
|
86
|
-
*/ static empty(header) {
|
|
87
|
-
return new L2Block(AppendOnlyTreeSnapshot.empty(), header ?? L2BlockHeader.empty(), Body.empty());
|
|
88
|
-
}
|
|
89
|
-
get number() {
|
|
90
|
-
return this.header.getBlockNumber();
|
|
91
|
-
}
|
|
92
|
-
get slot() {
|
|
93
|
-
return this.header.getSlot();
|
|
94
|
-
}
|
|
95
|
-
get timestamp() {
|
|
96
|
-
return this.header.globalVariables.timestamp;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Returns the block's hash (hash of block header).
|
|
100
|
-
* @returns The block's hash.
|
|
101
|
-
*/ async hash() {
|
|
102
|
-
if (this.blockHash === undefined) {
|
|
103
|
-
this.blockHash = await this.getBlockHeader().hash();
|
|
104
|
-
}
|
|
105
|
-
return this.blockHash;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* @deprecated
|
|
109
|
-
* This only works when there's one block per checkpoint.
|
|
110
|
-
* TODO(#17027): Remove this method from L2Block and create a dedicated Checkpoint class.
|
|
111
|
-
*/ getCheckpointHeader() {
|
|
112
|
-
return this.header.toCheckpointHeader();
|
|
113
|
-
}
|
|
114
|
-
// Temporary helper to get the actual block header.
|
|
115
|
-
getBlockHeader() {
|
|
116
|
-
return this.header.toBlockHeader();
|
|
117
|
-
}
|
|
118
|
-
toL2Block(args = {}) {
|
|
119
|
-
return new L2BlockNew(this.archive, this.getBlockHeader(), this.body, args?.checkpointNumber ?? CheckpointNumber.fromBlockNumber(this.number), args?.indexWithinCheckpoint ?? 0);
|
|
120
|
-
}
|
|
121
|
-
toCheckpoint() {
|
|
122
|
-
return new Checkpoint(this.archive, this.getCheckpointHeader(), [
|
|
123
|
-
this.toL2Block()
|
|
124
|
-
], CheckpointNumber.fromBlockNumber(this.number));
|
|
125
|
-
}
|
|
126
|
-
static fromCheckpoint(checkpoint) {
|
|
127
|
-
const checkpointHeader = checkpoint.header;
|
|
128
|
-
const block = checkpoint.blocks.at(-1);
|
|
129
|
-
const header = new L2BlockHeader(new AppendOnlyTreeSnapshot(checkpointHeader.lastArchiveRoot, block.number), checkpointHeader.blobsHash, checkpointHeader.inHash, checkpointHeader.epochOutHash, block.header.state, block.header.globalVariables, block.header.totalFees, checkpointHeader.totalManaUsed, block.header.spongeBlobHash, checkpointHeader.blockHeadersHash);
|
|
130
|
-
return new L2Block(checkpoint.archive, header, block.body);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* @deprecated
|
|
134
|
-
* This only works when there's one block per checkpoint.
|
|
135
|
-
* TODO(#17027): Remove this method from L2Block and create a dedicated Checkpoint class.
|
|
136
|
-
*/ getCheckpointBlobFields() {
|
|
137
|
-
const blockBlobData = this.toBlockBlobData();
|
|
138
|
-
return encodeCheckpointBlobDataFromBlocks([
|
|
139
|
-
blockBlobData
|
|
140
|
-
]);
|
|
141
|
-
}
|
|
142
|
-
toBlobFields() {
|
|
143
|
-
const blockBlobData = this.toBlockBlobData();
|
|
144
|
-
return encodeBlockBlobData(blockBlobData);
|
|
145
|
-
}
|
|
146
|
-
toBlockBlobData() {
|
|
147
|
-
// There's only one L2Block per checkpoint, so it's always the first block in the checkpoint.
|
|
148
|
-
const isFirstBlock = true;
|
|
149
|
-
return {
|
|
150
|
-
blockEndMarker: {
|
|
151
|
-
numTxs: this.body.txEffects.length,
|
|
152
|
-
timestamp: this.header.globalVariables.timestamp,
|
|
153
|
-
blockNumber: this.number
|
|
154
|
-
},
|
|
155
|
-
blockEndStateField: {
|
|
156
|
-
l1ToL2MessageNextAvailableLeafIndex: this.header.state.l1ToL2MessageTree.nextAvailableLeafIndex,
|
|
157
|
-
noteHashNextAvailableLeafIndex: this.header.state.partial.noteHashTree.nextAvailableLeafIndex,
|
|
158
|
-
nullifierNextAvailableLeafIndex: this.header.state.partial.nullifierTree.nextAvailableLeafIndex,
|
|
159
|
-
publicDataNextAvailableLeafIndex: this.header.state.partial.publicDataTree.nextAvailableLeafIndex,
|
|
160
|
-
totalManaUsed: this.header.totalManaUsed.toBigInt()
|
|
161
|
-
},
|
|
162
|
-
lastArchiveRoot: this.header.lastArchive.root,
|
|
163
|
-
noteHashRoot: this.header.state.partial.noteHashTree.root,
|
|
164
|
-
nullifierRoot: this.header.state.partial.nullifierTree.root,
|
|
165
|
-
publicDataRoot: this.header.state.partial.publicDataTree.root,
|
|
166
|
-
l1ToL2MessageRoot: isFirstBlock ? this.header.state.l1ToL2MessageTree.root : undefined,
|
|
167
|
-
txs: this.body.toTxBlobData()
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Returns stats used for logging.
|
|
172
|
-
* @returns Stats on tx count, number, and log size and count.
|
|
173
|
-
*/ getStats() {
|
|
174
|
-
const logsStats = {
|
|
175
|
-
privateLogCount: this.body.txEffects.reduce((logCount, txEffect)=>logCount + txEffect.privateLogs.length, 0),
|
|
176
|
-
publicLogCount: this.body.txEffects.reduce((logCount, txEffect)=>logCount + txEffect.publicLogs.length, 0),
|
|
177
|
-
contractClassLogCount: this.body.txEffects.reduce((logCount, txEffect)=>logCount + txEffect.contractClassLogs.length, 0),
|
|
178
|
-
contractClassLogSize: this.body.txEffects.reduce((totalLogSize, txEffect)=>totalLogSize + txEffect.contractClassLogs.reduce((acc, log)=>acc + log.emittedLength, 0), 0)
|
|
179
|
-
};
|
|
180
|
-
return {
|
|
181
|
-
txCount: this.body.txEffects.length,
|
|
182
|
-
blockNumber: this.number,
|
|
183
|
-
blockTimestamp: Number(this.header.globalVariables.timestamp),
|
|
184
|
-
...logsStats
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
toBlockInfo() {
|
|
188
|
-
return {
|
|
189
|
-
blockHash: this.blockHash,
|
|
190
|
-
archive: this.archive.root,
|
|
191
|
-
lastArchive: this.header.lastArchive.root,
|
|
192
|
-
blockNumber: this.number,
|
|
193
|
-
slotNumber: this.header.getSlot(),
|
|
194
|
-
txCount: this.body.txEffects.length,
|
|
195
|
-
timestamp: this.header.globalVariables.timestamp
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
equals(other) {
|
|
199
|
-
return this.archive.equals(other.archive) && this.header.equals(other.header) && this.body.equals(other.body);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
-
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
3
|
-
import { L2BlockHeader } from './l2_block_header.js';
|
|
4
|
-
export declare function makeL2BlockHeader(seed?: number, blockNumber?: number, slotNumber?: number, overrides?: Partial<FieldsOf<L2BlockHeader>>): L2BlockHeader;
|
|
5
|
-
/**
|
|
6
|
-
* Makes arbitrary append only tree snapshot.
|
|
7
|
-
* @param seed - The seed to use for generating the append only tree snapshot.
|
|
8
|
-
* @returns An append only tree snapshot.
|
|
9
|
-
*/
|
|
10
|
-
export declare function makeAppendOnlyTreeSnapshot(seed?: number): AppendOnlyTreeSnapshot;
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfYmxvY2tfY29kZV90b19wdXJnZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Jsb2NrL2wyX2Jsb2NrX2NvZGVfdG9fcHVyZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBSUEsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFJeEQsT0FBTyxFQUFFLHNCQUFzQixFQUFFLE1BQU0sdUNBQXVDLENBQUM7QUFJL0UsT0FBTyxFQUFFLGFBQWEsRUFBRSxNQUFNLHNCQUFzQixDQUFDO0FBRXJELHdCQUFnQixpQkFBaUIsQ0FDL0IsSUFBSSxTQUFJLEVBQ1IsV0FBVyxDQUFDLEVBQUUsTUFBTSxFQUNwQixVQUFVLENBQUMsRUFBRSxNQUFNLEVBQ25CLFNBQVMsR0FBRSxPQUFPLENBQUMsUUFBUSxDQUFDLGFBQWEsQ0FBQyxDQUFNLGlCQWlCakQ7QUFFRDs7OztHQUlHO0FBQ0gsd0JBQWdCLDBCQUEwQixDQUFDLElBQUksU0FBSSxHQUFHLHNCQUFzQixDQUUzRSJ9
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"l2_block_code_to_purge.d.ts","sourceRoot":"","sources":["../../src/block/l2_block_code_to_purge.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAI/E,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,wBAAgB,iBAAiB,CAC/B,IAAI,SAAI,EACR,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,SAAS,GAAE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAM,iBAiBjD;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,SAAI,GAAG,sBAAsB,CAE3E"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import { compact } from '@aztec/foundation/collection';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
-
import { AztecAddress } from '../aztec-address/index.js';
|
|
6
|
-
import { GasFees } from '../gas/gas_fees.js';
|
|
7
|
-
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
8
|
-
import { GlobalVariables } from '../tx/global_variables.js';
|
|
9
|
-
import { PartialStateReference } from '../tx/partial_state_reference.js';
|
|
10
|
-
import { StateReference } from '../tx/state_reference.js';
|
|
11
|
-
import { L2BlockHeader } from './l2_block_header.js';
|
|
12
|
-
export function makeL2BlockHeader(seed = 0, blockNumber, slotNumber, overrides = {}) {
|
|
13
|
-
return new L2BlockHeader(makeAppendOnlyTreeSnapshot(seed + 0x100), overrides.blobsHash ?? new Fr(seed + 0x200), overrides.inHash ?? new Fr(seed + 0x300), overrides.epochOutHash ?? new Fr(seed + 0x400), overrides.state ?? makeStateReference(seed + 0x600), makeGlobalVariables(seed += 0x700, {
|
|
14
|
-
...blockNumber ? {
|
|
15
|
-
blockNumber: BlockNumber(blockNumber)
|
|
16
|
-
} : {},
|
|
17
|
-
...slotNumber ? {
|
|
18
|
-
slotNumber: SlotNumber(slotNumber)
|
|
19
|
-
} : {}
|
|
20
|
-
}), new Fr(seed + 0x300), new Fr(seed + 0x800), new Fr(seed + 0x900), new Fr(seed + 0xa00));
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Makes arbitrary append only tree snapshot.
|
|
24
|
-
* @param seed - The seed to use for generating the append only tree snapshot.
|
|
25
|
-
* @returns An append only tree snapshot.
|
|
26
|
-
*/ export function makeAppendOnlyTreeSnapshot(seed = 1) {
|
|
27
|
-
return new AppendOnlyTreeSnapshot(new Fr(seed), seed);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Makes arbitrary state reference.
|
|
31
|
-
* @param seed - The seed to use for generating the state reference.
|
|
32
|
-
* @returns A state reference.
|
|
33
|
-
*/ function makeStateReference(seed = 0) {
|
|
34
|
-
return new StateReference(makeAppendOnlyTreeSnapshot(seed), makePartialStateReference(seed + 1));
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Makes arbitrary partial state reference.
|
|
38
|
-
* @param seed - The seed to use for generating the partial state reference.
|
|
39
|
-
* @returns A partial state reference.
|
|
40
|
-
*/ function makePartialStateReference(seed = 0) {
|
|
41
|
-
return new PartialStateReference(makeAppendOnlyTreeSnapshot(seed), makeAppendOnlyTreeSnapshot(seed + 1), makeAppendOnlyTreeSnapshot(seed + 2));
|
|
42
|
-
}
|
|
43
|
-
function makeGlobalVariables(seed = 1, overrides = {}) {
|
|
44
|
-
return GlobalVariables.from({
|
|
45
|
-
chainId: new Fr(seed),
|
|
46
|
-
version: new Fr(seed + 1),
|
|
47
|
-
blockNumber: BlockNumber(seed + 2),
|
|
48
|
-
slotNumber: SlotNumber(seed + 3),
|
|
49
|
-
timestamp: BigInt(seed + 4),
|
|
50
|
-
coinbase: EthAddress.fromField(new Fr(seed + 5)),
|
|
51
|
-
feeRecipient: AztecAddress.fromField(new Fr(seed + 6)),
|
|
52
|
-
gasFees: new GasFees(seed + 7, seed + 8),
|
|
53
|
-
...compact(overrides)
|
|
54
|
-
});
|
|
55
|
-
}
|