-
Notifications
You must be signed in to change notification settings - Fork 10
Fix owneronly for settings #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,8 @@ contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, SQParam | |
| * @param amount the labor of services | ||
| */ | ||
| function labor(bytes32 deploymentId, address runner, uint256 amount) external { | ||
| _requireNotBlacklisted(settings, runner); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blacklist enforcement is incomplete: caller bypass remains possible. These paths only gate Suggested patch function labor(bytes32 deploymentId, address runner, uint256 amount) external {
+ _requireNotBlacklisted(settings, msg.sender);
_requireNotBlacklisted(settings, runner);
...
}
function collect(bytes32 deploymentId, address runner) external {
+ _requireNotBlacklisted(settings, msg.sender);
_requireNotBlacklisted(settings, runner);
...
}
function batchCollect(address runner) external {
+ _requireNotBlacklisted(settings, msg.sender);
_requireNotBlacklisted(settings, runner);
...
}
function collectEra(uint256 era, bytes32 deploymentId, address runner) external {
+ _requireNotBlacklisted(settings, msg.sender);
_requireNotBlacklisted(settings, runner);
...
}
function batchCollectEra(uint256 era, address runner) external {
+ _requireNotBlacklisted(settings, msg.sender);
_requireNotBlacklisted(settings, runner);
...
}Also applies to: 215-215, 227-227, 241-241, 255-255 🤖 Prompt for AI Agents |
||
|
|
||
| require(amount > 0, 'RP002'); | ||
| IERC20(settings.getContractAddress(SQContracts.SQToken)).safeTransferFrom( | ||
| msg.sender, | ||
|
|
@@ -210,6 +212,8 @@ contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, SQParam | |
| * @param runner runner address | ||
| */ | ||
| function collect(bytes32 deploymentId, address runner) external { | ||
| _requireNotBlacklisted(settings, runner); | ||
|
|
||
| uint256 currentEra = IEraManager(settings.getContractAddress(SQContracts.EraManager)) | ||
| .safeUpdateAndGetEra(); | ||
| _collect(currentEra - 1, deploymentId, runner); | ||
|
|
@@ -220,6 +224,8 @@ contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, SQParam | |
| * @param runner runner address | ||
| */ | ||
| function batchCollect(address runner) external { | ||
| _requireNotBlacklisted(settings, runner); | ||
|
|
||
| uint256 currentEra = IEraManager(settings.getContractAddress(SQContracts.EraManager)) | ||
| .safeUpdateAndGetEra(); | ||
| _batchCollect(currentEra - 1, runner); | ||
|
|
@@ -232,6 +238,8 @@ contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, SQParam | |
| * @param runner runner address | ||
| */ | ||
| function collectEra(uint256 era, bytes32 deploymentId, address runner) external { | ||
| _requireNotBlacklisted(settings, runner); | ||
|
|
||
| uint256 currentEra = IEraManager(settings.getContractAddress(SQContracts.EraManager)) | ||
| .safeUpdateAndGetEra(); | ||
| require(currentEra > era, 'RP004'); | ||
|
|
@@ -244,6 +252,8 @@ contract RewardsPool is IRewardsPool, Initializable, OwnableUpgradeable, SQParam | |
| * @param runner runner address | ||
| */ | ||
| function batchCollectEra(uint256 era, address runner) external { | ||
| _requireNotBlacklisted(settings, runner); | ||
|
|
||
| uint256 currentEra = IEraManager(settings.getContractAddress(SQContracts.EraManager)) | ||
| .safeUpdateAndGetEra(); | ||
| require(currentEra > era, 'RP004'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import './interfaces/IStakingAllocation.sol'; | |
| import './interfaces/IIndexerRegistry.sol'; | ||
| import './Constants.sol'; | ||
| import './utils/MathUtil.sol'; | ||
| import './utils/SQParameter.sol'; | ||
|
|
||
| /** | ||
| * @title Rewards Staking Contract | ||
|
|
@@ -39,7 +40,7 @@ import './utils/MathUtil.sol'; | |
| * 2. These management functions are permissionless, so delegators can call them on runner's behalf so they can remove their delegation from the runner. | ||
| * | ||
| */ | ||
| contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable { | ||
| contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable, SQParameter { | ||
| using SafeERC20 for IERC20; | ||
| using MathUtil for uint256; | ||
|
|
||
|
|
@@ -144,6 +145,9 @@ contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable { | |
| * Last era's reward need to be collected before this can pass. | ||
| */ | ||
| function onStakeChange(address _runner, address _source) external onlyStaking { | ||
| _requireNotBlacklisted(settings, _runner); | ||
| _requireNotBlacklisted(settings, _source); | ||
|
|
||
| uint256 currentEra = _getCurrentEra(); | ||
| uint256 lastEra = currentEra - 1; | ||
|
|
||
|
|
@@ -228,6 +232,8 @@ contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable { | |
| * Last era's reward need to be collected before this can pass. | ||
| */ | ||
| function onICRChange(address runner, uint256 startEra) external onlyIndexerRegistry { | ||
| _requireNotBlacklisted(settings, runner); | ||
|
|
||
| uint256 currentEra = _getCurrentEra(); | ||
| require(startEra > currentEra, 'RS004'); | ||
|
|
||
|
|
@@ -246,6 +252,8 @@ contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable { | |
| * @dev Apply the stake change and calaulate the new rewardDebt for staker. | ||
| */ | ||
| function applyStakeChange(address runner, address staker) external { | ||
| _requireNotBlacklisted(settings, staker); | ||
|
|
||
|
Comment on lines
254
to
+256
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also blacklist-gate This path still settles Suggested fix function applyStakeChange(address runner, address staker) external {
+ _requireNotBlacklisted(settings, runner);
_requireNotBlacklisted(settings, staker);🤖 Prompt for AI Agents |
||
| IRewardsDistributor rewardsDistributor = _getRewardsDistributor(); | ||
| IndexerRewardInfo memory rewardInfo = rewardsDistributor.getRewardInfo(runner); | ||
| uint256 lastClaimEra = rewardInfo.lastClaimEra; | ||
|
|
@@ -294,6 +302,9 @@ contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable { | |
| } | ||
|
|
||
| function applyRedelegation(address runner, address staker) external onlyStakingManager { | ||
| _requireNotBlacklisted(settings, runner); | ||
| _requireNotBlacklisted(settings, staker); | ||
|
|
||
| IRewardsDistributor rewardsDistributor = _getRewardsDistributor(); | ||
| IndexerRewardInfo memory rewardInfo = rewardsDistributor.getRewardInfo(runner); | ||
| uint256 currentEra = _getCurrentEra(); | ||
|
|
@@ -338,6 +349,8 @@ contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable { | |
| * @dev Apply the CommissionRate change and update the commissionRates stored in contract states. | ||
| */ | ||
| function applyICRChange(address runner) external { | ||
| _requireNotBlacklisted(settings, runner); | ||
|
|
||
| uint256 currentEra = _getCurrentEra(); | ||
| require( | ||
| pendingCommissionRateChange[runner] != 0 && | ||
|
|
@@ -397,6 +410,8 @@ contract RewardsStaking is IRewardsStaking, Initializable, OwnableUpgradeable { | |
| * Require to be true when someone try to claimRewards() or onStakeChangeRequested(). | ||
| */ | ||
| function applyRunnerWeightChange(address _runner) public { | ||
| _requireNotBlacklisted(settings, _runner); | ||
|
|
||
| uint256 _runnerStakeWeight = runnerStakeWeight(); | ||
| uint256 _previousRunnerStakeWeight = previousRunnerStakeWeight(_runner); | ||
| if (_runnerStakeWeight != _previousRunnerStakeWeight) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid freezing distributor accounting for blacklisted runners.
These two functions are bookkeeping entrypoints, not runner-authenticated actions. Rejecting them on
runnermeansaccSQTPerStakenever advances for that runner again, so non-blacklisted delegators can get stuck with already-earned rewards and unsettled stake changes.Suggested fix
function collectAndDistributeRewards(address runner) public { - _requireNotBlacklisted(settings, runner); - // check current era is after lastClaimEra uint256 currentEra = _getCurrentEra(); require(info[runner].lastClaimEra < currentEra - 1, 'RD003'); collectAndDistributeEraRewards(currentEra, runner); } @@ function collectAndDistributeEraRewards( uint256 currentEra, address runner ) public returns (uint256) { - _requireNotBlacklisted(settings, runner); - RewardInfo storage rewardInfo = info[runner]; require(rewardInfo.lastClaimEra > 0, 'RD004');Also applies to: 351-356