@aztec/stdlib 1.2.0 → 2.0.0-nightly.20250813
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 +0 -67
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +1 -14
- package/dest/abi/authorization_selector.d.ts +52 -0
- package/dest/abi/authorization_selector.d.ts.map +1 -0
- package/dest/abi/authorization_selector.js +70 -0
- package/dest/abi/contract_artifact.d.ts.map +1 -1
- package/dest/abi/contract_artifact.js +0 -40
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +3 -6
- package/dest/abi/index.d.ts +1 -0
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +1 -0
- package/dest/avm/avm.d.ts +278 -412
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +12 -12
- package/dest/avm/avm_proving_request.d.ts +160 -186
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/l2_block.d.ts +8 -0
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +9 -0
- package/dest/block/l2_block_source.d.ts +446 -2
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +29 -0
- package/dest/block/proposal/committee_attestation.d.ts +3 -1
- package/dest/block/proposal/committee_attestation.d.ts.map +1 -1
- package/dest/block/proposal/committee_attestation.js +3 -0
- package/dest/block/published_l2_block.d.ts +2 -1
- package/dest/block/published_l2_block.d.ts.map +1 -1
- package/dest/block/published_l2_block.js +6 -1
- package/dest/contract/contract_instance.d.ts +3 -3
- package/dest/contract/contract_instance.d.ts.map +1 -1
- package/dest/contract/contract_instance.js +3 -3
- package/dest/contract/interfaces/contract_class.d.ts +2 -2
- package/dest/contract/interfaces/protocol_contract_addresses.d.ts +9 -9
- package/dest/contract/interfaces/protocol_contract_addresses.d.ts.map +1 -1
- package/dest/contract/interfaces/protocol_contract_addresses.js +4 -4
- package/dest/contract/private_function_membership_proof.d.ts +1 -1
- package/dest/contract/private_function_membership_proof.js +1 -1
- package/dest/contract/utility_function_membership_proof.d.ts +1 -1
- package/dest/contract/utility_function_membership_proof.js +1 -1
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +20 -0
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -0
- package/dest/{shared_mutable/shared_mutable_values.js → delayed_public_mutable/delayed_public_mutable_values.js} +9 -9
- package/dest/{shared_mutable/shared_mutable_values_with_hash.d.ts → delayed_public_mutable/delayed_public_mutable_values_with_hash.d.ts} +6 -6
- package/dest/delayed_public_mutable/delayed_public_mutable_values_with_hash.d.ts.map +1 -0
- package/dest/delayed_public_mutable/delayed_public_mutable_values_with_hash.js +30 -0
- package/dest/delayed_public_mutable/index.d.ts +5 -0
- package/dest/delayed_public_mutable/index.d.ts.map +1 -0
- package/dest/delayed_public_mutable/index.js +4 -0
- package/dest/delayed_public_mutable/scheduled_delay_change.d.ts.map +1 -0
- package/dest/delayed_public_mutable/scheduled_value_change.d.ts.map +1 -0
- package/dest/gas/gas.d.ts +1 -0
- package/dest/gas/gas.d.ts.map +1 -1
- package/dest/gas/gas.js +3 -0
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +1 -4
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +4 -2
- package/dest/interfaces/aztec-node-admin.d.ts +211 -8
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +9 -3
- package/dest/interfaces/configs.d.ts +27 -0
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +6 -1
- package/dest/interfaces/get_logs_response.d.ts +1 -1
- package/dest/interfaces/proving-job.d.ts +166 -192
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/pxe.d.ts +3 -1
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +1 -1
- package/dest/interfaces/server.d.ts +4 -2
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +4 -2
- package/dest/interfaces/slasher.d.ts +86 -0
- package/dest/interfaces/slasher.d.ts.map +1 -0
- package/dest/interfaces/slasher.js +23 -0
- package/dest/interfaces/tx_provider.d.ts +24 -0
- package/dest/interfaces/tx_provider.d.ts.map +1 -0
- package/dest/kernel/claimed_length_array.d.ts +34 -0
- package/dest/kernel/claimed_length_array.d.ts.map +1 -0
- package/dest/kernel/claimed_length_array.js +58 -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 +18 -20
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +7 -10
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +17 -32
- package/dest/kernel/hints/build_transient_data_hints.d.ts +4 -3
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +9 -10
- package/dest/kernel/hints/index.d.ts +1 -2
- package/dest/kernel/hints/index.d.ts.map +1 -1
- package/dest/kernel/hints/index.js +1 -2
- 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/private_kernel_reset_hints.d.ts +5 -5
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
- package/dest/kernel/hints/private_kernel_reset_hints.js +9 -9
- 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/{transient_data_index_hint.d.ts → transient_data_squashing_hint.d.ts} +5 -5
- package/dest/kernel/hints/transient_data_squashing_hint.d.ts.map +1 -0
- package/dest/kernel/hints/{transient_data_index_hint.js → transient_data_squashing_hint.js} +5 -5
- package/dest/kernel/index.d.ts +1 -0
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +1 -0
- package/dest/kernel/private_accumulated_data.d.ts +16 -15
- package/dest/kernel/private_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_accumulated_data.js +3 -3
- package/dest/kernel/private_call_data.d.ts +4 -4
- package/dest/kernel/private_call_data.d.ts.map +1 -1
- package/dest/kernel/private_call_data.js +2 -2
- package/dest/kernel/private_circuit_public_inputs.d.ts +26 -25
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +33 -15
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +9 -0
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.js +8 -4
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +10 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +9 -6
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +11 -4
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +20 -18
- 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 +9 -10
- 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 +11 -12
- package/dest/kernel/private_validation_requests.d.ts +8 -20
- package/dest/kernel/private_validation_requests.d.ts.map +1 -1
- package/dest/kernel/private_validation_requests.js +9 -21
- package/dest/kernel/utils/order_and_comparison.d.ts +0 -3
- package/dest/kernel/utils/order_and_comparison.d.ts.map +1 -1
- package/dest/kernel/utils/order_and_comparison.js +0 -19
- package/dest/logs/extended_public_log.d.ts +1 -1
- package/dest/logs/shared_secret_derivation.d.ts +1 -1
- package/dest/logs/shared_secret_derivation.js +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +4 -1
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +49 -54
- package/dest/messaging/l2_to_l1_message.d.ts +2 -0
- package/dest/messaging/l2_to_l1_message.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_message.js +7 -0
- package/dest/note/notes_filter.d.ts +5 -2
- package/dest/note/notes_filter.d.ts.map +1 -1
- package/dest/note/notes_filter.js +1 -1
- package/dest/p2p/attestation_utils.d.ts +10 -0
- package/dest/p2p/attestation_utils.d.ts.map +1 -0
- package/dest/p2p/attestation_utils.js +21 -0
- package/dest/p2p/block_attestation.d.ts +3 -4
- package/dest/p2p/block_attestation.d.ts.map +1 -1
- package/dest/p2p/block_attestation.js +3 -4
- package/dest/p2p/block_proposal.d.ts +8 -1
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +21 -8
- package/dest/p2p/consensus_payload.d.ts +3 -11
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +13 -22
- package/dest/p2p/index.d.ts +1 -0
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +1 -0
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +5 -3
- package/dest/rollup/block_root_rollup.d.ts +1 -1
- package/dest/slashing/index.d.ts +51 -0
- package/dest/slashing/index.d.ts.map +1 -0
- package/dest/slashing/index.js +54 -0
- package/dest/stats/stats.d.ts +2 -2
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +0 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +25 -24
- package/dest/tests/mocks.d.ts +2 -0
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +31 -22
- package/dest/tx/index.d.ts +0 -1
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.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/processed_tx.d.ts +2 -2
- package/dest/tx/processed_tx.d.ts.map +1 -1
- package/dest/tx/processed_tx.js +4 -4
- package/dest/tx/proven_tx.d.ts +1 -1
- package/dest/tx/proven_tx.d.ts.map +1 -1
- package/dest/tx/proven_tx.js +7 -3
- package/dest/tx/simulated_tx.d.ts +11 -17
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +12 -12
- package/dest/tx/tx.d.ts +25 -25
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +60 -48
- package/dest/tx/tx_effect.d.ts +2 -2
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +3 -18
- package/dest/tx/tx_execution_request.js +2 -2
- package/dest/tx/tx_hash.d.ts +7 -0
- package/dest/tx/tx_hash.d.ts.map +1 -1
- package/dest/tx/tx_hash.js +19 -1
- package/dest/tx/tx_request.d.ts +5 -5
- package/dest/tx/tx_request.d.ts.map +1 -1
- package/dest/tx/tx_request.js +7 -7
- package/dest/tx/validator/error_texts.d.ts +1 -0
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +1 -0
- package/dest/tx/validator/tx_validator.d.ts +6 -4
- package/dest/tx/validator/tx_validator.d.ts.map +1 -1
- package/dest/tx/validator/tx_validator.js +3 -0
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/verification_key.js +4 -4
- package/package.json +10 -9
- package/src/abi/abi.ts +0 -38
- package/src/abi/authorization_selector.ts +95 -0
- package/src/abi/contract_artifact.ts +0 -49
- package/src/abi/decoder.ts +3 -6
- package/src/abi/index.ts +1 -0
- package/src/avm/avm.ts +7 -9
- package/src/block/l2_block.ts +18 -0
- package/src/block/l2_block_source.ts +70 -1
- package/src/block/proposal/committee_attestation.ts +5 -1
- package/src/block/published_l2_block.ts +14 -5
- package/src/contract/contract_instance.ts +3 -3
- package/src/contract/interfaces/protocol_contract_addresses.ts +5 -10
- package/src/contract/private_function_membership_proof.ts +1 -1
- package/src/contract/utility_function_membership_proof.ts +1 -1
- package/src/{shared_mutable/shared_mutable_values.ts → delayed_public_mutable/delayed_public_mutable_values.ts} +10 -10
- package/src/delayed_public_mutable/delayed_public_mutable_values_with_hash.ts +38 -0
- package/src/delayed_public_mutable/index.ts +4 -0
- package/src/gas/gas.ts +4 -0
- package/src/hash/hash.ts +1 -4
- package/src/interfaces/archiver.ts +3 -1
- package/src/interfaces/aztec-node-admin.ts +19 -8
- package/src/interfaces/configs.ts +17 -0
- package/src/interfaces/pxe.ts +4 -2
- package/src/interfaces/server.ts +4 -2
- package/src/interfaces/slasher.ts +49 -0
- package/src/interfaces/tx_provider.ts +16 -0
- package/src/kernel/claimed_length_array.ts +104 -0
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +28 -30
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +28 -59
- package/src/kernel/hints/build_transient_data_hints.ts +12 -14
- package/src/kernel/hints/index.ts +1 -2
- package/src/kernel/hints/note_hash_read_request_hints.ts +4 -16
- package/src/kernel/hints/nullifier_read_request_hints.ts +4 -16
- package/src/kernel/hints/private_kernel_reset_hints.ts +7 -7
- package/src/kernel/hints/read_request_hints.ts +22 -22
- package/src/kernel/hints/{transient_data_index_hint.ts → transient_data_squashing_hint.ts} +5 -5
- package/src/kernel/index.ts +1 -0
- package/src/kernel/private_accumulated_data.ts +23 -23
- package/src/kernel/private_call_data.ts +3 -3
- package/src/kernel/private_circuit_public_inputs.ts +92 -68
- package/src/kernel/private_kernel_circuit_public_inputs.ts +9 -1
- package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +13 -4
- 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 +16 -10
- package/src/kernel/private_validation_requests.ts +19 -50
- package/src/kernel/utils/order_and_comparison.ts +0 -25
- package/src/logs/shared_secret_derivation.ts +1 -1
- package/src/messaging/l2_to_l1_membership.ts +76 -85
- package/src/messaging/l2_to_l1_message.ts +9 -0
- package/src/note/notes_filter.ts +6 -3
- package/src/p2p/attestation_utils.ts +35 -0
- package/src/p2p/block_attestation.ts +3 -4
- package/src/p2p/block_proposal.ts +23 -5
- package/src/p2p/consensus_payload.ts +10 -29
- package/src/p2p/index.ts +1 -0
- package/src/p2p/topic_type.ts +3 -1
- package/src/slashing/index.ts +74 -0
- package/src/stats/stats.ts +2 -2
- package/src/tests/factories.ts +37 -27
- package/src/tests/mocks.ts +24 -22
- package/src/tx/index.ts +0 -1
- package/src/tx/private_execution_result.ts +11 -9
- package/src/tx/processed_tx.ts +6 -6
- package/src/tx/proven_tx.ts +7 -8
- package/src/tx/simulated_tx.ts +13 -19
- package/src/tx/tx.ts +70 -57
- package/src/tx/tx_effect.ts +5 -20
- package/src/tx/tx_execution_request.ts +2 -2
- package/src/tx/tx_hash.ts +21 -1
- package/src/tx/tx_request.ts +7 -6
- package/src/tx/validator/error_texts.ts +1 -0
- package/src/tx/validator/tx_validator.ts +5 -0
- package/src/versioning/versioning.ts +0 -3
- package/src/vks/verification_key.ts +4 -7
- package/dest/interfaces/tx-collector.d.ts +0 -15
- package/dest/interfaces/tx-collector.d.ts.map +0 -1
- package/dest/kernel/hints/rollup_validation_requests.d.ts +0 -34
- package/dest/kernel/hints/rollup_validation_requests.d.ts.map +0 -1
- package/dest/kernel/hints/rollup_validation_requests.js +0 -55
- package/dest/kernel/hints/transient_data_index_hint.d.ts.map +0 -1
- package/dest/shared_mutable/index.d.ts +0 -5
- package/dest/shared_mutable/index.d.ts.map +0 -1
- package/dest/shared_mutable/index.js +0 -4
- package/dest/shared_mutable/scheduled_delay_change.d.ts.map +0 -1
- package/dest/shared_mutable/scheduled_value_change.d.ts.map +0 -1
- package/dest/shared_mutable/shared_mutable_values.d.ts +0 -20
- package/dest/shared_mutable/shared_mutable_values.d.ts.map +0 -1
- package/dest/shared_mutable/shared_mutable_values_with_hash.d.ts.map +0 -1
- package/dest/shared_mutable/shared_mutable_values_with_hash.js +0 -30
- package/dest/tx/include_by_timestamp.d.ts +0 -54
- package/dest/tx/include_by_timestamp.d.ts.map +0 -1
- package/dest/tx/include_by_timestamp.js +0 -72
- package/src/interfaces/tx-collector.ts +0 -17
- package/src/kernel/hints/rollup_validation_requests.ts +0 -71
- package/src/shared_mutable/index.ts +0 -4
- package/src/shared_mutable/shared_mutable_values_with_hash.ts +0 -38
- package/src/tx/include_by_timestamp.ts +0 -90
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.d.ts +0 -0
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.js +0 -0
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_value_change.d.ts +0 -0
- /package/dest/{shared_mutable → delayed_public_mutable}/scheduled_value_change.js +0 -0
- /package/dest/interfaces/{tx-collector.js → tx_provider.js} +0 -0
- /package/src/{shared_mutable → delayed_public_mutable}/scheduled_delay_change.ts +0 -0
- /package/src/{shared_mutable → delayed_public_mutable}/scheduled_value_change.ts +0 -0
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import { SHA256Trunc } from '@aztec/foundation/crypto';
|
|
2
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
SiblingPath,
|
|
4
|
+
UnbalancedMerkleTreeCalculator,
|
|
5
|
+
computeUnbalancedMerkleTreeRoot,
|
|
6
|
+
findLeafLevelAndIndex,
|
|
7
|
+
getMaxUnbalancedTreeDepth,
|
|
8
|
+
} from '@aztec/foundation/trees';
|
|
9
|
+
|
|
10
|
+
async function createOutHashTree(messages: Fr[]) {
|
|
11
|
+
const messageSubtreeHeight = getMaxUnbalancedTreeDepth(messages.length);
|
|
12
|
+
const calculator = UnbalancedMerkleTreeCalculator.create(messageSubtreeHeight);
|
|
13
|
+
await calculator.appendLeaves(messages.map(msg => msg.toBuffer()));
|
|
14
|
+
return calculator;
|
|
15
|
+
}
|
|
4
16
|
|
|
5
17
|
export interface MessageRetrieval {
|
|
6
18
|
getL2ToL1Messages(l2BlockNumber: number): Promise<Fr[][] | undefined>;
|
|
7
19
|
}
|
|
8
20
|
|
|
9
21
|
export type L2ToL1MembershipWitness = {
|
|
10
|
-
|
|
22
|
+
root: Fr;
|
|
23
|
+
leafIndex: bigint;
|
|
11
24
|
siblingPath: SiblingPath<number>;
|
|
12
25
|
};
|
|
13
26
|
|
|
@@ -16,98 +29,76 @@ export async function computeL2ToL1MembershipWitness(
|
|
|
16
29
|
l2BlockNumber: number,
|
|
17
30
|
message: Fr,
|
|
18
31
|
): Promise<L2ToL1MembershipWitness | undefined> {
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
32
|
+
const messagesForAllTxs = await messageRetriever.getL2ToL1Messages(l2BlockNumber);
|
|
33
|
+
if (!messagesForAllTxs) {
|
|
21
34
|
return undefined;
|
|
22
35
|
}
|
|
23
36
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
37
|
+
return computeL2ToL1MembershipWitnessFromMessagesForAllTxs(messagesForAllTxs, message);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function computeL2ToL1MembershipWitnessFromMessagesForAllTxs(
|
|
41
|
+
messagesForAllTxs: Fr[][],
|
|
42
|
+
message: Fr,
|
|
43
|
+
): Promise<L2ToL1MembershipWitness> {
|
|
44
|
+
// Find index of message in subtree and index of tx in a block.
|
|
45
|
+
let messageIndexInTx = -1;
|
|
46
|
+
const txIndex = messagesForAllTxs.findIndex(messages => {
|
|
47
|
+
messageIndexInTx = messages.findIndex(msg => msg.equals(message));
|
|
48
|
+
return messageIndexInTx !== -1;
|
|
49
|
+
});
|
|
34
50
|
|
|
35
51
|
if (txIndex === -1) {
|
|
36
52
|
throw new Error('The L2ToL1Message you are trying to prove inclusion of does not exist');
|
|
37
53
|
}
|
|
38
54
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const txTreeHeight = messages.length <= 1 ? 1 : Math.ceil(Math.log2(messages.length));
|
|
77
|
-
const calculator: MerkleTreeCalculator = await MerkleTreeCalculator.create(
|
|
78
|
-
txTreeHeight,
|
|
79
|
-
Buffer.alloc(32, 0), // Zero leaf
|
|
80
|
-
(lhs: Buffer, rhs: Buffer) => Promise.resolve(hasher.hash(lhs, rhs)),
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const root = await calculator.computeTreeRoot(messages.map(msg => msg.toBuffer()));
|
|
84
|
-
return Fr.fromBuffer(root);
|
|
85
|
-
}),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
// Construct the top tree and compute the combined path
|
|
89
|
-
let combinedPath: Buffer[];
|
|
90
|
-
{
|
|
91
|
-
const topTreeHeight = Math.ceil(Math.log2(txSubtreeRoots.length));
|
|
92
|
-
// The root of this tree is the out_hash calculated in Noir => we truncate to match Noir's SHA
|
|
93
|
-
const topTree = UnbalancedMerkleTreeCalculator.create(topTreeHeight, (lhs: Buffer, rhs: Buffer) =>
|
|
94
|
-
Promise.resolve(hasher.hash(lhs, rhs)),
|
|
95
|
-
);
|
|
96
|
-
await topTree.appendLeaves(txSubtreeRoots.map(f => f.toBuffer()));
|
|
97
|
-
|
|
98
|
-
const txPathInTopTree = await topTree.getSiblingPath(txSubtreeRoots[txIndex].toBigInt());
|
|
99
|
-
// Append subtree path to top tree path
|
|
100
|
-
combinedPath = messagePathInSubtree.toBufferArray().concat(txPathInTopTree.toBufferArray());
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// Append binary index of subtree path to binary index of top tree path
|
|
104
|
-
const combinedIndex = parseInt(
|
|
105
|
-
txIndex.toString(2).concat(messageIndexInTx.toString(2).padStart(messageSubtreeHeight, '0')),
|
|
106
|
-
2,
|
|
107
|
-
);
|
|
55
|
+
// Get the txOutHash and the sibling path of the message in the tx subtree.
|
|
56
|
+
const txMessages = messagesForAllTxs[txIndex];
|
|
57
|
+
const txOutHashTree = await createOutHashTree(txMessages);
|
|
58
|
+
const txOutHash = txOutHashTree.getRoot();
|
|
59
|
+
const messagePathInSubtree = await txOutHashTree.getSiblingPath(message);
|
|
60
|
+
|
|
61
|
+
// Calculate txOutHash for all txs.
|
|
62
|
+
const txSubtreeRoots = messagesForAllTxs.map((messages, i) => {
|
|
63
|
+
// For a tx with no messages, we have to set an out hash of 0 to match what the circuit does.
|
|
64
|
+
if (messages.length === 0) {
|
|
65
|
+
return Fr.ZERO;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (i === txIndex) {
|
|
69
|
+
return Fr.fromBuffer(txOutHash);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const root = computeUnbalancedMerkleTreeRoot(messages.map(msg => msg.toBuffer()));
|
|
73
|
+
return Fr.fromBuffer(root);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Construct the top tree.
|
|
77
|
+
// The leaves of this tree are the txOutHashes.
|
|
78
|
+
// The root of this tree is the out_hash calculated in the circuit.
|
|
79
|
+
const topTree = await createOutHashTree(txSubtreeRoots);
|
|
80
|
+
const root = Fr.fromBuffer(topTree.getRoot());
|
|
81
|
+
|
|
82
|
+
// Compute the combined sibling path by appending the tx subtree path to the top tree path.
|
|
83
|
+
const txPathInTopTree = await topTree.getSiblingPath(txOutHash);
|
|
84
|
+
const combinedPath = messagePathInSubtree.toBufferArray().concat(txPathInTopTree.toBufferArray());
|
|
85
|
+
|
|
86
|
+
// Compute the combined index.
|
|
87
|
+
// It is the index of the message in the balanced tree at its current height.
|
|
88
|
+
const txLeafPosition = findLeafLevelAndIndex(messagesForAllTxs.length, txIndex);
|
|
89
|
+
const messageLeafPosition = findLeafLevelAndIndex(txMessages.length, messageIndexInTx);
|
|
90
|
+
const numLeavesInLeftSubtrees = txLeafPosition.indexAtLevel * (1 << messageLeafPosition.level);
|
|
91
|
+
const combinedIndex = numLeavesInLeftSubtrees + messageLeafPosition.indexAtLevel;
|
|
108
92
|
|
|
109
93
|
return {
|
|
110
|
-
|
|
94
|
+
root,
|
|
95
|
+
leafIndex: BigInt(combinedIndex),
|
|
111
96
|
siblingPath: new SiblingPath(combinedPath.length, combinedPath),
|
|
112
97
|
};
|
|
113
98
|
}
|
|
99
|
+
|
|
100
|
+
export function getL2ToL1MessageLeafId(
|
|
101
|
+
membershipWitness: Pick<L2ToL1MembershipWitness, 'leafIndex' | 'siblingPath'>,
|
|
102
|
+
): bigint {
|
|
103
|
+
return 2n ** BigInt(membershipWitness.siblingPath.pathSize) + membershipWitness.leafIndex;
|
|
104
|
+
}
|
|
@@ -203,4 +203,13 @@ 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
|
+
}
|
|
206
215
|
}
|
package/src/note/notes_filter.ts
CHANGED
|
@@ -12,10 +12,13 @@ import { NoteStatus } from './note_status.js';
|
|
|
12
12
|
* @remarks This filter is applied as an intersection of all its params.
|
|
13
13
|
*/
|
|
14
14
|
export type NotesFilter = {
|
|
15
|
+
/**
|
|
16
|
+
* The contract address the note belongs to.
|
|
17
|
+
* @remarks Providing a contract address is required as we need that information to trigger private state sync.
|
|
18
|
+
*/
|
|
19
|
+
contractAddress: AztecAddress;
|
|
15
20
|
/** Hash of a transaction from which to fetch the notes. */
|
|
16
21
|
txHash?: TxHash;
|
|
17
|
-
/** The contract address the note belongs to. */
|
|
18
|
-
contractAddress?: AztecAddress;
|
|
19
22
|
/** The specific storage location of the note on the contract. */
|
|
20
23
|
storageSlot?: Fr;
|
|
21
24
|
/** The recipient of the note (whose public key was used to encrypt the note). */
|
|
@@ -29,8 +32,8 @@ export type NotesFilter = {
|
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
export const NotesFilterSchema: ZodFor<NotesFilter> = z.object({
|
|
35
|
+
contractAddress: schemas.AztecAddress,
|
|
32
36
|
txHash: TxHash.schema.optional(),
|
|
33
|
-
contractAddress: schemas.AztecAddress.optional(),
|
|
34
37
|
storageSlot: schemas.Fr.optional(),
|
|
35
38
|
recipient: schemas.AztecAddress.optional(),
|
|
36
39
|
status: z.nativeEnum(NoteStatus).optional(),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
|
|
3
|
+
import { CommitteeAttestation } from '../block/index.js';
|
|
4
|
+
import type { BlockAttestation } from './block_attestation.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns attestation signatures in the order of a series of provided ethereum addresses
|
|
8
|
+
* The rollup smart contract expects attestations to appear in the order of the committee
|
|
9
|
+
* @todo: perform this logic within the memory attestation store instead?
|
|
10
|
+
*/
|
|
11
|
+
export function orderAttestations(
|
|
12
|
+
attestations: BlockAttestation[],
|
|
13
|
+
orderAddresses: EthAddress[],
|
|
14
|
+
): CommitteeAttestation[] {
|
|
15
|
+
// Create a map of sender addresses to BlockAttestations
|
|
16
|
+
const attestationMap = new Map<string, CommitteeAttestation>();
|
|
17
|
+
|
|
18
|
+
for (const attestation of attestations) {
|
|
19
|
+
const sender = attestation.getSender();
|
|
20
|
+
if (sender) {
|
|
21
|
+
attestationMap.set(
|
|
22
|
+
sender.toString(),
|
|
23
|
+
CommitteeAttestation.fromAddressAndSignature(sender, attestation.signature),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Create the ordered array based on the orderAddresses, else return an empty attestation
|
|
29
|
+
const orderedAttestations = orderAddresses.map(address => {
|
|
30
|
+
const addressString = address.toString();
|
|
31
|
+
return attestationMap.get(addressString) || CommitteeAttestation.fromAddress(address);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return orderedAttestations;
|
|
35
|
+
}
|
|
@@ -66,10 +66,9 @@ export class BlockAttestation extends Gossipable {
|
|
|
66
66
|
return this.payload.header.slotNumber;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* @returns The sender of the attestation
|
|
69
|
+
/**
|
|
70
|
+
* Lazily evaluate and cache the signer of the attestation
|
|
71
|
+
* @returns The signer of the attestation
|
|
73
72
|
*/
|
|
74
73
|
getSender(): EthAddress {
|
|
75
74
|
if (!this.sender) {
|
|
@@ -5,6 +5,8 @@ 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';
|
|
8
10
|
import { Tx } from '../tx/tx.js';
|
|
9
11
|
import type { UInt32 } from '../types/index.js';
|
|
10
12
|
import { ConsensusPayload } from './consensus_payload.js';
|
|
@@ -47,6 +49,9 @@ export class BlockProposal extends Gossipable {
|
|
|
47
49
|
/** The signer of the BlockProposal over the header of the new block*/
|
|
48
50
|
public readonly signature: Signature,
|
|
49
51
|
|
|
52
|
+
/** The sequence of transactions in the block */
|
|
53
|
+
public readonly txHashes: TxHash[],
|
|
54
|
+
|
|
50
55
|
// Note(md): this is placed after the txs payload in order to be backwards compatible with previous versions
|
|
51
56
|
/** The transactions in the block */
|
|
52
57
|
public readonly txs?: Tx[],
|
|
@@ -66,9 +71,19 @@ export class BlockProposal extends Gossipable {
|
|
|
66
71
|
return this.payload.header.slotNumber;
|
|
67
72
|
}
|
|
68
73
|
|
|
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
|
+
|
|
69
83
|
static async createProposalFromSigner(
|
|
70
84
|
blockNumber: UInt32,
|
|
71
85
|
payload: ConsensusPayload,
|
|
86
|
+
txHashes: TxHash[],
|
|
72
87
|
// Note(md): Provided separately to tx hashes such that this function can be optional
|
|
73
88
|
txs: Tx[] | undefined,
|
|
74
89
|
payloadSigner: (payload: Buffer32) => Promise<Signature>,
|
|
@@ -76,7 +91,7 @@ export class BlockProposal extends Gossipable {
|
|
|
76
91
|
const hashed = getHashedSignaturePayload(payload, SignatureDomainSeparator.blockProposal);
|
|
77
92
|
const sig = await payloadSigner(hashed);
|
|
78
93
|
|
|
79
|
-
return new BlockProposal(blockNumber, payload, sig, txs);
|
|
94
|
+
return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
|
|
80
95
|
}
|
|
81
96
|
|
|
82
97
|
/**Get Sender
|
|
@@ -97,7 +112,7 @@ export class BlockProposal extends Gossipable {
|
|
|
97
112
|
}
|
|
98
113
|
|
|
99
114
|
toBuffer(): Buffer {
|
|
100
|
-
const buffer: any[] = [this.blockNumber, this.payload, this.signature];
|
|
115
|
+
const buffer: any[] = [this.blockNumber, this.payload, this.signature, this.txHashes.length, this.txHashes];
|
|
101
116
|
if (this.txs) {
|
|
102
117
|
buffer.push(this.txs.length);
|
|
103
118
|
buffer.push(this.txs);
|
|
@@ -111,13 +126,14 @@ export class BlockProposal extends Gossipable {
|
|
|
111
126
|
const blockNumber = reader.readNumber();
|
|
112
127
|
const payload = reader.readObject(ConsensusPayload);
|
|
113
128
|
const sig = reader.readObject(Signature);
|
|
129
|
+
const txHashes = reader.readArray(reader.readNumber(), TxHash);
|
|
114
130
|
|
|
115
131
|
if (!reader.isEmpty()) {
|
|
116
132
|
const txs = reader.readArray(reader.readNumber(), Tx);
|
|
117
|
-
return new BlockProposal(blockNumber, payload, sig, txs);
|
|
133
|
+
return new BlockProposal(blockNumber, payload, sig, txHashes, txs);
|
|
118
134
|
}
|
|
119
135
|
|
|
120
|
-
return new BlockProposal(blockNumber, payload, sig);
|
|
136
|
+
return new BlockProposal(blockNumber, payload, sig, txHashes);
|
|
121
137
|
}
|
|
122
138
|
|
|
123
139
|
getSize(): number {
|
|
@@ -125,7 +141,9 @@ export class BlockProposal extends Gossipable {
|
|
|
125
141
|
4 /* blockNumber */ +
|
|
126
142
|
this.payload.getSize() +
|
|
127
143
|
this.signature.getSize() +
|
|
128
|
-
|
|
144
|
+
4 /* txHashes.length */ +
|
|
145
|
+
this.txHashes.length * TxHash.SIZE +
|
|
146
|
+
(this.txs ? 4 /* txs.length */ + this.txs.reduce((acc, tx) => acc + tx.getSize(), 0) : 0)
|
|
129
147
|
);
|
|
130
148
|
}
|
|
131
149
|
}
|
|
@@ -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
|
|
11
|
+
import { ProposedBlockHeader, StateReference } from '../tx/index.js';
|
|
12
12
|
import type { Signable, SignatureDomainSeparator } from './signature_utils.js';
|
|
13
13
|
|
|
14
14
|
export class ConsensusPayload implements Signable {
|
|
@@ -21,8 +21,6 @@ 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[],
|
|
26
24
|
) {}
|
|
27
25
|
|
|
28
26
|
static get schema() {
|
|
@@ -31,13 +29,12 @@ export class ConsensusPayload implements Signable {
|
|
|
31
29
|
header: ProposedBlockHeader.schema,
|
|
32
30
|
archive: schemas.Fr,
|
|
33
31
|
stateReference: StateReference.schema,
|
|
34
|
-
txHashes: z.array(TxHash.schema),
|
|
35
32
|
})
|
|
36
|
-
.transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.stateReference
|
|
33
|
+
.transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.stateReference));
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
static getFields(fields: FieldsOf<ConsensusPayload>) {
|
|
40
|
-
return [fields.header, fields.archive, fields.stateReference
|
|
37
|
+
return [fields.header, fields.archive, fields.stateReference] as const;
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
|
|
@@ -47,31 +44,23 @@ export class ConsensusPayload implements Signable {
|
|
|
47
44
|
'bytes32, ' + // archive
|
|
48
45
|
'((bytes32,uint32),((bytes32,uint32),(bytes32,uint32),(bytes32,uint32))), ' + // stateReference
|
|
49
46
|
'(int256), ' + // oracleInput
|
|
50
|
-
'bytes32
|
|
51
|
-
'bytes32[]' + // txHashes
|
|
47
|
+
'bytes32' + // headerHash
|
|
52
48
|
')',
|
|
53
49
|
);
|
|
54
50
|
const archiveRoot = this.archive.toString();
|
|
55
51
|
const stateReference = this.stateReference.toAbi();
|
|
56
52
|
|
|
57
53
|
const headerHash = this.header.hash().toString();
|
|
58
|
-
const txArray = this.txHashes.map(tx => tx.toString());
|
|
59
54
|
const encodedData = encodeAbiParameters(abi, [
|
|
60
55
|
domainSeparator,
|
|
61
|
-
[archiveRoot, stateReference, [0n] /* @todo See #9963 */, headerHash
|
|
56
|
+
[archiveRoot, stateReference, [0n] /* @todo See #9963 */, headerHash],
|
|
62
57
|
] as const);
|
|
63
58
|
|
|
64
59
|
return hexToBuffer(encodedData);
|
|
65
60
|
}
|
|
66
61
|
|
|
67
62
|
toBuffer(): Buffer {
|
|
68
|
-
const buffer = serializeToBuffer([
|
|
69
|
-
this.header,
|
|
70
|
-
this.archive,
|
|
71
|
-
this.stateReference,
|
|
72
|
-
this.txHashes.length,
|
|
73
|
-
this.txHashes,
|
|
74
|
-
]);
|
|
63
|
+
const buffer = serializeToBuffer([this.header, this.archive, this.stateReference]);
|
|
75
64
|
this.size = buffer.length;
|
|
76
65
|
return buffer;
|
|
77
66
|
}
|
|
@@ -82,25 +71,19 @@ export class ConsensusPayload implements Signable {
|
|
|
82
71
|
reader.readObject(ProposedBlockHeader),
|
|
83
72
|
reader.readObject(Fr),
|
|
84
73
|
reader.readObject(StateReference),
|
|
85
|
-
reader.readArray(reader.readNumber(), TxHash),
|
|
86
74
|
);
|
|
87
75
|
}
|
|
88
76
|
|
|
89
77
|
static fromFields(fields: FieldsOf<ConsensusPayload>): ConsensusPayload {
|
|
90
|
-
return new ConsensusPayload(fields.header, fields.archive, fields.stateReference
|
|
78
|
+
return new ConsensusPayload(fields.header, fields.archive, fields.stateReference);
|
|
91
79
|
}
|
|
92
80
|
|
|
93
81
|
static fromBlock(block: L2Block): 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
|
-
);
|
|
82
|
+
return new ConsensusPayload(block.header.toPropose(), block.archive.root, block.header.state);
|
|
100
83
|
}
|
|
101
84
|
|
|
102
85
|
static empty(): ConsensusPayload {
|
|
103
|
-
return new ConsensusPayload(ProposedBlockHeader.empty(), Fr.ZERO, StateReference.empty()
|
|
86
|
+
return new ConsensusPayload(ProposedBlockHeader.empty(), Fr.ZERO, StateReference.empty());
|
|
104
87
|
}
|
|
105
88
|
|
|
106
89
|
/**
|
|
@@ -117,8 +100,6 @@ export class ConsensusPayload implements Signable {
|
|
|
117
100
|
}
|
|
118
101
|
|
|
119
102
|
toString() {
|
|
120
|
-
return `header: ${this.header.toString()}, archive: ${this.archive.toString()}, stateReference: ${this.stateReference.l1ToL2MessageTree.root.toString()}
|
|
121
|
-
', ',
|
|
122
|
-
)}`;
|
|
103
|
+
return `header: ${this.header.toString()}, archive: ${this.archive.toString()}, stateReference: ${this.stateReference.l1ToL2MessageTree.root.toString()}`;
|
|
123
104
|
}
|
|
124
105
|
}
|
package/src/p2p/index.ts
CHANGED
package/src/p2p/topic_type.ts
CHANGED
|
@@ -24,8 +24,10 @@ 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];
|
|
27
30
|
}
|
|
28
|
-
return [TopicType.tx];
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import { type ZodFor, schemas } from '../schemas/index.js';
|
|
6
|
+
|
|
7
|
+
export enum Offense {
|
|
8
|
+
UNKNOWN = 0,
|
|
9
|
+
DATA_WITHHOLDING = 1,
|
|
10
|
+
VALID_EPOCH_PRUNED = 2,
|
|
11
|
+
INACTIVITY = 3,
|
|
12
|
+
/** A proposer sent an invalid block proposal over the p2p network to the committee */
|
|
13
|
+
BROADCASTED_INVALID_BLOCK_PROPOSAL = 4,
|
|
14
|
+
/** A proposer pushed to L1 a block with insufficient committee attestations */
|
|
15
|
+
PROPOSED_INSUFFICIENT_ATTESTATIONS = 5,
|
|
16
|
+
/** A proposer pushed to L1 a block with incorrect committee attestations (ie signature from a non-committee member) */
|
|
17
|
+
PROPOSED_INCORRECT_ATTESTATIONS = 6,
|
|
18
|
+
/** A committee member attested to a block that was built as a descendent of an invalid block (as in a block with invalid attestations) */
|
|
19
|
+
ATTESTED_DESCENDANT_OF_INVALID = 7,
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const OffenseSchema = z.nativeEnum(Offense);
|
|
23
|
+
|
|
24
|
+
export type MonitoredSlashPayload = {
|
|
25
|
+
payloadAddress: EthAddress;
|
|
26
|
+
validators: readonly EthAddress[];
|
|
27
|
+
amounts: readonly bigint[];
|
|
28
|
+
offenses: readonly Offense[];
|
|
29
|
+
observedAtSeconds: number;
|
|
30
|
+
totalAmount: bigint;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const MonitoredSlashPayloadSchema = z.object({
|
|
34
|
+
payloadAddress: schemas.EthAddress,
|
|
35
|
+
validators: z.array(schemas.EthAddress),
|
|
36
|
+
amounts: z.array(schemas.BigInt),
|
|
37
|
+
offenses: z.array(OffenseSchema),
|
|
38
|
+
observedAtSeconds: z.number(),
|
|
39
|
+
totalAmount: schemas.BigInt,
|
|
40
|
+
}) satisfies ZodFor<MonitoredSlashPayload>;
|
|
41
|
+
|
|
42
|
+
export const OffenseToBigInt: Record<Offense, bigint> = {
|
|
43
|
+
[Offense.UNKNOWN]: 0n,
|
|
44
|
+
[Offense.DATA_WITHHOLDING]: 1n,
|
|
45
|
+
[Offense.VALID_EPOCH_PRUNED]: 2n,
|
|
46
|
+
[Offense.INACTIVITY]: 3n,
|
|
47
|
+
[Offense.BROADCASTED_INVALID_BLOCK_PROPOSAL]: 4n,
|
|
48
|
+
[Offense.PROPOSED_INSUFFICIENT_ATTESTATIONS]: 5n,
|
|
49
|
+
[Offense.PROPOSED_INCORRECT_ATTESTATIONS]: 6n,
|
|
50
|
+
[Offense.ATTESTED_DESCENDANT_OF_INVALID]: 7n,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function bigIntToOffense(offense: bigint): Offense {
|
|
54
|
+
switch (offense) {
|
|
55
|
+
case 0n:
|
|
56
|
+
return Offense.UNKNOWN;
|
|
57
|
+
case 1n:
|
|
58
|
+
return Offense.DATA_WITHHOLDING;
|
|
59
|
+
case 2n:
|
|
60
|
+
return Offense.VALID_EPOCH_PRUNED;
|
|
61
|
+
case 3n:
|
|
62
|
+
return Offense.INACTIVITY;
|
|
63
|
+
case 4n:
|
|
64
|
+
return Offense.BROADCASTED_INVALID_BLOCK_PROPOSAL;
|
|
65
|
+
case 5n:
|
|
66
|
+
return Offense.PROPOSED_INSUFFICIENT_ATTESTATIONS;
|
|
67
|
+
case 6n:
|
|
68
|
+
return Offense.PROPOSED_INCORRECT_ATTESTATIONS;
|
|
69
|
+
case 7n:
|
|
70
|
+
return Offense.ATTESTED_DESCENDANT_OF_INVALID;
|
|
71
|
+
default:
|
|
72
|
+
throw new Error(`Unknown offense: ${offense}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/stats/stats.ts
CHANGED
|
@@ -221,8 +221,8 @@ export type TxStats = {
|
|
|
221
221
|
nullifierCount: number;
|
|
222
222
|
/** Number of private logs */
|
|
223
223
|
privateLogCount: number;
|
|
224
|
-
/** How many classes were
|
|
225
|
-
|
|
224
|
+
/** How many classes were published to the canonical class registry. */
|
|
225
|
+
classPublishedCount: number;
|
|
226
226
|
/** Serialized size of contract class logs in fields. */
|
|
227
227
|
contractClassLogSize: number;
|
|
228
228
|
/** How this tx pays for its fee */
|