@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,7 +1,6 @@
|
|
|
1
|
-
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
-
import {
|
|
1
|
+
import { CheckpointAttestationHash, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { BaseBuffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
4
|
-
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
5
4
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
6
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
@@ -13,14 +12,10 @@ import type { ZodFor } from '../schemas/index.js';
|
|
|
13
12
|
import { CheckpointProposal } from './checkpoint_proposal.js';
|
|
14
13
|
import { ConsensusPayload } from './consensus_payload.js';
|
|
15
14
|
import { Gossipable } from './gossipable.js';
|
|
16
|
-
import {
|
|
15
|
+
import { type CoordinationSignatureContext, recoverCoordinationSigner } from './signature_utils.js';
|
|
17
16
|
import { TopicType } from './topic_type.js';
|
|
18
17
|
|
|
19
|
-
export
|
|
20
|
-
constructor(hash: Buffer) {
|
|
21
|
-
super(hash);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
18
|
+
export type { CheckpointAttestationHash } from '@aztec/foundation/branded-types';
|
|
24
19
|
|
|
25
20
|
/**
|
|
26
21
|
* CheckpointAttestation
|
|
@@ -31,8 +26,8 @@ export class CheckpointAttestationHash extends Buffer32 {
|
|
|
31
26
|
export class CheckpointAttestation extends Gossipable {
|
|
32
27
|
static override p2pTopic = TopicType.checkpoint_attestation;
|
|
33
28
|
|
|
34
|
-
private
|
|
35
|
-
private
|
|
29
|
+
private cachedSender: EthAddress | undefined | null = undefined;
|
|
30
|
+
private cachedProposer: EthAddress | undefined | null = undefined;
|
|
36
31
|
|
|
37
32
|
constructor(
|
|
38
33
|
/** The payload of the message, and what the signature is over */
|
|
@@ -57,8 +52,8 @@ export class CheckpointAttestation extends Gossipable {
|
|
|
57
52
|
.transform(obj => new CheckpointAttestation(obj.payload, obj.signature, obj.proposerSignature));
|
|
58
53
|
}
|
|
59
54
|
|
|
60
|
-
override generateP2PMessageIdentifier(): Promise<
|
|
61
|
-
return Promise.resolve(
|
|
55
|
+
override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
|
|
56
|
+
return Promise.resolve(CheckpointAttestationHash.fromBuffer(keccak256(this.signature.toBuffer())));
|
|
62
57
|
}
|
|
63
58
|
|
|
64
59
|
get archive(): Fr {
|
|
@@ -69,22 +64,19 @@ export class CheckpointAttestation extends Gossipable {
|
|
|
69
64
|
return this.payload.header.slotNumber;
|
|
70
65
|
}
|
|
71
66
|
|
|
67
|
+
get signatureContext(): CoordinationSignatureContext {
|
|
68
|
+
return this.payload.signatureContext;
|
|
69
|
+
}
|
|
70
|
+
|
|
72
71
|
/**
|
|
73
72
|
* Lazily evaluate and cache the signer of the attestation
|
|
74
73
|
* @returns The signer of the attestation, or undefined if signature recovery fails
|
|
75
74
|
*/
|
|
76
75
|
getSender(): EthAddress | undefined {
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
const hashed = getHashedSignaturePayloadEthSignedMessage(
|
|
80
|
-
this.payload,
|
|
81
|
-
SignatureDomainSeparator.checkpointAttestation,
|
|
82
|
-
);
|
|
83
|
-
// Cache the sender for later use
|
|
84
|
-
this.sender = tryRecoverAddress(hashed, this.signature);
|
|
76
|
+
if (this.cachedSender === undefined) {
|
|
77
|
+
this.cachedSender = recoverCoordinationSigner(this.payload, this.signature) ?? null;
|
|
85
78
|
}
|
|
86
|
-
|
|
87
|
-
return this.sender;
|
|
79
|
+
return this.cachedSender ?? undefined;
|
|
88
80
|
}
|
|
89
81
|
|
|
90
82
|
/**
|
|
@@ -92,7 +84,7 @@ export class CheckpointAttestation extends Gossipable {
|
|
|
92
84
|
* @returns The proposer of the checkpoint
|
|
93
85
|
*/
|
|
94
86
|
getProposer(): EthAddress | undefined {
|
|
95
|
-
if (
|
|
87
|
+
if (this.cachedProposer === undefined) {
|
|
96
88
|
// Create a temporary CheckpointProposal to recover the proposer address.
|
|
97
89
|
// We need to use CheckpointProposal because it has a different getPayloadToSign()
|
|
98
90
|
// implementation than ConsensusPayload (uses serializeToBuffer vs ABI encoding).
|
|
@@ -101,16 +93,15 @@ export class CheckpointAttestation extends Gossipable {
|
|
|
101
93
|
this.payload.archive,
|
|
102
94
|
this.payload.feeAssetPriceModifier,
|
|
103
95
|
this.proposerSignature,
|
|
96
|
+
this.payload.signatureContext,
|
|
104
97
|
);
|
|
105
|
-
|
|
106
|
-
this.proposer = proposal.getSender();
|
|
98
|
+
this.cachedProposer = proposal.getSender() ?? null;
|
|
107
99
|
}
|
|
108
|
-
|
|
109
|
-
return this.proposer;
|
|
100
|
+
return this.cachedProposer ?? undefined;
|
|
110
101
|
}
|
|
111
102
|
|
|
112
103
|
getPayload(): Buffer {
|
|
113
|
-
return this.payload.getPayloadToSign(
|
|
104
|
+
return this.payload.getPayloadToSign();
|
|
114
105
|
}
|
|
115
106
|
|
|
116
107
|
toBuffer(): Buffer {
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type CheckpointNumber,
|
|
3
|
+
CheckpointProposalHash,
|
|
4
|
+
IndexWithinCheckpoint,
|
|
5
|
+
SlotNumber,
|
|
6
|
+
} from '@aztec/foundation/branded-types';
|
|
7
|
+
import type { BaseBuffer32 } from '@aztec/foundation/buffer';
|
|
3
8
|
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
4
|
-
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
5
9
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
10
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
11
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
12
|
import { BufferReader, serializeSignedBigInt, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
13
|
|
|
14
|
+
import type { TypedDataDefinition } from 'viem';
|
|
15
|
+
|
|
10
16
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
11
17
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
12
18
|
import { DutyType, type SigningContext } from '../ha-signing/index.js';
|
|
@@ -17,19 +23,19 @@ import type { Tx } from '../tx/tx.js';
|
|
|
17
23
|
import { BlockProposal } from './block_proposal.js';
|
|
18
24
|
import { Gossipable } from './gossipable.js';
|
|
19
25
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
type CoordinationSignatureContext,
|
|
27
|
+
type CoordinationSignatureType,
|
|
28
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
29
|
+
type Signable,
|
|
30
|
+
getCoordinationSignatureTypedData,
|
|
31
|
+
readCoordinationSignatureContext,
|
|
32
|
+
recoverCoordinationSigner,
|
|
33
|
+
serializeCoordinationSignatureContext,
|
|
23
34
|
} from './signature_utils.js';
|
|
24
35
|
import { SignedTxs } from './signed_txs.js';
|
|
25
36
|
import { TopicType } from './topic_type.js';
|
|
26
37
|
|
|
27
|
-
|
|
28
|
-
export class CheckpointProposalHash extends Buffer32 {
|
|
29
|
-
constructor(hash: Buffer) {
|
|
30
|
-
super(hash);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
38
|
+
export type { CheckpointProposalHash } from '@aztec/foundation/branded-types';
|
|
33
39
|
|
|
34
40
|
export type CheckpointProposalOptions = {
|
|
35
41
|
/**
|
|
@@ -69,10 +75,12 @@ export type CheckpointLastBlock = Omit<CheckpointLastBlockData, 'txs'> & {
|
|
|
69
75
|
* It includes the aggregated checkpoint header that validators will attest to, plus optionally
|
|
70
76
|
* the last block's info for nodes to re-execute. This marks the completion of a slot's worth of blocks.
|
|
71
77
|
*/
|
|
72
|
-
export class CheckpointProposal extends Gossipable {
|
|
78
|
+
export class CheckpointProposal extends Gossipable implements Signable {
|
|
73
79
|
static override p2pTopic = TopicType.checkpoint_proposal;
|
|
74
80
|
|
|
75
|
-
|
|
81
|
+
readonly primaryType: CoordinationSignatureType = 'CheckpointProposal';
|
|
82
|
+
|
|
83
|
+
private cachedSender: EthAddress | undefined | null = undefined;
|
|
76
84
|
|
|
77
85
|
constructor(
|
|
78
86
|
/** The aggregated checkpoint header for consensus */
|
|
@@ -87,14 +95,17 @@ export class CheckpointProposal extends Gossipable {
|
|
|
87
95
|
/** The proposer's signature over the checkpoint payload (checkpointHeader + archive + feeAssetPriceModifier) */
|
|
88
96
|
public readonly signature: Signature,
|
|
89
97
|
|
|
98
|
+
/** The signing domain (chainId + rollupAddress) the signature is bound to */
|
|
99
|
+
public readonly signatureContext: CoordinationSignatureContext,
|
|
100
|
+
|
|
90
101
|
/** Optional last block info, including its own signature for BlockProposal extraction */
|
|
91
102
|
public readonly lastBlock?: CheckpointLastBlock,
|
|
92
103
|
) {
|
|
93
104
|
super();
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
override generateP2PMessageIdentifier(): Promise<
|
|
97
|
-
return Promise.resolve(
|
|
107
|
+
override generateP2PMessageIdentifier(): Promise<BaseBuffer32> {
|
|
108
|
+
return Promise.resolve(CheckpointProposalHash.fromBuffer(keccak256(this.signature.toBuffer())));
|
|
98
109
|
}
|
|
99
110
|
|
|
100
111
|
get slotNumber(): SlotNumber {
|
|
@@ -117,6 +128,7 @@ export class CheckpointProposal extends Gossipable {
|
|
|
117
128
|
this.archive,
|
|
118
129
|
this.lastBlock.txHashes,
|
|
119
130
|
this.lastBlock.signature,
|
|
131
|
+
this.signatureContext,
|
|
120
132
|
this.lastBlock.signedTxs,
|
|
121
133
|
);
|
|
122
134
|
}
|
|
@@ -148,21 +160,18 @@ export class CheckpointProposal extends Gossipable {
|
|
|
148
160
|
* Get the payload to sign for this checkpoint proposal.
|
|
149
161
|
* The signature is over the checkpoint header + archive root + feeAssetPriceModifier (for consensus).
|
|
150
162
|
*/
|
|
151
|
-
getPayloadToSign(
|
|
152
|
-
return serializeToBuffer([
|
|
153
|
-
domainSeparator,
|
|
154
|
-
this.checkpointHeader,
|
|
155
|
-
this.archive,
|
|
156
|
-
serializeSignedBigInt(this.feeAssetPriceModifier),
|
|
157
|
-
]);
|
|
163
|
+
getPayloadToSign(): Buffer {
|
|
164
|
+
return serializeToBuffer([this.checkpointHeader, this.archive, serializeSignedBigInt(this.feeAssetPriceModifier)]);
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
static async createProposalFromSigner(
|
|
161
168
|
checkpointHeader: CheckpointHeader,
|
|
162
169
|
archiveRoot: Fr,
|
|
170
|
+
checkpointNumber: CheckpointNumber,
|
|
163
171
|
feeAssetPriceModifier: bigint,
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
lastBlockProposal: BlockProposal | undefined,
|
|
173
|
+
signatureContext: CoordinationSignatureContext,
|
|
174
|
+
payloadSigner: (typedData: TypedDataDefinition, context: SigningContext) => Promise<Signature>,
|
|
166
175
|
): Promise<CheckpointProposal> {
|
|
167
176
|
// Sign the checkpoint payload with CHECKPOINT_PROPOSAL duty type
|
|
168
177
|
const tempProposal = new CheckpointProposal(
|
|
@@ -170,40 +179,25 @@ export class CheckpointProposal extends Gossipable {
|
|
|
170
179
|
archiveRoot,
|
|
171
180
|
feeAssetPriceModifier,
|
|
172
181
|
Signature.empty(),
|
|
182
|
+
signatureContext,
|
|
173
183
|
);
|
|
174
|
-
const checkpointHash = getHashedSignaturePayload(tempProposal, SignatureDomainSeparator.checkpointProposal);
|
|
175
|
-
|
|
176
184
|
const checkpointContext: SigningContext = {
|
|
177
185
|
slot: checkpointHeader.slotNumber,
|
|
178
|
-
|
|
186
|
+
checkpointNumber,
|
|
179
187
|
dutyType: DutyType.CHECKPOINT_PROPOSAL,
|
|
180
188
|
};
|
|
181
189
|
|
|
182
|
-
|
|
183
|
-
|
|
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
|
-
});
|
|
203
|
-
}
|
|
190
|
+
const typedData = getCoordinationSignatureTypedData(tempProposal);
|
|
191
|
+
const checkpointSignature = await payloadSigner(typedData, checkpointContext);
|
|
204
192
|
|
|
205
|
-
|
|
206
|
-
|
|
193
|
+
return new CheckpointProposal(
|
|
194
|
+
checkpointHeader,
|
|
195
|
+
archiveRoot,
|
|
196
|
+
feeAssetPriceModifier,
|
|
197
|
+
checkpointSignature,
|
|
198
|
+
signatureContext,
|
|
199
|
+
lastBlockProposal,
|
|
200
|
+
);
|
|
207
201
|
}
|
|
208
202
|
|
|
209
203
|
/**
|
|
@@ -212,28 +206,26 @@ export class CheckpointProposal extends Gossipable {
|
|
|
212
206
|
* @returns The sender address, or undefined if signature recovery fails or senders don't match
|
|
213
207
|
*/
|
|
214
208
|
getSender(): EthAddress | undefined {
|
|
215
|
-
if (
|
|
216
|
-
const
|
|
217
|
-
const checkpointSender = tryRecoverAddress(hashed, this.signature);
|
|
209
|
+
if (this.cachedSender === undefined) {
|
|
210
|
+
const checkpointSender = recoverCoordinationSigner(this, this.signature);
|
|
218
211
|
|
|
219
|
-
// If there's a lastBlock, verify the block proposal sender matches
|
|
220
212
|
if (checkpointSender && this.lastBlock) {
|
|
221
213
|
const blockProposal = this.getBlockProposal();
|
|
222
214
|
const blockSender = blockProposal?.getSender();
|
|
223
215
|
if (!blockSender || !blockSender.equals(checkpointSender)) {
|
|
224
|
-
|
|
216
|
+
this.cachedSender = null;
|
|
217
|
+
return undefined;
|
|
225
218
|
}
|
|
226
219
|
}
|
|
227
220
|
|
|
228
|
-
|
|
229
|
-
this.sender = checkpointSender;
|
|
221
|
+
this.cachedSender = checkpointSender ?? null;
|
|
230
222
|
}
|
|
231
223
|
|
|
232
|
-
return this.
|
|
224
|
+
return this.cachedSender ?? undefined;
|
|
233
225
|
}
|
|
234
226
|
|
|
235
227
|
getPayload() {
|
|
236
|
-
return this.getPayloadToSign(
|
|
228
|
+
return this.getPayloadToSign();
|
|
237
229
|
}
|
|
238
230
|
|
|
239
231
|
toBuffer(): Buffer {
|
|
@@ -242,6 +234,7 @@ export class CheckpointProposal extends Gossipable {
|
|
|
242
234
|
this.archive,
|
|
243
235
|
serializeSignedBigInt(this.feeAssetPriceModifier),
|
|
244
236
|
this.signature,
|
|
237
|
+
serializeCoordinationSignatureContext(this.signatureContext),
|
|
245
238
|
];
|
|
246
239
|
|
|
247
240
|
if (this.lastBlock) {
|
|
@@ -271,6 +264,7 @@ export class CheckpointProposal extends Gossipable {
|
|
|
271
264
|
const archive = reader.readObject(Fr);
|
|
272
265
|
const feeAssetPriceModifier = reader.readInt256();
|
|
273
266
|
const signature = reader.readObject(Signature);
|
|
267
|
+
const signatureContext = readCoordinationSignatureContext(reader);
|
|
274
268
|
|
|
275
269
|
const hasLastBlock = reader.readNumber();
|
|
276
270
|
|
|
@@ -292,7 +286,7 @@ export class CheckpointProposal extends Gossipable {
|
|
|
292
286
|
}
|
|
293
287
|
}
|
|
294
288
|
|
|
295
|
-
return new CheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, signature, {
|
|
289
|
+
return new CheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, signature, signatureContext, {
|
|
296
290
|
blockHeader,
|
|
297
291
|
indexWithinCheckpoint,
|
|
298
292
|
txHashes,
|
|
@@ -301,7 +295,7 @@ export class CheckpointProposal extends Gossipable {
|
|
|
301
295
|
});
|
|
302
296
|
}
|
|
303
297
|
|
|
304
|
-
return new CheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, signature);
|
|
298
|
+
return new CheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, signature, signatureContext);
|
|
305
299
|
}
|
|
306
300
|
|
|
307
301
|
getSize(): number {
|
|
@@ -310,6 +304,8 @@ export class CheckpointProposal extends Gossipable {
|
|
|
310
304
|
this.archive.size +
|
|
311
305
|
this.signature.getSize() +
|
|
312
306
|
8 /* feeAssetPriceModifier */ +
|
|
307
|
+
4 /* chainId */ +
|
|
308
|
+
20 /* rollupAddress */ +
|
|
313
309
|
4; /* hasLastBlock flag */
|
|
314
310
|
|
|
315
311
|
if (this.lastBlock) {
|
|
@@ -327,16 +323,29 @@ export class CheckpointProposal extends Gossipable {
|
|
|
327
323
|
}
|
|
328
324
|
|
|
329
325
|
static empty(): CheckpointProposal {
|
|
330
|
-
return new CheckpointProposal(
|
|
326
|
+
return new CheckpointProposal(
|
|
327
|
+
CheckpointHeader.empty(),
|
|
328
|
+
Fr.ZERO,
|
|
329
|
+
0n,
|
|
330
|
+
Signature.empty(),
|
|
331
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
332
|
+
);
|
|
331
333
|
}
|
|
332
334
|
|
|
333
335
|
static random(): CheckpointProposal {
|
|
334
|
-
return new CheckpointProposal(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
336
|
+
return new CheckpointProposal(
|
|
337
|
+
CheckpointHeader.random(),
|
|
338
|
+
Fr.random(),
|
|
339
|
+
0n,
|
|
340
|
+
Signature.random(),
|
|
341
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
342
|
+
{
|
|
343
|
+
blockHeader: BlockHeader.random(),
|
|
344
|
+
indexWithinCheckpoint: IndexWithinCheckpoint(Math.floor(Math.random() * 5)),
|
|
345
|
+
txHashes: [TxHash.random(), TxHash.random()],
|
|
346
|
+
signature: Signature.random(),
|
|
347
|
+
},
|
|
348
|
+
);
|
|
340
349
|
}
|
|
341
350
|
|
|
342
351
|
toInspect() {
|
|
@@ -345,6 +354,8 @@ export class CheckpointProposal extends Gossipable {
|
|
|
345
354
|
archive: this.archive.toString(),
|
|
346
355
|
signature: this.signature.toString(),
|
|
347
356
|
feeAssetPriceModifier: this.feeAssetPriceModifier.toString(),
|
|
357
|
+
chainId: this.signatureContext.chainId,
|
|
358
|
+
rollupAddress: this.signatureContext.rollupAddress.toString(),
|
|
348
359
|
lastBlock: this.lastBlock
|
|
349
360
|
? {
|
|
350
361
|
blockHeader: this.lastBlock.blockHeader.toInspect(),
|
|
@@ -361,7 +372,13 @@ export class CheckpointProposal extends Gossipable {
|
|
|
361
372
|
* Used when the lastBlock has been extracted and stored separately.
|
|
362
373
|
*/
|
|
363
374
|
toCore(): CheckpointProposalCore {
|
|
364
|
-
return new CheckpointProposal(
|
|
375
|
+
return new CheckpointProposal(
|
|
376
|
+
this.checkpointHeader,
|
|
377
|
+
this.archive,
|
|
378
|
+
this.feeAssetPriceModifier,
|
|
379
|
+
this.signature,
|
|
380
|
+
this.signatureContext,
|
|
381
|
+
);
|
|
365
382
|
}
|
|
366
383
|
}
|
|
367
384
|
|
|
@@ -10,10 +10,21 @@ import { z } from 'zod';
|
|
|
10
10
|
import type { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
11
11
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
12
12
|
import type { CheckpointProposal, CheckpointProposalCore } from './checkpoint_proposal.js';
|
|
13
|
-
import
|
|
13
|
+
import {
|
|
14
|
+
type CoordinationSignatureContext,
|
|
15
|
+
type CoordinationSignatureType,
|
|
16
|
+
EMPTY_COORDINATION_SIGNATURE_CONTEXT,
|
|
17
|
+
type Signable,
|
|
18
|
+
coordinationSignatureContextEquals,
|
|
19
|
+
coordinationSignatureContextSchema,
|
|
20
|
+
readCoordinationSignatureContext,
|
|
21
|
+
serializeCoordinationSignatureContext,
|
|
22
|
+
} from './signature_utils.js';
|
|
14
23
|
|
|
15
24
|
/** Checkpoint consensus payload as signed by validators and verified on L1. */
|
|
16
25
|
export class ConsensusPayload implements Signable {
|
|
26
|
+
readonly primaryType: CoordinationSignatureType = 'CheckpointAttestation';
|
|
27
|
+
|
|
17
28
|
private size: number | undefined;
|
|
18
29
|
|
|
19
30
|
constructor(
|
|
@@ -22,7 +33,9 @@ export class ConsensusPayload implements Signable {
|
|
|
22
33
|
/** The archive root after the block is added */
|
|
23
34
|
public readonly archive: Fr,
|
|
24
35
|
/** The fee asset price modifier in basis points (from oracle) */
|
|
25
|
-
public readonly feeAssetPriceModifier: bigint
|
|
36
|
+
public readonly feeAssetPriceModifier: bigint,
|
|
37
|
+
/** The signing domain (chainId + rollupAddress) the signature is bound to */
|
|
38
|
+
public readonly signatureContext: CoordinationSignatureContext,
|
|
26
39
|
) {}
|
|
27
40
|
|
|
28
41
|
static get schema() {
|
|
@@ -31,36 +44,38 @@ export class ConsensusPayload implements Signable {
|
|
|
31
44
|
header: CheckpointHeader.schema,
|
|
32
45
|
archive: schemas.Fr,
|
|
33
46
|
feeAssetPriceModifier: schemas.BigInt,
|
|
47
|
+
signatureContext: coordinationSignatureContextSchema,
|
|
34
48
|
})
|
|
35
|
-
.transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.feeAssetPriceModifier));
|
|
49
|
+
.transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.feeAssetPriceModifier, obj.signatureContext));
|
|
36
50
|
}
|
|
37
51
|
|
|
38
|
-
static getFields(fields: FieldsOf<ConsensusPayload>) {
|
|
39
|
-
return [fields.header, fields.archive, fields.feeAssetPriceModifier] as const;
|
|
52
|
+
static getFields(fields: Omit<FieldsOf<ConsensusPayload>, 'primaryType'>) {
|
|
53
|
+
return [fields.header, fields.archive, fields.feeAssetPriceModifier, fields.signatureContext] as const;
|
|
40
54
|
}
|
|
41
55
|
|
|
42
|
-
getPayloadToSign(
|
|
56
|
+
getPayloadToSign(): Buffer {
|
|
57
|
+
// Matches the L1 ProposePayload struct in ProposeLib.sol.
|
|
43
58
|
const abi = parseAbiParameters(
|
|
44
|
-
'
|
|
45
|
-
'(' +
|
|
59
|
+
'(' +
|
|
46
60
|
'bytes32, ' + // archive
|
|
47
61
|
'(int256), ' + // oracleInput
|
|
48
62
|
'bytes32' + // headerHash
|
|
49
63
|
')',
|
|
50
64
|
);
|
|
51
65
|
const archiveRoot = this.archive.toString();
|
|
52
|
-
|
|
53
66
|
const headerHash = this.header.hash().toString();
|
|
54
|
-
const encodedData = encodeAbiParameters(abi, [
|
|
55
|
-
domainSeparator,
|
|
56
|
-
[archiveRoot, [this.feeAssetPriceModifier], headerHash],
|
|
57
|
-
] as const);
|
|
67
|
+
const encodedData = encodeAbiParameters(abi, [[archiveRoot, [this.feeAssetPriceModifier], headerHash]] as const);
|
|
58
68
|
|
|
59
69
|
return hexToBuffer(encodedData);
|
|
60
70
|
}
|
|
61
71
|
|
|
62
72
|
toBuffer(): Buffer {
|
|
63
|
-
return serializeToBuffer([
|
|
73
|
+
return serializeToBuffer([
|
|
74
|
+
this.header,
|
|
75
|
+
this.archive,
|
|
76
|
+
serializeSignedBigInt(this.feeAssetPriceModifier),
|
|
77
|
+
serializeCoordinationSignatureContext(this.signatureContext),
|
|
78
|
+
]);
|
|
64
79
|
}
|
|
65
80
|
|
|
66
81
|
public equals(other: ConsensusPayload | CheckpointProposal | CheckpointProposalCore): boolean {
|
|
@@ -69,34 +84,39 @@ export class ConsensusPayload implements Signable {
|
|
|
69
84
|
return (
|
|
70
85
|
this.header.equals(otherHeader) &&
|
|
71
86
|
this.archive.equals(other.archive) &&
|
|
72
|
-
this.feeAssetPriceModifier === otherModifier
|
|
87
|
+
this.feeAssetPriceModifier === otherModifier &&
|
|
88
|
+
coordinationSignatureContextEquals(this.signatureContext, other.signatureContext)
|
|
73
89
|
);
|
|
74
90
|
}
|
|
75
91
|
|
|
76
92
|
static fromBuffer(buf: Buffer | BufferReader): ConsensusPayload {
|
|
77
93
|
const reader = BufferReader.asReader(buf);
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
);
|
|
83
|
-
return payload;
|
|
94
|
+
const header = reader.readObject(CheckpointHeader);
|
|
95
|
+
const archive = reader.readObject(Fr);
|
|
96
|
+
const feeAssetPriceModifier = reader.readInt256();
|
|
97
|
+
const signatureContext = readCoordinationSignatureContext(reader);
|
|
98
|
+
return new ConsensusPayload(header, archive, feeAssetPriceModifier, signatureContext);
|
|
84
99
|
}
|
|
85
100
|
|
|
86
|
-
static fromFields(fields: FieldsOf<ConsensusPayload>): ConsensusPayload {
|
|
87
|
-
return new ConsensusPayload(fields.header, fields.archive, fields.feeAssetPriceModifier);
|
|
101
|
+
static fromFields(fields: Omit<FieldsOf<ConsensusPayload>, 'primaryType'>): ConsensusPayload {
|
|
102
|
+
return new ConsensusPayload(fields.header, fields.archive, fields.feeAssetPriceModifier, fields.signatureContext);
|
|
88
103
|
}
|
|
89
104
|
|
|
90
|
-
static fromCheckpoint(checkpoint: Checkpoint): ConsensusPayload {
|
|
91
|
-
return new ConsensusPayload(
|
|
105
|
+
static fromCheckpoint(checkpoint: Checkpoint, signatureContext: CoordinationSignatureContext): ConsensusPayload {
|
|
106
|
+
return new ConsensusPayload(
|
|
107
|
+
checkpoint.header,
|
|
108
|
+
checkpoint.archive.root,
|
|
109
|
+
checkpoint.feeAssetPriceModifier,
|
|
110
|
+
signatureContext,
|
|
111
|
+
);
|
|
92
112
|
}
|
|
93
113
|
|
|
94
114
|
static empty(): ConsensusPayload {
|
|
95
|
-
return new ConsensusPayload(CheckpointHeader.empty(), Fr.ZERO, 0n);
|
|
115
|
+
return new ConsensusPayload(CheckpointHeader.empty(), Fr.ZERO, 0n, EMPTY_COORDINATION_SIGNATURE_CONTEXT);
|
|
96
116
|
}
|
|
97
117
|
|
|
98
118
|
static random(): ConsensusPayload {
|
|
99
|
-
return new ConsensusPayload(CheckpointHeader.random(), Fr.random(), 0n);
|
|
119
|
+
return new ConsensusPayload(CheckpointHeader.random(), Fr.random(), 0n, EMPTY_COORDINATION_SIGNATURE_CONTEXT);
|
|
100
120
|
}
|
|
101
121
|
|
|
102
122
|
/**
|
|
@@ -117,10 +137,12 @@ export class ConsensusPayload implements Signable {
|
|
|
117
137
|
header: this.header.toInspect(),
|
|
118
138
|
archive: this.archive.toString(),
|
|
119
139
|
feeAssetPriceModifier: this.feeAssetPriceModifier.toString(),
|
|
140
|
+
chainId: this.signatureContext.chainId,
|
|
141
|
+
rollupAddress: this.signatureContext.rollupAddress.toString(),
|
|
120
142
|
};
|
|
121
143
|
}
|
|
122
144
|
|
|
123
145
|
toString() {
|
|
124
|
-
return `header: ${this.header.toString()}, archive: ${this.archive.toString()}, feeAssetPriceModifier: ${this.feeAssetPriceModifier}}`;
|
|
146
|
+
return `header: ${this.header.toString()}, archive: ${this.archive.toString()}, feeAssetPriceModifier: ${this.feeAssetPriceModifier}, chainId: ${this.signatureContext.chainId}, rollupAddress: ${this.signatureContext.rollupAddress.toString()}`;
|
|
125
147
|
}
|
|
126
148
|
}
|
package/src/p2p/gossipable.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseBuffer32 } from '@aztec/foundation/buffer';
|
|
2
2
|
import { BufferReader, bigintToUInt64BE, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
3
|
|
|
4
4
|
import type { TopicType } from './topic_type.js';
|
|
@@ -46,7 +46,7 @@ export class P2PMessage {
|
|
|
46
46
|
* Any class which extends gossipable will be able to be Gossiped over the p2p network
|
|
47
47
|
*/
|
|
48
48
|
export abstract class Gossipable {
|
|
49
|
-
private cachedId:
|
|
49
|
+
private cachedId: BaseBuffer32 | undefined;
|
|
50
50
|
/** The p2p topic identifier, this determines how the message is handled */
|
|
51
51
|
static p2pTopic: TopicType;
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ export abstract class Gossipable {
|
|
|
54
54
|
* A digest of the message information **used for logging only**.
|
|
55
55
|
* The identifier used for deduplication is `getMsgIdFn` as defined in `encoding.ts` which is a hash over topic and data.
|
|
56
56
|
*/
|
|
57
|
-
async p2pMessageLoggingIdentifier(): Promise<
|
|
57
|
+
async p2pMessageLoggingIdentifier(): Promise<BaseBuffer32> {
|
|
58
58
|
if (this.cachedId) {
|
|
59
59
|
return this.cachedId;
|
|
60
60
|
}
|
|
@@ -62,7 +62,7 @@ export abstract class Gossipable {
|
|
|
62
62
|
return this.cachedId;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
abstract generateP2PMessageIdentifier(): Promise<
|
|
65
|
+
abstract generateP2PMessageIdentifier(): Promise<BaseBuffer32>;
|
|
66
66
|
|
|
67
67
|
abstract toBuffer(): Buffer;
|
|
68
68
|
|