@aztec/stdlib 3.0.3-rc.3 → 4.0.0-devnet.1-patch.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/abi/abi.d.ts +602 -4
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +7 -7
- package/dest/abi/contract_artifact.d.ts +2 -2
- package/dest/abi/contract_artifact.d.ts.map +1 -1
- package/dest/abi/contract_artifact.js +1 -1
- package/dest/abi/function_call.d.ts +47 -9
- package/dest/abi/function_call.d.ts.map +1 -1
- package/dest/abi/function_call.js +20 -3
- package/dest/abi/function_selector.d.ts +2 -1
- package/dest/abi/function_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.js +7 -0
- package/dest/abi/selector.js +3 -1
- package/dest/abi/utils.d.ts +7 -1
- package/dest/abi/utils.d.ts.map +1 -1
- package/dest/abi/utils.js +7 -0
- package/dest/auth_witness/auth_witness.d.ts +2 -1
- package/dest/auth_witness/auth_witness.d.ts.map +1 -1
- package/dest/avm/avm.d.ts +62 -62
- package/dest/avm/avm.js +1 -1
- package/dest/avm/avm_accumulated_data.d.ts +30 -3
- package/dest/avm/avm_accumulated_data.d.ts.map +1 -1
- package/dest/avm/avm_accumulated_data.js +5 -2
- package/dest/avm/avm_circuit_public_inputs.d.ts +9 -9
- package/dest/avm/avm_circuit_public_inputs.js +3 -1
- package/dest/avm/avm_proving_request.d.ts +299 -299
- package/dest/avm/contract_storage_read.d.ts +13 -1
- package/dest/avm/contract_storage_read.d.ts.map +1 -1
- package/dest/avm/contract_storage_update_request.d.ts +13 -1
- package/dest/avm/contract_storage_update_request.d.ts.map +1 -1
- package/dest/avm/public_call_stack_item_compressed.d.ts +3 -1
- package/dest/avm/public_call_stack_item_compressed.d.ts.map +1 -1
- package/dest/avm/public_data_read.d.ts +10 -1
- package/dest/avm/public_data_read.d.ts.map +1 -1
- package/dest/avm/public_data_update_request.d.ts +10 -1
- package/dest/avm/public_data_update_request.d.ts.map +1 -1
- package/dest/avm/public_data_update_request.js +3 -1
- package/dest/avm/public_data_write.d.ts +7 -1
- package/dest/avm/public_data_write.d.ts.map +1 -1
- package/dest/avm/public_inner_call_request.d.ts +4 -1
- package/dest/avm/public_inner_call_request.d.ts.map +1 -1
- package/dest/avm/public_inner_call_request.js +3 -1
- package/dest/avm/revert_code.d.ts +4 -4
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +3 -1
- package/dest/aztec-address/index.js +4 -2
- package/dest/block/attestation_info.d.ts +5 -5
- package/dest/block/attestation_info.d.ts.map +1 -1
- package/dest/block/attestation_info.js +4 -4
- package/dest/block/block_hash.d.ts +18 -14
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +22 -20
- package/dest/block/block_parameter.d.ts +4 -3
- package/dest/block/block_parameter.d.ts.map +1 -1
- package/dest/block/block_parameter.js +2 -0
- package/dest/block/body.d.ts +1 -1
- package/dest/block/body.d.ts.map +1 -1
- package/dest/block/body.js +5 -2
- package/dest/block/checkpointed_l2_block.d.ts +150 -0
- package/dest/block/checkpointed_l2_block.d.ts.map +1 -0
- package/dest/block/checkpointed_l2_block.js +46 -0
- package/dest/block/in_block.d.ts +9 -9
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/in_block.js +5 -5
- package/dest/block/index.d.ts +2 -4
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -3
- package/dest/block/l2_block.d.ts +57 -57
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +64 -108
- package/dest/block/l2_block_source.d.ts +344 -90
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +25 -6
- 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 +15 -5
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +13 -3
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +115 -32
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +24 -16
- 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 +55 -61
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +49 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.js +179 -0
- 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 +478 -41
- package/dest/block/validate_block_result.d.ts +24 -24
- package/dest/block/validate_block_result.d.ts.map +1 -1
- package/dest/block/validate_block_result.js +18 -17
- package/dest/checkpoint/checkpoint.d.ts +45 -20
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +59 -8
- package/dest/checkpoint/checkpoint_info.d.ts +38 -0
- package/dest/checkpoint/checkpoint_info.d.ts.map +1 -0
- package/dest/checkpoint/checkpoint_info.js +34 -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/published_checkpoint.d.ts +30 -22
- package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/published_checkpoint.js +14 -3
- 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/node-rpc-config.js +1 -1
- package/dest/config/sequencer-config.d.ts +10 -0
- package/dest/config/sequencer-config.d.ts.map +1 -0
- package/dest/config/sequencer-config.js +12 -0
- package/dest/contract/complete_address.d.ts +4 -1
- package/dest/contract/complete_address.d.ts.map +1 -1
- package/dest/contract/contract_address.js +1 -1
- package/dest/contract/contract_class_id.d.ts +1 -1
- package/dest/contract/contract_class_id.js +2 -2
- package/dest/contract/contract_deployment_data.d.ts +5 -5
- 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 +11 -13
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +18 -18
- package/dest/contract/interfaces/contract_instance.d.ts +28 -29
- package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.js +5 -5
- package/dest/contract/interfaces/contract_instance_update.d.ts +6 -7
- package/dest/contract/interfaces/contract_instance_update.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance_update.js +5 -5
- package/dest/contract/private_function.d.ts +1 -1
- package/dest/contract/private_function.d.ts.map +1 -1
- package/dest/contract/private_function.js +2 -3
- package/dest/contract/private_function_membership_proof.d.ts +1 -1
- package/dest/contract/private_function_membership_proof.js +1 -1
- package/dest/database-version/database_version.d.ts +58 -0
- package/dest/database-version/database_version.d.ts.map +1 -0
- package/dest/database-version/database_version.js +69 -0
- package/dest/database-version/version_manager.d.ts +3 -49
- package/dest/database-version/version_manager.d.ts.map +1 -1
- package/dest/database-version/version_manager.js +1 -64
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts +2 -2
- package/dest/delayed_public_mutable/delayed_public_mutable_values.d.ts.map +1 -1
- package/dest/delayed_public_mutable/delayed_public_mutable_values.js +7 -10
- package/dest/deserialization/index.d.ts +11 -0
- package/dest/deserialization/index.d.ts.map +1 -0
- package/dest/deserialization/index.js +10 -0
- package/dest/epoch-helpers/index.d.ts +7 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +12 -6
- package/dest/errors/proving_error.d.ts +2 -2
- package/dest/errors/proving_error.d.ts.map +1 -1
- package/dest/gas/gas.js +3 -1
- package/dest/gas/gas_fees.js +3 -1
- package/dest/hash/hash.d.ts +1 -9
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +2 -14
- package/dest/hash/map_slot.d.ts +1 -1
- package/dest/hash/map_slot.d.ts.map +1 -1
- package/dest/hash/map_slot.js +4 -3
- package/dest/interfaces/allowed_element.d.ts +7 -8
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +3 -3
- package/dest/interfaces/api_limit.d.ts +3 -1
- package/dest/interfaces/api_limit.d.ts.map +1 -1
- package/dest/interfaces/api_limit.js +2 -0
- package/dest/interfaces/archiver.d.ts +6 -6
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +25 -15
- package/dest/interfaces/aztec-node-admin.d.ts +110 -41
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +6 -4
- package/dest/interfaces/aztec-node.d.ts +77 -79
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +16 -17
- package/dest/interfaces/block-builder.d.ts +22 -13
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +16 -1
- package/dest/interfaces/configs.d.ts +56 -27
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +12 -6
- package/dest/interfaces/get_logs_response.d.ts +27 -5
- package/dest/interfaces/get_logs_response.d.ts.map +1 -1
- package/dest/interfaces/get_logs_response.js +5 -4
- package/dest/interfaces/l2_logs_source.d.ts +21 -8
- package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
- package/dest/interfaces/merkle_tree_operations.d.ts +2 -2
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/p2p.d.ts +7 -9
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +3 -4
- package/dest/interfaces/prover-broker.d.ts +16 -1
- package/dest/interfaces/prover-broker.d.ts.map +1 -1
- package/dest/interfaces/prover-broker.js +4 -1
- package/dest/interfaces/prover-client.d.ts +19 -3
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +16 -4
- package/dest/interfaces/proving-job.d.ts +218 -218
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/proving-job.js +1 -7
- package/dest/interfaces/server_circuit_prover.d.ts +4 -3
- package/dest/interfaces/server_circuit_prover.d.ts.map +1 -1
- package/dest/interfaces/slasher.d.ts +9 -1
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +5 -3
- package/dest/interfaces/tx_provider.d.ts +3 -3
- package/dest/interfaces/tx_provider.d.ts.map +1 -1
- package/dest/interfaces/validator.d.ts +161 -26
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +12 -7
- package/dest/interfaces/world_state.d.ts +17 -8
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/claimed_length_array.js +3 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -5
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +19 -10
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +3 -3
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +16 -8
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts.map +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +1 -3
- package/dest/kernel/hints/key_validation_hint.d.ts +2 -1
- package/dest/kernel/hints/key_validation_hint.d.ts.map +1 -1
- package/dest/kernel/hints/key_validation_request.d.ts +2 -1
- package/dest/kernel/hints/key_validation_request.d.ts.map +1 -1
- package/dest/kernel/hints/key_validation_request_and_generator.d.ts +6 -1
- package/dest/kernel/hints/key_validation_request_and_generator.d.ts.map +1 -1
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts +13 -1
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
- package/dest/kernel/hints/read_request.d.ts +7 -1
- package/dest/kernel/hints/read_request.d.ts.map +1 -1
- package/dest/kernel/hints/read_request_hints.d.ts +7 -1
- package/dest/kernel/hints/read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/transient_data_squashing_hint.js +3 -1
- package/dest/kernel/log_hash.js +3 -1
- package/dest/kernel/private_accumulated_data.d.ts +23 -1
- package/dest/kernel/private_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_call_data.d.ts +25 -1
- package/dest/kernel/private_call_data.d.ts.map +1 -1
- package/dest/kernel/private_call_request.d.ts +16 -1
- package/dest/kernel/private_call_request.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.d.ts +120 -47
- package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_circuit_public_inputs.js +59 -59
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts +31 -1
- package/dest/kernel/private_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_data.d.ts +7 -1
- package/dest/kernel/private_kernel_data.d.ts.map +1 -1
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts +22 -1
- package/dest/kernel/private_kernel_init_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_inner_circuit_private_inputs.d.ts +7 -1
- package/dest/kernel/private_kernel_inner_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_reset_circuit_private_inputs.d.ts +4 -1
- package/dest/kernel/private_kernel_reset_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts +10 -1
- package/dest/kernel/private_kernel_tail_circuit_private_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +23 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_log_data.js +5 -2
- package/dest/kernel/private_to_avm_accumulated_data.d.ts +2 -2
- package/dest/kernel/private_to_avm_accumulated_data.js +5 -2
- package/dest/kernel/private_to_public_accumulated_data.js +3 -1
- package/dest/kernel/private_to_rollup_accumulated_data.d.ts +17 -1
- package/dest/kernel/private_to_rollup_accumulated_data.d.ts.map +1 -1
- package/dest/kernel/private_to_rollup_accumulated_data.js +3 -1
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts +16 -1
- package/dest/kernel/private_to_rollup_kernel_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_validation_requests.d.ts +10 -1
- package/dest/kernel/private_validation_requests.d.ts.map +1 -1
- package/dest/kernel/private_validation_requests.js +3 -1
- package/dest/kernel/public_call_request.d.ts +22 -1
- package/dest/kernel/public_call_request.d.ts.map +1 -1
- package/dest/kernel/public_call_request.js +5 -2
- package/dest/kernel/utils/optional_number.d.ts +7 -1
- package/dest/kernel/utils/optional_number.d.ts.map +1 -1
- package/dest/keys/derivation.d.ts +3 -3
- package/dest/keys/derivation.js +8 -8
- package/dest/keys/key_types.d.ts +1 -1
- package/dest/keys/public_keys.d.ts +5 -1
- package/dest/keys/public_keys.d.ts.map +1 -1
- package/dest/keys/utils.d.ts +1 -1
- package/dest/keys/utils.d.ts.map +1 -1
- package/dest/keys/utils.js +7 -3
- package/dest/l1-contracts/slash_factory.d.ts +1 -1
- package/dest/l1-contracts/slash_factory.d.ts.map +1 -1
- package/dest/l1-contracts/slash_factory.js +1 -0
- package/dest/logs/contract_class_log.js +3 -1
- package/dest/logs/extended_contract_class_log.d.ts +3 -1
- package/dest/logs/extended_contract_class_log.d.ts.map +1 -1
- package/dest/logs/extended_public_log.d.ts +17 -3
- package/dest/logs/extended_public_log.d.ts.map +1 -1
- package/dest/logs/index.d.ts +3 -2
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +2 -1
- package/dest/logs/log_id.d.ts +22 -7
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +23 -13
- package/dest/logs/private_log.d.ts +1 -1
- package/dest/logs/private_log.d.ts.map +1 -1
- package/dest/logs/private_log.js +5 -2
- package/dest/logs/public_log.js +3 -1
- package/dest/logs/siloed_tag.d.ts +23 -0
- package/dest/logs/siloed_tag.d.ts.map +1 -0
- package/dest/logs/siloed_tag.js +31 -0
- package/dest/logs/tag.d.ts +21 -0
- package/dest/logs/tag.d.ts.map +1 -0
- package/dest/logs/tag.js +30 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +24 -33
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +37 -43
- package/dest/messaging/in_hash.d.ts +4 -2
- package/dest/messaging/in_hash.d.ts.map +1 -1
- package/dest/messaging/in_hash.js +3 -1
- package/dest/messaging/inbox_leaf.d.ts +3 -1
- package/dest/messaging/inbox_leaf.d.ts.map +1 -1
- package/dest/messaging/l1_actor.d.ts +7 -1
- package/dest/messaging/l1_actor.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.d.ts +6 -1
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l2_actor.d.ts +7 -1
- package/dest/messaging/l2_actor.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts +88 -6
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +160 -42
- package/dest/messaging/out_hash.d.ts +41 -3
- package/dest/messaging/out_hash.d.ts.map +1 -1
- package/dest/messaging/out_hash.js +54 -19
- package/dest/note/note_dao.d.ts +36 -5
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +15 -12
- package/dest/p2p/attestation_utils.d.ts +3 -3
- package/dest/p2p/attestation_utils.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.js +1 -1
- package/dest/p2p/block_proposal.d.ts +102 -23
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +140 -39
- package/dest/p2p/checkpoint_attestation.d.ts +81 -0
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -0
- package/dest/p2p/{block_attestation.js → checkpoint_attestation.js} +22 -19
- package/dest/p2p/checkpoint_proposal.d.ts +174 -0
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -0
- package/dest/p2p/checkpoint_proposal.js +238 -0
- package/dest/p2p/consensus_payload.d.ts +9 -9
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +3 -5
- package/dest/p2p/constants.d.ts +5 -0
- package/dest/p2p/constants.d.ts.map +1 -0
- package/dest/p2p/constants.js +3 -0
- package/dest/p2p/gossipable.d.ts +4 -3
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/p2p/gossipable.js +16 -5
- package/dest/p2p/index.d.ts +5 -2
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +4 -1
- package/dest/p2p/message_validator.d.ts +18 -3
- package/dest/p2p/message_validator.d.ts.map +1 -1
- package/dest/p2p/message_validator.js +2 -1
- package/dest/p2p/signature_utils.d.ts +5 -3
- package/dest/p2p/signature_utils.d.ts.map +1 -1
- package/dest/p2p/signature_utils.js +3 -1
- package/dest/p2p/signed_txs.d.ts +42 -0
- package/dest/p2p/signed_txs.d.ts.map +1 -0
- package/dest/p2p/signed_txs.js +75 -0
- package/dest/p2p/topic_type.d.ts +3 -2
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +10 -3
- package/dest/parity/parity_base_private_inputs.d.ts +3 -1
- package/dest/parity/parity_base_private_inputs.d.ts.map +1 -1
- package/dest/parity/parity_public_inputs.d.ts +4 -1
- package/dest/parity/parity_public_inputs.d.ts.map +1 -1
- package/dest/parity/parity_root_private_inputs.d.ts +2 -1
- package/dest/parity/parity_root_private_inputs.d.ts.map +1 -1
- package/dest/proofs/chonk_proof.d.ts +1 -1
- package/dest/proofs/chonk_proof.d.ts.map +1 -1
- package/dest/proofs/chonk_proof.js +9 -4
- package/dest/proofs/proof.d.ts +4 -1
- package/dest/proofs/proof.d.ts.map +1 -1
- package/dest/proofs/recursive_proof.d.ts +10 -1
- package/dest/proofs/recursive_proof.d.ts.map +1 -1
- package/dest/rollup/avm_proof_data.d.ts +1 -3
- package/dest/rollup/avm_proof_data.d.ts.map +1 -1
- package/dest/rollup/avm_proof_data.js +1 -9
- package/dest/rollup/base_rollup_hints.d.ts +34 -1
- package/dest/rollup/base_rollup_hints.d.ts.map +1 -1
- package/dest/rollup/block_constant_data.d.ts +12 -1
- package/dest/rollup/block_constant_data.d.ts.map +1 -1
- package/dest/rollup/block_headers_hash.js +1 -1
- package/dest/rollup/block_merge_rollup_private_inputs.d.ts +4 -1
- package/dest/rollup/block_merge_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/block_rollup_public_inputs.d.ts +47 -11
- package/dest/rollup/block_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/block_rollup_public_inputs.js +8 -12
- package/dest/rollup/block_root_rollup_private_inputs.d.ts +64 -1
- package/dest/rollup/block_root_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_constant_data.d.ts +11 -1
- package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
- package/dest/rollup/checkpoint_constant_data.js +4 -1
- package/dest/rollup/checkpoint_header.d.ts +46 -12
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +53 -20
- package/dest/rollup/checkpoint_merge_rollup_private_inputs.d.ts +4 -1
- package/dest/rollup/checkpoint_merge_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +46 -6
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_rollup_public_inputs.js +11 -3
- package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +44 -3
- package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_root_rollup_private_inputs.js +13 -2
- package/dest/rollup/epoch_constant_data.d.ts +16 -1
- package/dest/rollup/epoch_constant_data.d.ts.map +1 -1
- package/dest/rollup/root_rollup_private_inputs.d.ts +6 -1
- package/dest/rollup/root_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/root_rollup_public_inputs.d.ts +21 -6
- package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/root_rollup_public_inputs.js +10 -4
- package/dest/rollup/tree_snapshot_diff_hints.d.ts +24 -1
- package/dest/rollup/tree_snapshot_diff_hints.d.ts.map +1 -1
- package/dest/rollup/tx_merge_rollup_private_inputs.d.ts +4 -1
- package/dest/rollup/tx_merge_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/tx_rollup_public_inputs.d.ts +29 -1
- package/dest/rollup/tx_rollup_public_inputs.d.ts.map +1 -1
- package/dest/schemas/schemas.d.ts +5 -3
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +2 -1
- package/dest/slashing/empire.d.ts +1 -1
- package/dest/slashing/empire.d.ts.map +1 -1
- package/dest/slashing/empire.js +2 -0
- package/dest/slashing/helpers.d.ts +2 -2
- package/dest/slashing/helpers.d.ts.map +1 -1
- package/dest/slashing/helpers.js +6 -0
- package/dest/slashing/tally.d.ts +2 -1
- package/dest/slashing/tally.d.ts.map +1 -1
- package/dest/slashing/tally.js +6 -2
- package/dest/slashing/types.d.ts +10 -7
- package/dest/slashing/types.d.ts.map +1 -1
- package/dest/slashing/types.js +18 -6
- package/dest/snapshots/types.d.ts +1 -1
- package/dest/snapshots/types.d.ts.map +1 -1
- package/dest/snapshots/types.js +5 -5
- package/dest/stats/stats.d.ts +10 -8
- package/dest/stats/stats.d.ts.map +1 -1
- package/dest/tests/factories.d.ts +39 -10
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +81 -26
- package/dest/tests/jest.js +1 -1
- package/dest/tests/mocks.d.ts +76 -20
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +139 -60
- package/dest/timetable/index.d.ts +37 -0
- package/dest/timetable/index.d.ts.map +1 -0
- package/dest/timetable/index.js +39 -0
- package/dest/trees/append_only_tree_snapshot.d.ts +13 -1
- package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
- package/dest/trees/append_only_tree_snapshot.js +3 -1
- package/dest/trees/nullifier_leaf.d.ts +13 -1
- package/dest/trees/nullifier_leaf.d.ts.map +1 -1
- package/dest/trees/nullifier_membership_witness.d.ts +10 -1
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/public_data_leaf.d.ts +16 -1
- package/dest/trees/public_data_leaf.d.ts.map +1 -1
- package/dest/trees/public_data_witness.d.ts +11 -1
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/tx/block_header.d.ts +21 -8
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +12 -2
- package/dest/tx/call_context.d.ts +13 -1
- package/dest/tx/call_context.d.ts.map +1 -1
- package/dest/tx/call_context.js +3 -1
- package/dest/tx/capsule.d.ts +4 -1
- package/dest/tx/capsule.d.ts.map +1 -1
- package/dest/tx/execution_payload.d.ts +9 -1
- package/dest/tx/execution_payload.d.ts.map +1 -1
- package/dest/tx/function_data.d.ts +4 -2
- package/dest/tx/function_data.d.ts.map +1 -1
- package/dest/tx/global_variable_builder.d.ts +5 -3
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/global_variables.d.ts +14 -1
- package/dest/tx/global_variables.d.ts.map +1 -1
- package/dest/tx/global_variables.js +3 -1
- package/dest/tx/hashed_values.d.ts +7 -1
- package/dest/tx/hashed_values.d.ts.map +1 -1
- package/dest/tx/in_tx.d.ts +4 -4
- 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/indexed_tx_effect.d.ts +5 -5
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +3 -2
- package/dest/tx/partial_state_reference.d.ts +4 -1
- package/dest/tx/partial_state_reference.d.ts.map +1 -1
- package/dest/tx/private_execution_result.d.ts +24 -7
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +4 -21
- package/dest/tx/private_tx_constant_data.d.ts +16 -1
- package/dest/tx/private_tx_constant_data.d.ts.map +1 -1
- package/dest/tx/profiling.d.ts +149 -26
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +44 -7
- package/dest/tx/protocol_contracts.d.ts +1 -1
- package/dest/tx/public_call_request_with_calldata.d.ts +7 -1
- package/dest/tx/public_call_request_with_calldata.d.ts.map +1 -1
- package/dest/tx/public_call_request_with_calldata.js +3 -1
- package/dest/tx/simulated_tx.d.ts +1031 -7
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/state_reference.d.ts +3 -1
- package/dest/tx/state_reference.d.ts.map +1 -1
- package/dest/tx/state_reference.js +3 -1
- package/dest/tx/tree_snapshots.js +3 -1
- package/dest/tx/tx.d.ts +33 -3
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +18 -6
- package/dest/tx/tx_context.d.ts +2 -1
- package/dest/tx/tx_context.d.ts.map +1 -1
- package/dest/tx/tx_effect.d.ts +32 -6
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +6 -9
- package/dest/tx/tx_execution_request.d.ts +30 -1
- package/dest/tx/tx_execution_request.d.ts.map +1 -1
- package/dest/tx/tx_execution_request.js +6 -2
- package/dest/tx/tx_hash.d.ts +2 -1
- package/dest/tx/tx_hash.d.ts.map +1 -1
- package/dest/tx/tx_receipt.d.ts +47 -13
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +46 -15
- package/dest/tx/tx_request.d.ts +6 -1
- package/dest/tx/tx_request.d.ts.map +1 -1
- package/dest/tx/validator/empty_validator.d.ts +2 -2
- package/dest/tx/validator/empty_validator.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.d.ts +2 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +2 -0
- package/dest/tx/validator/tx_validator.d.ts +2 -5
- package/dest/tx/validator/tx_validator.d.ts.map +1 -1
- package/dest/tx/validator/tx_validator.js +4 -4
- package/dest/types/shared.d.ts +4 -1
- package/dest/types/shared.d.ts.map +1 -1
- package/dest/validators/schemas.d.ts +9 -9
- package/dest/validators/schemas.d.ts.map +1 -1
- package/dest/validators/schemas.js +13 -13
- package/dest/vks/verification_key.d.ts +22 -1
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/vk_data.d.ts +7 -1
- package/dest/vks/vk_data.d.ts.map +1 -1
- package/dest/zkpassport/index.d.ts +3 -4
- package/dest/zkpassport/index.d.ts.map +1 -1
- package/dest/zkpassport/index.js +9 -9
- package/package.json +27 -13
- package/src/abi/abi.ts +39 -33
- package/src/abi/contract_artifact.ts +10 -10
- package/src/abi/function_call.ts +25 -3
- package/src/abi/function_selector.ts +8 -0
- package/src/abi/utils.ts +17 -0
- package/src/avm/avm.ts +1 -1
- package/src/block/attestation_info.ts +9 -6
- package/src/block/block_hash.ts +26 -25
- package/src/block/block_parameter.ts +4 -2
- package/src/block/body.ts +2 -1
- package/src/block/checkpointed_l2_block.ts +70 -0
- package/src/block/in_block.ts +6 -6
- package/src/block/index.ts +1 -3
- package/src/block/l2_block.ts +102 -149
- package/src/block/l2_block_source.ts +175 -68
- package/src/block/l2_block_stream/index.ts +1 -0
- package/src/block/l2_block_stream/interfaces.ts +15 -4
- package/src/block/l2_block_stream/l2_block_stream.ts +139 -39
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +62 -56
- package/src/block/l2_block_stream/l2_tips_store_base.ts +226 -0
- package/src/block/test/l2_tips_store_test_suite.ts +480 -35
- package/src/block/validate_block_result.ts +40 -35
- package/src/checkpoint/checkpoint.ts +82 -12
- package/src/checkpoint/checkpoint_info.ts +52 -0
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/published_checkpoint.ts +22 -7
- package/src/config/index.ts +1 -0
- package/src/config/node-rpc-config.ts +1 -1
- package/src/config/sequencer-config.ts +19 -0
- package/src/contract/contract_address.ts +1 -1
- package/src/contract/contract_class_id.ts +2 -2
- package/src/contract/index.ts +0 -2
- package/src/contract/interfaces/contract_class.ts +59 -46
- package/src/contract/interfaces/contract_instance.ts +15 -13
- package/src/contract/interfaces/contract_instance_update.ts +11 -9
- package/src/contract/private_function.ts +2 -3
- package/src/contract/private_function_membership_proof.ts +1 -1
- package/src/database-version/database_version.ts +87 -0
- package/src/database-version/version_manager.ts +1 -77
- package/src/delayed_public_mutable/delayed_public_mutable_values.ts +9 -10
- package/src/deserialization/index.ts +21 -0
- package/src/epoch-helpers/index.ts +24 -10
- package/src/hash/hash.ts +2 -13
- package/src/hash/map_slot.ts +3 -2
- package/src/interfaces/allowed_element.ts +9 -7
- package/src/interfaces/api_limit.ts +2 -0
- package/src/interfaces/archiver.ts +33 -23
- package/src/interfaces/aztec-node-admin.ts +10 -6
- package/src/interfaces/aztec-node.ts +118 -134
- package/src/interfaces/block-builder.ts +50 -23
- package/src/interfaces/configs.ts +67 -33
- package/src/interfaces/get_logs_response.ts +13 -9
- package/src/interfaces/l2_logs_source.ts +25 -7
- package/src/interfaces/merkle_tree_operations.ts +4 -1
- package/src/interfaces/p2p.ts +8 -12
- package/src/interfaces/prover-broker.ts +22 -0
- package/src/interfaces/prover-client.ts +35 -10
- package/src/interfaces/proving-job.ts +2 -11
- package/src/interfaces/server_circuit_prover.ts +3 -3
- package/src/interfaces/slasher.ts +28 -22
- package/src/interfaces/tx_provider.ts +2 -2
- package/src/interfaces/validator.ts +92 -31
- package/src/interfaces/world_state.ts +16 -9
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +20 -12
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +17 -14
- package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +2 -4
- package/src/kernel/private_circuit_public_inputs.ts +85 -85
- package/src/keys/derivation.ts +8 -8
- package/src/keys/key_types.ts +1 -1
- package/src/keys/utils.ts +7 -3
- package/src/l1-contracts/slash_factory.ts +1 -0
- package/src/logs/index.ts +2 -1
- package/src/logs/log_id.ts +26 -12
- package/src/logs/private_log.ts +2 -1
- package/src/logs/siloed_tag.ts +45 -0
- package/src/logs/tag.ts +42 -0
- package/src/logs/tx_scoped_l2_log.ts +45 -43
- package/src/messaging/in_hash.ts +3 -1
- package/src/messaging/l1_to_l2_message.ts +1 -0
- package/src/messaging/l2_to_l1_membership.ts +178 -52
- package/src/messaging/out_hash.ts +62 -21
- package/src/note/note_dao.ts +18 -13
- package/src/p2p/attestation_utils.ts +3 -3
- package/src/p2p/block_proposal.ts +213 -46
- package/src/p2p/{block_attestation.ts → checkpoint_attestation.ts} +31 -25
- package/src/p2p/checkpoint_proposal.ts +365 -0
- package/src/p2p/consensus_payload.ts +5 -7
- package/src/p2p/constants.ts +6 -0
- package/src/p2p/gossipable.ts +14 -4
- package/src/p2p/index.ts +4 -1
- package/src/p2p/message_validator.ts +14 -2
- package/src/p2p/signature_utils.ts +3 -1
- package/src/p2p/signed_txs.ts +88 -0
- package/src/p2p/topic_type.ts +4 -3
- package/src/proofs/chonk_proof.ts +9 -5
- package/src/rollup/avm_proof_data.ts +0 -7
- package/src/rollup/block_headers_hash.ts +1 -1
- package/src/rollup/block_rollup_public_inputs.ts +5 -11
- package/src/rollup/checkpoint_constant_data.ts +1 -0
- package/src/rollup/checkpoint_header.ts +67 -20
- package/src/rollup/checkpoint_rollup_public_inputs.ts +17 -5
- package/src/rollup/checkpoint_root_rollup_private_inputs.ts +14 -1
- package/src/rollup/root_rollup_public_inputs.ts +16 -7
- package/src/schemas/schemas.ts +4 -0
- package/src/slashing/empire.ts +3 -1
- package/src/slashing/helpers.ts +8 -0
- package/src/slashing/tally.ts +8 -2
- package/src/slashing/types.ts +38 -20
- package/src/snapshots/types.ts +33 -29
- package/src/stats/stats.ts +10 -7
- package/src/tests/factories.ts +103 -42
- package/src/tests/jest.ts +1 -1
- package/src/tests/mocks.ts +226 -92
- package/src/timetable/index.ts +66 -0
- package/src/tx/block_header.ts +21 -8
- package/src/tx/global_variable_builder.ts +9 -2
- package/src/tx/global_variables.ts +6 -0
- package/src/tx/index.ts +0 -1
- package/src/tx/indexed_tx_effect.ts +3 -2
- package/src/tx/private_execution_result.ts +2 -17
- package/src/tx/profiling.ts +46 -4
- package/src/tx/tx.ts +19 -11
- package/src/tx/tx_effect.ts +3 -10
- package/src/tx/tx_execution_request.ts +2 -0
- package/src/tx/tx_receipt.ts +75 -18
- package/src/tx/validator/empty_validator.ts +1 -1
- package/src/tx/validator/error_texts.ts +3 -0
- package/src/tx/validator/tx_validator.ts +9 -7
- package/src/validators/schemas.ts +54 -48
- package/src/zkpassport/index.ts +11 -12
- package/dest/block/l2_block_code_to_purge.d.ts +0 -12
- package/dest/block/l2_block_code_to_purge.d.ts.map +0 -1
- package/dest/block/l2_block_code_to_purge.js +0 -61
- package/dest/block/l2_block_header.d.ts +0 -98
- package/dest/block/l2_block_header.d.ts.map +0 -1
- package/dest/block/l2_block_header.js +0 -153
- package/dest/block/l2_block_new.d.ts +0 -130
- package/dest/block/l2_block_new.d.ts.map +0 -1
- package/dest/block/l2_block_new.js +0 -151
- package/dest/block/published_l2_block.d.ts +0 -130
- package/dest/block/published_l2_block.d.ts.map +0 -1
- package/dest/block/published_l2_block.js +0 -48
- package/dest/contract/contract_class_metadata.d.ts +0 -8
- package/dest/contract/contract_class_metadata.d.ts.map +0 -1
- package/dest/contract/contract_class_metadata.js +0 -1
- package/dest/contract/contract_metadata.d.ts +0 -7
- package/dest/contract/contract_metadata.d.ts.map +0 -1
- package/dest/contract/contract_metadata.js +0 -1
- package/dest/database-version/index.d.ts +0 -2
- package/dest/database-version/index.d.ts.map +0 -1
- package/dest/database-version/index.js +0 -1
- package/dest/logs/log_with_tx_data.d.ts +0 -19
- package/dest/logs/log_with_tx_data.d.ts.map +0 -1
- package/dest/logs/log_with_tx_data.js +0 -49
- package/dest/p2p/block_attestation.d.ts +0 -80
- package/dest/p2p/block_attestation.d.ts.map +0 -1
- package/dest/tx/content_commitment.d.ts +0 -49
- package/dest/tx/content_commitment.d.ts.map +0 -1
- package/dest/tx/content_commitment.js +0 -90
- package/src/block/l2_block_code_to_purge.ts +0 -88
- package/src/block/l2_block_header.ts +0 -246
- package/src/block/l2_block_new.ts +0 -197
- package/src/block/published_l2_block.ts +0 -65
- package/src/contract/contract_class_metadata.ts +0 -8
- package/src/contract/contract_metadata.ts +0 -7
- package/src/database-version/index.ts +0 -1
- package/src/logs/log_with_tx_data.ts +0 -46
- package/src/tx/content_commitment.ts +0 -113
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BlockNumber,
|
|
3
3
|
BlockNumberSchema,
|
|
4
|
-
|
|
4
|
+
CheckpointNumber,
|
|
5
|
+
CheckpointNumberSchema,
|
|
5
6
|
type EpochNumber,
|
|
6
7
|
type SlotNumber,
|
|
7
8
|
} from '@aztec/foundation/branded-types';
|
|
@@ -14,13 +15,15 @@ import { z } from 'zod';
|
|
|
14
15
|
import type { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
15
16
|
import type { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
|
|
16
17
|
import type { L1RollupConstants } from '../epoch-helpers/index.js';
|
|
18
|
+
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
17
19
|
import type { BlockHeader } from '../tx/block_header.js';
|
|
18
20
|
import type { IndexedTxEffect } from '../tx/indexed_tx_effect.js';
|
|
19
21
|
import type { TxHash } from '../tx/tx_hash.js';
|
|
20
22
|
import type { TxReceipt } from '../tx/tx_receipt.js';
|
|
23
|
+
import type { BlockHash } from './block_hash.js';
|
|
24
|
+
import type { CheckpointedL2Block } from './checkpointed_l2_block.js';
|
|
21
25
|
import type { L2Block } from './l2_block.js';
|
|
22
|
-
import {
|
|
23
|
-
import type { ValidateBlockNegativeResult, ValidateBlockResult } from './validate_block_result.js';
|
|
26
|
+
import type { ValidateCheckpointNegativeResult, ValidateCheckpointResult } from './validate_block_result.js';
|
|
24
27
|
|
|
25
28
|
/**
|
|
26
29
|
* Interface of classes allowing for the retrieval of L2 blocks.
|
|
@@ -51,11 +54,18 @@ export interface L2BlockSource {
|
|
|
51
54
|
getProvenBlockNumber(): Promise<BlockNumber>;
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
|
-
* Gets
|
|
55
|
-
* @
|
|
56
|
-
* @returns The requested L2 block.
|
|
57
|
+
* Gets the number of the latest L2 block checkpointed seen by the block source implementation.
|
|
58
|
+
* @returns The number of the latest L2 block checkpointed seen by the block source implementation.
|
|
57
59
|
*/
|
|
58
|
-
|
|
60
|
+
getCheckpointedL2BlockNumber(): Promise<BlockNumber>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Computes the finalized block number based on the proven block number.
|
|
64
|
+
* A block is considered finalized when it's 2 epochs behind the proven block.
|
|
65
|
+
* TODO(#13569): Compute proper finalized block number based on L1 finalized block.
|
|
66
|
+
* @returns The finalized block number.
|
|
67
|
+
*/
|
|
68
|
+
getFinalizedL2BlockNumber(): Promise<BlockNumber>;
|
|
59
69
|
|
|
60
70
|
/**
|
|
61
71
|
* Gets an l2 block header.
|
|
@@ -65,54 +75,63 @@ export interface L2BlockSource {
|
|
|
65
75
|
getBlockHeader(number: BlockNumber | 'latest'): Promise<BlockHeader | undefined>;
|
|
66
76
|
|
|
67
77
|
/**
|
|
68
|
-
* Gets
|
|
69
|
-
*
|
|
70
|
-
* @param
|
|
71
|
-
* @
|
|
72
|
-
* @returns The requested L2 blocks.
|
|
78
|
+
* Gets a checkpointed L2 block by block number.
|
|
79
|
+
* Returns undefined if the block doesn't exist or hasn't been checkpointed yet.
|
|
80
|
+
* @param number - The block number to retrieve.
|
|
81
|
+
* @returns The requested checkpointed L2 block (or undefined if not found or not checkpointed).
|
|
73
82
|
*/
|
|
74
|
-
|
|
83
|
+
getCheckpointedBlock(number: BlockNumber): Promise<CheckpointedL2Block | undefined>;
|
|
75
84
|
|
|
76
|
-
|
|
85
|
+
getCheckpointedBlocks(from: BlockNumber, limit: number): Promise<CheckpointedL2Block[]>;
|
|
77
86
|
|
|
78
87
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* @param
|
|
82
|
-
* @returns The
|
|
88
|
+
* Retrieves a collection of checkpoints.
|
|
89
|
+
* @param checkpointNumber The first checkpoint to be retrieved.
|
|
90
|
+
* @param limit The number of checkpoints to be retrieved.
|
|
91
|
+
* @returns The collection of complete checkpoints.
|
|
83
92
|
*/
|
|
84
|
-
|
|
93
|
+
getCheckpoints(checkpointNumber: CheckpointNumber, limit: number): Promise<PublishedCheckpoint[]>;
|
|
85
94
|
|
|
86
|
-
/**
|
|
87
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Gets the checkpoints for a given epoch
|
|
97
|
+
* @param epochNumber - Epoch for which we want checkpoint data
|
|
98
|
+
*/
|
|
99
|
+
getCheckpointsForEpoch(epochNumber: EpochNumber): Promise<Checkpoint[]>;
|
|
88
100
|
|
|
89
101
|
/**
|
|
90
|
-
* Gets a
|
|
102
|
+
* Gets a block header by its hash.
|
|
91
103
|
* @param blockHash - The block hash to retrieve.
|
|
92
|
-
* @returns The requested
|
|
104
|
+
* @returns The requested block header (or undefined if not found).
|
|
93
105
|
*/
|
|
94
|
-
|
|
106
|
+
getBlockHeaderByHash(blockHash: BlockHash): Promise<BlockHeader | undefined>;
|
|
95
107
|
|
|
96
108
|
/**
|
|
97
|
-
* Gets a
|
|
109
|
+
* Gets a block header by its archive root.
|
|
98
110
|
* @param archive - The archive root to retrieve.
|
|
99
|
-
* @returns The requested
|
|
111
|
+
* @returns The requested block header (or undefined if not found).
|
|
100
112
|
*/
|
|
101
|
-
|
|
113
|
+
getBlockHeaderByArchive(archive: Fr): Promise<BlockHeader | undefined>;
|
|
102
114
|
|
|
103
115
|
/**
|
|
104
|
-
* Gets
|
|
116
|
+
* Gets an L2 block by block number.
|
|
117
|
+
* @param number - The block number to return.
|
|
118
|
+
* @returns The requested L2 block (or undefined if not found).
|
|
119
|
+
*/
|
|
120
|
+
getL2Block(number: BlockNumber): Promise<L2Block | undefined>;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Gets an L2 block by its hash.
|
|
105
124
|
* @param blockHash - The block hash to retrieve.
|
|
106
|
-
* @returns The requested block
|
|
125
|
+
* @returns The requested L2 block (or undefined if not found).
|
|
107
126
|
*/
|
|
108
|
-
|
|
127
|
+
getL2BlockByHash(blockHash: BlockHash): Promise<L2Block | undefined>;
|
|
109
128
|
|
|
110
129
|
/**
|
|
111
|
-
* Gets
|
|
130
|
+
* Gets an L2 block by its archive root.
|
|
112
131
|
* @param archive - The archive root to retrieve.
|
|
113
|
-
* @returns The requested block
|
|
132
|
+
* @returns The requested L2 block (or undefined if not found).
|
|
114
133
|
*/
|
|
115
|
-
|
|
134
|
+
getL2BlockByArchive(archive: Fr): Promise<L2Block | undefined>;
|
|
116
135
|
|
|
117
136
|
/**
|
|
118
137
|
* Gets a tx effect.
|
|
@@ -139,25 +158,11 @@ export interface L2BlockSource {
|
|
|
139
158
|
getL2EpochNumber(): Promise<EpochNumber | undefined>;
|
|
140
159
|
|
|
141
160
|
/**
|
|
142
|
-
* Returns all
|
|
143
|
-
* @dev Use this method only with recent epochs, since it walks the checkpoint list backwards.
|
|
144
|
-
* @param epochNumber - The epoch number to return checkpoints for.
|
|
145
|
-
*/
|
|
146
|
-
getCheckpointsForEpoch(epochNumber: EpochNumber): Promise<Checkpoint[]>;
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Returns all blocks for a given epoch.
|
|
150
|
-
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
151
|
-
* @param epochNumber - The epoch number to return blocks for.
|
|
152
|
-
*/
|
|
153
|
-
getBlocksForEpoch(epochNumber: EpochNumber): Promise<L2Block[]>;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Returns all block headers for a given epoch.
|
|
161
|
+
* Returns all checkpointed block headers for a given epoch.
|
|
157
162
|
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
158
163
|
* @param epochNumber - The epoch number to return headers for.
|
|
159
164
|
*/
|
|
160
|
-
|
|
165
|
+
getCheckpointedBlockHeadersForEpoch(epochNumber: EpochNumber): Promise<BlockHeader[]>;
|
|
161
166
|
|
|
162
167
|
/**
|
|
163
168
|
* Returns whether the given epoch is completed on L1, based on the current L1 and L2 block numbers.
|
|
@@ -188,13 +193,70 @@ export interface L2BlockSource {
|
|
|
188
193
|
isPendingChainInvalid(): Promise<boolean>;
|
|
189
194
|
|
|
190
195
|
/**
|
|
191
|
-
* Returns the status of the pending chain validation. If the chain is invalid, reports the earliest consecutive
|
|
192
|
-
* that is invalid, along with the reason for being invalid, which can be used to trigger an invalidation.
|
|
196
|
+
* Returns the status of the pending chain validation. If the chain is invalid, reports the earliest consecutive
|
|
197
|
+
* checkpoint that is invalid, along with the reason for being invalid, which can be used to trigger an invalidation.
|
|
193
198
|
*/
|
|
194
|
-
getPendingChainValidationStatus(): Promise<
|
|
199
|
+
getPendingChainValidationStatus(): Promise<ValidateCheckpointResult>;
|
|
195
200
|
|
|
196
201
|
/** Force a sync. */
|
|
197
202
|
syncImmediate(): Promise<void>;
|
|
203
|
+
|
|
204
|
+
/* Legacy APIS */
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Gets an l2 block. If a negative number is passed, the block returned is the most recent.
|
|
208
|
+
* @param number - The block number to return (inclusive).
|
|
209
|
+
* @returns The requested L2 block.
|
|
210
|
+
*/
|
|
211
|
+
getBlock(number: BlockNumber): Promise<L2Block | undefined>;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Returns all checkpointed blocks for a given epoch.
|
|
215
|
+
* @dev Use this method only with recent epochs, since it walks the block list backwards.
|
|
216
|
+
* @param epochNumber - The epoch number to return blocks for.
|
|
217
|
+
*/
|
|
218
|
+
getCheckpointedBlocksForEpoch(epochNumber: EpochNumber): Promise<CheckpointedL2Block[]>;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Returns all blocks for a given slot.
|
|
222
|
+
* @dev Use this method only with recent slots, since it walks the block list backwards.
|
|
223
|
+
* @param slotNumber - The slot number to return blocks for.
|
|
224
|
+
*/
|
|
225
|
+
getBlocksForSlot(slotNumber: SlotNumber): Promise<L2Block[]>;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Gets a checkpointed block by its block hash.
|
|
229
|
+
* @param blockHash - The block hash to retrieve.
|
|
230
|
+
* @returns The requested block (or undefined if not found).
|
|
231
|
+
*/
|
|
232
|
+
getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined>;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Gets a checkpointed block by its archive root.
|
|
236
|
+
* @param archive - The archive root to retrieve.
|
|
237
|
+
* @returns The requested block (or undefined if not found).
|
|
238
|
+
*/
|
|
239
|
+
getCheckpointedBlockByArchive(archive: Fr): Promise<CheckpointedL2Block | undefined>;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
243
|
+
* @param from - Number of the first block to return (inclusive).
|
|
244
|
+
* @param limit - The maximum number of blocks to return.
|
|
245
|
+
* @returns The requested L2 blocks.
|
|
246
|
+
*/
|
|
247
|
+
getBlocks(from: BlockNumber, limit: number): Promise<L2Block[]>;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Interface for classes that can receive and store L2 blocks.
|
|
252
|
+
*/
|
|
253
|
+
export interface L2BlockSink {
|
|
254
|
+
/**
|
|
255
|
+
* Adds a block to the store.
|
|
256
|
+
* @param block - The L2 block to add.
|
|
257
|
+
* @throws If block number is not incremental (i.e., not exactly one more than the last stored block).
|
|
258
|
+
*/
|
|
259
|
+
addBlock(block: L2Block): Promise<void>;
|
|
198
260
|
}
|
|
199
261
|
|
|
200
262
|
/**
|
|
@@ -202,26 +264,42 @@ export interface L2BlockSource {
|
|
|
202
264
|
* see L2BlockSourceEvents for the events emitted.
|
|
203
265
|
*/
|
|
204
266
|
export type ArchiverEmitter = TypedEventEmitter<{
|
|
205
|
-
[L2BlockSourceEvents.
|
|
267
|
+
[L2BlockSourceEvents.L2PruneUnproven]: (args: L2PruneUnprovenEvent) => void;
|
|
268
|
+
[L2BlockSourceEvents.L2PruneUncheckpointed]: (args: L2PruneUncheckpointedEvent) => void;
|
|
206
269
|
[L2BlockSourceEvents.L2BlockProven]: (args: L2BlockProvenEvent) => void;
|
|
207
|
-
[L2BlockSourceEvents.
|
|
270
|
+
[L2BlockSourceEvents.InvalidAttestationsCheckpointDetected]: (args: InvalidCheckpointDetectedEvent) => void;
|
|
271
|
+
[L2BlockSourceEvents.L2BlocksCheckpointed]: (args: L2CheckpointEvent) => void;
|
|
208
272
|
}>;
|
|
209
|
-
export interface L2BlockSourceEventEmitter extends L2BlockSource
|
|
273
|
+
export interface L2BlockSourceEventEmitter extends L2BlockSource {
|
|
274
|
+
events: ArchiverEmitter;
|
|
275
|
+
}
|
|
210
276
|
|
|
211
277
|
/**
|
|
212
278
|
* Identifier for L2 block tags.
|
|
213
|
-
* -
|
|
279
|
+
* - proposed: Latest block proposed on L2.
|
|
280
|
+
* - checkpointed: Checkpointed block on L1.
|
|
214
281
|
* - proven: Proven block on L1.
|
|
215
282
|
* - finalized: Proven block on a finalized L1 block (not implemented, set to proven for now).
|
|
216
283
|
*/
|
|
217
|
-
export type L2BlockTag = '
|
|
284
|
+
export type L2BlockTag = 'proposed' | 'checkpointed' | 'proven' | 'finalized';
|
|
218
285
|
|
|
219
286
|
/** Tips of the L2 chain. */
|
|
220
|
-
export type L2Tips =
|
|
287
|
+
export type L2Tips = {
|
|
288
|
+
proposed: L2BlockId;
|
|
289
|
+
checkpointed: L2TipId;
|
|
290
|
+
proven: L2TipId;
|
|
291
|
+
finalized: L2TipId;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export const GENESIS_CHECKPOINT_HEADER_HASH = CheckpointHeader.empty().hash();
|
|
221
295
|
|
|
222
296
|
/** Identifies a block by number and hash. */
|
|
223
297
|
export type L2BlockId = { number: BlockNumber; hash: string };
|
|
224
298
|
|
|
299
|
+
export type CheckpointId = { number: CheckpointNumber; hash: string };
|
|
300
|
+
|
|
301
|
+
export type L2TipId = { block: L2BlockId; checkpoint: CheckpointId };
|
|
302
|
+
|
|
225
303
|
/** Creates an L2 block id */
|
|
226
304
|
export function makeL2BlockId(number: BlockNumber, hash?: string): L2BlockId {
|
|
227
305
|
if (number !== 0 && !hash) {
|
|
@@ -230,21 +308,39 @@ export function makeL2BlockId(number: BlockNumber, hash?: string): L2BlockId {
|
|
|
230
308
|
return { number, hash: hash! };
|
|
231
309
|
}
|
|
232
310
|
|
|
311
|
+
/** Creates an L2 checkpoint id */
|
|
312
|
+
export function makeL2CheckpointId(number: CheckpointNumber, hash: string): CheckpointId {
|
|
313
|
+
return { number, hash };
|
|
314
|
+
}
|
|
315
|
+
|
|
233
316
|
const L2BlockIdSchema = z.object({
|
|
234
317
|
number: BlockNumberSchema,
|
|
235
318
|
hash: z.string(),
|
|
236
319
|
});
|
|
237
320
|
|
|
321
|
+
const L2CheckpointIdSchema = z.object({
|
|
322
|
+
number: CheckpointNumberSchema,
|
|
323
|
+
hash: z.string(),
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const L2TipIdSchema = z.object({
|
|
327
|
+
block: L2BlockIdSchema,
|
|
328
|
+
checkpoint: L2CheckpointIdSchema,
|
|
329
|
+
});
|
|
330
|
+
|
|
238
331
|
export const L2TipsSchema = z.object({
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
332
|
+
proposed: L2BlockIdSchema,
|
|
333
|
+
checkpointed: L2TipIdSchema,
|
|
334
|
+
proven: L2TipIdSchema,
|
|
335
|
+
finalized: L2TipIdSchema,
|
|
242
336
|
});
|
|
243
337
|
|
|
244
338
|
export enum L2BlockSourceEvents {
|
|
245
|
-
|
|
339
|
+
L2PruneUnproven = 'l2PruneUnproven',
|
|
340
|
+
L2PruneUncheckpointed = 'l2PruneUncheckpointed',
|
|
246
341
|
L2BlockProven = 'l2BlockProven',
|
|
247
|
-
|
|
342
|
+
L2BlocksCheckpointed = 'l2BlocksCheckpointed',
|
|
343
|
+
InvalidAttestationsCheckpointDetected = 'invalidCheckpointDetected',
|
|
248
344
|
}
|
|
249
345
|
|
|
250
346
|
export type L2BlockProvenEvent = {
|
|
@@ -254,13 +350,24 @@ export type L2BlockProvenEvent = {
|
|
|
254
350
|
epochNumber: EpochNumber;
|
|
255
351
|
};
|
|
256
352
|
|
|
257
|
-
export type
|
|
258
|
-
type: '
|
|
353
|
+
export type L2PruneUnprovenEvent = {
|
|
354
|
+
type: 'l2PruneUnproven';
|
|
259
355
|
epochNumber: EpochNumber;
|
|
260
356
|
blocks: L2Block[];
|
|
261
357
|
};
|
|
262
358
|
|
|
263
|
-
export type
|
|
264
|
-
type: '
|
|
265
|
-
|
|
359
|
+
export type L2PruneUncheckpointedEvent = {
|
|
360
|
+
type: 'l2PruneUncheckpointed';
|
|
361
|
+
slotNumber: SlotNumber;
|
|
362
|
+
blocks: L2Block[];
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
export type L2CheckpointEvent = {
|
|
366
|
+
type: 'l2BlocksCheckpointed';
|
|
367
|
+
checkpoint: PublishedCheckpoint;
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
export type InvalidCheckpointDetectedEvent = {
|
|
371
|
+
type: 'invalidCheckpointDetected';
|
|
372
|
+
validationResult: ValidateCheckpointNegativeResult;
|
|
266
373
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
|
|
2
|
+
import type { L2Block } from '../l2_block.js';
|
|
3
|
+
import type { CheckpointId, L2BlockId, L2Tips } from '../l2_block_source.js';
|
|
3
4
|
|
|
4
5
|
/** Interface to the local view of the chain. Implemented by world-state and l2-tips-store. */
|
|
5
6
|
export interface L2BlockStreamLocalDataProvider {
|
|
@@ -15,11 +16,21 @@ export interface L2BlockStreamEventHandler {
|
|
|
15
16
|
export type L2BlockStreamEvent =
|
|
16
17
|
| /** Emits blocks added to the chain. */ {
|
|
17
18
|
type: 'blocks-added';
|
|
18
|
-
blocks:
|
|
19
|
+
blocks: L2Block[];
|
|
19
20
|
}
|
|
20
|
-
| /**
|
|
21
|
+
| /** Emits checkpoints published to L1. */ {
|
|
22
|
+
type: 'chain-checkpointed';
|
|
23
|
+
checkpoint: PublishedCheckpoint;
|
|
24
|
+
block: L2BlockId;
|
|
25
|
+
}
|
|
26
|
+
| /**
|
|
27
|
+
* Reports last correct block (new tip of the proposed chain). Note that this is not necessarily the anchor block
|
|
28
|
+
* that will be used in the transaction - if the chain has already moved past the reorg, we'll also see blocks-added
|
|
29
|
+
* events that will push the anchor block forward.
|
|
30
|
+
*/ {
|
|
21
31
|
type: 'chain-pruned';
|
|
22
32
|
block: L2BlockId;
|
|
33
|
+
checkpoint: CheckpointId;
|
|
23
34
|
}
|
|
24
35
|
| /** Reports new proven block. */ {
|
|
25
36
|
type: 'chain-proven';
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { AbortError } from '@aztec/foundation/error';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
5
5
|
|
|
6
|
+
import type { PublishedCheckpoint } from '../../checkpoint/published_checkpoint.js';
|
|
6
7
|
import { type L2BlockId, type L2BlockSource, makeL2BlockId } from '../l2_block_source.js';
|
|
7
8
|
import type { L2BlockStreamEvent, L2BlockStreamEventHandler, L2BlockStreamLocalDataProvider } from './interfaces.js';
|
|
8
9
|
|
|
10
|
+
/** Maximum number of checkpoints to prefetch at once during sync. Matches MAX_RPC_CHECKPOINTS_LEN. */
|
|
11
|
+
export const CHECKPOINT_PREFETCH_LIMIT = 50;
|
|
12
|
+
|
|
9
13
|
/** Creates a stream of events for new blocks, chain tips updates, and reorgs, out of polling an archiver or a node. */
|
|
10
14
|
export class L2BlockStream {
|
|
11
15
|
private readonly runningPromise: RunningPromise;
|
|
@@ -13,19 +17,29 @@ export class L2BlockStream {
|
|
|
13
17
|
private hasStarted = false;
|
|
14
18
|
|
|
15
19
|
constructor(
|
|
16
|
-
private l2BlockSource: Pick<
|
|
20
|
+
private l2BlockSource: Pick<
|
|
21
|
+
L2BlockSource,
|
|
22
|
+
'getBlocks' | 'getBlockHeader' | 'getL2Tips' | 'getCheckpoints' | 'getCheckpointedBlocks'
|
|
23
|
+
>,
|
|
17
24
|
private localData: L2BlockStreamLocalDataProvider,
|
|
18
25
|
private handler: L2BlockStreamEventHandler,
|
|
19
26
|
private readonly log = createLogger('types:block_stream'),
|
|
20
27
|
private opts: {
|
|
21
|
-
proven?: boolean;
|
|
22
28
|
pollIntervalMS?: number;
|
|
23
29
|
batchSize?: number;
|
|
24
30
|
startingBlock?: number;
|
|
25
31
|
/** Instead of downloading all blocks, only fetch the smallest subset that results in reliable reorg detection. */
|
|
26
32
|
skipFinalized?: boolean;
|
|
33
|
+
/** When true, checkpoint events will not be emitted. Blocks are still fetched via checkpoints but only blocks-added events are emitted. */
|
|
34
|
+
ignoreCheckpoints?: boolean;
|
|
35
|
+
/** Maximum number of checkpoints to prefetch at once during sync. Defaults to CHECKPOINT_PREFETCH_LIMIT (50). */
|
|
36
|
+
checkpointPrefetchLimit?: number;
|
|
27
37
|
} = {},
|
|
28
38
|
) {
|
|
39
|
+
// Note that RunningPromise is in stopped state by default. This promise won't run until someone invokes `start`,
|
|
40
|
+
// which makes it run periodically, or `sync`, which triggers it once.
|
|
41
|
+
// Users of L2BlockStream decide what mode to run it in (_periodically_ vs _manually triggered_).
|
|
42
|
+
// The default is _manually triggered_.
|
|
29
43
|
this.runningPromise = new RunningPromise(() => this.work(), log, this.opts.pollIntervalMS ?? 1000);
|
|
30
44
|
}
|
|
31
45
|
|
|
@@ -42,6 +56,11 @@ export class L2BlockStream {
|
|
|
42
56
|
return this.runningPromise.isRunning();
|
|
43
57
|
}
|
|
44
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Runs the synchronization process once.
|
|
61
|
+
*
|
|
62
|
+
* If you want to run this process continuously use `start` and `stop` instead.
|
|
63
|
+
*/
|
|
45
64
|
public async sync() {
|
|
46
65
|
this.isSyncing = true;
|
|
47
66
|
await this.runningPromise.trigger();
|
|
@@ -52,36 +71,29 @@ export class L2BlockStream {
|
|
|
52
71
|
try {
|
|
53
72
|
const sourceTips = await this.l2BlockSource.getL2Tips();
|
|
54
73
|
const localTips = await this.localData.getL2Tips();
|
|
55
|
-
this.log.trace(`Running L2 block stream`, {
|
|
56
|
-
sourceLatest: sourceTips.latest.number,
|
|
57
|
-
localLatest: localTips.latest.number,
|
|
58
|
-
sourceFinalized: sourceTips.finalized.number,
|
|
59
|
-
localFinalized: localTips.finalized.number,
|
|
60
|
-
sourceProven: sourceTips.proven.number,
|
|
61
|
-
localProven: localTips.proven.number,
|
|
62
|
-
sourceLatestHash: sourceTips.latest.hash,
|
|
63
|
-
localLatestHash: localTips.latest.hash,
|
|
64
|
-
sourceProvenHash: sourceTips.proven.hash,
|
|
65
|
-
localProvenHash: localTips.proven.hash,
|
|
66
|
-
sourceFinalizedHash: sourceTips.finalized.hash,
|
|
67
|
-
localFinalizedHash: localTips.finalized.hash,
|
|
68
|
-
});
|
|
74
|
+
this.log.trace(`Running L2 block stream`, { sourceTips, localTips });
|
|
69
75
|
|
|
70
76
|
// Check if there was a reorg and emit a chain-pruned event if so.
|
|
71
|
-
let latestBlockNumber = localTips.
|
|
72
|
-
const sourceCache = new BlockHashCache([sourceTips.
|
|
77
|
+
let latestBlockNumber = localTips.proposed.number;
|
|
78
|
+
const sourceCache = new BlockHashCache([sourceTips.proposed]);
|
|
73
79
|
while (!(await this.areBlockHashesEqualAt(latestBlockNumber, { sourceCache }))) {
|
|
74
80
|
latestBlockNumber--;
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
if (latestBlockNumber < localTips.
|
|
78
|
-
latestBlockNumber = BlockNumber(Math.min(latestBlockNumber, sourceTips.
|
|
83
|
+
if (latestBlockNumber < localTips.proposed.number) {
|
|
84
|
+
latestBlockNumber = BlockNumber(Math.min(latestBlockNumber, sourceTips.proposed.number)); // see #13471
|
|
79
85
|
const hash = sourceCache.get(latestBlockNumber) ?? (await this.getBlockHashFromSource(latestBlockNumber));
|
|
80
86
|
if (latestBlockNumber !== 0 && !hash) {
|
|
81
87
|
throw new Error(`Block hash not found in block source for block number ${latestBlockNumber}`);
|
|
82
88
|
}
|
|
83
|
-
this.log.verbose(
|
|
84
|
-
|
|
89
|
+
this.log.verbose(
|
|
90
|
+
`Reorg detected. Pruning blocks from ${latestBlockNumber + 1} to ${localTips.proposed.number}.`,
|
|
91
|
+
);
|
|
92
|
+
await this.emitEvent({
|
|
93
|
+
type: 'chain-pruned',
|
|
94
|
+
block: makeL2BlockId(latestBlockNumber, hash),
|
|
95
|
+
checkpoint: sourceTips.checkpointed.checkpoint,
|
|
96
|
+
});
|
|
85
97
|
}
|
|
86
98
|
|
|
87
99
|
// If we are just starting, use the starting block number from the options.
|
|
@@ -96,40 +108,128 @@ export class L2BlockStream {
|
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
let nextBlockNumber = latestBlockNumber + 1;
|
|
111
|
+
let nextCheckpointToEmit = CheckpointNumber(localTips.checkpointed.checkpoint.number + 1);
|
|
99
112
|
if (this.opts.skipFinalized) {
|
|
100
113
|
// When skipping finalized blocks we need to provide reliable reorg detection while fetching as few blocks as
|
|
101
114
|
// possible. Finalized blocks cannot be reorged by definition, so we can skip most of them. We do need the very
|
|
102
115
|
// last finalized block however in order to guarantee that we will eventually find a block in which our local
|
|
103
116
|
// store matches the source.
|
|
104
117
|
// If the last finalized block is behind our local tip, there is nothing to skip.
|
|
105
|
-
nextBlockNumber = Math.max(sourceTips.finalized.number, nextBlockNumber);
|
|
118
|
+
nextBlockNumber = Math.max(sourceTips.finalized.block.number, nextBlockNumber);
|
|
119
|
+
// If the next checkpoint to emit is behind the finalized tip then skip forward
|
|
120
|
+
nextCheckpointToEmit = CheckpointNumber(Math.max(nextCheckpointToEmit, sourceTips.finalized.checkpoint.number));
|
|
106
121
|
}
|
|
107
122
|
|
|
108
|
-
//
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
// Loop 1: Emit checkpoint events for checkpoints whose blocks are already in local storage.
|
|
124
|
+
// This handles the case where blocks were synced as uncheckpointed and later became checkpointed.
|
|
125
|
+
// The guard `lastBlockInCheckpoint.number > localTips.proposed.number` ensures we don't emit
|
|
126
|
+
// checkpoints for blocks we don't have (e.g., when startingBlock skips earlier blocks).
|
|
127
|
+
// Since only one checkpoint can ever be uncheckpointed, this loop should iterate at most once.
|
|
128
|
+
if (!this.opts.ignoreCheckpoints) {
|
|
129
|
+
let loop1Iterations = 0;
|
|
130
|
+
while (nextCheckpointToEmit <= sourceTips.checkpointed.checkpoint.number) {
|
|
131
|
+
const checkpoints = await this.l2BlockSource.getCheckpoints(nextCheckpointToEmit, 1);
|
|
132
|
+
if (checkpoints.length === 0) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
const lastBlockInCheckpoint = checkpoints[0].checkpoint.blocks.at(-1)!;
|
|
136
|
+
// If this checkpoint has blocks we haven't seen yet, stop - they need to be fetched first
|
|
137
|
+
if (lastBlockInCheckpoint.number > localTips.proposed.number) {
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
loop1Iterations++;
|
|
141
|
+
if (loop1Iterations > 1) {
|
|
142
|
+
this.log.warn(
|
|
143
|
+
`Emitting multiple checkpoints (${loop1Iterations}) for already-local blocks. ` +
|
|
144
|
+
`Next checkpoint: ${nextCheckpointToEmit}, source checkpointed: ${sourceTips.checkpointed.checkpoint.number}`,
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
const lastBlockHash = await lastBlockInCheckpoint.hash();
|
|
148
|
+
await this.emitEvent({
|
|
149
|
+
type: 'chain-checkpointed',
|
|
150
|
+
checkpoint: checkpoints[0],
|
|
151
|
+
block: makeL2BlockId(lastBlockInCheckpoint.number, lastBlockHash.toString()),
|
|
152
|
+
});
|
|
153
|
+
nextCheckpointToEmit = CheckpointNumber(nextCheckpointToEmit + 1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Loop 2: Fetch new checkpointed blocks. For each checkpoint, emit all blocks
|
|
158
|
+
// from that checkpoint that we need, then emit the checkpoint event.
|
|
159
|
+
// We prefetch multiple checkpoints, then process them one by one.
|
|
160
|
+
let prefetchedCheckpoints: PublishedCheckpoint[] = [];
|
|
161
|
+
let prefetchIdx = 0;
|
|
162
|
+
let nextCheckpointNumber: CheckpointNumber | undefined;
|
|
163
|
+
|
|
164
|
+
// Find the starting checkpoint number
|
|
165
|
+
if (nextBlockNumber <= sourceTips.checkpointed.block.number) {
|
|
166
|
+
const blocks = await this.l2BlockSource.getCheckpointedBlocks(BlockNumber(nextBlockNumber), 1);
|
|
167
|
+
if (blocks.length > 0) {
|
|
168
|
+
nextCheckpointNumber = blocks[0].checkpointNumber;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
while (nextBlockNumber <= sourceTips.checkpointed.block.number && nextCheckpointNumber !== undefined) {
|
|
173
|
+
// Refill the prefetch buffer when exhausted
|
|
174
|
+
if (prefetchIdx >= prefetchedCheckpoints.length) {
|
|
175
|
+
const prefetchLimit = this.opts.checkpointPrefetchLimit ?? CHECKPOINT_PREFETCH_LIMIT;
|
|
176
|
+
prefetchedCheckpoints = await this.l2BlockSource.getCheckpoints(nextCheckpointNumber, prefetchLimit);
|
|
177
|
+
prefetchIdx = 0;
|
|
178
|
+
if (prefetchedCheckpoints.length === 0) {
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const checkpoint = prefetchedCheckpoints[prefetchIdx]!;
|
|
184
|
+
|
|
185
|
+
// Get all blocks from this checkpoint that we need, respecting batchSize
|
|
186
|
+
const limit = Math.min(this.opts.batchSize ?? 50, sourceTips.checkpointed.block.number - nextBlockNumber + 1);
|
|
187
|
+
const blocksForCheckpoint = checkpoint.checkpoint.blocks
|
|
188
|
+
.filter(b => b.number >= nextBlockNumber)
|
|
189
|
+
.slice(0, limit);
|
|
190
|
+
if (blocksForCheckpoint.length === 0) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
await this.emitEvent({ type: 'blocks-added', blocks: blocksForCheckpoint });
|
|
194
|
+
nextBlockNumber = blocksForCheckpoint.at(-1)!.number + 1;
|
|
195
|
+
|
|
196
|
+
// If we've reached the end of this checkpoint, emit the checkpoint event and move to next
|
|
197
|
+
const lastBlockInCheckpoint = checkpoint.checkpoint.blocks.at(-1)!;
|
|
198
|
+
if (nextBlockNumber > lastBlockInCheckpoint.number) {
|
|
199
|
+
if (!this.opts.ignoreCheckpoints) {
|
|
200
|
+
const lastBlockHash = await lastBlockInCheckpoint.hash();
|
|
201
|
+
await this.emitEvent({
|
|
202
|
+
type: 'chain-checkpointed',
|
|
203
|
+
checkpoint,
|
|
204
|
+
block: makeL2BlockId(lastBlockInCheckpoint.number, lastBlockHash.toString()),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
prefetchIdx++;
|
|
208
|
+
nextCheckpointNumber = CheckpointNumber(nextCheckpointNumber + 1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Loop 3: Fetch any remaining uncheckpointed (proposed) blocks.
|
|
213
|
+
while (nextBlockNumber <= sourceTips.proposed.number) {
|
|
214
|
+
const limit = Math.min(this.opts.batchSize ?? 50, sourceTips.proposed.number - nextBlockNumber + 1);
|
|
215
|
+
this.log.trace(`Requesting blocks from ${nextBlockNumber} limit ${limit}`);
|
|
216
|
+
const blocks = await this.l2BlockSource.getBlocks(BlockNumber(nextBlockNumber), BlockNumber(limit));
|
|
117
217
|
if (blocks.length === 0) {
|
|
118
218
|
break;
|
|
119
219
|
}
|
|
120
220
|
await this.emitEvent({ type: 'blocks-added', blocks });
|
|
121
|
-
nextBlockNumber = blocks.at(-1)!.
|
|
221
|
+
nextBlockNumber = blocks.at(-1)!.number + 1;
|
|
122
222
|
}
|
|
123
223
|
|
|
124
224
|
// Update the proven and finalized tips.
|
|
125
|
-
if (localTips.proven !== undefined && sourceTips.proven.number !== localTips.proven.number) {
|
|
225
|
+
if (localTips.proven !== undefined && sourceTips.proven.block.number !== localTips.proven.block.number) {
|
|
126
226
|
await this.emitEvent({
|
|
127
227
|
type: 'chain-proven',
|
|
128
|
-
block: sourceTips.proven,
|
|
228
|
+
block: sourceTips.proven.block,
|
|
129
229
|
});
|
|
130
230
|
}
|
|
131
|
-
if (localTips.finalized !== undefined && sourceTips.finalized.number !== localTips.finalized.number) {
|
|
132
|
-
await this.emitEvent({ type: 'chain-finalized', block: sourceTips.finalized });
|
|
231
|
+
if (localTips.finalized !== undefined && sourceTips.finalized.block.number !== localTips.finalized.block.number) {
|
|
232
|
+
await this.emitEvent({ type: 'chain-finalized', block: sourceTips.finalized.block });
|
|
133
233
|
}
|
|
134
234
|
} catch (err: any) {
|
|
135
235
|
if (err.name === 'AbortError') {
|
|
@@ -177,7 +277,7 @@ export class L2BlockStream {
|
|
|
177
277
|
|
|
178
278
|
private async emitEvent(event: L2BlockStreamEvent) {
|
|
179
279
|
this.log.debug(
|
|
180
|
-
`Emitting ${event.type} (${event.type === 'blocks-added' ? event.blocks.length : event.block.number})`,
|
|
280
|
+
`Emitting ${event.type} (${event.type === 'blocks-added' ? event.blocks.length : event.type === 'chain-checkpointed' ? event.checkpoint.checkpoint.number : event.block.number})`,
|
|
181
281
|
);
|
|
182
282
|
await this.handler.handleBlockStreamEvent(event);
|
|
183
283
|
if (!this.isRunning() && !this.isSyncing) {
|