@aztec/stdlib 4.0.0-nightly.20260112 → 4.0.0-nightly.20260114
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/utils.d.ts +7 -1
- package/dest/abi/utils.d.ts.map +1 -1
- package/dest/abi/utils.js +7 -0
- package/dest/avm/avm.d.ts +300 -300
- package/dest/block/attestation_info.d.ts +5 -5
- package/dest/block/attestation_info.d.ts.map +1 -1
- package/dest/block/attestation_info.js +4 -4
- package/dest/block/body.d.ts +1 -1
- package/dest/block/body.d.ts.map +1 -1
- package/dest/block/body.js +2 -1
- package/dest/block/checkpointed_l2_block.d.ts +1 -1
- package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
- package/dest/block/checkpointed_l2_block.js +5 -4
- package/dest/block/l2_block.d.ts +6 -3
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +3 -3
- package/dest/block/l2_block_code_to_purge.d.ts +1 -1
- package/dest/block/l2_block_code_to_purge.d.ts.map +1 -1
- package/dest/block/l2_block_code_to_purge.js +1 -1
- package/dest/block/l2_block_header.d.ts +6 -2
- package/dest/block/l2_block_header.d.ts.map +1 -1
- package/dest/block/l2_block_header.js +14 -7
- package/dest/block/l2_block_new.d.ts +1 -2
- package/dest/block/l2_block_new.d.ts.map +1 -1
- package/dest/block/l2_block_new.js +4 -1
- package/dest/block/l2_block_source.d.ts +247 -42
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_source.js +23 -5
- package/dest/block/l2_block_stream/index.d.ts +2 -1
- package/dest/block/l2_block_stream/index.d.ts.map +1 -1
- package/dest/block/l2_block_stream/index.js +1 -0
- package/dest/block/l2_block_stream/interfaces.d.ts +16 -5
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +4 -2
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +102 -30
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +24 -16
- package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_tips_memory_store.js +55 -61
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts +49 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.d.ts.map +1 -0
- package/dest/block/l2_block_stream/l2_tips_store_base.js +179 -0
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +483 -38
- package/dest/block/validate_block_result.d.ts +24 -24
- package/dest/block/validate_block_result.d.ts.map +1 -1
- package/dest/block/validate_block_result.js +18 -17
- package/dest/checkpoint/checkpoint.d.ts +2 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +11 -1
- package/dest/checkpoint/checkpoint_info.d.ts +32 -3
- package/dest/checkpoint/checkpoint_info.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint_info.js +34 -1
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/published_checkpoint.d.ts +1 -1
- package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/published_checkpoint.js +4 -3
- package/dest/contract/index.d.ts +1 -3
- package/dest/contract/index.d.ts.map +1 -1
- package/dest/contract/index.js +0 -2
- package/dest/deserialization/index.d.ts +11 -0
- package/dest/deserialization/index.d.ts.map +1 -0
- package/dest/deserialization/index.js +10 -0
- package/dest/interfaces/api_limit.d.ts +2 -1
- package/dest/interfaces/api_limit.d.ts.map +1 -1
- package/dest/interfaces/api_limit.js +1 -0
- package/dest/interfaces/archiver.d.ts +6 -6
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +6 -4
- package/dest/interfaces/aztec-node-admin.d.ts +12 -9
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node-admin.js +2 -2
- package/dest/interfaces/aztec-node.d.ts +2 -2
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +8 -3
- package/dest/interfaces/block-builder.d.ts +2 -2
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/configs.d.ts +6 -1
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/p2p.d.ts +7 -9
- package/dest/interfaces/p2p.d.ts.map +1 -1
- package/dest/interfaces/p2p.js +3 -4
- package/dest/interfaces/validator.d.ts +41 -15
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +3 -2
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +6 -5
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +5 -6
- package/dest/messaging/l2_to_l1_membership.d.ts +1 -1
- package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
- package/dest/messaging/l2_to_l1_membership.js +5 -3
- package/dest/messaging/out_hash.d.ts +41 -4
- package/dest/messaging/out_hash.d.ts.map +1 -1
- package/dest/messaging/out_hash.js +52 -26
- package/dest/note/note_dao.d.ts +8 -5
- package/dest/note/note_dao.d.ts.map +1 -1
- package/dest/note/note_dao.js +15 -12
- package/dest/p2p/attestation_utils.d.ts +3 -3
- package/dest/p2p/attestation_utils.d.ts.map +1 -1
- package/dest/p2p/attestation_utils.js +1 -1
- package/dest/p2p/block_proposal.d.ts +85 -21
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +126 -38
- package/dest/p2p/checkpoint_attestation.d.ts +78 -0
- package/dest/p2p/checkpoint_attestation.d.ts.map +1 -0
- package/dest/p2p/{block_attestation.js → checkpoint_attestation.js} +22 -19
- package/dest/p2p/checkpoint_proposal.d.ts +155 -0
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -0
- package/dest/p2p/checkpoint_proposal.js +222 -0
- package/dest/p2p/consensus_payload.d.ts +5 -2
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +3 -2
- package/dest/p2p/index.d.ts +4 -2
- package/dest/p2p/index.d.ts.map +1 -1
- package/dest/p2p/index.js +3 -1
- package/dest/p2p/signature_utils.d.ts +5 -3
- package/dest/p2p/signature_utils.d.ts.map +1 -1
- package/dest/p2p/signature_utils.js +3 -1
- package/dest/p2p/signed_txs.d.ts +40 -0
- package/dest/p2p/signed_txs.d.ts.map +1 -0
- package/dest/p2p/signed_txs.js +75 -0
- package/dest/p2p/topic_type.d.ts +3 -2
- package/dest/p2p/topic_type.d.ts.map +1 -1
- package/dest/p2p/topic_type.js +8 -2
- package/dest/rollup/block_headers_hash.js +1 -1
- package/dest/rollup/block_rollup_public_inputs.d.ts +2 -2
- package/dest/rollup/block_rollup_public_inputs.js +2 -2
- package/dest/rollup/checkpoint_header.d.ts +16 -2
- package/dest/rollup/checkpoint_header.d.ts.map +1 -1
- package/dest/rollup/checkpoint_header.js +25 -5
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts +11 -6
- package/dest/rollup/checkpoint_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_rollup_public_inputs.js +10 -6
- package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts +14 -3
- package/dest/rollup/checkpoint_root_rollup_private_inputs.d.ts.map +1 -1
- package/dest/rollup/checkpoint_root_rollup_private_inputs.js +13 -2
- package/dest/rollup/root_rollup_public_inputs.d.ts +5 -2
- package/dest/rollup/root_rollup_public_inputs.d.ts.map +1 -1
- package/dest/rollup/root_rollup_public_inputs.js +4 -1
- package/dest/tests/factories.d.ts +13 -1
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +53 -3
- package/dest/tests/mocks.d.ts +55 -9
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +84 -35
- package/dest/tx/private_execution_result.d.ts +1 -5
- package/dest/tx/private_execution_result.d.ts.map +1 -1
- package/dest/tx/private_execution_result.js +3 -20
- package/dest/tx/tx_effect.d.ts +1 -6
- package/dest/tx/tx_effect.d.ts.map +1 -1
- package/dest/tx/tx_effect.js +0 -7
- package/package.json +9 -8
- package/src/abi/utils.ts +17 -0
- package/src/block/attestation_info.ts +9 -6
- package/src/block/body.ts +2 -1
- package/src/block/checkpointed_l2_block.ts +5 -4
- package/src/block/l2_block.ts +4 -3
- package/src/block/l2_block_code_to_purge.ts +1 -0
- package/src/block/l2_block_header.ts +13 -0
- package/src/block/l2_block_new.ts +5 -1
- package/src/block/l2_block_source.ts +69 -17
- package/src/block/l2_block_stream/index.ts +1 -0
- package/src/block/l2_block_stream/interfaces.ts +16 -4
- package/src/block/l2_block_stream/l2_block_stream.ts +121 -38
- package/src/block/l2_block_stream/l2_tips_memory_store.ts +62 -56
- package/src/block/l2_block_stream/l2_tips_store_base.ts +226 -0
- package/src/block/test/l2_tips_store_test_suite.ts +485 -36
- package/src/block/validate_block_result.ts +40 -35
- package/src/checkpoint/checkpoint.ts +12 -1
- package/src/checkpoint/checkpoint_info.ts +45 -2
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/published_checkpoint.ts +4 -3
- package/src/contract/index.ts +0 -2
- package/src/deserialization/index.ts +21 -0
- package/src/interfaces/api_limit.ts +1 -0
- package/src/interfaces/archiver.ts +14 -6
- package/src/interfaces/aztec-node-admin.ts +5 -2
- package/src/interfaces/aztec-node.ts +30 -3
- package/src/interfaces/block-builder.ts +1 -0
- package/src/interfaces/configs.ts +5 -0
- package/src/interfaces/p2p.ts +8 -12
- package/src/interfaces/validator.ts +57 -11
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +5 -8
- package/src/messaging/l2_to_l1_membership.ts +5 -3
- package/src/messaging/out_hash.ts +60 -29
- package/src/note/note_dao.ts +18 -13
- package/src/p2p/attestation_utils.ts +3 -3
- package/src/p2p/block_proposal.ts +191 -42
- package/src/p2p/{block_attestation.ts → checkpoint_attestation.ts} +31 -25
- package/src/p2p/checkpoint_proposal.ts +342 -0
- package/src/p2p/consensus_payload.ts +5 -2
- package/src/p2p/index.ts +3 -1
- package/src/p2p/signature_utils.ts +3 -1
- package/src/p2p/signed_txs.ts +88 -0
- package/src/p2p/topic_type.ts +3 -2
- package/src/rollup/block_headers_hash.ts +1 -1
- package/src/rollup/block_rollup_public_inputs.ts +2 -2
- package/src/rollup/checkpoint_header.ts +33 -0
- package/src/rollup/checkpoint_rollup_public_inputs.ts +12 -6
- package/src/rollup/checkpoint_root_rollup_private_inputs.ts +14 -1
- package/src/rollup/root_rollup_public_inputs.ts +4 -1
- package/src/tests/factories.ts +46 -2
- package/src/tests/mocks.ts +146 -50
- package/src/tx/private_execution_result.ts +0 -15
- package/src/tx/tx_effect.ts +0 -9
- package/dest/contract/contract_class_metadata.d.ts +0 -8
- package/dest/contract/contract_class_metadata.d.ts.map +0 -1
- package/dest/contract/contract_class_metadata.js +0 -1
- package/dest/contract/contract_metadata.d.ts +0 -7
- package/dest/contract/contract_metadata.d.ts.map +0 -1
- package/dest/contract/contract_metadata.js +0 -1
- package/dest/p2p/block_attestation.d.ts +0 -77
- package/dest/p2p/block_attestation.d.ts.map +0 -1
- package/src/contract/contract_class_metadata.ts +0 -8
- package/src/contract/contract_metadata.ts +0 -7
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
|
+
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
4
|
+
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
5
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
6
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
|
+
|
|
10
|
+
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
11
|
+
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
12
|
+
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
13
|
+
import { BlockHeader } from '../tx/block_header.js';
|
|
14
|
+
import { TxHash } from '../tx/index.js';
|
|
15
|
+
import type { Tx } from '../tx/tx.js';
|
|
16
|
+
import { BlockProposal } from './block_proposal.js';
|
|
17
|
+
import { Gossipable } from './gossipable.js';
|
|
18
|
+
import {
|
|
19
|
+
SignatureDomainSeparator,
|
|
20
|
+
getHashedSignaturePayload,
|
|
21
|
+
getHashedSignaturePayloadEthSignedMessage,
|
|
22
|
+
} from './signature_utils.js';
|
|
23
|
+
import { SignedTxs } from './signed_txs.js';
|
|
24
|
+
import { TopicType } from './topic_type.js';
|
|
25
|
+
|
|
26
|
+
// REFACTOR(palla): Use a branded type instead of a subclass of Buffer32
|
|
27
|
+
export class CheckpointProposalHash extends Buffer32 {
|
|
28
|
+
constructor(hash: Buffer) {
|
|
29
|
+
super(hash);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type CheckpointProposalOptions = {
|
|
34
|
+
publishFullTxs: boolean;
|
|
35
|
+
/** Whether to generate an invalid checkpoint proposal for broadcasting. Use only for testing. */
|
|
36
|
+
broadcastInvalidCheckpointProposal?: boolean;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** Data for the last block included in a checkpoint proposal */
|
|
40
|
+
export type CheckpointLastBlockData = {
|
|
41
|
+
/** The per-block header for the last block in the checkpoint */
|
|
42
|
+
blockHeader: BlockHeader;
|
|
43
|
+
/** Index of this block within the checkpoint (should be the last index, e.g., numBlocks - 1) */
|
|
44
|
+
indexWithinCheckpoint: number; // REFACTOR(palla): Use branded type
|
|
45
|
+
/** The sequence of transactions in the last block */
|
|
46
|
+
txHashes: TxHash[];
|
|
47
|
+
/** The tx in the last block (optional, for DA guarantees) */
|
|
48
|
+
txs?: Tx[];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Last block included in a checkpoint proposal */
|
|
52
|
+
export type CheckpointLastBlock = Omit<CheckpointLastBlockData, 'txs'> & {
|
|
53
|
+
/** The proposer's signature over the block data (separate from checkpoint signature) */
|
|
54
|
+
signature: Signature;
|
|
55
|
+
/** The signed transactions in the last block (optional, for DA guarantees) */
|
|
56
|
+
signedTxs?: SignedTxs;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* A checkpoint proposal is created by the leader of the chain for the last block in a checkpoint.
|
|
61
|
+
* It includes the aggregated checkpoint header that validators will attest to, plus optionally
|
|
62
|
+
* the last block's info for nodes to re-execute. This marks the completion of a slot's worth of blocks.
|
|
63
|
+
*/
|
|
64
|
+
export class CheckpointProposal extends Gossipable {
|
|
65
|
+
static override p2pTopic = TopicType.checkpoint_proposal;
|
|
66
|
+
|
|
67
|
+
private sender: EthAddress | undefined;
|
|
68
|
+
|
|
69
|
+
constructor(
|
|
70
|
+
/** The aggregated checkpoint header for consensus */
|
|
71
|
+
public readonly checkpointHeader: CheckpointHeader,
|
|
72
|
+
|
|
73
|
+
/** Archive root after this checkpoint is applied */
|
|
74
|
+
public readonly archive: Fr,
|
|
75
|
+
|
|
76
|
+
/** The proposer's signature over the checkpoint payload (checkpointHeader + archive) */
|
|
77
|
+
public readonly signature: Signature,
|
|
78
|
+
|
|
79
|
+
/** Optional last block info, including its own signature for BlockProposal extraction */
|
|
80
|
+
public readonly lastBlock?: CheckpointLastBlock,
|
|
81
|
+
) {
|
|
82
|
+
super();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
override generateP2PMessageIdentifier(): Promise<Buffer32> {
|
|
86
|
+
return Promise.resolve(new CheckpointProposalHash(keccak256(this.signature.toBuffer())));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get slotNumber(): SlotNumber {
|
|
90
|
+
return this.checkpointHeader.slotNumber;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get blockNumber(): BlockNumber {
|
|
94
|
+
if (!this.lastBlock) {
|
|
95
|
+
throw new Error('Cannot get blockNumber without lastBlock');
|
|
96
|
+
}
|
|
97
|
+
return this.lastBlock.blockHeader.getBlockNumber();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Convenience getter for txHashes from lastBlock */
|
|
101
|
+
get txHashes(): TxHash[] {
|
|
102
|
+
return this.lastBlock?.txHashes ?? [];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Convenience getter for txs from lastBlock */
|
|
106
|
+
get txs(): Tx[] | undefined {
|
|
107
|
+
return this.lastBlock?.signedTxs?.txs;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Extract a BlockProposal from the last block info.
|
|
112
|
+
* Uses inHash from checkpointHeader.contentCommitment.inHash
|
|
113
|
+
*/
|
|
114
|
+
getBlockProposal(): BlockProposal | undefined {
|
|
115
|
+
if (!this.lastBlock) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return new BlockProposal(
|
|
120
|
+
this.lastBlock.blockHeader,
|
|
121
|
+
this.lastBlock.indexWithinCheckpoint,
|
|
122
|
+
this.checkpointHeader.inHash,
|
|
123
|
+
this.archive,
|
|
124
|
+
this.lastBlock.txHashes,
|
|
125
|
+
this.lastBlock.signature,
|
|
126
|
+
this.lastBlock.signedTxs,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
toBlockInfo(): Omit<L2BlockInfo, 'blockNumber'> {
|
|
131
|
+
if (!this.lastBlock) {
|
|
132
|
+
throw new Error('Cannot get blockInfo without lastBlock');
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
slotNumber: this.slotNumber,
|
|
136
|
+
lastArchive: this.lastBlock.blockHeader.lastArchive.root,
|
|
137
|
+
timestamp: this.lastBlock.blockHeader.globalVariables.timestamp,
|
|
138
|
+
archive: this.archive,
|
|
139
|
+
txCount: this.lastBlock.txHashes.length,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get the payload to sign for this checkpoint proposal.
|
|
145
|
+
* The signature is over the checkpoint header + archive root (for consensus).
|
|
146
|
+
*/
|
|
147
|
+
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
|
|
148
|
+
return serializeToBuffer([domainSeparator, this.checkpointHeader, this.archive]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
static async createProposalFromSigner(
|
|
152
|
+
checkpointHeader: CheckpointHeader,
|
|
153
|
+
archiveRoot: Fr,
|
|
154
|
+
lastBlockInfo: CheckpointLastBlockData | undefined,
|
|
155
|
+
payloadSigner: (payload: Buffer32) => Promise<Signature>,
|
|
156
|
+
): Promise<CheckpointProposal> {
|
|
157
|
+
// Sign the checkpoint payload
|
|
158
|
+
const tempProposal = new CheckpointProposal(checkpointHeader, archiveRoot, Signature.empty(), undefined);
|
|
159
|
+
|
|
160
|
+
const checkpointHash = getHashedSignaturePayload(tempProposal, SignatureDomainSeparator.checkpointProposal);
|
|
161
|
+
const checkpointSignature = await payloadSigner(checkpointHash);
|
|
162
|
+
|
|
163
|
+
if (!lastBlockInfo) {
|
|
164
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, checkpointSignature);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const lastBlockProposal = await BlockProposal.createProposalFromSigner(
|
|
168
|
+
lastBlockInfo.blockHeader,
|
|
169
|
+
lastBlockInfo.indexWithinCheckpoint,
|
|
170
|
+
checkpointHeader.inHash,
|
|
171
|
+
archiveRoot,
|
|
172
|
+
lastBlockInfo.txHashes,
|
|
173
|
+
lastBlockInfo.txs,
|
|
174
|
+
payloadSigner,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
return new CheckpointProposal(checkpointHeader, archiveRoot, checkpointSignature, {
|
|
178
|
+
blockHeader: lastBlockInfo.blockHeader,
|
|
179
|
+
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
|
|
180
|
+
txHashes: lastBlockInfo.txHashes,
|
|
181
|
+
signature: lastBlockProposal.signature,
|
|
182
|
+
signedTxs: lastBlockProposal.signedTxs,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Lazily evaluate the sender of the proposal; result is cached.
|
|
188
|
+
* If there's a lastBlock, also verifies the block proposal sender matches the checkpoint sender.
|
|
189
|
+
* @returns The sender address, or undefined if signature recovery fails or senders don't match
|
|
190
|
+
*/
|
|
191
|
+
getSender(): EthAddress | undefined {
|
|
192
|
+
if (!this.sender) {
|
|
193
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this, SignatureDomainSeparator.checkpointProposal);
|
|
194
|
+
const checkpointSender = tryRecoverAddress(hashed, this.signature);
|
|
195
|
+
|
|
196
|
+
// If there's a lastBlock, verify the block proposal sender matches
|
|
197
|
+
if (checkpointSender && this.lastBlock) {
|
|
198
|
+
const blockProposal = this.getBlockProposal();
|
|
199
|
+
const blockSender = blockProposal?.getSender();
|
|
200
|
+
if (!blockSender || !blockSender.equals(checkpointSender)) {
|
|
201
|
+
return undefined; // Sender mismatch - fail
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Cache the sender for later use
|
|
206
|
+
this.sender = checkpointSender;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return this.sender;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
getPayload() {
|
|
213
|
+
return this.getPayloadToSign(SignatureDomainSeparator.checkpointProposal);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
toBuffer(): Buffer {
|
|
217
|
+
const buffer: any[] = [this.checkpointHeader, this.archive, this.signature];
|
|
218
|
+
|
|
219
|
+
if (this.lastBlock) {
|
|
220
|
+
buffer.push(1); // hasLastBlock = true
|
|
221
|
+
buffer.push(this.lastBlock.blockHeader);
|
|
222
|
+
buffer.push(this.lastBlock.indexWithinCheckpoint);
|
|
223
|
+
buffer.push(this.lastBlock.signature);
|
|
224
|
+
buffer.push(this.lastBlock.txHashes.length);
|
|
225
|
+
buffer.push(this.lastBlock.txHashes);
|
|
226
|
+
if (this.lastBlock.signedTxs) {
|
|
227
|
+
buffer.push(1); // hasSignedTxs = true
|
|
228
|
+
buffer.push(this.lastBlock.signedTxs.toBuffer());
|
|
229
|
+
} else {
|
|
230
|
+
buffer.push(0); // hasSignedTxs = false
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
buffer.push(0); // hasLastBlock = false
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return serializeToBuffer(buffer);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
static fromBuffer(buf: Buffer | BufferReader): CheckpointProposal {
|
|
240
|
+
const reader = BufferReader.asReader(buf);
|
|
241
|
+
|
|
242
|
+
const checkpointHeader = reader.readObject(CheckpointHeader);
|
|
243
|
+
const archive = reader.readObject(Fr);
|
|
244
|
+
const signature = reader.readObject(Signature);
|
|
245
|
+
|
|
246
|
+
const hasLastBlock = reader.readNumber();
|
|
247
|
+
|
|
248
|
+
if (hasLastBlock) {
|
|
249
|
+
const blockHeader = reader.readObject(BlockHeader);
|
|
250
|
+
const indexWithinCheckpoint = reader.readNumber();
|
|
251
|
+
const blockSignature = reader.readObject(Signature);
|
|
252
|
+
const txHashCount = reader.readNumber();
|
|
253
|
+
if (txHashCount > MAX_TXS_PER_BLOCK) {
|
|
254
|
+
throw new Error(`txHashes count ${txHashCount} exceeds maximum ${MAX_TXS_PER_BLOCK}`);
|
|
255
|
+
}
|
|
256
|
+
const txHashes = reader.readArray(txHashCount, TxHash);
|
|
257
|
+
|
|
258
|
+
let signedTxs: SignedTxs | undefined;
|
|
259
|
+
if (!reader.isEmpty()) {
|
|
260
|
+
const hasSignedTxs = reader.readNumber();
|
|
261
|
+
if (hasSignedTxs) {
|
|
262
|
+
signedTxs = SignedTxs.fromBuffer(reader);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
return new CheckpointProposal(checkpointHeader, archive, signature, {
|
|
267
|
+
blockHeader,
|
|
268
|
+
indexWithinCheckpoint,
|
|
269
|
+
txHashes,
|
|
270
|
+
signature: blockSignature,
|
|
271
|
+
signedTxs,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return new CheckpointProposal(checkpointHeader, archive, signature);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
getSize(): number {
|
|
279
|
+
let size =
|
|
280
|
+
this.checkpointHeader.toBuffer().length +
|
|
281
|
+
this.archive.size +
|
|
282
|
+
this.signature.getSize() +
|
|
283
|
+
4; /* hasLastBlock flag */
|
|
284
|
+
|
|
285
|
+
if (this.lastBlock) {
|
|
286
|
+
size +=
|
|
287
|
+
this.lastBlock.blockHeader.getSize() +
|
|
288
|
+
4 /* indexWithinCheckpoint */ +
|
|
289
|
+
this.lastBlock.signature.getSize() +
|
|
290
|
+
4 /* txHashes.length */ +
|
|
291
|
+
this.lastBlock.txHashes.length * TxHash.SIZE +
|
|
292
|
+
4 /* hasSignedTxs flag */ +
|
|
293
|
+
(this.lastBlock.signedTxs ? this.lastBlock.signedTxs.getSize() : 0);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return size;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
static empty(): CheckpointProposal {
|
|
300
|
+
return new CheckpointProposal(CheckpointHeader.empty(), Fr.ZERO, Signature.empty());
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
static random(): CheckpointProposal {
|
|
304
|
+
return new CheckpointProposal(CheckpointHeader.random(), Fr.random(), Signature.random(), {
|
|
305
|
+
blockHeader: BlockHeader.random(),
|
|
306
|
+
indexWithinCheckpoint: Math.floor(Math.random() * 5),
|
|
307
|
+
txHashes: [TxHash.random(), TxHash.random()],
|
|
308
|
+
signature: Signature.random(),
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
toInspect() {
|
|
313
|
+
return {
|
|
314
|
+
checkpointHeader: this.checkpointHeader.toInspect(),
|
|
315
|
+
archive: this.archive.toString(),
|
|
316
|
+
signature: this.signature.toString(),
|
|
317
|
+
lastBlock: this.lastBlock
|
|
318
|
+
? {
|
|
319
|
+
blockHeader: this.lastBlock.blockHeader.toInspect(),
|
|
320
|
+
indexWithinCheckpoint: this.lastBlock.indexWithinCheckpoint,
|
|
321
|
+
txHashes: this.lastBlock.txHashes.map(h => h.toString()),
|
|
322
|
+
signature: this.lastBlock.signature.toString(),
|
|
323
|
+
}
|
|
324
|
+
: undefined,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Returns a copy of this proposal without lastBlock info, as a CheckpointProposalCore.
|
|
330
|
+
* Used when the lastBlock has been extracted and stored separately.
|
|
331
|
+
*/
|
|
332
|
+
toCore(): CheckpointProposalCore {
|
|
333
|
+
return new CheckpointProposal(this.checkpointHeader, this.archive, this.signature);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* A checkpoint proposal without the lastBlock info.
|
|
339
|
+
* Used when the lastBlock has been extracted and handled separately as a BlockProposal.
|
|
340
|
+
* This type makes it clear that lastBlock and getBlockProposal() are not available.
|
|
341
|
+
*/
|
|
342
|
+
export type CheckpointProposalCore = Omit<CheckpointProposal, 'lastBlock' | 'getBlockProposal' | 'toCore'>;
|
|
@@ -10,8 +10,10 @@ import { z } from 'zod';
|
|
|
10
10
|
import type { L2Block } from '../block/l2_block.js';
|
|
11
11
|
import type { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
12
12
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
13
|
+
import type { CheckpointProposal, CheckpointProposalCore } from './checkpoint_proposal.js';
|
|
13
14
|
import type { Signable, SignatureDomainSeparator } from './signature_utils.js';
|
|
14
15
|
|
|
16
|
+
/** Checkpoint consensus payload as signed by validators and verified on L1. */
|
|
15
17
|
export class ConsensusPayload implements Signable {
|
|
16
18
|
private size: number | undefined;
|
|
17
19
|
|
|
@@ -59,8 +61,9 @@ export class ConsensusPayload implements Signable {
|
|
|
59
61
|
return serializeToBuffer([this.header, this.archive]);
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
public equals(other: ConsensusPayload): boolean {
|
|
63
|
-
|
|
64
|
+
public equals(other: ConsensusPayload | CheckpointProposal | CheckpointProposalCore): boolean {
|
|
65
|
+
const otherHeader = 'checkpointHeader' in other ? other.checkpointHeader : other.header;
|
|
66
|
+
return this.header.equals(otherHeader) && this.archive.equals(other.archive);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
static fromBuffer(buf: Buffer | BufferReader): ConsensusPayload {
|
package/src/p2p/index.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from './attestation_utils.js';
|
|
2
|
-
export * from './block_attestation.js';
|
|
3
2
|
export * from './block_proposal.js';
|
|
3
|
+
export * from './checkpoint_attestation.js';
|
|
4
|
+
export * from './checkpoint_proposal.js';
|
|
4
5
|
export * from './consensus_payload.js';
|
|
5
6
|
export * from './gossipable.js';
|
|
6
7
|
export * from './interface.js';
|
|
7
8
|
export * from './signature_utils.js';
|
|
9
|
+
export * from './signed_txs.js';
|
|
8
10
|
export * from './topic_type.js';
|
|
9
11
|
export * from './client_type.js';
|
|
10
12
|
export * from './message_validator.js';
|
|
@@ -4,8 +4,10 @@ import { makeEthSignDigest } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
|
4
4
|
|
|
5
5
|
export enum SignatureDomainSeparator {
|
|
6
6
|
blockProposal = 0,
|
|
7
|
-
|
|
7
|
+
checkpointAttestation = 1,
|
|
8
8
|
attestationsAndSigners = 2,
|
|
9
|
+
checkpointProposal = 3,
|
|
10
|
+
signedTxs = 4,
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export interface Signable {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
|
+
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
+
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
6
|
+
|
|
7
|
+
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
8
|
+
import { Tx } from '../tx/tx.js';
|
|
9
|
+
import {
|
|
10
|
+
SignatureDomainSeparator,
|
|
11
|
+
getHashedSignaturePayload,
|
|
12
|
+
getHashedSignaturePayloadEthSignedMessage,
|
|
13
|
+
} from './signature_utils.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A signed collection of transactions.
|
|
17
|
+
* The signature is over the transaction objects themselves, providing
|
|
18
|
+
* data availability guarantees beyond just the transaction hashes.
|
|
19
|
+
*/
|
|
20
|
+
export class SignedTxs {
|
|
21
|
+
private sender: EthAddress | undefined;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
/** The transactions */
|
|
25
|
+
public readonly txs: Tx[],
|
|
26
|
+
/** The proposer's signature over the transactions */
|
|
27
|
+
public readonly signature: Signature,
|
|
28
|
+
) {}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get the payload to sign for this signed txs.
|
|
32
|
+
*/
|
|
33
|
+
getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
|
|
34
|
+
return serializeToBuffer([domainSeparator, this.txs.length, this.txs]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Lazily evaluate the sender of the signed txs; result is cached
|
|
39
|
+
* @returns The sender address, or undefined if signature recovery fails
|
|
40
|
+
*/
|
|
41
|
+
getSender(): EthAddress | undefined {
|
|
42
|
+
if (!this.sender) {
|
|
43
|
+
const hashed = getHashedSignaturePayloadEthSignedMessage(this, SignatureDomainSeparator.signedTxs);
|
|
44
|
+
this.sender = tryRecoverAddress(hashed, this.signature);
|
|
45
|
+
}
|
|
46
|
+
return this.sender;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Create SignedTxs from a signer function
|
|
51
|
+
*/
|
|
52
|
+
static async createFromSigner(
|
|
53
|
+
txs: Tx[],
|
|
54
|
+
payloadSigner: (payload: Buffer32) => Promise<Signature>,
|
|
55
|
+
): Promise<SignedTxs> {
|
|
56
|
+
const tempSignedTxs = new SignedTxs(txs, Signature.empty());
|
|
57
|
+
const hashed = getHashedSignaturePayload(tempSignedTxs, SignatureDomainSeparator.signedTxs);
|
|
58
|
+
const signature = await payloadSigner(hashed);
|
|
59
|
+
return new SignedTxs(txs, signature);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
toBuffer(): Buffer {
|
|
63
|
+
return serializeToBuffer([this.txs.length, this.txs, this.signature]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static fromBuffer(buf: Buffer | BufferReader): SignedTxs {
|
|
67
|
+
const reader = BufferReader.asReader(buf);
|
|
68
|
+
const txCount = reader.readNumber();
|
|
69
|
+
if (txCount > MAX_TXS_PER_BLOCK) {
|
|
70
|
+
throw new Error(`txs count ${txCount} exceeds maximum ${MAX_TXS_PER_BLOCK}`);
|
|
71
|
+
}
|
|
72
|
+
const txs = reader.readArray(txCount, Tx);
|
|
73
|
+
const signature = reader.readObject(Signature);
|
|
74
|
+
return new SignedTxs(txs, signature);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getSize(): number {
|
|
78
|
+
return 4 /* txs.length */ + this.txs.reduce((acc, tx) => acc + tx.getSize(), 0) + this.signature.getSize();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static empty(): SignedTxs {
|
|
82
|
+
return new SignedTxs([], Signature.empty());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static random(): SignedTxs {
|
|
86
|
+
return new SignedTxs([Tx.random(), Tx.random()], Signature.random());
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/p2p/topic_type.ts
CHANGED
|
@@ -23,12 +23,13 @@ export function getTopicFromString(topicStr: string): TopicType | undefined {
|
|
|
23
23
|
export enum TopicType {
|
|
24
24
|
tx = 'tx',
|
|
25
25
|
block_proposal = 'block_proposal',
|
|
26
|
-
|
|
26
|
+
checkpoint_proposal = 'checkpoint_proposal',
|
|
27
|
+
checkpoint_attestation = 'checkpoint_attestation',
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export function getTopicTypeForClientType(clientType: P2PClientType) {
|
|
30
31
|
if (clientType === P2PClientType.Full) {
|
|
31
|
-
return
|
|
32
|
+
return [TopicType.tx, TopicType.block_proposal, TopicType.checkpoint_proposal, TopicType.checkpoint_attestation];
|
|
32
33
|
} else if (clientType === P2PClientType.Prover) {
|
|
33
34
|
return [TopicType.tx, TopicType.block_proposal];
|
|
34
35
|
} else {
|
|
@@ -5,7 +5,7 @@ import type { BlockHeader } from '../tx/block_header.js';
|
|
|
5
5
|
|
|
6
6
|
export async function computeBlockHeadersHash(blockHeaders: BlockHeader[]): Promise<Fr> {
|
|
7
7
|
const blockHeaderHashes = await Promise.all(blockHeaders.map(header => header.hash()));
|
|
8
|
-
// Must match the implementation in merge_block_rollups.nr, with the **
|
|
8
|
+
// Must match the implementation in merge_block_rollups.nr, with the **unbalanced** rollup structure
|
|
9
9
|
// (see validate_consecutive_block_rollups.nr > assert_rollups_filled_greedily.nr).
|
|
10
10
|
const blockHeadersHash = await computeUnbalancedPoseidonRoot(blockHeaderHashes.map(hash => hash.toBuffer()));
|
|
11
11
|
return Fr.fromBuffer(blockHeadersHash);
|
|
@@ -48,8 +48,8 @@ export class BlockRollupPublicInputs {
|
|
|
48
48
|
public timestamp: UInt64,
|
|
49
49
|
/**
|
|
50
50
|
* Hash of the headers of all blocks in this block range. It will be combined with the `blockHeadersHash` from
|
|
51
|
-
* other blocks in the same checkpoint to form
|
|
52
|
-
* the checkpoint header, enabling validation of the blocks included in a checkpoint given their headers.
|
|
51
|
+
* other blocks in the same checkpoint to form an unbalanced tree. The root of that tree becomes the final hash
|
|
52
|
+
* stored in the checkpoint header, enabling validation of the blocks included in a checkpoint given their headers.
|
|
53
53
|
*/
|
|
54
54
|
public blockHeadersHash: Fr,
|
|
55
55
|
/**
|
|
@@ -14,11 +14,13 @@ import { z } from 'zod';
|
|
|
14
14
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
15
15
|
import { GasFees } from '../gas/index.js';
|
|
16
16
|
import { schemas } from '../schemas/index.js';
|
|
17
|
+
import type { GlobalVariables } from '../tx/global_variables.js';
|
|
17
18
|
import type { UInt64 } from '../types/shared.js';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Header of a checkpoint. A checkpoint is a collection of blocks submitted to L1 all within the same slot.
|
|
21
22
|
* TODO(palla/mbps): Should this include chainId and version as well? Is this used just in circuits?
|
|
23
|
+
* TODO(palla/mbps): What about CheckpointNumber?
|
|
22
24
|
*/
|
|
23
25
|
export class CheckpointHeader {
|
|
24
26
|
constructor(
|
|
@@ -30,6 +32,14 @@ export class CheckpointHeader {
|
|
|
30
32
|
public blobsHash: Fr,
|
|
31
33
|
/** Root of the l1 to l2 messages subtree. */
|
|
32
34
|
public inHash: Fr,
|
|
35
|
+
/**
|
|
36
|
+
* The root of the epoch out hash balanced tree. The out hash of the first checkpoint in the epoch is inserted at
|
|
37
|
+
* index 0, the second at index 1, and so on.
|
|
38
|
+
* Note: This is not necessarily the final epoch out hash. It includes only the out hashes of checkpoints up to and
|
|
39
|
+
* including the current checkpoint. Any subsequent checkpoints added to the same epoch are not reflected in this
|
|
40
|
+
* value.
|
|
41
|
+
*/
|
|
42
|
+
public epochOutHash: Fr,
|
|
33
43
|
/** Slot number of the L2 block */
|
|
34
44
|
public slotNumber: SlotNumber,
|
|
35
45
|
/** Timestamp of the L2 block. */
|
|
@@ -51,6 +61,7 @@ export class CheckpointHeader {
|
|
|
51
61
|
blockHeadersHash: schemas.Fr,
|
|
52
62
|
blobsHash: schemas.Fr,
|
|
53
63
|
inHash: schemas.Fr,
|
|
64
|
+
epochOutHash: schemas.Fr,
|
|
54
65
|
slotNumber: schemas.SlotNumber,
|
|
55
66
|
timestamp: schemas.BigInt,
|
|
56
67
|
coinbase: schemas.EthAddress,
|
|
@@ -67,6 +78,7 @@ export class CheckpointHeader {
|
|
|
67
78
|
fields.blockHeadersHash,
|
|
68
79
|
fields.blobsHash,
|
|
69
80
|
fields.inHash,
|
|
81
|
+
fields.epochOutHash,
|
|
70
82
|
fields.slotNumber,
|
|
71
83
|
fields.timestamp,
|
|
72
84
|
fields.coinbase,
|
|
@@ -88,6 +100,7 @@ export class CheckpointHeader {
|
|
|
88
100
|
reader.readObject(Fr),
|
|
89
101
|
reader.readObject(Fr),
|
|
90
102
|
reader.readObject(Fr),
|
|
103
|
+
reader.readObject(Fr),
|
|
91
104
|
SlotNumber(Fr.fromBuffer(reader).toNumber()),
|
|
92
105
|
reader.readUInt64(),
|
|
93
106
|
reader.readObject(EthAddress),
|
|
@@ -103,6 +116,7 @@ export class CheckpointHeader {
|
|
|
103
116
|
this.blockHeadersHash.equals(other.blockHeadersHash) &&
|
|
104
117
|
this.blobsHash.equals(other.blobsHash) &&
|
|
105
118
|
this.inHash.equals(other.inHash) &&
|
|
119
|
+
this.epochOutHash.equals(other.epochOutHash) &&
|
|
106
120
|
this.slotNumber === other.slotNumber &&
|
|
107
121
|
this.timestamp === other.timestamp &&
|
|
108
122
|
this.coinbase.equals(other.coinbase) &&
|
|
@@ -112,6 +126,17 @@ export class CheckpointHeader {
|
|
|
112
126
|
);
|
|
113
127
|
}
|
|
114
128
|
|
|
129
|
+
/** Returns true if the global variables match those in the checkpoint header. */
|
|
130
|
+
matchesGlobalVariables(other: GlobalVariables) {
|
|
131
|
+
return (
|
|
132
|
+
this.coinbase.equals(other.coinbase) &&
|
|
133
|
+
this.feeRecipient.equals(other.feeRecipient) &&
|
|
134
|
+
this.gasFees.equals(other.gasFees) &&
|
|
135
|
+
this.slotNumber === other.slotNumber &&
|
|
136
|
+
this.timestamp === other.timestamp
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
115
140
|
toBuffer() {
|
|
116
141
|
// Note: The order here must match the order in the ProposedHeaderLib solidity library.
|
|
117
142
|
return serializeToBuffer([
|
|
@@ -119,6 +144,7 @@ export class CheckpointHeader {
|
|
|
119
144
|
this.blockHeadersHash,
|
|
120
145
|
this.blobsHash,
|
|
121
146
|
this.inHash,
|
|
147
|
+
this.epochOutHash,
|
|
122
148
|
new Fr(this.slotNumber),
|
|
123
149
|
bigintToUInt64BE(this.timestamp),
|
|
124
150
|
this.coinbase,
|
|
@@ -138,6 +164,7 @@ export class CheckpointHeader {
|
|
|
138
164
|
blockHeadersHash: Fr.ZERO,
|
|
139
165
|
blobsHash: Fr.ZERO,
|
|
140
166
|
inHash: Fr.ZERO,
|
|
167
|
+
epochOutHash: Fr.ZERO,
|
|
141
168
|
slotNumber: SlotNumber.ZERO,
|
|
142
169
|
timestamp: 0n,
|
|
143
170
|
coinbase: EthAddress.ZERO,
|
|
@@ -154,6 +181,7 @@ export class CheckpointHeader {
|
|
|
154
181
|
blockHeadersHash: Fr.random(),
|
|
155
182
|
blobsHash: Fr.random(),
|
|
156
183
|
inHash: Fr.random(),
|
|
184
|
+
epochOutHash: Fr.random(),
|
|
157
185
|
slotNumber: SlotNumber(Math.floor(Math.random() * 1000) + 1),
|
|
158
186
|
timestamp: BigInt(Math.floor(Date.now() / 1000)),
|
|
159
187
|
coinbase: EthAddress.random(),
|
|
@@ -170,6 +198,7 @@ export class CheckpointHeader {
|
|
|
170
198
|
this.blockHeadersHash.isZero() &&
|
|
171
199
|
this.blobsHash.isZero() &&
|
|
172
200
|
this.inHash.isZero() &&
|
|
201
|
+
this.epochOutHash.isZero() &&
|
|
173
202
|
this.slotNumber === 0 &&
|
|
174
203
|
this.timestamp === 0n &&
|
|
175
204
|
this.coinbase.isZero() &&
|
|
@@ -197,6 +226,7 @@ export class CheckpointHeader {
|
|
|
197
226
|
Fr.fromString(header.blockHeadersHash),
|
|
198
227
|
Fr.fromString(header.blobsHash),
|
|
199
228
|
Fr.fromString(header.inHash),
|
|
229
|
+
Fr.fromString(header.outHash),
|
|
200
230
|
SlotNumber.fromBigInt(header.slotNumber),
|
|
201
231
|
header.timestamp,
|
|
202
232
|
new EthAddress(hexToBuffer(header.coinbase)),
|
|
@@ -220,6 +250,7 @@ export class CheckpointHeader {
|
|
|
220
250
|
blockHeadersHash: this.blockHeadersHash.toString(),
|
|
221
251
|
blobsHash: this.blobsHash.toString(),
|
|
222
252
|
inHash: this.inHash.toString(),
|
|
253
|
+
outHash: this.epochOutHash.toString(),
|
|
223
254
|
slotNumber: BigInt(this.slotNumber),
|
|
224
255
|
timestamp: this.timestamp,
|
|
225
256
|
coinbase: this.coinbase.toString(),
|
|
@@ -238,6 +269,7 @@ export class CheckpointHeader {
|
|
|
238
269
|
blockHeadersHash: this.blockHeadersHash.toString(),
|
|
239
270
|
blobsHash: this.blobsHash.toString(),
|
|
240
271
|
inHash: this.inHash.toString(),
|
|
272
|
+
epochOutHash: this.epochOutHash.toString(),
|
|
241
273
|
slotNumber: this.slotNumber,
|
|
242
274
|
timestamp: this.timestamp,
|
|
243
275
|
coinbase: this.coinbase.toString(),
|
|
@@ -253,6 +285,7 @@ export class CheckpointHeader {
|
|
|
253
285
|
blockHeadersHash: ${this.blockHeadersHash.toString()},
|
|
254
286
|
blobsHash: ${inspect(this.blobsHash)},
|
|
255
287
|
inHash: ${inspect(this.inHash)},
|
|
288
|
+
epochOutHash: ${inspect(this.epochOutHash)},
|
|
256
289
|
slotNumber: ${this.slotNumber},
|
|
257
290
|
timestamp: ${this.timestamp},
|
|
258
291
|
coinbase: ${this.coinbase.toString()},
|