diff --git a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol index 3b78364784..bf0af0b4b8 100644 --- a/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol +++ b/contracts/staking/contracts/src/staking_pools/MixinStakingPoolRewards.sol @@ -232,19 +232,13 @@ contract MixinStakingPoolRewards is view returns (uint256 reward) { - // There can be no rewards in epoch 0 because there is no delegated - // stake. - uint256 _currentEpoch = currentEpoch; - if (_currentEpoch == 0) { - return 0; - } - + uint256 currentEpoch_ = currentEpoch; IStructs.StoredBalance memory delegatedStake = _delegatedStakeToPoolByOwner[member][poolId]; // There can be no rewards if the last epoch when stake was stored is // equal to the current epoch, because all prior rewards, including // rewards finalized this epoch have been claimed. - if (delegatedStake.currentEpoch == _currentEpoch) { + if (delegatedStake.currentEpoch == currentEpoch_) { return 0; } @@ -253,7 +247,7 @@ contract MixinStakingPoolRewards is // 1/3 Unfinalized rewards earned in `currentEpoch - 1`. reward = _computeUnfinalizedDelegatorReward( delegatedStake, - _currentEpoch, + currentEpoch_, unfinalizedMembersReward, unfinalizedMembersStake ); @@ -275,7 +269,7 @@ contract MixinStakingPoolRewards is poolId, delegatedStake.nextEpochBalance, delegatedStakeNextEpoch, - _currentEpoch + currentEpoch_ ) ); diff --git a/contracts/staking/contracts/src/sys/MixinFinalizer.sol b/contracts/staking/contracts/src/sys/MixinFinalizer.sol index 18e4465b44..f6808d72bf 100644 --- a/contracts/staking/contracts/src/sys/MixinFinalizer.sol +++ b/contracts/staking/contracts/src/sys/MixinFinalizer.sol @@ -99,12 +99,6 @@ contract MixinFinalizer is function finalizePool(bytes32 poolId) public { - // Noop on epoch 0 - uint256 currentEpoch_ = currentEpoch; - if (currentEpoch_ == 0) { - return; - } - // Load the finalization and pool state into memory. IStructs.UnfinalizedState memory state = unfinalizedState; @@ -113,6 +107,7 @@ contract MixinFinalizer is return; } + uint256 currentEpoch_ = currentEpoch; uint256 prevEpoch = currentEpoch_.safeSub(1); IStructs.ActivePool memory pool = _getActivePoolFromEpoch(prevEpoch, poolId); @@ -182,12 +177,10 @@ contract MixinFinalizer is uint256 membersStake ) { - uint256 epoch = currentEpoch; - // There are no pools to finalize at epoch 0. - if (epoch == 0) { - return (0, 0); - } - IStructs.ActivePool memory pool = _getActivePoolFromEpoch(epoch - 1, poolId); + IStructs.ActivePool memory pool = _getActivePoolFromEpoch( + currentEpoch.safeSub(1), + poolId + ); reward = _getUnfinalizedPoolRewardsFromState(pool, unfinalizedState); membersStake = pool.membersStake; } diff --git a/contracts/staking/contracts/src/sys/MixinScheduler.sol b/contracts/staking/contracts/src/sys/MixinScheduler.sol index 90f76c22f9..0c52978c03 100644 --- a/contracts/staking/contracts/src/sys/MixinScheduler.sol +++ b/contracts/staking/contracts/src/sys/MixinScheduler.sol @@ -53,6 +53,7 @@ contract MixinScheduler is // solhint-disable-next-line currentEpochStartTimeInSeconds = block.timestamp; + currentEpoch = 1; } /// @dev Moves to the next epoch, given the current epoch period has ended.