add new staking - #192
Conversation
| } | ||
|
|
||
| function getStaking() public view returns(address){ | ||
| return addressStorage[STAKING]; |
There was a problem hiding this comment.
I don't see anything wrtiting too addressStorage[STAKING]. There's no _setStaking,
initializeAddresses wasn't extended, and setContractAddress upgrades an
existing proxy rather than registering a new address. getStaking() returns 0
forever, so the hook in BlockReward never fires.
|
|
||
| address stakingAddress = ProxyStorage(getProxyStorage()).getStaking(); | ||
| if (stakingAddress != address(0)) { | ||
| IStakingRewards(stakingAddress).recordBlockReward( |
There was a problem hiding this comment.
this may need wrapping in a try, if this reverts every node will fail to process the block and we risk a chain halt
| /// @param cycle The cycle being recorded. | ||
| /// @param receivers List of reward receivers. | ||
| /// @param rewardWeights List of corresponding reward weights. | ||
| function recordBlockReward( |
There was a problem hiding this comment.
It might be worth looking to limit number of delegates currently getDelegatorsForRewardDistribution is unlimited and this call will add state growth per block per delegate (might be a potential attack vector)
| /// This prevents users from claiming before the final reward amount is known. | ||
| /// | ||
| /// @param cycle The cycle to finalize. | ||
| function finalizeCycleReward(uint256 cycle) |
There was a problem hiding this comment.
might be worth gating this with a require to ensure the cycle is over
require(cycle != IConsensus(...).getCurrentCycleStartBlock())
| /// @notice Claims rewards for multiple finalized cycles. | ||
| /// @dev Reverts if any cycle in the list is not claimable by the caller. | ||
| /// @param cycles List of cycle IDs to claim. | ||
| function claimRewards(uint256[] calldata cycles) external whenNotPaused nonReentrant { |
There was a problem hiding this comment.
should pausing allow withdraws still?
i.m.o pausing should just gate recording and finalization only
| uint256 totalWeight = totalCycleWeights[cycle]; | ||
| if (totalWeight == 0) revert NoTotalWeight(); | ||
|
|
||
| uint256 rewardAmount = Math.mulDiv(cycleRewards[cycle], userWeight, totalWeight); |
There was a problem hiding this comment.
nothing major but this will accumulate dust from rounding per cycle so some rewards will be lost over time. Just something to be aware of
|
|
||
| /// @notice Emitted when the paused state is updated. | ||
| /// @param paused The new paused state. | ||
| event Paused(bool paused); |
There was a problem hiding this comment.
You might want to rename this collides with OpenZepllin convention, may break indexers/ external tooling.
No description provided.