Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: epoch cache, do not attest if not in committee or from current proposer #10327

Merged
merged 29 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e2d7829
feat: delete attestations older than a slot
Maddiaa0 Nov 30, 2024
67ea59c
fmt
Maddiaa0 Nov 30, 2024
b95bcef
test: attestation pool pruning
Maddiaa0 Nov 30, 2024
f6ac466
fmt
Maddiaa0 Nov 30, 2024
e67eaef
feat: epoch cache, do not attest if not in committee or from current …
Maddiaa0 Nov 30, 2024
0265e47
cleanup
Maddiaa0 Nov 30, 2024
6a795ea
test: validator client tests
Maddiaa0 Nov 30, 2024
50eaa4c
fmt
Maddiaa0 Nov 30, 2024
98b118a
fmt + test
Maddiaa0 Dec 2, 2024
6507c02
tmp
Maddiaa0 Dec 3, 2024
97f35c3
fix: next and current slot
Maddiaa0 Dec 5, 2024
7003114
fmt
Maddiaa0 Dec 5, 2024
452e781
Merge branch 'master' into md/epoch-cache--
Maddiaa0 Dec 5, 2024
8c8df0c
post merge fix
Maddiaa0 Dec 5, 2024
e2b43fb
fix: ordering
Maddiaa0 Dec 5, 2024
e0976bb
fix: ordering
Maddiaa0 Dec 5, 2024
da87b55
fix
Maddiaa0 Dec 5, 2024
5fc9900
fix: linter and test
just-mitch Dec 5, 2024
17353cf
Merge branch 'master' into md/epoch-cache--
just-mitch Dec 5, 2024
bcbcccd
fix: merge conflicts
just-mitch Dec 5, 2024
1309414
fix: function ordering and p2p tests
just-mitch Dec 5, 2024
6aba551
fix: reex test - sending same proposal twice in one slot
Maddiaa0 Dec 6, 2024
82da16b
fix: for a slot ci runner, decrease the time jump length
Maddiaa0 Dec 6, 2024
13ec8e4
fix: epoch cache flake
Maddiaa0 Dec 6, 2024
676b7ed
fix: in native testnet, deploy validators at genesis
Maddiaa0 Dec 6, 2024
ca99658
fix: run interleaved
Maddiaa0 Dec 6, 2024
e955e8d
fix: earthfile
Maddiaa0 Dec 6, 2024
dd88dbf
Merge branch 'master' into md/epoch-cache--
Maddiaa0 Dec 6, 2024
38f4b15
fix: unused import
just-mitch Dec 6, 2024
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
36 changes: 36 additions & 0 deletions l1-contracts/src/core/Leonidas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,42 @@ contract Leonidas is Ownable, TimeFns, ILeonidas {
return store.validatorSet.values();
}

/**
* @notice Get the committee for a given timestamp
*
* @param _ts - The timestamp to get the committee for
*
* @return The committee for the given timestamp
*/
function getCommitteeAt(Timestamp _ts)
external
view
override(ILeonidas)
returns (address[] memory)
{
return store.getCommitteeAt(getEpochAt(_ts), TARGET_COMMITTEE_SIZE);
}

/**
* @notice Get the sample seed for a given timestamp
*
* @param _ts - The timestamp to get the sample seed for
*
* @return The sample seed for the given timestamp
*/
function getSampleSeedAt(Timestamp _ts) external view override(ILeonidas) returns (uint256) {
return store.getSampleSeed(getEpochAt(_ts));
}

/**
* @notice Get the sample seed for the current epoch
*
* @return The sample seed for the current epoch
*/
function getCurrentSampleSeed() external view override(ILeonidas) returns (uint256) {
return store.getSampleSeed(getCurrentEpoch());
}

/**
* @notice Performs a setup of an epoch if needed. The setup will
* - Sample the validator set for the epoch
Expand Down
4 changes: 4 additions & 0 deletions l1-contracts/src/core/interfaces/ILeonidas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ interface ILeonidas {
// Likely removal of these to replace with a size and indiviual getter
// Get the current epoch committee
function getCurrentEpochCommittee() external view returns (address[] memory);
function getCommitteeAt(Timestamp _ts) external view returns (address[] memory);
function getEpochCommittee(Epoch _epoch) external view returns (address[] memory);
function getValidators() external view returns (address[] memory);

function getSampleSeedAt(Timestamp _ts) external view returns (uint256);
function getCurrentSampleSeed() external view returns (uint256);

function getEpochAt(Timestamp _ts) external view returns (Epoch);
function getSlotAt(Timestamp _ts) external view returns (Slot);
function getEpochAtSlot(Slot _slotNumber) external view returns (Epoch);
Expand Down
28 changes: 6 additions & 22 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
EmptyL1RollupConstants,
type GetUnencryptedLogsResponse,
type InBlock,
type InboxLeaf,
type L1RollupConstants,
type L1ToL2MessageSource,
type L2Block,
type L2BlockId,
Expand All @@ -15,6 +17,10 @@ import {
type TxReceipt,
type TxScopedL2Log,
type UnencryptedL2Log,
getEpochNumberAtTimestamp,
getSlotAtTimestamp,
getSlotRangeForEpoch,
getTimestampRangeForEpoch,
} from '@aztec/circuit-types';
import {
type ContractClassPublic,
Expand Down Expand Up @@ -62,12 +68,6 @@ import {
import { type ArchiverDataStore, type ArchiverL1SynchPoint } from './archiver_store.js';
import { type ArchiverConfig } from './config.js';
import { retrieveBlockFromRollup, retrieveL1ToL2Messages } from './data_retrieval.js';
import {
getEpochNumberAtTimestamp,
getSlotAtTimestamp,
getSlotRangeForEpoch,
getTimestampRangeForEpoch,
} from './epoch_helpers.js';
import { ArchiverInstrumentation } from './instrumentation.js';
import { type DataRetrieval } from './structs/data_retrieval.js';
import { type L1Published } from './structs/published.js';
Expand Down Expand Up @@ -1068,19 +1068,3 @@ class ArchiverStoreHelper
return this.store.estimateSize();
}
}

type L1RollupConstants = {
l1StartBlock: bigint;
l1GenesisTime: bigint;
slotDuration: number;
epochDuration: number;
ethereumSlotDuration: number;
};

const EmptyL1RollupConstants: L1RollupConstants = {
l1StartBlock: 0n,
l1GenesisTime: 0n,
epochDuration: 0,
slotDuration: 0,
ethereumSlotDuration: 0,
};
3 changes: 1 addition & 2 deletions yarn-project/archiver/src/test/mock_l2_block_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import {
TxReceipt,
TxStatus,
} from '@aztec/circuit-types';
import { getSlotRangeForEpoch } from '@aztec/circuit-types';
import { EthAddress, type Header } from '@aztec/circuits.js';
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
import { createDebugLogger } from '@aztec/foundation/log';

import { getSlotRangeForEpoch } from '../archiver/epoch_helpers.js';

/**
* A mocked implementation of L2BlockSource to be used in tests.
*/
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class AztecNodeService implements AztecNode {
// start both and wait for them to sync from the block source
await Promise.all([p2pClient.start(), worldStateSynchronizer.start()]);

const validatorClient = createValidatorClient(config, p2pClient, telemetry);
const validatorClient = await createValidatorClient(config, config.l1Contracts.rollupAddress, p2pClient, telemetry);

// now create the sequencer
const sequencer = config.disableValidator
Expand Down
8 changes: 5 additions & 3 deletions yarn-project/aztec.js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export {
type ContractNotes,
type ContractStorageLayout,
type DeployOptions,
type ProfileResult,
type SendMethodOptions,
type WaitOpts,
type ProfileResult,
} from './contract/index.js';

export { ContractDeployer } from './deployment/index.js';
Expand All @@ -59,8 +59,8 @@ export {
type FieldLike,
type FunctionSelectorLike,
type L2AmountClaim,
type L2Claim,
type L2AmountClaimWithRecipient,
type L2Claim,
type WrappedFieldLike,
} from './utils/index.js';

Expand Down Expand Up @@ -138,10 +138,12 @@ export {
UnencryptedL2Log,
UniqueNote,
createAztecNodeClient,
getTimestampRangeForEpoch,
merkleTreeIds,
mockEpochProofQuote,
mockTx,
type AztecNode,
type EpochConstants,
type LogFilter,
type PXE,
type PartialAddress,
Expand All @@ -164,7 +166,7 @@ export { elapsed } from '@aztec/foundation/timer';
export { type FieldsOf } from '@aztec/foundation/types';
export { fileURLToPath } from '@aztec/foundation/url';

export { type DeployL1Contracts, EthCheatCodes, deployL1Contract, deployL1Contracts } from '@aztec/ethereum';
export { EthCheatCodes, deployL1Contract, deployL1Contracts, type DeployL1Contracts } from '@aztec/ethereum';

// Start of section that exports public api via granular api.
// Here you *can* do `export *` as the granular api defacto exports things explicitly.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
// REFACTOR: This file should go in a package lower in the dependency graph.
export type L1RollupConstants = {
l1StartBlock: bigint;
l1GenesisTime: bigint;
slotDuration: number;
epochDuration: number;
ethereumSlotDuration: number;
};

export const EmptyL1RollupConstants: L1RollupConstants = {
l1StartBlock: 0n,
l1GenesisTime: 0n,
epochDuration: 1, // Not 0 to pervent division by zero
slotDuration: 1,
ethereumSlotDuration: 1,
};

export type EpochConstants = {
l1GenesisBlock: bigint;
Expand Down
1 change: 1 addition & 0 deletions yarn-project/circuit-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export * from './tx_execution_request.js';
export * from './in_block.js';
export * from './nullifier_with_block_source.js';
export * from './proving_error.js';
export * from './epoch-helpers/index.js';
1 change: 1 addition & 0 deletions yarn-project/end-to-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"devDependencies": {
"0x": "^5.7.0",
"@jest/globals": "^29.5.0",
"@sinonjs/fake-timers": "^13.0.5",
"@types/jest": "^29.5.0",
"@types/js-yaml": "^4.0.9",
"@types/lodash.chunk": "^4.2.9",
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_epochs.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type EpochConstants, getTimestampRangeForEpoch } from '@aztec/archiver/epoch';
import { type DebugLogger, retryUntil } from '@aztec/aztec.js';
// eslint-disable-next-line no-restricted-imports
import { type DebugLogger, type EpochConstants, getTimestampRangeForEpoch, retryUntil } from '@aztec/aztec.js';
import { RollupContract } from '@aztec/ethereum/contracts';
import { type Delayer, waitUntilL1Timestamp } from '@aztec/ethereum/test';

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/e2e_p2p/gossip_network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ describe('e2e_p2p_network', () => {
testName: 'e2e_p2p_network',
numberOfNodes: NUM_NODES,
basePort: BOOT_NODE_UDP_PORT,
// To collect metrics - run in aztec-packages `docker compose --profile metrics up` and set COLLECT_METRICS=true
metricsPort: shouldCollectMetrics(),
});

await t.applyBaseSnapshots();
await t.setup();
});
Expand Down
Loading
Loading