Skip to content

Commit

Permalink
superblock and l1block for staking contract
Browse files Browse the repository at this point in the history
  • Loading branch information
apenzk committed Feb 11, 2025
1 parent b074f84 commit 060549d
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ contract MovementStaking is
address domain = msg.sender;
if (domainGenesisAccepted[domain]) revert GenesisAlreadyAccepted();
domainGenesisAccepted[domain] = true;
// roll over from 0 (genesis) to current epoch by block time
currentEpochByDomain[domain] = getEpochByBlockTime(domain);
// roll over from 0 (genesis) to current epoch by L1Block time
currentEpochByDomain[domain] = getEpochByL1BlockTime(domain);

for (uint256 i = 0; i < attestersByDomain[domain].length(); i++) {
address attester = attestersByDomain[domain].at(i);
Expand Down Expand Up @@ -145,12 +145,12 @@ contract MovementStaking is
epochUnstakesByDomain[domain][epoch][custodian][attester] = amount;
}

// gets the would be epoch for the current block time
function getEpochByBlockTime(address domain) public view returns (uint256) {
// gets the would be epoch for the current L1Block time
function getEpochByL1BlockTime(address domain) public view returns (uint256) {
return block.timestamp / epochDurationByDomain[domain];
}

// gets the current epoch up to which blocks have been accepted
// gets the current epoch up to which superBlocks have been accepted
function getCurrentEpoch(address domain) public view returns (uint256) {
return currentEpochByDomain[domain];
}
Expand All @@ -160,11 +160,11 @@ contract MovementStaking is
return getCurrentEpoch(domain) == 0 ? 0 : getCurrentEpoch(domain) + 1;
}

function getNextEpochByBlockTime(
function getNextEpochByL1BlockTime(
address domain
) public view returns (uint256) {
return
getCurrentEpoch(domain) == 0 ? 0 : getEpochByBlockTime(domain) + 1;
getCurrentEpoch(domain) == 0 ? 0 : getEpochByL1BlockTime(domain) + 1;
}

// gets the stake for a given attester at a given epoch
Expand Down Expand Up @@ -263,7 +263,7 @@ contract MovementStaking is
// set the attester to stake for the next epoch
_addStake(
domain,
getNextEpochByBlockTime(domain),
getNextEpochByL1BlockTime(domain),
address(custodian),
msg.sender,
amount
Expand All @@ -290,7 +290,7 @@ contract MovementStaking is
// note: by tracking in the next epoch we need to make sure when we roll over an epoch we check the amount rolled over from stake by the unstake in the next epoch
_addUnstake(
domain,
getNextEpochByBlockTime(domain),
getNextEpochByL1BlockTime(domain),
custodian,
msg.sender,
amount
Expand Down

0 comments on commit 060549d

Please sign in to comment.