Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions yarn-project/stdlib/src/p2p/checkpoint_proposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,32 @@ export class CheckpointProposal extends Gossipable {
blockNumber: lastBlockInfo?.blockHeader?.globalVariables.blockNumber ?? BlockNumber(0),
dutyType: DutyType.CHECKPOINT_PROPOSAL,
};
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);

if (!lastBlockInfo) {
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
if (lastBlockInfo) {
// Sign block proposal before signing checkpoint proposal to ensure HA protection
const lastBlockProposal = await BlockProposal.createProposalFromSigner(
lastBlockInfo.blockHeader,
lastBlockInfo.indexWithinCheckpoint,
checkpointHeader.inHash,
archiveRoot,
lastBlockInfo.txHashes,
lastBlockInfo.txs,
payloadSigner,
);

const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);

return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
blockHeader: lastBlockInfo.blockHeader,
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
txHashes: lastBlockInfo.txHashes,
signature: lastBlockProposal.signature,
signedTxs: lastBlockProposal.signedTxs,
});
}

const lastBlockProposal = await BlockProposal.createProposalFromSigner(
lastBlockInfo.blockHeader,
lastBlockInfo.indexWithinCheckpoint,
checkpointHeader.inHash,
archiveRoot,
lastBlockInfo.txHashes,
lastBlockInfo.txs,
payloadSigner,
);

return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature, {
blockHeader: lastBlockInfo.blockHeader,
indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
txHashes: lastBlockInfo.txHashes,
signature: lastBlockProposal.signature,
signedTxs: lastBlockProposal.signedTxs,
});
const checkpointSignature = await payloadSigner(checkpointHash, checkpointContext);
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, checkpointSignature);
}

/**
Expand Down
Loading