@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
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
2
|
-
import {
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { schemas as foundationSchemas } from '@aztec/foundation/schemas';
|
|
4
|
+
import {
|
|
5
|
+
BufferReader,
|
|
6
|
+
bigintToUInt64BE,
|
|
7
|
+
numToUInt32BE,
|
|
8
|
+
serializeArrayOfBufferableToVector,
|
|
9
|
+
} from '@aztec/foundation/serialize';
|
|
3
10
|
|
|
4
11
|
import { z } from 'zod';
|
|
5
12
|
|
|
13
|
+
import { schemas } from '../schemas/schemas.js';
|
|
6
14
|
import { TxHash } from '../tx/tx_hash.js';
|
|
7
|
-
import {
|
|
8
|
-
import { PublicLog } from './public_log.js';
|
|
15
|
+
import type { UInt64 } from '../types/shared.js';
|
|
9
16
|
|
|
10
|
-
// TODO(#14460): Split to private and public versions instead of having this weird mix.
|
|
11
17
|
export class TxScopedL2Log {
|
|
12
18
|
constructor(
|
|
13
19
|
/*
|
|
@@ -15,82 +21,78 @@ export class TxScopedL2Log {
|
|
|
15
21
|
*/
|
|
16
22
|
public txHash: TxHash,
|
|
17
23
|
/*
|
|
18
|
-
* The
|
|
19
|
-
* with the log so the noteHashIndex can be reconstructed after decryption.
|
|
24
|
+
* The block this log is included in
|
|
20
25
|
*/
|
|
21
|
-
public
|
|
26
|
+
public blockNumber: BlockNumber,
|
|
22
27
|
/*
|
|
23
|
-
* The
|
|
24
|
-
* effect and for this reason these indices are independent (a private and public log can have the same index).
|
|
28
|
+
* The timestamp of the block this log is included in
|
|
25
29
|
*/
|
|
26
|
-
public
|
|
30
|
+
public blockTimestamp: UInt64,
|
|
27
31
|
/*
|
|
28
|
-
* The
|
|
32
|
+
* The log data as an array of field elements
|
|
29
33
|
*/
|
|
30
|
-
public
|
|
34
|
+
public logData: Fr[],
|
|
35
|
+
/*
|
|
36
|
+
* The note hashes from the tx effect
|
|
37
|
+
*/
|
|
38
|
+
public noteHashes: Fr[],
|
|
31
39
|
/*
|
|
32
|
-
* The
|
|
40
|
+
* The first nullifier from the tx effect. Used for nonce discovery when processing notes from logs.
|
|
41
|
+
*
|
|
42
|
+
* (Note nonces are computed as `hash(firstNullifier, noteIndexInTx)`.)
|
|
33
43
|
*/
|
|
34
|
-
public
|
|
44
|
+
public firstNullifier: Fr,
|
|
35
45
|
) {}
|
|
36
46
|
|
|
37
|
-
get isFromPublic() {
|
|
38
|
-
return this.log instanceof PublicLog;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
47
|
static get schema() {
|
|
42
48
|
return z
|
|
43
49
|
.object({
|
|
44
50
|
txHash: TxHash.schema,
|
|
45
|
-
dataStartIndexForTx: z.number(),
|
|
46
|
-
logIndexInTx: z.number(),
|
|
47
51
|
blockNumber: BlockNumberSchema,
|
|
48
|
-
|
|
52
|
+
blockTimestamp: schemas.UInt64,
|
|
53
|
+
logData: z.array(foundationSchemas.Fr),
|
|
54
|
+
noteHashes: z.array(foundationSchemas.Fr),
|
|
55
|
+
firstNullifier: foundationSchemas.Fr,
|
|
49
56
|
})
|
|
50
57
|
.transform(
|
|
51
|
-
({ txHash,
|
|
52
|
-
new TxScopedL2Log(txHash,
|
|
58
|
+
({ txHash, blockNumber, blockTimestamp, logData, noteHashes, firstNullifier }) =>
|
|
59
|
+
new TxScopedL2Log(txHash, blockNumber, blockTimestamp, logData, noteHashes, firstNullifier),
|
|
53
60
|
);
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
toBuffer() {
|
|
57
|
-
const isFromPublic = this.log instanceof PublicLog;
|
|
58
64
|
return Buffer.concat([
|
|
59
65
|
this.txHash.toBuffer(),
|
|
60
|
-
numToUInt32BE(this.dataStartIndexForTx),
|
|
61
|
-
numToUInt32BE(this.logIndexInTx),
|
|
62
66
|
numToUInt32BE(this.blockNumber),
|
|
63
|
-
|
|
64
|
-
this.
|
|
67
|
+
bigintToUInt64BE(this.blockTimestamp),
|
|
68
|
+
serializeArrayOfBufferableToVector(this.logData),
|
|
69
|
+
serializeArrayOfBufferableToVector(this.noteHashes),
|
|
70
|
+
this.firstNullifier.toBuffer(),
|
|
65
71
|
]);
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
static fromBuffer(buffer: Buffer) {
|
|
69
75
|
const reader = BufferReader.asReader(buffer);
|
|
70
76
|
const txHash = reader.readObject(TxHash);
|
|
71
|
-
const dataStartIndexForTx = reader.readNumber();
|
|
72
|
-
const logIndexInTx = reader.readNumber();
|
|
73
77
|
const blockNumber = BlockNumber(reader.readNumber());
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
78
|
+
const blockTimestamp = reader.readUInt64();
|
|
79
|
+
const logData = reader.readVector(Fr);
|
|
80
|
+
const noteHashes = reader.readVector(Fr);
|
|
81
|
+
const firstNullifier = reader.readObject(Fr);
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
|
|
82
|
-
return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), log);
|
|
83
|
+
return new TxScopedL2Log(txHash, blockNumber, blockTimestamp, logData, noteHashes, firstNullifier);
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
equals(other: TxScopedL2Log) {
|
|
86
87
|
return (
|
|
87
88
|
this.txHash.equals(other.txHash) &&
|
|
88
|
-
this.dataStartIndexForTx === other.dataStartIndexForTx &&
|
|
89
|
-
this.logIndexInTx === other.logIndexInTx &&
|
|
90
89
|
this.blockNumber === other.blockNumber &&
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.
|
|
90
|
+
this.blockTimestamp === other.blockTimestamp &&
|
|
91
|
+
this.logData.length === other.logData.length &&
|
|
92
|
+
this.logData.every((f, i) => f.equals(other.logData[i])) &&
|
|
93
|
+
this.noteHashes.length === other.noteHashes.length &&
|
|
94
|
+
this.noteHashes.every((h, i) => h.equals(other.noteHashes[i])) &&
|
|
95
|
+
this.firstNullifier.equals(other.firstNullifier)
|
|
94
96
|
);
|
|
95
97
|
}
|
|
96
98
|
}
|
|
@@ -84,6 +84,7 @@ export async function getNonNullifiedL1ToL2MessageWitness(
|
|
|
84
84
|
if (!response) {
|
|
85
85
|
throw new Error(`No L1 to L2 message found for message hash ${messageHash.toString()}`);
|
|
86
86
|
}
|
|
87
|
+
|
|
87
88
|
const [messageIndex, siblingPath] = response;
|
|
88
89
|
|
|
89
90
|
const messageNullifier = await computeL1ToL2MessageNullifier(contractAddress, messageHash, secret);
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED } from '@aztec/constants';
|
|
2
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
|
|
4
3
|
import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
|
|
5
4
|
import type { ProofDataForFixedVk } from '../proofs/proof_data.js';
|
|
6
5
|
|
|
7
6
|
export type AvmProofData = ProofDataForFixedVk<AvmCircuitPublicInputs, typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>;
|
|
8
|
-
|
|
9
|
-
// TODO(#14234)[Unconditional PIs validation]: remove this function.
|
|
10
|
-
export function enhanceProofWithPiValidationFlag(proof: Fr[], skipPublicInputsValidation: boolean): Fr[] {
|
|
11
|
-
const skipPublicInputsField = skipPublicInputsValidation ? new Fr(1) : new Fr(0);
|
|
12
|
-
return [skipPublicInputsField].concat(proof).slice(0, AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED);
|
|
13
|
-
}
|
|
@@ -43,13 +43,9 @@ export class BlockRollupPublicInputs {
|
|
|
43
43
|
*/
|
|
44
44
|
public endSpongeBlob: SpongeBlob,
|
|
45
45
|
/**
|
|
46
|
-
* Timestamp of the
|
|
46
|
+
* Timestamp of the blocks in this block range.
|
|
47
47
|
*/
|
|
48
|
-
public
|
|
49
|
-
/**
|
|
50
|
-
* Timestamp of the last block in this block range.
|
|
51
|
-
*/
|
|
52
|
-
public endTimestamp: UInt64,
|
|
48
|
+
public timestamp: UInt64,
|
|
53
49
|
/**
|
|
54
50
|
* Hash of the headers of all blocks in this block range. It will be combined with the `blockHeadersHash` from
|
|
55
51
|
* other blocks in the same checkpoint to form a wonky tree. The root of that tree becomes the final hash stored in
|
|
@@ -85,7 +81,6 @@ export class BlockRollupPublicInputs {
|
|
|
85
81
|
reader.readObject(SpongeBlob),
|
|
86
82
|
reader.readObject(SpongeBlob),
|
|
87
83
|
reader.readUInt64(),
|
|
88
|
-
reader.readUInt64(),
|
|
89
84
|
Fr.fromBuffer(reader),
|
|
90
85
|
Fr.fromBuffer(reader),
|
|
91
86
|
Fr.fromBuffer(reader),
|
|
@@ -103,8 +98,7 @@ export class BlockRollupPublicInputs {
|
|
|
103
98
|
this.endState,
|
|
104
99
|
this.startSpongeBlob,
|
|
105
100
|
this.endSpongeBlob,
|
|
106
|
-
bigintToUInt64BE(this.
|
|
107
|
-
bigintToUInt64BE(this.endTimestamp),
|
|
101
|
+
bigintToUInt64BE(this.timestamp),
|
|
108
102
|
this.blockHeadersHash,
|
|
109
103
|
this.inHash,
|
|
110
104
|
this.outHash,
|
|
@@ -17,6 +17,10 @@ import { schemas } from '../schemas/index.js';
|
|
|
17
17
|
import { ContentCommitment } from '../tx/content_commitment.js';
|
|
18
18
|
import type { UInt64 } from '../types/shared.js';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Header of a checkpoint. A checkpoint is a collection of blocks submitted to L1 all within the same slot.
|
|
22
|
+
* TODO(palla/mbps): Should this include chainId and version as well? Is this used just in circuits?
|
|
23
|
+
*/
|
|
20
24
|
export class CheckpointHeader {
|
|
21
25
|
constructor(
|
|
22
26
|
/** Root of the archive tree before this block is added. */
|
package/src/schemas/schemas.ts
CHANGED
|
@@ -40,6 +40,9 @@ export const schemas = {
|
|
|
40
40
|
/** Coerces input to UInt32. */
|
|
41
41
|
UInt32: foundationSchemas.UInt32,
|
|
42
42
|
|
|
43
|
+
/** Coerces input to UInt64. */
|
|
44
|
+
UInt64: foundationSchemas.UInt64,
|
|
45
|
+
|
|
43
46
|
/** Accepts a hex string as a Buffer32 type. */
|
|
44
47
|
Buffer32: foundationSchemas.Buffer32 as ZodFor<Buffer32>,
|
|
45
48
|
|
|
@@ -94,6 +97,7 @@ export const NullishToUndefined = (schema: ZodFor<any>) => schema.nullish().tran
|
|
|
94
97
|
|
|
95
98
|
export {
|
|
96
99
|
type ZodFor,
|
|
100
|
+
zodFor,
|
|
97
101
|
bufferSchema,
|
|
98
102
|
hexSchema,
|
|
99
103
|
hexSchemaFor,
|
package/src/slashing/types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { schemas, zodFor } from '../schemas/index.js';
|
|
6
6
|
|
|
7
7
|
export enum OffenseType {
|
|
8
8
|
UNKNOWN = 0,
|
|
@@ -90,12 +90,14 @@ export type Offense = {
|
|
|
90
90
|
|
|
91
91
|
export type OffenseIdentifier = Pick<Offense, 'validator' | 'offenseType' | 'epochOrSlot'>;
|
|
92
92
|
|
|
93
|
-
export const OffenseSchema =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
export const OffenseSchema = zodFor<Offense>()(
|
|
94
|
+
z.object({
|
|
95
|
+
validator: schemas.EthAddress,
|
|
96
|
+
amount: schemas.BigInt,
|
|
97
|
+
offenseType: OffenseTypeSchema,
|
|
98
|
+
epochOrSlot: schemas.BigInt,
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
99
101
|
|
|
100
102
|
/** Offense by a validator in the context of a slash payload */
|
|
101
103
|
export type ValidatorSlashOffense = {
|
|
@@ -120,19 +122,21 @@ export type SlashPayload = {
|
|
|
120
122
|
/** Slash payload with round information from empire slash proposer */
|
|
121
123
|
export type SlashPayloadRound = SlashPayload & { votes: bigint; round: bigint };
|
|
122
124
|
|
|
123
|
-
export const SlashPayloadRoundSchema =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
z.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
export const SlashPayloadRoundSchema = zodFor<SlashPayloadRound>()(
|
|
126
|
+
z.object({
|
|
127
|
+
address: schemas.EthAddress,
|
|
128
|
+
timestamp: schemas.BigInt,
|
|
129
|
+
votes: schemas.BigInt,
|
|
130
|
+
round: schemas.BigInt,
|
|
131
|
+
slashes: z.array(
|
|
132
|
+
z.object({
|
|
133
|
+
validator: schemas.EthAddress,
|
|
134
|
+
amount: schemas.BigInt,
|
|
135
|
+
offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
|
|
136
|
+
}),
|
|
137
|
+
),
|
|
138
|
+
}),
|
|
139
|
+
);
|
|
136
140
|
|
|
137
141
|
/** Votes for a validator slash in the consensus slash proposer */
|
|
138
142
|
export type ValidatorSlashVote = number;
|
package/src/snapshots/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import {
|
|
2
|
+
import { schemas, zodFor } from '@aztec/foundation/schemas';
|
|
3
3
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
@@ -38,33 +38,37 @@ export type SnapshotsIndex = SnapshotsIndexMetadata & {
|
|
|
38
38
|
export type UploadSnapshotMetadata = Pick<SnapshotMetadata, 'l2BlockNumber' | 'l2BlockHash' | 'l1BlockNumber'> &
|
|
39
39
|
Pick<SnapshotsIndex, 'l1ChainId' | 'rollupVersion' | 'rollupAddress'>;
|
|
40
40
|
|
|
41
|
-
export const SnapshotsIndexSchema =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
z.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
export const SnapshotsIndexSchema = zodFor<SnapshotsIndex>()(
|
|
42
|
+
z.object({
|
|
43
|
+
l1ChainId: z.number(),
|
|
44
|
+
rollupVersion: z.number(),
|
|
45
|
+
rollupAddress: schemas.EthAddress,
|
|
46
|
+
snapshots: z.array(
|
|
47
|
+
z.object({
|
|
48
|
+
l2BlockNumber: z.number(),
|
|
49
|
+
l2BlockHash: z.string(),
|
|
50
|
+
l1BlockNumber: z.number(),
|
|
51
|
+
timestamp: z.number(),
|
|
52
|
+
schemaVersions: z.object({
|
|
53
|
+
archiver: z.number(),
|
|
54
|
+
worldState: z.number(),
|
|
55
|
+
}),
|
|
56
|
+
dataUrls: z
|
|
57
|
+
.record(z.enum(SnapshotDataKeys), z.string())
|
|
58
|
+
// See https://stackoverflow.com/questions/77958464/zod-record-with-required-keys
|
|
59
|
+
.refine((obj): obj is Required<typeof obj> => SnapshotDataKeys.every(key => !!obj[key])),
|
|
54
60
|
}),
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.refine((obj): obj is Required<typeof obj> => SnapshotDataKeys.every(key => !!obj[key])),
|
|
59
|
-
}),
|
|
60
|
-
),
|
|
61
|
-
}) satisfies ZodFor<SnapshotsIndex>;
|
|
61
|
+
),
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
62
64
|
|
|
63
|
-
export const UploadSnapshotMetadataSchema =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
export const UploadSnapshotMetadataSchema = zodFor<UploadSnapshotMetadata>()(
|
|
66
|
+
z.object({
|
|
67
|
+
l2BlockNumber: z.number(),
|
|
68
|
+
l2BlockHash: z.string(),
|
|
69
|
+
l1BlockNumber: z.number(),
|
|
70
|
+
l1ChainId: z.number(),
|
|
71
|
+
rollupVersion: z.number(),
|
|
72
|
+
rollupAddress: schemas.EthAddress,
|
|
73
|
+
}),
|
|
74
|
+
);
|
package/src/stats/stats.ts
CHANGED
|
@@ -20,6 +20,13 @@ export type L2BlockStats = {
|
|
|
20
20
|
publicLogCount?: number;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
+
export type CheckpointStats = {
|
|
24
|
+
/** Number of transactions in the checkpoint */
|
|
25
|
+
txCount: number;
|
|
26
|
+
/** Number of blocks in the checkpoint */
|
|
27
|
+
blockCount: number;
|
|
28
|
+
};
|
|
29
|
+
|
|
23
30
|
/** Stats logged for each L1 publish tx.*/
|
|
24
31
|
export type L1PublishStats = {
|
|
25
32
|
/** Address of the sender. */
|
|
@@ -45,11 +52,11 @@ export type L1PublishStats = {
|
|
|
45
52
|
};
|
|
46
53
|
|
|
47
54
|
/** Stats logged for each L1 rollup publish tx.*/
|
|
48
|
-
export type
|
|
55
|
+
export type L1PublishCheckpointStats = {
|
|
49
56
|
/** Name of the event for metrics purposes */
|
|
50
57
|
eventName: 'rollup-published-to-l1';
|
|
51
58
|
} & L1PublishStats &
|
|
52
|
-
|
|
59
|
+
CheckpointStats;
|
|
53
60
|
|
|
54
61
|
/** Stats logged for each L1 rollup publish tx.*/
|
|
55
62
|
export type L1PublishProofStats = {
|
|
@@ -189,8 +196,6 @@ export type CircuitVerificationStats = {
|
|
|
189
196
|
|
|
190
197
|
/** Stats for an L2 block built by a sequencer. */
|
|
191
198
|
export type L2BlockBuiltStats = {
|
|
192
|
-
/** The creator of the block */
|
|
193
|
-
creator: string;
|
|
194
199
|
/** Name of the event. */
|
|
195
200
|
eventName: 'l2-block-built';
|
|
196
201
|
/** Total duration in ms. */
|
|
@@ -272,7 +277,7 @@ export type Stats =
|
|
|
272
277
|
| CircuitSimulationStats
|
|
273
278
|
| CircuitWitnessGenerationStats
|
|
274
279
|
| PublicDBAccessStats
|
|
275
|
-
|
|
|
280
|
+
| L1PublishCheckpointStats
|
|
276
281
|
| L1PublishProofStats
|
|
277
282
|
| L2BlockBuiltStats
|
|
278
283
|
| L2BlockHandledStats
|
package/src/tests/factories.ts
CHANGED
|
@@ -131,6 +131,7 @@ import { PublicKeys, computeAddress } from '../keys/index.js';
|
|
|
131
131
|
import { ContractClassLog, ContractClassLogFields } from '../logs/index.js';
|
|
132
132
|
import { PrivateLog } from '../logs/private_log.js';
|
|
133
133
|
import { FlatPublicLogs, PublicLog } from '../logs/public_log.js';
|
|
134
|
+
import { TxScopedL2Log } from '../logs/tx_scoped_l2_log.js';
|
|
134
135
|
import { CountedL2ToL1Message, L2ToL1Message, ScopedL2ToL1Message } from '../messaging/l2_to_l1_message.js';
|
|
135
136
|
import { ParityBasePrivateInputs } from '../parity/parity_base_private_inputs.js';
|
|
136
137
|
import { ParityPublicInputs } from '../parity/parity_public_inputs.js';
|
|
@@ -173,6 +174,7 @@ import { StateReference } from '../tx/state_reference.js';
|
|
|
173
174
|
import { TreeSnapshots } from '../tx/tree_snapshots.js';
|
|
174
175
|
import { TxConstantData } from '../tx/tx_constant_data.js';
|
|
175
176
|
import { TxContext } from '../tx/tx_context.js';
|
|
177
|
+
import { TxHash } from '../tx/tx_hash.js';
|
|
176
178
|
import { TxRequest } from '../tx/tx_request.js';
|
|
177
179
|
import { Vector } from '../types/index.js';
|
|
178
180
|
import { VkData } from '../vks/index.js';
|
|
@@ -835,7 +837,6 @@ export function makeBlockRollupPublicInputs(seed = 0): BlockRollupPublicInputs {
|
|
|
835
837
|
makeSpongeBlob(seed + 0x600),
|
|
836
838
|
makeSpongeBlob(seed + 0x700),
|
|
837
839
|
BigInt(seed + 0x800),
|
|
838
|
-
BigInt(seed + 0x810),
|
|
839
840
|
fr(seed + 0x820),
|
|
840
841
|
fr(seed + 0x830),
|
|
841
842
|
fr(seed + 0x840),
|
|
@@ -1696,3 +1697,46 @@ export async function makeAvmCircuitInputs(
|
|
|
1696
1697
|
export function fr(n: number): Fr {
|
|
1697
1698
|
return new Fr(BigInt(n));
|
|
1698
1699
|
}
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* Creates a random TxScopedL2Log with private log data.
|
|
1703
|
+
*/
|
|
1704
|
+
export function randomTxScopedPrivateL2Log(opts?: {
|
|
1705
|
+
tag?: Fr;
|
|
1706
|
+
txHash?: TxHash;
|
|
1707
|
+
blockNumber?: number;
|
|
1708
|
+
blockTimestamp?: bigint;
|
|
1709
|
+
noteHashes?: Fr[];
|
|
1710
|
+
firstNullifier?: Fr;
|
|
1711
|
+
}) {
|
|
1712
|
+
const log = PrivateLog.random(opts?.tag);
|
|
1713
|
+
return new TxScopedL2Log(
|
|
1714
|
+
opts?.txHash ?? TxHash.random(),
|
|
1715
|
+
BlockNumber(opts?.blockNumber ?? 1),
|
|
1716
|
+
opts?.blockTimestamp ?? 1n,
|
|
1717
|
+
log.getEmittedFields(),
|
|
1718
|
+
opts?.noteHashes ?? [Fr.random(), Fr.random()],
|
|
1719
|
+
opts?.firstNullifier ?? Fr.random(),
|
|
1720
|
+
);
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Creates a random TxScopedL2Log with public log data.
|
|
1725
|
+
*/
|
|
1726
|
+
export async function randomTxScopedPublicL2Log(opts?: {
|
|
1727
|
+
txHash?: TxHash;
|
|
1728
|
+
blockNumber?: number;
|
|
1729
|
+
blockTimestamp?: bigint;
|
|
1730
|
+
noteHashes?: Fr[];
|
|
1731
|
+
firstNullifier?: Fr;
|
|
1732
|
+
}) {
|
|
1733
|
+
const log = await PublicLog.random();
|
|
1734
|
+
return new TxScopedL2Log(
|
|
1735
|
+
opts?.txHash ?? TxHash.random(),
|
|
1736
|
+
BlockNumber(opts?.blockNumber ?? 1),
|
|
1737
|
+
opts?.blockTimestamp ?? 1n,
|
|
1738
|
+
log.getEmittedFields(),
|
|
1739
|
+
opts?.noteHashes ?? [Fr.random(), Fr.random()],
|
|
1740
|
+
opts?.firstNullifier ?? Fr.random(),
|
|
1741
|
+
);
|
|
1742
|
+
}
|
package/src/tests/mocks.ts
CHANGED
|
@@ -20,10 +20,9 @@ import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
|
|
|
20
20
|
import { PublicDataWrite } from '../avm/public_data_write.js';
|
|
21
21
|
import { RevertCode } from '../avm/revert_code.js';
|
|
22
22
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
23
|
-
import { CommitteeAttestation, L2BlockHeader, L2BlockNew } from '../block/index.js';
|
|
23
|
+
import { CommitteeAttestation, L2BlockHeader, L2BlockNew, PublishedL2Block } from '../block/index.js';
|
|
24
24
|
import { L2Block } from '../block/l2_block.js';
|
|
25
25
|
import type { CommitteeAttestationsAndSigners } from '../block/proposal/attestations_and_signers.js';
|
|
26
|
-
import { PublishedL2Block } from '../block/published_l2_block.js';
|
|
27
26
|
import { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
28
27
|
import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
|
|
29
28
|
import { computeContractAddressFromInstance } from '../contract/contract_address.js';
|
|
@@ -396,6 +395,7 @@ export async function mockCheckpointAndMessages(
|
|
|
396
395
|
numTxsPerBlock = 1,
|
|
397
396
|
numL1ToL2Messages = 1,
|
|
398
397
|
makeBlockOptions = () => ({}),
|
|
398
|
+
previousArchive,
|
|
399
399
|
...options
|
|
400
400
|
}: {
|
|
401
401
|
startBlockNumber?: BlockNumber;
|
|
@@ -403,11 +403,15 @@ export async function mockCheckpointAndMessages(
|
|
|
403
403
|
numTxsPerBlock?: number;
|
|
404
404
|
numL1ToL2Messages?: number;
|
|
405
405
|
makeBlockOptions?: (blockNumber: BlockNumber) => Partial<Parameters<typeof L2BlockNew.random>[1]>;
|
|
406
|
+
previousArchive?: AppendOnlyTreeSnapshot;
|
|
406
407
|
} & Partial<Parameters<typeof Checkpoint.random>[1]> &
|
|
407
408
|
Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
|
|
408
409
|
) {
|
|
409
410
|
const slotNumber = options.slotNumber ?? SlotNumber(checkpointNumber * 10);
|
|
410
411
|
const blocksAndMessages = [];
|
|
412
|
+
// Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
|
|
413
|
+
// The current block's header.lastArchive must equal the previous block's archive.
|
|
414
|
+
let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
|
|
411
415
|
for (let i = 0; i < numBlocks; i++) {
|
|
412
416
|
const blockNumber = BlockNumber(startBlockNumber + i);
|
|
413
417
|
const { block, messages } = {
|
|
@@ -418,9 +422,12 @@ export async function mockCheckpointAndMessages(
|
|
|
418
422
|
slotNumber,
|
|
419
423
|
...options,
|
|
420
424
|
...makeBlockOptions(blockNumber),
|
|
425
|
+
...(lastArchive ? { lastArchive } : {}),
|
|
421
426
|
}),
|
|
422
427
|
messages: mockL1ToL2Messages(numL1ToL2Messages),
|
|
423
428
|
};
|
|
429
|
+
// Update lastArchive for the next block
|
|
430
|
+
lastArchive = block.archive;
|
|
424
431
|
blocksAndMessages.push({ block, messages });
|
|
425
432
|
}
|
|
426
433
|
|
|
@@ -428,8 +435,13 @@ export async function mockCheckpointAndMessages(
|
|
|
428
435
|
const inHash = computeInHashFromL1ToL2Messages(messages);
|
|
429
436
|
const checkpoint = await Checkpoint.random(checkpointNumber, { numBlocks: 0, slotNumber, inHash, ...options });
|
|
430
437
|
checkpoint.blocks = blocksAndMessages.map(({ block }) => block);
|
|
438
|
+
// Set the checkpoint's archive to match the last block's archive for proper chaining.
|
|
439
|
+
// When the archiver reconstructs checkpoints from L1, it uses the checkpoint's archive root
|
|
440
|
+
// from the L1 event to set the last block's archive. Without this, the archive chain breaks.
|
|
441
|
+
checkpoint.archive = lastArchive!;
|
|
431
442
|
|
|
432
|
-
|
|
443
|
+
// Return lastArchive so callers can chain it across multiple checkpoints
|
|
444
|
+
return { checkpoint, messages, lastArchive };
|
|
433
445
|
}
|
|
434
446
|
|
|
435
447
|
export const randomContractArtifact = (): ContractArtifact => ({
|
package/src/tx/block_header.ts
CHANGED
|
@@ -17,22 +17,24 @@ import { StateReference } from './state_reference.js';
|
|
|
17
17
|
|
|
18
18
|
/** A header of an L2 block. */
|
|
19
19
|
export class BlockHeader {
|
|
20
|
+
private _cachedHash?: Promise<Fr>;
|
|
21
|
+
|
|
20
22
|
constructor(
|
|
21
23
|
/** Snapshot of archive before the block is applied. */
|
|
22
|
-
public lastArchive: AppendOnlyTreeSnapshot,
|
|
24
|
+
public readonly lastArchive: AppendOnlyTreeSnapshot,
|
|
23
25
|
/** State reference. */
|
|
24
|
-
public state: StateReference,
|
|
26
|
+
public readonly state: StateReference,
|
|
25
27
|
/**
|
|
26
28
|
* Hash of the sponge blob after the tx effects of this block has been applied.
|
|
27
29
|
* May contain tx effects from the previous blocks in the same checkpoint.
|
|
28
30
|
*/
|
|
29
|
-
public spongeBlobHash: Fr,
|
|
31
|
+
public readonly spongeBlobHash: Fr,
|
|
30
32
|
/** Global variables of an L2 block. */
|
|
31
|
-
public globalVariables: GlobalVariables,
|
|
33
|
+
public readonly globalVariables: GlobalVariables,
|
|
32
34
|
/** Total fees in the block, computed by the root rollup circuit */
|
|
33
|
-
public totalFees: Fr,
|
|
35
|
+
public readonly totalFees: Fr,
|
|
34
36
|
/** Total mana used in the block, computed by the root rollup circuit */
|
|
35
|
-
public totalManaUsed: Fr,
|
|
37
|
+
public readonly totalManaUsed: Fr,
|
|
36
38
|
) {}
|
|
37
39
|
|
|
38
40
|
static get schema(): ZodFor<BlockHeader> {
|
|
@@ -160,7 +162,10 @@ export class BlockHeader {
|
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
hash(): Promise<Fr> {
|
|
163
|
-
|
|
165
|
+
if (!this._cachedHash) {
|
|
166
|
+
this._cachedHash = poseidon2HashWithSeparator(this.toFields(), GeneratorIndex.BLOCK_HASH);
|
|
167
|
+
}
|
|
168
|
+
return this._cachedHash;
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
|
|
@@ -4,7 +4,7 @@ import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
|
4
4
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
5
|
import type { GasFees } from '../gas/gas_fees.js';
|
|
6
6
|
import type { UInt32 } from '../types/index.js';
|
|
7
|
-
import type { GlobalVariables } from './global_variables.js';
|
|
7
|
+
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Interface for building global variables for Aztec blocks.
|
|
@@ -26,4 +26,11 @@ export interface GlobalVariableBuilder {
|
|
|
26
26
|
feeRecipient: AztecAddress,
|
|
27
27
|
slotNumber?: SlotNumber,
|
|
28
28
|
): Promise<GlobalVariables>;
|
|
29
|
+
|
|
30
|
+
/** Builds global variables that are constant throughout a checkpoint. */
|
|
31
|
+
buildCheckpointGlobalVariables(
|
|
32
|
+
coinbase: EthAddress,
|
|
33
|
+
feeRecipient: AztecAddress,
|
|
34
|
+
slotNumber: SlotNumber,
|
|
35
|
+
): Promise<CheckpointGlobalVariables>;
|
|
29
36
|
}
|
|
@@ -21,6 +21,12 @@ import { GasFees } from '../gas/gas_fees.js';
|
|
|
21
21
|
import { schemas } from '../schemas/index.js';
|
|
22
22
|
import type { UInt64 } from '../types/index.js';
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Global variables that are constant across the entire slot.
|
|
26
|
+
* TODO(palla/mbps): Should timestamp be included here as well?
|
|
27
|
+
*/
|
|
28
|
+
export type CheckpointGlobalVariables = Omit<FieldsOf<GlobalVariables>, 'blockNumber' | 'timestamp'>;
|
|
29
|
+
|
|
24
30
|
/**
|
|
25
31
|
* Global variables of the L2 block.
|
|
26
32
|
*/
|
|
@@ -139,7 +139,7 @@ export class PrivateCallExecutionResult {
|
|
|
139
139
|
public returnValues: Fr[],
|
|
140
140
|
/** The offchain effects emitted during execution of this function call via the `emit_offchain_effect` oracle. */
|
|
141
141
|
public offchainEffects: { data: Fr[] }[],
|
|
142
|
-
/** The pre
|
|
142
|
+
/** The pre-tags used in this tx to compute tags for private logs */
|
|
143
143
|
public preTags: PreTag[],
|
|
144
144
|
/** The nested executions. */
|
|
145
145
|
public nestedExecutionResults: PrivateCallExecutionResult[],
|