@aztec/stdlib 0.0.1-commit.e588bc7e5 → 0.0.1-commit.e5a3663dd
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/authorization_selector.d.ts +3 -6
- package/dest/abi/authorization_selector.d.ts.map +1 -1
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +32 -6
- package/dest/abi/event_selector.d.ts +3 -6
- package/dest/abi/event_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.d.ts +3 -6
- package/dest/abi/function_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.js +1 -3
- package/dest/abi/note_selector.d.ts +3 -6
- package/dest/abi/note_selector.d.ts.map +1 -1
- package/dest/abi/note_selector.js +1 -3
- package/dest/abi/selector.d.ts +2 -2
- package/dest/abi/selector.d.ts.map +1 -1
- package/dest/abi/selector.js +1 -1
- package/dest/avm/revert_code.d.ts +8 -18
- package/dest/avm/revert_code.d.ts.map +1 -1
- package/dest/avm/revert_code.js +15 -30
- package/dest/aztec-address/index.d.ts +3 -6
- package/dest/aztec-address/index.d.ts.map +1 -1
- package/dest/aztec-address/index.js +2 -4
- package/dest/block/attestation_info.d.ts +3 -2
- package/dest/block/attestation_info.d.ts.map +1 -1
- package/dest/block/attestation_info.js +7 -5
- package/dest/block/block_data.d.ts +297 -8
- package/dest/block/block_data.d.ts.map +1 -1
- package/dest/block/block_data.js +16 -2
- package/dest/block/block_hash.d.ts +11 -10
- package/dest/block/block_hash.d.ts.map +1 -1
- package/dest/block/block_hash.js +10 -9
- package/dest/block/block_parameter.d.ts +30 -3
- package/dest/block/block_parameter.d.ts.map +1 -1
- package/dest/block/block_parameter.js +36 -2
- package/dest/block/l2_block_info.d.ts +6 -5
- package/dest/block/l2_block_info.d.ts.map +1 -1
- package/dest/block/l2_block_info.js +6 -5
- package/dest/block/l2_block_source.d.ts +39 -4
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/interfaces.d.ts +6 -3
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_store_base.js +1 -1
- package/dest/block/proposal/attestations_and_signers.d.ts +13 -6
- package/dest/block/proposal/attestations_and_signers.d.ts.map +1 -1
- package/dest/block/proposal/attestations_and_signers.js +26 -18
- package/dest/block/test/l2_tips_store_test_suite.js +1 -1
- package/dest/checkpoint/checkpoint_data.d.ts +7 -1
- package/dest/checkpoint/checkpoint_data.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint_data.js +2 -0
- package/dest/config/chain-config.d.ts +2 -2
- package/dest/config/chain-config.d.ts.map +1 -1
- package/dest/config/chain-config.js +9 -3
- package/dest/config/sequencer-config.d.ts +5 -3
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +18 -4
- package/dest/contract/contract_address.d.ts +1 -1
- package/dest/contract/contract_address.js +2 -2
- 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 -4
- package/dest/gas/fee_math.d.ts +49 -0
- package/dest/gas/fee_math.d.ts.map +1 -0
- package/dest/gas/fee_math.js +80 -0
- package/dest/gas/gas_fees.d.ts +5 -1
- package/dest/gas/gas_fees.d.ts.map +1 -1
- package/dest/gas/gas_fees.js +10 -1
- package/dest/gas/gas_settings.d.ts +40 -3
- package/dest/gas/gas_settings.d.ts.map +1 -1
- package/dest/gas/gas_settings.js +50 -6
- package/dest/gas/index.d.ts +2 -1
- package/dest/gas/index.d.ts.map +1 -1
- package/dest/gas/index.js +1 -0
- package/dest/ha-signing/config.d.ts +6 -6
- package/dest/ha-signing/config.d.ts.map +1 -1
- package/dest/ha-signing/config.js +4 -3
- package/dest/ha-signing/index.d.ts +2 -2
- package/dest/ha-signing/index.d.ts.map +1 -1
- package/dest/ha-signing/index.js +1 -1
- package/dest/ha-signing/local_config.d.ts +1 -1
- package/dest/ha-signing/local_config.d.ts.map +1 -1
- package/dest/ha-signing/local_config.js +2 -2
- package/dest/ha-signing/types.d.ts +37 -32
- package/dest/ha-signing/types.d.ts.map +1 -1
- package/dest/ha-signing/types.js +13 -6
- package/dest/hash/hash.d.ts +16 -1
- package/dest/hash/hash.d.ts.map +1 -1
- package/dest/hash/hash.js +32 -0
- package/dest/interfaces/archiver.d.ts +11 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +10 -4
- package/dest/interfaces/aztec-node-admin.d.ts +22 -14
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +5 -4
- package/dest/interfaces/aztec-node-debug.d.ts +21 -0
- package/dest/interfaces/aztec-node-debug.d.ts.map +1 -0
- package/dest/interfaces/aztec-node-debug.js +18 -0
- package/dest/interfaces/aztec-node.d.ts +54 -55
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +20 -16
- package/dest/interfaces/block_response.d.ts +156 -0
- package/dest/interfaces/block_response.d.ts.map +1 -0
- package/dest/interfaces/block_response.js +24 -0
- package/dest/interfaces/chain_tips.d.ts +304 -0
- package/dest/interfaces/chain_tips.d.ts.map +1 -0
- package/dest/interfaces/chain_tips.js +11 -0
- package/dest/interfaces/checkpoint_parameter.d.ts +27 -0
- package/dest/interfaces/checkpoint_parameter.d.ts.map +1 -0
- package/dest/interfaces/checkpoint_parameter.js +20 -0
- package/dest/interfaces/checkpoint_response.d.ts +312 -0
- package/dest/interfaces/checkpoint_response.d.ts.map +1 -0
- package/dest/interfaces/checkpoint_response.js +26 -0
- package/dest/interfaces/client.d.ts +7 -1
- package/dest/interfaces/client.d.ts.map +1 -1
- package/dest/interfaces/client.js +6 -0
- package/dest/interfaces/configs.d.ts +12 -2
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +3 -1
- package/dest/interfaces/l1_publish_info.d.ts +43 -0
- package/dest/interfaces/l1_publish_info.d.ts.map +1 -0
- package/dest/interfaces/l1_publish_info.js +26 -0
- package/dest/interfaces/merkle_tree_operations.d.ts +4 -3
- package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
- package/dest/interfaces/prover-client.d.ts +1 -1
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +0 -3
- package/dest/interfaces/proving-job.d.ts +166 -166
- package/dest/interfaces/server.d.ts +6 -1
- package/dest/interfaces/server.d.ts.map +1 -1
- package/dest/interfaces/server.js +5 -0
- package/dest/interfaces/slasher.d.ts +1 -10
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +0 -2
- package/dest/interfaces/validator.d.ts +27 -18
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +2 -0
- package/dest/l1-contracts/index.d.ts +2 -2
- package/dest/l1-contracts/index.d.ts.map +1 -1
- package/dest/l1-contracts/index.js +1 -1
- package/dest/logs/log_id.d.ts +1 -1
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +1 -2
- package/dest/logs/siloed_tag.d.ts +5 -7
- package/dest/logs/siloed_tag.d.ts.map +1 -1
- package/dest/logs/siloed_tag.js +4 -0
- package/dest/logs/tag.d.ts +5 -6
- package/dest/logs/tag.d.ts.map +1 -1
- package/dest/logs/tag.js +4 -0
- package/dest/p2p/block_proposal.d.ts +22 -14
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +45 -40
- package/dest/p2p/checkpoint_attestation.d.ts +10 -8
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -1
- package/dest/p2p/checkpoint_attestation.js +17 -24
- package/dest/p2p/checkpoint_proposal.d.ts +20 -14
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +34 -51
- package/dest/p2p/consensus_payload.d.ts +18 -7
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +31 -19
- package/dest/p2p/gossipable.d.ts +4 -4
- package/dest/p2p/gossipable.d.ts.map +1 -1
- package/dest/p2p/signature_utils.d.ts +28 -19
- package/dest/p2p/signature_utils.d.ts.map +1 -1
- package/dest/p2p/signature_utils.js +118 -21
- package/dest/p2p/signed_txs.d.ts +15 -13
- package/dest/p2p/signed_txs.d.ts.map +1 -1
- package/dest/p2p/signed_txs.js +26 -24
- package/dest/parity/parity_base_private_inputs.d.ts +7 -3
- package/dest/parity/parity_base_private_inputs.d.ts.map +1 -1
- package/dest/parity/parity_base_private_inputs.js +7 -5
- package/dest/parity/parity_public_inputs.d.ts +7 -3
- package/dest/parity/parity_public_inputs.d.ts.map +1 -1
- package/dest/parity/parity_public_inputs.js +6 -3
- package/dest/rollup/block_headers_hash.d.ts +1 -1
- package/dest/rollup/block_headers_hash.d.ts.map +1 -1
- package/dest/rollup/block_headers_hash.js +8 -2
- package/dest/slashing/index.d.ts +2 -3
- package/dest/slashing/index.d.ts.map +1 -1
- package/dest/slashing/index.js +1 -2
- package/dest/slashing/serialization.d.ts +2 -6
- package/dest/slashing/serialization.d.ts.map +1 -1
- package/dest/slashing/serialization.js +0 -60
- package/dest/slashing/types.d.ts +4 -90
- package/dest/slashing/types.d.ts.map +1 -1
- package/dest/slashing/types.js +0 -14
- package/dest/slashing/{tally.d.ts → votes.d.ts} +1 -1
- package/dest/slashing/{tally.d.ts.map → votes.d.ts.map} +1 -1
- package/dest/slashing/{tally.js → votes.js} +1 -1
- package/dest/tests/factories.d.ts +2 -7
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +9 -19
- package/dest/tests/mocks.d.ts +7 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +39 -30
- package/dest/timetable/index.d.ts +51 -1
- package/dest/timetable/index.d.ts.map +1 -1
- package/dest/timetable/index.js +218 -14
- package/dest/trees/nullifier_leaf.d.ts +2 -1
- package/dest/trees/nullifier_leaf.d.ts.map +1 -1
- package/dest/trees/nullifier_leaf.js +3 -0
- package/dest/tx/block_header.d.ts +2 -2
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +1 -1
- package/dest/tx/fee_provider.d.ts +10 -0
- package/dest/tx/fee_provider.d.ts.map +1 -0
- package/dest/tx/fee_provider.js +1 -0
- package/dest/tx/global_variable_builder.d.ts +3 -16
- package/dest/tx/global_variable_builder.d.ts.map +1 -1
- package/dest/tx/index.d.ts +2 -1
- package/dest/tx/index.d.ts.map +1 -1
- package/dest/tx/index.js +1 -0
- package/dest/tx/indexed_tx_effect.d.ts +1 -1
- package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
- package/dest/tx/indexed_tx_effect.js +1 -2
- package/dest/tx/profiling.js +4 -4
- package/dest/tx/simulated_tx.d.ts +4 -4
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +3 -3
- package/dest/tx/tx.d.ts +3 -3
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx_receipt.d.ts +8 -4
- package/dest/tx/tx_receipt.d.ts.map +1 -1
- package/dest/tx/tx_receipt.js +8 -15
- package/dest/types/shared.d.ts +1 -10
- package/dest/types/shared.d.ts.map +1 -1
- package/dest/types/shared.js +0 -9
- package/dest/vks/verification_key.d.ts +2 -137
- package/dest/vks/verification_key.d.ts.map +1 -1
- package/dest/vks/verification_key.js +5 -126
- package/dest/world-state/genesis_data.d.ts +11 -0
- package/dest/world-state/genesis_data.d.ts.map +1 -0
- package/dest/world-state/genesis_data.js +4 -0
- package/dest/world-state/index.d.ts +2 -1
- package/dest/world-state/index.d.ts.map +1 -1
- package/dest/world-state/index.js +1 -0
- package/dest/world-state/world_state_revision.d.ts +8 -1
- package/dest/world-state/world_state_revision.d.ts.map +1 -1
- package/dest/world-state/world_state_revision.js +7 -1
- package/package.json +8 -8
- package/src/abi/authorization_selector.ts +2 -8
- package/src/abi/encoder.ts +42 -6
- package/src/abi/event_selector.ts +2 -8
- package/src/abi/function_selector.ts +3 -12
- package/src/abi/note_selector.ts +3 -12
- package/src/abi/selector.ts +1 -1
- package/src/avm/revert_code.ts +25 -39
- package/src/aztec-address/index.ts +4 -10
- package/src/block/attestation_info.ts +11 -11
- package/src/block/block_data.ts +20 -4
- package/src/block/block_hash.ts +21 -14
- package/src/block/block_parameter.ts +35 -2
- package/src/block/l2_block_info.ts +8 -6
- package/src/block/l2_block_source.ts +43 -3
- package/src/block/l2_block_stream/interfaces.ts +6 -2
- package/src/block/l2_block_stream/l2_tips_store_base.ts +1 -1
- package/src/block/proposal/attestations_and_signers.ts +32 -17
- package/src/block/test/l2_tips_store_test_suite.ts +1 -1
- package/src/checkpoint/checkpoint_data.ts +4 -0
- package/src/config/chain-config.ts +9 -4
- package/src/config/sequencer-config.ts +34 -6
- package/src/contract/contract_address.ts +2 -2
- package/src/contract/private_function.ts +3 -1
- package/src/gas/README.md +31 -0
- package/src/gas/fee_math.ts +120 -0
- package/src/gas/gas_fees.ts +17 -4
- package/src/gas/gas_settings.ts +65 -12
- package/src/gas/index.ts +1 -0
- package/src/ha-signing/config.ts +5 -2
- package/src/ha-signing/index.ts +3 -1
- package/src/ha-signing/local_config.ts +2 -2
- package/src/ha-signing/types.ts +48 -34
- package/src/hash/hash.ts +27 -0
- package/src/interfaces/archiver.ts +21 -3
- package/src/interfaces/aztec-node-admin.ts +8 -8
- package/src/interfaces/aztec-node-debug.ts +40 -0
- package/src/interfaces/aztec-node.ts +120 -95
- package/src/interfaces/block_response.ts +79 -0
- package/src/interfaces/chain_tips.ts +24 -0
- package/src/interfaces/checkpoint_parameter.ts +22 -0
- package/src/interfaces/checkpoint_response.ts +84 -0
- package/src/interfaces/client.ts +6 -0
- package/src/interfaces/configs.ts +8 -1
- package/src/interfaces/l1_publish_info.ts +40 -0
- package/src/interfaces/merkle_tree_operations.ts +3 -2
- package/src/interfaces/prover-client.ts +2 -5
- package/src/interfaces/server.ts +5 -0
- package/src/interfaces/slasher.ts +0 -6
- package/src/interfaces/validator.ts +22 -9
- package/src/l1-contracts/index.ts +1 -1
- package/src/logs/log_id.ts +1 -2
- package/src/logs/siloed_tag.ts +8 -9
- package/src/logs/tag.ts +8 -8
- package/src/p2p/block_proposal.ts +96 -36
- package/src/p2p/checkpoint_attestation.ts +20 -29
- package/src/p2p/checkpoint_proposal.ts +88 -71
- package/src/p2p/consensus_payload.ts +50 -28
- package/src/p2p/gossipable.ts +4 -4
- package/src/p2p/signature_utils.ts +110 -25
- package/src/p2p/signed_txs.ts +46 -28
- package/src/parity/parity_base_private_inputs.ts +10 -4
- package/src/parity/parity_public_inputs.ts +9 -2
- package/src/rollup/block_headers_hash.ts +11 -2
- package/src/slashing/index.ts +1 -2
- package/src/slashing/serialization.ts +1 -81
- package/src/slashing/types.ts +3 -35
- package/src/slashing/{tally.ts → votes.ts} +1 -1
- package/src/tests/factories.ts +15 -21
- package/src/tests/mocks.ts +63 -39
- package/src/timetable/index.ts +308 -13
- package/src/trees/nullifier_leaf.ts +4 -0
- package/src/tx/block_header.ts +2 -2
- package/src/tx/fee_provider.ts +10 -0
- package/src/tx/global_variable_builder.ts +2 -18
- package/src/tx/index.ts +1 -0
- package/src/tx/indexed_tx_effect.ts +1 -2
- package/src/tx/profiling.ts +4 -4
- package/src/tx/simulated_tx.ts +6 -2
- package/src/tx/tx.ts +2 -2
- package/src/tx/tx_receipt.ts +11 -14
- package/src/types/shared.ts +0 -10
- package/src/vks/verification_key.ts +5 -184
- package/src/world-state/genesis_data.ts +15 -0
- package/src/world-state/index.ts +1 -0
- package/src/world-state/world_state_revision.ts +9 -1
- package/dest/abi/mocked_keys.d.ts +0 -2
- package/dest/abi/mocked_keys.d.ts.map +0 -1
- package/dest/abi/mocked_keys.js +0 -1
- package/dest/l1-contracts/slash_factory.d.ts +0 -45
- package/dest/l1-contracts/slash_factory.d.ts.map +0 -1
- package/dest/l1-contracts/slash_factory.js +0 -158
- package/dest/slashing/empire.d.ts +0 -31
- package/dest/slashing/empire.d.ts.map +0 -1
- package/dest/slashing/empire.js +0 -87
- package/src/abi/mocked_keys.ts +0 -2
- package/src/l1-contracts/slash_factory.ts +0 -180
- package/src/slashing/empire.ts +0 -104
|
@@ -15,6 +15,8 @@ export interface SequencerConfig {
|
|
|
15
15
|
maxTxsPerBlock?: number;
|
|
16
16
|
/** The maximum number of txs across all blocks in a checkpoint. */
|
|
17
17
|
maxTxsPerCheckpoint?: number;
|
|
18
|
+
/** Maximum number of blocks the sequencer packs into a single checkpoint, and the highest indexWithinCheckpoint accepted on a block proposal. */
|
|
19
|
+
maxBlocksPerCheckpoint?: number;
|
|
18
20
|
/** The minimum number of txs to include in a block. */
|
|
19
21
|
minTxsPerBlock?: number;
|
|
20
22
|
/** The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock. */
|
|
@@ -83,6 +85,8 @@ export interface SequencerConfig {
|
|
|
83
85
|
minBlocksForCheckpoint?: number;
|
|
84
86
|
/** Skip publishing checkpoint proposals probability (for testing checkpoint prunes only) */
|
|
85
87
|
skipPublishingCheckpointsPercent?: number;
|
|
88
|
+
/** Skip broadcasting checkpoint and block proposals via gossipsub when proposer (for testing only) */
|
|
89
|
+
skipBroadcastProposals?: boolean;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
export const SequencerConfigSchema = zodFor<SequencerConfig>()(
|
|
@@ -90,6 +94,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
|
|
|
90
94
|
sequencerPollingIntervalMS: z.number().optional(),
|
|
91
95
|
maxTxsPerBlock: z.number().optional(),
|
|
92
96
|
maxTxsPerCheckpoint: z.number().optional(),
|
|
97
|
+
maxBlocksPerCheckpoint: z.number().positive().optional(),
|
|
93
98
|
minValidTxsPerBlock: z.number().optional(),
|
|
94
99
|
minTxsPerBlock: z.number().optional(),
|
|
95
100
|
maxL2BlockGas: z.number().optional(),
|
|
@@ -124,6 +129,7 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
|
|
|
124
129
|
skipPushProposedBlocksToArchiver: z.boolean().optional(),
|
|
125
130
|
minBlocksForCheckpoint: z.number().positive().optional(),
|
|
126
131
|
skipPublishingCheckpointsPercent: z.number().gte(0).lte(100).optional(),
|
|
132
|
+
skipBroadcastProposals: z.boolean().optional(),
|
|
127
133
|
}),
|
|
128
134
|
);
|
|
129
135
|
|
|
@@ -145,7 +151,8 @@ type SequencerConfigOptionalKeys =
|
|
|
145
151
|
| 'maxTxsPerCheckpoint'
|
|
146
152
|
| 'maxL2BlockGas'
|
|
147
153
|
| 'maxDABlockGas'
|
|
148
|
-
| 'redistributeCheckpointBudget'
|
|
154
|
+
| 'redistributeCheckpointBudget'
|
|
155
|
+
| 'skipBroadcastProposals';
|
|
149
156
|
|
|
150
157
|
export type ResolvedSequencerConfig = Prettify<
|
|
151
158
|
Required<Omit<SequencerConfig, SequencerConfigOptionalKeys>> & Pick<SequencerConfig, SequencerConfigOptionalKeys>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { schemas } from '@aztec/foundation/schemas';
|
|
2
|
+
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* L1 publication info for a block or checkpoint.
|
|
9
|
+
*
|
|
10
|
+
* A discriminated union over `published`: when `false`, the block/checkpoint has not yet been
|
|
11
|
+
* published to L1. When `true`, the L1 block info (number, timestamp, hash) is present.
|
|
12
|
+
*
|
|
13
|
+
* Distinct from {@link L1PublishedData}, which is always the "published" case.
|
|
14
|
+
*/
|
|
15
|
+
export type L1PublishInfo =
|
|
16
|
+
| { published: false }
|
|
17
|
+
| { published: true; blockNumber: bigint; timestamp: bigint; blockHash: string };
|
|
18
|
+
|
|
19
|
+
export const L1PublishInfoSchema = z.union([
|
|
20
|
+
z.object({ published: z.literal(false) }),
|
|
21
|
+
z.object({
|
|
22
|
+
published: z.literal(true),
|
|
23
|
+
blockNumber: schemas.BigInt,
|
|
24
|
+
timestamp: schemas.BigInt,
|
|
25
|
+
blockHash: z.string(),
|
|
26
|
+
}),
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
/** Projects the internal {@link L1PublishedData} (or its absence) to the public {@link L1PublishInfo} shape. */
|
|
30
|
+
export function l1PublishInfoFromL1PublishedData(data: L1PublishedData | undefined): L1PublishInfo {
|
|
31
|
+
if (!data) {
|
|
32
|
+
return { published: false };
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
published: true,
|
|
36
|
+
blockNumber: data.blockNumber,
|
|
37
|
+
timestamp: data.timestamp,
|
|
38
|
+
blockHash: data.blockHash,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { type IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
|
|
5
5
|
|
|
6
|
+
import type { BlockHash } from '../block/block_hash.js';
|
|
6
7
|
import type { MerkleTreeId, TreeHeights } from '../trees/merkle_tree_id.js';
|
|
7
8
|
import type { NullifierLeaf } from '../trees/nullifier_leaf.js';
|
|
8
9
|
import type { PublicDataTreeLeaf } from '../trees/public_data_leaf.js';
|
|
@@ -99,7 +100,7 @@ type LeafTypes = {
|
|
|
99
100
|
[MerkleTreeId.NOTE_HASH_TREE]: Fr;
|
|
100
101
|
[MerkleTreeId.PUBLIC_DATA_TREE]: Buffer;
|
|
101
102
|
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
|
|
102
|
-
[MerkleTreeId.ARCHIVE]:
|
|
103
|
+
[MerkleTreeId.ARCHIVE]: BlockHash;
|
|
103
104
|
};
|
|
104
105
|
|
|
105
106
|
type LeafValueTypes = {
|
|
@@ -107,7 +108,7 @@ type LeafValueTypes = {
|
|
|
107
108
|
[MerkleTreeId.NOTE_HASH_TREE]: Fr;
|
|
108
109
|
[MerkleTreeId.PUBLIC_DATA_TREE]: PublicDataTreeLeaf;
|
|
109
110
|
[MerkleTreeId.L1_TO_L2_MESSAGE_TREE]: Fr;
|
|
110
|
-
[MerkleTreeId.ARCHIVE]:
|
|
111
|
+
[MerkleTreeId.ARCHIVE]: BlockHash;
|
|
111
112
|
};
|
|
112
113
|
|
|
113
114
|
export type MerkleTreeLeafType<ID extends MerkleTreeId> = LeafTypes[ID];
|
|
@@ -71,7 +71,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
71
71
|
},
|
|
72
72
|
proverId: {
|
|
73
73
|
env: 'PROVER_ID',
|
|
74
|
-
parseEnv: (val
|
|
74
|
+
parseEnv: (val: string) => parseProverId(val),
|
|
75
75
|
description: 'Hex value that identifies the prover. Defaults to the address used for submitting proofs if not set.',
|
|
76
76
|
},
|
|
77
77
|
proverTestDelayType: {
|
|
@@ -117,10 +117,7 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
117
117
|
},
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
-
function parseProverId(str
|
|
121
|
-
if (!str) {
|
|
122
|
-
return undefined;
|
|
123
|
-
}
|
|
120
|
+
function parseProverId(str: string) {
|
|
124
121
|
return EthAddress.fromString(str);
|
|
125
122
|
}
|
|
126
123
|
|
package/src/interfaces/server.ts
CHANGED
|
@@ -2,6 +2,11 @@ export * from './allowed_element.js';
|
|
|
2
2
|
export * from './api_limit.js';
|
|
3
3
|
export * from './archiver.js';
|
|
4
4
|
export * from './aztec-node.js';
|
|
5
|
+
export * from './block_response.js';
|
|
6
|
+
export * from './chain_tips.js';
|
|
7
|
+
export * from './checkpoint_parameter.js';
|
|
8
|
+
export * from './checkpoint_response.js';
|
|
9
|
+
export * from './l1_publish_info.js';
|
|
5
10
|
export * from './block-builder.js';
|
|
6
11
|
export * from './configs.js';
|
|
7
12
|
export * from './epoch-prover.js';
|
|
@@ -3,12 +3,8 @@ import { schemas, zodFor } from '@aztec/foundation/schemas';
|
|
|
3
3
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
export type SlasherClientType = 'empire' | 'tally';
|
|
7
|
-
|
|
8
6
|
export interface SlasherConfig {
|
|
9
7
|
slashOverridePayload?: EthAddress;
|
|
10
|
-
slashMinPenaltyPercentage: number;
|
|
11
|
-
slashMaxPenaltyPercentage: number;
|
|
12
8
|
slashSelfAllowed?: boolean; // Whether to allow slashes to own validators
|
|
13
9
|
slashValidatorsAlways: EthAddress[]; // Array of validator addresses
|
|
14
10
|
slashValidatorsNever: EthAddress[]; // Array of validator addresses
|
|
@@ -32,8 +28,6 @@ export interface SlasherConfig {
|
|
|
32
28
|
export const SlasherConfigSchema = zodFor<SlasherConfig>()(
|
|
33
29
|
z.object({
|
|
34
30
|
slashOverridePayload: schemas.EthAddress.optional(),
|
|
35
|
-
slashMinPenaltyPercentage: z.number(),
|
|
36
|
-
slashMaxPenaltyPercentage: z.number(),
|
|
37
31
|
slashValidatorsAlways: z.array(schemas.EthAddress),
|
|
38
32
|
slashValidatorsNever: z.array(schemas.EthAddress),
|
|
39
33
|
slashPrunePenalty: schemas.BigInt,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { SecretValue } from '@aztec/foundation/config';
|
|
3
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -9,7 +9,6 @@ import type {
|
|
|
9
9
|
BlockProposal,
|
|
10
10
|
BlockProposalOptions,
|
|
11
11
|
CheckpointAttestation,
|
|
12
|
-
CheckpointLastBlockData,
|
|
13
12
|
CheckpointProposal,
|
|
14
13
|
CheckpointProposalOptions,
|
|
15
14
|
} from '@aztec/stdlib/p2p';
|
|
@@ -20,6 +19,7 @@ import type { PeerId } from '@libp2p/interface';
|
|
|
20
19
|
import { z } from 'zod';
|
|
21
20
|
|
|
22
21
|
import type { CommitteeAttestationsAndSigners } from '../block/index.js';
|
|
22
|
+
import type { ChainConfig } from '../config/chain-config.js';
|
|
23
23
|
import {
|
|
24
24
|
type LocalSignerConfig,
|
|
25
25
|
LocalSignerConfigSchema,
|
|
@@ -33,6 +33,9 @@ import { AllowedElementSchema } from './allowed_element.js';
|
|
|
33
33
|
*/
|
|
34
34
|
export type ValidatorClientConfig = ValidatorHASignerConfig &
|
|
35
35
|
LocalSignerConfig & {
|
|
36
|
+
/** The L1 chain id used for EIP-712 proposal-path signing. */
|
|
37
|
+
l1ChainId: ChainConfig['l1ChainId'];
|
|
38
|
+
|
|
36
39
|
/** The private keys of the validators participating in attestation duties */
|
|
37
40
|
validatorPrivateKeys?: SecretValue<`0x${string}`[]>;
|
|
38
41
|
|
|
@@ -77,7 +80,7 @@ export type ValidatorClientConfig = ValidatorHASignerConfig &
|
|
|
77
80
|
};
|
|
78
81
|
|
|
79
82
|
export type ValidatorClientFullConfig = ValidatorClientConfig &
|
|
80
|
-
Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal'> &
|
|
83
|
+
Pick<SequencerConfig, 'txPublicSetupAllowListExtend' | 'broadcastInvalidBlockProposal' | 'maxBlocksPerCheckpoint'> &
|
|
81
84
|
Pick<
|
|
82
85
|
SlasherConfig,
|
|
83
86
|
'slashBroadcastedInvalidBlockPenalty' | 'slashDuplicateProposalPenalty' | 'slashDuplicateAttestationPenalty'
|
|
@@ -91,6 +94,7 @@ export type ValidatorClientFullConfig = ValidatorClientConfig &
|
|
|
91
94
|
|
|
92
95
|
export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'validatorPrivateKeys'>>()(
|
|
93
96
|
ValidatorHASignerConfigSchema.merge(LocalSignerConfigSchema).extend({
|
|
97
|
+
l1ChainId: z.number().int().nonnegative(),
|
|
94
98
|
validatorAddresses: z.array(schemas.EthAddress).optional(),
|
|
95
99
|
disableValidator: z.boolean(),
|
|
96
100
|
disabledValidators: z.array(schemas.EthAddress),
|
|
@@ -111,6 +115,7 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
|
|
|
111
115
|
ValidatorClientConfigSchema.extend({
|
|
112
116
|
txPublicSetupAllowListExtend: z.array(AllowedElementSchema).optional(),
|
|
113
117
|
broadcastInvalidBlockProposal: z.boolean().optional(),
|
|
118
|
+
maxBlocksPerCheckpoint: z.number().positive().optional(),
|
|
114
119
|
slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
|
|
115
120
|
slashDuplicateProposalPenalty: schemas.BigInt,
|
|
116
121
|
slashDuplicateAttestationPenalty: schemas.BigInt,
|
|
@@ -118,8 +123,6 @@ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullCo
|
|
|
118
123
|
}),
|
|
119
124
|
);
|
|
120
125
|
|
|
121
|
-
export type CreateCheckpointProposalLastBlockData = Omit<CheckpointLastBlockData, 'txHashes'> & { txs: Tx[] };
|
|
122
|
-
|
|
123
126
|
export interface Validator {
|
|
124
127
|
start(): Promise<void>;
|
|
125
128
|
updateConfig(config: Partial<ValidatorClientFullConfig>): void;
|
|
@@ -127,6 +130,7 @@ export interface Validator {
|
|
|
127
130
|
// Block validation responsibilities
|
|
128
131
|
createBlockProposal(
|
|
129
132
|
blockHeader: BlockHeader,
|
|
133
|
+
checkpointNumber: CheckpointNumber,
|
|
130
134
|
indexWithinCheckpoint: number,
|
|
131
135
|
inHash: Fr,
|
|
132
136
|
archive: Fr,
|
|
@@ -139,8 +143,9 @@ export interface Validator {
|
|
|
139
143
|
createCheckpointProposal(
|
|
140
144
|
checkpointHeader: CheckpointHeader,
|
|
141
145
|
archive: Fr,
|
|
146
|
+
checkpointNumber: CheckpointNumber,
|
|
142
147
|
feeAssetPriceModifier: bigint,
|
|
143
|
-
|
|
148
|
+
lastBlockProposal: BlockProposal | undefined,
|
|
144
149
|
proposerAddress: EthAddress | undefined,
|
|
145
150
|
options: CheckpointProposalOptions,
|
|
146
151
|
): Promise<CheckpointProposal>;
|
|
@@ -164,15 +169,23 @@ export interface Validator {
|
|
|
164
169
|
broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
|
|
165
170
|
|
|
166
171
|
/** Collect own attestations for a checkpoint proposal (used when skipping p2p attestation collection) */
|
|
167
|
-
collectOwnAttestations(
|
|
172
|
+
collectOwnAttestations(
|
|
173
|
+
proposal: CheckpointProposal,
|
|
174
|
+
checkpointNumber: CheckpointNumber,
|
|
175
|
+
): Promise<CheckpointAttestation[]>;
|
|
168
176
|
|
|
169
177
|
/** Collect attestations from the p2p network for a checkpoint proposal */
|
|
170
|
-
collectAttestations(
|
|
178
|
+
collectAttestations(
|
|
179
|
+
proposal: CheckpointProposal,
|
|
180
|
+
required: number,
|
|
181
|
+
deadline: Date,
|
|
182
|
+
checkpointNumber: CheckpointNumber,
|
|
183
|
+
): Promise<CheckpointAttestation[]>;
|
|
171
184
|
|
|
172
185
|
signAttestationsAndSigners(
|
|
173
186
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
174
187
|
proposer: EthAddress,
|
|
175
188
|
slot: SlotNumber,
|
|
176
|
-
|
|
189
|
+
checkpointNumber: CheckpointNumber,
|
|
177
190
|
): Promise<Signature>;
|
|
178
191
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
// No exports.
|
package/src/logs/log_id.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
2
|
import { toBufferBE } from '@aztec/foundation/bigint-buffer';
|
|
3
3
|
import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
|
|
4
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
4
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
6
5
|
|
|
7
6
|
import { z } from 'zod';
|
|
@@ -83,7 +82,7 @@ export class LogId {
|
|
|
83
82
|
const reader = BufferReader.asReader(buffer);
|
|
84
83
|
|
|
85
84
|
const blockNumber = BlockNumber(reader.readNumber());
|
|
86
|
-
const blockHash =
|
|
85
|
+
const blockHash = BlockHash.fromBuffer(reader);
|
|
87
86
|
const txHash = reader.readObject(TxHash);
|
|
88
87
|
const txIndex = reader.readNumber();
|
|
89
88
|
const logIndex = reader.readNumber();
|
package/src/logs/siloed_tag.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DomainSeparator } from '@aztec/constants';
|
|
2
|
-
import
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
4
4
|
|
|
5
5
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
@@ -8,19 +8,14 @@ import { schemas } from '../schemas/schemas.js';
|
|
|
8
8
|
import type { PreTag } from './pre_tag.js';
|
|
9
9
|
import { Tag } from './tag.js';
|
|
10
10
|
|
|
11
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
12
|
-
|
|
13
|
-
/** Branding to ensure fields are not interchangeable types. */
|
|
14
|
-
export interface SiloedTag {
|
|
15
|
-
/** Brand. */
|
|
16
|
-
_branding: 'SiloedTag';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
11
|
/**
|
|
20
12
|
* Represents a tag used in private log as it "appears on the chain" - that is the tag is siloed with a contract
|
|
21
13
|
* address that emitted the log.
|
|
22
14
|
*/
|
|
23
15
|
export class SiloedTag {
|
|
16
|
+
/** Branding for nominal typing. */
|
|
17
|
+
declare private readonly _branding: 'SiloedTag';
|
|
18
|
+
|
|
24
19
|
constructor(public readonly value: Fr) {}
|
|
25
20
|
|
|
26
21
|
static async compute(preTag: PreTag): Promise<SiloedTag> {
|
|
@@ -49,6 +44,10 @@ export class SiloedTag {
|
|
|
49
44
|
return this.value.equals(other.value);
|
|
50
45
|
}
|
|
51
46
|
|
|
47
|
+
static random(): SiloedTag {
|
|
48
|
+
return new SiloedTag(Fr.random());
|
|
49
|
+
}
|
|
50
|
+
|
|
52
51
|
static get schema(): ZodFor<SiloedTag> {
|
|
53
52
|
return schemas.Fr.transform((fr: Fr) => new SiloedTag(fr));
|
|
54
53
|
}
|
package/src/logs/tag.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
|
-
import
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import type { ZodFor } from '@aztec/foundation/schemas';
|
|
4
4
|
|
|
5
5
|
import { schemas } from '../schemas/schemas.js';
|
|
6
6
|
import type { PreTag } from './pre_tag.js';
|
|
7
7
|
|
|
8
|
-
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
9
|
-
|
|
10
|
-
export interface Tag {
|
|
11
|
-
/** Brand. */
|
|
12
|
-
_branding: 'Tag';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
8
|
/**
|
|
16
9
|
* Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
|
|
17
10
|
* with a contract address by kernels before being included in the final log.
|
|
18
11
|
*/
|
|
19
12
|
export class Tag {
|
|
13
|
+
/** Branding for nominal typing. */
|
|
14
|
+
declare private readonly _branding: 'Tag';
|
|
15
|
+
|
|
20
16
|
constructor(public readonly value: Fr) {}
|
|
21
17
|
|
|
22
18
|
static async compute(preTag: PreTag): Promise<Tag> {
|
|
@@ -36,6 +32,10 @@ export class Tag {
|
|
|
36
32
|
return this.value.equals(other.value);
|
|
37
33
|
}
|
|
38
34
|
|
|
35
|
+
static random(): Tag {
|
|
36
|
+
return new Tag(Fr.random());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
39
|
static get schema(): ZodFor<Tag> {
|
|
40
40
|
return schemas.Fr.transform((fr: Fr) => new Tag(fr));
|
|
41
41
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
BlockNumber,
|
|
3
|
+
BlockProposalHash,
|
|
4
|
+
type CheckpointNumber,
|
|
5
|
+
IndexWithinCheckpoint,
|
|
6
|
+
SlotNumber,
|
|
7
|
+
} from '@aztec/foundation/branded-types';
|
|
8
|
+
import type { BaseBuffer32 } from '@aztec/foundation/buffer';
|
|
3
9
|
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
4
|
-
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
5
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
11
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
12
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
13
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
14
|
|
|
15
|
+
import type { TypedDataDefinition } from 'viem';
|
|
16
|
+
|
|
10
17
|
import type { L2Block } from '../block/l2_block.js';
|
|
11
18
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
12
19
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
@@ -16,18 +23,20 @@ import { TxHash } from '../tx/index.js';
|
|
|
16
23
|
import type { Tx } from '../tx/tx.js';
|
|
17
24
|
import { Gossipable } from './gossipable.js';
|
|
18
25
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
type CoordinationSignatureContext,
|
|
27
|
+
type CoordinationSignatureType,
|
|
28
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
29
|
+
type Signable,
|
|
30
|
+
coordinationSignatureContextEquals,
|
|
31
|
+
getCoordinationSignatureTypedData,
|
|
32
|
+
readCoordinationSignatureContext,
|
|
33
|
+
recoverCoordinationSigner,
|
|
34
|
+
serializeCoordinationSignatureContext,
|
|
22
35
|
} from './signature_utils.js';
|
|
23
36
|
import { SignedTxs } from './signed_txs.js';
|
|
24
37
|
import { TopicType } from './topic_type.js';
|
|
25
38
|
|
|
26
|
-
export
|
|
27
|
-
constructor(hash: Buffer) {
|
|
28
|
-
super(hash);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
39
|
+
export type { BlockProposalHash } from '@aztec/foundation/branded-types';
|
|
31
40
|
|
|
32
41
|
export type BlockProposalOptions = {
|
|
33
42
|
/**
|
|
@@ -47,10 +56,12 @@ export type BlockProposalOptions = {
|
|
|
47
56
|
* to be included in a block within a checkpoint. This is used for non-last blocks in a slot.
|
|
48
57
|
* The last block is sent as part of a CheckpointProposal.
|
|
49
58
|
*/
|
|
50
|
-
export class BlockProposal extends Gossipable {
|
|
59
|
+
export class BlockProposal extends Gossipable implements Signable {
|
|
51
60
|
static override p2pTopic = TopicType.block_proposal;
|
|
52
61
|
|
|
53
|
-
|
|
62
|
+
readonly primaryType: CoordinationSignatureType = 'BlockProposal';
|
|
63
|
+
|
|
64
|
+
private cachedSender: EthAddress | undefined | null = undefined;
|
|
54
65
|
|
|
55
66
|
constructor(
|
|
56
67
|
/** The per-block header containing block state and global variables */
|
|
@@ -71,14 +82,17 @@ export class BlockProposal extends Gossipable {
|
|
|
71
82
|
/** The proposer's signature over the block data */
|
|
72
83
|
public readonly signature: Signature,
|
|
73
84
|
|
|
85
|
+
/** The signing domain (chainId + rollupAddress) the signature is bound to */
|
|
86
|
+
public readonly signatureContext: CoordinationSignatureContext,
|
|
87
|
+
|
|
74
88
|
/** The signed transactions in the block (optional, for DA guarantees) */
|
|
75
89
|
public readonly signedTxs?: SignedTxs,
|
|
76
90
|
) {
|
|
77
91
|
super();
|
|
78
92
|
}
|
|
79
93
|
|
|
80
|
-
override generateP2PMessageIdentifier(): Promise<
|
|
81
|
-
return Promise.resolve(
|
|
94
|
+
override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
|
|
95
|
+
return Promise.resolve(BlockProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
get archive(): Fr {
|
|
@@ -112,9 +126,8 @@ export class BlockProposal extends Gossipable {
|
|
|
112
126
|
* Get the payload to sign for this block proposal.
|
|
113
127
|
* The signature is over: blockHeader + indexWithinCheckpoint + inHash + archiveRoot + txHashes
|
|
114
128
|
*/
|
|
115
|
-
getPayloadToSign(
|
|
129
|
+
getPayloadToSign(): Buffer {
|
|
116
130
|
return serializeToBuffer([
|
|
117
|
-
domainSeparator,
|
|
118
131
|
this.blockHeader,
|
|
119
132
|
this.indexWithinCheckpoint,
|
|
120
133
|
this.inHash,
|
|
@@ -126,12 +139,15 @@ export class BlockProposal extends Gossipable {
|
|
|
126
139
|
|
|
127
140
|
static async createProposalFromSigner(
|
|
128
141
|
blockHeader: BlockHeader,
|
|
142
|
+
checkpointNumber: CheckpointNumber,
|
|
129
143
|
indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
130
144
|
inHash: Fr,
|
|
131
145
|
archiveRoot: Fr,
|
|
132
146
|
txHashes: TxHash[],
|
|
133
147
|
txs: Tx[] | undefined,
|
|
134
|
-
|
|
148
|
+
signatureContext: CoordinationSignatureContext,
|
|
149
|
+
proposalSigner: (typedData: TypedDataDefinition, context: SigningContext) => Promise<Signature>,
|
|
150
|
+
txsSigner?: (typedData: TypedDataDefinition, context: SigningContext) => Promise<Signature>,
|
|
135
151
|
): Promise<BlockProposal> {
|
|
136
152
|
// Create a temporary proposal to get the payload to sign
|
|
137
153
|
const tempProposal = new BlockProposal(
|
|
@@ -141,57 +157,76 @@ export class BlockProposal extends Gossipable {
|
|
|
141
157
|
archiveRoot,
|
|
142
158
|
txHashes,
|
|
143
159
|
Signature.empty(),
|
|
160
|
+
signatureContext,
|
|
144
161
|
);
|
|
145
162
|
|
|
146
163
|
// Create the block signing context
|
|
147
164
|
const blockContext: SigningContext = {
|
|
148
165
|
slot: blockHeader.globalVariables.slotNumber,
|
|
149
166
|
blockNumber: blockHeader.globalVariables.blockNumber,
|
|
167
|
+
checkpointNumber,
|
|
150
168
|
blockIndexWithinCheckpoint: indexWithinCheckpoint,
|
|
151
169
|
dutyType: DutyType.BLOCK_PROPOSAL,
|
|
152
170
|
};
|
|
153
171
|
|
|
154
|
-
const
|
|
155
|
-
const sig = await
|
|
172
|
+
const typedData = getCoordinationSignatureTypedData(tempProposal);
|
|
173
|
+
const sig = await proposalSigner(typedData, blockContext);
|
|
156
174
|
|
|
157
175
|
// If txs are provided, sign them as well
|
|
158
176
|
let signedTxs: SignedTxs | undefined;
|
|
159
177
|
if (txs) {
|
|
160
178
|
const txsSigningContext: SigningContext = { dutyType: DutyType.TXS };
|
|
161
|
-
|
|
162
|
-
|
|
179
|
+
if (!txsSigner) {
|
|
180
|
+
throw new Error('signed_txs requires a typed-data signer');
|
|
181
|
+
}
|
|
182
|
+
signedTxs = await SignedTxs.createFromSigner(txs, signatureContext, typedData =>
|
|
183
|
+
txsSigner(typedData, txsSigningContext),
|
|
184
|
+
);
|
|
163
185
|
}
|
|
164
186
|
|
|
165
|
-
return new BlockProposal(
|
|
187
|
+
return new BlockProposal(
|
|
188
|
+
blockHeader,
|
|
189
|
+
indexWithinCheckpoint,
|
|
190
|
+
inHash,
|
|
191
|
+
archiveRoot,
|
|
192
|
+
txHashes,
|
|
193
|
+
sig,
|
|
194
|
+
signatureContext,
|
|
195
|
+
signedTxs,
|
|
196
|
+
);
|
|
166
197
|
}
|
|
167
198
|
|
|
168
199
|
/**
|
|
169
200
|
* Lazily evaluate the sender of the proposal; result is cached.
|
|
170
|
-
* If there's signedTxs, also verifies
|
|
171
|
-
*
|
|
201
|
+
* If there's signedTxs, also verifies that its signing domain matches this proposal's and
|
|
202
|
+
* that the signedTxs sender matches the block proposal sender. This prevents a proposer
|
|
203
|
+
* from wrapping a foreign-chain SignedTxs bundle inside a local-chain proposal.
|
|
204
|
+
* @returns The sender address, or undefined if signature recovery fails or inner/outer mismatch
|
|
172
205
|
*/
|
|
173
206
|
getSender(): EthAddress | undefined {
|
|
174
|
-
if (
|
|
175
|
-
const
|
|
176
|
-
const blockSender = tryRecoverAddress(hashed, this.signature);
|
|
207
|
+
if (this.cachedSender === undefined) {
|
|
208
|
+
const blockSender = recoverCoordinationSigner(this, this.signature);
|
|
177
209
|
|
|
178
|
-
// If there's signedTxs, verify the sender matches
|
|
179
210
|
if (blockSender && this.signedTxs) {
|
|
211
|
+
if (!coordinationSignatureContextEquals(this.signedTxs.signatureContext, this.signatureContext)) {
|
|
212
|
+
this.cachedSender = null;
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
180
215
|
const txsSender = this.signedTxs.getSender();
|
|
181
216
|
if (!txsSender || !txsSender.equals(blockSender)) {
|
|
182
|
-
|
|
217
|
+
this.cachedSender = null;
|
|
218
|
+
return undefined;
|
|
183
219
|
}
|
|
184
220
|
}
|
|
185
221
|
|
|
186
|
-
|
|
187
|
-
this.sender = blockSender;
|
|
222
|
+
this.cachedSender = blockSender ?? null;
|
|
188
223
|
}
|
|
189
224
|
|
|
190
|
-
return this.
|
|
225
|
+
return this.cachedSender ?? undefined;
|
|
191
226
|
}
|
|
192
227
|
|
|
193
228
|
getPayload() {
|
|
194
|
-
return this.getPayloadToSign(
|
|
229
|
+
return this.getPayloadToSign();
|
|
195
230
|
}
|
|
196
231
|
|
|
197
232
|
toBuffer(): Buffer {
|
|
@@ -201,6 +236,7 @@ export class BlockProposal extends Gossipable {
|
|
|
201
236
|
this.inHash,
|
|
202
237
|
this.archiveRoot,
|
|
203
238
|
this.signature,
|
|
239
|
+
serializeCoordinationSignatureContext(this.signatureContext),
|
|
204
240
|
this.txHashes.length,
|
|
205
241
|
this.txHashes,
|
|
206
242
|
];
|
|
@@ -221,6 +257,7 @@ export class BlockProposal extends Gossipable {
|
|
|
221
257
|
const inHash = reader.readObject(Fr);
|
|
222
258
|
const archiveRoot = reader.readObject(Fr);
|
|
223
259
|
const signature = reader.readObject(Signature);
|
|
260
|
+
const signatureContext = readCoordinationSignatureContext(reader);
|
|
224
261
|
const txHashCount = reader.readNumber();
|
|
225
262
|
if (txHashCount > MAX_TXS_PER_BLOCK) {
|
|
226
263
|
throw new Error(`txHashes count ${txHashCount} exceeds maximum ${MAX_TXS_PER_BLOCK}`);
|
|
@@ -238,12 +275,21 @@ export class BlockProposal extends Gossipable {
|
|
|
238
275
|
archiveRoot,
|
|
239
276
|
txHashes,
|
|
240
277
|
signature,
|
|
278
|
+
signatureContext,
|
|
241
279
|
signedTxs,
|
|
242
280
|
);
|
|
243
281
|
}
|
|
244
282
|
}
|
|
245
283
|
|
|
246
|
-
return new BlockProposal(
|
|
284
|
+
return new BlockProposal(
|
|
285
|
+
blockHeader,
|
|
286
|
+
indexWithinCheckpoint,
|
|
287
|
+
inHash,
|
|
288
|
+
archiveRoot,
|
|
289
|
+
txHashes,
|
|
290
|
+
signature,
|
|
291
|
+
signatureContext,
|
|
292
|
+
);
|
|
247
293
|
}
|
|
248
294
|
|
|
249
295
|
getSize(): number {
|
|
@@ -253,6 +299,8 @@ export class BlockProposal extends Gossipable {
|
|
|
253
299
|
this.inHash.size +
|
|
254
300
|
this.archiveRoot.size +
|
|
255
301
|
this.signature.getSize() +
|
|
302
|
+
4 /* chainId */ +
|
|
303
|
+
20 /* rollupAddress */ +
|
|
256
304
|
4 /* txHashes.length */ +
|
|
257
305
|
this.txHashes.length * TxHash.SIZE +
|
|
258
306
|
4 /* hasSignedTxs flag */ +
|
|
@@ -261,7 +309,15 @@ export class BlockProposal extends Gossipable {
|
|
|
261
309
|
}
|
|
262
310
|
|
|
263
311
|
static empty(): BlockProposal {
|
|
264
|
-
return new BlockProposal(
|
|
312
|
+
return new BlockProposal(
|
|
313
|
+
BlockHeader.empty(),
|
|
314
|
+
IndexWithinCheckpoint(0),
|
|
315
|
+
Fr.ZERO,
|
|
316
|
+
Fr.ZERO,
|
|
317
|
+
[],
|
|
318
|
+
Signature.empty(),
|
|
319
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
320
|
+
);
|
|
265
321
|
}
|
|
266
322
|
|
|
267
323
|
static random(): BlockProposal {
|
|
@@ -272,6 +328,7 @@ export class BlockProposal extends Gossipable {
|
|
|
272
328
|
Fr.random(),
|
|
273
329
|
[TxHash.random(), TxHash.random()],
|
|
274
330
|
Signature.random(),
|
|
331
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
275
332
|
);
|
|
276
333
|
}
|
|
277
334
|
|
|
@@ -283,6 +340,8 @@ export class BlockProposal extends Gossipable {
|
|
|
283
340
|
archiveRoot: this.archiveRoot.toString(),
|
|
284
341
|
signature: this.signature.toString(),
|
|
285
342
|
txHashes: this.txHashes.map(h => h.toString()),
|
|
343
|
+
chainId: this.signatureContext.chainId,
|
|
344
|
+
rollupAddress: this.signatureContext.rollupAddress.toString(),
|
|
286
345
|
};
|
|
287
346
|
}
|
|
288
347
|
|
|
@@ -308,6 +367,7 @@ export class BlockProposal extends Gossipable {
|
|
|
308
367
|
this.archiveRoot,
|
|
309
368
|
this.txHashes,
|
|
310
369
|
this.signature,
|
|
370
|
+
this.signatureContext,
|
|
311
371
|
);
|
|
312
372
|
}
|
|
313
373
|
}
|