@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
|
@@ -1,37 +1,122 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
2
|
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
3
|
-
import {
|
|
3
|
+
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
4
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
5
|
+
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
6
|
+
import { type BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { type TypedDataDefinition, hashTypedData } from 'viem';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
|
|
11
|
+
import type { ZodFor } from '../schemas/index.js';
|
|
12
|
+
|
|
13
|
+
export type CoordinationSignatureType =
|
|
14
|
+
| 'BlockProposal'
|
|
15
|
+
| 'CheckpointProposal'
|
|
16
|
+
| 'CheckpointAttestation'
|
|
17
|
+
| 'AttestationsAndSigners'
|
|
18
|
+
| 'SignedTxs';
|
|
19
|
+
|
|
20
|
+
export type CoordinationSignatureContext = {
|
|
21
|
+
chainId: number;
|
|
22
|
+
rollupAddress: EthAddress;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const EMPTY_COORDINATION_SIGNATURE_CONTEXT: CoordinationSignatureContext = {
|
|
26
|
+
chainId: 0,
|
|
27
|
+
rollupAddress: EthAddress.ZERO,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const coordinationSignatureContextSchema: ZodFor<CoordinationSignatureContext> = z.object({
|
|
31
|
+
chainId: z.number(),
|
|
32
|
+
rollupAddress: EthAddress.schema,
|
|
33
|
+
});
|
|
12
34
|
|
|
13
35
|
export interface Signable {
|
|
14
|
-
|
|
36
|
+
readonly primaryType: CoordinationSignatureType;
|
|
37
|
+
readonly signatureContext: CoordinationSignatureContext;
|
|
38
|
+
getPayloadToSign(): Buffer;
|
|
15
39
|
}
|
|
16
40
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
41
|
+
export function coordinationSignatureContextEquals(
|
|
42
|
+
a: CoordinationSignatureContext,
|
|
43
|
+
b: CoordinationSignatureContext,
|
|
44
|
+
): boolean {
|
|
45
|
+
return a.chainId === b.chainId && a.rollupAddress.equals(b.rollupAddress);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function serializeCoordinationSignatureContext(ctx: CoordinationSignatureContext): Buffer {
|
|
49
|
+
return serializeToBuffer([ctx.chainId, ctx.rollupAddress]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function readCoordinationSignatureContext(reader: BufferReader): CoordinationSignatureContext {
|
|
53
|
+
const chainId = reader.readNumber();
|
|
54
|
+
const rollupAddress = reader.readObject(EthAddress);
|
|
55
|
+
return { chainId, rollupAddress };
|
|
24
56
|
}
|
|
25
57
|
|
|
26
58
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
59
|
+
* Returns true if the signable carries a context matching the node's expected context.
|
|
60
|
+
* Use this at the P2P ingress boundary to reject foreign-chain messages cheaply before
|
|
61
|
+
* performing any signature recovery.
|
|
30
62
|
*/
|
|
31
|
-
export function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
63
|
+
export function hasValidSignatureContext(signable: Signable, expected: CoordinationSignatureContext): boolean {
|
|
64
|
+
return coordinationSignatureContextEquals(signable.signatureContext, expected);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const COORDINATION_SIGNATURE_NAME = 'Aztec Rollup';
|
|
68
|
+
const COORDINATION_SIGNATURE_VERSION = '1';
|
|
69
|
+
|
|
70
|
+
const EIP712_DOMAIN_FIELDS = [
|
|
71
|
+
{ name: 'name', type: 'string' },
|
|
72
|
+
{ name: 'version', type: 'string' },
|
|
73
|
+
{ name: 'chainId', type: 'uint256' },
|
|
74
|
+
{ name: 'verifyingContract', type: 'address' },
|
|
75
|
+
] as const;
|
|
76
|
+
|
|
77
|
+
const COORDINATION_SIGNATURE_TYPES = {
|
|
78
|
+
EIP712Domain: EIP712_DOMAIN_FIELDS,
|
|
79
|
+
BlockProposal: [{ name: 'payloadHash', type: 'bytes32' }],
|
|
80
|
+
CheckpointProposal: [{ name: 'payloadHash', type: 'bytes32' }],
|
|
81
|
+
CheckpointAttestation: [{ name: 'payloadHash', type: 'bytes32' }],
|
|
82
|
+
AttestationsAndSigners: [{ name: 'payloadHash', type: 'bytes32' }],
|
|
83
|
+
SignedTxs: [{ name: 'payloadHash', type: 'bytes32' }],
|
|
84
|
+
} as const;
|
|
85
|
+
|
|
86
|
+
export function getCoordinationSignatureTypedDataForPayloadHash(
|
|
87
|
+
payloadHash: Buffer32,
|
|
88
|
+
type: CoordinationSignatureType,
|
|
89
|
+
context: CoordinationSignatureContext,
|
|
90
|
+
): TypedDataDefinition {
|
|
91
|
+
return {
|
|
92
|
+
domain: {
|
|
93
|
+
name: COORDINATION_SIGNATURE_NAME,
|
|
94
|
+
version: COORDINATION_SIGNATURE_VERSION,
|
|
95
|
+
chainId: context.chainId,
|
|
96
|
+
verifyingContract: context.rollupAddress.toString() as `0x${string}`,
|
|
97
|
+
},
|
|
98
|
+
types: COORDINATION_SIGNATURE_TYPES,
|
|
99
|
+
primaryType: type,
|
|
100
|
+
message: {
|
|
101
|
+
payloadHash: payloadHash.toString() as `0x${string}`,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function getCoordinationSignatureTypedData(signable: Signable): TypedDataDefinition {
|
|
107
|
+
const payloadHash = getHashedSignaturePayload(signable);
|
|
108
|
+
return getCoordinationSignatureTypedDataForPayloadHash(payloadHash, signable.primaryType, signable.signatureContext);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function getHashedSignaturePayloadTypedData(signable: Signable): Buffer32 {
|
|
112
|
+
return Buffer32.fromString(hashTypedData(getCoordinationSignatureTypedData(signable)));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function recoverCoordinationSigner(signable: Signable, signature: Signature): EthAddress | undefined {
|
|
116
|
+
const digest = getHashedSignaturePayloadTypedData(signable);
|
|
117
|
+
return tryRecoverAddress(digest, signature, { allowYParityAsV: true });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function getHashedSignaturePayload(s: Signable): Buffer32 {
|
|
121
|
+
return Buffer32.fromBuffer(keccak256(s.getPayloadToSign()));
|
|
37
122
|
}
|
package/src/p2p/signed_txs.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
-
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
2
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
3
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
4
|
|
|
5
|
+
import type { TypedDataDefinition } from 'viem';
|
|
6
|
+
|
|
7
7
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
8
8
|
import { Tx } from '../tx/tx.js';
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
type CoordinationSignatureContext,
|
|
11
|
+
type CoordinationSignatureType,
|
|
12
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
13
|
+
type Signable,
|
|
14
|
+
getCoordinationSignatureTypedData,
|
|
15
|
+
readCoordinationSignatureContext,
|
|
16
|
+
recoverCoordinationSigner,
|
|
17
|
+
serializeCoordinationSignatureContext,
|
|
13
18
|
} from './signature_utils.js';
|
|
14
19
|
|
|
15
20
|
/**
|
|
@@ -17,50 +22,56 @@ import {
|
|
|
17
22
|
* The signature is over the transaction objects themselves, providing
|
|
18
23
|
* data availability guarantees beyond just the transaction hashes.
|
|
19
24
|
*/
|
|
20
|
-
export class SignedTxs {
|
|
21
|
-
|
|
25
|
+
export class SignedTxs implements Signable {
|
|
26
|
+
readonly primaryType: CoordinationSignatureType = 'SignedTxs';
|
|
27
|
+
|
|
28
|
+
private cachedSender: EthAddress | undefined | null = undefined;
|
|
22
29
|
|
|
23
30
|
constructor(
|
|
24
31
|
/** The transactions */
|
|
25
32
|
public readonly txs: Tx[],
|
|
26
33
|
/** The proposer's signature over the transactions */
|
|
27
34
|
public readonly signature: Signature,
|
|
35
|
+
/** The signing domain (chainId + rollupAddress) the signature is bound to */
|
|
36
|
+
public readonly signatureContext: CoordinationSignatureContext,
|
|
28
37
|
) {}
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
|
|
34
|
-
return serializeToBuffer([domainSeparator, this.txs.length, this.txs]);
|
|
39
|
+
getPayloadToSign(): Buffer {
|
|
40
|
+
return serializeToBuffer([this.txs.length, this.txs]);
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
/**
|
|
38
|
-
* Lazily evaluate the sender of the signed txs; result is cached
|
|
44
|
+
* Lazily evaluate the sender of the signed txs; result is cached.
|
|
39
45
|
* @returns The sender address, or undefined if signature recovery fails
|
|
40
46
|
*/
|
|
41
47
|
getSender(): EthAddress | undefined {
|
|
42
|
-
if (
|
|
43
|
-
|
|
44
|
-
this.sender = tryRecoverAddress(hashed, this.signature);
|
|
48
|
+
if (this.cachedSender === undefined) {
|
|
49
|
+
this.cachedSender = recoverCoordinationSigner(this, this.signature) ?? null;
|
|
45
50
|
}
|
|
46
|
-
return this.
|
|
51
|
+
return this.cachedSender ?? undefined;
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
/**
|
|
50
|
-
* Create SignedTxs from a signer function
|
|
55
|
+
* Create SignedTxs from a typed-data signer function
|
|
51
56
|
*/
|
|
52
57
|
static async createFromSigner(
|
|
53
58
|
txs: Tx[],
|
|
54
|
-
|
|
59
|
+
signatureContext: CoordinationSignatureContext,
|
|
60
|
+
typedDataSigner: (typedData: TypedDataDefinition) => Promise<Signature>,
|
|
55
61
|
): Promise<SignedTxs> {
|
|
56
|
-
const tempSignedTxs = new SignedTxs(txs, Signature.empty());
|
|
57
|
-
const
|
|
58
|
-
const signature = await
|
|
59
|
-
return new SignedTxs(txs, signature);
|
|
62
|
+
const tempSignedTxs = new SignedTxs(txs, Signature.empty(), signatureContext);
|
|
63
|
+
const typedData = getCoordinationSignatureTypedData(tempSignedTxs);
|
|
64
|
+
const signature = await typedDataSigner(typedData);
|
|
65
|
+
return new SignedTxs(txs, signature, signatureContext);
|
|
60
66
|
}
|
|
61
67
|
|
|
62
68
|
toBuffer(): Buffer {
|
|
63
|
-
return serializeToBuffer([
|
|
69
|
+
return serializeToBuffer([
|
|
70
|
+
this.txs.length,
|
|
71
|
+
this.txs,
|
|
72
|
+
this.signature,
|
|
73
|
+
serializeCoordinationSignatureContext(this.signatureContext),
|
|
74
|
+
]);
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
static fromBuffer(buf: Buffer | BufferReader): SignedTxs {
|
|
@@ -71,18 +82,25 @@ export class SignedTxs {
|
|
|
71
82
|
}
|
|
72
83
|
const txs = reader.readArray(txCount, Tx);
|
|
73
84
|
const signature = reader.readObject(Signature);
|
|
74
|
-
|
|
85
|
+
const signatureContext = readCoordinationSignatureContext(reader);
|
|
86
|
+
return new SignedTxs(txs, signature, signatureContext);
|
|
75
87
|
}
|
|
76
88
|
|
|
77
89
|
getSize(): number {
|
|
78
|
-
return
|
|
90
|
+
return (
|
|
91
|
+
4 /* txs.length */ +
|
|
92
|
+
this.txs.reduce((acc, tx) => acc + tx.getSize(), 0) +
|
|
93
|
+
this.signature.getSize() +
|
|
94
|
+
4 /* chainId */ +
|
|
95
|
+
20 /* rollupAddress */
|
|
96
|
+
);
|
|
79
97
|
}
|
|
80
98
|
|
|
81
99
|
static empty(): SignedTxs {
|
|
82
|
-
return new SignedTxs([], Signature.empty());
|
|
100
|
+
return new SignedTxs([], Signature.empty(), EMPTY_COORDINATION_SIGNATURE_CONTEXT);
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
static random(): SignedTxs {
|
|
86
|
-
return new SignedTxs([Tx.random(), Tx.random()], Signature.random());
|
|
104
|
+
return new SignedTxs([Tx.random(), Tx.random()], Signature.random(), EMPTY_COORDINATION_SIGNATURE_CONTEXT);
|
|
87
105
|
}
|
|
88
106
|
}
|
|
@@ -10,9 +10,11 @@ export class ParityBasePrivateInputs {
|
|
|
10
10
|
public readonly msgs: Tuple<Fr, typeof NUM_MSGS_PER_BASE_PARITY>,
|
|
11
11
|
/** Root of the VK tree */
|
|
12
12
|
public readonly vkTreeRoot: Fr,
|
|
13
|
+
/** Prover identity committed to by the circuit, for sybil protection. */
|
|
14
|
+
public readonly proverId: Fr,
|
|
13
15
|
) {}
|
|
14
16
|
|
|
15
|
-
public static fromSlice(array: Fr[], index: number, vkTreeRoot: Fr): ParityBasePrivateInputs {
|
|
17
|
+
public static fromSlice(array: Fr[], index: number, vkTreeRoot: Fr, proverId: Fr): ParityBasePrivateInputs {
|
|
16
18
|
// Can't use Tuple<Fr, typeof NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP> due to length
|
|
17
19
|
if (array.length !== NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP) {
|
|
18
20
|
throw new Error(
|
|
@@ -22,12 +24,12 @@ export class ParityBasePrivateInputs {
|
|
|
22
24
|
const start = index * NUM_MSGS_PER_BASE_PARITY;
|
|
23
25
|
const end = start + NUM_MSGS_PER_BASE_PARITY;
|
|
24
26
|
const msgs = array.slice(start, end);
|
|
25
|
-
return new ParityBasePrivateInputs(msgs as Tuple<Fr, typeof NUM_MSGS_PER_BASE_PARITY>, vkTreeRoot);
|
|
27
|
+
return new ParityBasePrivateInputs(msgs as Tuple<Fr, typeof NUM_MSGS_PER_BASE_PARITY>, vkTreeRoot, proverId);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/** Serializes the inputs to a buffer. */
|
|
29
31
|
toBuffer() {
|
|
30
|
-
return serializeToBuffer(this.msgs, this.vkTreeRoot);
|
|
32
|
+
return serializeToBuffer(this.msgs, this.vkTreeRoot, this.proverId);
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
/** Serializes the inputs to a hex string. */
|
|
@@ -41,7 +43,11 @@ export class ParityBasePrivateInputs {
|
|
|
41
43
|
*/
|
|
42
44
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
43
45
|
const reader = BufferReader.asReader(buffer);
|
|
44
|
-
return new ParityBasePrivateInputs(
|
|
46
|
+
return new ParityBasePrivateInputs(
|
|
47
|
+
reader.readArray(NUM_MSGS_PER_BASE_PARITY, Fr),
|
|
48
|
+
Fr.fromBuffer(reader),
|
|
49
|
+
Fr.fromBuffer(reader),
|
|
50
|
+
);
|
|
45
51
|
}
|
|
46
52
|
|
|
47
53
|
/**
|
|
@@ -12,6 +12,8 @@ export class ParityPublicInputs {
|
|
|
12
12
|
public convertedRoot: Fr,
|
|
13
13
|
/** Root of the VK tree */
|
|
14
14
|
public vkTreeRoot: Fr,
|
|
15
|
+
/** Prover identity committed to by the circuit, for sybil protection. */
|
|
16
|
+
public proverId: Fr,
|
|
15
17
|
) {
|
|
16
18
|
if (shaRoot.toBuffer()[0] != 0) {
|
|
17
19
|
throw new Error(`shaRoot buffer must be 31 bytes. Got 32 bytes`);
|
|
@@ -54,7 +56,7 @@ export class ParityPublicInputs {
|
|
|
54
56
|
* @returns The instance fields.
|
|
55
57
|
*/
|
|
56
58
|
static getFields(fields: FieldsOf<ParityPublicInputs>) {
|
|
57
|
-
return [fields.shaRoot, fields.convertedRoot, fields.vkTreeRoot] as const;
|
|
59
|
+
return [fields.shaRoot, fields.convertedRoot, fields.vkTreeRoot, fields.proverId] as const;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
/**
|
|
@@ -64,7 +66,12 @@ export class ParityPublicInputs {
|
|
|
64
66
|
*/
|
|
65
67
|
static fromBuffer(buffer: Buffer | BufferReader) {
|
|
66
68
|
const reader = BufferReader.asReader(buffer);
|
|
67
|
-
return new ParityPublicInputs(
|
|
69
|
+
return new ParityPublicInputs(
|
|
70
|
+
reader.readObject(Fr),
|
|
71
|
+
reader.readObject(Fr),
|
|
72
|
+
Fr.fromBuffer(reader),
|
|
73
|
+
Fr.fromBuffer(reader),
|
|
74
|
+
);
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
/**
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { DomainSeparator } from '@aztec/constants';
|
|
2
|
+
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
1
3
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
-
import {
|
|
4
|
+
import { computeUnbalancedMerkleTreeRootAsync } from '@aztec/foundation/trees';
|
|
3
5
|
|
|
4
6
|
import type { BlockHeader } from '../tx/block_header.js';
|
|
5
7
|
|
|
@@ -7,6 +9,13 @@ export async function computeBlockHeadersHash(blockHeaders: BlockHeader[]): Prom
|
|
|
7
9
|
const blockHeaderHashes = await Promise.all(blockHeaders.map(header => header.hash()));
|
|
8
10
|
// Must match the implementation in merge_block_rollups.nr, with the **unbalanced** rollup structure
|
|
9
11
|
// (see validate_consecutive_block_rollups.nr > assert_rollups_filled_greedily.nr).
|
|
10
|
-
const
|
|
12
|
+
const blockHeadersHasher = async (left: Uint8Array, right: Uint8Array) =>
|
|
13
|
+
(
|
|
14
|
+
await poseidon2HashWithSeparator([Buffer.from(left), Buffer.from(right)], DomainSeparator.BLOCK_HEADERS_HASH)
|
|
15
|
+
).toBuffer() as Buffer<ArrayBuffer>;
|
|
16
|
+
const blockHeadersHash = await computeUnbalancedMerkleTreeRootAsync(
|
|
17
|
+
blockHeaderHashes.map(hash => hash.toBuffer()),
|
|
18
|
+
blockHeadersHasher,
|
|
19
|
+
);
|
|
11
20
|
return Fr.fromBuffer(blockHeadersHash);
|
|
12
21
|
}
|
package/src/slashing/index.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import { times } from '@aztec/foundation/collection';
|
|
2
1
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
2
|
import { BufferReader, bigintToUInt64BE, bigintToUInt128BE, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
4
3
|
|
|
5
|
-
import type {
|
|
6
|
-
Offense,
|
|
7
|
-
OffenseType,
|
|
8
|
-
SlashPayload,
|
|
9
|
-
SlashPayloadRound,
|
|
10
|
-
ValidatorSlash,
|
|
11
|
-
ValidatorSlashOffense,
|
|
12
|
-
} from './types.js';
|
|
4
|
+
import type { Offense, OffenseType } from './types.js';
|
|
13
5
|
|
|
14
6
|
export function serializeOffense(offense: Offense): Buffer {
|
|
15
7
|
return serializeToBuffer(
|
|
@@ -29,75 +21,3 @@ export function deserializeOffense(buffer: Buffer): Offense {
|
|
|
29
21
|
|
|
30
22
|
return { validator, amount, offenseType: offense, epochOrSlot };
|
|
31
23
|
}
|
|
32
|
-
|
|
33
|
-
function serializeValidatorSlashOffense(offense: ValidatorSlashOffense): Buffer {
|
|
34
|
-
return serializeToBuffer(bigintToUInt64BE(offense.epochOrSlot), offense.offenseType);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function deserializeValidatorSlashOffense(buffer: Buffer | BufferReader): ValidatorSlashOffense {
|
|
38
|
-
const reader = BufferReader.asReader(buffer);
|
|
39
|
-
return {
|
|
40
|
-
epochOrSlot: reader.readUInt64(),
|
|
41
|
-
offenseType: reader.readNumber() as OffenseType,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function serializeValidatorSlash(slash: ValidatorSlash): Buffer {
|
|
46
|
-
return serializeToBuffer(
|
|
47
|
-
slash.validator,
|
|
48
|
-
bigintToUInt128BE(slash.amount),
|
|
49
|
-
slash.offenses.length,
|
|
50
|
-
slash.offenses.map(serializeValidatorSlashOffense),
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function deserializeValidatorSlash(buffer: Buffer | BufferReader): ValidatorSlash {
|
|
55
|
-
const reader = BufferReader.asReader(buffer);
|
|
56
|
-
const validator = reader.readObject(EthAddress);
|
|
57
|
-
const amount = reader.readUInt128();
|
|
58
|
-
const offensesCount = reader.readNumber();
|
|
59
|
-
const offenses = times(offensesCount, () => deserializeValidatorSlashOffense(reader));
|
|
60
|
-
|
|
61
|
-
return { validator, amount, offenses };
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function serializeSlashPayload(payload: SlashPayload): Buffer {
|
|
65
|
-
return serializeToBuffer(
|
|
66
|
-
payload.address,
|
|
67
|
-
payload.slashes.length,
|
|
68
|
-
payload.slashes.map(serializeValidatorSlash),
|
|
69
|
-
bigintToUInt64BE(payload.timestamp),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function deserializeSlashPayload(buffer: Buffer): SlashPayload {
|
|
74
|
-
const reader = BufferReader.asReader(buffer);
|
|
75
|
-
const address = reader.readObject(EthAddress);
|
|
76
|
-
const slashesCount = reader.readNumber();
|
|
77
|
-
const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
|
|
78
|
-
const timestamp = reader.readUInt64();
|
|
79
|
-
return { address, slashes, timestamp };
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function serializeSlashPayloadRound(payload: SlashPayloadRound): Buffer {
|
|
83
|
-
return serializeToBuffer(
|
|
84
|
-
payload.address,
|
|
85
|
-
payload.slashes.length,
|
|
86
|
-
payload.slashes.map(serializeValidatorSlash),
|
|
87
|
-
bigintToUInt64BE(payload.timestamp),
|
|
88
|
-
Number(payload.votes),
|
|
89
|
-
bigintToUInt64BE(payload.round),
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export function deserializeSlashPayloadRound(buffer: Buffer): SlashPayloadRound {
|
|
94
|
-
const reader = BufferReader.asReader(buffer);
|
|
95
|
-
const address = reader.readObject(EthAddress);
|
|
96
|
-
const slashesCount = reader.readNumber();
|
|
97
|
-
const slashes = times(slashesCount, () => deserializeValidatorSlash(reader));
|
|
98
|
-
const timestamp = reader.readUInt64();
|
|
99
|
-
const votes = BigInt(reader.readNumber());
|
|
100
|
-
const round = reader.readUInt64();
|
|
101
|
-
|
|
102
|
-
return { address, slashes, timestamp, votes, round };
|
|
103
|
-
}
|
package/src/slashing/types.ts
CHANGED
|
@@ -126,45 +126,13 @@ export type ValidatorSlash = {
|
|
|
126
126
|
offenses: ValidatorSlashOffense[];
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
export type SlashPayload = {
|
|
131
|
-
address: EthAddress;
|
|
132
|
-
slashes: ValidatorSlash[];
|
|
133
|
-
timestamp: bigint;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/** Slash payload with round information from empire slash proposer */
|
|
137
|
-
export type SlashPayloadRound = SlashPayload & { votes: bigint; round: bigint };
|
|
138
|
-
|
|
139
|
-
export const SlashPayloadRoundSchema = zodFor<SlashPayloadRound>()(
|
|
140
|
-
z.object({
|
|
141
|
-
address: schemas.EthAddress,
|
|
142
|
-
timestamp: schemas.BigInt,
|
|
143
|
-
votes: schemas.BigInt,
|
|
144
|
-
round: schemas.BigInt,
|
|
145
|
-
slashes: z.array(
|
|
146
|
-
z.object({
|
|
147
|
-
validator: schemas.EthAddress,
|
|
148
|
-
amount: schemas.BigInt,
|
|
149
|
-
offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
|
|
150
|
-
}),
|
|
151
|
-
),
|
|
152
|
-
}),
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
/** Votes for a validator slash in the consensus slash proposer */
|
|
129
|
+
/** Votes for a validator slash in the slashing proposer */
|
|
156
130
|
export type ValidatorSlashVote = number;
|
|
157
131
|
|
|
158
132
|
export type ProposerSlashAction =
|
|
159
|
-
/**
|
|
160
|
-
| { type: 'create-empire-payload'; data: ValidatorSlash[] }
|
|
161
|
-
/** Vote for a slashing payload on an empire-based slash proposer */
|
|
162
|
-
| { type: 'vote-empire-payload'; payload: EthAddress }
|
|
163
|
-
/** Execute a slashing payload on an empire-based slash proposer */
|
|
164
|
-
| { type: 'execute-empire-payload'; round: bigint }
|
|
165
|
-
/** Vote for offenses on a consensus slashing proposer */
|
|
133
|
+
/** Vote for offenses on the slashing proposer */
|
|
166
134
|
| { type: 'vote-offenses'; votes: ValidatorSlashVote[]; committees: EthAddress[][]; round: bigint }
|
|
167
|
-
/** Execute a slashing round on
|
|
135
|
+
/** Execute a slashing round on the slashing proposer */
|
|
168
136
|
| { type: 'execute-slash'; committees: EthAddress[][]; round: bigint };
|
|
169
137
|
|
|
170
138
|
export type ProposerSlashActionType = ProposerSlashAction['type'];
|
|
@@ -28,7 +28,7 @@ export function getSlashConsensusVotesFromOffenses(
|
|
|
28
28
|
targetCommitteeSize: number;
|
|
29
29
|
maxSlashedValidators?: number;
|
|
30
30
|
},
|
|
31
|
-
logger: Logger = createLogger('slasher:
|
|
31
|
+
logger: Logger = createLogger('slasher:votes'),
|
|
32
32
|
): ValidatorSlashVote[] {
|
|
33
33
|
const { slashingAmounts, targetCommitteeSize, maxSlashedValidators } = settings;
|
|
34
34
|
|
package/src/tests/factories.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED,
|
|
10
10
|
CHONK_PROOF_LENGTH,
|
|
11
11
|
CONTRACT_CLASS_LOG_SIZE_IN_FIELDS,
|
|
12
|
-
DomainSeparator,
|
|
13
12
|
L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
14
13
|
MAX_CHECKPOINTS_PER_EPOCH,
|
|
15
14
|
MAX_CONTRACT_CLASS_LOGS_PER_TX,
|
|
@@ -46,7 +45,6 @@ import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
|
|
|
46
45
|
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
47
46
|
import { compact } from '@aztec/foundation/collection';
|
|
48
47
|
import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
|
|
49
|
-
import { poseidon2HashWithSeparator } from '@aztec/foundation/crypto/poseidon';
|
|
50
48
|
import { SchnorrSignature } from '@aztec/foundation/crypto/schnorr';
|
|
51
49
|
import { sha256 } from '@aztec/foundation/crypto/sha256';
|
|
52
50
|
import { Fq, Fr } from '@aztec/foundation/curves/bn254';
|
|
@@ -95,6 +93,7 @@ import {
|
|
|
95
93
|
type PrivateFunction,
|
|
96
94
|
SerializableContractInstance,
|
|
97
95
|
computeContractClassId,
|
|
96
|
+
computePartialAddress,
|
|
98
97
|
computePublicBytecodeCommitment,
|
|
99
98
|
} from '../contract/index.js';
|
|
100
99
|
import { Gas, GasFees, GasSettings } from '../gas/index.js';
|
|
@@ -176,7 +175,7 @@ import { TxHash } from '../tx/tx_hash.js';
|
|
|
176
175
|
import { TxRequest } from '../tx/tx_request.js';
|
|
177
176
|
import { Vector } from '../types/index.js';
|
|
178
177
|
import { VkData } from '../vks/index.js';
|
|
179
|
-
import {
|
|
178
|
+
import { VerificationKeyAsFields, VerificationKeyData } from '../vks/verification_key.js';
|
|
180
179
|
|
|
181
180
|
/**
|
|
182
181
|
* Creates an arbitrary side effect object with the given seed.
|
|
@@ -232,7 +231,7 @@ export function makeTxContext(seed: number = 1): TxContext {
|
|
|
232
231
|
* Creates a default instance of gas settings. No seed value is used to ensure we allocate a sensible amount of gas for testing.
|
|
233
232
|
*/
|
|
234
233
|
export function makeGasSettings() {
|
|
235
|
-
return GasSettings.
|
|
234
|
+
return GasSettings.fallback({ maxFeesPerGas: new GasFees(10, 10) });
|
|
236
235
|
}
|
|
237
236
|
|
|
238
237
|
/**
|
|
@@ -573,14 +572,6 @@ export function makeVerificationKeyAsFields(size: number): VerificationKeyAsFiel
|
|
|
573
572
|
return VerificationKeyAsFields.makeFake(size);
|
|
574
573
|
}
|
|
575
574
|
|
|
576
|
-
/**
|
|
577
|
-
* Creates arbitrary/mocked verification key.
|
|
578
|
-
* @returns A verification key object
|
|
579
|
-
*/
|
|
580
|
-
export function makeVerificationKey(): VerificationKey {
|
|
581
|
-
return VerificationKey.makeFake();
|
|
582
|
-
}
|
|
583
|
-
|
|
584
575
|
/**
|
|
585
576
|
* Creates an arbitrary point in a curve.
|
|
586
577
|
* @param seed - Seed to generate the point values.
|
|
@@ -863,11 +854,16 @@ export function makeParityPublicInputs(seed = 0): ParityPublicInputs {
|
|
|
863
854
|
new Fr(BigInt(seed + 0x200)),
|
|
864
855
|
new Fr(BigInt(seed + 0x300)),
|
|
865
856
|
new Fr(BigInt(seed + 0x400)),
|
|
857
|
+
new Fr(BigInt(seed + 0x500)),
|
|
866
858
|
);
|
|
867
859
|
}
|
|
868
860
|
|
|
869
861
|
export function makeParityBasePrivateInputs(seed = 0): ParityBasePrivateInputs {
|
|
870
|
-
return new ParityBasePrivateInputs(
|
|
862
|
+
return new ParityBasePrivateInputs(
|
|
863
|
+
makeTuple(NUM_MSGS_PER_BASE_PARITY, fr, seed + 0x3000),
|
|
864
|
+
new Fr(seed + 0x4000),
|
|
865
|
+
new Fr(seed + 0x5000),
|
|
866
|
+
);
|
|
871
867
|
}
|
|
872
868
|
|
|
873
869
|
export function makeParityRootPrivateInputs(seed = 0) {
|
|
@@ -1253,14 +1249,12 @@ export async function makeContractInstanceFromClassId(
|
|
|
1253
1249
|
const deployer = overrides?.deployer ?? new AztecAddress(new Fr(seed + 2));
|
|
1254
1250
|
const publicKeys = overrides?.publicKeys ?? (await makePublicKeys(seed + 3));
|
|
1255
1251
|
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
DomainSeparator.PARTIAL_ADDRESS,
|
|
1263
|
-
);
|
|
1252
|
+
const partialAddress = await computePartialAddress({
|
|
1253
|
+
originalContractClassId: classId,
|
|
1254
|
+
salt,
|
|
1255
|
+
initializationHash,
|
|
1256
|
+
deployer,
|
|
1257
|
+
});
|
|
1264
1258
|
const address = await computeAddress(publicKeys, partialAddress);
|
|
1265
1259
|
return new SerializableContractInstance({
|
|
1266
1260
|
version: 1,
|