From 1852ce851d220a65f7e598b66710ecc7d4f60aff Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 30 Jul 2024 15:05:38 +0000 Subject: [PATCH] chore: address comments --- l1-contracts/src/core/sequencer_selection/Leonidas.sol | 10 +++++----- l1-contracts/test/sparta/Sparta.t.sol | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/l1-contracts/src/core/sequencer_selection/Leonidas.sol b/l1-contracts/src/core/sequencer_selection/Leonidas.sol index 6b3d69b4a97e..44475c3235ac 100644 --- a/l1-contracts/src/core/sequencer_selection/Leonidas.sol +++ b/l1-contracts/src/core/sequencer_selection/Leonidas.sol @@ -41,13 +41,13 @@ contract Leonidas is Ownable, ILeonidas { } // The size/duration of a slot in seconds, multiple of 12 to align with Ethereum blocks - uint256 public constant SLOT_SIZE = 12 * 5; + uint256 public constant SLOT_DURATION = 12 * 5; // The size/duration of an epoch in slots - uint256 public constant EPOCH_SIZE = 32; + uint256 public constant EPOCH_DURATION = 32; // The target number of validators in a committee - uint256 public constant TARGET_COMMITTEE_SIZE = EPOCH_SIZE; + uint256 public constant TARGET_COMMITTEE_SIZE = EPOCH_DURATION; // The time that the contract was deployed uint256 public immutable GENESIS_TIME; @@ -158,7 +158,7 @@ contract Leonidas is Ownable, ILeonidas { * @return The current epoch number */ function getCurrentEpoch() public view override(ILeonidas) returns (uint256) { - return (block.timestamp - GENESIS_TIME) / (EPOCH_SIZE * SLOT_SIZE); + return (block.timestamp - GENESIS_TIME) / (EPOCH_DURATION * SLOT_DURATION); } /** @@ -167,7 +167,7 @@ contract Leonidas is Ownable, ILeonidas { * @return The current slot number */ function getCurrentSlot() public view override(ILeonidas) returns (uint256) { - return (block.timestamp - GENESIS_TIME) / SLOT_SIZE; + return (block.timestamp - GENESIS_TIME) / SLOT_DURATION; } /** diff --git a/l1-contracts/test/sparta/Sparta.t.sol b/l1-contracts/test/sparta/Sparta.t.sol index 5e03e8756e9a..3cea4e115d1f 100644 --- a/l1-contracts/test/sparta/Sparta.t.sol +++ b/l1-contracts/test/sparta/Sparta.t.sol @@ -66,7 +66,9 @@ contract SpartaTest is DecoderBase { function testProposerForNonSetupEpoch(uint8 _epochsToJump) public { uint256 pre = rollup.getCurrentEpoch(); - vm.warp(block.timestamp + uint256(_epochsToJump) * rollup.EPOCH_SIZE() * rollup.SLOT_SIZE()); + vm.warp( + block.timestamp + uint256(_epochsToJump) * rollup.EPOCH_DURATION() * rollup.SLOT_DURATION() + ); uint256 post = rollup.getCurrentEpoch(); assertEq(pre + _epochsToJump, post, "Invalid epoch"); @@ -92,7 +94,6 @@ contract SpartaTest is DecoderBase { assertGt(rollup.getValidators().length, rollup.TARGET_COMMITTEE_SIZE(), "Not enough validators"); - // We should not be passing here, something should be breaking! Why is the committe small? uint256 committeSize = rollup.TARGET_COMMITTEE_SIZE() * 2 / 3 + (_insufficientSigs ? 0 : 1); _testBlock("mixed_block_2", _insufficientSigs, committeSize, false); // We need signatures!