Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 11 additions & 6 deletions yarn-project/end-to-end/src/composed/ha/e2e_ha_full.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { Logger } from '@aztec/aztec.js/log';
import type { AztecNode } from '@aztec/aztec.js/node';
import { GovernanceProposerContract } from '@aztec/ethereum/contracts';
import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
import { BlockNumber, CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
import { Buffer32 } from '@aztec/foundation/buffer';
import { SecretValue } from '@aztec/foundation/config';
import { withLoggerBindings } from '@aztec/foundation/log/server';
Expand Down Expand Up @@ -815,7 +815,8 @@ describe('HA Full Setup', () => {
rollupAddress,
validatorAddress,
slot: SlotNumber(100),
blockNumber: BlockNumber(100),
blockNumber: BlockNumber(0),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATION,
messageHash: Buffer32.random().toString(),
nodeId: 'node-utc',
Expand All @@ -840,7 +841,8 @@ describe('HA Full Setup', () => {
rollupAddress,
validatorAddress,
slot: SlotNumber(101),
blockNumber: BlockNumber(101),
blockNumber: BlockNumber(0),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATION,
messageHash: Buffer32.random().toString(),
nodeId: 'node-tokyo',
Expand Down Expand Up @@ -886,7 +888,8 @@ describe('HA Full Setup', () => {
rollupAddress,
validatorAddress,
slot: SlotNumber(200),
blockNumber: BlockNumber(200),
blockNumber: BlockNumber(0),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATION,
messageHash: Buffer32.random().toString(),
nodeId: 'test-node',
Expand Down Expand Up @@ -947,7 +950,8 @@ describe('HA Full Setup', () => {
rollupAddress,
validatorAddress,
slot: SlotNumber(300),
blockNumber: BlockNumber(300),
blockNumber: BlockNumber(0),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATION,
messageHash: Buffer32.random().toString(),
nodeId: 'test-node',
Expand Down Expand Up @@ -1012,7 +1016,8 @@ describe('HA Full Setup', () => {
rollupAddress,
validatorAddress,
slot: SlotNumber(400),
blockNumber: BlockNumber(400),
blockNumber: BlockNumber(0),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATION,
messageHash: Buffer32.random().toString(),
nodeId: 'stuck-node',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { getAddressFromPrivateKey } from '@aztec/ethereum/account';
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
import { RollupContract } from '@aztec/ethereum/contracts';
import type { DeployAztecL1ContractsReturnType } from '@aztec/ethereum/deploy-aztec-l1-contracts';
import { IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
import { type CheckpointNumber, IndexWithinCheckpoint } from '@aztec/foundation/branded-types';
import { SecretValue } from '@aztec/foundation/config';
import { retryUntil } from '@aztec/foundation/retry';
import { type EthPrivateKey, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
Expand Down Expand Up @@ -364,6 +364,7 @@ describe('e2e_multi_validator_node', () => {
const originalCreateProposal = validatorClient.createBlockProposal.bind(validatorClient);
const createBlockProposal = (
blockHeader: BlockHeader,
checkpointNumber: CheckpointNumber,
indexWithinCheckpoint: number,
inHash: Fr,
archive: Fr,
Expand All @@ -384,6 +385,7 @@ describe('e2e_multi_validator_node', () => {

return originalCreateProposal(
blockHeader,
checkpointNumber,
IndexWithinCheckpoint(indexWithinCheckpoint),
inHash,
archive,
Expand Down
2 changes: 2 additions & 0 deletions yarn-project/end-to-end/src/e2e_p2p/reex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { AztecNodeService } from '@aztec/aztec-node';
import { Fr } from '@aztec/aztec.js/fields';
import { waitForTx } from '@aztec/aztec.js/node';
import { Tx, TxHash } from '@aztec/aztec.js/tx';
import { CheckpointNumber } from '@aztec/foundation/branded-types';
import { times } from '@aztec/foundation/collection';
import { sleep } from '@aztec/foundation/sleep';
import { unfreeze } from '@aztec/foundation/types';
Expand Down Expand Up @@ -141,6 +142,7 @@ describe('e2e_p2p_reex', () => {
.keyStore as ValidatorKeyStore;
const newProposal = await BlockProposal.createProposalFromSigner(
proposal.blockHeader,
CheckpointNumber(1),
proposal.indexWithinCheckpoint,
proposal.inHash,
proposal.archiveRoot,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ describe('CheckpointProposalJob', () => {
validatorClient = mock<ValidatorClient>();
validatorClient.collectAttestations.mockImplementation(() => Promise.resolve([]));
validatorClient.createBlockProposal.mockImplementation(
async (blockHeader, indexWithinCheckpoint, inHash, archiveRoot, txs) => {
async (blockHeader, _checkpointNumber, indexWithinCheckpoint, inHash, archiveRoot, txs) => {
const txHashes = await Promise.all((txs ?? []).map((tx: Tx) => tx.getTxHash()));
return new BlockProposal(
blockHeader,
Expand All @@ -243,7 +243,7 @@ describe('CheckpointProposalJob', () => {
},
);
validatorClient.createCheckpointProposal.mockImplementation(
async (checkpointHeader, archiveRoot, feeAssetPriceModifier, lastBlockInfo) => {
async (checkpointHeader, archiveRoot, _checkpointNumber, feeAssetPriceModifier, lastBlockInfo) => {
if (!lastBlockInfo) {
return new CheckpointProposal(checkpointHeader, archiveRoot, feeAssetPriceModifier, mockedSig);
}
Expand Down Expand Up @@ -377,6 +377,7 @@ describe('CheckpointProposalJob', () => {
expect.anything(),
expect.any(Number),
expect.any(Date),
checkpointNumber,
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ export class CheckpointProposalJob implements Traceable {
const proposal = await this.validatorClient.createCheckpointProposal(
checkpoint.header,
checkpoint.archive.root,
this.checkpointNumber,
feeAssetPriceModifier,
blockPendingBroadcast,
this.proposer,
Expand Down Expand Up @@ -626,6 +627,7 @@ export class CheckpointProposalJob implements Traceable {
}
return this.validatorClient.createBlockProposal(
block.header,
this.checkpointNumber,
block.indexWithinCheckpoint,
inHash,
block.archive.root,
Expand Down Expand Up @@ -877,7 +879,7 @@ export class CheckpointProposalJob implements Traceable {

if (this.config.skipCollectingAttestations) {
this.log.warn('Skipping attestation collection as per config (attesting with own keys only)');
const attestations = await this.validatorClient?.collectOwnAttestations(proposal);
const attestations = await this.validatorClient?.collectOwnAttestations(proposal, this.checkpointNumber);
return new CommitteeAttestationsAndSigners(orderAttestations(attestations ?? [], committee));
}

Expand All @@ -895,6 +897,7 @@ export class CheckpointProposalJob implements Traceable {
proposal,
numberOfRequiredAttestations,
attestationDeadline,
this.checkpointNumber,
);

collectedAttestationsCount = attestations.length;
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/stdlib/src/ha-signing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ export {
} from './local_config.js';
export {
DutyType,
type AttestationSigningContext,
type BlockProposalSigningContext,
type CheckpointProposalSigningContext,
type HAProtectedSigningContext,
type NoHAProtectionSigningContext,
type OtherSigningContext,
type SigningContext,
type VoteSigningContext,
getBlockNumberFromSigningContext,
getCheckpointNumberFromSigningContext,
isHAProtectedContext,
} from './types.js';
36 changes: 20 additions & 16 deletions yarn-project/stdlib/src/ha-signing/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from
import { describe, expect, it } from '@jest/globals';

import {
type AttestationSigningContext,
type BlockProposalSigningContext,
type CheckpointProposalSigningContext,
DutyType,
type HAProtectedSigningContext,
type OtherSigningContext,
type VoteSigningContext,
getBlockNumberFromSigningContext,
} from './types.js';
Expand All @@ -17,44 +18,46 @@ describe('getBlockNumberFromSigningContext', () => {
const context: BlockProposalSigningContext = {
slot: SlotNumber(100),
blockNumber: BlockNumber(50),
checkpointNumber: CheckpointNumber(1),
dutyType: DutyType.BLOCK_PROPOSAL,
blockIndexWithinCheckpoint: IndexWithinCheckpoint(0),
};
expect(getBlockNumberFromSigningContext(context)).toBe(BlockNumber(50));
});

it('should return blockNumber for CHECKPOINT_PROPOSAL', () => {
const context: OtherSigningContext = {
it('should return BlockNumber(0) for CHECKPOINT_PROPOSAL', () => {
const context: CheckpointProposalSigningContext = {
slot: SlotNumber(100),
blockNumber: CheckpointNumber(25),
checkpointNumber: CheckpointNumber(25),
dutyType: DutyType.CHECKPOINT_PROPOSAL,
};
expect(getBlockNumberFromSigningContext(context)).toBe(CheckpointNumber(25));
expect(getBlockNumberFromSigningContext(context)).toBe(BlockNumber(0));
});

it('should return blockNumber for ATTESTATION', () => {
const context: OtherSigningContext = {
it('should return BlockNumber(0) for ATTESTATION', () => {
const context: AttestationSigningContext = {
slot: SlotNumber(100),
blockNumber: BlockNumber(50),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATION,
};
expect(getBlockNumberFromSigningContext(context)).toBe(BlockNumber(50));
expect(getBlockNumberFromSigningContext(context)).toBe(BlockNumber(0));
});

it('should return blockNumber for ATTESTATIONS_AND_SIGNERS', () => {
const context: OtherSigningContext = {
it('should return BlockNumber(0) for ATTESTATIONS_AND_SIGNERS', () => {
const context: AttestationSigningContext = {
slot: SlotNumber(100),
blockNumber: BlockNumber(50),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATIONS_AND_SIGNERS,
};
expect(getBlockNumberFromSigningContext(context)).toBe(BlockNumber(50));
expect(getBlockNumberFromSigningContext(context)).toBe(BlockNumber(0));
});

it('should handle large block numbers', () => {
const largeBlockNumber = BlockNumber(Number.MAX_SAFE_INTEGER);
const context: BlockProposalSigningContext = {
slot: SlotNumber(100),
blockNumber: largeBlockNumber,
checkpointNumber: CheckpointNumber(1),
dutyType: DutyType.BLOCK_PROPOSAL,
blockIndexWithinCheckpoint: IndexWithinCheckpoint(0),
};
Expand Down Expand Up @@ -94,22 +97,23 @@ describe('getBlockNumberFromSigningContext', () => {
{
slot: SlotNumber(100),
blockNumber: BlockNumber(50),
checkpointNumber: CheckpointNumber(1),
dutyType: DutyType.BLOCK_PROPOSAL,
blockIndexWithinCheckpoint: IndexWithinCheckpoint(0),
},
{
slot: SlotNumber(100),
blockNumber: BlockNumber(50),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATION,
},
{
slot: SlotNumber(100),
blockNumber: BlockNumber(50),
checkpointNumber: CheckpointNumber(0),
dutyType: DutyType.ATTESTATIONS_AND_SIGNERS,
},
{
slot: SlotNumber(100),
blockNumber: CheckpointNumber(25),
checkpointNumber: CheckpointNumber(25),
dutyType: DutyType.CHECKPOINT_PROPOSAL,
},
{
Expand Down
Loading
Loading