Skip to content

Commit

Permalink
chore: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Jul 30, 2024
1 parent 06bd9a6 commit 1852ce8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions l1-contracts/src/core/sequencer_selection/Leonidas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions l1-contracts/test/sparta/Sparta.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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!

Expand Down

0 comments on commit 1852ce8

Please sign in to comment.