@aztec/stdlib 4.0.0-devnet.2-patch.4 → 4.0.0-devnet.3-patch.1
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/buffer.d.ts +14 -4
- package/dest/abi/buffer.d.ts.map +1 -1
- package/dest/abi/buffer.js +25 -4
- package/dest/abi/decoder.d.ts +6 -45
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +17 -70
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +37 -6
- package/dest/abi/event_metadata_definition.d.ts +3 -1
- package/dest/abi/event_metadata_definition.d.ts.map +1 -1
- package/dest/abi/event_metadata_definition.js +1 -1
- package/dest/abi/function_selector.js +1 -1
- package/dest/abi/function_signature_decoder.d.ts +43 -0
- package/dest/abi/function_signature_decoder.d.ts.map +1 -0
- package/dest/abi/function_signature_decoder.js +66 -0
- package/dest/abi/index.d.ts +2 -1
- package/dest/abi/index.d.ts.map +1 -1
- package/dest/abi/index.js +1 -0
- package/dest/abi/utils.d.ts +14 -1
- package/dest/abi/utils.d.ts.map +1 -1
- package/dest/abi/utils.js +15 -0
- package/dest/avm/avm.d.ts +300 -300
- package/dest/avm/avm_accumulated_data.js +2 -2
- package/dest/avm/avm_circuit_public_inputs.js +2 -2
- package/dest/avm/avm_proving_request.d.ts +166 -166
- package/dest/avm/revert_code.d.ts +16 -1
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +15 -5
- package/dest/block/l2_block.d.ts +9 -1
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +12 -2
- package/dest/block/l2_block_source.d.ts +16 -8
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +10 -0
- package/dest/checkpoint/checkpoint.d.ts +2 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -4
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/validate.d.ts +36 -0
- package/dest/checkpoint/validate.d.ts.map +1 -0
- package/dest/checkpoint/validate.js +120 -0
- package/dest/config/sequencer-config.d.ts +2 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +11 -0
- package/dest/epoch-helpers/index.d.ts +9 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +13 -2
- package/dest/gas/gas_fees.d.ts +1 -1
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +4 -1
- package/dest/hash/hash.d.ts +19 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +29 -0
- package/dest/interfaces/allowed_element.d.ts +26 -20
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +8 -8
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +3 -2
- package/dest/interfaces/aztec-node-admin.d.ts +67 -27
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +12 -6
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +5 -2
- package/dest/interfaces/block-builder.d.ts +38 -11
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +13 -6
- package/dest/interfaces/configs.d.ts +67 -32
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +7 -2
- package/dest/interfaces/merkle_tree_operations.d.ts +9 -19
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/p2p.d.ts +3 -8
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +6 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +7 -1
- package/dest/interfaces/validator.d.ts +67 -25
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +6 -2
- package/dest/interfaces/world_state.d.ts +5 -4
- package/dest/interfaces/world_state.d.ts.map +1 -1
- package/dest/kernel/claimed_length_array.js +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +3 -3
- 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 +13 -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 +13 -10
- package/dest/kernel/hints/build_transient_data_hints.d.ts +5 -2
- package/dest/kernel/hints/build_transient_data_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_transient_data_hints.js +9 -3
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts +1 -1
- package/dest/kernel/hints/private_kernel_reset_hints.d.ts.map +1 -1
- package/dest/kernel/padded_side_effects.js +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
- package/dest/kernel/private_to_avm_accumulated_data.js +2 -2
- package/dest/kernel/private_to_public_accumulated_data.js +2 -2
- package/dest/kernel/private_to_rollup_accumulated_data.js +1 -1
- package/dest/logs/debug_log_store.d.ts +30 -0
- package/dest/logs/debug_log_store.d.ts.map +1 -0
- package/dest/logs/debug_log_store.js +30 -0
- package/dest/logs/extended_directional_app_tagging_secret.d.ts +47 -0
- package/dest/logs/extended_directional_app_tagging_secret.d.ts.map +1 -0
- package/dest/logs/{directional_app_tagging_secret.js → extended_directional_app_tagging_secret.js} +35 -20
- package/dest/logs/index.d.ts +4 -2
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +3 -1
- package/dest/logs/log_filter.d.ts +4 -1
- package/dest/logs/log_filter.d.ts.map +1 -1
- package/dest/logs/log_filter.js +2 -1
- package/dest/logs/message_context.d.ts +4 -7
- package/dest/logs/message_context.d.ts.map +1 -1
- package/dest/logs/message_context.js +23 -9
- package/dest/logs/pending_tagged_log.d.ts +2 -3
- package/dest/logs/pending_tagged_log.d.ts.map +1 -1
- package/dest/logs/pending_tagged_log.js +2 -2
- package/dest/logs/pre_tag.d.ts +16 -11
- package/dest/logs/pre_tag.d.ts.map +1 -1
- package/dest/logs/pre_tag.js +2 -2
- package/dest/logs/private_log.js +1 -1
- package/dest/logs/public_log.d.ts +4 -3
- package/dest/logs/public_log.d.ts.map +1 -1
- package/dest/logs/public_log.js +9 -2
- package/dest/logs/shared_secret_derivation.d.ts +11 -10
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -1
- package/dest/logs/shared_secret_derivation.js +15 -9
- package/dest/logs/siloed_tag.d.ts +8 -3
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +11 -2
- package/dest/logs/tag.js +1 -1
- package/dest/logs/tagging_index_range.d.ts +40 -0
- package/dest/logs/tagging_index_range.d.ts.map +1 -0
- package/dest/logs/tagging_index_range.js +8 -0
- package/dest/logs/tx_scoped_l2_log.d.ts +3 -1
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +7 -0
- package/dest/messaging/l1_to_l2_message.d.ts +3 -2
- package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
- package/dest/messaging/l1_to_l2_message.js +11 -13
- package/dest/messaging/l2_to_l1_membership.d.ts +32 -6
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +69 -26
- package/dest/noir/index.d.ts +3 -3
- package/dest/noir/index.d.ts.map +1 -1
- package/dest/note/note_dao.d.ts +1 -1
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +1 -4
- package/dest/p2p/attestation_utils.d.ts +11 -1
- package/dest/p2p/attestation_utils.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.js +45 -0
- package/dest/p2p/checkpoint_proposal.d.ts +1 -6
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +13 -23
- package/dest/p2p/client_type.d.ts +2 -5
- package/dest/p2p/client_type.d.ts.map +1 -1
- package/dest/p2p/client_type.js +0 -7
- 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/peer_error.d.ts +3 -1
- package/dest/p2p/peer_error.d.ts.map +1 -1
- package/dest/p2p/peer_error.js +5 -0
- package/dest/p2p/topic_type.d.ts +3 -4
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +7 -24
- package/dest/parity/parity_base_private_inputs.js +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 +7 -1
- package/dest/rollup/base_rollup_hints.js +2 -2
- package/dest/rollup/block_root_rollup_private_inputs.js +5 -5
- package/dest/rollup/checkpoint_rollup_public_inputs.js +1 -1
- package/dest/rollup/checkpoint_root_rollup_private_inputs.js +3 -3
- package/dest/rollup/root_rollup_public_inputs.js +1 -1
- package/dest/rollup/tree_snapshot_diff_hints.js +2 -2
- package/dest/slashing/tally.d.ts +7 -2
- package/dest/slashing/tally.d.ts.map +1 -1
- package/dest/slashing/tally.js +30 -2
- package/dest/tests/factories.d.ts +3 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +8 -0
- package/dest/tests/mocks.d.ts +5 -3
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +18 -13
- package/dest/tx/block_header.d.ts +3 -1
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +4 -0
- package/dest/tx/capsule.d.ts +6 -2
- package/dest/tx/capsule.d.ts.map +1 -1
- package/dest/tx/capsule.js +9 -3
- package/dest/tx/private_execution_result.d.ts +6 -6
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +6 -6
- package/dest/tx/profiling.d.ts +17 -5
- package/dest/tx/profiling.d.ts.map +1 -1
- package/dest/tx/profiling.js +15 -5
- package/dest/tx/protocol_contracts.js +2 -2
- package/dest/tx/public_simulation_output.d.ts +4 -2
- package/dest/tx/public_simulation_output.d.ts.map +1 -1
- package/dest/tx/public_simulation_output.js +7 -3
- package/dest/tx/simulated_tx.d.ts +5 -2
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +4 -1
- package/dest/tx/tx.d.ts +6 -5
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +18 -6
- package/dest/tx/tx_receipt.d.ts +22 -3
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +15 -4
- package/dest/tx/validator/error_texts.d.ts +9 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +10 -0
- package/dest/update-checker/index.d.ts +3 -2
- package/dest/update-checker/index.d.ts.map +1 -1
- package/dest/update-checker/index.js +2 -1
- package/dest/update-checker/package_version.d.ts +3 -0
- package/dest/update-checker/package_version.d.ts.map +1 -0
- package/dest/update-checker/package_version.js +24 -0
- package/dest/update-checker/version_checker.d.ts +25 -0
- package/dest/update-checker/version_checker.d.ts.map +1 -0
- package/dest/update-checker/version_checker.js +50 -0
- package/dest/validators/errors.d.ts +6 -1
- package/dest/validators/errors.d.ts.map +1 -1
- package/dest/validators/errors.js +7 -0
- package/dest/versioning/versioning.d.ts +4 -2
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +4 -1
- package/dest/vks/vk_data.js +1 -1
- package/package.json +10 -10
- package/src/abi/buffer.ts +25 -4
- package/src/abi/decoder.ts +36 -82
- package/src/abi/encoder.ts +49 -6
- package/src/abi/event_metadata_definition.ts +2 -0
- package/src/abi/function_selector.ts +1 -1
- package/src/abi/function_signature_decoder.ts +77 -0
- package/src/abi/index.ts +1 -0
- package/src/abi/utils.ts +25 -0
- package/src/avm/avm_accumulated_data.ts +6 -6
- package/src/avm/avm_circuit_public_inputs.ts +4 -4
- package/src/avm/revert_code.ts +15 -0
- package/src/block/l2_block.ts +13 -1
- package/src/block/l2_block_source.ts +16 -7
- package/src/block/l2_block_stream/l2_block_stream.ts +21 -0
- package/src/checkpoint/checkpoint.ts +12 -3
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/validate.ts +230 -0
- package/src/config/sequencer-config.ts +16 -1
- package/src/epoch-helpers/index.ts +22 -0
- package/src/gas/README.md +123 -0
- package/src/gas/gas_fees.ts +7 -1
- package/src/hash/hash.ts +34 -0
- package/src/interfaces/allowed_element.ts +29 -9
- package/src/interfaces/archiver.ts +3 -2
- package/src/interfaces/aztec-node.ts +24 -5
- package/src/interfaces/block-builder.ts +60 -14
- package/src/interfaces/configs.ts +29 -8
- package/src/interfaces/merkle_tree_operations.ts +8 -18
- package/src/interfaces/p2p.ts +2 -13
- package/src/interfaces/prover-client.ts +8 -0
- package/src/interfaces/validator.ts +18 -2
- package/src/interfaces/world_state.ts +4 -3
- package/src/kernel/claimed_length_array.ts +2 -2
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +14 -18
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +15 -18
- package/src/kernel/hints/build_transient_data_hints.ts +17 -2
- package/src/kernel/hints/private_kernel_reset_hints.ts +5 -2
- package/src/kernel/hints/read_request_hints.ts +3 -3
- package/src/kernel/padded_side_effects.ts +3 -3
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
- package/src/kernel/private_to_avm_accumulated_data.ts +4 -4
- package/src/kernel/private_to_public_accumulated_data.ts +10 -10
- package/src/kernel/private_to_rollup_accumulated_data.ts +5 -5
- package/src/logs/debug_log_store.ts +54 -0
- package/src/logs/{directional_app_tagging_secret.ts → extended_directional_app_tagging_secret.ts} +41 -22
- package/src/logs/index.ts +3 -1
- package/src/logs/log_filter.ts +5 -0
- package/src/logs/message_context.ts +17 -7
- package/src/logs/pending_tagged_log.ts +1 -3
- package/src/logs/pre_tag.ts +5 -5
- package/src/logs/private_log.ts +1 -1
- package/src/logs/public_log.ts +15 -3
- package/src/logs/shared_secret_derivation.ts +21 -10
- package/src/logs/siloed_tag.ts +14 -3
- package/src/logs/tag.ts +1 -1
- package/src/logs/tagging_index_range.ts +24 -0
- package/src/logs/tx_scoped_l2_log.ts +16 -0
- package/src/messaging/l1_to_l2_message.ts +12 -9
- package/src/messaging/l2_to_l1_membership.ts +98 -33
- package/src/noir/index.ts +2 -2
- package/src/note/note_dao.ts +1 -4
- package/src/p2p/attestation_utils.ts +56 -0
- package/src/p2p/checkpoint_proposal.ts +23 -37
- package/src/p2p/client_type.ts +0 -6
- package/src/p2p/index.ts +0 -1
- package/src/p2p/peer_error.ts +7 -0
- package/src/p2p/topic_type.ts +8 -15
- package/src/parity/parity_base_private_inputs.ts +1 -1
- package/src/proofs/chonk_proof.ts +9 -1
- package/src/rollup/base_rollup_hints.ts +2 -2
- package/src/rollup/block_root_rollup_private_inputs.ts +8 -8
- package/src/rollup/checkpoint_rollup_public_inputs.ts +2 -2
- package/src/rollup/checkpoint_root_rollup_private_inputs.ts +4 -4
- package/src/rollup/root_rollup_public_inputs.ts +2 -2
- package/src/rollup/tree_snapshot_diff_hints.ts +5 -5
- package/src/slashing/tally.ts +34 -1
- package/src/tests/factories.ts +9 -0
- package/src/tests/mocks.ts +25 -10
- package/src/tx/block_header.ts +6 -0
- package/src/tx/capsule.ts +10 -2
- package/src/tx/private_execution_result.ts +5 -5
- package/src/tx/profiling.ts +14 -5
- package/src/tx/protocol_contracts.ts +2 -2
- package/src/tx/public_simulation_output.ts +4 -0
- package/src/tx/simulated_tx.ts +8 -1
- package/src/tx/tx.ts +20 -11
- package/src/tx/tx_receipt.ts +17 -2
- package/src/tx/validator/error_texts.ts +12 -0
- package/src/update-checker/index.ts +2 -1
- package/src/update-checker/package_version.ts +30 -0
- package/src/update-checker/version_checker.ts +65 -0
- package/src/validators/errors.ts +9 -0
- package/src/versioning/versioning.ts +4 -1
- package/src/vks/vk_data.ts +1 -1
- package/dest/logs/directional_app_tagging_secret.d.ts +0 -40
- package/dest/logs/directional_app_tagging_secret.d.ts.map +0 -1
- package/dest/update-checker/update-checker.d.ts +0 -49
- package/dest/update-checker/update-checker.d.ts.map +0 -1
- package/dest/update-checker/update-checker.js +0 -130
- package/src/update-checker/update-checker.ts +0 -166
|
@@ -101,23 +101,6 @@ export class CheckpointProposal extends Gossipable {
|
|
|
101
101
|
return this.checkpointHeader.slotNumber;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
get blockNumber(): BlockNumber {
|
|
105
|
-
if (!this.lastBlock) {
|
|
106
|
-
throw new Error('Cannot get blockNumber without lastBlock');
|
|
107
|
-
}
|
|
108
|
-
return this.lastBlock.blockHeader.getBlockNumber();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** Convenience getter for txHashes from lastBlock */
|
|
112
|
-
get txHashes(): TxHash[] {
|
|
113
|
-
return this.lastBlock?.txHashes ?? [];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/** Convenience getter for txs from lastBlock */
|
|
117
|
-
get txs(): Tx[] | undefined {
|
|
118
|
-
return this.lastBlock?.signedTxs?.txs;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
104
|
/**
|
|
122
105
|
* Extract a BlockProposal from the last block info.
|
|
123
106
|
* Uses inHash from checkpointHeader.contentCommitment.inHash
|
|
@@ -195,29 +178,32 @@ export class CheckpointProposal extends Gossipable {
|
|
|
195
178
|
blockNumber: lastBlockInfo?.blockHeader?.globalVariables.blockNumber ?? BlockNumber(0),
|
|
196
179
|
dutyType: DutyType.CHECKPOINT_PROPOSAL,
|
|
197
180
|
};
|
|
198
|
-
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
199
181
|
|
|
200
|
-
if (
|
|
201
|
-
|
|
182
|
+
if (lastBlockInfo) {
|
|
183
|
+
// Sign block proposal before signing checkpoint proposal to ensure HA protection
|
|
184
|
+
const lastBlockProposal = await BlockProposal.createProposalFromSigner(
|
|
185
|
+
lastBlockInfo.blockHeader,
|
|
186
|
+
lastBlockInfo.indexWithinCheckpoint,
|
|
187
|
+
checkpointHeader.inHash,
|
|
188
|
+
archiveRoot,
|
|
189
|
+
lastBlockInfo.txHashes,
|
|
190
|
+
lastBlockInfo.txs,
|
|
191
|
+
payloadSigner,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
195
|
+
|
|
196
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
|
|
197
|
+
blockHeader: lastBlockInfo.blockHeader,
|
|
198
|
+
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
199
|
+
txHashes: lastBlockInfo.txHashes,
|
|
200
|
+
signature: lastBlockProposal.signature,
|
|
201
|
+
signedTxs: lastBlockProposal.signedTxs,
|
|
202
|
+
});
|
|
202
203
|
}
|
|
203
204
|
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
lastBlockInfo.indexWithinCheckpoint,
|
|
207
|
-
checkpointHeader.inHash,
|
|
208
|
-
archiveRoot,
|
|
209
|
-
lastBlockInfo.txHashes,
|
|
210
|
-
lastBlockInfo.txs,
|
|
211
|
-
payloadSigner,
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
|
|
215
|
-
blockHeader: lastBlockInfo.blockHeader,
|
|
216
|
-
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
217
|
-
txHashes: lastBlockInfo.txHashes,
|
|
218
|
-
signature: lastBlockProposal.signature,
|
|
219
|
-
signedTxs: lastBlockProposal.signedTxs,
|
|
220
|
-
});
|
|
205
|
+
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
|
|
206
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
|
|
221
207
|
}
|
|
222
208
|
|
|
223
209
|
/**
|
package/src/p2p/client_type.ts
CHANGED
package/src/p2p/index.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from './interface.js';
|
|
|
8
8
|
export * from './signature_utils.js';
|
|
9
9
|
export * from './signed_txs.js';
|
|
10
10
|
export * from './topic_type.js';
|
|
11
|
-
export * from './client_type.js';
|
|
12
11
|
export * from './message_validator.js';
|
|
13
12
|
export * from './peer_error.js';
|
|
14
13
|
export * from './constants.js';
|
package/src/p2p/peer_error.ts
CHANGED
|
@@ -15,3 +15,10 @@ export enum PeerErrorSeverity {
|
|
|
15
15
|
*/
|
|
16
16
|
HighToleranceError = 'HighToleranceError',
|
|
17
17
|
}
|
|
18
|
+
|
|
19
|
+
/** Severities ordered from mildest to harshest. */
|
|
20
|
+
export const PeerErrorSeverityByHarshness = [
|
|
21
|
+
PeerErrorSeverity.HighToleranceError,
|
|
22
|
+
PeerErrorSeverity.MidToleranceError,
|
|
23
|
+
PeerErrorSeverity.LowToleranceError,
|
|
24
|
+
] as const;
|
package/src/p2p/topic_type.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { P2PClientType } from './client_type.js';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Creates the topic channel identifier string from a given topic type
|
|
5
3
|
*/
|
|
@@ -27,19 +25,14 @@ export enum TopicType {
|
|
|
27
25
|
checkpoint_attestation = 'checkpoint_attestation',
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function getTopicsForClientAndConfig(clientType: P2PClientType, disableTransactions: boolean) {
|
|
42
|
-
const topics = getTopicTypeForClientType(clientType);
|
|
28
|
+
/** Returns all gossip topics, optionally filtering out transactions. */
|
|
29
|
+
export function getTopicsForConfig(disableTransactions: boolean) {
|
|
30
|
+
const topics = [
|
|
31
|
+
TopicType.tx,
|
|
32
|
+
TopicType.block_proposal,
|
|
33
|
+
TopicType.checkpoint_proposal,
|
|
34
|
+
TopicType.checkpoint_attestation,
|
|
35
|
+
];
|
|
43
36
|
if (disableTransactions) {
|
|
44
37
|
return topics.filter(topic => topic !== TopicType.tx);
|
|
45
38
|
}
|
|
@@ -41,7 +41,7 @@ export class ParityBasePrivateInputs {
|
|
|
41
41
|
*/
|
|
42
42
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
43
43
|
const reader = BufferReader.asReader(buffer);
|
|
44
|
-
return new ParityBasePrivateInputs(reader.
|
|
44
|
+
return new ParityBasePrivateInputs(reader.readTuple(NUM_MSGS_PER_BASE_PARITY, Fr), Fr.fromBuffer(reader));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -56,7 +56,10 @@ export class ChonkProof {
|
|
|
56
56
|
static fromBuffer(buffer: Buffer | BufferReader): ChonkProof {
|
|
57
57
|
const reader = BufferReader.asReader(buffer);
|
|
58
58
|
const proofLength = reader.readNumber();
|
|
59
|
-
|
|
59
|
+
if (proofLength !== CHONK_PROOF_LENGTH) {
|
|
60
|
+
throw new Error(`Invalid ChonkProof length from buffer: ${proofLength}, expected ${CHONK_PROOF_LENGTH}`);
|
|
61
|
+
}
|
|
62
|
+
const proof = reader.readArray(CHONK_PROOF_LENGTH, Fr);
|
|
60
63
|
return new ChonkProof(proof);
|
|
61
64
|
}
|
|
62
65
|
|
|
@@ -106,6 +109,11 @@ export class ChonkProofWithPublicInputs {
|
|
|
106
109
|
static fromBuffer(buffer: Buffer | BufferReader): ChonkProofWithPublicInputs {
|
|
107
110
|
const reader = BufferReader.asReader(buffer);
|
|
108
111
|
const proofLength = reader.readNumber();
|
|
112
|
+
if (proofLength < CHONK_PROOF_LENGTH) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
`Invalid ChonkProofWithPublicInputs length from buffer: ${proofLength}, expected at least ${CHONK_PROOF_LENGTH}`,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
109
117
|
const proof = reader.readArray(proofLength, Fr);
|
|
110
118
|
return new ChonkProofWithPublicInputs(proof);
|
|
111
119
|
}
|
|
@@ -86,7 +86,7 @@ export class PrivateBaseRollupHints {
|
|
|
86
86
|
reader.readObject(SpongeBlob),
|
|
87
87
|
reader.readObject(TreeSnapshotDiffHints),
|
|
88
88
|
reader.readObject(PublicDataTreeLeafPreimage),
|
|
89
|
-
reader.
|
|
89
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
90
90
|
makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, () => reader.readObject(ContractClassLogFields)),
|
|
91
91
|
reader.readObject(BlockConstantData),
|
|
92
92
|
);
|
|
@@ -163,7 +163,7 @@ export class PublicBaseRollupHints {
|
|
|
163
163
|
return new PublicBaseRollupHints(
|
|
164
164
|
reader.readObject(SpongeBlob),
|
|
165
165
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
166
|
-
reader.
|
|
166
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
167
167
|
makeTuple(MAX_CONTRACT_CLASS_LOGS_PER_TX, () => reader.readObject(ContractClassLogFields)),
|
|
168
168
|
);
|
|
169
169
|
}
|
|
@@ -60,8 +60,8 @@ export class BlockRootFirstRollupPrivateInputs {
|
|
|
60
60
|
ProofData.fromBuffer(reader, ParityPublicInputs),
|
|
61
61
|
[ProofData.fromBuffer(reader, TxRollupPublicInputs), ProofData.fromBuffer(reader, TxRollupPublicInputs)],
|
|
62
62
|
AppendOnlyTreeSnapshot.fromBuffer(reader),
|
|
63
|
-
reader.
|
|
64
|
-
reader.
|
|
63
|
+
reader.readTuple(L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH, Fr),
|
|
64
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -124,8 +124,8 @@ export class BlockRootSingleTxFirstRollupPrivateInputs {
|
|
|
124
124
|
ProofData.fromBuffer(reader, ParityPublicInputs),
|
|
125
125
|
ProofData.fromBuffer(reader, TxRollupPublicInputs),
|
|
126
126
|
AppendOnlyTreeSnapshot.fromBuffer(reader),
|
|
127
|
-
reader.
|
|
128
|
-
reader.
|
|
127
|
+
reader.readTuple(L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH, Fr),
|
|
128
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -206,8 +206,8 @@ export class BlockRootEmptyTxFirstRollupPrivateInputs {
|
|
|
206
206
|
StateReference.fromBuffer(reader),
|
|
207
207
|
CheckpointConstantData.fromBuffer(reader),
|
|
208
208
|
reader.readUInt64(),
|
|
209
|
-
reader.
|
|
210
|
-
reader.
|
|
209
|
+
reader.readTuple(L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH, Fr),
|
|
210
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
211
211
|
);
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -248,7 +248,7 @@ export class BlockRootRollupPrivateInputs {
|
|
|
248
248
|
const reader = BufferReader.asReader(buffer);
|
|
249
249
|
return new BlockRootRollupPrivateInputs(
|
|
250
250
|
[ProofData.fromBuffer(reader, TxRollupPublicInputs), ProofData.fromBuffer(reader, TxRollupPublicInputs)],
|
|
251
|
-
reader.
|
|
251
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
254
|
|
|
@@ -289,7 +289,7 @@ export class BlockRootSingleTxRollupPrivateInputs {
|
|
|
289
289
|
const reader = BufferReader.asReader(buffer);
|
|
290
290
|
return new BlockRootSingleTxRollupPrivateInputs(
|
|
291
291
|
ProofData.fromBuffer(reader, TxRollupPublicInputs),
|
|
292
|
-
reader.
|
|
292
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
293
293
|
);
|
|
294
294
|
}
|
|
295
295
|
|
|
@@ -65,8 +65,8 @@ export class CheckpointRollupPublicInputs {
|
|
|
65
65
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
66
66
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
67
67
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
68
|
-
reader.
|
|
69
|
-
reader.
|
|
68
|
+
reader.readTuple(MAX_CHECKPOINTS_PER_EPOCH, Fr),
|
|
69
|
+
reader.readTuple(MAX_CHECKPOINTS_PER_EPOCH, FeeRecipient),
|
|
70
70
|
reader.readObject(BlobAccumulator),
|
|
71
71
|
reader.readObject(BlobAccumulator),
|
|
72
72
|
reader.readObject(FinalBlobBatchingChallenges),
|
|
@@ -81,15 +81,15 @@ export class CheckpointRootRollupHints {
|
|
|
81
81
|
const reader = BufferReader.asReader(buffer);
|
|
82
82
|
return new CheckpointRootRollupHints(
|
|
83
83
|
BlockHeader.fromBuffer(reader),
|
|
84
|
-
reader.
|
|
84
|
+
reader.readTuple(ARCHIVE_HEIGHT, Fr),
|
|
85
85
|
reader.readObject(AppendOnlyTreeSnapshot),
|
|
86
|
-
reader.
|
|
86
|
+
reader.readTuple(OUT_HASH_TREE_HEIGHT, Fr),
|
|
87
87
|
reader.readObject(BlobAccumulator),
|
|
88
88
|
reader.readObject(FinalBlobBatchingChallenges),
|
|
89
89
|
// Below line gives error 'Type instantiation is excessively deep and possibly infinite. ts(2589)'
|
|
90
|
-
// reader.
|
|
90
|
+
// reader.readTuple(FIELDS_PER_BLOB, Fr),
|
|
91
91
|
Array.from({ length: FIELDS_PER_BLOB * BLOBS_PER_CHECKPOINT }, () => Fr.fromBuffer(reader)),
|
|
92
|
-
reader.
|
|
92
|
+
reader.readTuple(BLOBS_PER_CHECKPOINT, BLS12Point),
|
|
93
93
|
Fr.fromBuffer(reader),
|
|
94
94
|
);
|
|
95
95
|
}
|
|
@@ -68,8 +68,8 @@ export class RootRollupPublicInputs {
|
|
|
68
68
|
Fr.fromBuffer(reader),
|
|
69
69
|
Fr.fromBuffer(reader),
|
|
70
70
|
Fr.fromBuffer(reader),
|
|
71
|
-
reader.
|
|
72
|
-
reader.
|
|
71
|
+
reader.readTuple(MAX_CHECKPOINTS_PER_EPOCH, Fr),
|
|
72
|
+
reader.readTuple(MAX_CHECKPOINTS_PER_EPOCH, FeeRecipient),
|
|
73
73
|
EpochConstantData.fromBuffer(reader),
|
|
74
74
|
reader.readObject(FinalBlobAccumulator),
|
|
75
75
|
);
|
|
@@ -85,14 +85,14 @@ export class TreeSnapshotDiffHints {
|
|
|
85
85
|
static fromBuffer(buffer: Buffer | BufferReader): TreeSnapshotDiffHints {
|
|
86
86
|
const reader = BufferReader.asReader(buffer);
|
|
87
87
|
return new TreeSnapshotDiffHints(
|
|
88
|
-
reader.
|
|
89
|
-
reader.
|
|
90
|
-
reader.
|
|
88
|
+
reader.readTuple(NOTE_HASH_SUBTREE_ROOT_SIBLING_PATH_LENGTH, Fr),
|
|
89
|
+
reader.readTuple(MAX_NULLIFIERS_PER_TX, NullifierLeafPreimage),
|
|
90
|
+
reader.readTuple(MAX_NULLIFIERS_PER_TX, {
|
|
91
91
|
fromBuffer: buffer => MembershipWitness.fromBuffer(buffer, NULLIFIER_TREE_HEIGHT),
|
|
92
92
|
}),
|
|
93
|
-
reader.
|
|
93
|
+
reader.readTuple(MAX_NULLIFIERS_PER_TX, Fr),
|
|
94
94
|
reader.readNumbers(MAX_NULLIFIERS_PER_TX),
|
|
95
|
-
reader.
|
|
95
|
+
reader.readTuple(NULLIFIER_SUBTREE_ROOT_SIBLING_PATH_LENGTH, Fr),
|
|
96
96
|
MembershipWitness.fromBuffer(reader, PUBLIC_DATA_TREE_HEIGHT),
|
|
97
97
|
);
|
|
98
98
|
}
|
package/src/slashing/tally.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { sumBigint } from '@aztec/foundation/bigint';
|
|
2
2
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
5
|
import type { PartialBy } from '@aztec/foundation/types';
|
|
5
6
|
|
|
6
7
|
import { getEpochForOffense } from './helpers.js';
|
|
@@ -12,6 +13,9 @@ import type { Offense, ValidatorSlashVote } from './types.js';
|
|
|
12
13
|
* @param committees - Array of committees (each containing array of validator addresses)
|
|
13
14
|
* @param epochsForCommittees - Array of epochs corresponding to each committee
|
|
14
15
|
* @param settings - Settings including slashingAmounts and optional validator override lists
|
|
16
|
+
* @param settings.maxSlashedValidators - If set, limits the total number of [validator, epoch] pairs
|
|
17
|
+
* with non-zero votes. The lowest-vote pairs are zeroed out to stay within the limit.
|
|
18
|
+
* @param logger - Logger, logs which validators were dropped.
|
|
15
19
|
* @returns Array of ValidatorSlashVote, where each vote is how many slash units the validator in that position should be slashed
|
|
16
20
|
*/
|
|
17
21
|
export function getSlashConsensusVotesFromOffenses(
|
|
@@ -22,9 +26,11 @@ export function getSlashConsensusVotesFromOffenses(
|
|
|
22
26
|
slashingAmounts: [bigint, bigint, bigint];
|
|
23
27
|
epochDuration: number;
|
|
24
28
|
targetCommitteeSize: number;
|
|
29
|
+
maxSlashedValidators?: number;
|
|
25
30
|
},
|
|
31
|
+
logger: Logger = createLogger('slasher:tally'),
|
|
26
32
|
): ValidatorSlashVote[] {
|
|
27
|
-
const { slashingAmounts, targetCommitteeSize } = settings;
|
|
33
|
+
const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
|
|
28
34
|
|
|
29
35
|
if (committees.length !== epochsForCommittees.length) {
|
|
30
36
|
throw new Error('committees and epochsForCommittees must have the same length');
|
|
@@ -53,6 +59,33 @@ export function getSlashConsensusVotesFromOffenses(
|
|
|
53
59
|
return padArrayEnd(votes, 0, targetCommitteeSize);
|
|
54
60
|
});
|
|
55
61
|
|
|
62
|
+
// if a cap is set, zero out the lowest-vote [validator, epoch] pairs so that the most severe slashes stay.
|
|
63
|
+
if (maxSlashedValidators === undefined) {
|
|
64
|
+
return votes;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const nonZeroByDescendingVote = [...votes.entries()].filter(([, vote]) => vote > 0).sort(([, a], [, b]) => b - a);
|
|
68
|
+
|
|
69
|
+
const toTruncate = nonZeroByDescendingVote.slice(maxSlashedValidators);
|
|
70
|
+
for (const [idx] of toTruncate) {
|
|
71
|
+
votes[idx] = 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (toTruncate.length > 0) {
|
|
75
|
+
const truncated = toTruncate.map(([idx]) => {
|
|
76
|
+
const committeeIndex = Math.floor(idx / targetCommitteeSize);
|
|
77
|
+
const positionInCommittee = idx % targetCommitteeSize;
|
|
78
|
+
return {
|
|
79
|
+
validator: committees[committeeIndex][positionInCommittee].toString(),
|
|
80
|
+
epoch: epochsForCommittees[committeeIndex],
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
logger.warn(
|
|
84
|
+
`Truncated ${toTruncate.length} validator-epoch pairs to stay within limit of ${maxSlashedValidators}`,
|
|
85
|
+
{ truncated },
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
56
89
|
return votes;
|
|
57
90
|
}
|
|
58
91
|
|
package/src/tests/factories.ts
CHANGED
|
@@ -128,6 +128,7 @@ import {
|
|
|
128
128
|
PublicCallRequestArrayLengths,
|
|
129
129
|
} from '../kernel/public_call_request.js';
|
|
130
130
|
import { PublicKeys, computeAddress } from '../keys/index.js';
|
|
131
|
+
import { ExtendedDirectionalAppTaggingSecret } from '../logs/extended_directional_app_tagging_secret.js';
|
|
131
132
|
import { ContractClassLog, ContractClassLogFields } from '../logs/index.js';
|
|
132
133
|
import { PrivateLog } from '../logs/private_log.js';
|
|
133
134
|
import { FlatPublicLogs, PublicLog } from '../logs/public_log.js';
|
|
@@ -1757,3 +1758,11 @@ export function makeL2Tips(
|
|
|
1757
1758
|
},
|
|
1758
1759
|
};
|
|
1759
1760
|
}
|
|
1761
|
+
|
|
1762
|
+
export async function randomExtendedDirectionalAppTaggingSecret(): Promise<ExtendedDirectionalAppTaggingSecret> {
|
|
1763
|
+
const resolvedApp = await AztecAddress.random();
|
|
1764
|
+
// Using the fromString method like this is messy as it leaks the underlying serialization format but I don't want to
|
|
1765
|
+
// expose the type's constructor just for tests since in prod the secret is always constructed via compute. Also this
|
|
1766
|
+
// method is tested in extended_directional_app_tagging_secret.test.ts hence all should be fine.
|
|
1767
|
+
return ExtendedDirectionalAppTaggingSecret.fromString(`${Fr.random().toString()}:${resolvedApp.toString()}`);
|
|
1768
|
+
}
|
package/src/tests/mocks.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
FIXED_DA_GAS,
|
|
3
|
-
FIXED_L2_GAS,
|
|
4
2
|
MAX_ENQUEUED_CALLS_PER_TX,
|
|
5
3
|
MAX_NULLIFIERS_PER_TX,
|
|
6
4
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
7
5
|
MAX_TX_LIFETIME,
|
|
6
|
+
PRIVATE_TX_L2_GAS_OVERHEAD,
|
|
7
|
+
PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
8
|
+
TX_DA_GAS_OVERHEAD,
|
|
8
9
|
} from '@aztec/constants';
|
|
9
10
|
import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
|
|
10
11
|
import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
@@ -97,6 +98,7 @@ export const mockTx = async (
|
|
|
97
98
|
publicCalldataSize = 2,
|
|
98
99
|
feePayer,
|
|
99
100
|
chonkProof = ChonkProof.random(),
|
|
101
|
+
gasLimits,
|
|
100
102
|
maxFeesPerGas = new GasFees(10, 10),
|
|
101
103
|
maxPriorityFeesPerGas,
|
|
102
104
|
gasUsed = Gas.empty(),
|
|
@@ -113,6 +115,7 @@ export const mockTx = async (
|
|
|
113
115
|
publicCalldataSize?: number;
|
|
114
116
|
feePayer?: AztecAddress;
|
|
115
117
|
chonkProof?: ChonkProof;
|
|
118
|
+
gasLimits?: Gas;
|
|
116
119
|
maxFeesPerGas?: GasFees;
|
|
117
120
|
maxPriorityFeesPerGas?: GasFees;
|
|
118
121
|
gasUsed?: Gas;
|
|
@@ -131,7 +134,7 @@ export const mockTx = async (
|
|
|
131
134
|
const data = PrivateKernelTailCircuitPublicInputs.empty();
|
|
132
135
|
const firstNullifier = new Nullifier(new Fr(seed + 1), Fr.ZERO, 0);
|
|
133
136
|
data.constants.anchorBlockHeader = anchorBlockHeader;
|
|
134
|
-
data.constants.txContext.gasSettings = GasSettings.default({ maxFeesPerGas, maxPriorityFeesPerGas });
|
|
137
|
+
data.constants.txContext.gasSettings = GasSettings.default({ gasLimits, maxFeesPerGas, maxPriorityFeesPerGas });
|
|
135
138
|
data.feePayer = feePayer ?? (await AztecAddress.random());
|
|
136
139
|
data.gasUsed = gasUsed;
|
|
137
140
|
data.constants.txContext.chainId = chainId;
|
|
@@ -205,8 +208,11 @@ export async function mockProcessedTx({
|
|
|
205
208
|
feePayer,
|
|
206
209
|
feePaymentPublicDataWrite,
|
|
207
210
|
// The default gasUsed is the tx overhead.
|
|
208
|
-
gasUsed = Gas.from({ daGas: FIXED_DA_GAS, l2Gas: FIXED_L2_GAS }),
|
|
209
211
|
privateOnly = false,
|
|
212
|
+
gasUsed = Gas.from({
|
|
213
|
+
daGas: TX_DA_GAS_OVERHEAD,
|
|
214
|
+
l2Gas: privateOnly ? PRIVATE_TX_L2_GAS_OVERHEAD : PUBLIC_TX_L2_GAS_OVERHEAD,
|
|
215
|
+
}),
|
|
210
216
|
avmAccumulatedData,
|
|
211
217
|
...mockTxOpts
|
|
212
218
|
}: {
|
|
@@ -421,10 +427,13 @@ export async function mockCheckpointAndMessages(
|
|
|
421
427
|
Partial<Parameters<typeof L2Block.random>[1]> = {},
|
|
422
428
|
) {
|
|
423
429
|
const slotNumber = options.slotNumber ?? SlotNumber(Number(checkpointNumber) * 10);
|
|
430
|
+
const globals = GlobalVariables.random({ slotNumber, ...options });
|
|
424
431
|
const blocksAndMessages = [];
|
|
432
|
+
|
|
425
433
|
// Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
|
|
426
434
|
// The current block's header.lastArchive must equal the previous block's archive.
|
|
427
435
|
let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
|
|
436
|
+
|
|
428
437
|
// Pass maxEffects via txOptions so it reaches TxEffect.random
|
|
429
438
|
const txOptions = maxEffects !== undefined ? { maxEffects } : {};
|
|
430
439
|
for (let i = 0; i < (blocks?.length ?? numBlocks); i++) {
|
|
@@ -433,11 +442,11 @@ export async function mockCheckpointAndMessages(
|
|
|
433
442
|
block:
|
|
434
443
|
blocks?.[i] ??
|
|
435
444
|
(await L2Block.random(blockNumber, {
|
|
445
|
+
...globals,
|
|
436
446
|
checkpointNumber,
|
|
437
447
|
indexWithinCheckpoint: IndexWithinCheckpoint(i),
|
|
438
448
|
txsPerBlock: numTxsPerBlock,
|
|
439
449
|
txOptions,
|
|
440
|
-
slotNumber,
|
|
441
450
|
...options,
|
|
442
451
|
...makeBlockOptions(blockNumber),
|
|
443
452
|
...(lastArchive ? { lastArchive } : {}),
|
|
@@ -451,12 +460,18 @@ export async function mockCheckpointAndMessages(
|
|
|
451
460
|
|
|
452
461
|
const messages = blocksAndMessages[0].messages;
|
|
453
462
|
const inHash = computeInHashFromL1ToL2Messages(messages);
|
|
454
|
-
const
|
|
463
|
+
const firstBlockLastArchive = blocksAndMessages[0].block.header.lastArchive;
|
|
464
|
+
const checkpoint = await Checkpoint.random(checkpointNumber, {
|
|
465
|
+
numBlocks: 0,
|
|
466
|
+
inHash,
|
|
467
|
+
...options,
|
|
468
|
+
...globals,
|
|
469
|
+
lastArchive: firstBlockLastArchive,
|
|
470
|
+
lastArchiveRoot: firstBlockLastArchive.root,
|
|
471
|
+
archive: lastArchive,
|
|
472
|
+
});
|
|
473
|
+
|
|
455
474
|
checkpoint.blocks = blocksAndMessages.map(({ block }) => block);
|
|
456
|
-
// Set the checkpoint's archive to match the last block's archive for proper chaining.
|
|
457
|
-
// When the archiver reconstructs checkpoints from L1, it uses the checkpoint's archive root
|
|
458
|
-
// from the L1 event to set the last block's archive. Without this, the archive chain breaks.
|
|
459
|
-
checkpoint.archive = lastArchive!;
|
|
460
475
|
|
|
461
476
|
// Return lastArchive so callers can chain it across multiple checkpoints
|
|
462
477
|
return { checkpoint, messages, lastArchive };
|
package/src/tx/block_header.ts
CHANGED
|
@@ -176,6 +176,12 @@ export class BlockHeader {
|
|
|
176
176
|
this._cachedHash = Promise.resolve(new BlockHash(hashed));
|
|
177
177
|
}
|
|
178
178
|
|
|
179
|
+
/** Recomputes the cached hash. Used for testing when header fields are mutated via unfreeze. */
|
|
180
|
+
recomputeHash(): Promise<BlockHash> {
|
|
181
|
+
this._cachedHash = undefined;
|
|
182
|
+
return this.hash();
|
|
183
|
+
}
|
|
184
|
+
|
|
179
185
|
static random(overrides: Partial<FieldsOf<BlockHeader>> & Partial<FieldsOf<GlobalVariables>> = {}): BlockHeader {
|
|
180
186
|
return BlockHeader.from({
|
|
181
187
|
lastArchive: AppendOnlyTreeSnapshot.random(),
|
package/src/tx/capsule.ts
CHANGED
|
@@ -19,6 +19,8 @@ export class Capsule {
|
|
|
19
19
|
public readonly storageSlot: Fr,
|
|
20
20
|
/** Data passed to the contract */
|
|
21
21
|
public readonly data: Fr[],
|
|
22
|
+
/** Optional namespace for the capsule contents */
|
|
23
|
+
public readonly scope?: AztecAddress,
|
|
22
24
|
) {}
|
|
23
25
|
|
|
24
26
|
static get schema() {
|
|
@@ -30,12 +32,18 @@ export class Capsule {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
toBuffer() {
|
|
33
|
-
return
|
|
35
|
+
return this.scope
|
|
36
|
+
? serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), true, this.scope)
|
|
37
|
+
: serializeToBuffer(this.contractAddress, this.storageSlot, new Vector(this.data), false);
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
static fromBuffer(buffer: Buffer | BufferReader): Capsule {
|
|
37
41
|
const reader = BufferReader.asReader(buffer);
|
|
38
|
-
|
|
42
|
+
const contractAddress = AztecAddress.fromBuffer(reader);
|
|
43
|
+
const storageSlot = Fr.fromBuffer(reader);
|
|
44
|
+
const data = reader.readVector(Fr);
|
|
45
|
+
const hasScope = reader.readBoolean();
|
|
46
|
+
return new Capsule(contractAddress, storageSlot, data, hasScope ? AztecAddress.fromBuffer(reader) : undefined);
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
toString() {
|
|
@@ -11,7 +11,7 @@ import { PrivateCircuitPublicInputs } from '../kernel/private_circuit_public_inp
|
|
|
11
11
|
import type { IsEmpty } from '../kernel/utils/interfaces.js';
|
|
12
12
|
import { sortByCounter } from '../kernel/utils/order_and_comparison.js';
|
|
13
13
|
import { ContractClassLog, ContractClassLogFields } from '../logs/contract_class_log.js';
|
|
14
|
-
import { type
|
|
14
|
+
import { type TaggingIndexRange, TaggingIndexRangeSchema } from '../logs/tagging_index_range.js';
|
|
15
15
|
import { Note } from '../note/note.js';
|
|
16
16
|
import { type ZodFor, mapSchema, schemas } from '../schemas/index.js';
|
|
17
17
|
import { HashedValues } from './hashed_values.js';
|
|
@@ -137,8 +137,8 @@ export class PrivateCallExecutionResult {
|
|
|
137
137
|
public returnValues: Fr[],
|
|
138
138
|
/** The offchain effects emitted during execution of this function call via the `emit_offchain_effect` oracle. */
|
|
139
139
|
public offchainEffects: { data: Fr[] }[],
|
|
140
|
-
/** The
|
|
141
|
-
public
|
|
140
|
+
/** The tagging index ranges used in this tx to compute tags for private logs */
|
|
141
|
+
public taggingIndexRanges: TaggingIndexRange[],
|
|
142
142
|
/** The nested executions. */
|
|
143
143
|
public nestedExecutionResults: PrivateCallExecutionResult[],
|
|
144
144
|
/**
|
|
@@ -161,7 +161,7 @@ export class PrivateCallExecutionResult {
|
|
|
161
161
|
noteHashNullifierCounterMap: mapSchema(z.coerce.number(), z.number()),
|
|
162
162
|
returnValues: z.array(schemas.Fr),
|
|
163
163
|
offchainEffects: z.array(z.object({ data: z.array(schemas.Fr) })),
|
|
164
|
-
|
|
164
|
+
taggingIndexRanges: z.array(TaggingIndexRangeSchema),
|
|
165
165
|
nestedExecutionResults: z.array(z.lazy(() => PrivateCallExecutionResult.schema)),
|
|
166
166
|
contractClassLogs: z.array(CountedContractClassLog.schema),
|
|
167
167
|
})
|
|
@@ -178,7 +178,7 @@ export class PrivateCallExecutionResult {
|
|
|
178
178
|
fields.noteHashNullifierCounterMap,
|
|
179
179
|
fields.returnValues,
|
|
180
180
|
fields.offchainEffects,
|
|
181
|
-
fields.
|
|
181
|
+
fields.taggingIndexRanges,
|
|
182
182
|
fields.nestedExecutionResults,
|
|
183
183
|
fields.contractClassLogs,
|
|
184
184
|
);
|
package/src/tx/profiling.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type ZodFor, optional, schemas } from '@aztec/foundation/schemas';
|
|
|
3
3
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
+
import { AztecAddress } from '../aztec-address/index.js';
|
|
6
7
|
import type { AztecNode } from '../interfaces/aztec-node.js';
|
|
7
8
|
import { type PrivateExecutionStep, PrivateExecutionStepSchema } from '../kernel/private_kernel_prover_output.js';
|
|
8
9
|
|
|
@@ -157,23 +158,31 @@ export class TxProfileResult {
|
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
export class
|
|
161
|
+
export class UtilityExecutionResult {
|
|
161
162
|
constructor(
|
|
162
163
|
public result: Fr[],
|
|
164
|
+
public offchainEffects: { data: Fr[]; contractAddress: AztecAddress }[],
|
|
165
|
+
/** Timestamp of the anchor block used during utility execution. */
|
|
166
|
+
public anchorBlockTimestamp: bigint,
|
|
163
167
|
public stats?: SimulationStats,
|
|
164
168
|
) {}
|
|
165
169
|
|
|
166
|
-
static get schema(): ZodFor<
|
|
170
|
+
static get schema(): ZodFor<UtilityExecutionResult> {
|
|
167
171
|
return z
|
|
168
172
|
.object({
|
|
169
173
|
result: z.array(schemas.Fr),
|
|
174
|
+
offchainEffects: z.array(z.object({ data: z.array(schemas.Fr), contractAddress: AztecAddress.schema })),
|
|
175
|
+
anchorBlockTimestamp: schemas.BigInt,
|
|
170
176
|
stats: optional(SimulationStatsSchema),
|
|
171
177
|
})
|
|
172
|
-
.transform(
|
|
178
|
+
.transform(
|
|
179
|
+
({ result, offchainEffects, anchorBlockTimestamp, stats }) =>
|
|
180
|
+
new UtilityExecutionResult(result, offchainEffects, anchorBlockTimestamp, stats),
|
|
181
|
+
);
|
|
173
182
|
}
|
|
174
183
|
|
|
175
|
-
static random():
|
|
176
|
-
return new
|
|
184
|
+
static random(): UtilityExecutionResult {
|
|
185
|
+
return new UtilityExecutionResult([Fr.random()], [], 0n, {
|
|
177
186
|
nodeRPCCalls: {
|
|
178
187
|
perMethod: { getBlockHeader: { times: [1] } },
|
|
179
188
|
roundTrips: {
|
|
@@ -30,7 +30,7 @@ export class ProtocolContracts {
|
|
|
30
30
|
|
|
31
31
|
static fromFields(fields: Fr[] | FieldReader): ProtocolContracts {
|
|
32
32
|
const reader = FieldReader.asReader(fields);
|
|
33
|
-
return new ProtocolContracts(reader.
|
|
33
|
+
return new ProtocolContracts(reader.readTuple(MAX_PROTOCOL_CONTRACTS, AztecAddress));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
toFields(): Fr[] {
|
|
@@ -39,7 +39,7 @@ export class ProtocolContracts {
|
|
|
39
39
|
|
|
40
40
|
static fromBuffer(buffer: Buffer | BufferReader): ProtocolContracts {
|
|
41
41
|
const reader = BufferReader.asReader(buffer);
|
|
42
|
-
return new ProtocolContracts(reader.
|
|
42
|
+
return new ProtocolContracts(reader.readTuple(MAX_PROTOCOL_CONTRACTS, AztecAddress));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
toBuffer() {
|