Skip to content

Commit

Permalink
genesis can only be ran once if successful per domain
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPrimata committed Sep 6, 2024
1 parent e608512 commit 5c20d36
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ contract MovementStaking is

function acceptGenesisCeremony() public {
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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ contract MovementStakingStorage {
mapping(uint256 epoch =>
mapping(address attester => uint256 stake))) public epochTotalStakeByDomain;

mapping(address domain => bool) public domainGenesisAccepted;

// the whitelist role needed to stake/unstake
bytes32 public constant WHITELIST_ROLE = keccak256("WHITELIST_ROLE");
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ interface IMovementStaking {
);

event EpochRolledOver(address indexed domain, uint256 epoch);

error StakeExceedsGenesisStake();
error CustodianTransferAmountMismatch();
error GenesisAlreadyAccepted();
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ contract MovementStakingTest is Test {
staking.getCurrentEpochStake(domain, address(moveToken), staker),
100
);

vm.expectRevert(IMovementStaking.GenesisAlreadyAccepted.selector);
vm.prank(domain);
staking.acceptGenesisCeremony();
}

function testSimpleRolloverEpoch() public {
Expand Down

0 comments on commit 5c20d36

Please sign in to comment.