diff --git a/docs/docs/guides/developer_guides/js_apps/test.md b/docs/docs/guides/developer_guides/js_apps/test.md index f06258f2cca..19f10a7c56d 100644 --- a/docs/docs/guides/developer_guides/js_apps/test.md +++ b/docs/docs/guides/developer_guides/js_apps/test.md @@ -134,7 +134,7 @@ The [`CheatCodes`](../../../reference/developer_references/sandbox_reference/che ### Set next block timestamp Since the rollup time is dependent on what "slot" the block is included in, time can be progressed by progressing slots. -The duration of a slot is available by calling `SLOT_DURATION()` on the Rollup (code in Leonidas.sol). +The duration of a slot is available by calling `getSlotDuration()` on the Rollup (code in Leonidas.sol). You can then use the `warp` function on the EthCheatCodes to progress the underlying chain. diff --git a/l1-contracts/src/core/ProofCommitmentEscrow.sol b/l1-contracts/src/core/ProofCommitmentEscrow.sol index e4773525932..c11c2a35853 100644 --- a/l1-contracts/src/core/ProofCommitmentEscrow.sol +++ b/l1-contracts/src/core/ProofCommitmentEscrow.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {IProofCommitmentEscrow} from "@aztec/core/interfaces/IProofCommitmentEscrow.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol"; diff --git a/l1-contracts/src/core/Rollup.sol b/l1-contracts/src/core/Rollup.sol index ea820587138..90486a7395e 100644 --- a/l1-contracts/src/core/Rollup.sol +++ b/l1-contracts/src/core/Rollup.sol @@ -34,7 +34,7 @@ import { } from "@aztec/core/libraries/RollupLibs/ExtRollupLib.sol"; import {IntRollupLib, EpochProofQuote} from "@aztec/core/libraries/RollupLibs/IntRollupLib.sol"; import {ProposeArgs, ProposeLib} from "@aztec/core/libraries/RollupLibs/ProposeLib.sol"; -import {Timestamp, Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot, Epoch, TimeLib} from "@aztec/core/libraries/TimeLib.sol"; import {Inbox} from "@aztec/core/messagebridge/Inbox.sol"; import {Outbox} from "@aztec/core/messagebridge/Outbox.sol"; import {ProofCommitmentEscrow} from "@aztec/core/ProofCommitmentEscrow.sol"; @@ -63,8 +63,6 @@ struct Config { * @dev WARNING: This contract is VERY close to the size limit (500B at time of writing). */ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, ValidatorSelection, IRollup, ITestRollup { - using SlotLib for Slot; - using EpochLib for Epoch; using ProposeLib for ProposeArgs; using IntRollupLib for uint256; using IntRollupLib for ManaBaseFeeComponents; @@ -662,7 +660,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, ValidatorSelection, IRo rollupStore.blocks[blockOfInterest].feeHeader, getL1FeesAt(_timestamp), _inFeeAsset ? getFeeAssetPrice() : 1e9, - EPOCH_DURATION + TimeLib.getStorage().epochDuration ); } @@ -683,7 +681,7 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, ValidatorSelection, IRo Slot currentSlot = getSlotAt(_ts); address currentProposer = getProposerAt(_ts); Epoch epochToProve = getEpochToProve(); - uint256 posInEpoch = positionInEpoch(currentSlot); + uint256 posInEpoch = TimeLib.positionInEpoch(currentSlot); bytes32 digest = quoteToDigest(_quote.quote); ExtRollupLib.validateEpochProofRightClaimAtTime( @@ -786,16 +784,17 @@ contract Rollup is EIP712("Aztec Rollup", "1"), Ownable, ValidatorSelection, IRo Slot currentSlot = getSlotAt(_ts); Epoch oldestPendingEpoch = getEpochForBlock(rollupStore.tips.provenBlockNumber + 1); - Slot startSlotOfPendingEpoch = toSlots(oldestPendingEpoch); + Slot startSlotOfPendingEpoch = TimeLib.toSlots(oldestPendingEpoch); // suppose epoch 1 is proven, epoch 2 is pending, epoch 3 is the current epoch. // we prune the pending chain back to the end of epoch 1 if: // - the proof claim phase of epoch 3 has ended without a claim to prove epoch 2 (or proof of epoch 2) // - we reach epoch 4 without a proof of epoch 2 (regardless of whether a proof claim was submitted) bool inClaimPhase = currentSlot - < startSlotOfPendingEpoch + toSlots(Epoch.wrap(1)) + Slot.wrap(CLAIM_DURATION_IN_L2_SLOTS); + < startSlotOfPendingEpoch + TimeLib.toSlots(Epoch.wrap(1)) + + Slot.wrap(CLAIM_DURATION_IN_L2_SLOTS); - bool claimExists = currentSlot < startSlotOfPendingEpoch + toSlots(Epoch.wrap(2)) + bool claimExists = currentSlot < startSlotOfPendingEpoch + TimeLib.toSlots(Epoch.wrap(2)) && rollupStore.proofClaim.epochToProve == oldestPendingEpoch && rollupStore.proofClaim.proposerClaimant != address(0); diff --git a/l1-contracts/src/core/ValidatorSelection.sol b/l1-contracts/src/core/ValidatorSelection.sol index 84f65ac1093..1d065cfaf26 100644 --- a/l1-contracts/src/core/ValidatorSelection.sol +++ b/l1-contracts/src/core/ValidatorSelection.sol @@ -11,8 +11,8 @@ import {Signature} from "@aztec/core/libraries/crypto/SignatureLib.sol"; import {DataStructures} from "@aztec/core/libraries/DataStructures.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; import { - Timestamp, Slot, Epoch, SlotLib, EpochLib, TimeFns -} from "@aztec/core/libraries/TimeMath.sol"; + Timestamp, Slot, Epoch, SlotLib, EpochLib, TimeLib +} from "@aztec/core/libraries/TimeLib.sol"; import {ValidatorSelectionLib} from "@aztec/core/libraries/ValidatorSelectionLib/ValidatorSelectionLib.sol"; import {Staking} from "@aztec/core/staking/Staking.sol"; @@ -27,19 +27,19 @@ import {EnumerableSet} from "@oz/utils/structs/EnumerableSet.sol"; * It is a reference implementation, it is not optimized for gas. * */ -contract ValidatorSelection is Staking, TimeFns, IValidatorSelection { +contract ValidatorSelection is Staking, IValidatorSelection { using EnumerableSet for EnumerableSet.AddressSet; using SlotLib for Slot; using EpochLib for Epoch; + using TimeLib for Timestamp; + using TimeLib for Slot; + using TimeLib for Epoch; // The target number of validators in a committee // @todo #8021 uint256 public immutable TARGET_COMMITTEE_SIZE; - // The time that the contract was deployed - Timestamp public immutable GENESIS_TIME; - ValidatorSelectionStorage private validatorSelectionStore; constructor( @@ -50,14 +50,22 @@ contract ValidatorSelection is Staking, TimeFns, IValidatorSelection { uint256 _slotDuration, uint256 _epochDuration, uint256 _targetCommitteeSize - ) - Staking(_stakingAsset, _minimumStake, _slashingQuorum, _roundSize) - TimeFns(_slotDuration, _epochDuration) - { - GENESIS_TIME = Timestamp.wrap(block.timestamp); - SLOT_DURATION = _slotDuration; - EPOCH_DURATION = _epochDuration; + ) Staking(_stakingAsset, _minimumStake, _slashingQuorum, _roundSize) { TARGET_COMMITTEE_SIZE = _targetCommitteeSize; + + TimeLib.initialize(block.timestamp, _slotDuration, _epochDuration); + } + + function getGenesisTime() external view override(IValidatorSelection) returns (Timestamp) { + return Timestamp.wrap(TimeLib.getStorage().genesisTime); + } + + function getSlotDuration() external view override(IValidatorSelection) returns (uint256) { + return TimeLib.getStorage().slotDuration; + } + + function getEpochDuration() external view override(IValidatorSelection) returns (uint256) { + return TimeLib.getStorage().epochDuration; } /** @@ -224,7 +232,7 @@ contract ValidatorSelection is Staking, TimeFns, IValidatorSelection { override(IValidatorSelection) returns (Timestamp) { - return GENESIS_TIME + toTimestamp(_slotNumber); + return _slotNumber.toTimestamp(); } /** @@ -275,7 +283,7 @@ contract ValidatorSelection is Staking, TimeFns, IValidatorSelection { * @return The computed epoch */ function getEpochAt(Timestamp _ts) public view override(IValidatorSelection) returns (Epoch) { - return _ts < GENESIS_TIME ? Epoch.wrap(0) : epochFromTimestamp(_ts - GENESIS_TIME); + return _ts.epochFromTimestamp(); } /** @@ -286,7 +294,7 @@ contract ValidatorSelection is Staking, TimeFns, IValidatorSelection { * @return The computed slot */ function getSlotAt(Timestamp _ts) public view override(IValidatorSelection) returns (Slot) { - return _ts < GENESIS_TIME ? Slot.wrap(0) : slotFromTimestamp(_ts - GENESIS_TIME); + return _ts.slotFromTimestamp(); } /** @@ -302,7 +310,7 @@ contract ValidatorSelection is Staking, TimeFns, IValidatorSelection { override(IValidatorSelection) returns (Epoch) { - return Epoch.wrap(_slotNumber.unwrap() / EPOCH_DURATION); + return _slotNumber.epochFromSlot(); } // Can be used to add validators without setting up the epoch, useful for the initial set. diff --git a/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol b/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol index f73333c8396..87ef34e0219 100644 --- a/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol +++ b/l1-contracts/src/core/interfaces/IProofCommitmentEscrow.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; interface IProofCommitmentEscrow { diff --git a/l1-contracts/src/core/interfaces/IRollup.sol b/l1-contracts/src/core/interfaces/IRollup.sol index 0edcd7df1d4..c8216166cf0 100644 --- a/l1-contracts/src/core/interfaces/IRollup.sol +++ b/l1-contracts/src/core/interfaces/IRollup.sol @@ -15,7 +15,7 @@ import { FeeHeader, L1FeeData, ManaBaseFeeComponents } from "@aztec/core/libraries/RollupLibs/FeeMath.sol"; import {ProposeArgs} from "@aztec/core/libraries/RollupLibs/ProposeLib.sol"; -import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol"; struct SubmitEpochRootProofArgs { uint256 epochSize; diff --git a/l1-contracts/src/core/interfaces/IStaking.sol b/l1-contracts/src/core/interfaces/IStaking.sol index e2d469dd8a3..63363af287b 100644 --- a/l1-contracts/src/core/interfaces/IStaking.sol +++ b/l1-contracts/src/core/interfaces/IStaking.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {EnumerableSet} from "@oz/utils/structs/EnumerableSet.sol"; // None -> Does not exist in our setup diff --git a/l1-contracts/src/core/interfaces/IValidatorSelection.sol b/l1-contracts/src/core/interfaces/IValidatorSelection.sol index 4216f5f9e0f..07dab165693 100644 --- a/l1-contracts/src/core/interfaces/IValidatorSelection.sol +++ b/l1-contracts/src/core/interfaces/IValidatorSelection.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol"; /** * @notice The data structure for an epoch @@ -49,4 +49,8 @@ interface IValidatorSelection { function getEpochAt(Timestamp _ts) external view returns (Epoch); function getSlotAt(Timestamp _ts) external view returns (Slot); function getEpochAtSlot(Slot _slotNumber) external view returns (Epoch); + + function getGenesisTime() external view returns (Timestamp); + function getSlotDuration() external view returns (uint256); + function getEpochDuration() external view returns (uint256); } diff --git a/l1-contracts/src/core/libraries/DataStructures.sol b/l1-contracts/src/core/libraries/DataStructures.sol index 61accf40655..66b9acbbc52 100644 --- a/l1-contracts/src/core/libraries/DataStructures.sol +++ b/l1-contracts/src/core/libraries/DataStructures.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Epoch} from "@aztec/core/libraries/TimeLib.sol"; /** * @title Data Structures Library diff --git a/l1-contracts/src/core/libraries/Errors.sol b/l1-contracts/src/core/libraries/Errors.sol index 1d3d155ace8..9084c90fa4b 100644 --- a/l1-contracts/src/core/libraries/Errors.sol +++ b/l1-contracts/src/core/libraries/Errors.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol"; /** * @title Errors Library diff --git a/l1-contracts/src/core/libraries/RollupLibs/EpochProofLib.sol b/l1-contracts/src/core/libraries/RollupLibs/EpochProofLib.sol index e5279d42b41..ef87ec9eb50 100644 --- a/l1-contracts/src/core/libraries/RollupLibs/EpochProofLib.sol +++ b/l1-contracts/src/core/libraries/RollupLibs/EpochProofLib.sol @@ -9,7 +9,7 @@ import { } from "@aztec/core/interfaces/IRollup.sol"; import {Constants} from "@aztec/core/libraries/ConstantsGen.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Epoch} from "@aztec/core/libraries/TimeLib.sol"; import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol"; diff --git a/l1-contracts/src/core/libraries/RollupLibs/EpochProofQuoteLib.sol b/l1-contracts/src/core/libraries/RollupLibs/EpochProofQuoteLib.sol index bfa865d6d4e..4165263facb 100644 --- a/l1-contracts/src/core/libraries/RollupLibs/EpochProofQuoteLib.sol +++ b/l1-contracts/src/core/libraries/RollupLibs/EpochProofQuoteLib.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.27; import {Signature} from "@aztec/core/libraries/crypto/SignatureLib.sol"; -import {Slot, Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol"; /** * @notice Struct encompassing an epoch proof quote diff --git a/l1-contracts/src/core/libraries/RollupLibs/ExtRollupLib.sol b/l1-contracts/src/core/libraries/RollupLibs/ExtRollupLib.sol index aa8167d8029..3676a5d13c6 100644 --- a/l1-contracts/src/core/libraries/RollupLibs/ExtRollupLib.sol +++ b/l1-contracts/src/core/libraries/RollupLibs/ExtRollupLib.sol @@ -9,7 +9,7 @@ import {BlockLog, RollupStore, SubmitEpochRootProofArgs} from "@aztec/core/inter import {IRewardDistributor} from "@aztec/governance/interfaces/IRewardDistributor.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {DataStructures} from "./../DataStructures.sol"; -import {Slot, Epoch} from "./../TimeMath.sol"; +import {Slot, Epoch} from "./../TimeLib.sol"; import {BlobLib} from "./BlobLib.sol"; import { EpochProofLib, diff --git a/l1-contracts/src/core/libraries/RollupLibs/ValidationLib.sol b/l1-contracts/src/core/libraries/RollupLibs/ValidationLib.sol index 7d0b2861b38..3738b5f7920 100644 --- a/l1-contracts/src/core/libraries/RollupLibs/ValidationLib.sol +++ b/l1-contracts/src/core/libraries/RollupLibs/ValidationLib.sol @@ -8,7 +8,7 @@ import {BlockLog} from "@aztec/core/interfaces/IRollup.sol"; import {SignatureLib} from "@aztec/core/libraries/crypto/SignatureLib.sol"; import {DataStructures} from "./../DataStructures.sol"; import {Errors} from "./../Errors.sol"; -import {Timestamp, Slot, Epoch} from "./../TimeMath.sol"; +import {Timestamp, Slot, Epoch} from "./../TimeLib.sol"; import {SignedEpochProofQuote} from "./EpochProofQuoteLib.sol"; import {Header} from "./HeaderLib.sol"; diff --git a/l1-contracts/src/core/libraries/TimeLib.sol b/l1-contracts/src/core/libraries/TimeLib.sol new file mode 100644 index 00000000000..ef8edbe7485 --- /dev/null +++ b/l1-contracts/src/core/libraries/TimeLib.sol @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024 Aztec Labs. +pragma solidity >=0.8.27; + +// solhint-disable-next-line no-unused-import +import {Timestamp, Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol"; + +struct TimeStorage { + uint256 genesisTime; + uint256 slotDuration; // Number of seconds in a slot + uint256 epochDuration; // Number of slots in an epoch +} + +library TimeLib { + bytes32 private constant TIME_STORAGE_POSITION = keccak256("aztec.time.storage"); + + function initialize(uint256 _genesisTime, uint256 _slotDuration, uint256 _epochDuration) internal { + TimeStorage storage store = getStorage(); + store.genesisTime = _genesisTime; + store.slotDuration = _slotDuration; + store.epochDuration = _epochDuration; + } + + function toTimestamp(Slot _a) internal view returns (Timestamp) { + TimeStorage storage store = getStorage(); + return Timestamp.wrap(store.genesisTime) + Timestamp.wrap(Slot.unwrap(_a) * store.slotDuration); + } + + function slotFromTimestamp(Timestamp _a) internal view returns (Slot) { + TimeStorage storage store = getStorage(); + return Slot.wrap((Timestamp.unwrap(_a) - store.genesisTime) / store.slotDuration); + } + + function positionInEpoch(Slot _a) internal view returns (uint256) { + return Slot.unwrap(_a) % getStorage().epochDuration; + } + + function toSlots(Epoch _a) internal view returns (Slot) { + return Slot.wrap(Epoch.unwrap(_a) * getStorage().epochDuration); + } + + function toTimestamp(Epoch _a) internal view returns (Timestamp) { + return toTimestamp(toSlots(_a)); + } + + function epochFromTimestamp(Timestamp _a) internal view returns (Epoch) { + TimeStorage storage store = getStorage(); + return Epoch.wrap( + (Timestamp.unwrap(_a) - store.genesisTime) / (store.epochDuration * store.slotDuration) + ); + } + + function epochFromSlot(Slot _a) internal view returns (Epoch) { + return Epoch.wrap(Slot.unwrap(_a) / getStorage().epochDuration); + } + + function getStorage() internal pure returns (TimeStorage storage storageStruct) { + bytes32 position = TIME_STORAGE_POSITION; + assembly { + storageStruct.slot := position + } + } +} diff --git a/l1-contracts/src/core/libraries/TimeMath.sol b/l1-contracts/src/core/libraries/TimeMath.sol index cfca87c2e06..9331336ec33 100644 --- a/l1-contracts/src/core/libraries/TimeMath.sol +++ b/l1-contracts/src/core/libraries/TimeMath.sol @@ -8,53 +8,6 @@ type Slot is uint256; type Epoch is uint256; -abstract contract TimeFns { - // @note @LHerskind The multiple cause pain and suffering in the E2E tests as we introduce - // a timeliness requirement into the publication that did not exists before, - // and at the same time have a setup that will impact the time at every tx - // because of auto-mine. By using just 1, we can make our test work - // but anything using an actual working chain would eat dung as simulating - // transactions is slower than an actual ethereum slot. - // - // The value should be a higher multiple for any actual chain - // @todo #8019 - uint256 public immutable SLOT_DURATION; - - // The duration of an epoch in slots - // @todo @LHerskind - This value should be updated when we are not blind. - // @todo #8020 - uint256 public immutable EPOCH_DURATION; - - constructor(uint256 _slotDuration, uint256 _epochDuration) { - SLOT_DURATION = _slotDuration; - EPOCH_DURATION = _epochDuration; - } - - function toTimestamp(Slot _a) internal view returns (Timestamp) { - return Timestamp.wrap(Slot.unwrap(_a) * SLOT_DURATION); - } - - function slotFromTimestamp(Timestamp _a) internal view returns (Slot) { - return Slot.wrap(Timestamp.unwrap(_a) / SLOT_DURATION); - } - - function positionInEpoch(Slot _a) internal view returns (uint256) { - return Slot.unwrap(_a) % EPOCH_DURATION; - } - - function toSlots(Epoch _a) internal view returns (Slot) { - return Slot.wrap(Epoch.unwrap(_a) * EPOCH_DURATION); - } - - function toTimestamp(Epoch _a) internal view returns (Timestamp) { - return toTimestamp(toSlots(_a)); - } - - function epochFromTimestamp(Timestamp _a) internal view returns (Epoch) { - return Epoch.wrap(Timestamp.unwrap(_a) / (EPOCH_DURATION * SLOT_DURATION)); - } -} - library SlotLib { function unwrap(Slot _a) internal pure returns (uint256) { return Slot.unwrap(_a); diff --git a/l1-contracts/src/core/libraries/ValidatorSelectionLib/ValidatorSelectionLib.sol b/l1-contracts/src/core/libraries/ValidatorSelectionLib/ValidatorSelectionLib.sol index c647a3750a2..981b7d92b2e 100644 --- a/l1-contracts/src/core/libraries/ValidatorSelectionLib/ValidatorSelectionLib.sol +++ b/l1-contracts/src/core/libraries/ValidatorSelectionLib/ValidatorSelectionLib.sol @@ -10,7 +10,7 @@ import {SampleLib} from "@aztec/core/libraries/crypto/SampleLib.sol"; import {SignatureLib, Signature} from "@aztec/core/libraries/crypto/SignatureLib.sol"; import {DataStructures} from "@aztec/core/libraries/DataStructures.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {Slot, Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol"; import {MessageHashUtils} from "@oz/utils/cryptography/MessageHashUtils.sol"; import {EnumerableSet} from "@oz/utils/structs/EnumerableSet.sol"; diff --git a/l1-contracts/src/core/staking/Staking.sol b/l1-contracts/src/core/staking/Staking.sol index 5e928f64c56..6f6edffebca 100644 --- a/l1-contracts/src/core/staking/Staking.sol +++ b/l1-contracts/src/core/staking/Staking.sol @@ -11,7 +11,7 @@ import { StakingStorage } from "@aztec/core/interfaces/IStaking.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Slasher} from "@aztec/core/staking/Slasher.sol"; import {IERC20} from "@oz/token/ERC20/IERC20.sol"; import {SafeERC20} from "@oz/token/ERC20/utils/SafeERC20.sol"; diff --git a/l1-contracts/src/governance/Governance.sol b/l1-contracts/src/governance/Governance.sol index 93c914f4141..32bc7485557 100644 --- a/l1-contracts/src/governance/Governance.sol +++ b/l1-contracts/src/governance/Governance.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; diff --git a/l1-contracts/src/governance/interfaces/IGovernance.sol b/l1-contracts/src/governance/interfaces/IGovernance.sol index 7f45d1bb981..937b81e2f1a 100644 --- a/l1-contracts/src/governance/interfaces/IGovernance.sol +++ b/l1-contracts/src/governance/interfaces/IGovernance.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; diff --git a/l1-contracts/src/governance/interfaces/IGovernanceProposer.sol b/l1-contracts/src/governance/interfaces/IGovernanceProposer.sol index 52ac72e8d6f..d5deb52919a 100644 --- a/l1-contracts/src/governance/interfaces/IGovernanceProposer.sol +++ b/l1-contracts/src/governance/interfaces/IGovernanceProposer.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Slot} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot} from "@aztec/core/libraries/TimeLib.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; interface IGovernanceProposer { diff --git a/l1-contracts/src/governance/libraries/ConfigurationLib.sol b/l1-contracts/src/governance/libraries/ConfigurationLib.sol index 2537e9b13c2..482dee7ff90 100644 --- a/l1-contracts/src/governance/libraries/ConfigurationLib.sol +++ b/l1-contracts/src/governance/libraries/ConfigurationLib.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; diff --git a/l1-contracts/src/governance/libraries/DataStructures.sol b/l1-contracts/src/governance/libraries/DataStructures.sol index ea820eae466..5e18aa9d90e 100644 --- a/l1-contracts/src/governance/libraries/DataStructures.sol +++ b/l1-contracts/src/governance/libraries/DataStructures.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; /** diff --git a/l1-contracts/src/governance/libraries/Errors.sol b/l1-contracts/src/governance/libraries/Errors.sol index b6654440e55..66e74e62d9c 100644 --- a/l1-contracts/src/governance/libraries/Errors.sol +++ b/l1-contracts/src/governance/libraries/Errors.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Slot, Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot, Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; /** diff --git a/l1-contracts/src/governance/libraries/ProposalLib.sol b/l1-contracts/src/governance/libraries/ProposalLib.sol index 56845cddace..6ce56908a84 100644 --- a/l1-contracts/src/governance/libraries/ProposalLib.sol +++ b/l1-contracts/src/governance/libraries/ProposalLib.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Math} from "@oz/utils/math/Math.sol"; diff --git a/l1-contracts/src/governance/libraries/UserLib.sol b/l1-contracts/src/governance/libraries/UserLib.sol index e520ec99d11..5c1d69341ba 100644 --- a/l1-contracts/src/governance/libraries/UserLib.sol +++ b/l1-contracts/src/governance/libraries/UserLib.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; diff --git a/l1-contracts/src/governance/proposer/EmpireBase.sol b/l1-contracts/src/governance/proposer/EmpireBase.sol index 56fffbe1953..f65da0eaba1 100644 --- a/l1-contracts/src/governance/proposer/EmpireBase.sol +++ b/l1-contracts/src/governance/proposer/EmpireBase.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.27; import {IValidatorSelection} from "@aztec/core/interfaces/IValidatorSelection.sol"; -import {Slot, SlotLib} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot, SlotLib} from "@aztec/core/libraries/TimeLib.sol"; import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernanceProposer.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; diff --git a/l1-contracts/src/periphery/SlashFactory.sol b/l1-contracts/src/periphery/SlashFactory.sol index e368a5b9a92..c7869678d6b 100644 --- a/l1-contracts/src/periphery/SlashFactory.sol +++ b/l1-contracts/src/periphery/SlashFactory.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.27; import {IValidatorSelection} from "@aztec/core/interfaces/IValidatorSelection.sol"; -import {Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Epoch} from "@aztec/core/libraries/TimeLib.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {ISlashFactory} from "./interfaces/ISlashFactory.sol"; import {SlashPayload} from "./SlashPayload.sol"; diff --git a/l1-contracts/src/periphery/SlashPayload.sol b/l1-contracts/src/periphery/SlashPayload.sol index 7df173b6d55..b39fcb8301c 100644 --- a/l1-contracts/src/periphery/SlashPayload.sol +++ b/l1-contracts/src/periphery/SlashPayload.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {IStaking} from "@aztec/core/interfaces/IStaking.sol"; import {IValidatorSelection} from "@aztec/core/interfaces/IValidatorSelection.sol"; -import {Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Epoch} from "@aztec/core/libraries/TimeLib.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; /** diff --git a/l1-contracts/src/periphery/interfaces/ISlashFactory.sol b/l1-contracts/src/periphery/interfaces/ISlashFactory.sol index 7300cfbba84..9c859415618 100644 --- a/l1-contracts/src/periphery/interfaces/ISlashFactory.sol +++ b/l1-contracts/src/periphery/interfaces/ISlashFactory.sol @@ -2,7 +2,7 @@ // Copyright 2024 Aztec Labs. pragma solidity >=0.8.27; -import {Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Epoch} from "@aztec/core/libraries/TimeLib.sol"; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; interface ISlashFactory { diff --git a/l1-contracts/test/Rollup.t.sol b/l1-contracts/test/Rollup.t.sol index a9f7cbcdcb0..ad454786e91 100644 --- a/l1-contracts/test/Rollup.t.sol +++ b/l1-contracts/test/Rollup.t.sol @@ -33,8 +33,8 @@ import { } from "@aztec/core/libraries/RollupLibs/ProposeLib.sol"; import { - Timestamp, Slot, Epoch, SlotLib, EpochLib, TimeFns -} from "@aztec/core/libraries/TimeMath.sol"; + Timestamp, Slot, Epoch, SlotLib, EpochLib, TimeLib +} from "@aztec/core/libraries/TimeLib.sol"; // solhint-disable comprehensive-interface @@ -42,10 +42,13 @@ import { * Blocks are generated using the `integration_l1_publisher.test.ts` tests. * Main use of these test is shorter cycles when updating the decoder contract. */ -contract RollupTest is DecoderBase, TimeFns { +contract RollupTest is DecoderBase { using SlotLib for Slot; using EpochLib for Epoch; using ProposeLib for ProposeArgs; + using TimeLib for Timestamp; + using TimeLib for Slot; + using TimeLib for Epoch; Registry internal registry; Inbox internal inbox; @@ -65,7 +68,16 @@ contract RollupTest is DecoderBase, TimeFns { uint256 internal privateKey; address internal signer; - constructor() TimeFns(TestConstants.AZTEC_SLOT_DURATION, TestConstants.AZTEC_EPOCH_DURATION) {} + uint256 internal SLOT_DURATION; + uint256 internal EPOCH_DURATION; + + constructor() { + TimeLib.initialize( + block.timestamp, TestConstants.AZTEC_SLOT_DURATION, TestConstants.AZTEC_EPOCH_DURATION + ); + SLOT_DURATION = TestConstants.AZTEC_SLOT_DURATION; + EPOCH_DURATION = TestConstants.AZTEC_EPOCH_DURATION; + } /** * @notice Set up the contracts needed for the tests with time aligned to the provided block name @@ -299,7 +311,7 @@ contract RollupTest is DecoderBase, TimeFns { rollup.propose(args, signatures, data.body, data.blobInputs); quote.epochToProve = Epoch.wrap(1); - quote.validUntilSlot = toSlots(Epoch.wrap(2)); + quote.validUntilSlot = Epoch.wrap(2).toSlots(); signedQuote = _quoteToSignedQuote(quote); rollup.claimEpochProofRight(signedQuote); BlockLog memory blockLog = rollup.getBlock(0); @@ -327,7 +339,7 @@ contract RollupTest is DecoderBase, TimeFns { function testMissingProofSlashesBond(uint256 _slotToHit) public setUpFor("mixed_block_1") { Slot lower = rollup.getCurrentSlot() + Slot.wrap(2 * EPOCH_DURATION); Slot upper = Slot.wrap( - (type(uint256).max - Timestamp.unwrap(rollup.GENESIS_TIME())) / rollup.SLOT_DURATION() + (type(uint256).max - Timestamp.unwrap(rollup.getGenesisTime())) / rollup.getSlotDuration() ); Slot slotToHit = Slot.wrap(bound(_slotToHit, lower.unwrap(), upper.unwrap())); @@ -344,7 +356,7 @@ contract RollupTest is DecoderBase, TimeFns { function testClaimTwice() public setUpFor("mixed_block_1") { _testBlock("mixed_block_1", false, 1); - quote.validUntilSlot = toSlots(Epoch.wrap(1e9)); + quote.validUntilSlot = Epoch.wrap(1e9).toSlots(); signedQuote = _quoteToSignedQuote(quote); rollup.claimEpochProofRight(signedQuote); @@ -371,7 +383,7 @@ contract RollupTest is DecoderBase, TimeFns { function testClaimOutsideClaimPhase() public setUpFor("mixed_block_1") { _testBlock("mixed_block_1", false, 1); - quote.validUntilSlot = toSlots(Epoch.wrap(1e9)); + quote.validUntilSlot = Epoch.wrap(1e9).toSlots(); signedQuote = _quoteToSignedQuote(quote); warpToL2Slot(EPOCH_DURATION + rollup.CLAIM_DURATION_IN_L2_SLOTS()); @@ -388,7 +400,7 @@ contract RollupTest is DecoderBase, TimeFns { function testNoPruneWhenClaimExists() public setUpFor("mixed_block_1") { _testBlock("mixed_block_1", false, 1); - quote.validUntilSlot = toSlots(Epoch.wrap(2)); + quote.validUntilSlot = Epoch.wrap(2).toSlots(); signedQuote = _quoteToSignedQuote(quote); warpToL2Slot(EPOCH_DURATION + rollup.CLAIM_DURATION_IN_L2_SLOTS() - 1); @@ -404,7 +416,7 @@ contract RollupTest is DecoderBase, TimeFns { function testPruneWhenClaimExpires() public setUpFor("mixed_block_1") { _testBlock("mixed_block_1", false, 1); - quote.validUntilSlot = toSlots(Epoch.wrap(2)); + quote.validUntilSlot = Epoch.wrap(2).toSlots(); signedQuote = _quoteToSignedQuote(quote); warpToL2Slot(EPOCH_DURATION + rollup.CLAIM_DURATION_IN_L2_SLOTS() - 1); @@ -426,7 +438,7 @@ contract RollupTest is DecoderBase, TimeFns { function testClaimAfterPrune() public setUpFor("mixed_block_1") { _testBlock("mixed_block_1", false, 1); - quote.validUntilSlot = toSlots(Epoch.wrap(3)); + quote.validUntilSlot = Epoch.wrap(3).toSlots(); signedQuote = _quoteToSignedQuote(quote); warpToL2Slot(EPOCH_DURATION + rollup.CLAIM_DURATION_IN_L2_SLOTS() - 1); @@ -437,14 +449,14 @@ contract RollupTest is DecoderBase, TimeFns { rollup.prune(); - _testBlock("mixed_block_1", false, toSlots(Epoch.wrap(3)).unwrap()); + _testBlock("mixed_block_1", false, Epoch.wrap(3).toSlots().unwrap()); quote.epochToProve = Epoch.wrap(3); signedQuote = _quoteToSignedQuote(quote); vm.expectEmit(true, true, true, true); emit IRollup.ProofRightClaimed( - quote.epochToProve, quote.prover, address(this), quote.bondAmount, toSlots(Epoch.wrap(3)) + quote.epochToProve, quote.prover, address(this), quote.bondAmount, Epoch.wrap(3).toSlots() ); rollup.claimEpochProofRight(signedQuote); } @@ -584,7 +596,7 @@ contract RollupTest is DecoderBase, TimeFns { bytes32 inboxRoot2 = inbox.getRoot(2); BlockLog memory blockLog = rollup.getBlock(1); - Slot prunableAt = blockLog.slotNumber + toSlots(Epoch.wrap(2)); + Slot prunableAt = blockLog.slotNumber + Epoch.wrap(2).toSlots(); Timestamp timeOfPrune = rollup.getTimestampForSlot(prunableAt); vm.warp(Timestamp.unwrap(timeOfPrune)); @@ -651,7 +663,7 @@ contract RollupTest is DecoderBase, TimeFns { _testBlock("mixed_block_1", false, 1); assertEq(rollup.getEpochToProve(), 0, "Invalid epoch to prove"); warpToL2Slot(EPOCH_DURATION * 2); - _testBlock("mixed_block_1", false, toSlots(Epoch.wrap(2)).unwrap()); + _testBlock("mixed_block_1", false, Epoch.wrap(2).toSlots().unwrap()); assertEq(rollup.getPendingBlockNumber(), 1, "Invalid pending block number"); assertEq(rollup.getProvenBlockNumber(), 0, "Invalid proven block number"); @@ -756,7 +768,7 @@ contract RollupTest is DecoderBase, TimeFns { BlockLog memory blockLog = rollup.getBlock(0); quote.epochToProve = Epoch.wrap(1); - quote.validUntilSlot = toSlots(Epoch.wrap(2)); + quote.validUntilSlot = Epoch.wrap(2).toSlots(); signedQuote = _quoteToSignedQuote(quote); warpToL2Slot(EPOCH_DURATION + rollup.CLAIM_DURATION_IN_L2_SLOTS() - 1); diff --git a/l1-contracts/test/base/Base.sol b/l1-contracts/test/base/Base.sol index 1f975efb96a..f01da01e64e 100644 --- a/l1-contracts/test/base/Base.sol +++ b/l1-contracts/test/base/Base.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.27; -import {Timestamp, Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeLib.sol"; import {Test} from "forge-std/Test.sol"; contract TestBase is Test { diff --git a/l1-contracts/test/fees/FeeRollup.t.sol b/l1-contracts/test/fees/FeeRollup.t.sol index 80ba0fd3f60..c79eaa05032 100644 --- a/l1-contracts/test/fees/FeeRollup.t.sol +++ b/l1-contracts/test/fees/FeeRollup.t.sol @@ -46,9 +46,7 @@ import { ManaBaseFeeComponents as ManaBaseFeeComponentsModel } from "./FeeModelTestPoints.t.sol"; -import { - Timestamp, Slot, Epoch, SlotLib, EpochLib, TimeFns -} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeLib.sol"; import {FeeModelTestPoints, TestPoint} from "./FeeModelTestPoints.t.sol"; import {MinimalFeeModel} from "./MinimalFeeModel.sol"; diff --git a/l1-contracts/test/fees/MinimalFeeModel.sol b/l1-contracts/test/fees/MinimalFeeModel.sol index 90849e20248..8faa096ac26 100644 --- a/l1-contracts/test/fees/MinimalFeeModel.sol +++ b/l1-contracts/test/fees/MinimalFeeModel.sol @@ -10,21 +10,23 @@ import { L1_GAS_PER_EPOCH_VERIFIED, MINIMUM_CONGESTION_MULTIPLIER } from "@aztec/core/libraries/RollupLibs/FeeMath.sol"; -import {Timestamp, TimeFns, Slot, SlotLib} from "@aztec/core/libraries/TimeMath.sol"; import {Vm} from "forge-std/Vm.sol"; import { ManaBaseFeeComponents, L1Fees, L1GasOracleValues, FeeHeader } from "./FeeModelTestPoints.t.sol"; import {Math} from "@oz/utils/math/Math.sol"; +import {Timestamp, TimeLib, Slot, SlotLib} from "@aztec/core/libraries/TimeLib.sol"; + // The data types are slightly messed up here, the reason is that // we just want to use the same structs from the test points making // is simpler to compare etc. -contract MinimalFeeModel is TimeFns { +contract MinimalFeeModel { using FeeMath for OracleInput; using FeeMath for uint256; using SlotLib for Slot; + using TimeLib for Timestamp; // This is to allow us to use the cheatcodes for blobbasefee as foundry does not play nice // with the block.blobbasefee value if using cheatcodes to alter it. @@ -35,15 +37,13 @@ contract MinimalFeeModel is TimeFns { Slot public constant LIFETIME = Slot.wrap(5); Slot public constant LAG = Slot.wrap(2); - Timestamp public immutable GENESIS_TIMESTAMP; uint256 public populatedThrough = 0; mapping(uint256 slotNumber => FeeHeader feeHeader) public feeHeaders; L1GasOracleValues public l1BaseFees; - constructor(uint256 _slotDuration, uint256 _epochDuration) TimeFns(_slotDuration, _epochDuration) { - GENESIS_TIMESTAMP = Timestamp.wrap(block.timestamp); + constructor(uint256 _slotDuration, uint256 _epochDuration) { feeHeaders[0] = FeeHeader({ excess_mana: 0, fee_asset_price_numerator: 0, @@ -54,6 +54,8 @@ contract MinimalFeeModel is TimeFns { l1BaseFees.pre = L1Fees({base_fee: 1 gwei, blob_fee: 1}); l1BaseFees.post = L1Fees({base_fee: block.basefee, blob_fee: _getBlobBaseFee()}); l1BaseFees.slot_of_change = LIFETIME.unwrap(); + + TimeLib.initialize(block.timestamp, _slotDuration, _epochDuration); } function getL1GasOracleValues() public view returns (L1GasOracleValues memory) { @@ -70,7 +72,7 @@ contract MinimalFeeModel is TimeFns { uint256 dataCost = Math.mulDiv(_blobsUsed * BLOB_GAS_PER_BLOB, fees.blob_fee, MANA_TARGET, Math.Rounding.Ceil); uint256 gasUsed = L1_GAS_PER_BLOCK_PROPOSED + _blobsUsed * GAS_PER_BLOB_POINT_EVALUATION - + L1_GAS_PER_EPOCH_VERIFIED / EPOCH_DURATION; + + L1_GAS_PER_EPOCH_VERIFIED / TimeLib.getStorage().epochDuration; uint256 gasCost = Math.mulDiv(gasUsed, fees.base_fee, MANA_TARGET, Math.Rounding.Ceil); uint256 provingCost = getProvingCost(); @@ -161,8 +163,7 @@ contract MinimalFeeModel is TimeFns { } function getCurrentSlot() public view returns (Slot) { - Timestamp currentTime = Timestamp.wrap(block.timestamp); - return TimeFns.slotFromTimestamp(currentTime - GENESIS_TIMESTAMP); + return Timestamp.wrap(block.timestamp).slotFromTimestamp(); } function _getBlobBaseFee() internal view returns (uint256) { diff --git a/l1-contracts/test/fees/MinimalFeeModel.t.sol b/l1-contracts/test/fees/MinimalFeeModel.t.sol index f2b79e42f24..e2c3e3190e8 100644 --- a/l1-contracts/test/fees/MinimalFeeModel.t.sol +++ b/l1-contracts/test/fees/MinimalFeeModel.t.sol @@ -11,7 +11,7 @@ import { } from "./FeeModelTestPoints.t.sol"; import {MinimalFeeModel} from "./MinimalFeeModel.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {SlotLib, Slot} from "@aztec/core/libraries/TimeMath.sol"; +import {SlotLib, Slot} from "@aztec/core/libraries/TimeLib.sol"; import { MAX_PROVING_COST_MODIFIER, MAX_FEE_ASSET_PRICE_MODIFIER diff --git a/l1-contracts/test/governance/governance-proposer/executeProposal.t.sol b/l1-contracts/test/governance/governance-proposer/executeProposal.t.sol index b06b7d6db13..9ccdcc234ef 100644 --- a/l1-contracts/test/governance/governance-proposer/executeProposal.t.sol +++ b/l1-contracts/test/governance/governance-proposer/executeProposal.t.sol @@ -6,7 +6,7 @@ import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernancePropo import {GovernanceProposerBase} from "./Base.t.sol"; import {ValidatorSelection} from "../../harnesses/ValidatorSelection.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; -import {Slot, SlotLib, Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot, SlotLib, Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {FaultyGovernance} from "./mocks/FaultyGovernance.sol"; import {FalsyGovernance} from "./mocks/FalsyGovernance.sol"; @@ -64,8 +64,8 @@ contract ExecuteProposalTest is GovernanceProposerBase { Slot lower = validatorSelection.getCurrentSlot() + Slot.wrap(governanceProposer.M() * governanceProposer.LIFETIME_IN_ROUNDS() + 1); Slot upper = Slot.wrap( - (type(uint256).max - Timestamp.unwrap(validatorSelection.GENESIS_TIME())) - / validatorSelection.SLOT_DURATION() + (type(uint256).max - Timestamp.unwrap(validatorSelection.getGenesisTime())) + / validatorSelection.getSlotDuration() ); Slot slotToHit = Slot.wrap(bound(_slotToHit, lower.unwrap(), upper.unwrap())); vm.warp(Timestamp.unwrap(validatorSelection.getTimestampForSlot(slotToHit))); diff --git a/l1-contracts/test/governance/governance-proposer/vote.t.sol b/l1-contracts/test/governance/governance-proposer/vote.t.sol index 677aabf7991..00144b652b5 100644 --- a/l1-contracts/test/governance/governance-proposer/vote.t.sol +++ b/l1-contracts/test/governance/governance-proposer/vote.t.sol @@ -6,7 +6,7 @@ import {IGovernanceProposer} from "@aztec/governance/interfaces/IGovernancePropo import {GovernanceProposerBase} from "./Base.t.sol"; import {ValidatorSelection} from "../../harnesses/ValidatorSelection.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; -import {Slot, SlotLib, Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot, SlotLib, Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract VoteTest is GovernanceProposerBase { using SlotLib for Slot; diff --git a/l1-contracts/test/governance/governance/base.t.sol b/l1-contracts/test/governance/governance/base.t.sol index 05a125f10ff..f77cbc8d2e1 100644 --- a/l1-contracts/test/governance/governance/base.t.sol +++ b/l1-contracts/test/governance/governance/base.t.sol @@ -8,7 +8,7 @@ import {Registry} from "@aztec/governance/Registry.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; import {TestERC20} from "@aztec/mock/TestERC20.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Math} from "@oz/utils/math/Math.sol"; import { diff --git a/l1-contracts/test/governance/governance/deposit.t.sol b/l1-contracts/test/governance/governance/deposit.t.sol index 6089139a9d5..fa7778a7175 100644 --- a/l1-contracts/test/governance/governance/deposit.t.sol +++ b/l1-contracts/test/governance/governance/deposit.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {GovernanceBase} from "./base.t.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {IERC20Errors} from "@oz/interfaces/draft-IERC6093.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract DepositTest is GovernanceBase { uint256 internal constant DEPOSIT_COUNT = 8; diff --git a/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol b/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol index 9d9b747467f..ae437f23c22 100644 --- a/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol +++ b/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {GovernanceBase} from "./base.t.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; import {IERC20Errors} from "@oz/interfaces/draft-IERC6093.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; diff --git a/l1-contracts/test/governance/governance/getProposalState.t.sol b/l1-contracts/test/governance/governance/getProposalState.t.sol index 8ff0a9f521f..9c08d0f8bae 100644 --- a/l1-contracts/test/governance/governance/getProposalState.t.sol +++ b/l1-contracts/test/governance/governance/getProposalState.t.sol @@ -6,7 +6,7 @@ import {stdStorage, StdStorage} from "forge-std/Test.sol"; import {GovernanceBase} from "./base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {ProposalLib, VoteTabulationReturn} from "@aztec/governance/libraries/ProposalLib.sol"; contract GetProposalStateTest is GovernanceBase { diff --git a/l1-contracts/test/governance/governance/initiateWithdraw.t.sol b/l1-contracts/test/governance/governance/initiateWithdraw.t.sol index 37a4105a344..ebb79e75864 100644 --- a/l1-contracts/test/governance/governance/initiateWithdraw.t.sol +++ b/l1-contracts/test/governance/governance/initiateWithdraw.t.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.27; import {GovernanceBase} from "./base.t.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; diff --git a/l1-contracts/test/governance/governance/proposallib/static.t.sol b/l1-contracts/test/governance/governance/proposallib/static.t.sol index 314db1519e1..0c7c5f27d0d 100644 --- a/l1-contracts/test/governance/governance/proposallib/static.t.sol +++ b/l1-contracts/test/governance/governance/proposallib/static.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {TestBase} from "@test/base/Base.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract Static is TestBase { using ProposalLib for DataStructures.Proposal; diff --git a/l1-contracts/test/governance/governance/propose.t.sol b/l1-contracts/test/governance/governance/propose.t.sol index 317c7a113ce..2abfc911458 100644 --- a/l1-contracts/test/governance/governance/propose.t.sol +++ b/l1-contracts/test/governance/governance/propose.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {GovernanceBase} from "./base.t.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; diff --git a/l1-contracts/test/governance/governance/proposeWithLock.t.sol b/l1-contracts/test/governance/governance/proposeWithLock.t.sol index 1f65f7ee1d5..1dc8b562ead 100644 --- a/l1-contracts/test/governance/governance/proposeWithLock.t.sol +++ b/l1-contracts/test/governance/governance/proposeWithLock.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {IPayload} from "@aztec/governance/interfaces/IPayload.sol"; import {GovernanceBase} from "./base.t.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; diff --git a/l1-contracts/test/governance/governance/scenarios/noVoteAndExit.t.sol b/l1-contracts/test/governance/governance/scenarios/noVoteAndExit.t.sol index b4327a9daea..a01182c6c33 100644 --- a/l1-contracts/test/governance/governance/scenarios/noVoteAndExit.t.sol +++ b/l1-contracts/test/governance/governance/scenarios/noVoteAndExit.t.sol @@ -5,7 +5,7 @@ import {GovernanceBase} from "../base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {Math} from "@oz/utils/math/Math.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol"; contract NoVoteAndExitTest is GovernanceBase { diff --git a/l1-contracts/test/governance/governance/updateConfiguration.t.sol b/l1-contracts/test/governance/governance/updateConfiguration.t.sol index 65382f4682b..eea89462ec3 100644 --- a/l1-contracts/test/governance/governance/updateConfiguration.t.sol +++ b/l1-contracts/test/governance/governance/updateConfiguration.t.sol @@ -3,11 +3,10 @@ pragma solidity >=0.8.27; import {GovernanceBase} from "./base.t.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ConfigurationLib} from "@aztec/governance/libraries/ConfigurationLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract UpdateConfigurationTest is GovernanceBase { using ConfigurationLib for DataStructures.Configuration; diff --git a/l1-contracts/test/governance/governance/userlib/add.t.sol b/l1-contracts/test/governance/governance/userlib/add.t.sol index f824a9855c4..6a0c7329347 100644 --- a/l1-contracts/test/governance/governance/userlib/add.t.sol +++ b/l1-contracts/test/governance/governance/userlib/add.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {UserLibBase} from "./base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {UserLib} from "@aztec/governance/libraries/UserLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract AddTest is UserLibBase { using UserLib for DataStructures.User; diff --git a/l1-contracts/test/governance/governance/userlib/base.t.sol b/l1-contracts/test/governance/governance/userlib/base.t.sol index f607fd52075..a68d13e6419 100644 --- a/l1-contracts/test/governance/governance/userlib/base.t.sol +++ b/l1-contracts/test/governance/governance/userlib/base.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {TestBase} from "@test/base/Base.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {UserLib} from "@aztec/governance/libraries/UserLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract UserLibBase is TestBase { using UserLib for DataStructures.User; diff --git a/l1-contracts/test/governance/governance/userlib/powerAt.t.sol b/l1-contracts/test/governance/governance/userlib/powerAt.t.sol index f4becc2e5d9..4056262ca0b 100644 --- a/l1-contracts/test/governance/governance/userlib/powerAt.t.sol +++ b/l1-contracts/test/governance/governance/userlib/powerAt.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {UserLibBase} from "./base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {UserLib} from "@aztec/governance/libraries/UserLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; contract PowerAtTest is UserLibBase { diff --git a/l1-contracts/test/governance/governance/userlib/powerNow.t.sol b/l1-contracts/test/governance/governance/userlib/powerNow.t.sol index 8ac7ca278ee..5b86f70e32d 100644 --- a/l1-contracts/test/governance/governance/userlib/powerNow.t.sol +++ b/l1-contracts/test/governance/governance/userlib/powerNow.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {UserLibBase} from "./base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {UserLib} from "@aztec/governance/libraries/UserLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; contract PowerNowTest is UserLibBase { diff --git a/l1-contracts/test/governance/governance/userlib/sub.t.sol b/l1-contracts/test/governance/governance/userlib/sub.t.sol index 4be54e2bc98..dfcefa43cf6 100644 --- a/l1-contracts/test/governance/governance/userlib/sub.t.sol +++ b/l1-contracts/test/governance/governance/userlib/sub.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {UserLibBase} from "./base.t.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {UserLib} from "@aztec/governance/libraries/UserLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; contract SubTest is UserLibBase { diff --git a/l1-contracts/test/governance/governance/vote.t.sol b/l1-contracts/test/governance/governance/vote.t.sol index 97dc30fd65f..16ea4ad6b77 100644 --- a/l1-contracts/test/governance/governance/vote.t.sol +++ b/l1-contracts/test/governance/governance/vote.t.sol @@ -6,7 +6,7 @@ import {GovernanceBase} from "./base.t.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {IGovernance} from "@aztec/governance/interfaces/IGovernance.sol"; contract VoteTest is GovernanceBase { diff --git a/l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol b/l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol index f5fd35a9a34..90fb881c5c1 100644 --- a/l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol +++ b/l1-contracts/test/governance/scenario/UpgradeGovernanceProposerTest.t.sol @@ -11,9 +11,8 @@ import {Registry} from "@aztec/governance/Registry.sol"; import {DataStructures} from "@aztec/governance/libraries/DataStructures.sol"; import {IMintableERC20} from "@aztec/governance/interfaces/IMintableERC20.sol"; import {TestERC20} from "@aztec/mock/TestERC20.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {MockFeeJuicePortal} from "@aztec/mock/MockFeeJuicePortal.sol"; -import {Slot} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot} from "@aztec/core/libraries/TimeLib.sol"; import {ProposalLib} from "@aztec/governance/libraries/ProposalLib.sol"; import {Errors} from "@aztec/governance/libraries/Errors.sol"; import {NewGovernanceProposerPayload} from "./NewGovernanceProposerPayload.sol"; diff --git a/l1-contracts/test/governance/scenario/slashing/Slashing.t.sol b/l1-contracts/test/governance/scenario/slashing/Slashing.t.sol index ba26dd03fd3..dd0476d7c0f 100644 --- a/l1-contracts/test/governance/scenario/slashing/Slashing.t.sol +++ b/l1-contracts/test/governance/scenario/slashing/Slashing.t.sol @@ -19,16 +19,13 @@ import {IValidatorSelection} from "@aztec/core/interfaces/IValidatorSelection.so import {Status, ValidatorInfo} from "@aztec/core/interfaces/IStaking.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; import {CheatDepositArgs} from "@aztec/core/interfaces/IRollup.sol"; import {SlashingProposer} from "@aztec/core/staking/SlashingProposer.sol"; -import {Slot, SlotLib, Epoch} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp, Slot, Epoch} from "@aztec/core/libraries/TimeLib.sol"; contract SlashingScenario is TestBase { - using SlotLib for Slot; - TestERC20 internal testERC20; RewardDistributor internal rewardDistributor; Rollup internal rollup; diff --git a/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol b/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol index 18c07487dfe..45a7985308c 100644 --- a/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol +++ b/l1-contracts/test/prover-coordination/ProofCommitmentEscrow.t.sol @@ -6,7 +6,7 @@ import {Test} from "forge-std/Test.sol"; import {ProofCommitmentEscrow} from "@aztec/core/ProofCommitmentEscrow.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; import {TestConstants} from "../harnesses/TestConstants.sol"; import {TestERC20} from "@aztec/mock/TestERC20.sol"; diff --git a/l1-contracts/test/staking/finaliseWithdraw.t.sol b/l1-contracts/test/staking/finaliseWithdraw.t.sol index b48e9534ccc..dea6053c04d 100644 --- a/l1-contracts/test/staking/finaliseWithdraw.t.sol +++ b/l1-contracts/test/staking/finaliseWithdraw.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {StakingBase} from "./base.t.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; import {IStaking, Status, ValidatorInfo, Exit} from "@aztec/core/staking/Staking.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract FinaliseWithdrawTest is StakingBase { function test_GivenStatusIsNotExiting() external { diff --git a/l1-contracts/test/staking/initiateWithdraw.t.sol b/l1-contracts/test/staking/initiateWithdraw.t.sol index e970a5ae120..3883e826ac9 100644 --- a/l1-contracts/test/staking/initiateWithdraw.t.sol +++ b/l1-contracts/test/staking/initiateWithdraw.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {StakingBase} from "./base.t.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; import {IStaking, Status, ValidatorInfo, Exit} from "@aztec/core/staking/Staking.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract InitiateWithdrawTest is StakingBase { function test_WhenAttesterIsNotRegistered() external { diff --git a/l1-contracts/test/staking/slash.t.sol b/l1-contracts/test/staking/slash.t.sol index 8a9682397af..fd4ded49803 100644 --- a/l1-contracts/test/staking/slash.t.sol +++ b/l1-contracts/test/staking/slash.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.27; import {StakingBase} from "./base.t.sol"; import {Errors} from "@aztec/core/libraries/Errors.sol"; import {Staking, IStaking, Status, ValidatorInfo, Exit} from "@aztec/core/staking/Staking.sol"; -import {Timestamp} from "@aztec/core/libraries/TimeMath.sol"; +import {Timestamp} from "@aztec/core/libraries/TimeLib.sol"; contract SlashTest is StakingBase { uint256 internal constant DEPOSIT_AMOUNT = MINIMUM_STAKE + 2; diff --git a/l1-contracts/test/validator-selection/ValidatorSelection.t.sol b/l1-contracts/test/validator-selection/ValidatorSelection.t.sol index 2a5c895d2e4..773248000c9 100644 --- a/l1-contracts/test/validator-selection/ValidatorSelection.t.sol +++ b/l1-contracts/test/validator-selection/ValidatorSelection.t.sol @@ -25,7 +25,7 @@ import { import {TestConstants} from "../harnesses/TestConstants.sol"; import {CheatDepositArgs} from "@aztec/core/interfaces/IRollup.sol"; -import {Slot, Epoch, SlotLib, EpochLib} from "@aztec/core/libraries/TimeMath.sol"; +import {Slot, Epoch, EpochLib} from "@aztec/core/libraries/TimeLib.sol"; import {RewardDistributor} from "@aztec/governance/RewardDistributor.sol"; import {SlashFactory} from "@aztec/periphery/SlashFactory.sol"; @@ -40,7 +40,6 @@ import {Status, ValidatorInfo} from "@aztec/core/interfaces/IStaking.sol"; */ contract ValidatorSelectionTest is DecoderBase { using MessageHashUtils for bytes32; - using SlotLib for Slot; using EpochLib for Epoch; struct StructToAvoidDeepStacks { @@ -83,7 +82,7 @@ contract ValidatorSelectionTest is DecoderBase { DecoderBase.Full memory full = load(_name); uint256 slotNumber = full.block.decodedHeader.globalVariables.slotNumber; uint256 initialTime = full.block.decodedHeader.globalVariables.timestamp - - slotNumber * validatorSelection.SLOT_DURATION(); + - slotNumber * validatorSelection.getSlotDuration(); vm.warp(initialTime); } @@ -168,7 +167,8 @@ contract ValidatorSelectionTest is DecoderBase { function testProposerForNonSetupEpoch(uint8 _epochsToJump) public setup(4) { Epoch pre = rollup.getCurrentEpoch(); vm.warp( - block.timestamp + uint256(_epochsToJump) * rollup.EPOCH_DURATION() * rollup.SLOT_DURATION() + block.timestamp + + uint256(_epochsToJump) * rollup.getEpochDuration() * rollup.getSlotDuration() ); Epoch post = rollup.getCurrentEpoch(); assertEq(pre + Epoch.wrap(_epochsToJump), post, "Invalid epoch"); diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index 47427f9d246..3467d2c6df3 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -167,7 +167,7 @@ export class Archiver implements ArchiveSource, Traceable { const [l1StartBlock, l1GenesisTime] = await Promise.all([ rollup.read.L1_BLOCK_AT_GENESIS(), - rollup.read.GENESIS_TIME(), + rollup.read.getGenesisTime(), ] as const); const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config; diff --git a/yarn-project/aztec.js/src/utils/cheat_codes.ts b/yarn-project/aztec.js/src/utils/cheat_codes.ts index d3b88ebd798..413650e893d 100644 --- a/yarn-project/aztec.js/src/utils/cheat_codes.ts +++ b/yarn-project/aztec.js/src/utils/cheat_codes.ts @@ -96,8 +96,8 @@ export class RollupCheatCodes { /** Slot duration */ slotDuration: bigint; }> { const [epochDuration, slotDuration] = await Promise.all([ - this.rollup.read.EPOCH_DURATION(), - this.rollup.read.SLOT_DURATION(), + this.rollup.read.getEpochDuration(), + this.rollup.read.getSlotDuration(), ]); return { epochDuration, slotDuration }; } @@ -128,7 +128,7 @@ export class RollupCheatCodes { */ public async advanceSlots(howMany: number) { const l1Timestamp = (await this.client.getBlock()).timestamp; - const slotDuration = await this.rollup.read.SLOT_DURATION(); + const slotDuration = await this.rollup.read.getSlotDuration(); const timeToWarp = BigInt(howMany) * slotDuration; await this.ethCheatCodes.warp(l1Timestamp + timeToWarp, true); const [slot, epoch] = await Promise.all([this.getSlot(), this.getEpoch()]); diff --git a/yarn-project/cli/src/cmds/l1/update_l1_validators.ts b/yarn-project/cli/src/cmds/l1/update_l1_validators.ts index 606643f3536..38a8dc6a9f2 100644 --- a/yarn-project/cli/src/cmds/l1/update_l1_validators.ts +++ b/yarn-project/cli/src/cmds/l1/update_l1_validators.ts @@ -162,7 +162,7 @@ export async function fastForwardEpochs({ const cheatCodes = new EthCheatCodes(rpcUrl, debugLogger); const currentSlot = await rollup.read.getCurrentSlot(); - const l2SlotsInEpoch = await rollup.read.EPOCH_DURATION(); + const l2SlotsInEpoch = await rollup.read.getEpochDuration(); const timestamp = await rollup.read.getTimestampForSlot([currentSlot + l2SlotsInEpoch * numEpochs]); dualLog(`Fast forwarding ${numEpochs} epochs to ${timestamp}`); try { diff --git a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts index 1982b5c8269..86a9e971aef 100644 --- a/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts +++ b/yarn-project/end-to-end/src/composed/integration_l1_publisher.test.ts @@ -226,7 +226,7 @@ describe('L1Publisher integration', () => { baseFee = new GasFees(0, await rollup.read.getManaBaseFeeAt([ts, true])); // We jump to the next epoch such that the committee can be setup. - const timeToJump = await rollup.read.EPOCH_DURATION(); + const timeToJump = await rollup.read.getEpochDuration(); await progressTimeBySlot(timeToJump); }); diff --git a/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts b/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts index 4d92c8e070c..e5c34a7b74d 100644 --- a/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts +++ b/yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts @@ -217,7 +217,7 @@ export class P2PNetworkTest { hash: await rollup.write.cheat__InitialiseValidatorSet([validators]), }); - const slotsInEpoch = await rollup.read.EPOCH_DURATION(); + const slotsInEpoch = await rollup.read.getEpochDuration(); const timestamp = await rollup.read.getTimestampForSlot([slotsInEpoch]); const cheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrl); try { diff --git a/yarn-project/end-to-end/src/e2e_p2p/reqresp.test.ts b/yarn-project/end-to-end/src/e2e_p2p/reqresp.test.ts index fed938743d4..6ecb33a6be1 100644 --- a/yarn-project/end-to-end/src/e2e_p2p/reqresp.test.ts +++ b/yarn-project/end-to-end/src/e2e_p2p/reqresp.test.ts @@ -130,7 +130,7 @@ describe('e2e_p2p_reqresp_tx', () => { ); const currentTime = await t.ctx.cheatCodes.eth.timestamp(); - const slotDuration = await rollupContract.read.SLOT_DURATION(); + const slotDuration = await rollupContract.read.getSlotDuration(); const proposers = []; diff --git a/yarn-project/end-to-end/src/e2e_synching.test.ts b/yarn-project/end-to-end/src/e2e_synching.test.ts index a61fca34477..505e7bd8b28 100644 --- a/yarn-project/end-to-end/src/e2e_synching.test.ts +++ b/yarn-project/end-to-end/src/e2e_synching.test.ts @@ -548,7 +548,7 @@ describe('e2e_synching', () => { const assumeProvenThrough = pendingBlockNumber - 2n; await rollup.write.setAssumeProvenThroughBlockNumber([assumeProvenThrough]); - const timeliness = (await rollup.read.EPOCH_DURATION()) * 2n; + const timeliness = (await rollup.read.getEpochDuration()) * 2n; const blockLog = await rollup.read.getBlock([(await rollup.read.getProvenBlockNumber()) + 1n]); const timeJumpTo = await rollup.read.getTimestampForSlot([blockLog.slotNumber + timeliness]); @@ -634,7 +634,7 @@ describe('e2e_synching', () => { const blockBeforePrune = await aztecNode.getBlockNumber(); - const timeliness = (await rollup.read.EPOCH_DURATION()) * 2n; + const timeliness = (await rollup.read.getEpochDuration()) * 2n; const blockLog = await rollup.read.getBlock([(await rollup.read.getProvenBlockNumber()) + 1n]); const timeJumpTo = await rollup.read.getTimestampForSlot([blockLog.slotNumber + timeliness]); @@ -694,7 +694,7 @@ describe('e2e_synching', () => { const pendingBlockNumber = await rollup.read.getPendingBlockNumber(); await rollup.write.setAssumeProvenThroughBlockNumber([pendingBlockNumber - BigInt(variant.blockCount) / 2n]); - const timeliness = (await rollup.read.EPOCH_DURATION()) * 2n; + const timeliness = (await rollup.read.getEpochDuration()) * 2n; const blockLog = await rollup.read.getBlock([(await rollup.read.getProvenBlockNumber()) + 1n]); const timeJumpTo = await rollup.read.getTimestampForSlot([blockLog.slotNumber + timeliness]); diff --git a/yarn-project/ethereum/src/contracts/rollup.ts b/yarn-project/ethereum/src/contracts/rollup.ts index d92b3680c93..f7535bf3f84 100644 --- a/yarn-project/ethereum/src/contracts/rollup.ts +++ b/yarn-project/ethereum/src/contracts/rollup.ts @@ -85,7 +85,7 @@ export class RollupContract { @memoize getL1GenesisTime() { - return this.rollup.read.GENESIS_TIME(); + return this.rollup.read.getGenesisTime(); } @memoize @@ -95,12 +95,12 @@ export class RollupContract { @memoize getEpochDuration() { - return this.rollup.read.EPOCH_DURATION(); + return this.rollup.read.getEpochDuration(); } @memoize getSlotDuration() { - return this.rollup.read.SLOT_DURATION(); + return this.rollup.read.getSlotDuration(); } @memoize