@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAc,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/tests/mocks.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,QAAQ,EAAa,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,qBAAqB,EAAc,MAAM,iCAAiC,CAAC;AAInH,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAC5E,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAwB,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1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AE,EAAE,EAAE,CAAC;KACZ,CAAC;CACH;AAqBD,eAAO,MAAM,0CAA0C,kGAStD,CAAC;AAEF,eAAO,MAAM,iBAAiB,4EAkB7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,sFAmBlC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,OAAO,CAAC,EAAE,EAAE,CAAC;IACb,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,uEA0BrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qCAAqC,uGAgBjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uCAAuC,+IASnD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kCAAkC,0IAe9C,CAAC;AAEF,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,eAAe,EAAE,CAAA;CAAO,GACzC,OAAO,CAAC,mBAAmB,CAAC,CAsB9B"}
|
package/dest/tests/mocks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FIXED_DA_GAS, FIXED_L2_GAS, MAX_ENQUEUED_CALLS_PER_TX, MAX_INCLUDE_BY_TIMESTAMP_DURATION, MAX_NULLIFIERS_PER_TX, MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX } from '@aztec/constants';
|
|
2
2
|
import { makeTuple } from '@aztec/foundation/array';
|
|
3
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
4
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
5
5
|
import { padArrayEnd, times } from '@aztec/foundation/collection';
|
|
6
6
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
@@ -12,8 +12,7 @@ import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
|
|
|
12
12
|
import { PublicDataWrite } from '../avm/public_data_write.js';
|
|
13
13
|
import { RevertCode } from '../avm/revert_code.js';
|
|
14
14
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
15
|
-
import { CommitteeAttestation, L2BlockNew
|
|
16
|
-
import { L2Block } from '../block/l2_block.js';
|
|
15
|
+
import { CheckpointedL2Block, CommitteeAttestation, L2BlockNew } from '../block/index.js';
|
|
17
16
|
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
18
17
|
import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
|
|
19
18
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
@@ -37,13 +36,14 @@ import { ConsensusPayload } from '../p2p/consensus_payload.js';
|
|
|
37
36
|
import { SignatureDomainSeparator, getHashedSignaturePayloadEthSignedMessage } from '../p2p/signature_utils.js';
|
|
38
37
|
import { ChonkProof } from '../proofs/chonk_proof.js';
|
|
39
38
|
import { ProvingRequestType } from '../proofs/proving_request_type.js';
|
|
39
|
+
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
40
40
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
41
41
|
import { GlobalVariables, HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, TxConstantData, makeProcessedTxFromPrivateOnlyTx, makeProcessedTxFromTxWithPublicCalls } from '../tx/index.js';
|
|
42
42
|
import { NestedProcessReturnValues, PublicSimulationOutput } from '../tx/public_simulation_output.js';
|
|
43
43
|
import { TxSimulationResult } from '../tx/simulated_tx.js';
|
|
44
44
|
import { TxEffect } from '../tx/tx_effect.js';
|
|
45
45
|
import { TxHash } from '../tx/tx_hash.js';
|
|
46
|
-
import { makeAvmCircuitInputs, makeAztecAddress, makeBlockHeader, makeGas, makeGlobalVariables,
|
|
46
|
+
import { makeAvmCircuitInputs, makeAztecAddress, makeBlockHeader, makeCheckpointHeader, makeGas, makeGlobalVariables, makePrivateToPublicAccumulatedData, makePrivateToRollupAccumulatedData, makeProtocolContracts, makePublicCallRequest, makePublicDataWrite } from './factories.js';
|
|
47
47
|
export const randomTxHash = ()=>TxHash.random();
|
|
48
48
|
export const mockTx = async (seed = 1, { numberOfNonRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2, numberOfRevertiblePublicCallRequests = MAX_ENQUEUED_CALLS_PER_TX / 2, numberOfRevertibleNullifiers = 0, hasPublicTeardownCallRequest = false, publicCalldataSize = 2, feePayer, chonkProof = ChonkProof.random(), maxPriorityFeesPerGas, gasUsed = Gas.empty(), chainId = Fr.ZERO, version = Fr.ZERO, vkTreeRoot = Fr.ZERO, protocolContractsHash = Fr.ZERO } = {})=>{
|
|
49
49
|
const totalPublicCallRequests = numberOfNonRevertiblePublicCallRequests + numberOfRevertiblePublicCallRequests + (hasPublicTeardownCallRequest ? 1 : 0);
|
|
@@ -223,7 +223,7 @@ export async function mockCheckpointAndMessages(checkpointNumber, { startBlockNu
|
|
|
223
223
|
const { block, messages } = {
|
|
224
224
|
block: blocks?.[i] ?? await L2BlockNew.random(blockNumber, {
|
|
225
225
|
checkpointNumber,
|
|
226
|
-
indexWithinCheckpoint: i,
|
|
226
|
+
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
227
227
|
txsPerBlock: numTxsPerBlock,
|
|
228
228
|
slotNumber,
|
|
229
229
|
...options,
|
|
@@ -291,16 +291,16 @@ export const randomDeployedContract = async ()=>{
|
|
|
291
291
|
};
|
|
292
292
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
293
293
|
const makeAndSignConsensusPayload = (domainSeparator, options)=>{
|
|
294
|
-
const header = options?.header ??
|
|
294
|
+
const header = options?.header ?? makeCheckpointHeader(1);
|
|
295
295
|
const { signer = Secp256k1Signer.random(), archive = Fr.random() } = options ?? {};
|
|
296
296
|
const payload = ConsensusPayload.fromFields({
|
|
297
|
-
header
|
|
297
|
+
header,
|
|
298
298
|
archive
|
|
299
299
|
});
|
|
300
300
|
const hash = getHashedSignaturePayloadEthSignedMessage(payload, domainSeparator);
|
|
301
301
|
const signature = signer.sign(hash);
|
|
302
302
|
return {
|
|
303
|
-
blockNumber: header.
|
|
303
|
+
blockNumber: header.slotNumber,
|
|
304
304
|
payload,
|
|
305
305
|
signature
|
|
306
306
|
};
|
|
@@ -310,9 +310,8 @@ export const makeAndSignCommitteeAttestationsAndSigners = (attestationsAndSigner
|
|
|
310
310
|
return signer.sign(hash);
|
|
311
311
|
};
|
|
312
312
|
export const makeBlockProposal = (options)=>{
|
|
313
|
-
const
|
|
314
|
-
const
|
|
315
|
-
const indexWithinCheckpoint = options?.indexWithinCheckpoint ?? 0;
|
|
313
|
+
const blockHeader = options?.blockHeader ?? makeBlockHeader(1);
|
|
314
|
+
const indexWithinCheckpoint = options?.indexWithinCheckpoint ?? IndexWithinCheckpoint(0);
|
|
316
315
|
const inHash = options?.inHash ?? Fr.random();
|
|
317
316
|
const archiveRoot = options?.archiveRoot ?? Fr.random();
|
|
318
317
|
const txHashes = options?.txHashes ?? [
|
|
@@ -328,14 +327,14 @@ export const makeBlockProposal = (options)=>{
|
|
|
328
327
|
return BlockProposal.createProposalFromSigner(blockHeader, indexWithinCheckpoint, inHash, archiveRoot, txHashes, txs, (_payload, _context)=>Promise.resolve(signer.signMessage(_payload)));
|
|
329
328
|
};
|
|
330
329
|
export const makeCheckpointProposal = (options)=>{
|
|
331
|
-
const
|
|
332
|
-
const checkpointHeader = options?.checkpointHeader ??
|
|
330
|
+
const blockHeader = options?.lastBlock?.blockHeader ?? makeBlockHeader(1);
|
|
331
|
+
const checkpointHeader = options?.checkpointHeader ?? makeCheckpointHeader(1);
|
|
333
332
|
const archiveRoot = options?.archiveRoot ?? Fr.random();
|
|
334
333
|
const signer = options?.signer ?? Secp256k1Signer.random();
|
|
335
334
|
// Build lastBlock info if provided
|
|
336
335
|
const lastBlockInfo = options?.lastBlock ? {
|
|
337
|
-
blockHeader
|
|
338
|
-
indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? 4,
|
|
336
|
+
blockHeader,
|
|
337
|
+
indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4),
|
|
339
338
|
txHashes: options.lastBlock.txHashes ?? [
|
|
340
339
|
0,
|
|
341
340
|
1,
|
|
@@ -351,7 +350,7 @@ export const makeCheckpointProposal = (options)=>{
|
|
|
351
350
|
/**
|
|
352
351
|
* Create a checkpoint attestation for testing
|
|
353
352
|
*/ export const makeCheckpointAttestation = (options = {})=>{
|
|
354
|
-
const header = options.header ??
|
|
353
|
+
const header = options.header ?? makeCheckpointHeader(1);
|
|
355
354
|
const archive = options.archive ?? Fr.random();
|
|
356
355
|
const { signer, attesterSigner = signer, proposerSigner = signer } = options;
|
|
357
356
|
const payload = new ConsensusPayload(header, archive);
|
|
@@ -391,9 +390,16 @@ export const makeCheckpointProposal = (options)=>{
|
|
|
391
390
|
});
|
|
392
391
|
};
|
|
393
392
|
/**
|
|
394
|
-
* Create a checkpoint attestation from an
|
|
393
|
+
* Create a checkpoint attestation from an L2BlockNew
|
|
394
|
+
* Note: This is a compatibility function for tests. L2BlockNew doesn't have a checkpoint header directly.
|
|
395
395
|
*/ export const makeCheckpointAttestationFromBlock = (block, attesterSigner, proposerSigner)=>{
|
|
396
|
-
|
|
396
|
+
// For L2BlockNew, we create a minimal checkpoint header for testing purposes
|
|
397
|
+
const header = CheckpointHeader.empty({
|
|
398
|
+
lastArchiveRoot: block.header.lastArchive.root,
|
|
399
|
+
slotNumber: block.slot,
|
|
400
|
+
timestamp: block.timestamp,
|
|
401
|
+
blockHeadersHash: Fr.ZERO
|
|
402
|
+
});
|
|
397
403
|
const archive = block.archive.root;
|
|
398
404
|
return makeCheckpointAttestation({
|
|
399
405
|
header,
|
|
@@ -403,18 +409,24 @@ export const makeCheckpointProposal = (options)=>{
|
|
|
403
409
|
});
|
|
404
410
|
};
|
|
405
411
|
export async function randomPublishedL2Block(l2BlockNumber, opts = {}) {
|
|
406
|
-
const block = await
|
|
412
|
+
const block = await L2BlockNew.random(BlockNumber(l2BlockNumber));
|
|
407
413
|
const l1 = L1PublishedData.fromFields({
|
|
408
414
|
blockNumber: BigInt(block.number),
|
|
409
415
|
timestamp: block.header.globalVariables.timestamp,
|
|
410
416
|
blockHash: Buffer32.random().toString()
|
|
411
417
|
});
|
|
412
418
|
const signers = opts.signers ?? times(3, ()=>Secp256k1Signer.random());
|
|
419
|
+
const checkpoint = await Checkpoint.random(CheckpointNumber(l2BlockNumber), {
|
|
420
|
+
numBlocks: 0
|
|
421
|
+
});
|
|
422
|
+
checkpoint.blocks = [
|
|
423
|
+
block
|
|
424
|
+
];
|
|
413
425
|
const atts = signers.map((signer)=>makeCheckpointAttestation({
|
|
414
426
|
signer,
|
|
415
427
|
archive: block.archive.root,
|
|
416
|
-
header:
|
|
428
|
+
header: checkpoint.header
|
|
417
429
|
}));
|
|
418
430
|
const attestations = atts.map((attestation, i)=>new CommitteeAttestation(signers[i].address, attestation.signature));
|
|
419
|
-
return new
|
|
431
|
+
return new CheckpointedL2Block(CheckpointNumber(l2BlockNumber), block, l1, attestations);
|
|
420
432
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "4.0.0-nightly.
|
|
3
|
+
"version": "4.0.0-nightly.20260121",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -78,14 +78,14 @@
|
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
81
|
-
"@aztec/bb.js": "4.0.0-nightly.
|
|
82
|
-
"@aztec/blob-lib": "4.0.0-nightly.
|
|
83
|
-
"@aztec/constants": "4.0.0-nightly.
|
|
84
|
-
"@aztec/ethereum": "4.0.0-nightly.
|
|
85
|
-
"@aztec/foundation": "4.0.0-nightly.
|
|
86
|
-
"@aztec/l1-artifacts": "4.0.0-nightly.
|
|
87
|
-
"@aztec/noir-noirc_abi": "4.0.0-nightly.
|
|
88
|
-
"@aztec/validator-ha-signer": "4.0.0-nightly.
|
|
81
|
+
"@aztec/bb.js": "4.0.0-nightly.20260121",
|
|
82
|
+
"@aztec/blob-lib": "4.0.0-nightly.20260121",
|
|
83
|
+
"@aztec/constants": "4.0.0-nightly.20260121",
|
|
84
|
+
"@aztec/ethereum": "4.0.0-nightly.20260121",
|
|
85
|
+
"@aztec/foundation": "4.0.0-nightly.20260121",
|
|
86
|
+
"@aztec/l1-artifacts": "4.0.0-nightly.20260121",
|
|
87
|
+
"@aztec/noir-noirc_abi": "4.0.0-nightly.20260121",
|
|
88
|
+
"@aztec/validator-ha-signer": "4.0.0-nightly.20260121",
|
|
89
89
|
"@google-cloud/storage": "^7.15.0",
|
|
90
90
|
"axios": "^1.12.0",
|
|
91
91
|
"json-stringify-deterministic": "1.0.12",
|
package/src/block/block_hash.ts
CHANGED
|
@@ -13,6 +13,28 @@ export class L2BlockHash extends Buffer32 {
|
|
|
13
13
|
super(hash);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Type guard that checks if a value is an L2BlockHash instance.
|
|
18
|
+
* Uses duck typing to handle cases where instanceof fails due to module duplication.
|
|
19
|
+
* Checks for Buffer32-like structure with a 32-byte buffer.
|
|
20
|
+
*/
|
|
21
|
+
static isL2BlockHash(value: unknown): value is L2BlockHash {
|
|
22
|
+
if (value instanceof L2BlockHash) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
// Duck typing fallback: check if it looks like a Buffer32 with a 32-byte buffer
|
|
26
|
+
// This helps when instanceof fails due to module duplication
|
|
27
|
+
return (
|
|
28
|
+
typeof value === 'object' &&
|
|
29
|
+
value !== null &&
|
|
30
|
+
'buffer' in value &&
|
|
31
|
+
Buffer.isBuffer((value as Buffer32).buffer) &&
|
|
32
|
+
(value as Buffer32).buffer.length === 32 &&
|
|
33
|
+
'toBuffer' in value &&
|
|
34
|
+
typeof (value as Buffer32).toBuffer === 'function'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
static override random() {
|
|
17
39
|
return new L2BlockHash(Fr.random().toBuffer());
|
|
18
40
|
}
|
|
@@ -2,7 +2,9 @@ import { BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { L2BlockHash } from './block_hash.js';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const BlockParameterSchema = z.union([L2BlockHash.schema, BlockNumberSchema, z.literal('latest')]);
|
|
8
|
+
|
|
9
|
+
/** Block parameter - either a specific BlockNumber, block hash (L2BlockHash), or 'latest' */
|
|
8
10
|
export type BlockParameter = z.infer<typeof BlockParameterSchema>;
|
|
@@ -5,9 +5,8 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
-
import { L1PublishedData
|
|
8
|
+
import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
|
|
9
9
|
import { MAX_BLOCK_HASH_STRING_LENGTH, MAX_COMMITTEE_SIZE } from '../deserialization/index.js';
|
|
10
|
-
import { L2Block } from './l2_block.js';
|
|
11
10
|
import { L2BlockNew } from './l2_block_new.js';
|
|
12
11
|
import { CommitteeAttestation } from './proposal/committee_attestation.js';
|
|
13
12
|
|
|
@@ -59,6 +58,7 @@ export class CheckpointedL2Block {
|
|
|
59
58
|
|
|
60
59
|
public toBuffer(): Buffer {
|
|
61
60
|
return serializeToBuffer(
|
|
61
|
+
this.checkpointNumber,
|
|
62
62
|
this.block,
|
|
63
63
|
this.l1.blockNumber,
|
|
64
64
|
this.l1.blockHash,
|
|
@@ -68,54 +68,3 @@ export class CheckpointedL2Block {
|
|
|
68
68
|
);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
export class PublishedL2Block {
|
|
73
|
-
constructor(
|
|
74
|
-
public block: L2Block,
|
|
75
|
-
public l1: L1PublishedData,
|
|
76
|
-
public attestations: CommitteeAttestation[],
|
|
77
|
-
) {}
|
|
78
|
-
|
|
79
|
-
static get schema() {
|
|
80
|
-
return z
|
|
81
|
-
.object({
|
|
82
|
-
block: L2Block.schema,
|
|
83
|
-
l1: L1PublishedData.schema,
|
|
84
|
-
attestations: z.array(CommitteeAttestation.schema),
|
|
85
|
-
})
|
|
86
|
-
.transform(obj => PublishedL2Block.fromFields(obj));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
static fromBuffer(bufferOrReader: Buffer | BufferReader): PublishedL2Block {
|
|
90
|
-
const reader = BufferReader.asReader(bufferOrReader);
|
|
91
|
-
const block = reader.readObject(L2Block);
|
|
92
|
-
const l1BlockNumber = reader.readBigInt();
|
|
93
|
-
const l1BlockHash = reader.readString(MAX_BLOCK_HASH_STRING_LENGTH);
|
|
94
|
-
const l1Timestamp = reader.readBigInt();
|
|
95
|
-
const attestations = reader.readVector(CommitteeAttestation, MAX_COMMITTEE_SIZE);
|
|
96
|
-
return new PublishedL2Block(block, new L1PublishedData(l1BlockNumber, l1Timestamp, l1BlockHash), attestations);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static fromFields(fields: FieldsOf<PublishedL2Block>) {
|
|
100
|
-
return new PublishedL2Block(fields.block, fields.l1, fields.attestations);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
public toBuffer(): Buffer {
|
|
104
|
-
return serializeToBuffer(
|
|
105
|
-
this.block,
|
|
106
|
-
this.l1.blockNumber,
|
|
107
|
-
this.l1.blockHash,
|
|
108
|
-
this.l1.timestamp,
|
|
109
|
-
this.attestations.length,
|
|
110
|
-
this.attestations,
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public toPublishedCheckpoint() {
|
|
115
|
-
return new PublishedCheckpoint(this.block.toCheckpoint(), this.l1, this.attestations);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
static fromPublishedCheckpoint(checkpoint: PublishedCheckpoint) {
|
|
119
|
-
return new PublishedL2Block(L2Block.fromCheckpoint(checkpoint.checkpoint), checkpoint.l1, checkpoint.attestations);
|
|
120
|
-
}
|
|
121
|
-
}
|
package/src/block/in_block.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types'
|
|
|
3
3
|
import { type ZodTypeAny, z } from 'zod';
|
|
4
4
|
|
|
5
5
|
import { L2BlockHash } from './block_hash.js';
|
|
6
|
-
import type {
|
|
6
|
+
import type { L2BlockNew } from './l2_block_new.js';
|
|
7
7
|
|
|
8
8
|
export type InBlock = {
|
|
9
9
|
l2BlockNumber: BlockNumber;
|
|
@@ -29,7 +29,7 @@ export function randomDataInBlock<T>(data: T): DataInBlock<T> {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export async function wrapDataInBlock<T>(data: T, block:
|
|
32
|
+
export async function wrapDataInBlock<T>(data: T, block: L2BlockNew): Promise<DataInBlock<T>> {
|
|
33
33
|
return {
|
|
34
34
|
data,
|
|
35
35
|
l2BlockNumber: block.number,
|
package/src/block/index.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { type BlockBlobData, encodeBlockBlobData } from '@aztec/blob-lib/encoding';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BlockNumber,
|
|
4
|
+
CheckpointNumber,
|
|
5
|
+
CheckpointNumberSchema,
|
|
6
|
+
IndexWithinCheckpoint,
|
|
7
|
+
IndexWithinCheckpointSchema,
|
|
8
|
+
SlotNumber,
|
|
9
|
+
} from '@aztec/foundation/branded-types';
|
|
3
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
11
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
12
|
|
|
@@ -30,7 +37,7 @@ export class L2BlockNew {
|
|
|
30
37
|
/** Number of the checkpoint that the block belongs to. */
|
|
31
38
|
public checkpointNumber: CheckpointNumber,
|
|
32
39
|
/** Index of the block within the checkpoint. */
|
|
33
|
-
public indexWithinCheckpoint:
|
|
40
|
+
public indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
34
41
|
) {}
|
|
35
42
|
|
|
36
43
|
get number(): BlockNumber {
|
|
@@ -52,7 +59,7 @@ export class L2BlockNew {
|
|
|
52
59
|
header: BlockHeader.schema,
|
|
53
60
|
body: Body.schema,
|
|
54
61
|
checkpointNumber: CheckpointNumberSchema,
|
|
55
|
-
indexWithinCheckpoint:
|
|
62
|
+
indexWithinCheckpoint: IndexWithinCheckpointSchema,
|
|
56
63
|
})
|
|
57
64
|
.transform(
|
|
58
65
|
({ archive, header, body, checkpointNumber, indexWithinCheckpoint }) =>
|
|
@@ -70,7 +77,7 @@ export class L2BlockNew {
|
|
|
70
77
|
const archive = reader.readObject(AppendOnlyTreeSnapshot);
|
|
71
78
|
const body = reader.readObject(Body);
|
|
72
79
|
const checkpointNumber = CheckpointNumber(reader.readNumber());
|
|
73
|
-
const indexWithinCheckpoint = reader.readNumber();
|
|
80
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(reader.readNumber());
|
|
74
81
|
|
|
75
82
|
return new L2BlockNew(archive, header, body, checkpointNumber, indexWithinCheckpoint);
|
|
76
83
|
}
|
|
@@ -141,7 +148,7 @@ export class L2BlockNew {
|
|
|
141
148
|
header ?? BlockHeader.empty(),
|
|
142
149
|
Body.empty(),
|
|
143
150
|
CheckpointNumber(0),
|
|
144
|
-
0,
|
|
151
|
+
IndexWithinCheckpoint(0),
|
|
145
152
|
);
|
|
146
153
|
}
|
|
147
154
|
|
|
@@ -158,14 +165,14 @@ export class L2BlockNew {
|
|
|
158
165
|
blockNumber: BlockNumber,
|
|
159
166
|
{
|
|
160
167
|
checkpointNumber = CheckpointNumber(Number(blockNumber)),
|
|
161
|
-
indexWithinCheckpoint = 0,
|
|
168
|
+
indexWithinCheckpoint = IndexWithinCheckpoint(0),
|
|
162
169
|
txsPerBlock = 1,
|
|
163
170
|
txOptions = {},
|
|
164
171
|
makeTxOptions,
|
|
165
172
|
...blockHeaderOverrides
|
|
166
173
|
}: {
|
|
167
174
|
checkpointNumber?: CheckpointNumber;
|
|
168
|
-
indexWithinCheckpoint?:
|
|
175
|
+
indexWithinCheckpoint?: IndexWithinCheckpoint;
|
|
169
176
|
txsPerBlock?: number;
|
|
170
177
|
txOptions?: Partial<Parameters<typeof Body.random>[0]>;
|
|
171
178
|
makeTxOptions?: (txIndex: number) => Partial<Parameters<typeof Body.random>[0]>;
|
|
@@ -20,8 +20,7 @@ import type { BlockHeader } from '../tx/block_header.js';
|
|
|
20
20
|
import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
21
21
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
22
22
|
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
23
|
-
import {
|
|
24
|
-
import type { L2Block } from './l2_block.js';
|
|
23
|
+
import type { CheckpointedL2Block } from './checkpointed_l2_block.js';
|
|
25
24
|
import type { L2BlockNew } from './l2_block_new.js';
|
|
26
25
|
import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
|
|
27
26
|
|
|
@@ -105,6 +104,20 @@ export interface L2BlockSource {
|
|
|
105
104
|
*/
|
|
106
105
|
getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined>;
|
|
107
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Gets an L2 block by its hash.
|
|
109
|
+
* @param blockHash - The block hash to retrieve.
|
|
110
|
+
* @returns The requested L2 block (or undefined if not found).
|
|
111
|
+
*/
|
|
112
|
+
getL2BlockNewByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Gets an L2 block by its archive root.
|
|
116
|
+
* @param archive - The archive root to retrieve.
|
|
117
|
+
* @returns The requested L2 block (or undefined if not found).
|
|
118
|
+
*/
|
|
119
|
+
getL2BlockNewByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
|
|
120
|
+
|
|
108
121
|
/**
|
|
109
122
|
* Gets a tx effect.
|
|
110
123
|
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
@@ -179,11 +192,8 @@ export interface L2BlockSource {
|
|
|
179
192
|
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
180
193
|
* @param number - The block number to return (inclusive).
|
|
181
194
|
* @returns The requested L2 block.
|
|
182
|
-
* @deprecated Use getL2BlockNew instead.
|
|
183
195
|
*/
|
|
184
|
-
getBlock(number: BlockNumber): Promise<
|
|
185
|
-
|
|
186
|
-
getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined>;
|
|
196
|
+
getBlock(number: BlockNumber): Promise<L2BlockNew | undefined>;
|
|
187
197
|
|
|
188
198
|
getL2BlocksNew(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
|
|
189
199
|
|
|
@@ -192,7 +202,7 @@ export interface L2BlockSource {
|
|
|
192
202
|
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
193
203
|
* @param epochNumber - The epoch number to return blocks for.
|
|
194
204
|
*/
|
|
195
|
-
getBlocksForEpoch(epochNumber: EpochNumber): Promise<
|
|
205
|
+
getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2BlockNew[]>;
|
|
196
206
|
|
|
197
207
|
/**
|
|
198
208
|
* Returns all blocks for a given slot.
|
|
@@ -206,14 +216,14 @@ export interface L2BlockSource {
|
|
|
206
216
|
* @param blockHash - The block hash to retrieve.
|
|
207
217
|
* @returns The requested block (or undefined if not found).
|
|
208
218
|
*/
|
|
209
|
-
getPublishedBlockByHash(blockHash: Fr): Promise<
|
|
219
|
+
getPublishedBlockByHash(blockHash: Fr): Promise<CheckpointedL2Block | undefined>;
|
|
210
220
|
|
|
211
221
|
/**
|
|
212
222
|
* Gets a published block by its archive root.
|
|
213
223
|
* @param archive - The archive root to retrieve.
|
|
214
224
|
* @returns The requested block (or undefined if not found).
|
|
215
225
|
*/
|
|
216
|
-
getPublishedBlockByArchive(archive: Fr): Promise<
|
|
226
|
+
getPublishedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
|
|
217
227
|
|
|
218
228
|
/**
|
|
219
229
|
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
@@ -222,10 +232,10 @@ export interface L2BlockSource {
|
|
|
222
232
|
* @param proven - If true, only return blocks that have been proven.
|
|
223
233
|
* @returns The requested L2 blocks.
|
|
224
234
|
*/
|
|
225
|
-
getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<
|
|
235
|
+
getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2BlockNew[]>;
|
|
226
236
|
|
|
227
237
|
/** Equivalent to getBlocks but includes publish data. */
|
|
228
|
-
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<
|
|
238
|
+
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<CheckpointedL2Block[]>;
|
|
229
239
|
}
|
|
230
240
|
|
|
231
241
|
/**
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { encodeCheckpointBlobDataFromBlocks } from '@aztec/blob-lib/encoding';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BlockNumber,
|
|
4
|
+
CheckpointNumber,
|
|
5
|
+
CheckpointNumberSchema,
|
|
6
|
+
IndexWithinCheckpoint,
|
|
7
|
+
SlotNumber,
|
|
8
|
+
} from '@aztec/foundation/branded-types';
|
|
3
9
|
import { sum } from '@aztec/foundation/collection';
|
|
4
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
11
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
@@ -139,7 +145,7 @@ export class Checkpoint {
|
|
|
139
145
|
let lastArchive = previousArchive;
|
|
140
146
|
for (let i = 0; i < numBlocks; i++) {
|
|
141
147
|
const block = await L2BlockNew.random(BlockNumber(startBlockNumber + i), {
|
|
142
|
-
indexWithinCheckpoint: i,
|
|
148
|
+
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
143
149
|
...options,
|
|
144
150
|
...(lastArchive ? { lastArchive } : {}),
|
|
145
151
|
});
|
|
@@ -4,8 +4,7 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
|
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
|
-
import { CheckpointedL2Block
|
|
8
|
-
import { L2Block } from '../block/l2_block.js';
|
|
7
|
+
import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
|
|
9
8
|
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
10
9
|
import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
|
|
11
10
|
import { ValidateCheckpointResultSchema } from '../block/validate_block_result.js';
|
|
@@ -83,7 +82,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
83
82
|
getRegistryAddress: z.function().args().returns(schemas.EthAddress),
|
|
84
83
|
getBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
85
84
|
getProvenBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
86
|
-
getBlock: z.function().args(BlockNumberSchema).returns(
|
|
85
|
+
getBlock: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
|
|
87
86
|
getBlockHeader: z
|
|
88
87
|
.function()
|
|
89
88
|
.args(z.union([BlockNumberSchema, z.literal('latest')]))
|
|
@@ -96,7 +95,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
96
95
|
getBlocks: z
|
|
97
96
|
.function()
|
|
98
97
|
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
99
|
-
.returns(z.array(
|
|
98
|
+
.returns(z.array(L2BlockNew.schema)),
|
|
100
99
|
getPublishedCheckpoints: z
|
|
101
100
|
.function()
|
|
102
101
|
.args(CheckpointNumberSchema, schemas.Integer)
|
|
@@ -104,22 +103,24 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
104
103
|
getPublishedBlocks: z
|
|
105
104
|
.function()
|
|
106
105
|
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
107
|
-
.returns(z.array(
|
|
106
|
+
.returns(z.array(CheckpointedL2Block.schema)),
|
|
108
107
|
getL2BlocksNew: z
|
|
109
108
|
.function()
|
|
110
109
|
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
111
110
|
.returns(z.array(L2BlockNew.schema)),
|
|
112
|
-
getPublishedBlockByHash: z.function().args(schemas.Fr).returns(
|
|
113
|
-
getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(
|
|
111
|
+
getPublishedBlockByHash: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
|
|
112
|
+
getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
|
|
114
113
|
getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
|
|
115
114
|
getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
|
|
116
115
|
getL2BlockNew: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
|
|
116
|
+
getL2BlockNewByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
|
|
117
|
+
getL2BlockNewByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
|
|
117
118
|
getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
|
|
118
119
|
getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
|
|
119
120
|
getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
|
|
120
121
|
getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
|
|
121
122
|
getCheckpointsForEpoch: z.function().args(EpochNumberSchema).returns(z.array(Checkpoint.schema)),
|
|
122
|
-
getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(
|
|
123
|
+
getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(L2BlockNew.schema)),
|
|
123
124
|
getBlocksForSlot: z.function().args(schemas.SlotNumber).returns(z.array(L2BlockNew.schema)),
|
|
124
125
|
getBlockHeadersForEpoch: z.function().args(EpochNumberSchema).returns(z.array(BlockHeader.schema)),
|
|
125
126
|
isEpochComplete: z.function().args(EpochNumberSchema).returns(z.boolean()),
|