@aztec/stdlib 3.0.0-rc.5 → 4.0.0-nightly.20260107
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/abi/abi.d.ts +602 -4
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +7 -7
- package/dest/abi/function_selector.d.ts +2 -1
- package/dest/abi/function_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.js +7 -0
- package/dest/abi/selector.js +3 -1
- package/dest/avm/avm.js +1 -1
- package/dest/avm/avm_accumulated_data.js +5 -2
- package/dest/avm/avm_circuit_public_inputs.js +3 -1
- package/dest/avm/public_data_update_request.js +3 -1
- package/dest/avm/public_inner_call_request.js +3 -1
- package/dest/avm/revert_code.js +3 -1
- package/dest/aztec-address/index.js +4 -2
- package/dest/block/body.js +3 -1
- package/dest/block/checkpointed_l2_block.d.ts +267 -0
- package/dest/block/checkpointed_l2_block.d.ts.map +1 -0
- package/dest/block/{published_l2_block.js → checkpointed_l2_block.js} +40 -4
- package/dest/block/index.d.ts +2 -2
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -1
- package/dest/block/l2_block_header.js +3 -1
- package/dest/block/l2_block_new.d.ts +8 -3
- package/dest/block/l2_block_new.d.ts.map +1 -1
- package/dest/block/l2_block_new.js +10 -9
- package/dest/block/l2_block_source.d.ts +69 -45
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/interfaces.d.ts +2 -2
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +6 -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 +9 -1
- 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 +2 -5
- package/dest/checkpoint/checkpoint.d.ts +17 -2
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +42 -4
- package/dest/checkpoint/checkpoint_info.d.ts +9 -0
- package/dest/checkpoint/checkpoint_info.d.ts.map +1 -0
- package/dest/checkpoint/checkpoint_info.js +1 -0
- package/dest/checkpoint/published_checkpoint.d.ts +14 -8
- package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/published_checkpoint.js +11 -1
- package/dest/contract/contract_class_id.js +1 -1
- package/dest/contract/interfaces/contract_class.d.ts +11 -13
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +18 -18
- package/dest/contract/interfaces/contract_instance.d.ts +12 -13
- package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.js +5 -5
- package/dest/contract/interfaces/contract_instance_update.d.ts +6 -7
- package/dest/contract/interfaces/contract_instance_update.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance_update.js +5 -5
- package/dest/database-version/version_manager.js +3 -1
- package/dest/epoch-helpers/index.d.ts +1 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +3 -3
- package/dest/gas/gas.js +3 -1
- package/dest/gas/gas_fees.js +3 -1
- package/dest/hash/hash.d.ts +1 -9
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +0 -12
- package/dest/interfaces/allowed_element.d.ts +7 -8
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +3 -3
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +8 -3
- package/dest/interfaces/aztec-node-admin.d.ts +29 -11
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +1 -1
- package/dest/interfaces/aztec-node.d.ts +10 -10
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +4 -4
- package/dest/interfaces/block-builder.d.ts +3 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +9 -1
- package/dest/interfaces/configs.d.ts +47 -23
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +11 -6
- package/dest/interfaces/get_logs_response.d.ts +19 -4
- package/dest/interfaces/get_logs_response.d.ts.map +1 -1
- package/dest/interfaces/get_logs_response.js +5 -4
- package/dest/interfaces/l2_logs_source.d.ts +12 -8
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +2 -2
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +5 -3
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +5 -4
- package/dest/interfaces/proving-job.d.ts +168 -168
- package/dest/interfaces/server_circuit_prover.d.ts +2 -2
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/slasher.d.ts +1 -1
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +3 -3
- package/dest/interfaces/validator.d.ts +7 -8
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +5 -5
- package/dest/interfaces/world_state.d.ts +17 -8
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/claimed_length_array.js +3 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts.map +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +1 -3
- package/dest/kernel/hints/transient_data_squashing_hint.js +3 -1
- package/dest/kernel/log_hash.js +3 -1
- package/dest/kernel/private_circuit_public_inputs.d.ts +47 -47
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +59 -59
- package/dest/kernel/private_log_data.js +5 -2
- package/dest/kernel/private_to_avm_accumulated_data.js +5 -2
- package/dest/kernel/private_to_public_accumulated_data.js +3 -1
- package/dest/kernel/private_to_rollup_accumulated_data.js +3 -1
- package/dest/kernel/private_validation_requests.js +3 -1
- package/dest/kernel/public_call_request.js +5 -2
- package/dest/logs/contract_class_log.js +3 -1
- package/dest/logs/extended_public_log.d.ts +7 -1
- package/dest/logs/extended_public_log.d.ts.map +1 -1
- package/dest/logs/index.d.ts +3 -2
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +2 -1
- package/dest/logs/log_id.d.ts +9 -1
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +15 -8
- package/dest/logs/private_log.d.ts +1 -1
- package/dest/logs/private_log.d.ts.map +1 -1
- package/dest/logs/private_log.js +5 -2
- package/dest/logs/public_log.js +3 -1
- package/dest/logs/siloed_tag.d.ts +23 -0
- package/dest/logs/siloed_tag.d.ts.map +1 -0
- package/dest/logs/siloed_tag.js +30 -0
- package/dest/logs/tag.d.ts +21 -0
- package/dest/logs/tag.d.ts.map +1 -0
- package/dest/logs/tag.js +30 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +24 -33
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +37 -43
- package/dest/messaging/l1_to_l2_message.d.ts +1 -1
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/rollup/avm_proof_data.d.ts +1 -3
- package/dest/rollup/avm_proof_data.d.ts.map +1 -1
- package/dest/rollup/avm_proof_data.js +1 -9
- package/dest/rollup/block_rollup_public_inputs.d.ts +4 -9
- package/dest/rollup/block_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/block_rollup_public_inputs.js +6 -10
- package/dest/rollup/checkpoint_constant_data.d.ts +2 -1
- package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
- package/dest/rollup/checkpoint_constant_data.js +4 -1
- package/dest/rollup/checkpoint_header.d.ts +5 -1
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +7 -2
- package/dest/schemas/schemas.d.ts +4 -2
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +2 -1
- package/dest/slashing/types.d.ts +4 -5
- package/dest/slashing/types.d.ts.map +1 -1
- package/dest/slashing/types.js +5 -5
- package/dest/snapshots/types.d.ts +1 -1
- package/dest/snapshots/types.d.ts.map +1 -1
- package/dest/snapshots/types.js +5 -5
- package/dest/stats/stats.d.ts +10 -6
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +24 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +21 -1
- package/dest/tests/mocks.d.ts +5 -4
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +18 -5
- package/dest/trees/append_only_tree_snapshot.js +3 -1
- package/dest/tx/block_header.d.ts +8 -7
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +8 -2
- package/dest/tx/call_context.js +3 -1
- package/dest/tx/global_variable_builder.d.ts +4 -2
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/global_variables.d.ts +6 -1
- package/dest/tx/global_variables.d.ts.map +1 -1
- package/dest/tx/global_variables.js +3 -1
- package/dest/tx/private_execution_result.d.ts +1 -1
- package/dest/tx/private_execution_result.js +1 -1
- package/dest/tx/public_call_request_with_calldata.js +3 -1
- package/dest/tx/simulated_tx.d.ts +1031 -7
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/state_reference.js +3 -1
- package/dest/tx/tree_snapshots.js +3 -1
- package/dest/tx/tx.d.ts +10 -3
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +9 -2
- package/dest/tx/tx_effect.d.ts +1 -1
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +6 -2
- package/dest/tx/tx_execution_request.js +3 -1
- package/dest/tx/validator/tx_validator.d.ts +1 -4
- package/dest/tx/validator/tx_validator.d.ts.map +1 -1
- package/dest/tx/validator/tx_validator.js +4 -4
- package/dest/validators/schemas.d.ts +1 -1
- package/dest/validators/schemas.d.ts.map +1 -1
- package/dest/validators/schemas.js +13 -13
- package/package.json +8 -8
- package/src/abi/abi.ts +39 -33
- package/src/abi/function_selector.ts +8 -0
- package/src/avm/avm.ts +1 -1
- package/src/block/{published_l2_block.ts → checkpointed_l2_block.ts} +58 -3
- package/src/block/index.ts +1 -1
- package/src/block/l2_block_new.ts +17 -7
- package/src/block/l2_block_source.ts +78 -50
- package/src/block/l2_block_stream/interfaces.ts +1 -1
- package/src/block/l2_block_stream/l2_block_stream.ts +9 -0
- package/src/block/test/l2_tips_store_test_suite.ts +2 -1
- package/src/checkpoint/checkpoint.ts +51 -4
- package/src/checkpoint/checkpoint_info.ts +9 -0
- package/src/checkpoint/published_checkpoint.ts +19 -5
- package/src/contract/contract_class_id.ts +1 -1
- package/src/contract/interfaces/contract_class.ts +59 -46
- package/src/contract/interfaces/contract_instance.ts +15 -13
- package/src/contract/interfaces/contract_instance_update.ts +11 -9
- package/src/epoch-helpers/index.ts +11 -9
- package/src/hash/hash.ts +0 -11
- package/src/interfaces/allowed_element.ts +9 -7
- package/src/interfaces/archiver.ts +12 -4
- package/src/interfaces/aztec-node-admin.ts +2 -2
- package/src/interfaces/aztec-node.ts +18 -15
- package/src/interfaces/block-builder.ts +11 -1
- package/src/interfaces/configs.ts +64 -33
- package/src/interfaces/get_logs_response.ts +13 -9
- package/src/interfaces/l2_logs_source.ts +12 -7
- package/src/interfaces/merkle_tree_operations.ts +4 -1
- package/src/interfaces/prover-client.ts +13 -10
- package/src/interfaces/server_circuit_prover.ts +0 -1
- package/src/interfaces/slasher.ts +24 -22
- package/src/interfaces/validator.ts +22 -18
- package/src/interfaces/world_state.ts +16 -9
- package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +2 -4
- package/src/kernel/private_circuit_public_inputs.ts +85 -85
- package/src/logs/index.ts +2 -1
- package/src/logs/log_id.ts +16 -6
- package/src/logs/private_log.ts +2 -1
- package/src/logs/siloed_tag.ts +44 -0
- package/src/logs/tag.ts +42 -0
- package/src/logs/tx_scoped_l2_log.ts +45 -43
- package/src/messaging/l1_to_l2_message.ts +1 -0
- package/src/rollup/avm_proof_data.ts +0 -7
- package/src/rollup/block_rollup_public_inputs.ts +3 -9
- package/src/rollup/checkpoint_constant_data.ts +1 -0
- package/src/rollup/checkpoint_header.ts +4 -0
- package/src/schemas/schemas.ts +4 -0
- package/src/slashing/types.ts +24 -20
- package/src/snapshots/types.ts +33 -29
- package/src/stats/stats.ts +10 -5
- package/src/tests/factories.ts +45 -1
- package/src/tests/mocks.ts +15 -3
- package/src/tx/block_header.ts +12 -7
- package/src/tx/global_variable_builder.ts +8 -1
- package/src/tx/global_variables.ts +6 -0
- package/src/tx/private_execution_result.ts +1 -1
- package/src/tx/tx.ts +9 -2
- package/src/tx/tx_effect.ts +3 -1
- package/src/tx/validator/tx_validator.ts +8 -6
- package/src/validators/schemas.ts +54 -48
- package/dest/block/published_l2_block.d.ts +0 -130
- package/dest/block/published_l2_block.d.ts.map +0 -1
- package/dest/logs/log_with_tx_data.d.ts +0 -19
- package/dest/logs/log_with_tx_data.d.ts.map +0 -1
- package/dest/logs/log_with_tx_data.js +0 -49
- package/src/logs/log_with_tx_data.ts +0 -46
package/src/block/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ export * from './body.js';
|
|
|
7
7
|
export * from './block_parameter.js';
|
|
8
8
|
export * from './l2_block_source.js';
|
|
9
9
|
export * from './block_hash.js';
|
|
10
|
-
export * from './
|
|
10
|
+
export * from './checkpointed_l2_block.js';
|
|
11
11
|
export * from './proposal/index.js';
|
|
12
12
|
export * from './validate_block_result.js';
|
|
13
13
|
export * from './l2_block_info.js';
|
|
@@ -27,7 +27,6 @@ export class L2BlockNew {
|
|
|
27
27
|
public checkpointNumber: CheckpointNumber,
|
|
28
28
|
/** Index of the block within the checkpoint. */
|
|
29
29
|
public indexWithinCheckpoint: number,
|
|
30
|
-
private blockHash: Fr | undefined = undefined,
|
|
31
30
|
) {}
|
|
32
31
|
|
|
33
32
|
get number(): BlockNumber {
|
|
@@ -80,11 +79,23 @@ export class L2BlockNew {
|
|
|
80
79
|
* Returns the block's hash (hash of block header).
|
|
81
80
|
* @returns The block's hash.
|
|
82
81
|
*/
|
|
83
|
-
public
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
public hash(): Promise<Fr> {
|
|
83
|
+
return this.header.hash();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Checks if this block equals another block.
|
|
88
|
+
* @param other - The other block to compare with.
|
|
89
|
+
* @returns True if both blocks are equal.
|
|
90
|
+
*/
|
|
91
|
+
public equals(other: this): boolean {
|
|
92
|
+
return (
|
|
93
|
+
this.archive.equals(other.archive) &&
|
|
94
|
+
this.header.equals(other.header) &&
|
|
95
|
+
this.body.equals(other.body) &&
|
|
96
|
+
this.checkpointNumber === other.checkpointNumber &&
|
|
97
|
+
this.indexWithinCheckpoint === other.indexWithinCheckpoint
|
|
98
|
+
);
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
public toBlobFields(): Fr[] {
|
|
@@ -185,7 +196,6 @@ export class L2BlockNew {
|
|
|
185
196
|
|
|
186
197
|
toBlockInfo(): L2BlockInfo {
|
|
187
198
|
return {
|
|
188
|
-
blockHash: this.blockHash,
|
|
189
199
|
archive: this.archive.root,
|
|
190
200
|
lastArchive: this.header.lastArchive.root,
|
|
191
201
|
blockNumber: this.number,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BlockNumber,
|
|
3
3
|
BlockNumberSchema,
|
|
4
|
-
|
|
4
|
+
CheckpointNumber,
|
|
5
5
|
type EpochNumber,
|
|
6
6
|
type SlotNumber,
|
|
7
7
|
} from '@aztec/foundation/branded-types';
|
|
@@ -18,8 +18,9 @@ import type { BlockHeader } from '../tx/block_header.js';
|
|
|
18
18
|
import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
19
19
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
20
20
|
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
21
|
+
import { type CheckpointedL2Block, PublishedL2Block } from './checkpointed_l2_block.js';
|
|
21
22
|
import type { L2Block } from './l2_block.js';
|
|
22
|
-
import {
|
|
23
|
+
import type { L2BlockNew } from './l2_block_new.js';
|
|
23
24
|
import type { ValidateBlockNegativeResult, ValidateBlockResult } from './validate_block_result.js';
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -50,13 +51,6 @@ export interface L2BlockSource {
|
|
|
50
51
|
*/
|
|
51
52
|
getProvenBlockNumber(): Promise<BlockNumber>;
|
|
52
53
|
|
|
53
|
-
/**
|
|
54
|
-
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
55
|
-
* @param number - The block number to return (inclusive).
|
|
56
|
-
* @returns The requested L2 block.
|
|
57
|
-
*/
|
|
58
|
-
getBlock(number: BlockNumber): Promise<L2Block | undefined>;
|
|
59
|
-
|
|
60
54
|
/**
|
|
61
55
|
* Gets an l2 block header.
|
|
62
56
|
* @param number - The block number to return or 'latest' for the most recent one.
|
|
@@ -65,40 +59,26 @@ export interface L2BlockSource {
|
|
|
65
59
|
getBlockHeader(number: BlockNumber | 'latest'): Promise<BlockHeader | undefined>;
|
|
66
60
|
|
|
67
61
|
/**
|
|
68
|
-
* Gets
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
* @
|
|
72
|
-
* @returns The requested L2 blocks.
|
|
73
|
-
*/
|
|
74
|
-
getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2Block[]>;
|
|
75
|
-
|
|
76
|
-
getPublishedCheckpoints(from: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Gets a checkpoint by the archive root, which should be the root of the archive tree after the requested checkpoint
|
|
80
|
-
* is applied.
|
|
81
|
-
* @param archive - The new archive root of the checkpoint.
|
|
82
|
-
* @returns The requested checkpoint (or undefined if not found).
|
|
62
|
+
* Gets a checkpointed L2 block by block number.
|
|
63
|
+
* Returns undefined if the block doesn't exist or hasn't been checkpointed yet.
|
|
64
|
+
* @param number - The block number to retrieve.
|
|
65
|
+
* @returns The requested checkpointed L2 block (or undefined if not found or not checkpointed).
|
|
83
66
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
/** Equivalent to getBlocks but includes publish data. */
|
|
87
|
-
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
|
|
67
|
+
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined>;
|
|
88
68
|
|
|
89
69
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @param
|
|
92
|
-
* @
|
|
70
|
+
* Retrieves a collection of published checkpoints
|
|
71
|
+
* @param checkpointNumber The first checkpoint to be retrieved
|
|
72
|
+
* @param limit The number of checkpoints to be retrieved
|
|
73
|
+
* @returns The collection of complete checkpoints
|
|
93
74
|
*/
|
|
94
|
-
|
|
75
|
+
getPublishedCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
|
|
95
76
|
|
|
96
77
|
/**
|
|
97
|
-
* Gets
|
|
98
|
-
* @param
|
|
99
|
-
* @returns The requested published block (or undefined if not found).
|
|
78
|
+
* Gets the checkpoints for a given epoch
|
|
79
|
+
* @param epochNumber - Epoch for which we want checkpoint data
|
|
100
80
|
*/
|
|
101
|
-
|
|
81
|
+
getCheckpointsForEpoch(epochNumber: EpochNumber): Promise<Checkpoint[]>;
|
|
102
82
|
|
|
103
83
|
/**
|
|
104
84
|
* Gets a block header by its hash.
|
|
@@ -114,6 +94,13 @@ export interface L2BlockSource {
|
|
|
114
94
|
*/
|
|
115
95
|
getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined>;
|
|
116
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Gets an L2 block by block number.
|
|
99
|
+
* @param number - The block number to return.
|
|
100
|
+
* @returns The requested L2 block (or undefined if not found).
|
|
101
|
+
*/
|
|
102
|
+
getL2BlockNew(number: BlockNumber): Promise<L2BlockNew | undefined>;
|
|
103
|
+
|
|
117
104
|
/**
|
|
118
105
|
* Gets a tx effect.
|
|
119
106
|
* @param txHash - The hash of the tx corresponding to the tx effect.
|
|
@@ -138,20 +125,6 @@ export interface L2BlockSource {
|
|
|
138
125
|
*/
|
|
139
126
|
getL2EpochNumber(): Promise<EpochNumber | undefined>;
|
|
140
127
|
|
|
141
|
-
/**
|
|
142
|
-
* Returns all checkpoints for a given epoch.
|
|
143
|
-
* @dev Use this method only with recent epochs, since it walks the checkpoint list backwards.
|
|
144
|
-
* @param epochNumber - The epoch number to return checkpoints for.
|
|
145
|
-
*/
|
|
146
|
-
getCheckpointsForEpoch(epochNumber: EpochNumber): Promise<Checkpoint[]>;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Returns all blocks for a given epoch.
|
|
150
|
-
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
151
|
-
* @param epochNumber - The epoch number to return blocks for.
|
|
152
|
-
*/
|
|
153
|
-
getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2Block[]>;
|
|
154
|
-
|
|
155
128
|
/**
|
|
156
129
|
* Returns all block headers for a given epoch.
|
|
157
130
|
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
@@ -195,6 +168,61 @@ export interface L2BlockSource {
|
|
|
195
168
|
|
|
196
169
|
/** Force a sync. */
|
|
197
170
|
syncImmediate(): Promise<void>;
|
|
171
|
+
|
|
172
|
+
/* Legacy APIS */
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
176
|
+
* @param number - The block number to return (inclusive).
|
|
177
|
+
* @returns The requested L2 block.
|
|
178
|
+
* @deprecated Use getL2BlockNew instead.
|
|
179
|
+
*/
|
|
180
|
+
getBlock(number: BlockNumber): Promise<L2Block | undefined>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Returns all blocks for a given epoch.
|
|
184
|
+
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
185
|
+
* @param epochNumber - The epoch number to return blocks for.
|
|
186
|
+
*/
|
|
187
|
+
getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2Block[]>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Gets a published block by its block hash.
|
|
191
|
+
* @param blockHash - The block hash to retrieve.
|
|
192
|
+
* @returns The requested block (or undefined if not found).
|
|
193
|
+
*/
|
|
194
|
+
getPublishedBlockByHash(blockHash: Fr): Promise<PublishedL2Block | undefined>;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Gets a published block by its archive root.
|
|
198
|
+
* @param archive - The archive root to retrieve.
|
|
199
|
+
* @returns The requested block (or undefined if not found).
|
|
200
|
+
*/
|
|
201
|
+
getPublishedBlockByArchive(archive: Fr): Promise<PublishedL2Block | undefined>;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
205
|
+
* @param from - Number of the first block to return (inclusive).
|
|
206
|
+
* @param limit - The maximum number of blocks to return.
|
|
207
|
+
* @param proven - If true, only return blocks that have been proven.
|
|
208
|
+
* @returns The requested L2 blocks.
|
|
209
|
+
*/
|
|
210
|
+
getBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<L2Block[]>;
|
|
211
|
+
|
|
212
|
+
/** Equivalent to getBlocks but includes publish data. */
|
|
213
|
+
getPublishedBlocks(from: BlockNumber, limit: number, proven?: boolean): Promise<PublishedL2Block[]>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Interface for classes that can receive and store L2 blocks.
|
|
218
|
+
*/
|
|
219
|
+
export interface L2BlockSink {
|
|
220
|
+
/**
|
|
221
|
+
* Adds a block to the store.
|
|
222
|
+
* @param block - The L2 block to add.
|
|
223
|
+
* @throws If block number is not incremental (i.e., not exactly one more than the last stored block).
|
|
224
|
+
*/
|
|
225
|
+
addBlock(block: L2BlockNew): Promise<void>;
|
|
198
226
|
}
|
|
199
227
|
|
|
200
228
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { PublishedL2Block } from '../checkpointed_l2_block.js';
|
|
1
2
|
import type { L2BlockId, L2Tips } from '../l2_block_source.js';
|
|
2
|
-
import type { PublishedL2Block } from '../published_l2_block.js';
|
|
3
3
|
|
|
4
4
|
/** Interface to the local view of the chain. Implemented by world-state and l2-tips-store. */
|
|
5
5
|
export interface L2BlockStreamLocalDataProvider {
|
|
@@ -26,6 +26,10 @@ export class L2BlockStream {
|
|
|
26
26
|
skipFinalized?: boolean;
|
|
27
27
|
} = {},
|
|
28
28
|
) {
|
|
29
|
+
// Note that RunningPromise is in stopped state by default. This promise won't run until someone invokes `start`,
|
|
30
|
+
// which makes it run periodically, or `sync`, which triggers it once.
|
|
31
|
+
// Users of L2BlockStream decide what mode to run it in (_periodically_ vs _manually triggered_).
|
|
32
|
+
// The default is _manually triggered_.
|
|
29
33
|
this.runningPromise = new RunningPromise(() => this.work(), log, this.opts.pollIntervalMS ?? 1000);
|
|
30
34
|
}
|
|
31
35
|
|
|
@@ -42,6 +46,11 @@ export class L2BlockStream {
|
|
|
42
46
|
return this.runningPromise.isRunning();
|
|
43
47
|
}
|
|
44
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Runs the synchronization process once.
|
|
51
|
+
*
|
|
52
|
+
* If you want to run this process continuously use `start` and `stop` instead.
|
|
53
|
+
*/
|
|
45
54
|
public async sync() {
|
|
46
55
|
this.isSyncing = true;
|
|
47
56
|
await this.runningPromise.trigger();
|
|
@@ -3,6 +3,7 @@ import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
|
3
3
|
import { times } from '@aztec/foundation/collection';
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import { type L2Block, type L2BlockId, PublishedL2Block } from '@aztec/stdlib/block';
|
|
6
|
+
import { L1PublishedData } from '@aztec/stdlib/checkpoint';
|
|
6
7
|
|
|
7
8
|
import { jestExpect as expect } from '@jest/expect';
|
|
8
9
|
|
|
@@ -18,7 +19,7 @@ export function testL2TipsStore(makeTipsStore: () => Promise<L2TipsStore>) {
|
|
|
18
19
|
const makeBlock = (number: number): PublishedL2Block =>
|
|
19
20
|
PublishedL2Block.fromFields({
|
|
20
21
|
block: { number: BlockNumber(number), hash: () => Promise.resolve(new Fr(number)) } as L2Block,
|
|
21
|
-
l1:
|
|
22
|
+
l1: new L1PublishedData(BigInt(number), BigInt(number), `0x${number}`),
|
|
22
23
|
attestations: [],
|
|
23
24
|
});
|
|
24
25
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { encodeCheckpointBlobDataFromBlocks } from '@aztec/blob-lib/encoding';
|
|
2
2
|
import { BlockNumber, CheckpointNumber, CheckpointNumberSchema } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { sum } from '@aztec/foundation/collection';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
5
6
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
@@ -9,6 +10,7 @@ import { z } from 'zod';
|
|
|
9
10
|
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
10
11
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
11
12
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
13
|
+
import type { CheckpointInfo } from './checkpoint_info.js';
|
|
12
14
|
|
|
13
15
|
export class Checkpoint {
|
|
14
16
|
constructor(
|
|
@@ -68,20 +70,65 @@ export class Checkpoint {
|
|
|
68
70
|
return this.blocks.at(-1)!.header.state;
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
public toCheckpointInfo(): CheckpointInfo {
|
|
74
|
+
return {
|
|
75
|
+
archive: this.archive.root,
|
|
76
|
+
slotNumber: this.header.slotNumber,
|
|
77
|
+
checkpointNumber: this.number,
|
|
78
|
+
timestamp: this.header.timestamp,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Returns stats used for logging */
|
|
83
|
+
public getStats() {
|
|
84
|
+
const txEffects = this.blocks.flatMap(block => block.body.txEffects);
|
|
85
|
+
|
|
86
|
+
const logsStats = {
|
|
87
|
+
privateLogCount: sum(txEffects.map(tx => tx.privateLogs.length)),
|
|
88
|
+
publicLogCount: sum(txEffects.map(tx => tx.publicLogs.length)),
|
|
89
|
+
contractClassLogCount: sum(txEffects.map(tx => tx.contractClassLogs.length)),
|
|
90
|
+
contractClassLogSize: sum(txEffects.map(tx => sum(tx.contractClassLogs.map(log => log.emittedLength)))),
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
txCount: txEffects.length,
|
|
95
|
+
blockCount: this.blocks.length,
|
|
96
|
+
slotNumber: this.header.slotNumber,
|
|
97
|
+
checkpointNumber: this.number,
|
|
98
|
+
timestamp: this.header.timestamp,
|
|
99
|
+
...logsStats,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
71
103
|
static async random(
|
|
72
104
|
checkpointNumber = CheckpointNumber(1),
|
|
73
105
|
{
|
|
74
106
|
numBlocks = 1,
|
|
75
107
|
startBlockNumber = 1,
|
|
108
|
+
previousArchive,
|
|
76
109
|
...options
|
|
77
|
-
}: {
|
|
110
|
+
}: {
|
|
111
|
+
numBlocks?: number;
|
|
112
|
+
startBlockNumber?: number;
|
|
113
|
+
previousArchive?: AppendOnlyTreeSnapshot;
|
|
114
|
+
} & Partial<Parameters<typeof CheckpointHeader.random>[0]> &
|
|
78
115
|
Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
|
|
79
116
|
) {
|
|
80
117
|
const header = CheckpointHeader.random(options);
|
|
81
118
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
119
|
+
// Create blocks sequentially to chain archive roots properly.
|
|
120
|
+
// Each block's header.lastArchive must equal the previous block's archive.
|
|
121
|
+
const blocks: L2BlockNew[] = [];
|
|
122
|
+
let lastArchive = previousArchive;
|
|
123
|
+
for (let i = 0; i < numBlocks; i++) {
|
|
124
|
+
const block = await L2BlockNew.random(BlockNumber(startBlockNumber + i), {
|
|
125
|
+
indexWithinCheckpoint: i,
|
|
126
|
+
...options,
|
|
127
|
+
...(lastArchive ? { lastArchive } : {}),
|
|
128
|
+
});
|
|
129
|
+
lastArchive = block.archive;
|
|
130
|
+
blocks.push(block);
|
|
131
|
+
}
|
|
85
132
|
|
|
86
133
|
return new Checkpoint(AppendOnlyTreeSnapshot.random(), header, blocks, checkpointNumber);
|
|
87
134
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { Fr, SlotNumber } from '@aztec/foundation/schemas';
|
|
3
|
+
|
|
4
|
+
export type CheckpointInfo = {
|
|
5
|
+
archive: Fr;
|
|
6
|
+
slotNumber: SlotNumber;
|
|
7
|
+
checkpointNumber: CheckpointNumber;
|
|
8
|
+
timestamp: bigint;
|
|
9
|
+
};
|
|
@@ -18,11 +18,13 @@ export class L1PublishedData {
|
|
|
18
18
|
) {}
|
|
19
19
|
|
|
20
20
|
static get schema() {
|
|
21
|
-
return z
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
return z
|
|
22
|
+
.object({
|
|
23
|
+
blockNumber: schemas.BigInt,
|
|
24
|
+
timestamp: schemas.BigInt,
|
|
25
|
+
blockHash: z.string(),
|
|
26
|
+
})
|
|
27
|
+
.transform(obj => L1PublishedData.fromFields(obj));
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
static random() {
|
|
@@ -36,6 +38,18 @@ export class L1PublishedData {
|
|
|
36
38
|
static fromFields(fields: FieldsOf<L1PublishedData>) {
|
|
37
39
|
return new L1PublishedData(fields.blockNumber, fields.timestamp, fields.blockHash);
|
|
38
40
|
}
|
|
41
|
+
|
|
42
|
+
static fromBuffer(bufferOrReader: Buffer | BufferReader): L1PublishedData {
|
|
43
|
+
const reader = BufferReader.asReader(bufferOrReader);
|
|
44
|
+
const l1BlockNumber = reader.readBigInt();
|
|
45
|
+
const l1BlockHash = reader.readString();
|
|
46
|
+
const l1Timestamp = reader.readBigInt();
|
|
47
|
+
return new L1PublishedData(l1BlockNumber, l1Timestamp, l1BlockHash);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public toBuffer(): Buffer {
|
|
51
|
+
return serializeToBuffer(this.blockNumber, this.blockHash, this.timestamp);
|
|
52
|
+
}
|
|
39
53
|
}
|
|
40
54
|
|
|
41
55
|
export class PublishedCheckpoint {
|
|
@@ -40,7 +40,7 @@ export async function computeContractClassIdWithPreimage(
|
|
|
40
40
|
: await computePublicBytecodeCommitment(contractClass.packedBytecode);
|
|
41
41
|
const id = await poseidon2HashWithSeparator(
|
|
42
42
|
[artifactHash, privateFunctionsRoot, publicBytecodeCommitment],
|
|
43
|
-
GeneratorIndex.
|
|
43
|
+
GeneratorIndex.CONTRACT_CLASS_ID,
|
|
44
44
|
);
|
|
45
45
|
return { id, artifactHash, privateFunctionsRoot, publicBytecodeCommitment };
|
|
46
46
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import {
|
|
2
|
+
import { schemas, zodFor } from '@aztec/foundation/schemas';
|
|
3
3
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
@@ -35,10 +35,12 @@ export interface PrivateFunction {
|
|
|
35
35
|
vkHash: Fr;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const PrivateFunctionSchema =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
const PrivateFunctionSchema = zodFor<PrivateFunction>()(
|
|
39
|
+
z.object({
|
|
40
|
+
selector: FunctionSelector.schema,
|
|
41
|
+
vkHash: schemas.Fr,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
42
44
|
|
|
43
45
|
/** Private function definition with executable bytecode. */
|
|
44
46
|
export interface ExecutablePrivateFunction extends PrivateFunction {
|
|
@@ -46,9 +48,9 @@ export interface ExecutablePrivateFunction extends PrivateFunction {
|
|
|
46
48
|
bytecode: Buffer;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
const ExecutablePrivateFunctionSchema =
|
|
50
|
-
z.object({ bytecode: schemas.Buffer }),
|
|
51
|
-
)
|
|
51
|
+
const ExecutablePrivateFunctionSchema = zodFor<ExecutablePrivateFunction>()(
|
|
52
|
+
PrivateFunctionSchema.and(z.object({ bytecode: schemas.Buffer })),
|
|
53
|
+
);
|
|
52
54
|
|
|
53
55
|
/** Utility function definition. */
|
|
54
56
|
export interface UtilityFunction {
|
|
@@ -58,11 +60,12 @@ export interface UtilityFunction {
|
|
|
58
60
|
bytecode: Buffer;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
const UtilityFunctionSchema =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
})
|
|
63
|
+
const UtilityFunctionSchema = zodFor<UtilityFunction>()(
|
|
64
|
+
z.object({
|
|
65
|
+
selector: FunctionSelector.schema,
|
|
66
|
+
bytecode: schemas.Buffer,
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
66
69
|
|
|
67
70
|
/** Sibling paths and sibling commitments for proving membership of a private function within a contract class. */
|
|
68
71
|
export type PrivateFunctionMembershipProof = {
|
|
@@ -75,15 +78,17 @@ export type PrivateFunctionMembershipProof = {
|
|
|
75
78
|
artifactTreeLeafIndex: number;
|
|
76
79
|
};
|
|
77
80
|
|
|
78
|
-
const PrivateFunctionMembershipProofSchema =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
const PrivateFunctionMembershipProofSchema = zodFor<PrivateFunctionMembershipProof>()(
|
|
82
|
+
z.object({
|
|
83
|
+
artifactMetadataHash: schemas.Fr,
|
|
84
|
+
functionMetadataHash: schemas.Fr,
|
|
85
|
+
utilityFunctionsTreeRoot: schemas.Fr,
|
|
86
|
+
privateFunctionTreeSiblingPath: z.array(schemas.Fr),
|
|
87
|
+
privateFunctionTreeLeafIndex: schemas.Integer,
|
|
88
|
+
artifactTreeSiblingPath: z.array(schemas.Fr),
|
|
89
|
+
artifactTreeLeafIndex: schemas.Integer,
|
|
90
|
+
}),
|
|
91
|
+
);
|
|
87
92
|
|
|
88
93
|
/** A private function with a membership proof. */
|
|
89
94
|
export type ExecutablePrivateFunctionWithMembershipProof = ExecutablePrivateFunction & PrivateFunctionMembershipProof;
|
|
@@ -97,23 +102,27 @@ export type UtilityFunctionMembershipProof = {
|
|
|
97
102
|
artifactTreeLeafIndex: number;
|
|
98
103
|
};
|
|
99
104
|
|
|
100
|
-
const UtilityFunctionMembershipProofSchema =
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
const UtilityFunctionMembershipProofSchema = zodFor<UtilityFunctionMembershipProof>()(
|
|
106
|
+
z.object({
|
|
107
|
+
artifactMetadataHash: schemas.Fr,
|
|
108
|
+
functionMetadataHash: schemas.Fr,
|
|
109
|
+
privateFunctionsArtifactTreeRoot: schemas.Fr,
|
|
110
|
+
artifactTreeSiblingPath: z.array(schemas.Fr),
|
|
111
|
+
artifactTreeLeafIndex: schemas.Integer,
|
|
112
|
+
}),
|
|
113
|
+
);
|
|
107
114
|
|
|
108
115
|
/** A utility function with a membership proof. */
|
|
109
116
|
export type UtilityFunctionWithMembershipProof = UtilityFunction & UtilityFunctionMembershipProof;
|
|
110
117
|
|
|
111
|
-
export const ContractClassSchema =
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
118
|
+
export const ContractClassSchema = zodFor<ContractClass>()(
|
|
119
|
+
z.object({
|
|
120
|
+
version: z.literal(VERSION),
|
|
121
|
+
artifactHash: schemas.Fr,
|
|
122
|
+
privateFunctions: z.array(PrivateFunctionSchema),
|
|
123
|
+
packedBytecode: schemas.Buffer,
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
117
126
|
|
|
118
127
|
/** Commitments to fields of a contract class. */
|
|
119
128
|
interface ContractClassCommitments {
|
|
@@ -128,9 +137,11 @@ interface ContractClassCommitments {
|
|
|
128
137
|
/** A contract class with its precomputed id. */
|
|
129
138
|
export type ContractClassWithId = ContractClass & Pick<ContractClassCommitments, 'id'>;
|
|
130
139
|
|
|
131
|
-
export const ContractClassWithIdSchema =
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
export const ContractClassWithIdSchema = zodFor<ContractClassWithId>()(
|
|
141
|
+
ContractClassSchema.extend({
|
|
142
|
+
id: schemas.Fr,
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
134
145
|
|
|
135
146
|
/** A contract class with public bytecode information, and optional private and utility functions. */
|
|
136
147
|
export type ContractClassPublic = {
|
|
@@ -142,14 +153,16 @@ export type ContractClassPublic = {
|
|
|
142
153
|
export type ContractClassPublicWithCommitment = ContractClassPublic &
|
|
143
154
|
Pick<ContractClassCommitments, 'publicBytecodeCommitment'>;
|
|
144
155
|
|
|
145
|
-
export const ContractClassPublicSchema =
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
export const ContractClassPublicSchema = zodFor<ContractClassPublic>()(
|
|
157
|
+
z
|
|
158
|
+
.object({
|
|
159
|
+
id: schemas.Fr,
|
|
160
|
+
privateFunctionsRoot: schemas.Fr,
|
|
161
|
+
privateFunctions: z.array(ExecutablePrivateFunctionSchema.and(PrivateFunctionMembershipProofSchema)),
|
|
162
|
+
utilityFunctions: z.array(UtilityFunctionSchema.and(UtilityFunctionMembershipProofSchema)),
|
|
163
|
+
})
|
|
164
|
+
.and(ContractClassSchema.omit({ privateFunctions: true })),
|
|
165
|
+
);
|
|
153
166
|
|
|
154
167
|
/** The contract class with the block it was initially deployed at */
|
|
155
168
|
export type ContractClassPublicWithBlockNumber = { l2BlockNumber: number } & ContractClassPublic;
|
|
@@ -4,7 +4,7 @@ import { z } from 'zod';
|
|
|
4
4
|
|
|
5
5
|
import { AztecAddress } from '../../aztec-address/index.js';
|
|
6
6
|
import { PublicKeys } from '../../keys/public_keys.js';
|
|
7
|
-
import {
|
|
7
|
+
import { schemas, zodFor } from '../../schemas/index.js';
|
|
8
8
|
|
|
9
9
|
const VERSION = 1 as const;
|
|
10
10
|
|
|
@@ -32,19 +32,21 @@ export interface ContractInstance {
|
|
|
32
32
|
|
|
33
33
|
export type ContractInstanceWithAddress = ContractInstance & { address: AztecAddress };
|
|
34
34
|
|
|
35
|
-
export const ContractInstanceSchema =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
export const ContractInstanceSchema = zodFor<ContractInstance>()(
|
|
36
|
+
z.object({
|
|
37
|
+
version: z.literal(VERSION),
|
|
38
|
+
salt: schemas.Fr,
|
|
39
|
+
deployer: schemas.AztecAddress,
|
|
40
|
+
currentContractClassId: schemas.Fr,
|
|
41
|
+
originalContractClassId: schemas.Fr,
|
|
42
|
+
initializationHash: schemas.Fr,
|
|
43
|
+
publicKeys: PublicKeys.schema,
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
44
46
|
|
|
45
|
-
export const ContractInstanceWithAddressSchema =
|
|
46
|
-
z.object({ address: schemas.AztecAddress }),
|
|
47
|
-
)
|
|
47
|
+
export const ContractInstanceWithAddressSchema = zodFor<ContractInstanceWithAddress>()(
|
|
48
|
+
ContractInstanceSchema.and(z.object({ address: schemas.AztecAddress })),
|
|
49
|
+
);
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* Creates a ContractInstance from a plain object without Zod validation.
|