@aztec/stdlib 1.0.0-nightly.20250708 → 1.0.0-staging.0
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/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +6 -3
- package/dest/abi/index.d.ts +0 -1
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +0 -1
- package/dest/block/l2_block.d.ts +0 -7
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +0 -8
- package/dest/block/l2_block_stream/l2_block_stream.js +1 -1
- package/dest/block/proposal/committee_attestation.d.ts +3 -3
- package/dest/block/proposal/committee_attestation.d.ts.map +1 -1
- package/dest/block/proposal/committee_attestation.js +2 -41
- package/dest/contract/contract_instance_update.d.ts +1 -2
- package/dest/contract/contract_instance_update.d.ts.map +1 -1
- package/dest/contract/contract_instance_update.js +6 -6
- package/dest/contract/interfaces/contract_data_source.d.ts +2 -5
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance_update.d.ts +8 -9
- package/dest/contract/interfaces/contract_instance_update.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance_update.js +1 -1
- package/dest/gas/gas.d.ts +0 -1
- package/dest/gas/gas.d.ts.map +1 -1
- package/dest/gas/gas.js +0 -3
- package/dest/hash/hash.d.ts +1 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +3 -7
- package/dest/interfaces/archiver.js +1 -1
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +1 -3
- package/dest/interfaces/aztec-node.d.ts +1 -1
- package/dest/interfaces/client.d.ts +0 -1
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/client.js +0 -1
- package/dest/interfaces/configs.d.ts +0 -10
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +1 -3
- package/dest/interfaces/proving-job.d.ts +17 -38
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/proving-job.js +0 -13
- package/dest/interfaces/pxe.d.ts +0 -2
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/server.d.ts +1 -3
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +1 -3
- package/dest/interfaces/server_circuit_prover.d.ts +0 -2
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/tx-collector.d.ts +15 -0
- package/dest/interfaces/tx-collector.d.ts.map +1 -0
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -6
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +20 -18
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +10 -7
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +32 -17
- package/dest/kernel/hints/build_transient_data_hints.d.ts +1 -2
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +8 -7
- package/dest/kernel/hints/index.d.ts +1 -0
- package/dest/kernel/hints/index.d.ts.map +1 -1
- package/dest/kernel/hints/index.js +1 -0
- package/dest/kernel/hints/note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/note_hash_read_request_hints.js +4 -4
- package/dest/kernel/hints/nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/nullifier_read_request_hints.js +4 -4
- package/dest/kernel/hints/read_request_hints.d.ts +17 -17
- package/dest/kernel/hints/read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/read_request_hints.js +28 -28
- package/dest/kernel/hints/rollup_validation_requests.d.ts +38 -0
- package/dest/kernel/hints/rollup_validation_requests.d.ts.map +1 -0
- package/dest/kernel/hints/rollup_validation_requests.js +57 -0
- package/dest/kernel/index.d.ts +0 -1
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +0 -1
- package/dest/kernel/private_accumulated_data.d.ts +15 -16
- package/dest/kernel/private_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_accumulated_data.js +3 -3
- package/dest/kernel/private_circuit_public_inputs.d.ts +27 -28
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +20 -38
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +0 -9
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.js +4 -8
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +1 -10
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +6 -9
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +4 -11
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +18 -20
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts +4 -4
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_to_public_kernel_circuit_public_inputs.js +10 -9
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts +11 -11
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.js +12 -11
- package/dest/kernel/private_validation_requests.d.ts +20 -8
- package/dest/kernel/private_validation_requests.d.ts.map +1 -1
- package/dest/kernel/private_validation_requests.js +21 -9
- package/dest/kernel/utils/order_and_comparison.d.ts +3 -0
- package/dest/kernel/utils/order_and_comparison.d.ts.map +1 -1
- package/dest/kernel/utils/order_and_comparison.js +19 -0
- package/dest/messaging/l2_to_l1_message.d.ts +0 -2
- package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_message.js +0 -7
- package/dest/p2p/block_proposal.d.ts +1 -8
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +8 -21
- package/dest/p2p/consensus_payload.d.ts +11 -3
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +22 -13
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +3 -5
- package/dest/proofs/proving_request_type.d.ts +7 -8
- package/dest/proofs/proving_request_type.d.ts.map +1 -1
- package/dest/proofs/proving_request_type.js +7 -8
- package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts +9 -0
- package/dest/rollup/base_or_merge_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/base_or_merge_rollup_public_inputs.js +8 -3
- package/dest/rollup/empty_block_root_rollup_inputs.d.ts +3 -2
- package/dest/rollup/empty_block_root_rollup_inputs.d.ts.map +1 -1
- package/dest/rollup/empty_block_root_rollup_inputs.js +6 -3
- package/dest/rollup/index.d.ts +0 -1
- package/dest/rollup/index.d.ts.map +1 -1
- package/dest/rollup/index.js +0 -1
- package/dest/shared_mutable/scheduled_delay_change.d.ts +5 -5
- package/dest/shared_mutable/scheduled_delay_change.d.ts.map +1 -1
- package/dest/shared_mutable/scheduled_delay_change.js +5 -5
- package/dest/shared_mutable/scheduled_value_change.d.ts +3 -4
- package/dest/shared_mutable/scheduled_value_change.d.ts.map +1 -1
- package/dest/shared_mutable/scheduled_value_change.js +7 -7
- package/dest/shared_mutable/shared_mutable_values.js +7 -7
- package/dest/stats/stats.d.ts +1 -1
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +2 -0
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +25 -23
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +12 -14
- package/dest/tx/index.d.ts +1 -0
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +1 -0
- package/dest/tx/max_block_number.d.ts +54 -0
- package/dest/tx/max_block_number.d.ts.map +1 -0
- package/dest/tx/max_block_number.js +64 -0
- package/dest/tx/offchain_effect.d.ts.map +1 -1
- package/dest/tx/offchain_effect.js +0 -1
- package/dest/tx/private_execution_result.d.ts +2 -2
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +11 -11
- package/dest/tx/simulated_tx.js +1 -1
- package/dest/tx/tx.d.ts +2 -7
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +0 -8
- package/dest/tx/validator/error_texts.d.ts +1 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +1 -1
- package/dest/types/shared.d.ts +8 -0
- package/dest/types/shared.d.ts.map +1 -1
- package/dest/types/shared.js +8 -0
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/vks/verification_key.d.ts +0 -1
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/verification_key.js +0 -5
- package/package.json +7 -7
- package/src/abi/decoder.ts +6 -3
- package/src/abi/index.ts +0 -1
- package/src/block/l2_block.ts +0 -16
- package/src/block/l2_block_stream/l2_block_stream.ts +1 -1
- package/src/block/proposal/committee_attestation.ts +3 -49
- package/src/contract/contract_instance_update.ts +6 -7
- package/src/contract/interfaces/contract_data_source.ts +2 -5
- package/src/contract/interfaces/contract_instance_update.ts +3 -4
- package/src/gas/gas.ts +0 -4
- package/src/hash/hash.ts +3 -7
- package/src/interfaces/archiver.ts +1 -1
- package/src/interfaces/aztec-node-admin.ts +1 -8
- package/src/interfaces/aztec-node.ts +1 -1
- package/src/interfaces/client.ts +0 -1
- package/src/interfaces/configs.ts +0 -6
- package/src/interfaces/proving-job.ts +0 -21
- package/src/interfaces/pxe.ts +0 -2
- package/src/interfaces/server.ts +1 -3
- package/src/interfaces/server_circuit_prover.ts +0 -9
- package/src/interfaces/tx-collector.ts +17 -0
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +30 -28
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +59 -28
- package/src/kernel/hints/build_transient_data_hints.ts +11 -9
- package/src/kernel/hints/index.ts +1 -0
- package/src/kernel/hints/note_hash_read_request_hints.ts +16 -4
- package/src/kernel/hints/nullifier_read_request_hints.ts +16 -4
- package/src/kernel/hints/read_request_hints.ts +22 -22
- package/src/kernel/hints/rollup_validation_requests.ts +73 -0
- package/src/kernel/index.ts +0 -1
- package/src/kernel/private_accumulated_data.ts +23 -23
- package/src/kernel/private_circuit_public_inputs.ts +70 -94
- package/src/kernel/private_kernel_circuit_public_inputs.ts +1 -9
- package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +4 -13
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +20 -20
- package/src/kernel/private_to_public_kernel_circuit_public_inputs.ts +7 -7
- package/src/kernel/private_to_rollup_kernel_circuit_public_inputs.ts +10 -16
- package/src/kernel/private_validation_requests.ts +50 -19
- package/src/kernel/utils/order_and_comparison.ts +25 -0
- package/src/messaging/l2_to_l1_message.ts +0 -9
- package/src/p2p/block_proposal.ts +5 -23
- package/src/p2p/consensus_payload.ts +29 -10
- package/src/p2p/topic_type.ts +1 -3
- package/src/proofs/proving_request_type.ts +0 -1
- package/src/rollup/base_or_merge_rollup_public_inputs.ts +8 -0
- package/src/rollup/empty_block_root_rollup_inputs.ts +7 -2
- package/src/rollup/index.ts +0 -1
- package/src/shared_mutable/scheduled_delay_change.ts +6 -6
- package/src/shared_mutable/scheduled_value_change.ts +5 -7
- package/src/shared_mutable/shared_mutable_values.ts +9 -9
- package/src/stats/stats.ts +0 -1
- package/src/tests/factories.ts +29 -34
- package/src/tests/mocks.ts +9 -7
- package/src/tx/index.ts +1 -0
- package/src/tx/max_block_number.ts +81 -0
- package/src/tx/offchain_effect.ts +0 -1
- package/src/tx/private_execution_result.ts +9 -11
- package/src/tx/simulated_tx.ts +2 -2
- package/src/tx/tx.ts +1 -14
- package/src/tx/validator/error_texts.ts +1 -1
- package/src/types/shared.ts +9 -0
- package/src/versioning/versioning.ts +3 -0
- package/src/vks/verification_key.ts +0 -6
- package/dest/abi/authorization_selector.d.ts +0 -52
- package/dest/abi/authorization_selector.d.ts.map +0 -1
- package/dest/abi/authorization_selector.js +0 -70
- package/dest/interfaces/tx_provider.d.ts +0 -24
- package/dest/interfaces/tx_provider.d.ts.map +0 -1
- package/dest/kernel/claimed_length_array.d.ts +0 -34
- package/dest/kernel/claimed_length_array.d.ts.map +0 -1
- package/dest/kernel/claimed_length_array.js +0 -58
- package/dest/rollup/padding_block_root_rollup_inputs.d.ts +0 -20
- package/dest/rollup/padding_block_root_rollup_inputs.d.ts.map +0 -1
- package/dest/rollup/padding_block_root_rollup_inputs.js +0 -39
- package/src/abi/authorization_selector.ts +0 -95
- package/src/interfaces/tx_provider.ts +0 -16
- package/src/kernel/claimed_length_array.ts +0 -104
- package/src/rollup/padding_block_root_rollup_inputs.ts +0 -47
- /package/dest/interfaces/{tx_provider.js → tx-collector.js} +0 -0
|
@@ -2,14 +2,14 @@ import { GeneratorIndex, PRIVATE_TO_ROLLUP_KERNEL_CIRCUIT_PUBLIC_INPUTS_LENGTH }
|
|
|
2
2
|
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto';
|
|
3
3
|
import type { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { bufferSchemaFor } from '@aztec/foundation/schemas';
|
|
5
|
-
import { BufferReader,
|
|
5
|
+
import { BufferReader, serializeToBuffer, serializeToFields } from '@aztec/foundation/serialize';
|
|
6
6
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
7
7
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
8
8
|
|
|
9
9
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
10
10
|
import { Gas } from '../gas/gas.js';
|
|
11
11
|
import { TxConstantData } from '../tx/tx_constant_data.js';
|
|
12
|
-
import
|
|
12
|
+
import { RollupValidationRequests } from './hints/rollup_validation_requests.js';
|
|
13
13
|
import { PrivateToRollupAccumulatedData } from './private_to_rollup_accumulated_data.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -22,6 +22,10 @@ export class PrivateToRollupKernelCircuitPublicInputs {
|
|
|
22
22
|
* Data which is not modified by the circuits.
|
|
23
23
|
*/
|
|
24
24
|
public constants: TxConstantData,
|
|
25
|
+
/**
|
|
26
|
+
* Validation requests accumulated from private and public execution to be completed by the rollup.
|
|
27
|
+
*/
|
|
28
|
+
public rollupValidationRequests: RollupValidationRequests,
|
|
25
29
|
/**
|
|
26
30
|
* Data accumulated from both public and private circuits.
|
|
27
31
|
*/
|
|
@@ -34,10 +38,6 @@ export class PrivateToRollupKernelCircuitPublicInputs {
|
|
|
34
38
|
* The address of the fee payer for the transaction.
|
|
35
39
|
*/
|
|
36
40
|
public feePayer: AztecAddress,
|
|
37
|
-
/**
|
|
38
|
-
* The timestamp by which the transaction must be included in a block.
|
|
39
|
-
*/
|
|
40
|
-
public includeByTimestamp: UInt64,
|
|
41
41
|
) {}
|
|
42
42
|
|
|
43
43
|
getNonEmptyNullifiers() {
|
|
@@ -45,13 +45,7 @@ export class PrivateToRollupKernelCircuitPublicInputs {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
toBuffer() {
|
|
48
|
-
return serializeToBuffer(
|
|
49
|
-
this.constants,
|
|
50
|
-
this.end,
|
|
51
|
-
this.gasUsed,
|
|
52
|
-
this.feePayer,
|
|
53
|
-
bigintToUInt64BE(this.includeByTimestamp),
|
|
54
|
-
);
|
|
48
|
+
return serializeToBuffer(this.constants, this.rollupValidationRequests, this.end, this.gasUsed, this.feePayer);
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
/**
|
|
@@ -63,20 +57,20 @@ export class PrivateToRollupKernelCircuitPublicInputs {
|
|
|
63
57
|
const reader = BufferReader.asReader(buffer);
|
|
64
58
|
return new PrivateToRollupKernelCircuitPublicInputs(
|
|
65
59
|
reader.readObject(TxConstantData),
|
|
60
|
+
reader.readObject(RollupValidationRequests),
|
|
66
61
|
reader.readObject(PrivateToRollupAccumulatedData),
|
|
67
62
|
reader.readObject(Gas),
|
|
68
63
|
reader.readObject(AztecAddress),
|
|
69
|
-
reader.readUInt64(),
|
|
70
64
|
);
|
|
71
65
|
}
|
|
72
66
|
|
|
73
67
|
static empty() {
|
|
74
68
|
return new PrivateToRollupKernelCircuitPublicInputs(
|
|
75
69
|
TxConstantData.empty(),
|
|
70
|
+
RollupValidationRequests.empty(),
|
|
76
71
|
PrivateToRollupAccumulatedData.empty(),
|
|
77
72
|
Gas.empty(),
|
|
78
73
|
AztecAddress.ZERO,
|
|
79
|
-
0n,
|
|
80
74
|
);
|
|
81
75
|
}
|
|
82
76
|
|
|
@@ -94,7 +88,7 @@ export class PrivateToRollupKernelCircuitPublicInputs {
|
|
|
94
88
|
}
|
|
95
89
|
|
|
96
90
|
static getFields(fields: FieldsOf<PrivateToRollupKernelCircuitPublicInputs>) {
|
|
97
|
-
return [fields.constants, fields.
|
|
91
|
+
return [fields.constants, fields.rollupValidationRequests, fields.end, fields.gasUsed, fields.feePayer] as const;
|
|
98
92
|
}
|
|
99
93
|
|
|
100
94
|
/** Creates an instance from a hex string. */
|
|
@@ -3,14 +3,17 @@ import {
|
|
|
3
3
|
MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
|
|
4
4
|
MAX_NULLIFIER_READ_REQUESTS_PER_TX,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
|
-
import {
|
|
6
|
+
import { makeTuple } from '@aztec/foundation/array';
|
|
7
|
+
import { arraySerializedSizeOfNonEmpty } from '@aztec/foundation/collection';
|
|
8
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
9
|
+
import { BufferReader, FieldReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
7
10
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
8
11
|
|
|
9
12
|
import { inspect } from 'util';
|
|
10
13
|
|
|
11
14
|
import { ScopedKeyValidationRequestAndGenerator } from '../kernel/hints/scoped_key_validation_request_and_generator.js';
|
|
12
|
-
import { ClaimedLengthArray, ClaimedLengthArrayFromBuffer } from './claimed_length_array.js';
|
|
13
15
|
import { ScopedReadRequest } from './hints/read_request.js';
|
|
16
|
+
import { RollupValidationRequests } from './hints/rollup_validation_requests.js';
|
|
14
17
|
import { OptionalNumber } from './utils/optional_number.js';
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -18,18 +21,23 @@ import { OptionalNumber } from './utils/optional_number.js';
|
|
|
18
21
|
*/
|
|
19
22
|
export class PrivateValidationRequests {
|
|
20
23
|
constructor(
|
|
24
|
+
/**
|
|
25
|
+
* Validation requests that cannot be fulfilled in the current context (private or public), and must be instead be
|
|
26
|
+
* forwarded to the rollup for it to take care of them.
|
|
27
|
+
*/
|
|
28
|
+
public forRollup: RollupValidationRequests,
|
|
21
29
|
/**
|
|
22
30
|
* All the read requests made in this transaction.
|
|
23
31
|
*/
|
|
24
|
-
public noteHashReadRequests:
|
|
32
|
+
public noteHashReadRequests: Tuple<ScopedReadRequest, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX>,
|
|
25
33
|
/**
|
|
26
34
|
* All the nullifier read requests made in this transaction.
|
|
27
35
|
*/
|
|
28
|
-
public nullifierReadRequests:
|
|
36
|
+
public nullifierReadRequests: Tuple<ScopedReadRequest, typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX>,
|
|
29
37
|
/**
|
|
30
38
|
* All the key validation requests made in this transaction.
|
|
31
39
|
*/
|
|
32
|
-
public scopedKeyValidationRequestsAndGenerators:
|
|
40
|
+
public scopedKeyValidationRequestsAndGenerators: Tuple<
|
|
33
41
|
ScopedKeyValidationRequestAndGenerator,
|
|
34
42
|
typeof MAX_KEY_VALIDATION_REQUESTS_PER_TX
|
|
35
43
|
>,
|
|
@@ -43,15 +51,17 @@ export class PrivateValidationRequests {
|
|
|
43
51
|
|
|
44
52
|
getSize() {
|
|
45
53
|
return (
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
54
|
+
this.forRollup.getSize() +
|
|
55
|
+
arraySerializedSizeOfNonEmpty(this.noteHashReadRequests) +
|
|
56
|
+
arraySerializedSizeOfNonEmpty(this.nullifierReadRequests) +
|
|
57
|
+
arraySerializedSizeOfNonEmpty(this.scopedKeyValidationRequestsAndGenerators) +
|
|
49
58
|
this.splitCounter.getSize()
|
|
50
59
|
);
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
toBuffer() {
|
|
54
63
|
return serializeToBuffer(
|
|
64
|
+
this.forRollup,
|
|
55
65
|
this.noteHashReadRequests,
|
|
56
66
|
this.nullifierReadRequests,
|
|
57
67
|
this.scopedKeyValidationRequestsAndGenerators,
|
|
@@ -63,6 +73,17 @@ export class PrivateValidationRequests {
|
|
|
63
73
|
return bufferToHex(this.toBuffer());
|
|
64
74
|
}
|
|
65
75
|
|
|
76
|
+
static fromFields(fields: Fr[] | FieldReader) {
|
|
77
|
+
const reader = FieldReader.asReader(fields);
|
|
78
|
+
return new PrivateValidationRequests(
|
|
79
|
+
reader.readObject(RollupValidationRequests),
|
|
80
|
+
reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ScopedReadRequest),
|
|
81
|
+
reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest),
|
|
82
|
+
reader.readArray(MAX_KEY_VALIDATION_REQUESTS_PER_TX, ScopedKeyValidationRequestAndGenerator),
|
|
83
|
+
reader.readObject(OptionalNumber),
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
66
87
|
/**
|
|
67
88
|
* Deserializes from a buffer or reader, corresponding to a write in cpp.
|
|
68
89
|
* @param buffer - Buffer or reader to read from.
|
|
@@ -71,11 +92,10 @@ export class PrivateValidationRequests {
|
|
|
71
92
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
72
93
|
const reader = BufferReader.asReader(buffer);
|
|
73
94
|
return new PrivateValidationRequests(
|
|
74
|
-
reader.readObject(
|
|
75
|
-
reader.
|
|
76
|
-
reader.
|
|
77
|
-
|
|
78
|
-
),
|
|
95
|
+
reader.readObject(RollupValidationRequests),
|
|
96
|
+
reader.readArray(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ScopedReadRequest),
|
|
97
|
+
reader.readArray(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest),
|
|
98
|
+
reader.readArray(MAX_KEY_VALIDATION_REQUESTS_PER_TX, ScopedKeyValidationRequestAndGenerator),
|
|
79
99
|
reader.readObject(OptionalNumber),
|
|
80
100
|
);
|
|
81
101
|
}
|
|
@@ -91,18 +111,29 @@ export class PrivateValidationRequests {
|
|
|
91
111
|
|
|
92
112
|
static empty() {
|
|
93
113
|
return new PrivateValidationRequests(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
RollupValidationRequests.empty(),
|
|
115
|
+
makeTuple(MAX_NOTE_HASH_READ_REQUESTS_PER_TX, ScopedReadRequest.empty),
|
|
116
|
+
makeTuple(MAX_NULLIFIER_READ_REQUESTS_PER_TX, ScopedReadRequest.empty),
|
|
117
|
+
makeTuple(MAX_KEY_VALIDATION_REQUESTS_PER_TX, ScopedKeyValidationRequestAndGenerator.empty),
|
|
97
118
|
OptionalNumber.empty(),
|
|
98
119
|
);
|
|
99
120
|
}
|
|
100
121
|
|
|
101
122
|
[inspect.custom]() {
|
|
102
123
|
return `PrivateValidationRequests {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
124
|
+
forRollup: ${inspect(this.forRollup)},
|
|
125
|
+
noteHashReadRequests: [${this.noteHashReadRequests
|
|
126
|
+
.filter(x => !x.isEmpty())
|
|
127
|
+
.map(h => inspect(h))
|
|
128
|
+
.join(', ')}],
|
|
129
|
+
nullifierReadRequests: [${this.nullifierReadRequests
|
|
130
|
+
.filter(x => !x.isEmpty())
|
|
131
|
+
.map(h => inspect(h))
|
|
132
|
+
.join(', ')}],
|
|
133
|
+
scopedKeyValidationRequestsAndGenerators: [${this.scopedKeyValidationRequestsAndGenerators
|
|
134
|
+
.filter(x => !x.isEmpty())
|
|
135
|
+
.map(h => inspect(h))
|
|
136
|
+
.join(', ')}],
|
|
106
137
|
splitCounter: ${this.splitCounter.getSize()}
|
|
107
138
|
`;
|
|
108
139
|
}
|
|
@@ -17,6 +17,23 @@ export function countAccumulatedItems<T extends IsEmpty>(arr: T[]) {
|
|
|
17
17
|
}, 0);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// Merges two arrays of length N into an array of length N.
|
|
21
|
+
export function mergeAccumulatedData<T extends IsEmpty, N extends number>(
|
|
22
|
+
arr0: Tuple<T, N>,
|
|
23
|
+
arr1: Tuple<T, N>,
|
|
24
|
+
length: N = arr0.length as N, // Need this for ts to infer the return Tuple length.
|
|
25
|
+
): Tuple<T, N> {
|
|
26
|
+
const numNonEmptyItems0 = countAccumulatedItems(arr0);
|
|
27
|
+
const numNonEmptyItems1 = countAccumulatedItems(arr1);
|
|
28
|
+
if (numNonEmptyItems0 + numNonEmptyItems1 > length) {
|
|
29
|
+
throw new Error('Combined non-empty items exceeded the maximum allowed.');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const arr = [...arr0] as Tuple<T, N>;
|
|
33
|
+
arr1.slice(0, numNonEmptyItems1).forEach((item, i) => (arr[i + numNonEmptyItems0] = item));
|
|
34
|
+
return arr;
|
|
35
|
+
}
|
|
36
|
+
|
|
20
37
|
// Sort items by a provided compare function. All empty items are padded to the right.
|
|
21
38
|
function genericSort<T extends IsEmpty, N extends number>(
|
|
22
39
|
arr: Tuple<T, N>,
|
|
@@ -44,3 +61,11 @@ export function sortByCounter<T extends Ordered & IsEmpty, N extends number>(
|
|
|
44
61
|
): Tuple<T, N> {
|
|
45
62
|
return genericSort(arr, compareByCounter, ascending);
|
|
46
63
|
}
|
|
64
|
+
|
|
65
|
+
export function isEmptyArray<T extends IsEmpty>(arr: T[]): boolean {
|
|
66
|
+
return arr.every(item => item.isEmpty());
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function getNonEmptyItems<T extends IsEmpty>(arr: T[]): T[] {
|
|
70
|
+
return arr.filter(item => !item.isEmpty());
|
|
71
|
+
}
|
|
@@ -203,13 +203,4 @@ export class ScopedCountedL2ToL1Message {
|
|
|
203
203
|
toBuffer(): Buffer {
|
|
204
204
|
return serializeToBuffer(this.inner, this.contractAddress);
|
|
205
205
|
}
|
|
206
|
-
|
|
207
|
-
static fromFields(fields: Fr[] | FieldReader) {
|
|
208
|
-
const reader = FieldReader.asReader(fields);
|
|
209
|
-
return new ScopedCountedL2ToL1Message(reader.readObject(CountedL2ToL1Message), reader.readObject(AztecAddress));
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
toFields(): Fr[] {
|
|
213
|
-
return serializeToFields(this.inner, this.contractAddress);
|
|
214
|
-
}
|
|
215
206
|
}
|
|
@@ -5,8 +5,6 @@ import { Signature } from '@aztec/foundation/eth-signature';
|
|
|
5
5
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
6
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
7
7
|
|
|
8
|
-
import type { BlockInfo } from '../block/l2_block.js';
|
|
9
|
-
import { TxHash } from '../tx/index.js';
|
|
10
8
|
import { Tx } from '../tx/tx.js';
|
|
11
9
|
import type { UInt32 } from '../types/index.js';
|
|
12
10
|
import { ConsensusPayload } from './consensus_payload.js';
|
|
@@ -49,9 +47,6 @@ export class BlockProposal extends Gossipable {
|
|
|
49
47
|
/** The signer of the BlockProposal over the header of the new block*/
|
|
50
48
|
public readonly signature: Signature,
|
|
51
49
|
|
|
52
|
-
/** The sequence of transactions in the block */
|
|
53
|
-
public readonly txHashes: TxHash[],
|
|
54
|
-
|
|
55
50
|
// Note(md): this is placed after the txs payload in order to be backwards compatible with previous versions
|
|
56
51
|
/** The transactions in the block */
|
|
57
52
|
public readonly txs?: Tx[],
|
|
@@ -71,19 +66,9 @@ export class BlockProposal extends Gossipable {
|
|
|
71
66
|
return this.payload.header.slotNumber;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
|
-
toBlockInfo(): BlockInfo {
|
|
75
|
-
return {
|
|
76
|
-
blockNumber: this.blockNumber,
|
|
77
|
-
slotNumber: this.slotNumber.toNumber(),
|
|
78
|
-
archive: this.archive.toString(),
|
|
79
|
-
txCount: this.txHashes.length,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
69
|
static async createProposalFromSigner(
|
|
84
70
|
blockNumber: UInt32,
|
|
85
71
|
payload: ConsensusPayload,
|
|
86
|
-
txHashes: TxHash[],
|
|
87
72
|
// Note(md): Provided separately to tx hashes such that this function can be optional
|
|
88
73
|
txs: Tx[] | undefined,
|
|
89
74
|
payloadSigner: (payload: Buffer32) => Promise<Signature>,
|
|
@@ -91,7 +76,7 @@ export class BlockProposal extends Gossipable {
|
|
|
91
76
|
const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
|
|
92
77
|
const sig = await payloadSigner(hashed);
|
|
93
78
|
|
|
94
|
-
return new BlockProposal(blockNumber, payload, sig,
|
|
79
|
+
return new BlockProposal(blockNumber, payload, sig, txs);
|
|
95
80
|
}
|
|
96
81
|
|
|
97
82
|
/**Get Sender
|
|
@@ -112,7 +97,7 @@ export class BlockProposal extends Gossipable {
|
|
|
112
97
|
}
|
|
113
98
|
|
|
114
99
|
toBuffer(): Buffer {
|
|
115
|
-
const buffer: any[] = [this.blockNumber, this.payload, this.signature
|
|
100
|
+
const buffer: any[] = [this.blockNumber, this.payload, this.signature];
|
|
116
101
|
if (this.txs) {
|
|
117
102
|
buffer.push(this.txs.length);
|
|
118
103
|
buffer.push(this.txs);
|
|
@@ -126,14 +111,13 @@ export class BlockProposal extends Gossipable {
|
|
|
126
111
|
const blockNumber = reader.readNumber();
|
|
127
112
|
const payload = reader.readObject(ConsensusPayload);
|
|
128
113
|
const sig = reader.readObject(Signature);
|
|
129
|
-
const txHashes = reader.readArray(reader.readNumber(), TxHash);
|
|
130
114
|
|
|
131
115
|
if (!reader.isEmpty()) {
|
|
132
116
|
const txs = reader.readArray(reader.readNumber(), Tx);
|
|
133
|
-
return new BlockProposal(blockNumber, payload, sig,
|
|
117
|
+
return new BlockProposal(blockNumber, payload, sig, txs);
|
|
134
118
|
}
|
|
135
119
|
|
|
136
|
-
return new BlockProposal(blockNumber, payload, sig
|
|
120
|
+
return new BlockProposal(blockNumber, payload, sig);
|
|
137
121
|
}
|
|
138
122
|
|
|
139
123
|
getSize(): number {
|
|
@@ -141,9 +125,7 @@ export class BlockProposal extends Gossipable {
|
|
|
141
125
|
4 /* blockNumber */ +
|
|
142
126
|
this.payload.getSize() +
|
|
143
127
|
this.signature.getSize() +
|
|
144
|
-
|
|
145
|
-
this.txHashes.length * TxHash.SIZE +
|
|
146
|
-
(this.txs ? 4 /* txs.length */ + this.txs.reduce((acc, tx) => acc + tx.getSize(), 0) : 0)
|
|
128
|
+
(this.txs ? this.txs.reduce((acc, tx) => acc + tx.getSize(), 0) : 0)
|
|
147
129
|
);
|
|
148
130
|
}
|
|
149
131
|
}
|
|
@@ -8,7 +8,7 @@ import { encodeAbiParameters, parseAbiParameters } from 'viem';
|
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
10
|
import type { L2Block } from '../block/l2_block.js';
|
|
11
|
-
import { ProposedBlockHeader, StateReference } from '../tx/index.js';
|
|
11
|
+
import { ProposedBlockHeader, StateReference, TxHash } from '../tx/index.js';
|
|
12
12
|
import type { Signable, SignatureDomainSeparator } from './signature_utils.js';
|
|
13
13
|
|
|
14
14
|
export class ConsensusPayload implements Signable {
|
|
@@ -21,6 +21,8 @@ export class ConsensusPayload implements Signable {
|
|
|
21
21
|
public readonly archive: Fr,
|
|
22
22
|
/** The state reference after the block is added */
|
|
23
23
|
public readonly stateReference: StateReference,
|
|
24
|
+
/** The sequence of transactions in the block */
|
|
25
|
+
public readonly txHashes: TxHash[],
|
|
24
26
|
) {}
|
|
25
27
|
|
|
26
28
|
static get schema() {
|
|
@@ -29,12 +31,13 @@ export class ConsensusPayload implements Signable {
|
|
|
29
31
|
header: ProposedBlockHeader.schema,
|
|
30
32
|
archive: schemas.Fr,
|
|
31
33
|
stateReference: StateReference.schema,
|
|
34
|
+
txHashes: z.array(TxHash.schema),
|
|
32
35
|
})
|
|
33
|
-
.transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.stateReference));
|
|
36
|
+
.transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.stateReference, obj.txHashes));
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
static getFields(fields: FieldsOf<ConsensusPayload>) {
|
|
37
|
-
return [fields.header, fields.archive, fields.stateReference] as const;
|
|
40
|
+
return [fields.header, fields.archive, fields.stateReference, fields.txHashes] as const;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
|
|
@@ -44,23 +47,31 @@ export class ConsensusPayload implements Signable {
|
|
|
44
47
|
'bytes32, ' + // archive
|
|
45
48
|
'((bytes32,uint32),((bytes32,uint32),(bytes32,uint32),(bytes32,uint32))), ' + // stateReference
|
|
46
49
|
'(int256), ' + // oracleInput
|
|
47
|
-
'bytes32' + // headerHash
|
|
50
|
+
'bytes32, ' + // headerHash
|
|
51
|
+
'bytes32[]' + // txHashes
|
|
48
52
|
')',
|
|
49
53
|
);
|
|
50
54
|
const archiveRoot = this.archive.toString();
|
|
51
55
|
const stateReference = this.stateReference.toAbi();
|
|
52
56
|
|
|
53
57
|
const headerHash = this.header.hash().toString();
|
|
58
|
+
const txArray = this.txHashes.map(tx => tx.toString());
|
|
54
59
|
const encodedData = encodeAbiParameters(abi, [
|
|
55
60
|
domainSeparator,
|
|
56
|
-
[archiveRoot, stateReference, [0n] /* @todo See #9963 */, headerHash],
|
|
61
|
+
[archiveRoot, stateReference, [0n] /* @todo See #9963 */, headerHash, txArray],
|
|
57
62
|
] as const);
|
|
58
63
|
|
|
59
64
|
return hexToBuffer(encodedData);
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
toBuffer(): Buffer {
|
|
63
|
-
const buffer = serializeToBuffer([
|
|
68
|
+
const buffer = serializeToBuffer([
|
|
69
|
+
this.header,
|
|
70
|
+
this.archive,
|
|
71
|
+
this.stateReference,
|
|
72
|
+
this.txHashes.length,
|
|
73
|
+
this.txHashes,
|
|
74
|
+
]);
|
|
64
75
|
this.size = buffer.length;
|
|
65
76
|
return buffer;
|
|
66
77
|
}
|
|
@@ -71,19 +82,25 @@ export class ConsensusPayload implements Signable {
|
|
|
71
82
|
reader.readObject(ProposedBlockHeader),
|
|
72
83
|
reader.readObject(Fr),
|
|
73
84
|
reader.readObject(StateReference),
|
|
85
|
+
reader.readArray(reader.readNumber(), TxHash),
|
|
74
86
|
);
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
static fromFields(fields: FieldsOf<ConsensusPayload>): ConsensusPayload {
|
|
78
|
-
return new ConsensusPayload(fields.header, fields.archive, fields.stateReference);
|
|
90
|
+
return new ConsensusPayload(fields.header, fields.archive, fields.stateReference, fields.txHashes);
|
|
79
91
|
}
|
|
80
92
|
|
|
81
93
|
static fromBlock(block: L2Block): ConsensusPayload {
|
|
82
|
-
return new ConsensusPayload(
|
|
94
|
+
return new ConsensusPayload(
|
|
95
|
+
block.header.toPropose(),
|
|
96
|
+
block.archive.root,
|
|
97
|
+
block.header.state,
|
|
98
|
+
block.body.txEffects.map(tx => tx.txHash),
|
|
99
|
+
);
|
|
83
100
|
}
|
|
84
101
|
|
|
85
102
|
static empty(): ConsensusPayload {
|
|
86
|
-
return new ConsensusPayload(ProposedBlockHeader.empty(), Fr.ZERO, StateReference.empty());
|
|
103
|
+
return new ConsensusPayload(ProposedBlockHeader.empty(), Fr.ZERO, StateReference.empty(), []);
|
|
87
104
|
}
|
|
88
105
|
|
|
89
106
|
/**
|
|
@@ -100,6 +117,8 @@ export class ConsensusPayload implements Signable {
|
|
|
100
117
|
}
|
|
101
118
|
|
|
102
119
|
toString() {
|
|
103
|
-
return `header: ${this.header.toString()}, archive: ${this.archive.toString()}, stateReference: ${this.stateReference.l1ToL2MessageTree.root.toString()}
|
|
120
|
+
return `header: ${this.header.toString()}, archive: ${this.archive.toString()}, stateReference: ${this.stateReference.l1ToL2MessageTree.root.toString()}, txHashes: ${this.txHashes.join(
|
|
121
|
+
', ',
|
|
122
|
+
)}`;
|
|
104
123
|
}
|
|
105
124
|
}
|
package/src/p2p/topic_type.ts
CHANGED
|
@@ -24,10 +24,8 @@ export function getTopicTypeForClientType(clientType: P2PClientType) {
|
|
|
24
24
|
return Object.values(TopicType);
|
|
25
25
|
} else if (clientType === P2PClientType.Prover) {
|
|
26
26
|
return [TopicType.tx, TopicType.block_proposal];
|
|
27
|
-
} else {
|
|
28
|
-
const _: never = clientType;
|
|
29
|
-
return [TopicType.tx];
|
|
30
27
|
}
|
|
28
|
+
return [TopicType.tx];
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
/**
|
|
@@ -5,6 +5,7 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
|
5
5
|
import { bufferToHex, hexToBuffer } from '@aztec/foundation/string';
|
|
6
6
|
|
|
7
7
|
import { PartialStateReference } from '../tx/partial_state_reference.js';
|
|
8
|
+
import { RollupTypes } from '../types/shared.js';
|
|
8
9
|
import { BlockConstantData } from './block_constant_data.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -12,6 +13,10 @@ import { BlockConstantData } from './block_constant_data.js';
|
|
|
12
13
|
*/
|
|
13
14
|
export class BaseOrMergeRollupPublicInputs {
|
|
14
15
|
constructor(
|
|
16
|
+
/**
|
|
17
|
+
* Specifies from which type of rollup circuit these inputs are from.
|
|
18
|
+
*/
|
|
19
|
+
public rollupType: RollupTypes,
|
|
15
20
|
/**
|
|
16
21
|
* Number of txs in this rollup.
|
|
17
22
|
*/
|
|
@@ -54,6 +59,7 @@ export class BaseOrMergeRollupPublicInputs {
|
|
|
54
59
|
/** Returns an empty instance. */
|
|
55
60
|
static empty() {
|
|
56
61
|
return new BaseOrMergeRollupPublicInputs(
|
|
62
|
+
RollupTypes.Base,
|
|
57
63
|
0,
|
|
58
64
|
BlockConstantData.empty(),
|
|
59
65
|
PartialStateReference.empty(),
|
|
@@ -75,6 +81,7 @@ export class BaseOrMergeRollupPublicInputs {
|
|
|
75
81
|
static fromBuffer(buffer: Buffer | BufferReader): BaseOrMergeRollupPublicInputs {
|
|
76
82
|
const reader = BufferReader.asReader(buffer);
|
|
77
83
|
return new BaseOrMergeRollupPublicInputs(
|
|
84
|
+
reader.readNumber(),
|
|
78
85
|
reader.readNumber(),
|
|
79
86
|
reader.readObject(BlockConstantData),
|
|
80
87
|
reader.readObject(PartialStateReference),
|
|
@@ -93,6 +100,7 @@ export class BaseOrMergeRollupPublicInputs {
|
|
|
93
100
|
*/
|
|
94
101
|
toBuffer() {
|
|
95
102
|
return serializeToBuffer(
|
|
103
|
+
this.rollupType,
|
|
96
104
|
this.numTxs,
|
|
97
105
|
this.constants,
|
|
98
106
|
|
|
@@ -13,6 +13,7 @@ export class EmptyBlockRootRollupInputs {
|
|
|
13
13
|
constructor(
|
|
14
14
|
public readonly data: BlockRootRollupData,
|
|
15
15
|
public readonly constants: BlockConstantData,
|
|
16
|
+
public readonly isPadding: boolean,
|
|
16
17
|
) {}
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -46,7 +47,7 @@ export class EmptyBlockRootRollupInputs {
|
|
|
46
47
|
* @returns An array of fields.
|
|
47
48
|
*/
|
|
48
49
|
static getFields(fields: FieldsOf<EmptyBlockRootRollupInputs>) {
|
|
49
|
-
return [fields.data, fields.constants] as const;
|
|
50
|
+
return [fields.data, fields.constants, fields.isPadding] as const;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -56,7 +57,11 @@ export class EmptyBlockRootRollupInputs {
|
|
|
56
57
|
*/
|
|
57
58
|
static fromBuffer(buffer: Buffer | BufferReader): EmptyBlockRootRollupInputs {
|
|
58
59
|
const reader = BufferReader.asReader(buffer);
|
|
59
|
-
return new EmptyBlockRootRollupInputs(
|
|
60
|
+
return new EmptyBlockRootRollupInputs(
|
|
61
|
+
reader.readObject(BlockRootRollupData),
|
|
62
|
+
reader.readObject(BlockConstantData),
|
|
63
|
+
reader.readBoolean(),
|
|
64
|
+
);
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
/**
|
package/src/rollup/index.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from './empty_block_root_rollup_inputs.js';
|
|
|
8
8
|
export * from './epoch_constant_data.js';
|
|
9
9
|
export * from './block_root_rollup.js';
|
|
10
10
|
export * from './merge_rollup.js';
|
|
11
|
-
export * from './padding_block_root_rollup_inputs.js';
|
|
12
11
|
export * from './previous_rollup_block_data.js';
|
|
13
12
|
export * from './previous_rollup_data.js';
|
|
14
13
|
export * from './private_base_rollup_inputs.js';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UInt32 } from '../types/shared.js';
|
|
2
2
|
|
|
3
3
|
export class ScheduledDelayChange {
|
|
4
4
|
constructor(
|
|
5
|
-
public pre:
|
|
6
|
-
public post:
|
|
7
|
-
public
|
|
5
|
+
public pre: UInt32 | undefined,
|
|
6
|
+
public post: UInt32 | undefined,
|
|
7
|
+
public blockOfChange: UInt32,
|
|
8
8
|
) {}
|
|
9
9
|
|
|
10
10
|
static empty() {
|
|
11
|
-
return new this(undefined, undefined,
|
|
11
|
+
return new this(undefined, undefined, 0);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
isEmpty(): boolean {
|
|
15
|
-
return this.pre === undefined && this.post === undefined && this.
|
|
15
|
+
return this.pre === undefined && this.post === undefined && this.blockOfChange === 0;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
|
|
3
|
-
import type { UInt64 } from '../types/shared.js';
|
|
4
|
-
|
|
5
3
|
export class ScheduledValueChange {
|
|
6
4
|
constructor(
|
|
7
5
|
public previous: Fr[],
|
|
8
6
|
public post: Fr[],
|
|
9
|
-
public
|
|
7
|
+
public blockOfChange: number,
|
|
10
8
|
) {
|
|
11
9
|
if (this.previous.length !== this.post.length) {
|
|
12
10
|
throw new Error('Previous and post must have the same length');
|
|
@@ -14,15 +12,15 @@ export class ScheduledValueChange {
|
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
static empty(valueSize: number) {
|
|
17
|
-
return new this(Array(valueSize).fill(new Fr(0)), Array(valueSize).fill(new Fr(0)),
|
|
15
|
+
return new this(Array(valueSize).fill(new Fr(0)), Array(valueSize).fill(new Fr(0)), 0);
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
isEmpty(): boolean {
|
|
21
|
-
return this.previous.every(v => v.isZero()) && this.post.every(v => v.isZero()) && this.
|
|
19
|
+
return this.previous.every(v => v.isZero()) && this.post.every(v => v.isZero()) && this.blockOfChange === 0;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
getCurrentAt(
|
|
25
|
-
if (
|
|
22
|
+
getCurrentAt(blockNumber: number) {
|
|
23
|
+
if (blockNumber < this.blockOfChange) {
|
|
26
24
|
return this.previous;
|
|
27
25
|
} else {
|
|
28
26
|
return this.post;
|
|
@@ -22,20 +22,20 @@ export class SharedMutableValues {
|
|
|
22
22
|
// Extract fields for ScheduledValueChange
|
|
23
23
|
const svcPre = reader.readFieldArray(UPDATES_VALUE_SIZE);
|
|
24
24
|
const svcPost = reader.readFieldArray(UPDATES_VALUE_SIZE);
|
|
25
|
-
const
|
|
26
|
-
const svc = new ScheduledValueChange(svcPre, svcPost,
|
|
25
|
+
const svcBlockOfChange = firstField & 0xffffffffn;
|
|
26
|
+
const svc = new ScheduledValueChange(svcPre, svcPost, Number(svcBlockOfChange));
|
|
27
27
|
|
|
28
28
|
// Extract fields for ScheduledDelayChange from first field
|
|
29
|
-
const
|
|
29
|
+
const sdcBlockOfChange = (firstField >> 32n) & 0xffffffffn;
|
|
30
30
|
const sdcIsPostSome = (firstField >> 64n) & 1n;
|
|
31
31
|
const sdcPost = (firstField >> 72n) & 0xffffffffn;
|
|
32
32
|
const sdcIsPreSome = (firstField >> 104n) & 1n;
|
|
33
33
|
const sdcPre = (firstField >> 112n) & 0xffffffffn;
|
|
34
34
|
|
|
35
35
|
const sdc = new ScheduledDelayChange(
|
|
36
|
-
sdcIsPreSome ? sdcPre : undefined,
|
|
37
|
-
sdcIsPostSome ? sdcPost : undefined,
|
|
38
|
-
|
|
36
|
+
sdcIsPreSome ? Number(sdcPre) : undefined,
|
|
37
|
+
sdcIsPostSome ? Number(sdcPost) : undefined,
|
|
38
|
+
Number(sdcBlockOfChange),
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
return new this(svc, sdc);
|
|
@@ -43,9 +43,9 @@ export class SharedMutableValues {
|
|
|
43
43
|
|
|
44
44
|
toFields(): Fr[] {
|
|
45
45
|
// Pack format matches Noir implementation:
|
|
46
|
-
// [ sdc.pre_inner: u32 | sdc.pre_is_some: u8 | sdc.post_inner: u32 | sdc.post_is_some: u8 | sdc.
|
|
47
|
-
let firstField = this.svc.
|
|
48
|
-
firstField |= this.sdc.
|
|
46
|
+
// [ sdc.pre_inner: u32 | sdc.pre_is_some: u8 | sdc.post_inner: u32 | sdc.post_is_some: u8 | sdc.block_of_change: u32 | svc.block_of_change: u32 ]
|
|
47
|
+
let firstField = BigInt(this.svc.blockOfChange);
|
|
48
|
+
firstField |= BigInt(this.sdc.blockOfChange) << 32n;
|
|
49
49
|
firstField |= (this.sdc.post === undefined ? 0n : 1n) << 64n;
|
|
50
50
|
firstField |= BigInt(this.sdc.post || 0) << 72n;
|
|
51
51
|
firstField |= (this.sdc.pre === undefined ? 0n : 1n) << 104n;
|