@aztec/stdlib 0.0.1-commit.f504929 → 0.0.1-commit.f650c0a5c
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 +138 -1
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +10 -2
- package/dest/abi/buffer.d.ts +14 -4
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +25 -4
- package/dest/abi/decoder.d.ts +5 -44
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +12 -67
- package/dest/abi/function_selector.js +1 -1
- package/dest/abi/function_signature_decoder.d.ts +43 -0
- package/dest/abi/function_signature_decoder.d.ts.map +1 -0
- package/dest/abi/function_signature_decoder.js +66 -0
- package/dest/abi/index.d.ts +2 -1
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +1 -0
- package/dest/abi/selector.d.ts +2 -2
- package/dest/abi/selector.d.ts.map +1 -1
- package/dest/abi/selector.js +1 -1
- package/dest/avm/avm.d.ts +300 -300
- package/dest/avm/revert_code.d.ts +8 -18
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +15 -30
- package/dest/block/l2_block.d.ts +9 -1
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +12 -2
- package/dest/block/l2_block_source.d.ts +95 -10
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +1 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +17 -4
- 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 +3 -2
- package/dest/checkpoint/checkpoint.d.ts +8 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +18 -5
- package/dest/checkpoint/checkpoint_data.d.ts +71 -5
- package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint_data.js +10 -0
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/validate.d.ts +36 -0
- package/dest/checkpoint/validate.d.ts.map +1 -0
- package/dest/checkpoint/validate.js +120 -0
- package/dest/config/index.d.ts +2 -1
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +1 -0
- package/dest/config/pipelining-config.d.ts +19 -0
- package/dest/config/pipelining-config.d.ts.map +1 -0
- package/dest/config/pipelining-config.js +18 -0
- package/dest/config/sequencer-config.d.ts +2 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +1 -2
- package/dest/contract/contract_address.d.ts +3 -3
- package/dest/contract/contract_address.js +3 -3
- package/dest/contract/contract_class_id.d.ts +2 -2
- package/dest/contract/contract_class_id.js +2 -2
- package/dest/contract/index.d.ts +1 -3
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +0 -2
- package/dest/contract/interfaces/contract_class.d.ts +3 -156
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +1 -28
- package/dest/epoch-helpers/index.d.ts +11 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +16 -2
- package/dest/file-store/factory.d.ts +4 -3
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +2 -2
- package/dest/file-store/http.d.ts +9 -2
- package/dest/file-store/http.d.ts.map +1 -1
- package/dest/file-store/http.js +20 -9
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/gas/gas_settings.d.ts +40 -3
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +50 -6
- package/dest/ha-signing/config.d.ts +49 -14
- package/dest/ha-signing/config.d.ts.map +1 -1
- package/dest/ha-signing/config.js +20 -15
- package/dest/ha-signing/index.d.ts +3 -2
- package/dest/ha-signing/index.d.ts.map +1 -1
- package/dest/ha-signing/index.js +2 -1
- package/dest/ha-signing/local_config.d.ts +63 -0
- package/dest/ha-signing/local_config.d.ts.map +1 -0
- package/dest/ha-signing/local_config.js +24 -0
- package/dest/hash/hash.d.ts +19 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +29 -0
- package/dest/interfaces/allowed_element.d.ts +25 -1
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +8 -2
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +6 -3
- package/dest/interfaces/aztec-node-admin.d.ts +73 -23
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +3 -3
- package/dest/interfaces/aztec-node.d.ts +12 -6
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +5 -2
- package/dest/interfaces/block-builder.d.ts +38 -11
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +12 -5
- package/dest/interfaces/configs.d.ts +47 -7
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +3 -1
- package/dest/interfaces/l2_logs_source.d.ts +5 -3
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +6 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +7 -1
- package/dest/interfaces/proving-job.d.ts +34 -34
- package/dest/interfaces/slasher.d.ts +1 -10
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +0 -2
- package/dest/interfaces/validator.d.ts +103 -35
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +7 -5
- package/dest/interfaces/world_state.d.ts +5 -4
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
- package/dest/kv-store/config.d.ts +17 -0
- package/dest/kv-store/config.d.ts.map +1 -0
- package/dest/kv-store/config.js +26 -0
- package/dest/kv-store/index.d.ts +2 -0
- package/dest/kv-store/index.d.ts.map +1 -0
- package/dest/kv-store/index.js +1 -0
- package/dest/l1-contracts/index.d.ts +2 -2
- package/dest/l1-contracts/index.d.ts.map +1 -1
- package/dest/l1-contracts/index.js +1 -1
- package/dest/logs/extended_directional_app_tagging_secret.d.ts +4 -4
- package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -1
- package/dest/logs/extended_directional_app_tagging_secret.js +12 -5
- package/dest/logs/index.d.ts +2 -1
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +1 -0
- package/dest/logs/log_filter.d.ts +4 -1
- package/dest/logs/log_filter.d.ts.map +1 -1
- package/dest/logs/log_filter.js +2 -1
- package/dest/logs/message_context.d.ts +4 -7
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +23 -9
- package/dest/logs/pending_tagged_log.d.ts +2 -3
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +2 -2
- package/dest/logs/shared_secret_derivation.d.ts +11 -10
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
- package/dest/logs/shared_secret_derivation.js +15 -9
- package/dest/logs/siloed_tag.d.ts +4 -1
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +7 -3
- package/dest/logs/tagging_index_range.d.ts +40 -0
- package/dest/logs/tagging_index_range.d.ts.map +1 -0
- package/dest/logs/tagging_index_range.js +8 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +7 -0
- package/dest/messaging/l1_to_l2_message.d.ts +3 -2
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.js +11 -13
- package/dest/messaging/l1_to_l2_message_source.d.ts +4 -2
- package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +69 -26
- package/dest/noir/index.d.ts +3 -3
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/note/note_dao.d.ts +1 -1
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +1 -4
- package/dest/p2p/checkpoint_proposal.d.ts +2 -7
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +3 -25
- package/dest/p2p/peer_error.d.ts +3 -1
- package/dest/p2p/peer_error.d.ts.map +1 -1
- package/dest/p2p/peer_error.js +5 -0
- package/dest/proofs/chonk_proof.d.ts +46 -2
- package/dest/proofs/chonk_proof.d.ts.map +1 -1
- package/dest/proofs/chonk_proof.js +85 -10
- package/dest/slashing/index.d.ts +2 -3
- package/dest/slashing/index.d.ts.map +1 -1
- package/dest/slashing/index.js +1 -2
- package/dest/slashing/serialization.d.ts +2 -6
- package/dest/slashing/serialization.d.ts.map +1 -1
- package/dest/slashing/serialization.js +0 -60
- package/dest/slashing/types.d.ts +4 -90
- package/dest/slashing/types.d.ts.map +1 -1
- package/dest/slashing/types.js +0 -14
- package/dest/slashing/{tally.d.ts → votes.d.ts} +5 -6
- package/dest/slashing/votes.d.ts.map +1 -0
- package/dest/slashing/{tally.js → votes.js} +19 -10
- package/dest/tests/factories.d.ts +2 -4
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +11 -28
- package/dest/tests/mocks.d.ts +4 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +26 -26
- package/dest/timetable/index.d.ts +2 -1
- package/dest/timetable/index.d.ts.map +1 -1
- package/dest/timetable/index.js +6 -2
- package/dest/tx/block_header.d.ts +3 -1
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +4 -0
- package/dest/tx/capsule.d.ts +6 -2
- package/dest/tx/capsule.d.ts.map +1 -1
- package/dest/tx/capsule.js +9 -3
- package/dest/tx/global_variable_builder.d.ts +14 -2
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/private_execution_result.d.ts +6 -6
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +6 -6
- package/dest/tx/profiling.d.ts +14 -2
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +13 -3
- package/dest/tx/simulated_tx.d.ts +111 -3
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +2 -2
- package/dest/tx/tx.d.ts +6 -5
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +18 -6
- package/dest/tx/tx_receipt.d.ts +14 -5
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +14 -18
- package/dest/tx/validator/error_texts.d.ts +8 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +9 -0
- package/dest/update-checker/index.d.ts +3 -2
- package/dest/update-checker/index.d.ts.map +1 -1
- package/dest/update-checker/index.js +2 -1
- package/dest/update-checker/package_version.d.ts +3 -0
- package/dest/update-checker/package_version.d.ts.map +1 -0
- package/dest/update-checker/package_version.js +24 -0
- package/dest/update-checker/version_checker.d.ts +25 -0
- package/dest/update-checker/version_checker.d.ts.map +1 -0
- package/dest/update-checker/version_checker.js +50 -0
- package/dest/validators/errors.d.ts +6 -1
- package/dest/validators/errors.d.ts.map +1 -1
- package/dest/validators/errors.js +7 -0
- package/dest/versioning/versioning.d.ts +4 -2
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +4 -1
- package/dest/world-state/genesis_data.d.ts +11 -0
- package/dest/world-state/genesis_data.d.ts.map +1 -0
- package/dest/world-state/genesis_data.js +4 -0
- package/dest/world-state/index.d.ts +2 -1
- package/dest/world-state/index.d.ts.map +1 -1
- package/dest/world-state/index.js +1 -0
- package/package.json +10 -9
- package/src/abi/abi.ts +25 -2
- package/src/abi/buffer.ts +25 -4
- package/src/abi/decoder.ts +23 -78
- package/src/abi/function_selector.ts +1 -1
- package/src/abi/function_signature_decoder.ts +77 -0
- package/src/abi/index.ts +1 -0
- package/src/abi/selector.ts +1 -1
- package/src/avm/revert_code.ts +25 -39
- package/src/block/l2_block.ts +13 -1
- package/src/block/l2_block_source.ts +26 -9
- package/src/block/l2_block_stream/l2_tips_store_base.ts +24 -12
- package/src/block/test/l2_tips_store_test_suite.ts +8 -1
- package/src/checkpoint/checkpoint.ts +23 -4
- package/src/checkpoint/checkpoint_data.ts +40 -4
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/validate.ts +230 -0
- package/src/config/index.ts +1 -0
- package/src/config/pipelining-config.ts +31 -0
- package/src/config/sequencer-config.ts +2 -2
- package/src/contract/contract_address.ts +3 -3
- package/src/contract/contract_class_id.ts +2 -2
- package/src/contract/index.ts +0 -2
- package/src/contract/interfaces/contract_class.ts +2 -82
- package/src/epoch-helpers/index.ts +27 -0
- package/src/file-store/factory.ts +13 -4
- package/src/file-store/http.ts +29 -10
- package/src/file-store/index.ts +1 -0
- package/src/gas/README.md +123 -0
- package/src/gas/gas_settings.ts +65 -12
- package/src/ha-signing/config.ts +45 -38
- package/src/ha-signing/index.ts +9 -0
- package/src/ha-signing/local_config.ts +46 -0
- package/src/hash/hash.ts +34 -0
- package/src/interfaces/allowed_element.ts +28 -4
- package/src/interfaces/archiver.ts +6 -3
- package/src/interfaces/aztec-node-admin.ts +5 -7
- package/src/interfaces/aztec-node.ts +24 -5
- package/src/interfaces/block-builder.ts +56 -13
- package/src/interfaces/configs.ts +15 -4
- package/src/interfaces/l2_logs_source.ts +4 -1
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/prover-client.ts +8 -0
- package/src/interfaces/slasher.ts +0 -6
- package/src/interfaces/validator.ts +47 -33
- package/src/interfaces/world_state.ts +4 -3
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
- package/src/kv-store/config.ts +36 -0
- package/src/kv-store/index.ts +1 -0
- package/src/l1-contracts/index.ts +1 -1
- package/src/logs/extended_directional_app_tagging_secret.ts +19 -8
- package/src/logs/index.ts +1 -0
- package/src/logs/log_filter.ts +5 -0
- package/src/logs/message_context.ts +17 -7
- package/src/logs/pending_tagged_log.ts +1 -3
- package/src/logs/shared_secret_derivation.ts +21 -10
- package/src/logs/siloed_tag.ts +7 -2
- package/src/logs/tagging_index_range.ts +24 -0
- package/src/logs/tx_scoped_l2_log.ts +16 -0
- package/src/messaging/l1_to_l2_message.ts +12 -9
- package/src/messaging/l1_to_l2_message_source.ts +3 -1
- package/src/messaging/l2_to_l1_membership.ts +98 -33
- package/src/noir/index.ts +2 -2
- package/src/note/note_dao.ts +1 -4
- package/src/p2p/checkpoint_proposal.ts +8 -38
- package/src/p2p/peer_error.ts +7 -0
- package/src/proofs/chonk_proof.ts +91 -5
- package/src/slashing/index.ts +1 -2
- package/src/slashing/serialization.ts +1 -81
- package/src/slashing/types.ts +3 -35
- package/src/slashing/{tally.ts → votes.ts} +22 -4
- package/src/tests/factories.ts +5 -34
- package/src/tests/mocks.ts +31 -18
- package/src/timetable/index.ts +7 -2
- package/src/tx/block_header.ts +6 -0
- package/src/tx/capsule.ts +10 -2
- package/src/tx/global_variable_builder.ts +15 -0
- package/src/tx/private_execution_result.ts +5 -5
- package/src/tx/profiling.ts +11 -2
- package/src/tx/simulated_tx.ts +5 -1
- package/src/tx/tx.ts +20 -11
- package/src/tx/tx_receipt.ts +18 -16
- package/src/tx/validator/error_texts.ts +11 -0
- package/src/update-checker/index.ts +2 -1
- package/src/update-checker/package_version.ts +30 -0
- package/src/update-checker/version_checker.ts +65 -0
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
- package/src/world-state/genesis_data.ts +15 -0
- package/src/world-state/index.ts +1 -0
- package/dest/contract/private_function_membership_proof.d.ts +0 -32
- package/dest/contract/private_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/private_function_membership_proof.js +0 -124
- package/dest/contract/utility_function_membership_proof.d.ts +0 -27
- package/dest/contract/utility_function_membership_proof.d.ts.map +0 -1
- package/dest/contract/utility_function_membership_proof.js +0 -87
- package/dest/l1-contracts/slash_factory.d.ts +0 -45
- package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
- package/dest/l1-contracts/slash_factory.js +0 -158
- package/dest/slashing/empire.d.ts +0 -31
- package/dest/slashing/empire.d.ts.map +0 -1
- package/dest/slashing/empire.js +0 -87
- package/dest/slashing/tally.d.ts.map +0 -1
- package/dest/update-checker/update-checker.d.ts +0 -49
- package/dest/update-checker/update-checker.d.ts.map +0 -1
- package/dest/update-checker/update-checker.js +0 -130
- package/src/contract/private_function_membership_proof.ts +0 -167
- package/src/contract/utility_function_membership_proof.ts +0 -118
- package/src/l1-contracts/slash_factory.ts +0 -180
- package/src/slashing/empire.ts +0 -104
- package/src/update-checker/update-checker.ts +0 -166
|
@@ -1,21 +1,41 @@
|
|
|
1
|
+
import { BarretenbergSync, flattenChonkProofFields } from '@aztec/bb.js';
|
|
1
2
|
import { CHONK_PROOF_LENGTH } from '@aztec/constants';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
3
4
|
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
4
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
6
|
import { bufferSchemaFor } from '@aztec/foundation/schemas';
|
|
6
|
-
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
7
|
+
import { BufferReader, numToUInt32BE, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Serialization format detection for ChonkProof is size-based:
|
|
11
|
+
* - UNCOMPRESSED (legacy): [field_count=1632: uint32] [fields...] → total ≈ 52KB (>= 40KB)
|
|
12
|
+
* - COMPRESSED: [byte_count: uint32] [compressed_bytes] → total ≈ 35KB (< 40KB)
|
|
13
|
+
*
|
|
14
|
+
* Detection: if the first uint32 equals CHONK_PROOF_LENGTH (1632), it's legacy format
|
|
15
|
+
* (field count). Otherwise, it's compressed format (byte count). The old uncompressed
|
|
16
|
+
* format is never smaller than 40KB; compressed proofs are always smaller than 40KB.
|
|
17
|
+
*/
|
|
7
18
|
|
|
8
19
|
// CHONK: "Client Honk" - An UltraHonk variant with incremental folding and delayed non-native arithmetic.
|
|
9
20
|
export class ChonkProof {
|
|
21
|
+
/**
|
|
22
|
+
* Optional compressed proof bytes from chonk compression (point compression + u256 encoding).
|
|
23
|
+
* When set, toBuffer() will serialize in compressed format (~1.7x smaller).
|
|
24
|
+
* When reading from compressed format, this is populated and fields are decompressed on demand.
|
|
25
|
+
*/
|
|
26
|
+
public compressedProof?: Buffer;
|
|
27
|
+
|
|
10
28
|
constructor(
|
|
11
29
|
// The proof fields.
|
|
12
30
|
// For native verification, attach public inputs via `attachPublicInputs(publicInputs)`.
|
|
13
31
|
// Not using Tuple here due to the length being too high.
|
|
14
32
|
public fields: Fr[],
|
|
33
|
+
compressedProof?: Buffer,
|
|
15
34
|
) {
|
|
16
35
|
if (fields.length !== CHONK_PROOF_LENGTH) {
|
|
17
36
|
throw new Error(`Invalid ChonkProof length: ${fields.length}`);
|
|
18
37
|
}
|
|
38
|
+
this.compressedProof = compressedProof;
|
|
19
39
|
}
|
|
20
40
|
|
|
21
41
|
public attachPublicInputs(publicInputs: Fr[]) {
|
|
@@ -53,19 +73,84 @@ export class ChonkProof {
|
|
|
53
73
|
return this.toBuffer();
|
|
54
74
|
}
|
|
55
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Deserialize a ChonkProof from a buffer.
|
|
78
|
+
* Supports both legacy (field elements) and compressed (chonk compression) formats.
|
|
79
|
+
*
|
|
80
|
+
* Size-based format detection:
|
|
81
|
+
* - First uint32 == CHONK_PROOF_LENGTH (1632): legacy format, read field elements
|
|
82
|
+
* Total proof data ≈ 52KB (always >= 40KB)
|
|
83
|
+
* - Otherwise: compressed format, first uint32 is byte count of compressed data
|
|
84
|
+
* Total proof data ≈ 35KB (always < 40KB)
|
|
85
|
+
*/
|
|
56
86
|
static fromBuffer(buffer: Buffer | BufferReader): ChonkProof {
|
|
57
87
|
const reader = BufferReader.asReader(buffer);
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
88
|
+
const firstUint32 = reader.readNumber();
|
|
89
|
+
|
|
90
|
+
if (firstUint32 === CHONK_PROOF_LENGTH) {
|
|
91
|
+
// Legacy format: firstUint32 is the field count (1632)
|
|
92
|
+
// Widen to `number` to prevent TS from narrowing to literal 1632,
|
|
93
|
+
// which would cause Tuple<Fr, 1632> to exceed the recursion limit.
|
|
94
|
+
const fieldCount: number = firstUint32;
|
|
95
|
+
const proof = reader.readArray(fieldCount, Fr);
|
|
96
|
+
return new ChonkProof(proof);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Compressed format: firstUint32 is the compressed byte count
|
|
100
|
+
const compressedBytes = reader.readBytes(firstUint32);
|
|
101
|
+
return ChonkProof.fromCompressedBytes(Buffer.from(compressedBytes));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create a ChonkProof from compressed bytes by decompressing via the BarretenbergSync API.
|
|
106
|
+
* The compressed format uses point compression and u256 encoding (from PR #20645).
|
|
107
|
+
*
|
|
108
|
+
* @param compressed - Compressed proof bytes from chonk compression
|
|
109
|
+
* @returns ChonkProof with both fields and compressed bytes populated
|
|
110
|
+
*/
|
|
111
|
+
static fromCompressedBytes(compressed: Buffer): ChonkProof {
|
|
112
|
+
const api = BarretenbergSync.getSingleton();
|
|
113
|
+
const result = api.chonkDecompressProof({ compressedProof: new Uint8Array(compressed) });
|
|
114
|
+
|
|
115
|
+
// Flatten the structured bb.js ChonkProof into flat Fr[] field elements
|
|
116
|
+
const flatFields = flattenChonkProofFields(result.proof);
|
|
117
|
+
const fields = flatFields.map(f => Fr.fromBuffer(Buffer.from(f)));
|
|
118
|
+
|
|
119
|
+
// The decompressed proof includes public inputs in hidingOinkProof.
|
|
120
|
+
// Since ChonkProof stores fields WITHOUT public inputs, strip them.
|
|
121
|
+
// The number of public inputs = total fields - CHONK_PROOF_LENGTH
|
|
122
|
+
if (fields.length > CHONK_PROOF_LENGTH) {
|
|
123
|
+
const numPubInputs = fields.length - CHONK_PROOF_LENGTH;
|
|
124
|
+
const proofFields = fields.slice(numPubInputs);
|
|
125
|
+
return new ChonkProof(proofFields, compressed);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return new ChonkProof(fields, compressed);
|
|
61
129
|
}
|
|
62
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Serialize the proof to a buffer.
|
|
133
|
+
* If compressed bytes are available, uses the compressed format (~1.7x smaller).
|
|
134
|
+
* Otherwise falls back to legacy field element format.
|
|
135
|
+
*/
|
|
63
136
|
public toBuffer() {
|
|
137
|
+
if (this.compressedProof) {
|
|
138
|
+
// Compressed format: [compressed_byte_count: uint32] [compressed_bytes]
|
|
139
|
+
return Buffer.concat([numToUInt32BE(this.compressedProof.length), this.compressedProof]);
|
|
140
|
+
}
|
|
141
|
+
// Legacy format: [field_count=1632: uint32] [fields...]
|
|
64
142
|
return serializeToBuffer(this.fields.length, this.fields);
|
|
65
143
|
}
|
|
66
144
|
}
|
|
67
145
|
|
|
68
146
|
export class ChonkProofWithPublicInputs {
|
|
147
|
+
/**
|
|
148
|
+
* Optional compressed proof bytes (covers the full proof WITH public inputs).
|
|
149
|
+
* Set by the prover when using chonk compression. Flows through to ChonkProof
|
|
150
|
+
* via removePublicInputs() so the Tx can serialize in compressed format.
|
|
151
|
+
*/
|
|
152
|
+
public compressedProof?: Buffer;
|
|
153
|
+
|
|
69
154
|
constructor(
|
|
70
155
|
// The proof fields with public inputs.
|
|
71
156
|
// For recursive verification, use without public inputs via `removePublicInputs()`.
|
|
@@ -83,7 +168,8 @@ export class ChonkProofWithPublicInputs {
|
|
|
83
168
|
|
|
84
169
|
public removePublicInputs() {
|
|
85
170
|
const numPublicInputs = this.fieldsWithPublicInputs.length - CHONK_PROOF_LENGTH;
|
|
86
|
-
|
|
171
|
+
// Flow compressed proof bytes through so the ChonkProof can serialize efficiently
|
|
172
|
+
return new ChonkProof(this.fieldsWithPublicInputs.slice(numPublicInputs), this.compressedProof);
|
|
87
173
|
}
|
|
88
174
|
|
|
89
175
|
public isEmpty() {
|
package/src/slashing/index.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { times } from '@aztec/foundation/collection';
|
|
2
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
2
|
import { BufferReader, bigintToUInt64BE, bigintToUInt128BE, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
3
|
|
|
5
|
-
import type {
|
|
6
|
-
Offense,
|
|
7
|
-
OffenseType,
|
|
8
|
-
SlashPayload,
|
|
9
|
-
SlashPayloadRound,
|
|
10
|
-
ValidatorSlash,
|
|
11
|
-
ValidatorSlashOffense,
|
|
12
|
-
} from './types.js';
|
|
4
|
+
import type { Offense, OffenseType } from './types.js';
|
|
13
5
|
|
|
14
6
|
export function serializeOffense(offense: Offense): Buffer {
|
|
15
7
|
return serializeToBuffer(
|
|
@@ -29,75 +21,3 @@ export function deserializeOffense(buffer: Buffer): Offense {
|
|
|
29
21
|
|
|
30
22
|
return { validator, amount, offenseType: offense, epochOrSlot };
|
|
31
23
|
}
|
|
32
|
-
|
|
33
|
-
function serializeValidatorSlashOffense(offense: ValidatorSlashOffense): Buffer {
|
|
34
|
-
return serializeToBuffer(bigintToUInt64BE(offense.epochOrSlot), offense.offenseType);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function deserializeValidatorSlashOffense(buffer: Buffer | BufferReader): ValidatorSlashOffense {
|
|
38
|
-
const reader = BufferReader.asReader(buffer);
|
|
39
|
-
return {
|
|
40
|
-
epochOrSlot: reader.readUInt64(),
|
|
41
|
-
offenseType: reader.readNumber() as OffenseType,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function serializeValidatorSlash(slash: ValidatorSlash): Buffer {
|
|
46
|
-
return serializeToBuffer(
|
|
47
|
-
slash.validator,
|
|
48
|
-
bigintToUInt128BE(slash.amount),
|
|
49
|
-
slash.offenses.length,
|
|
50
|
-
slash.offenses.map(serializeValidatorSlashOffense),
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function deserializeValidatorSlash(buffer: Buffer | BufferReader): ValidatorSlash {
|
|
55
|
-
const reader = BufferReader.asReader(buffer);
|
|
56
|
-
const validator = reader.readObject(EthAddress);
|
|
57
|
-
const amount = reader.readUInt128();
|
|
58
|
-
const offensesCount = reader.readNumber();
|
|
59
|
-
const offenses = times(offensesCount, () => deserializeValidatorSlashOffense(reader));
|
|
60
|
-
|
|
61
|
-
return { validator, amount, offenses };
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function serializeSlashPayload(payload: SlashPayload): Buffer {
|
|
65
|
-
return serializeToBuffer(
|
|
66
|
-
payload.address,
|
|
67
|
-
payload.slashes.length,
|
|
68
|
-
payload.slashes.map(serializeValidatorSlash),
|
|
69
|
-
bigintToUInt64BE(payload.timestamp),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function deserializeSlashPayload(buffer: Buffer): SlashPayload {
|
|
74
|
-
const reader = BufferReader.asReader(buffer);
|
|
75
|
-
const address = reader.readObject(EthAddress);
|
|
76
|
-
const slashesCount = reader.readNumber();
|
|
77
|
-
const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
|
|
78
|
-
const timestamp = reader.readUInt64();
|
|
79
|
-
return { address, slashes, timestamp };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function serializeSlashPayloadRound(payload: SlashPayloadRound): Buffer {
|
|
83
|
-
return serializeToBuffer(
|
|
84
|
-
payload.address,
|
|
85
|
-
payload.slashes.length,
|
|
86
|
-
payload.slashes.map(serializeValidatorSlash),
|
|
87
|
-
bigintToUInt64BE(payload.timestamp),
|
|
88
|
-
Number(payload.votes),
|
|
89
|
-
bigintToUInt64BE(payload.round),
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function deserializeSlashPayloadRound(buffer: Buffer): SlashPayloadRound {
|
|
94
|
-
const reader = BufferReader.asReader(buffer);
|
|
95
|
-
const address = reader.readObject(EthAddress);
|
|
96
|
-
const slashesCount = reader.readNumber();
|
|
97
|
-
const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
|
|
98
|
-
const timestamp = reader.readUInt64();
|
|
99
|
-
const votes = BigInt(reader.readNumber());
|
|
100
|
-
const round = reader.readUInt64();
|
|
101
|
-
|
|
102
|
-
return { address, slashes, timestamp, votes, round };
|
|
103
|
-
}
|
package/src/slashing/types.ts
CHANGED
|
@@ -126,45 +126,13 @@ export type ValidatorSlash = {
|
|
|
126
126
|
offenses: ValidatorSlashOffense[];
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
export type SlashPayload = {
|
|
131
|
-
address: EthAddress;
|
|
132
|
-
slashes: ValidatorSlash[];
|
|
133
|
-
timestamp: bigint;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/** Slash payload with round information from empire slash proposer */
|
|
137
|
-
export type SlashPayloadRound = SlashPayload & { votes: bigint; round: bigint };
|
|
138
|
-
|
|
139
|
-
export const SlashPayloadRoundSchema = zodFor<SlashPayloadRound>()(
|
|
140
|
-
z.object({
|
|
141
|
-
address: schemas.EthAddress,
|
|
142
|
-
timestamp: schemas.BigInt,
|
|
143
|
-
votes: schemas.BigInt,
|
|
144
|
-
round: schemas.BigInt,
|
|
145
|
-
slashes: z.array(
|
|
146
|
-
z.object({
|
|
147
|
-
validator: schemas.EthAddress,
|
|
148
|
-
amount: schemas.BigInt,
|
|
149
|
-
offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
|
|
150
|
-
}),
|
|
151
|
-
),
|
|
152
|
-
}),
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
/** Votes for a validator slash in the consensus slash proposer */
|
|
129
|
+
/** Votes for a validator slash in the slashing proposer */
|
|
156
130
|
export type ValidatorSlashVote = number;
|
|
157
131
|
|
|
158
132
|
export type ProposerSlashAction =
|
|
159
|
-
/**
|
|
160
|
-
| { type: 'create-empire-payload'; data: ValidatorSlash[] }
|
|
161
|
-
/** Vote for a slashing payload on an empire-based slash proposer */
|
|
162
|
-
| { type: 'vote-empire-payload'; payload: EthAddress }
|
|
163
|
-
/** Execute a slashing payload on an empire-based slash proposer */
|
|
164
|
-
| { type: 'execute-empire-payload'; round: bigint }
|
|
165
|
-
/** Vote for offenses on a consensus slashing proposer */
|
|
133
|
+
/** Vote for offenses on the slashing proposer */
|
|
166
134
|
| { type: 'vote-offenses'; votes: ValidatorSlashVote[]; committees: EthAddress[][]; round: bigint }
|
|
167
|
-
/** Execute a slashing round on
|
|
135
|
+
/** Execute a slashing round on the slashing proposer */
|
|
168
136
|
| { type: 'execute-slash'; committees: EthAddress[][]; round: bigint };
|
|
169
137
|
|
|
170
138
|
export type ProposerSlashActionType = ProposerSlashAction['type'];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sumBigint } from '@aztec/foundation/bigint';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import type { PartialBy } from '@aztec/foundation/types';
|
|
5
6
|
|
|
6
7
|
import { getEpochForOffense } from './helpers.js';
|
|
@@ -13,7 +14,8 @@ import type { Offense, ValidatorSlashVote } from './types.js';
|
|
|
13
14
|
* @param epochsForCommittees - Array of epochs corresponding to each committee
|
|
14
15
|
* @param settings - Settings including slashingAmounts and optional validator override lists
|
|
15
16
|
* @param settings.maxSlashedValidators - If set, limits the total number of [validator, epoch] pairs
|
|
16
|
-
* with non-zero votes.
|
|
17
|
+
* with non-zero votes. The lowest-vote pairs are zeroed out to stay within the limit.
|
|
18
|
+
* @param logger - Logger, logs which validators were dropped.
|
|
17
19
|
* @returns Array of ValidatorSlashVote, where each vote is how many slash units the validator in that position should be slashed
|
|
18
20
|
*/
|
|
19
21
|
export function getSlashConsensusVotesFromOffenses(
|
|
@@ -26,7 +28,8 @@ export function getSlashConsensusVotesFromOffenses(
|
|
|
26
28
|
targetCommitteeSize: number;
|
|
27
29
|
maxSlashedValidators?: number;
|
|
28
30
|
},
|
|
29
|
-
|
|
31
|
+
logger: Logger = createLogger('slasher:votes'),
|
|
32
|
+
): ValidatorSlashVote[] {
|
|
30
33
|
const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
|
|
31
34
|
|
|
32
35
|
if (committees.length !== epochsForCommittees.length) {
|
|
@@ -58,7 +61,7 @@ export function getSlashConsensusVotesFromOffenses(
|
|
|
58
61
|
|
|
59
62
|
// if a cap is set, zero out the lowest-vote [validator, epoch] pairs so that the most severe slashes stay.
|
|
60
63
|
if (maxSlashedValidators === undefined) {
|
|
61
|
-
return
|
|
64
|
+
return votes;
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
const nonZeroByDescendingVote = [...votes.entries()].filter(([, vote]) => vote > 0).sort(([, a], [, b]) => b - a);
|
|
@@ -68,7 +71,22 @@ export function getSlashConsensusVotesFromOffenses(
|
|
|
68
71
|
votes[idx] = 0;
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
if (toTruncate.length > 0) {
|
|
75
|
+
const truncated = toTruncate.map(([idx]) => {
|
|
76
|
+
const committeeIndex = Math.floor(idx / targetCommitteeSize);
|
|
77
|
+
const positionInCommittee = idx % targetCommitteeSize;
|
|
78
|
+
return {
|
|
79
|
+
validator: committees[committeeIndex][positionInCommittee].toString(),
|
|
80
|
+
epoch: epochsForCommittees[committeeIndex],
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
logger.warn(
|
|
84
|
+
`Truncated ${toTruncate.length} validator-epoch pairs to stay within limit of ${maxSlashedValidators}`,
|
|
85
|
+
{ truncated },
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return votes;
|
|
72
90
|
}
|
|
73
91
|
|
|
74
92
|
/** Returns the slash vote for the given amount to slash. */
|
package/src/tests/factories.ts
CHANGED
|
@@ -92,10 +92,8 @@ import {
|
|
|
92
92
|
type ContractClassPublic,
|
|
93
93
|
ContractDeploymentData,
|
|
94
94
|
type ContractInstanceWithAddress,
|
|
95
|
-
type ExecutablePrivateFunctionWithMembershipProof,
|
|
96
95
|
type PrivateFunction,
|
|
97
96
|
SerializableContractInstance,
|
|
98
|
-
type UtilityFunctionWithMembershipProof,
|
|
99
97
|
computeContractClassId,
|
|
100
98
|
computePublicBytecodeCommitment,
|
|
101
99
|
} from '../contract/index.js';
|
|
@@ -234,7 +232,7 @@ export function makeTxContext(seed: number = 1): TxContext {
|
|
|
234
232
|
* Creates a default instance of gas settings. No seed value is used to ensure we allocate a sensible amount of gas for testing.
|
|
235
233
|
*/
|
|
236
234
|
export function makeGasSettings() {
|
|
237
|
-
return GasSettings.
|
|
235
|
+
return GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) });
|
|
238
236
|
}
|
|
239
237
|
|
|
240
238
|
/**
|
|
@@ -1183,35 +1181,6 @@ export function makePublicTxBaseRollupPrivateInputs(seed = 0) {
|
|
|
1183
1181
|
});
|
|
1184
1182
|
}
|
|
1185
1183
|
|
|
1186
|
-
export function makeExecutablePrivateFunctionWithMembershipProof(
|
|
1187
|
-
seed = 0,
|
|
1188
|
-
): ExecutablePrivateFunctionWithMembershipProof {
|
|
1189
|
-
return {
|
|
1190
|
-
selector: makeSelector(seed),
|
|
1191
|
-
bytecode: makeBytes(100, seed + 1),
|
|
1192
|
-
artifactTreeSiblingPath: makeTuple(3, fr, seed + 2),
|
|
1193
|
-
artifactTreeLeafIndex: seed + 2,
|
|
1194
|
-
privateFunctionTreeSiblingPath: makeTuple(3, fr, seed + 3),
|
|
1195
|
-
privateFunctionTreeLeafIndex: seed + 3,
|
|
1196
|
-
artifactMetadataHash: fr(seed + 4),
|
|
1197
|
-
functionMetadataHash: fr(seed + 5),
|
|
1198
|
-
utilityFunctionsTreeRoot: fr(seed + 6),
|
|
1199
|
-
vkHash: fr(seed + 7),
|
|
1200
|
-
};
|
|
1201
|
-
}
|
|
1202
|
-
|
|
1203
|
-
export function makeUtilityFunctionWithMembershipProof(seed = 0): UtilityFunctionWithMembershipProof {
|
|
1204
|
-
return {
|
|
1205
|
-
selector: makeSelector(seed),
|
|
1206
|
-
bytecode: makeBytes(100, seed + 1),
|
|
1207
|
-
artifactTreeSiblingPath: makeTuple(3, fr, seed + 2),
|
|
1208
|
-
artifactTreeLeafIndex: seed + 2,
|
|
1209
|
-
artifactMetadataHash: fr(seed + 4),
|
|
1210
|
-
functionMetadataHash: fr(seed + 5),
|
|
1211
|
-
privateFunctionsArtifactTreeRoot: fr(seed + 6),
|
|
1212
|
-
};
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1184
|
export async function makeContractClassPublic(seed = 0, publicBytecode?: Buffer): Promise<ContractClassPublic> {
|
|
1216
1185
|
const artifactHash = fr(seed + 1);
|
|
1217
1186
|
const privateFunctionsRoot = fr(seed + 3);
|
|
@@ -1223,8 +1192,6 @@ export async function makeContractClassPublic(seed = 0, publicBytecode?: Buffer)
|
|
|
1223
1192
|
artifactHash,
|
|
1224
1193
|
packedBytecode,
|
|
1225
1194
|
privateFunctionsRoot,
|
|
1226
|
-
privateFunctions: [],
|
|
1227
|
-
utilityFunctions: [],
|
|
1228
1195
|
version: 1,
|
|
1229
1196
|
};
|
|
1230
1197
|
}
|
|
@@ -1748,6 +1715,10 @@ export function makeL2Tips(
|
|
|
1748
1715
|
block: { number: bn, hash },
|
|
1749
1716
|
checkpoint: { number: cpn, hash: cph },
|
|
1750
1717
|
},
|
|
1718
|
+
proposedCheckpoint: {
|
|
1719
|
+
block: { number: bn, hash },
|
|
1720
|
+
checkpoint: { number: cpn, hash: cph },
|
|
1721
|
+
},
|
|
1751
1722
|
proven: {
|
|
1752
1723
|
block: { number: bn, hash },
|
|
1753
1724
|
checkpoint: { number: cpn, hash: cph },
|
package/src/tests/mocks.ts
CHANGED
|
@@ -98,6 +98,7 @@ export const mockTx = async (
|
|
|
98
98
|
publicCalldataSize = 2,
|
|
99
99
|
feePayer,
|
|
100
100
|
chonkProof = ChonkProof.random(),
|
|
101
|
+
gasLimits,
|
|
101
102
|
maxFeesPerGas = new GasFees(10, 10),
|
|
102
103
|
maxPriorityFeesPerGas,
|
|
103
104
|
gasUsed = Gas.empty(),
|
|
@@ -114,6 +115,7 @@ export const mockTx = async (
|
|
|
114
115
|
publicCalldataSize?: number;
|
|
115
116
|
feePayer?: AztecAddress;
|
|
116
117
|
chonkProof?: ChonkProof;
|
|
118
|
+
gasLimits?: Gas;
|
|
117
119
|
maxFeesPerGas?: GasFees;
|
|
118
120
|
maxPriorityFeesPerGas?: GasFees;
|
|
119
121
|
gasUsed?: Gas;
|
|
@@ -132,7 +134,7 @@ export const mockTx = async (
|
|
|
132
134
|
const data = PrivateKernelTailCircuitPublicInputs.empty();
|
|
133
135
|
const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
|
|
134
136
|
data.constants.anchorBlockHeader = anchorBlockHeader;
|
|
135
|
-
data.constants.txContext.gasSettings = GasSettings.
|
|
137
|
+
data.constants.txContext.gasSettings = GasSettings.fallback({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
|
|
136
138
|
data.feePayer = feePayer ?? (await AztecAddress.random());
|
|
137
139
|
data.gasUsed = gasUsed;
|
|
138
140
|
data.constants.txContext.chainId = chainId;
|
|
@@ -198,7 +200,7 @@ export async function mockProcessedTx({
|
|
|
198
200
|
db,
|
|
199
201
|
chainId = Fr.ZERO,
|
|
200
202
|
version = Fr.ZERO,
|
|
201
|
-
gasSettings = GasSettings.
|
|
203
|
+
gasSettings = GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) }),
|
|
202
204
|
vkTreeRoot = Fr.ZERO,
|
|
203
205
|
protocolContracts = makeProtocolContracts(seed + 0x100),
|
|
204
206
|
globalVariables = GlobalVariables.empty(),
|
|
@@ -425,10 +427,13 @@ export async function mockCheckpointAndMessages(
|
|
|
425
427
|
Partial<Parameters<typeof L2Block.random>[1]> = {},
|
|
426
428
|
) {
|
|
427
429
|
const slotNumber = options.slotNumber ?? SlotNumber(Number(checkpointNumber) * 10);
|
|
430
|
+
const globals = GlobalVariables.random({ slotNumber, ...options });
|
|
428
431
|
const blocksAndMessages = [];
|
|
432
|
+
|
|
429
433
|
// Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
|
|
430
434
|
// The current block's header.lastArchive must equal the previous block's archive.
|
|
431
435
|
let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
|
|
436
|
+
|
|
432
437
|
// Pass maxEffects via txOptions so it reaches TxEffect.random
|
|
433
438
|
const txOptions = maxEffects !== undefined ? { maxEffects } : {};
|
|
434
439
|
for (let i = 0; i < (blocks?.length ?? numBlocks); i++) {
|
|
@@ -437,11 +442,11 @@ export async function mockCheckpointAndMessages(
|
|
|
437
442
|
block:
|
|
438
443
|
blocks?.[i] ??
|
|
439
444
|
(await L2Block.random(blockNumber, {
|
|
445
|
+
...globals,
|
|
440
446
|
checkpointNumber,
|
|
441
447
|
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
442
448
|
txsPerBlock: numTxsPerBlock,
|
|
443
449
|
txOptions,
|
|
444
|
-
slotNumber,
|
|
445
450
|
...options,
|
|
446
451
|
...makeBlockOptions(blockNumber),
|
|
447
452
|
...(lastArchive ? { lastArchive } : {}),
|
|
@@ -455,12 +460,18 @@ export async function mockCheckpointAndMessages(
|
|
|
455
460
|
|
|
456
461
|
const messages = blocksAndMessages[0].messages;
|
|
457
462
|
const inHash = computeInHashFromL1ToL2Messages(messages);
|
|
458
|
-
const
|
|
463
|
+
const firstBlockLastArchive = blocksAndMessages[0].block.header.lastArchive;
|
|
464
|
+
const checkpoint = await Checkpoint.random(checkpointNumber, {
|
|
465
|
+
numBlocks: 0,
|
|
466
|
+
inHash,
|
|
467
|
+
...options,
|
|
468
|
+
...globals,
|
|
469
|
+
lastArchive: firstBlockLastArchive,
|
|
470
|
+
lastArchiveRoot: firstBlockLastArchive.root,
|
|
471
|
+
archive: lastArchive,
|
|
472
|
+
});
|
|
473
|
+
|
|
459
474
|
checkpoint.blocks = blocksAndMessages.map(({ block }) => block);
|
|
460
|
-
// Set the checkpoint's archive to match the last block's archive for proper chaining.
|
|
461
|
-
// When the archiver reconstructs checkpoints from L1, it uses the checkpoint's archive root
|
|
462
|
-
// from the L1 event to set the last block's archive. Without this, the archive chain breaks.
|
|
463
|
-
checkpoint.archive = lastArchive!;
|
|
464
475
|
|
|
465
476
|
// Return lastArchive so callers can chain it across multiple checkpoints
|
|
466
477
|
return { checkpoint, messages, lastArchive };
|
|
@@ -585,28 +596,30 @@ export const makeBlockProposal = (options?: MakeBlockProposalOptions): Promise<B
|
|
|
585
596
|
);
|
|
586
597
|
};
|
|
587
598
|
|
|
588
|
-
export const makeCheckpointProposal = (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
|
|
589
|
-
const blockHeader = options?.lastBlock?.blockHeader ?? makeBlockHeader(1);
|
|
599
|
+
export const makeCheckpointProposal = async (options?: MakeCheckpointProposalOptions): Promise<CheckpointProposal> => {
|
|
590
600
|
const checkpointHeader = options?.checkpointHeader ?? makeCheckpointHeader(1);
|
|
591
601
|
const archiveRoot = options?.archiveRoot ?? Fr.random();
|
|
592
602
|
const feeAssetPriceModifier = options?.feeAssetPriceModifier ?? 0n;
|
|
593
603
|
const signer = options?.signer ?? Secp256k1Signer.random();
|
|
594
604
|
|
|
595
|
-
// Build
|
|
596
|
-
const
|
|
597
|
-
? {
|
|
598
|
-
blockHeader,
|
|
599
|
-
indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4),
|
|
600
|
-
|
|
605
|
+
// Build a signed block proposal if lastBlock options are provided
|
|
606
|
+
const lastBlockProposal = options?.lastBlock
|
|
607
|
+
? await makeBlockProposal({
|
|
608
|
+
blockHeader: options.lastBlock.blockHeader,
|
|
609
|
+
indexWithinCheckpoint: options.lastBlock.indexWithinCheckpoint ?? IndexWithinCheckpoint(4),
|
|
610
|
+
inHash: checkpointHeader.inHash,
|
|
611
|
+
archiveRoot,
|
|
612
|
+
txHashes: options.lastBlock.txHashes,
|
|
601
613
|
txs: options.lastBlock.txs,
|
|
602
|
-
|
|
614
|
+
signer,
|
|
615
|
+
})
|
|
603
616
|
: undefined;
|
|
604
617
|
|
|
605
618
|
return CheckpointProposal.createProposalFromSigner(
|
|
606
619
|
checkpointHeader,
|
|
607
620
|
archiveRoot,
|
|
608
621
|
feeAssetPriceModifier,
|
|
609
|
-
|
|
622
|
+
lastBlockProposal,
|
|
610
623
|
payload => Promise.resolve(signer.signMessage(payload)),
|
|
611
624
|
);
|
|
612
625
|
};
|
package/src/timetable/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ export function calculateMaxBlocksPerSlot(
|
|
|
42
42
|
checkpointAssembleTime?: number;
|
|
43
43
|
p2pPropagationTime?: number;
|
|
44
44
|
l1PublishingTime?: number;
|
|
45
|
+
pipelining?: boolean;
|
|
45
46
|
} = {},
|
|
46
47
|
): number {
|
|
47
48
|
if (!blockDurationSec) {
|
|
@@ -56,8 +57,12 @@ export function calculateMaxBlocksPerSlot(
|
|
|
56
57
|
// Calculate checkpoint finalization time (assembly + round-trip propagation + L1 publishing)
|
|
57
58
|
const checkpointFinalizationTime = assembleTime + p2pTime * 2 + l1Time;
|
|
58
59
|
|
|
59
|
-
//
|
|
60
|
-
|
|
60
|
+
// When pipelining, finalization is deferred to the next slot, but we still reserve
|
|
61
|
+
// a sub-slot for validator re-execution so they can produce attestations.
|
|
62
|
+
let timeReservedAtEnd = blockDurationSec;
|
|
63
|
+
if (!opts.pipelining) {
|
|
64
|
+
timeReservedAtEnd += checkpointFinalizationTime;
|
|
65
|
+
}
|
|
61
66
|
|
|
62
67
|
// Time available for building blocks
|
|
63
68
|
const timeAvailableForBlocks = aztecSlotDurationSec - initOffset - timeReservedAtEnd;
|
package/src/tx/block_header.ts
CHANGED
|
@@ -176,6 +176,12 @@ export class BlockHeader {
|
|
|
176
176
|
this._cachedHash = Promise.resolve(new BlockHash(hashed));
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
/** Recomputes the cached hash. Used for testing when header fields are mutated via unfreeze. */
|
|
180
|
+
recomputeHash(): Promise<BlockHash> {
|
|
181
|
+
this._cachedHash = undefined;
|
|
182
|
+
return this.hash();
|
|
183
|
+
}
|
|
184
|
+
|
|
179
185
|
static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
|
|
180
186
|
return BlockHeader.from({
|
|
181
187
|
lastArchive: AppendOnlyTreeSnapshot.random(),
|
package/src/tx/capsule.ts
CHANGED
|
@@ -19,6 +19,8 @@ export class Capsule {
|
|
|
19
19
|
public readonly storageSlot: Fr,
|
|
20
20
|
/** Data passed to the contract */
|
|
21
21
|
public readonly data: Fr[],
|
|
22
|
+
/** Optional namespace for the capsule contents */
|
|
23
|
+
public readonly scope?: AztecAddress,
|
|
22
24
|
) {}
|
|
23
25
|
|
|
24
26
|
static get schema() {
|
|
@@ -30,12 +32,18 @@ export class Capsule {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
toBuffer() {
|
|
33
|
-
return
|
|
35
|
+
return this.scope
|
|
36
|
+
? serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), true, this.scope)
|
|
37
|
+
: serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), false);
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
static fromBuffer(buffer: Buffer | BufferReader): Capsule {
|
|
37
41
|
const reader = BufferReader.asReader(buffer);
|
|
38
|
-
|
|
42
|
+
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
43
|
+
const storageSlot = Fr.fromBuffer(reader);
|
|
44
|
+
const data = reader.readVector(Fr);
|
|
45
|
+
const hasScope = reader.readBoolean();
|
|
46
|
+
return new Capsule(contractAddress, storageSlot, data, hasScope ? AztecAddress.fromBuffer(reader) : undefined);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
toString() {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { FeeHeader } from '@aztec/ethereum/contracts';
|
|
2
|
+
import type { CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
1
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
4
|
import type { SlotNumber } from '@aztec/foundation/schemas';
|
|
3
5
|
|
|
@@ -6,6 +8,18 @@ import type { GasFees } from '../gas/gas_fees.js';
|
|
|
6
8
|
import type { UInt32 } from '../types/index.js';
|
|
7
9
|
import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
|
|
8
10
|
|
|
11
|
+
/** Fee header fields needed for pipelining overrides. */
|
|
12
|
+
export type ForceProposedFeeHeader = {
|
|
13
|
+
checkpointNumber: CheckpointNumber;
|
|
14
|
+
feeHeader: FeeHeader;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Options for building checkpoint global variables during pipelining. */
|
|
18
|
+
export type BuildCheckpointGlobalVariablesOpts = {
|
|
19
|
+
forcePendingCheckpointNumber?: CheckpointNumber;
|
|
20
|
+
forceProposedFeeHeader?: ForceProposedFeeHeader;
|
|
21
|
+
};
|
|
22
|
+
|
|
9
23
|
/**
|
|
10
24
|
* Interface for building global variables for Aztec blocks.
|
|
11
25
|
*/
|
|
@@ -32,5 +46,6 @@ export interface GlobalVariableBuilder {
|
|
|
32
46
|
coinbase: EthAddress,
|
|
33
47
|
feeRecipient: AztecAddress,
|
|
34
48
|
slotNumber: SlotNumber,
|
|
49
|
+
opts?: BuildCheckpointGlobalVariablesOpts,
|
|
35
50
|
): Promise<CheckpointGlobalVariables>;
|
|
36
51
|
}
|