@aztec/stdlib 3.0.0-nightly.20251202 → 3.0.0-nightly.20251204
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 +17 -9
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm_circuit_public_inputs.d.ts +5 -3
- package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
- package/dest/avm/avm_proving_request.d.ts +9 -5
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/block_parameter.d.ts +5 -0
- package/dest/block/block_parameter.d.ts.map +1 -0
- package/dest/block/block_parameter.js +6 -0
- package/dest/block/in_block.d.ts +6 -5
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/in_block.js +3 -3
- package/dest/block/index.d.ts +1 -1
- package/dest/block/index.js +1 -1
- package/dest/block/l2_block.d.ts +5 -5
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +1 -1
- package/dest/block/l2_block_code_to_purge.js +3 -3
- package/dest/block/l2_block_header.d.ts +3 -3
- package/dest/block/l2_block_header.d.ts.map +1 -1
- package/dest/block/l2_block_info.d.ts +15 -10
- package/dest/block/l2_block_info.d.ts.map +1 -1
- package/dest/block/l2_block_info.js +7 -6
- package/dest/block/l2_block_new.d.ts +5 -4
- package/dest/block/l2_block_new.d.ts.map +1 -1
- package/dest/block/l2_block_new.js +1 -1
- package/dest/block/l2_block_source.d.ts +56 -97
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +5 -11
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +4 -3
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +3 -2
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_memory_store.js +4 -2
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -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 +6 -4
- package/dest/checkpoint/checkpoint.d.ts +1 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +2 -2
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -2
- package/dest/contract/interfaces/contract_data_source.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 +14 -9
- package/dest/interfaces/aztec-node.d.ts +23 -23
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +24 -23
- package/dest/interfaces/block-builder.d.ts +3 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/epoch-prover.d.ts +4 -4
- package/dest/interfaces/epoch-prover.d.ts.map +1 -1
- package/dest/interfaces/get_logs_response.d.ts +5 -3
- package/dest/interfaces/get_logs_response.d.ts.map +1 -1
- package/dest/interfaces/l2_logs_source.d.ts +4 -3
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +3 -2
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/proving-job.d.ts +9 -5
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/tx_provider.d.ts +3 -3
- package/dest/interfaces/tx_provider.d.ts.map +1 -1
- package/dest/interfaces/world_state.d.ts +9 -26
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/interfaces/world_state.js +4 -3
- package/dest/kernel/private_call_data.d.ts +5 -62
- package/dest/kernel/private_call_data.d.ts.map +1 -1
- package/dest/kernel/private_call_data.js +4 -105
- package/dest/logs/extended_public_log.d.ts +5 -3
- package/dest/logs/extended_public_log.d.ts.map +1 -1
- package/dest/logs/log_id.d.ts +8 -5
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +5 -4
- package/dest/logs/tx_scoped_l2_log.d.ts +10 -7
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +4 -3
- package/dest/messaging/l1_to_l2_message_source.d.ts +10 -3
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +4 -3
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/note/note_dao.d.ts +4 -3
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +3 -2
- package/dest/tests/factories.js +5 -5
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +2 -1
- package/dest/tx/block_header.d.ts +4 -4
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/global_variables.d.ts +13 -11
- package/dest/tx/global_variables.d.ts.map +1 -1
- package/dest/tx/global_variables.js +6 -6
- package/dest/tx/indexed_tx_effect.d.ts +6 -3
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +2 -1
- package/dest/tx/private_execution_result.d.ts +3 -3
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/tx_receipt.d.ts +4 -3
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +2 -1
- package/package.json +8 -8
- package/src/block/block_parameter.ts +8 -0
- package/src/block/in_block.ts +5 -4
- package/src/block/index.ts +1 -1
- package/src/block/l2_block.ts +4 -4
- package/src/block/l2_block_code_to_purge.ts +3 -3
- package/src/block/l2_block_info.ts +10 -9
- package/src/block/l2_block_new.ts +4 -3
- package/src/block/l2_block_source.ts +26 -22
- package/src/block/l2_block_stream/l2_block_stream.ts +10 -5
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +5 -2
- package/src/block/test/l2_tips_store_test_suite.ts +8 -3
- package/src/checkpoint/checkpoint.ts +2 -2
- package/src/contract/interfaces/contract_data_source.ts +2 -1
- package/src/interfaces/archiver.ts +17 -9
- package/src/interfaces/aztec-node.ts +51 -44
- package/src/interfaces/block-builder.ts +2 -1
- package/src/interfaces/epoch-prover.ts +3 -3
- package/src/interfaces/l2_logs_source.ts +3 -2
- package/src/interfaces/merkle_tree_operations.ts +2 -1
- package/src/interfaces/tx_provider.ts +2 -2
- package/src/interfaces/world_state.ts +12 -11
- package/src/kernel/private_call_data.ts +3 -130
- package/src/logs/log_id.ts +6 -5
- package/src/logs/tx_scoped_l2_log.ts +5 -4
- package/src/messaging/l1_to_l2_message_source.ts +10 -2
- package/src/messaging/l2_to_l1_membership.ts +3 -2
- package/src/note/note_dao.ts +4 -3
- package/src/tests/factories.ts +4 -4
- package/src/tests/mocks.ts +2 -1
- package/src/tx/block_header.ts +2 -2
- package/src/tx/global_variables.ts +8 -8
- package/src/tx/indexed_tx_effect.ts +2 -1
- package/src/tx/private_execution_result.ts +2 -2
- package/src/tx/tx_receipt.ts +3 -2
- package/dest/block/l2_block_number.d.ts +0 -5
- package/dest/block/l2_block_number.d.ts.map +0 -1
- package/dest/block/l2_block_number.js +0 -6
- package/src/block/l2_block_number.ts +0 -8
package/dest/tx/tx_receipt.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
3
|
import { RevertCode } from '../avm/revert_code.js';
|
|
3
4
|
import { L2BlockHash } from '../block/block_hash.js';
|
|
@@ -26,7 +27,7 @@ export declare class TxReceipt {
|
|
|
26
27
|
error: string;
|
|
27
28
|
transactionFee?: bigint | undefined;
|
|
28
29
|
blockHash?: L2BlockHash | undefined;
|
|
29
|
-
blockNumber?:
|
|
30
|
+
blockNumber?: BlockNumber | undefined;
|
|
30
31
|
constructor(
|
|
31
32
|
/** A unique identifier for a transaction. */
|
|
32
33
|
txHash: TxHash,
|
|
@@ -39,10 +40,10 @@ export declare class TxReceipt {
|
|
|
39
40
|
/** The hash of the block containing the transaction. */
|
|
40
41
|
blockHash?: L2BlockHash | undefined,
|
|
41
42
|
/** The block number in which the transaction was included. */
|
|
42
|
-
blockNumber?:
|
|
43
|
+
blockNumber?: BlockNumber | undefined);
|
|
43
44
|
static empty(): TxReceipt;
|
|
44
45
|
static get schema(): ZodFor<TxReceipt>;
|
|
45
46
|
static from(fields: FieldsOf<TxReceipt>): TxReceipt;
|
|
46
47
|
static statusFromRevertCode(revertCode: RevertCode): TxStatus.SUCCESS | TxStatus.APP_LOGIC_REVERTED | TxStatus.TEARDOWN_REVERTED | TxStatus.BOTH_REVERTED;
|
|
47
48
|
}
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
49
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfcmVjZWlwdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3R4L3R4X3JlY2VpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBcUIsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRixPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUl4RCxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFDbkQsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQ3JELE9BQU8sRUFBRSxLQUFLLE1BQU0sRUFBVyxNQUFNLHVCQUF1QixDQUFDO0FBQzdELE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxjQUFjLENBQUM7QUFFdEM7O0dBRUc7QUFDSCxvQkFBWSxRQUFRO0lBQ2xCLE9BQU8sWUFBWTtJQUNuQixPQUFPLFlBQVk7SUFDbkIsT0FBTyxZQUFZO0lBQ25CLGtCQUFrQix1QkFBdUI7SUFDekMsaUJBQWlCLHNCQUFzQjtJQUN2QyxhQUFhLGtCQUFrQjtDQUNoQztBQUVEOzs7OztHQUtHO0FBQ0gscUJBQWEsU0FBUztJQUdYLE1BQU0sRUFBRSxNQUFNO0lBRWQsTUFBTSxFQUFFLFFBQVE7SUFFaEIsS0FBSyxFQUFFLE1BQU07SUFFYixjQUFjLENBQUM7SUFFZixTQUFTLENBQUM7SUFFVixXQUFXLENBQUM7SUFackI7SUFDRSw2Q0FBNkM7SUFDdEMsTUFBTSxFQUFFLE1BQU07SUFDckIsZ0NBQWdDO0lBQ3pCLE1BQU0sRUFBRSxRQUFRO0lBQ3ZCLGdEQUFnRDtJQUN6QyxLQUFLLEVBQUUsTUFBTTtJQUNwQixvREFBb0Q7SUFDN0MsY0FBYyxDQUFDLG9CQUFRO0lBQzlCLHdEQUF3RDtJQUNqRCxTQUFTLENBQUMseUJBQWE7SUFDOUIsOERBQThEO0lBQ3ZELFdBQVcsQ0FBQyx5QkFBYSxFQUM5QjtJQUVKLE1BQU0sQ0FBQyxLQUFLLGNBRVg7SUFFRCxNQUFNLEtBQUssTUFBTSxJQUFJLE1BQU0sQ0FBQyxTQUFTLENBQUMsQ0FXckM7SUFFRCxNQUFNLENBQUMsSUFBSSxDQUFDLE1BQU0sRUFBRSxRQUFRLENBQUMsU0FBUyxDQUFDLGFBU3RDO0lBRUQsT0FBYyxvQkFBb0IsQ0FBQyxVQUFVLEVBQUUsVUFBVSx3R0FZeEQ7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tx_receipt.d.ts","sourceRoot":"","sources":["../../src/tx/tx_receipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;CAChC;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IAGX,MAAM,EAAE,MAAM;IAEd,MAAM,EAAE,QAAQ;IAEhB,KAAK,EAAE,MAAM;IAEb,cAAc,CAAC;IAEf,SAAS,CAAC;IAEV,WAAW,CAAC;IAZrB;IACE,6CAA6C;IACtC,MAAM,EAAE,MAAM;IACrB,gCAAgC;IACzB,MAAM,EAAE,QAAQ;IACvB,gDAAgD;IACzC,KAAK,EAAE,MAAM;IACpB,oDAAoD;IAC7C,cAAc,CAAC,oBAAQ;IAC9B,wDAAwD;IACjD,SAAS,CAAC,yBAAa;IAC9B,8DAA8D;IACvD,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"tx_receipt.d.ts","sourceRoot":"","sources":["../../src/tx/tx_receipt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,iCAAiC,CAAC;AACjF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAIxD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;GAEG;AACH,oBAAY,QAAQ;IAClB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,aAAa,kBAAkB;CAChC;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IAGX,MAAM,EAAE,MAAM;IAEd,MAAM,EAAE,QAAQ;IAEhB,KAAK,EAAE,MAAM;IAEb,cAAc,CAAC;IAEf,SAAS,CAAC;IAEV,WAAW,CAAC;IAZrB;IACE,6CAA6C;IACtC,MAAM,EAAE,MAAM;IACrB,gCAAgC;IACzB,MAAM,EAAE,QAAQ;IACvB,gDAAgD;IACzC,KAAK,EAAE,MAAM;IACpB,oDAAoD;IAC7C,cAAc,CAAC,oBAAQ;IAC9B,wDAAwD;IACjD,SAAS,CAAC,yBAAa;IAC9B,8DAA8D;IACvD,WAAW,CAAC,yBAAa,EAC9B;IAEJ,MAAM,CAAC,KAAK,cAEX;IAED,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,SAAS,CAAC,CAWrC;IAED,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,aAStC;IAED,OAAc,oBAAoB,CAAC,UAAU,EAAE,UAAU,wGAYxD;CACF"}
|
package/dest/tx/tx_receipt.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { RevertCode } from '../avm/revert_code.js';
|
|
3
4
|
import { L2BlockHash } from '../block/block_hash.js';
|
|
@@ -43,7 +44,7 @@ import { TxHash } from './tx_hash.js';
|
|
|
43
44
|
status: z.nativeEnum(TxStatus),
|
|
44
45
|
error: z.string(),
|
|
45
46
|
blockHash: L2BlockHash.schema.optional(),
|
|
46
|
-
blockNumber:
|
|
47
|
+
blockNumber: BlockNumberSchema.optional(),
|
|
47
48
|
transactionFee: schemas.BigInt.optional()
|
|
48
49
|
}).transform(TxReceipt.from);
|
|
49
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251204",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@aws-sdk/client-s3": "^3.892.0",
|
|
75
|
-
"@aztec/bb.js": "3.0.0-nightly.
|
|
76
|
-
"@aztec/blob-lib": "3.0.0-nightly.
|
|
77
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
78
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
79
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
80
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
81
|
-
"@aztec/noir-noirc_abi": "3.0.0-nightly.
|
|
75
|
+
"@aztec/bb.js": "3.0.0-nightly.20251204",
|
|
76
|
+
"@aztec/blob-lib": "3.0.0-nightly.20251204",
|
|
77
|
+
"@aztec/constants": "3.0.0-nightly.20251204",
|
|
78
|
+
"@aztec/ethereum": "3.0.0-nightly.20251204",
|
|
79
|
+
"@aztec/foundation": "3.0.0-nightly.20251204",
|
|
80
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251204",
|
|
81
|
+
"@aztec/noir-noirc_abi": "3.0.0-nightly.20251204",
|
|
82
82
|
"@google-cloud/storage": "^7.15.0",
|
|
83
83
|
"axios": "^1.12.0",
|
|
84
84
|
"json-stringify-deterministic": "1.0.12",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
export const BlockParameterSchema = z.union([BlockNumberSchema, z.literal('latest')]);
|
|
6
|
+
|
|
7
|
+
/** Block parameter - either a specific BlockNumber or 'latest' */
|
|
8
|
+
export type BlockParameter = z.infer<typeof BlockParameterSchema>;
|
package/src/block/in_block.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
+
|
|
1
3
|
import { type ZodTypeAny, z } from 'zod';
|
|
2
4
|
|
|
3
|
-
import { schemas } from '../schemas/index.js';
|
|
4
5
|
import { L2BlockHash } from './block_hash.js';
|
|
5
6
|
import type { L2Block } from './l2_block.js';
|
|
6
7
|
|
|
7
8
|
export type InBlock = {
|
|
8
|
-
l2BlockNumber:
|
|
9
|
+
l2BlockNumber: BlockNumber;
|
|
9
10
|
l2BlockHash: L2BlockHash;
|
|
10
11
|
};
|
|
11
12
|
|
|
@@ -17,7 +18,7 @@ export type DataInBlock<T> = {
|
|
|
17
18
|
export function randomInBlock<T>(data: T): DataInBlock<T> {
|
|
18
19
|
return {
|
|
19
20
|
data,
|
|
20
|
-
l2BlockNumber: Math.floor(Math.random() * 1000),
|
|
21
|
+
l2BlockNumber: BlockNumber(Math.floor(Math.random() * 1000)),
|
|
21
22
|
l2BlockHash: L2BlockHash.random(),
|
|
22
23
|
};
|
|
23
24
|
}
|
|
@@ -33,7 +34,7 @@ export async function wrapInBlock<T>(data: T, block: L2Block): Promise<DataInBlo
|
|
|
33
34
|
export function inBlockSchemaFor<T extends ZodTypeAny>(schema: T) {
|
|
34
35
|
return z.object({
|
|
35
36
|
data: schema,
|
|
36
|
-
l2BlockNumber:
|
|
37
|
+
l2BlockNumber: BlockNumberSchema,
|
|
37
38
|
l2BlockHash: L2BlockHash.schema,
|
|
38
39
|
});
|
|
39
40
|
}
|
package/src/block/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './l2_block_header.js';
|
|
|
4
4
|
export * from './l2_block_stream/index.js';
|
|
5
5
|
export * from './in_block.js';
|
|
6
6
|
export * from './body.js';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './block_parameter.js';
|
|
8
8
|
export * from './l2_block_source.js';
|
|
9
9
|
export * from './block_hash.js';
|
|
10
10
|
export * from './published_l2_block.js';
|
package/src/block/l2_block.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type BlockBlobData, encodeBlockBlobData, encodeCheckpointBlobDataFromBlocks } from '@aztec/blob-lib/encoding';
|
|
2
|
-
import { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
5
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
@@ -89,7 +89,7 @@ export class L2Block {
|
|
|
89
89
|
* @returns The L2 block.
|
|
90
90
|
*/
|
|
91
91
|
static async random(
|
|
92
|
-
l2BlockNum:
|
|
92
|
+
l2BlockNum: BlockNumber,
|
|
93
93
|
txsPerBlock = 4,
|
|
94
94
|
numPublicCallsPerTx = 3,
|
|
95
95
|
numPublicLogsPerCall = 1,
|
|
@@ -114,7 +114,7 @@ export class L2Block {
|
|
|
114
114
|
return new L2Block(AppendOnlyTreeSnapshot.empty(), L2BlockHeader.empty(), Body.empty());
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
get number():
|
|
117
|
+
get number(): BlockNumber {
|
|
118
118
|
return this.header.getBlockNumber();
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -251,7 +251,7 @@ export class L2Block {
|
|
|
251
251
|
archive: this.archive.root,
|
|
252
252
|
lastArchive: this.header.lastArchive.root,
|
|
253
253
|
blockNumber: this.number,
|
|
254
|
-
slotNumber:
|
|
254
|
+
slotNumber: this.header.getSlot(),
|
|
255
255
|
txCount: this.body.txEffects.length,
|
|
256
256
|
timestamp: this.header.globalVariables.timestamp,
|
|
257
257
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { compact } from '@aztec/foundation/collection';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -25,7 +25,7 @@ export function makeL2BlockHeader(
|
|
|
25
25
|
overrides?.contentCommitment ?? makeContentCommitment(seed + 0x200, inHash),
|
|
26
26
|
overrides?.state ?? makeStateReference(seed + 0x600),
|
|
27
27
|
makeGlobalVariables((seed += 0x700), {
|
|
28
|
-
...(blockNumber ? { blockNumber } : {}),
|
|
28
|
+
...(blockNumber ? { blockNumber: BlockNumber(blockNumber) } : {}),
|
|
29
29
|
...(slotNumber ? { slotNumber: SlotNumber(slotNumber) } : {}),
|
|
30
30
|
}),
|
|
31
31
|
new Fr(seed + 0x300),
|
|
@@ -77,7 +77,7 @@ function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<GlobalVariabl
|
|
|
77
77
|
return GlobalVariables.from({
|
|
78
78
|
chainId: new Fr(seed),
|
|
79
79
|
version: new Fr(seed + 1),
|
|
80
|
-
blockNumber: seed + 2,
|
|
80
|
+
blockNumber: BlockNumber(seed + 2),
|
|
81
81
|
slotNumber: SlotNumber(seed + 3),
|
|
82
82
|
timestamp: BigInt(seed + 4),
|
|
83
83
|
coinbase: EthAddress.fromField(new Fr(seed + 5)),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber, BlockNumberSchema, SlotNumber, SlotNumberSchema } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { schemas } from '@aztec/foundation/schemas';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
@@ -8,19 +9,19 @@ export type L2BlockInfo = {
|
|
|
8
9
|
blockHash?: Fr;
|
|
9
10
|
archive: Fr;
|
|
10
11
|
lastArchive: Fr;
|
|
11
|
-
blockNumber:
|
|
12
|
-
slotNumber:
|
|
12
|
+
blockNumber: BlockNumber;
|
|
13
|
+
slotNumber: SlotNumber;
|
|
13
14
|
txCount: number;
|
|
14
15
|
timestamp: bigint;
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
export function randomBlockInfo(blockNumber?: number): L2BlockInfo {
|
|
18
|
+
export function randomBlockInfo(blockNumber?: BlockNumber | number): L2BlockInfo {
|
|
18
19
|
return {
|
|
19
20
|
blockHash: Fr.random(),
|
|
20
21
|
archive: Fr.random(),
|
|
21
22
|
lastArchive: Fr.random(),
|
|
22
|
-
blockNumber: blockNumber ?? Math.floor(Math.random() * 100000) + 1,
|
|
23
|
-
slotNumber: Math.floor(Math.random() * 100000) + 1,
|
|
23
|
+
blockNumber: BlockNumber(blockNumber ?? Math.floor(Math.random() * 100000) + 1),
|
|
24
|
+
slotNumber: SlotNumber(Math.floor(Math.random() * 100000) + 1),
|
|
24
25
|
txCount: Math.floor(Math.random() * 100),
|
|
25
26
|
timestamp: BigInt(Math.floor(Date.now() / 1000)),
|
|
26
27
|
};
|
|
@@ -30,8 +31,8 @@ export const BlockInfoSchema = z.object({
|
|
|
30
31
|
blockHash: schemas.Fr.optional(),
|
|
31
32
|
archive: schemas.Fr,
|
|
32
33
|
lastArchive: schemas.Fr,
|
|
33
|
-
blockNumber:
|
|
34
|
-
slotNumber:
|
|
34
|
+
blockNumber: BlockNumberSchema,
|
|
35
|
+
slotNumber: SlotNumberSchema,
|
|
35
36
|
txCount: z.number(),
|
|
36
37
|
timestamp: schemas.BigInt,
|
|
37
38
|
});
|
|
@@ -55,8 +56,8 @@ export function deserializeBlockInfo(buffer: Buffer | BufferReader): L2BlockInfo
|
|
|
55
56
|
blockHash: blockHash.equals(Fr.ZERO) ? undefined : blockHash,
|
|
56
57
|
archive: reader.readObject(Fr),
|
|
57
58
|
lastArchive: reader.readObject(Fr),
|
|
58
|
-
blockNumber: reader.readNumber(),
|
|
59
|
-
slotNumber: reader.readNumber(),
|
|
59
|
+
blockNumber: BlockNumber(reader.readNumber()),
|
|
60
|
+
slotNumber: SlotNumber(reader.readNumber()),
|
|
60
61
|
txCount: reader.readNumber(),
|
|
61
62
|
timestamp: reader.readBigInt(),
|
|
62
63
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type BlockBlobData, encodeBlockBlobData } from '@aztec/blob-lib/encoding';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
5
|
|
|
@@ -24,7 +25,7 @@ export class L2BlockNew {
|
|
|
24
25
|
private blockHash: Fr | undefined = undefined,
|
|
25
26
|
) {}
|
|
26
27
|
|
|
27
|
-
get number():
|
|
28
|
+
get number(): BlockNumber {
|
|
28
29
|
return this.header.globalVariables.blockNumber;
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -112,7 +113,7 @@ export class L2BlockNew {
|
|
|
112
113
|
* @returns The L2 block.
|
|
113
114
|
*/
|
|
114
115
|
static async random(
|
|
115
|
-
blockNumber:
|
|
116
|
+
blockNumber: BlockNumber,
|
|
116
117
|
{
|
|
117
118
|
txsPerBlock = 1,
|
|
118
119
|
txOptions = {},
|
|
@@ -163,7 +164,7 @@ export class L2BlockNew {
|
|
|
163
164
|
archive: this.archive.root,
|
|
164
165
|
lastArchive: this.header.lastArchive.root,
|
|
165
166
|
blockNumber: this.number,
|
|
166
|
-
slotNumber:
|
|
167
|
+
slotNumber: this.header.getSlot(),
|
|
167
168
|
txCount: this.body.txEffects.length,
|
|
168
169
|
timestamp: this.header.globalVariables.timestamp,
|
|
169
170
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { BlockNumber, BlockNumberSchema, type EpochNumber, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
3
|
import type { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { TypedEventEmitter } from '@aztec/foundation/types';
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
+
import type { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
9
|
+
import type { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
|
|
8
10
|
import type { L1RollupConstants } from '../epoch-helpers/index.js';
|
|
9
11
|
import type { BlockHeader } from '../tx/block_header.js';
|
|
10
12
|
import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
@@ -34,27 +36,27 @@ export interface L2BlockSource {
|
|
|
34
36
|
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
35
37
|
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
36
38
|
*/
|
|
37
|
-
getBlockNumber(): Promise<
|
|
39
|
+
getBlockNumber(): Promise<BlockNumber>;
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* Gets the number of the latest L2 block proven seen by the block source implementation.
|
|
41
43
|
* @returns The number of the latest L2 block proven seen by the block source implementation.
|
|
42
44
|
*/
|
|
43
|
-
getProvenBlockNumber(): Promise<
|
|
45
|
+
getProvenBlockNumber(): Promise<BlockNumber>;
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
47
49
|
* @param number - The block number to return (inclusive).
|
|
48
50
|
* @returns The requested L2 block.
|
|
49
51
|
*/
|
|
50
|
-
getBlock(number:
|
|
52
|
+
getBlock(number: BlockNumber): Promise<L2Block | undefined>;
|
|
51
53
|
|
|
52
54
|
/**
|
|
53
55
|
* Gets an l2 block header.
|
|
54
56
|
* @param number - The block number to return or 'latest' for the most recent one.
|
|
55
57
|
* @returns The requested L2 block header.
|
|
56
58
|
*/
|
|
57
|
-
getBlockHeader(number:
|
|
59
|
+
getBlockHeader(number: BlockNumber | 'latest'): Promise<BlockHeader | undefined>;
|
|
58
60
|
|
|
59
61
|
/**
|
|
60
62
|
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
@@ -63,10 +65,12 @@ export interface L2BlockSource {
|
|
|
63
65
|
* @param proven - If true, only return blocks that have been proven.
|
|
64
66
|
* @returns The requested L2 blocks.
|
|
65
67
|
*/
|
|
66
|
-
getBlocks(from:
|
|
68
|
+
getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2Block[]>;
|
|
69
|
+
|
|
70
|
+
getPublishedCheckpoints(from: number, limit: number): Promise<PublishedCheckpoint[]>;
|
|
67
71
|
|
|
68
72
|
/** Equivalent to getBlocks but includes publish data. */
|
|
69
|
-
getPublishedBlocks(from:
|
|
73
|
+
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
76
|
* Gets a published block by its hash.
|
|
@@ -120,6 +124,13 @@ export interface L2BlockSource {
|
|
|
120
124
|
*/
|
|
121
125
|
getL2EpochNumber(): Promise<EpochNumber | undefined>;
|
|
122
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Returns all checkpoints for a given epoch.
|
|
129
|
+
* @dev Use this method only with recent epochs, since it walks the checkpoint list backwards.
|
|
130
|
+
* @param epochNumber - The epoch number to return checkpoints for.
|
|
131
|
+
*/
|
|
132
|
+
getCheckpointsForEpoch(epochNumber: EpochNumber): Promise<Checkpoint[]>;
|
|
133
|
+
|
|
123
134
|
/**
|
|
124
135
|
* Returns all blocks for a given epoch.
|
|
125
136
|
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
@@ -195,33 +206,26 @@ export type L2BlockTag = 'latest' | 'proven' | 'finalized';
|
|
|
195
206
|
export type L2Tips = Record<L2BlockTag, L2BlockId>;
|
|
196
207
|
|
|
197
208
|
/** Identifies a block by number and hash. */
|
|
198
|
-
export type L2BlockId =
|
|
209
|
+
export type L2BlockId = { number: BlockNumber; hash: string };
|
|
199
210
|
|
|
200
211
|
/** Creates an L2 block id */
|
|
201
|
-
export function makeL2BlockId(number:
|
|
212
|
+
export function makeL2BlockId(number: BlockNumber, hash?: string): L2BlockId {
|
|
202
213
|
if (number !== 0 && !hash) {
|
|
203
214
|
throw new Error(`Hash is required for non-genesis blocks (got block number ${number})`);
|
|
204
215
|
}
|
|
205
216
|
return { number, hash: hash! };
|
|
206
217
|
}
|
|
207
218
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
z.
|
|
211
|
-
|
|
212
|
-
hash: z.undefined(),
|
|
213
|
-
}),
|
|
214
|
-
z.object({
|
|
215
|
-
number: z.number(),
|
|
216
|
-
hash: z.string(),
|
|
217
|
-
}),
|
|
218
|
-
]);
|
|
219
|
+
const L2BlockIdSchema = z.object({
|
|
220
|
+
number: BlockNumberSchema,
|
|
221
|
+
hash: z.string(),
|
|
222
|
+
});
|
|
219
223
|
|
|
220
224
|
export const L2TipsSchema = z.object({
|
|
221
225
|
latest: L2BlockIdSchema,
|
|
222
226
|
proven: L2BlockIdSchema,
|
|
223
227
|
finalized: L2BlockIdSchema,
|
|
224
|
-
})
|
|
228
|
+
});
|
|
225
229
|
|
|
226
230
|
export enum L2BlockSourceEvents {
|
|
227
231
|
L2PruneDetected = 'l2PruneDetected',
|
|
@@ -231,7 +235,7 @@ export enum L2BlockSourceEvents {
|
|
|
231
235
|
|
|
232
236
|
export type L2BlockProvenEvent = {
|
|
233
237
|
type: 'l2BlockProven';
|
|
234
|
-
blockNumber:
|
|
238
|
+
blockNumber: BlockNumber;
|
|
235
239
|
slotNumber: SlotNumber;
|
|
236
240
|
epochNumber: EpochNumber;
|
|
237
241
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import { AbortError } from '@aztec/foundation/error';
|
|
2
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
3
4
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
@@ -74,7 +75,7 @@ export class L2BlockStream {
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
if (latestBlockNumber < localTips.latest.number) {
|
|
77
|
-
latestBlockNumber = Math.min(latestBlockNumber, sourceTips.latest.number); // see #13471
|
|
78
|
+
latestBlockNumber = BlockNumber(Math.min(latestBlockNumber, sourceTips.latest.number)); // see #13471
|
|
78
79
|
const hash = sourceCache.get(latestBlockNumber) ?? (await this.getBlockHashFromSource(latestBlockNumber));
|
|
79
80
|
if (latestBlockNumber !== 0 && !hash) {
|
|
80
81
|
throw new Error(`Block hash not found in block source for block number ${latestBlockNumber}`);
|
|
@@ -85,7 +86,7 @@ export class L2BlockStream {
|
|
|
85
86
|
|
|
86
87
|
// If we are just starting, use the starting block number from the options.
|
|
87
88
|
if (latestBlockNumber === 0 && this.opts.startingBlock !== undefined) {
|
|
88
|
-
latestBlockNumber = Math.max(this.opts.startingBlock - 1, 0);
|
|
89
|
+
latestBlockNumber = BlockNumber(Math.max(this.opts.startingBlock - 1, 0));
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
// Only log this entry once (for sanity)
|
|
@@ -108,7 +109,11 @@ export class L2BlockStream {
|
|
|
108
109
|
while (nextBlockNumber <= sourceTips.latest.number) {
|
|
109
110
|
const limit = Math.min(this.opts.batchSize ?? 50, sourceTips.latest.number - nextBlockNumber + 1);
|
|
110
111
|
this.log.trace(`Requesting blocks from ${nextBlockNumber} limit ${limit} proven=${this.opts.proven}`);
|
|
111
|
-
const blocks = await this.l2BlockSource.getPublishedBlocks(
|
|
112
|
+
const blocks = await this.l2BlockSource.getPublishedBlocks(
|
|
113
|
+
BlockNumber(nextBlockNumber),
|
|
114
|
+
limit,
|
|
115
|
+
this.opts.proven,
|
|
116
|
+
);
|
|
112
117
|
if (blocks.length === 0) {
|
|
113
118
|
break;
|
|
114
119
|
}
|
|
@@ -139,7 +144,7 @@ export class L2BlockStream {
|
|
|
139
144
|
* @param blockNumber - The block number to test.
|
|
140
145
|
* @param args - A cache of data already requested from source, to avoid re-requesting it.
|
|
141
146
|
*/
|
|
142
|
-
private async areBlockHashesEqualAt(blockNumber:
|
|
147
|
+
private async areBlockHashesEqualAt(blockNumber: BlockNumber, args: { sourceCache: BlockHashCache }) {
|
|
143
148
|
if (blockNumber === 0) {
|
|
144
149
|
return true;
|
|
145
150
|
}
|
|
@@ -163,7 +168,7 @@ export class L2BlockStream {
|
|
|
163
168
|
return localBlockHash === sourceBlockHash;
|
|
164
169
|
}
|
|
165
170
|
|
|
166
|
-
private getBlockHashFromSource(blockNumber:
|
|
171
|
+
private getBlockHashFromSource(blockNumber: BlockNumber) {
|
|
167
172
|
return this.l2BlockSource
|
|
168
173
|
.getBlockHeader(blockNumber)
|
|
169
174
|
.then(h => h?.hash())
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
|
|
1
4
|
import type { L2Block } from '../l2_block.js';
|
|
2
5
|
import type { L2BlockId, L2BlockTag, L2Tips } from '../l2_block_source.js';
|
|
3
6
|
import type { L2BlockStreamEvent, L2BlockStreamEventHandler, L2BlockStreamLocalDataProvider } from './interfaces.js';
|
|
@@ -7,7 +10,7 @@ import type { L2BlockStreamEvent, L2BlockStreamEventHandler, L2BlockStreamLocalD
|
|
|
7
10
|
* @dev tests in kv-store/src/stores/l2_tips_memory_store.test.ts
|
|
8
11
|
*/
|
|
9
12
|
export class L2TipsMemoryStore implements L2BlockStreamEventHandler, L2BlockStreamLocalDataProvider {
|
|
10
|
-
protected readonly l2TipsStore: Map<L2BlockTag,
|
|
13
|
+
protected readonly l2TipsStore: Map<L2BlockTag, BlockNumber> = new Map();
|
|
11
14
|
protected readonly l2BlockHashesStore: Map<number, string> = new Map();
|
|
12
15
|
|
|
13
16
|
public getL2BlockHash(number: number): Promise<string | undefined> {
|
|
@@ -25,7 +28,7 @@ export class L2TipsMemoryStore implements L2BlockStreamEventHandler, L2BlockStre
|
|
|
25
28
|
private getL2Tip(tag: L2BlockTag): L2BlockId {
|
|
26
29
|
const blockNumber = this.l2TipsStore.get(tag);
|
|
27
30
|
if (blockNumber === undefined || blockNumber === 0) {
|
|
28
|
-
return { number:
|
|
31
|
+
return { number: BlockNumber.ZERO, hash: GENESIS_BLOCK_HEADER_HASH.toString() };
|
|
29
32
|
}
|
|
30
33
|
const blockHash = this.l2BlockHashesStore.get(blockNumber);
|
|
31
34
|
if (!blockHash) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { GENESIS_BLOCK_HEADER_HASH } from '@aztec/constants';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
3
|
import { times } from '@aztec/foundation/collection';
|
|
2
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
5
|
import { type L2Block, type L2BlockId, PublishedL2Block } from '@aztec/stdlib/block';
|
|
@@ -15,17 +17,20 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
|
15
17
|
|
|
16
18
|
const makeBlock = (number: number): PublishedL2Block =>
|
|
17
19
|
PublishedL2Block.fromFields({
|
|
18
|
-
block: { number, hash: () => Promise.resolve(new Fr(number)) } as L2Block,
|
|
20
|
+
block: { number: BlockNumber(number), hash: () => Promise.resolve(new Fr(number)) } as L2Block,
|
|
19
21
|
l1: { blockNumber: BigInt(number), blockHash: `0x${number}`, timestamp: BigInt(number) },
|
|
20
22
|
attestations: [],
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
const makeBlockId = (number: number): L2BlockId => ({
|
|
24
|
-
number,
|
|
26
|
+
number: BlockNumber(number),
|
|
25
27
|
hash: new Fr(number).toString(),
|
|
26
28
|
});
|
|
27
29
|
|
|
28
|
-
const makeTip = (number: number) => ({
|
|
30
|
+
const makeTip = (number: number): L2BlockId => ({
|
|
31
|
+
number: BlockNumber(number),
|
|
32
|
+
hash: number === 0 ? GENESIS_BLOCK_HEADER_HASH.toString() : new Fr(number).toString(),
|
|
33
|
+
});
|
|
29
34
|
|
|
30
35
|
const makeTips = (latest: number, proven: number, finalized: number) => ({
|
|
31
36
|
latest: makeTip(latest),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { encodeCheckpointBlobDataFromBlocks } from '@aztec/blob-lib/encoding';
|
|
2
|
-
import { CheckpointNumber, CheckpointNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockNumber, CheckpointNumber, CheckpointNumberSchema } from '@aztec/foundation/branded-types';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
5
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
@@ -80,7 +80,7 @@ export class Checkpoint {
|
|
|
80
80
|
const header = CheckpointHeader.random(options);
|
|
81
81
|
|
|
82
82
|
const blocks = await Promise.all(
|
|
83
|
-
Array.from({ length: numBlocks }, (_, i) => L2BlockNew.random(startBlockNumber + i, options)),
|
|
83
|
+
Array.from({ length: numBlocks }, (_, i) => L2BlockNew.random(BlockNumber(startBlockNumber + i), options)),
|
|
84
84
|
);
|
|
85
85
|
|
|
86
86
|
return new Checkpoint(AppendOnlyTreeSnapshot.random(), header, blocks, checkpointNumber);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
2
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
|
|
3
4
|
import type { FunctionSelector } from '../../abi/index.js';
|
|
@@ -11,7 +12,7 @@ export interface ContractDataSource {
|
|
|
11
12
|
* Gets the number of the latest L2 block processed by the implementation.
|
|
12
13
|
* @returns The number of the latest L2 block processed by the implementation.
|
|
13
14
|
*/
|
|
14
|
-
getBlockNumber(): Promise<
|
|
15
|
+
getBlockNumber(): Promise<BlockNumber>;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Returns the contract class for a given contract class id, or undefined if not found.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { L1ContractAddresses } from '@aztec/ethereum';
|
|
2
|
-
import { EpochNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { BlockNumberSchema, CheckpointNumberSchema, EpochNumberSchema } from '@aztec/foundation/branded-types';
|
|
3
3
|
import type { ApiSchemaFor } from '@aztec/foundation/schemas';
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod';
|
|
@@ -8,6 +8,8 @@ import { L2Block } from '../block/l2_block.js';
|
|
|
8
8
|
import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
|
|
9
9
|
import { PublishedL2Block } from '../block/published_l2_block.js';
|
|
10
10
|
import { ValidateBlockResultSchema } from '../block/validate_block_result.js';
|
|
11
|
+
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
12
|
+
import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
|
|
11
13
|
import {
|
|
12
14
|
ContractClassPublicSchema,
|
|
13
15
|
type ContractDataSource,
|
|
@@ -73,20 +75,24 @@ export type ArchiverApi = Omit<
|
|
|
73
75
|
export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
74
76
|
getRollupAddress: z.function().args().returns(schemas.EthAddress),
|
|
75
77
|
getRegistryAddress: z.function().args().returns(schemas.EthAddress),
|
|
76
|
-
getBlockNumber: z.function().args().returns(
|
|
77
|
-
getProvenBlockNumber: z.function().args().returns(
|
|
78
|
-
getBlock: z.function().args(
|
|
78
|
+
getBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
79
|
+
getProvenBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
80
|
+
getBlock: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
|
|
79
81
|
getBlockHeader: z
|
|
80
82
|
.function()
|
|
81
|
-
.args(z.union([
|
|
83
|
+
.args(z.union([BlockNumberSchema, z.literal('latest')]))
|
|
82
84
|
.returns(BlockHeader.schema.optional()),
|
|
83
85
|
getBlocks: z
|
|
84
86
|
.function()
|
|
85
|
-
.args(
|
|
87
|
+
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
86
88
|
.returns(z.array(L2Block.schema)),
|
|
89
|
+
getPublishedCheckpoints: z
|
|
90
|
+
.function()
|
|
91
|
+
.args(schemas.Integer, schemas.Integer)
|
|
92
|
+
.returns(z.array(PublishedCheckpoint.schema)),
|
|
87
93
|
getPublishedBlocks: z
|
|
88
94
|
.function()
|
|
89
|
-
.args(
|
|
95
|
+
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
90
96
|
.returns(z.array(PublishedL2Block.schema)),
|
|
91
97
|
getPublishedBlockByHash: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
|
|
92
98
|
getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(PublishedL2Block.schema.optional()),
|
|
@@ -96,11 +102,12 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
96
102
|
getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
|
|
97
103
|
getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
|
|
98
104
|
getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
|
|
105
|
+
getCheckpointsForEpoch: z.function().args(EpochNumberSchema).returns(z.array(Checkpoint.schema)),
|
|
99
106
|
getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(L2Block.schema)),
|
|
100
107
|
getBlockHeadersForEpoch: z.function().args(EpochNumberSchema).returns(z.array(BlockHeader.schema)),
|
|
101
108
|
isEpochComplete: z.function().args(EpochNumberSchema).returns(z.boolean()),
|
|
102
109
|
getL2Tips: z.function().args().returns(L2TipsSchema),
|
|
103
|
-
getPrivateLogs: z.function().args(
|
|
110
|
+
getPrivateLogs: z.function().args(BlockNumberSchema, z.number()).returns(z.array(PrivateLog.schema)),
|
|
104
111
|
getLogsByTags: z
|
|
105
112
|
.function()
|
|
106
113
|
.args(z.array(schemas.Fr))
|
|
@@ -115,7 +122,8 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
115
122
|
.returns(ContractInstanceWithAddressSchema.optional()),
|
|
116
123
|
getContractClassIds: z.function().args().returns(z.array(schemas.Fr)),
|
|
117
124
|
registerContractFunctionSignatures: z.function().args(z.array(z.string())).returns(z.void()),
|
|
118
|
-
|
|
125
|
+
getL1ToL2MessagesForCheckpoint: z.function().args(CheckpointNumberSchema).returns(z.array(schemas.Fr)),
|
|
126
|
+
getL1ToL2Messages: z.function().args(BlockNumberSchema).returns(z.array(schemas.Fr)),
|
|
119
127
|
getL1ToL2MessageIndex: z.function().args(schemas.Fr).returns(schemas.BigInt.optional()),
|
|
120
128
|
getDebugFunctionName: z.function().args(schemas.AztecAddress, schemas.FunctionSelector).returns(optional(z.string())),
|
|
121
129
|
getL1Constants: z.function().args().returns(L1RollupConstantsSchema),
|