@aztec/stdlib 0.0.1-commit.b9865e97 → 0.0.1-commit.be03c316
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 +8 -1
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/buffer.d.ts +6 -2
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +13 -1
- package/dest/abi/contract_artifact.d.ts +1 -1
- package/dest/abi/contract_artifact.d.ts.map +1 -1
- package/dest/abi/contract_artifact.js +26 -8
- package/dest/avm/avm.js +1 -1
- package/dest/avm/avm_proving_request.d.ts +70 -70
- package/dest/avm/index.d.ts +1 -6
- package/dest/avm/index.d.ts.map +1 -1
- package/dest/avm/index.js +0 -5
- package/dest/aztec-address/index.d.ts +35 -5
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +32 -8
- package/dest/block/attestation_info.d.ts +1 -1
- package/dest/block/attestation_info.d.ts.map +1 -1
- package/dest/block/attestation_info.js +7 -4
- package/dest/block/l2_block_source.d.ts +46 -23
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +15 -1
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts +39 -0
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.d.ts.map +1 -0
- package/dest/block/l2_block_stream/event_driven_l2_block_stream.js +165 -0
- package/dest/block/l2_block_stream/index.d.ts +2 -1
- package/dest/block/l2_block_stream/index.d.ts.map +1 -1
- package/dest/block/l2_block_stream/index.js +1 -0
- package/dest/block/l2_block_stream/interfaces.d.ts +81 -11
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/interfaces.js +25 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +23 -15
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +149 -152
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +6 -12
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_memory_store.js +8 -32
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +17 -18
- 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 +70 -58
- package/dest/block/proposal/attestations_and_signers.d.ts +19 -1
- package/dest/block/proposal/attestations_and_signers.d.ts.map +1 -1
- package/dest/block/proposal/attestations_and_signers.js +47 -7
- 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 +296 -37
- package/dest/block/validate_block_result.d.ts +16 -1
- package/dest/block/validate_block_result.d.ts.map +1 -1
- package/dest/block/validate_block_result.js +18 -3
- package/dest/checkpoint/checkpoint.js +2 -2
- 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/simulation_overrides.d.ts +61 -0
- package/dest/checkpoint/simulation_overrides.d.ts.map +1 -0
- package/dest/checkpoint/simulation_overrides.js +98 -0
- package/dest/checkpoint/validate.d.ts +11 -3
- package/dest/checkpoint/validate.d.ts.map +1 -1
- package/dest/checkpoint/validate.js +9 -6
- 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/network-consensus-config.d.ts +72 -0
- package/dest/config/network-consensus-config.d.ts.map +1 -0
- package/dest/config/network-consensus-config.js +223 -0
- package/dest/config/sequencer-config.d.ts +4 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +22 -3
- package/dest/contract/contract_address.d.ts +5 -4
- package/dest/contract/contract_address.d.ts.map +1 -1
- package/dest/contract/contract_class.d.ts +1 -1
- package/dest/contract/contract_class.d.ts.map +1 -1
- package/dest/contract/contract_class.js +3 -2
- package/dest/contract/contract_instance.d.ts +16 -2
- package/dest/contract/contract_instance.d.ts.map +1 -1
- package/dest/contract/contract_instance.js +45 -0
- package/dest/contract/index.d.ts +1 -2
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +0 -1
- package/dest/contract/interfaces/contract_data_source.d.ts +3 -5
- package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.d.ts +71 -10
- package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.js +7 -2
- package/dest/contract/interfaces/node-info.d.ts +11 -1
- package/dest/contract/interfaces/node-info.d.ts.map +1 -1
- package/dest/contract/interfaces/node-info.js +7 -1
- package/dest/contract/partial_address.d.ts +9 -3
- package/dest/contract/partial_address.d.ts.map +1 -1
- package/dest/contract/partial_address.js +8 -2
- package/dest/database-version/version_manager.d.ts +18 -4
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +76 -6
- package/dest/deserialization/index.d.ts +35 -3
- package/dest/deserialization/index.d.ts.map +1 -1
- package/dest/deserialization/index.js +32 -1
- package/dest/file-store/factory.d.ts +1 -1
- package/dest/file-store/factory.d.ts.map +1 -1
- package/dest/file-store/factory.js +7 -0
- package/dest/file-store/index.d.ts +2 -1
- package/dest/file-store/index.d.ts.map +1 -1
- package/dest/file-store/index.js +1 -0
- package/dest/file-store/memory.d.ts +24 -0
- package/dest/file-store/memory.d.ts.map +1 -0
- package/dest/file-store/memory.js +80 -0
- package/dest/gas/gas_settings.d.ts +7 -13
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +9 -16
- package/dest/gas/index.d.ts +2 -1
- package/dest/gas/index.d.ts.map +1 -1
- package/dest/gas/index.js +1 -0
- package/dest/gas/tx_gas_limits.d.ts +72 -0
- package/dest/gas/tx_gas_limits.d.ts.map +1 -0
- package/dest/gas/tx_gas_limits.js +85 -0
- package/dest/ha-signing/config.d.ts +19 -5
- package/dest/ha-signing/config.d.ts.map +1 -1
- package/dest/ha-signing/config.js +9 -3
- package/dest/ha-signing/local_config.d.ts +10 -2
- package/dest/ha-signing/local_config.d.ts.map +1 -1
- package/dest/ha-signing/local_config.js +8 -2
- package/dest/hash/hash.d.ts +1 -2
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +0 -7
- package/dest/interfaces/archiver.d.ts +7 -9
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -2
- package/dest/interfaces/aztec-node-admin.d.ts +24 -17
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +1 -1
- package/dest/interfaces/aztec-node-debug.d.ts +40 -2
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-debug.js +29 -1
- package/dest/interfaces/aztec-node.d.ts +69 -28
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +56 -20
- package/dest/interfaces/block-builder.d.ts +3 -1
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/chain_tips.d.ts +8 -47
- package/dest/interfaces/chain_tips.d.ts.map +1 -1
- package/dest/interfaces/chain_tips.js +1 -6
- package/dest/interfaces/checkpoint_parameter.d.ts +3 -3
- package/dest/interfaces/checkpoint_parameter.d.ts.map +1 -1
- package/dest/interfaces/checkpoint_parameter.js +3 -3
- package/dest/interfaces/client.d.ts +2 -1
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +27 -6
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +5 -1
- package/dest/interfaces/get_tx_by_hash_options.d.ts +9 -0
- package/dest/interfaces/get_tx_by_hash_options.d.ts.map +1 -0
- package/dest/interfaces/get_tx_by_hash_options.js +4 -0
- package/dest/interfaces/merkle_tree_operations.d.ts +3 -4
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/p2p.d.ts +38 -9
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +14 -2
- package/dest/interfaces/private_kernel_prover.d.ts +71 -12
- package/dest/interfaces/private_kernel_prover.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +2 -3
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-node.d.ts +12 -8
- package/dest/interfaces/prover-node.d.ts.map +1 -1
- package/dest/interfaces/prover-node.js +24 -17
- package/dest/interfaces/proving-job.d.ts +4 -4
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/proving-job.js +2 -2
- package/dest/interfaces/server.d.ts +1 -3
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +0 -2
- package/dest/interfaces/server_circuit_prover.d.ts +3 -3
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +15 -4
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +3 -1
- package/dest/interfaces/world_state.d.ts +14 -1
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts +8 -2
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts.map +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +12 -74
- 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 +0 -1
- package/dest/kernel/hints/read_request.js +1 -1
- package/dest/kernel/index.d.ts +6 -2
- package/dest/kernel/index.d.ts.map +1 -1
- package/dest/kernel/index.js +5 -1
- package/dest/kernel/log_hash.d.ts +1 -1
- package/dest/kernel/log_hash.d.ts.map +1 -1
- package/dest/kernel/log_hash.js +2 -2
- package/dest/kernel/note_hash.js +1 -1
- package/dest/kernel/nullifier.js +1 -1
- package/dest/kernel/private_circuit_public_inputs.d.ts +13 -3
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +14 -7
- package/dest/kernel/private_context_inputs.d.ts +4 -3
- package/dest/kernel/private_context_inputs.d.ts.map +1 -1
- package/dest/kernel/private_context_inputs.js +7 -3
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +7 -9
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.js +10 -7
- package/dest/kernel/private_kernel_init_2_circuit_private_inputs.d.ts +2 -3
- package/dest/kernel/private_kernel_init_2_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_2_circuit_private_inputs.js +3 -5
- package/dest/kernel/private_kernel_init_3_circuit_private_inputs.d.ts +2 -3
- package/dest/kernel/private_kernel_init_3_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_3_circuit_private_inputs.js +3 -5
- package/dest/kernel/private_kernel_init_4_circuit_private_inputs.d.ts +24 -0
- package/dest/kernel/private_kernel_init_4_circuit_private_inputs.d.ts.map +1 -0
- package/dest/kernel/private_kernel_init_4_circuit_private_inputs.js +37 -0
- package/dest/kernel/private_kernel_init_5_circuit_private_inputs.d.ts +25 -0
- package/dest/kernel/private_kernel_init_5_circuit_private_inputs.d.ts.map +1 -0
- package/dest/kernel/private_kernel_init_5_circuit_private_inputs.js +39 -0
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts +1 -9
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_circuit_private_inputs.js +2 -6
- package/dest/kernel/private_kernel_inner_4_circuit_private_inputs.d.ts +18 -0
- package/dest/kernel/private_kernel_inner_4_circuit_private_inputs.d.ts.map +1 -0
- package/dest/kernel/private_kernel_inner_4_circuit_private_inputs.js +27 -0
- package/dest/kernel/private_kernel_inner_5_circuit_private_inputs.d.ts +19 -0
- package/dest/kernel/private_kernel_inner_5_circuit_private_inputs.d.ts.map +1 -0
- package/dest/kernel/private_kernel_inner_5_circuit_private_inputs.js +29 -0
- package/dest/kernel/private_kernel_prover_output.d.ts +4 -1
- package/dest/kernel/private_kernel_prover_output.d.ts.map +1 -1
- package/dest/kernel/private_kernel_prover_output.js +4 -1
- package/dest/kernel/private_kernel_reset_dimensions.d.ts +7 -8
- package/dest/kernel/private_kernel_reset_dimensions.d.ts.map +1 -1
- package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.d.ts +29 -0
- package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.d.ts.map +1 -0
- package/dest/kernel/private_kernel_reset_tail_circuit_private_inputs.js +36 -0
- package/dest/kernel/private_kernel_simulated_output.d.ts +1 -7
- package/dest/kernel/private_kernel_simulated_output.d.ts.map +1 -1
- package/dest/kernel/private_kernel_simulated_output.js +2 -1
- package/dest/kernel/private_log_data.d.ts +1 -1
- package/dest/kernel/private_log_data.d.ts.map +1 -1
- package/dest/kernel/private_log_data.js +1 -1
- package/dest/kernel/utils/index.d.ts +1 -2
- package/dest/kernel/utils/index.d.ts.map +1 -1
- package/dest/kernel/utils/index.js +0 -1
- package/dest/keys/derivation.d.ts +41 -6
- package/dest/keys/derivation.d.ts.map +1 -1
- package/dest/keys/derivation.js +49 -26
- package/dest/logs/app_tagging_secret.d.ts +30 -7
- package/dest/logs/app_tagging_secret.d.ts.map +1 -1
- package/dest/logs/app_tagging_secret.js +46 -39
- package/dest/logs/app_tagging_secret_kind.js +1 -1
- package/dest/logs/contract_class_log.d.ts +1 -2
- package/dest/logs/contract_class_log.d.ts.map +1 -1
- package/dest/logs/contract_class_log.js +0 -4
- package/dest/logs/message_context.d.ts +5 -15
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +1 -66
- package/dest/logs/pending_tagged_log.d.ts +6 -8
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +1 -31
- package/dest/logs/shared_secret_derivation.d.ts +29 -6
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
- package/dest/logs/shared_secret_derivation.js +44 -11
- package/dest/messaging/l1_to_l2_message.d.ts +23 -2
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.js +36 -11
- package/dest/noir/index.d.ts +3 -3
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.d.ts +1 -1
- package/dest/p2p/attestation_utils.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.js +8 -1
- package/dest/p2p/checkpoint_attestation.d.ts +10 -1
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
- package/dest/p2p/checkpoint_attestation.js +10 -0
- package/dest/p2p/checkpoint_proposal.d.ts +2 -1
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.d.ts +2 -1
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/index.d.ts +1 -2
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +0 -1
- package/dest/p2p/signature_utils.d.ts +10 -1
- package/dest/p2p/signature_utils.d.ts.map +1 -1
- package/dest/p2p/signature_utils.js +9 -1
- package/dest/rollup/avm_proof_data.d.ts +3 -3
- package/dest/rollup/avm_proof_data.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.d.ts +8 -3
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +20 -10
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +1 -1
- package/dest/stats/stats.d.ts +2 -2
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +1 -27
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +10 -45
- package/dest/tests/mocks.d.ts +1 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +3 -2
- package/dest/timetable/budgets.d.ts +57 -0
- package/dest/timetable/budgets.d.ts.map +1 -0
- package/dest/timetable/budgets.js +56 -0
- package/dest/timetable/build_proposer_timetable.d.ts +21 -0
- package/dest/timetable/build_proposer_timetable.d.ts.map +1 -0
- package/dest/timetable/build_proposer_timetable.js +17 -0
- package/dest/timetable/consensus_timetable.d.ts +70 -0
- package/dest/timetable/consensus_timetable.d.ts.map +1 -0
- package/dest/timetable/consensus_timetable.js +89 -0
- package/dest/timetable/index.d.ts +5 -84
- package/dest/timetable/index.d.ts.map +1 -1
- package/dest/timetable/index.js +4 -209
- package/dest/timetable/proposer_timetable.d.ts +106 -0
- package/dest/timetable/proposer_timetable.d.ts.map +1 -0
- package/dest/timetable/proposer_timetable.js +132 -0
- package/dest/trees/nullifier_membership_witness.d.ts +5 -8
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/nullifier_membership_witness.js +0 -9
- package/dest/trees/public_data_witness.d.ts +7 -17
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/trees/public_data_witness.js +0 -27
- package/dest/tx/execution_payload.d.ts +1 -1
- package/dest/tx/execution_payload.d.ts.map +1 -1
- package/dest/tx/execution_payload.js +1 -1
- package/dest/tx/fee_provider.d.ts +2 -2
- package/dest/tx/fee_provider.d.ts.map +1 -1
- package/dest/tx/global_variable_builder.d.ts +2 -12
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/global_variables.js +2 -2
- package/dest/tx/index.d.ts +1 -2
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +0 -1
- package/dest/tx/private_tx_constant_data.d.ts +18 -2
- package/dest/tx/private_tx_constant_data.d.ts.map +1 -1
- package/dest/tx/private_tx_constant_data.js +13 -4
- package/dest/tx/profiling.d.ts +1 -1
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +2 -0
- package/dest/tx/simulated_tx.d.ts +10 -6
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/tx.d.ts +9 -1
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +15 -0
- package/dest/tx/validator/error_texts.d.ts +2 -2
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +1 -1
- package/package.json +8 -8
- package/src/abi/abi.ts +8 -0
- package/src/abi/buffer.ts +13 -1
- package/src/abi/contract_artifact.ts +33 -9
- package/src/avm/avm.ts +1 -1
- package/src/avm/index.ts +0 -5
- package/src/aztec-address/index.ts +36 -6
- package/src/block/attestation_info.ts +7 -2
- package/src/block/l2_block_source.ts +67 -13
- package/src/block/l2_block_stream/event_driven_l2_block_stream.ts +207 -0
- package/src/block/l2_block_stream/index.ts +1 -0
- package/src/block/l2_block_stream/interfaces.ts +96 -10
- package/src/block/l2_block_stream/l2_block_stream.ts +216 -175
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +12 -41
- package/src/block/l2_block_stream/l2_tips_store_base.ts +84 -93
- package/src/block/proposal/attestations_and_signers.ts +53 -7
- package/src/block/test/l2_tips_store_test_suite.ts +270 -28
- package/src/block/validate_block_result.ts +48 -2
- package/src/checkpoint/checkpoint.ts +2 -2
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/simulation_overrides.ts +171 -0
- package/src/checkpoint/validate.ts +16 -6
- package/src/config/index.ts +1 -0
- package/src/config/network-consensus-config.ts +291 -0
- package/src/config/sequencer-config.ts +36 -5
- package/src/contract/contract_address.ts +4 -3
- package/src/contract/contract_class.ts +3 -2
- package/src/contract/contract_instance.ts +62 -1
- package/src/contract/index.ts +0 -1
- package/src/contract/interfaces/contract_data_source.ts +2 -4
- package/src/contract/interfaces/contract_instance.ts +26 -8
- package/src/contract/interfaces/node-info.ts +11 -0
- package/src/contract/partial_address.ts +8 -2
- package/src/database-version/version_manager.ts +96 -6
- package/src/deserialization/index.ts +35 -2
- package/src/file-store/factory.ts +7 -0
- package/src/file-store/index.ts +1 -0
- package/src/file-store/memory.ts +94 -0
- package/src/gas/README.md +199 -35
- package/src/gas/gas_settings.ts +11 -21
- package/src/gas/index.ts +1 -0
- package/src/gas/tx_gas_limits.ts +123 -0
- package/src/ha-signing/config.ts +23 -5
- package/src/ha-signing/local_config.ts +20 -1
- package/src/hash/hash.ts +0 -8
- package/src/interfaces/archiver.ts +8 -9
- package/src/interfaces/aztec-node-admin.ts +1 -1
- package/src/interfaces/aztec-node-debug.ts +54 -2
- package/src/interfaces/aztec-node.ts +121 -43
- package/src/interfaces/block-builder.ts +2 -0
- package/src/interfaces/chain_tips.ts +8 -16
- package/src/interfaces/checkpoint_parameter.ts +3 -3
- package/src/interfaces/client.ts +1 -0
- package/src/interfaces/configs.ts +27 -6
- package/src/interfaces/get_tx_by_hash_options.ts +14 -0
- package/src/interfaces/merkle_tree_operations.ts +2 -3
- package/src/interfaces/p2p.ts +29 -9
- package/src/interfaces/private_kernel_prover.ts +104 -13
- package/src/interfaces/prover-client.ts +1 -3
- package/src/interfaces/prover-node.ts +32 -17
- package/src/interfaces/proving-job.ts +3 -3
- package/src/interfaces/server.ts +0 -2
- package/src/interfaces/server_circuit_prover.ts +2 -2
- package/src/interfaces/validator.ts +11 -0
- package/src/interfaces/world_state.ts +14 -0
- package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +22 -112
- package/src/kernel/hints/index.ts +0 -1
- package/src/kernel/hints/read_request.ts +1 -1
- package/src/kernel/index.ts +5 -1
- package/src/kernel/log_hash.ts +5 -2
- package/src/kernel/note_hash.ts +1 -1
- package/src/kernel/nullifier.ts +1 -1
- package/src/kernel/private_circuit_public_inputs.ts +12 -1
- package/src/kernel/private_context_inputs.ts +10 -3
- package/src/kernel/private_kernel_circuit_public_inputs.ts +9 -7
- package/src/kernel/private_kernel_init_2_circuit_private_inputs.ts +0 -3
- package/src/kernel/private_kernel_init_3_circuit_private_inputs.ts +0 -3
- package/src/kernel/private_kernel_init_4_circuit_private_inputs.ts +52 -0
- package/src/kernel/private_kernel_init_5_circuit_private_inputs.ts +55 -0
- package/src/kernel/private_kernel_init_circuit_private_inputs.ts +0 -6
- package/src/kernel/private_kernel_inner_4_circuit_private_inputs.ts +39 -0
- package/src/kernel/private_kernel_inner_5_circuit_private_inputs.ts +42 -0
- package/src/kernel/private_kernel_prover_output.ts +4 -0
- package/src/kernel/private_kernel_reset_dimensions.ts +15 -5
- package/src/kernel/private_kernel_reset_tail_circuit_private_inputs.ts +69 -0
- package/src/kernel/private_kernel_simulated_output.ts +0 -7
- package/src/kernel/private_log_data.ts +4 -1
- package/src/kernel/utils/index.ts +0 -1
- package/src/keys/derivation.ts +69 -24
- package/src/logs/app_tagging_secret.ts +62 -39
- package/src/logs/app_tagging_secret_kind.ts +1 -1
- package/src/logs/contract_class_log.ts +0 -9
- package/src/logs/message_context.ts +7 -65
- package/src/logs/pending_tagged_log.ts +6 -33
- package/src/logs/shared_secret_derivation.ts +47 -14
- package/src/messaging/l1_to_l2_message.ts +51 -13
- package/src/noir/index.ts +2 -1
- package/src/p2p/attestation_utils.ts +8 -1
- package/src/p2p/checkpoint_attestation.ts +12 -0
- package/src/p2p/index.ts +0 -1
- package/src/p2p/signature_utils.ts +9 -0
- package/src/rollup/avm_proof_data.ts +2 -2
- package/src/rollup/checkpoint_header.ts +16 -2
- package/src/stats/stats.ts +6 -2
- package/src/tests/factories.ts +13 -51
- package/src/tests/mocks.ts +7 -2
- package/src/timetable/README.md +609 -0
- package/src/timetable/budgets.ts +87 -0
- package/src/timetable/build_proposer_timetable.ts +42 -0
- package/src/timetable/consensus_timetable.ts +126 -0
- package/src/timetable/index.ts +4 -304
- package/src/timetable/proposer_timetable.ts +190 -0
- package/src/timetable/timetable-example.svg +108 -0
- package/src/trees/nullifier_membership_witness.ts +0 -11
- package/src/trees/public_data_witness.ts +0 -31
- package/src/tx/execution_payload.ts +2 -1
- package/src/tx/fee_provider.ts +1 -1
- package/src/tx/global_variable_builder.ts +1 -17
- package/src/tx/global_variables.ts +2 -2
- package/src/tx/index.ts +0 -1
- package/src/tx/private_tx_constant_data.ts +25 -2
- package/src/tx/profiling.ts +2 -0
- package/src/tx/tx.ts +17 -0
- package/src/tx/validator/error_texts.ts +2 -1
- package/dest/avm/contract_storage_read.d.ts +0 -58
- package/dest/avm/contract_storage_read.d.ts.map +0 -1
- package/dest/avm/contract_storage_read.js +0 -65
- package/dest/avm/contract_storage_update_request.d.ts +0 -65
- package/dest/avm/contract_storage_update_request.d.ts.map +0 -1
- package/dest/avm/contract_storage_update_request.js +0 -80
- package/dest/avm/public_call_stack_item_compressed.d.ts +0 -43
- package/dest/avm/public_call_stack_item_compressed.d.ts.map +0 -1
- package/dest/avm/public_call_stack_item_compressed.js +0 -70
- package/dest/avm/public_data_update_request.d.ts +0 -62
- package/dest/avm/public_data_update_request.d.ts.map +0 -1
- package/dest/avm/public_data_update_request.js +0 -67
- package/dest/avm/public_inner_call_request.d.ts +0 -50
- package/dest/avm/public_inner_call_request.d.ts.map +0 -1
- package/dest/avm/public_inner_call_request.js +0 -74
- package/dest/contract/deployment_info.d.ts +0 -24
- package/dest/contract/deployment_info.d.ts.map +0 -1
- package/dest/contract/deployment_info.js +0 -3
- package/dest/interfaces/epoch-prover.d.ts +0 -57
- package/dest/interfaces/epoch-prover.d.ts.map +0 -1
- package/dest/interfaces/epoch-prover.js +0 -1
- package/dest/interfaces/prover-coordination.d.ts +0 -15
- package/dest/interfaces/prover-coordination.d.ts.map +0 -1
- package/dest/interfaces/prover-coordination.js +0 -1
- package/dest/kernel/hints/tree_leaf_read_request.d.ts +0 -14
- package/dest/kernel/hints/tree_leaf_read_request.d.ts.map +0 -1
- package/dest/kernel/hints/tree_leaf_read_request.js +0 -33
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +0 -47
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +0 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.js +0 -38
- package/dest/kernel/utils/optional_number.d.ts +0 -31
- package/dest/kernel/utils/optional_number.d.ts.map +0 -1
- package/dest/kernel/utils/optional_number.js +0 -42
- package/dest/p2p/interface.d.ts +0 -5
- package/dest/p2p/interface.d.ts.map +0 -1
- package/dest/p2p/interface.js +0 -1
- package/dest/tx/validator/empty_validator.d.ts +0 -5
- package/dest/tx/validator/empty_validator.d.ts.map +0 -1
- package/dest/tx/validator/empty_validator.js +0 -7
- package/src/avm/contract_storage_read.ts +0 -77
- package/src/avm/contract_storage_update_request.ts +0 -93
- package/src/avm/public_call_stack_item_compressed.ts +0 -113
- package/src/avm/public_data_update_request.ts +0 -106
- package/src/avm/public_inner_call_request.ts +0 -85
- package/src/contract/deployment_info.ts +0 -25
- package/src/interfaces/epoch-prover.ts +0 -72
- package/src/interfaces/prover-coordination.ts +0 -17
- package/src/kernel/hints/tree_leaf_read_request.ts +0 -35
- package/src/kernel/private_kernel_tail_circuit_private_inputs.ts +0 -58
- package/src/kernel/utils/optional_number.ts +0 -50
- package/src/p2p/interface.ts +0 -4
- package/src/tx/validator/empty_validator.ts +0 -7
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
type ABIParameter,
|
|
14
14
|
type ABIParameterVisibility,
|
|
15
15
|
ARTIFACT_VERSION_BEFORE_INJECTION,
|
|
16
|
+
type AbiNamedValue,
|
|
16
17
|
type AbiType,
|
|
18
|
+
type AbiValue,
|
|
17
19
|
type BasicValue,
|
|
18
20
|
type ContractArtifact,
|
|
19
21
|
ContractArtifactSchema,
|
|
@@ -246,20 +248,24 @@ function hasKernelFunctionInputs(params: ABIParameter[]): boolean {
|
|
|
246
248
|
|
|
247
249
|
/**
|
|
248
250
|
* Generates a storage layout for the contract artifact.
|
|
249
|
-
* @param
|
|
251
|
+
* @param contractName - The name of the compiled Noir contract.
|
|
252
|
+
* @param globals - The normalized globals exported by the contract.
|
|
250
253
|
* @returns A storage layout for the contract.
|
|
251
254
|
*/
|
|
252
|
-
function getStorageLayout(
|
|
255
|
+
function getStorageLayout(contractName: string, globals: Record<string, AbiValue[]>) {
|
|
253
256
|
// If another contract is imported by the main contract, its storage layout its going to also show up here.
|
|
254
257
|
// The layout export includes the contract name, so here we can find the one that belongs to the current one and
|
|
255
258
|
// ignore the rest.
|
|
256
|
-
const storageExports =
|
|
257
|
-
const storageForContract = storageExports.find(storageExport => {
|
|
259
|
+
const storageExports = globals.storage ?? [];
|
|
260
|
+
const storageForContract = storageExports.find((storageExport): storageExport is StructValue => {
|
|
261
|
+
if (storageExport.kind !== 'struct') {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
258
264
|
const contractNameField = storageExport.fields.find(field => field.name === 'contract_name')?.value as BasicValue<
|
|
259
265
|
'string',
|
|
260
266
|
string
|
|
261
267
|
>;
|
|
262
|
-
return contractNameField.value ===
|
|
268
|
+
return contractNameField.value === contractName;
|
|
263
269
|
});
|
|
264
270
|
const storageFields = storageForContract
|
|
265
271
|
? ((storageForContract.fields.find(field => field.name == 'fields') as TypedStructFieldValue<StructValue>).value
|
|
@@ -280,6 +286,22 @@ function getStorageLayout(input: NoirCompiledContract) {
|
|
|
280
286
|
}, {});
|
|
281
287
|
}
|
|
282
288
|
|
|
289
|
+
function isAbiNamedValue(value: AbiNamedValue | AbiValue): value is AbiNamedValue {
|
|
290
|
+
return 'name' in value;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function normalizeContractOutputs(outputs: NoirCompiledContract['outputs']): ContractArtifact['outputs'] {
|
|
294
|
+
return {
|
|
295
|
+
structs: outputs.structs,
|
|
296
|
+
globals: Object.fromEntries(
|
|
297
|
+
Object.entries(outputs.globals).map(([tag, values]) => [
|
|
298
|
+
tag,
|
|
299
|
+
values.map(value => (isAbiNamedValue(value) ? value.value : value)),
|
|
300
|
+
]),
|
|
301
|
+
),
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
|
|
283
305
|
/**
|
|
284
306
|
* Given a post-processed Nargo output defined as `contract` generates an Aztec-compatible contract artifact.
|
|
285
307
|
*
|
|
@@ -290,6 +312,7 @@ function generateContractArtifact(contract: NoirCompiledContract): ContractArtif
|
|
|
290
312
|
if (!contract.transpiled) {
|
|
291
313
|
throw new Error("Contract's public bytecode has not been transpiled");
|
|
292
314
|
}
|
|
315
|
+
const outputs = normalizeContractOutputs(contract.outputs);
|
|
293
316
|
return ContractArtifactSchema.parse({
|
|
294
317
|
name: contract.name,
|
|
295
318
|
aztecVersion: contract.aztec_version,
|
|
@@ -297,8 +320,8 @@ function generateContractArtifact(contract: NoirCompiledContract): ContractArtif
|
|
|
297
320
|
nonDispatchPublicFunctions: contract.functions
|
|
298
321
|
.filter(f => !retainBytecode(f))
|
|
299
322
|
.map(f => generateFunctionAbi(f, contract)),
|
|
300
|
-
outputs
|
|
301
|
-
storageLayout: getStorageLayout(contract),
|
|
323
|
+
outputs,
|
|
324
|
+
storageLayout: getStorageLayout(contract.name, outputs.globals),
|
|
302
325
|
fileMap: contract.file_map,
|
|
303
326
|
});
|
|
304
327
|
} catch (err) {
|
|
@@ -313,6 +336,7 @@ function generateContractArtifact(contract: NoirCompiledContract): ContractArtif
|
|
|
313
336
|
*/
|
|
314
337
|
function generateContractArtifactForPublic(contract: NoirCompiledContract): ContractArtifact {
|
|
315
338
|
try {
|
|
339
|
+
const outputs = normalizeContractOutputs(contract.outputs);
|
|
316
340
|
return ContractArtifactSchema.parse({
|
|
317
341
|
name: contract.name,
|
|
318
342
|
aztecVersion: contract.aztec_version,
|
|
@@ -320,8 +344,8 @@ function generateContractArtifactForPublic(contract: NoirCompiledContract): Cont
|
|
|
320
344
|
nonDispatchPublicFunctions: contract.functions
|
|
321
345
|
.filter(f => !retainBytecode(f))
|
|
322
346
|
.map(f => generateFunctionAbi(f, contract)),
|
|
323
|
-
outputs
|
|
324
|
-
storageLayout: getStorageLayout(contract),
|
|
347
|
+
outputs,
|
|
348
|
+
storageLayout: getStorageLayout(contract.name, outputs.globals),
|
|
325
349
|
fileMap: contract.file_map,
|
|
326
350
|
});
|
|
327
351
|
} catch (err) {
|
package/src/avm/avm.ts
CHANGED
|
@@ -1152,7 +1152,7 @@ export class CallStackMetadata {
|
|
|
1152
1152
|
|
|
1153
1153
|
const { stack, leaf } = failingCall;
|
|
1154
1154
|
const aztecCallStack = stack.map(call => ({
|
|
1155
|
-
contractAddress: AztecAddress.
|
|
1155
|
+
contractAddress: AztecAddress.fromFieldUnsafe(call.contractAddress),
|
|
1156
1156
|
functionSelector: call.calldata.length > 0 ? FunctionSelector.fromFieldOrUndefined(call.calldata[0]) : undefined,
|
|
1157
1157
|
}));
|
|
1158
1158
|
|
package/src/avm/index.ts
CHANGED
|
@@ -3,10 +3,5 @@ export * from './avm_accumulated_data.js';
|
|
|
3
3
|
export * from './avm_circuit_public_inputs.js';
|
|
4
4
|
export * from './revert_code.js';
|
|
5
5
|
export * from './public_data_write.js';
|
|
6
|
-
export * from './public_data_update_request.js';
|
|
7
|
-
export * from './contract_storage_update_request.js';
|
|
8
|
-
export * from './contract_storage_read.js';
|
|
9
|
-
export * from './public_inner_call_request.js';
|
|
10
|
-
export * from './public_call_stack_item_compressed.js';
|
|
11
6
|
export * from './avm_proving_request.js';
|
|
12
7
|
export * from './message_pack.js';
|
|
@@ -43,34 +43,64 @@ export class AztecAddress {
|
|
|
43
43
|
static ZERO = new AztecAddress(Buffer.alloc(32, 0));
|
|
44
44
|
|
|
45
45
|
/** Null msg sender address. Not part of the protocol contracts tree. */
|
|
46
|
-
static NULL_MSG_SENDER = AztecAddress.
|
|
46
|
+
static NULL_MSG_SENDER = AztecAddress.fromBigIntUnsafe(NULL_MSG_SENDER_CONTRACT_ADDRESS);
|
|
47
47
|
|
|
48
48
|
static zero(): AztecAddress {
|
|
49
49
|
return AztecAddress.ZERO;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Builds an `AztecAddress` from a field **without checking it is a valid address** (the x-coordinate of a point on
|
|
54
|
+
* the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an
|
|
55
|
+
* untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
56
|
+
*/
|
|
57
|
+
static fromFieldUnsafe(fr: Fr) {
|
|
53
58
|
return new AztecAddress(fr);
|
|
54
59
|
}
|
|
55
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Deserializes an `AztecAddress` from a buffer. It does **not** check the value is a valid Grumpkin-curve address
|
|
63
|
+
* (see {@link AztecAddress.isValid}); it is meant for reading addresses from already-validated serialized data. Use
|
|
64
|
+
* {@link AztecAddress.random} for valid test addresses.
|
|
65
|
+
*/
|
|
56
66
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
57
67
|
return new AztecAddress(fromBuffer(buffer, Fr));
|
|
58
68
|
}
|
|
59
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Deserializes an `AztecAddress` from a field reader. It does **not** check the value is a valid Grumpkin-curve
|
|
72
|
+
* address (see {@link AztecAddress.isValid}); it is meant for reading addresses from already-validated serialized
|
|
73
|
+
* data. Use {@link AztecAddress.random} for valid test addresses.
|
|
74
|
+
*/
|
|
60
75
|
static fromFields(fields: Fr[] | FieldReader) {
|
|
61
76
|
const reader = FieldReader.asReader(fields);
|
|
62
77
|
return new AztecAddress(reader.readField());
|
|
63
78
|
}
|
|
64
79
|
|
|
65
|
-
|
|
80
|
+
/**
|
|
81
|
+
* Builds an `AztecAddress` from a bigint **without checking it is a valid address** (the x-coordinate of a point on
|
|
82
|
+
* the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an
|
|
83
|
+
* untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
84
|
+
*/
|
|
85
|
+
static fromBigIntUnsafe(value: bigint) {
|
|
66
86
|
return new AztecAddress(new Fr(value));
|
|
67
87
|
}
|
|
68
88
|
|
|
69
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Builds an `AztecAddress` from a number **without checking it is a valid address** (the x-coordinate of a point on
|
|
91
|
+
* the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to validate an
|
|
92
|
+
* untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
93
|
+
*/
|
|
94
|
+
static fromNumberUnsafe(value: number) {
|
|
70
95
|
return new AztecAddress(new Fr(value));
|
|
71
96
|
}
|
|
72
97
|
|
|
73
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Builds an `AztecAddress` from a hex string **without checking it is a valid address** (the x-coordinate of a
|
|
100
|
+
* point on the Grumpkin curve, which is what lets it be encrypted to). Use {@link AztecAddress.isValid} to
|
|
101
|
+
* validate an untrusted one, or {@link AztecAddress.random} for valid test addresses.
|
|
102
|
+
*/
|
|
103
|
+
static fromStringUnsafe(buf: string) {
|
|
74
104
|
return new AztecAddress(hexToBuffer(buf));
|
|
75
105
|
}
|
|
76
106
|
|
|
@@ -89,7 +119,7 @@ export class AztecAddress {
|
|
|
89
119
|
if (obj instanceof Buffer || Buffer.isBuffer(obj)) {
|
|
90
120
|
return new AztecAddress(obj);
|
|
91
121
|
}
|
|
92
|
-
return AztecAddress.
|
|
122
|
+
return AztecAddress.fromStringUnsafe(obj);
|
|
93
123
|
}
|
|
94
124
|
|
|
95
125
|
/**
|
|
@@ -60,9 +60,14 @@ export function getAttestationInfoFromPayload(
|
|
|
60
60
|
return { address: attestation.address, status: 'provided-as-address' as const };
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
// Try to recover address from signature
|
|
63
|
+
// Try to recover address from signature. Recover with default opts (no allowYParityAsV): a slot
|
|
64
|
+
// whose recovery byte is in yParity form (v ∈ {0, 1}) is judged invalid here, matching L1 proving
|
|
65
|
+
// (ValidatorSelectionLib.verifyAttestations → ECDSA.recover only accepts v ∈ {27, 28}). A malicious
|
|
66
|
+
// proposer that lands such a slot cannot have it silently treated as valid off-chain; it is routed to
|
|
67
|
+
// invalid-attestation and invalidated. The gossip receipt path (recoverCoordinationSigner) stays
|
|
68
|
+
// lenient with allowYParityAsV; A-1351 normalizes on pool ingress and before the L1 bundle.
|
|
64
69
|
try {
|
|
65
|
-
const recoveredAddress = recoverAddress(hashedPayload, attestation.signature
|
|
70
|
+
const recoveredAddress = recoverAddress(hashedPayload, attestation.signature);
|
|
66
71
|
return { address: recoveredAddress, status: 'recovered-from-signature' as const };
|
|
67
72
|
} catch {
|
|
68
73
|
// Signature present but recovery failed
|
|
@@ -63,8 +63,18 @@ export type CheckpointQuery =
|
|
|
63
63
|
| { slot: SlotNumber }
|
|
64
64
|
| { tag: 'checkpointed' | 'proven' | 'finalized' };
|
|
65
65
|
|
|
66
|
-
/**
|
|
67
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Query a range of confirmed checkpoints by start/limit, by slot anchor, or by epoch.
|
|
68
|
+
*
|
|
69
|
+
* The `fromSlot` variant walks the slot index: it returns up to `limit` checkpoints anchored at
|
|
70
|
+
* `fromSlot`, ordered nearest-first. With `reverse` it takes the checkpoints at or before the slot
|
|
71
|
+
* (descending); otherwise the checkpoints at or after it (ascending). Use `limit: 1, reverse: true`
|
|
72
|
+
* to find the latest checkpoint at or before a slot in a single range scan.
|
|
73
|
+
*/
|
|
74
|
+
export type CheckpointsQuery =
|
|
75
|
+
| { from: CheckpointNumber; limit: number }
|
|
76
|
+
| { fromSlot: SlotNumber; limit: number; reverse?: boolean }
|
|
77
|
+
| { epoch: EpochNumber };
|
|
68
78
|
|
|
69
79
|
/**
|
|
70
80
|
* Lookup a proposed (archiver-internal, not-yet-L1-confirmed) checkpoint.
|
|
@@ -81,6 +91,7 @@ export const CheckpointQuerySchema: z.ZodType<CheckpointQuery, unknown> = z.unio
|
|
|
81
91
|
|
|
82
92
|
export const CheckpointsQuerySchema: z.ZodType<CheckpointsQuery, unknown> = z.union([
|
|
83
93
|
z.object({ from: CheckpointNumberSchema, limit: z.number().int().min(1) }).strict(),
|
|
94
|
+
z.object({ fromSlot: SlotNumberSchema, limit: z.number().int().min(1), reverse: z.boolean().optional() }).strict(),
|
|
84
95
|
z.object({ epoch: EpochNumberSchema }).strict(),
|
|
85
96
|
]);
|
|
86
97
|
|
|
@@ -241,7 +252,10 @@ export interface L2BlockSource {
|
|
|
241
252
|
|
|
242
253
|
/**
|
|
243
254
|
* Looks up a proposed (archiver-internal, not-yet-L1-confirmed) checkpoint.
|
|
244
|
-
* Returns the latest proposed entry when called with no args or `{ tag: 'proposed' }
|
|
255
|
+
* Returns the latest proposed entry when called with no args or `{ tag: 'proposed' }`; since a
|
|
256
|
+
* proposed entry can only be stored with a checkpoint number beyond the confirmed frontier (and is
|
|
257
|
+
* deleted on confirmation), the latest entry is always the leading one. Callers derive the proposed
|
|
258
|
+
* tip from the payload (checkpoint number, and last block `startBlock + blockCount - 1`).
|
|
245
259
|
* With `{ number }` or `{ slot }`, returns the matching entry or undefined.
|
|
246
260
|
* Never falls back to confirmed checkpoints.
|
|
247
261
|
*/
|
|
@@ -321,36 +335,37 @@ export type ArchiverEmitter = TypedEventEmitter<{
|
|
|
321
335
|
[L2BlockSourceEvents.DescendentOfInvalidAttestationsCheckpointDetected]: (
|
|
322
336
|
args: DescendentOfInvalidAttestationsCheckpointEvent,
|
|
323
337
|
) => void;
|
|
338
|
+
[L2BlockSourceEvents.L2BlockSourceUpdated]: (args: L2BlockSourceUpdatedEvent) => void;
|
|
324
339
|
}>;
|
|
325
340
|
export interface L2BlockSourceEventEmitter extends L2BlockSource {
|
|
326
341
|
events: ArchiverEmitter;
|
|
327
342
|
}
|
|
328
343
|
|
|
329
344
|
/**
|
|
330
|
-
* Identifier for L2 block tags. Internal counterpart to {@link BlockTag} that
|
|
331
|
-
*
|
|
332
|
-
* archiver side) and omits `latest` (which is an alias for `proposed` accepted only at
|
|
333
|
-
* the public RPC surface).
|
|
345
|
+
* Identifier for L2 block tags. Internal counterpart to {@link BlockTag} that omits `latest`
|
|
346
|
+
* (which is an alias for `proposed` accepted only at the public RPC surface).
|
|
334
347
|
*
|
|
335
348
|
* - proposed: Latest block proposed on L2.
|
|
336
|
-
* - proposedCheckpoint: Latest block in the most recent proposed checkpoint (archiver-internal).
|
|
337
349
|
* - checkpointed: Latest block whose enclosing checkpoint has been published on L1.
|
|
338
350
|
* - proven: Latest block whose enclosing checkpoint has been proven on L1.
|
|
339
351
|
* - finalized: Latest block whose proving L1 transaction has reached L1 finality.
|
|
340
|
-
*
|
|
341
|
-
* TODO(palla): Remove `proposedCheckpoint` and unify with `proposed`.
|
|
342
352
|
*/
|
|
343
|
-
export type L2BlockTag = 'proposed' | '
|
|
353
|
+
export type L2BlockTag = 'proposed' | 'checkpointed' | 'proven' | 'finalized';
|
|
344
354
|
|
|
345
355
|
/** Tips of the L2 chain. */
|
|
346
356
|
export type L2Tips = {
|
|
347
357
|
proposed: L2BlockId;
|
|
348
358
|
checkpointed: L2TipId;
|
|
349
|
-
proposedCheckpoint: L2TipId;
|
|
350
359
|
proven: L2TipId;
|
|
351
360
|
finalized: L2TipId;
|
|
352
361
|
};
|
|
353
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Tips of the L2 chain as tracked by a local provider (world-state, l2-tips-store). Identical to
|
|
365
|
+
* {@link L2Tips}; the alias is retained for call sites that document a local-only provenance.
|
|
366
|
+
*/
|
|
367
|
+
export type LocalL2Tips = L2Tips;
|
|
368
|
+
|
|
354
369
|
export const GENESIS_CHECKPOINT_HEADER_HASH = CheckpointHeader.empty().hash();
|
|
355
370
|
|
|
356
371
|
/** Identifies a block by number and hash. */
|
|
@@ -373,6 +388,28 @@ export function makeL2CheckpointId(number: CheckpointNumber, hash: string): Chec
|
|
|
373
388
|
return { number, hash };
|
|
374
389
|
}
|
|
375
390
|
|
|
391
|
+
function l2BlockIdEquals(a: L2BlockId, b: L2BlockId): boolean {
|
|
392
|
+
return a.number === b.number && a.hash === b.hash;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
function l2TipIdEquals(a: L2TipId, b: L2TipId): boolean {
|
|
396
|
+
return (
|
|
397
|
+
l2BlockIdEquals(a.block, b.block) &&
|
|
398
|
+
a.checkpoint.number === b.checkpoint.number &&
|
|
399
|
+
a.checkpoint.hash === b.checkpoint.hash
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/** Returns whether two {@link L2Tips} snapshots agree on every tier (proposed, checkpointed, proven, finalized). */
|
|
404
|
+
export function l2TipsEqual(a: L2Tips, b: L2Tips): boolean {
|
|
405
|
+
return (
|
|
406
|
+
l2BlockIdEquals(a.proposed, b.proposed) &&
|
|
407
|
+
l2TipIdEquals(a.checkpointed, b.checkpointed) &&
|
|
408
|
+
l2TipIdEquals(a.proven, b.proven) &&
|
|
409
|
+
l2TipIdEquals(a.finalized, b.finalized)
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
376
413
|
const L2BlockIdSchema = z.object({
|
|
377
414
|
number: BlockNumberSchema,
|
|
378
415
|
hash: z.string(),
|
|
@@ -391,7 +428,6 @@ const L2TipIdSchema = z.object({
|
|
|
391
428
|
export const L2TipsSchema = z.object({
|
|
392
429
|
proposed: L2BlockIdSchema,
|
|
393
430
|
checkpointed: L2TipIdSchema,
|
|
394
|
-
proposedCheckpoint: L2TipIdSchema,
|
|
395
431
|
proven: L2TipIdSchema,
|
|
396
432
|
finalized: L2TipIdSchema,
|
|
397
433
|
});
|
|
@@ -404,8 +440,26 @@ export enum L2BlockSourceEvents {
|
|
|
404
440
|
InvalidAttestationsCheckpointDetected = 'invalidCheckpointDetected',
|
|
405
441
|
CheckpointEquivocationDetected = 'checkpointEquivocationDetected',
|
|
406
442
|
DescendentOfInvalidAttestationsCheckpointDetected = 'descendentOfInvalidAttestationsCheckpointDetected',
|
|
443
|
+
L2BlockSourceUpdated = 'l2BlockSourceUpdated',
|
|
407
444
|
}
|
|
408
445
|
|
|
446
|
+
/**
|
|
447
|
+
* Aggregate event emitted once per committed archiver sync pass that mutated local state. Carries the chain tips
|
|
448
|
+
* before and after the pass, and the blocks added during it. Consumers compare `fromTips` and `toTips` to learn what
|
|
449
|
+
* moved; there is no separate `changed` section.
|
|
450
|
+
*
|
|
451
|
+
* This is an optimization signal that lets a block stream reconcile immediately on an archiver update rather than
|
|
452
|
+
* waiting for its next poll. Polling remains the correctness fallback, so a missed event only affects latency.
|
|
453
|
+
* `blocksAdded` are hydrated blocks already in hand from the sync pass, so a triggered sync that is caught up to
|
|
454
|
+
* `fromTips` can reuse them (and `toTips`) instead of re-reading the store.
|
|
455
|
+
*/
|
|
456
|
+
export type L2BlockSourceUpdatedEvent = {
|
|
457
|
+
type: 'l2BlockSourceUpdated';
|
|
458
|
+
fromTips: L2Tips;
|
|
459
|
+
toTips: L2Tips;
|
|
460
|
+
blocksAdded: readonly L2Block[];
|
|
461
|
+
};
|
|
462
|
+
|
|
409
463
|
export type L2BlockProvenEvent = {
|
|
410
464
|
type: 'l2BlockProven';
|
|
411
465
|
blockNumber: BlockNumber;
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
3
|
+
|
|
4
|
+
import type { BlockData } from '../block_data.js';
|
|
5
|
+
import type { L2Block } from '../l2_block.js';
|
|
6
|
+
import {
|
|
7
|
+
type ArchiverEmitter,
|
|
8
|
+
type BlockQuery,
|
|
9
|
+
type BlocksQuery,
|
|
10
|
+
type L2BlockSource,
|
|
11
|
+
type L2BlockSourceEventEmitter,
|
|
12
|
+
L2BlockSourceEvents,
|
|
13
|
+
type L2BlockSourceUpdatedEvent,
|
|
14
|
+
type L2Tips,
|
|
15
|
+
} from '../l2_block_source.js';
|
|
16
|
+
import { type L2BlockStreamEventHandler, type L2BlockStreamLocalDataProvider, localTipsMatch } from './interfaces.js';
|
|
17
|
+
import { L2BlockStream, type L2BlockStreamOptions, type L2BlockStreamSource } from './l2_block_stream.js';
|
|
18
|
+
|
|
19
|
+
/** Derives the metadata-only {@link BlockData} view of a hydrated {@link L2Block}. */
|
|
20
|
+
async function l2BlockToBlockData(block: L2Block): Promise<BlockData> {
|
|
21
|
+
return {
|
|
22
|
+
header: block.header,
|
|
23
|
+
archive: block.archive,
|
|
24
|
+
blockHash: await block.hash(),
|
|
25
|
+
checkpointNumber: block.checkpointNumber,
|
|
26
|
+
indexWithinCheckpoint: block.indexWithinCheckpoint,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Returns the event emitter of a source that exposes one, or undefined for plain (e.g. RPC-backed) sources. */
|
|
31
|
+
function getEmitter(source: L2BlockSource | L2BlockSourceEventEmitter): ArchiverEmitter | undefined {
|
|
32
|
+
return 'events' in source ? source.events : undefined;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Fast-path context for a single sync pass: blocks to serve by number, plus the tips to report as the source's. */
|
|
36
|
+
type ActiveUpdate = { byNumber: Map<number, L2Block>; toTips: L2Tips };
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Wraps a block source so a single sync pass can be served from blocks delivered by an aggregate update event,
|
|
40
|
+
* avoiding round-trips to archiver storage. The fast path is only armed (via {@link activate}) for a pass that is
|
|
41
|
+
* confirmed caught up to the event's pre-pass tips: in that case the event's `blocksAdded` contiguously cover the
|
|
42
|
+
* pass's download range and `toTips` is the exact post-pass tip, so `getL2Tips` can report it without querying the
|
|
43
|
+
* source. When the fast path is not armed, every read delegates to the source, so a stale or partial cache never
|
|
44
|
+
* changes the sync outcome.
|
|
45
|
+
*/
|
|
46
|
+
class HotBlockSourceAdapter implements L2BlockStreamSource {
|
|
47
|
+
/** Set for the duration of one fast-path pass; undefined when reads must delegate to the source. */
|
|
48
|
+
private active: ActiveUpdate | undefined;
|
|
49
|
+
|
|
50
|
+
constructor(
|
|
51
|
+
private readonly source: L2BlockStreamSource,
|
|
52
|
+
private readonly log: Logger,
|
|
53
|
+
) {}
|
|
54
|
+
|
|
55
|
+
/** Arms the fast path for the current pass: serve these blocks and report `toTips` as the source tips. */
|
|
56
|
+
public activate(blocks: readonly L2Block[], toTips: L2Tips): void {
|
|
57
|
+
const byNumber = new Map<number, L2Block>();
|
|
58
|
+
for (const block of blocks) {
|
|
59
|
+
byNumber.set(block.number, block);
|
|
60
|
+
}
|
|
61
|
+
this.active = { byNumber, toTips };
|
|
62
|
+
this.log.trace(`Armed hot-block fast path`, { blocks: byNumber.size, toTips });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Disarms the fast path so subsequent reads delegate to the source again. */
|
|
66
|
+
public deactivate(): void {
|
|
67
|
+
this.active = undefined;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public getL2Tips(): Promise<L2Tips> {
|
|
71
|
+
return this.active ? Promise.resolve(this.active.toTips) : this.source.getL2Tips();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public getBlocks(query: BlocksQuery): Promise<L2Block[]> {
|
|
75
|
+
const served = this.active ? this.tryServeBlocksFromCache(query) : undefined;
|
|
76
|
+
return served ? Promise.resolve(served) : this.source.getBlocks(query);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public getBlockData(query: BlockQuery): Promise<BlockData | undefined> {
|
|
80
|
+
if (this.active && 'number' in query) {
|
|
81
|
+
const block = this.active.byNumber.get(query.number);
|
|
82
|
+
if (block) {
|
|
83
|
+
return l2BlockToBlockData(block);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return this.source.getBlockData(query);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Serves a block range from the cache only when it is fully covered by contiguous cached blocks. */
|
|
90
|
+
private tryServeBlocksFromCache(query: BlocksQuery): L2Block[] | undefined {
|
|
91
|
+
// Only the by-range form is cacheable, and only for the full (not checkpointed-only) chain: the cache may hold
|
|
92
|
+
// uncheckpointed blocks that an onlyCheckpointed query must not receive.
|
|
93
|
+
if (!this.active || !('from' in query) || query.onlyCheckpointed) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
const from = query.from;
|
|
97
|
+
const to = from + query.limit - 1;
|
|
98
|
+
const blocks: L2Block[] = [];
|
|
99
|
+
for (let n = from; n <= to; n++) {
|
|
100
|
+
const block = this.active.byNumber.get(n);
|
|
101
|
+
if (!block) {
|
|
102
|
+
// A gap inside the requested range: bail out and let the source serve the whole range.
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
blocks.push(block);
|
|
106
|
+
}
|
|
107
|
+
return blocks;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Event-driven wrapper around {@link L2BlockStream}. Subscribes to the source's aggregate `l2BlockSourceUpdated`
|
|
113
|
+
* event (when the source exposes one) to trigger an immediate reconciliation, while keeping the periodic poll as
|
|
114
|
+
* the correctness fallback. Subsystems keep consuming the same {@link L2BlockStreamEvent}s; the archiver aggregate
|
|
115
|
+
* event is handled entirely here.
|
|
116
|
+
*
|
|
117
|
+
* The event is passed through to the sync pass via {@link RunningPromise.trigger}. If, at the time the pass runs,
|
|
118
|
+
* the stream's local tips match the event's `fromTips` (it is caught up to where the event began), the event's
|
|
119
|
+
* hydrated blocks are served back through a hot-block cache and the event's `toTips` is reported as the source tips
|
|
120
|
+
* — so the triggered sync re-reads neither block bodies nor tips from the archiver. Otherwise the pass delegates
|
|
121
|
+
* entirely to the source, and the periodic poll guarantees eventual catch-up.
|
|
122
|
+
*/
|
|
123
|
+
export class EventDrivenL2BlockStream {
|
|
124
|
+
private readonly adapter: HotBlockSourceAdapter;
|
|
125
|
+
private readonly blockStream: L2BlockStream;
|
|
126
|
+
private readonly runningPromise: RunningPromise<L2BlockSourceUpdatedEvent>;
|
|
127
|
+
private readonly emitter: ArchiverEmitter | undefined;
|
|
128
|
+
private started = false;
|
|
129
|
+
|
|
130
|
+
private readonly onSourceUpdated = (event: L2BlockSourceUpdatedEvent) => {
|
|
131
|
+
// Fire-and-forget: trigger coalesces with any in-flight or periodic pass (see RunningPromise.trigger), so a
|
|
132
|
+
// burst of events does not run passes concurrently. Errors are swallowed by the inner stream's own handler.
|
|
133
|
+
void this.runningPromise
|
|
134
|
+
.trigger(event)
|
|
135
|
+
.catch(err => this.log.error(`Error in event-triggered block stream sync`, err));
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
constructor(
|
|
139
|
+
source: L2BlockSource | L2BlockSourceEventEmitter,
|
|
140
|
+
private readonly localData: L2BlockStreamLocalDataProvider,
|
|
141
|
+
handler: L2BlockStreamEventHandler,
|
|
142
|
+
private readonly log = createLogger('types:event_driven_block_stream'),
|
|
143
|
+
opts: L2BlockStreamOptions = {},
|
|
144
|
+
) {
|
|
145
|
+
this.adapter = new HotBlockSourceAdapter(source, log);
|
|
146
|
+
// The inner stream's own RunningPromise is never started; this wrapper owns the polling loop and drives the
|
|
147
|
+
// stream through `sync()` (which runs `work()` directly when the inner loop is stopped).
|
|
148
|
+
this.blockStream = new L2BlockStream(this.adapter, localData, handler, log, opts);
|
|
149
|
+
this.runningPromise = new RunningPromise<L2BlockSourceUpdatedEvent>(
|
|
150
|
+
this.runPass.bind(this),
|
|
151
|
+
log,
|
|
152
|
+
opts.pollIntervalMS ?? 1000,
|
|
153
|
+
);
|
|
154
|
+
this.emitter = getEmitter(source);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public start(): void {
|
|
158
|
+
if (this.started) {
|
|
159
|
+
this.log.warn(`Attempted to start an already-started event-driven block stream`);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this.started = true;
|
|
163
|
+
this.emitter?.on(L2BlockSourceEvents.L2BlockSourceUpdated, this.onSourceUpdated);
|
|
164
|
+
this.runningPromise.start();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public async stop(): Promise<void> {
|
|
168
|
+
this.started = false;
|
|
169
|
+
this.emitter?.off(L2BlockSourceEvents.L2BlockSourceUpdated, this.onSourceUpdated);
|
|
170
|
+
await this.runningPromise.stop();
|
|
171
|
+
await this.blockStream.stop();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public isRunning(): boolean {
|
|
175
|
+
return this.runningPromise.isRunning();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Runs a synchronization pass now, bypassing the poll interval, and resolves once that pass completes. Concurrent
|
|
180
|
+
* callers and periodic ticks coalesce onto a single pass; a caller that coalesces onto an already in-flight pass
|
|
181
|
+
* can resolve against a pass that began just before it, so this guarantees freshness only up to that coalescing
|
|
182
|
+
* window. The periodic poll and per-pass reorg handling make the gap a latency effect, never a correctness one.
|
|
183
|
+
*/
|
|
184
|
+
public sync(): Promise<void> {
|
|
185
|
+
return this.runningPromise.trigger();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Runs a single pass over the underlying block stream. When triggered by an aggregate event and the stream is
|
|
190
|
+
* caught up to the event's pre-pass tips, the event's blocks and tips serve the pass directly; the fast path is
|
|
191
|
+
* always disarmed afterwards so a subsequent poll-driven pass reads from the source.
|
|
192
|
+
*/
|
|
193
|
+
private async runPass(event?: L2BlockSourceUpdatedEvent): Promise<void> {
|
|
194
|
+
if (event) {
|
|
195
|
+
const localTips = await this.localData.getL2Tips();
|
|
196
|
+
if (localTipsMatch(localTips, event.fromTips)) {
|
|
197
|
+
this.adapter.activate(event.blocksAdded, event.toTips);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
await this.blockStream.sync();
|
|
203
|
+
} finally {
|
|
204
|
+
this.adapter.deactivate();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|