From a19ecb1a9b50245c62753cabceebc22467e67841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Migone?= Date: Tue, 29 Apr 2025 16:47:52 -0300 Subject: [PATCH] chore: remove unused code (OZ N-03) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Migone --- .../horizon/contracts/libraries/UintRange.sol | 2 -- .../staking/HorizonStakingExtension.sol | 5 ++-- .../contracts/staking/utilities/Managed.sol | 8 ----- .../contracts/utilities/AllocationManager.sol | 30 ++----------------- 4 files changed, 4 insertions(+), 41 deletions(-) diff --git a/packages/horizon/contracts/libraries/UintRange.sol b/packages/horizon/contracts/libraries/UintRange.sol index 54552b549..69d3f5d8a 100644 --- a/packages/horizon/contracts/libraries/UintRange.sol +++ b/packages/horizon/contracts/libraries/UintRange.sol @@ -8,8 +8,6 @@ pragma solidity 0.8.27; * bugs. We may have an active bug bounty program. */ library UintRange { - using UintRange for uint256; - /** * @notice Checks if a value is in the range [`min`, `max`]. * @param value The value to check. diff --git a/packages/horizon/contracts/staking/HorizonStakingExtension.sol b/packages/horizon/contracts/staking/HorizonStakingExtension.sol index bb51ac433..0bfe54a8b 100644 --- a/packages/horizon/contracts/staking/HorizonStakingExtension.sol +++ b/packages/horizon/contracts/staking/HorizonStakingExtension.sol @@ -279,10 +279,9 @@ contract HorizonStakingExtension is HorizonStakingBase, IHorizonStakingExtension /** * @dev Triggers an update of rewards due to a change in allocations. * @param _subgraphDeploymentID Subgraph deployment updated - * @return Accumulated rewards per allocated token for the subgraph deployment */ - function _updateRewards(bytes32 _subgraphDeploymentID) private returns (uint256) { - return _graphRewardsManager().onSubgraphAllocationUpdate(_subgraphDeploymentID); + function _updateRewards(bytes32 _subgraphDeploymentID) private { + _graphRewardsManager().onSubgraphAllocationUpdate(_subgraphDeploymentID); } /** diff --git a/packages/horizon/contracts/staking/utilities/Managed.sol b/packages/horizon/contracts/staking/utilities/Managed.sol index c1b466870..b2e36056f 100644 --- a/packages/horizon/contracts/staking/utilities/Managed.sol +++ b/packages/horizon/contracts/staking/utilities/Managed.sol @@ -50,14 +50,6 @@ abstract contract Managed is GraphDirectory { _; } - /** - * @dev Revert if the caller is not the Controller - */ - modifier onlyController() { - require(msg.sender == address(_graphController()), ManagedOnlyController()); - _; - } - /** * @dev Revert if the caller is not the governor */ diff --git a/packages/subgraph-service/contracts/utilities/AllocationManager.sol b/packages/subgraph-service/contracts/utilities/AllocationManager.sol index eb4938059..8c8f6ade7 100644 --- a/packages/subgraph-service/contracts/utilities/AllocationManager.sol +++ b/packages/subgraph-service/contracts/utilities/AllocationManager.sol @@ -200,7 +200,6 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca * @param _tokens The amount of tokens to allocate * @param _allocationProof Signed proof of allocation id address ownership * @param _delegationRatio The delegation ratio to consider when locking tokens - * @return The allocation details */ function _allocate( address _indexer, @@ -209,7 +208,7 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca uint256 _tokens, bytes memory _allocationProof, uint32 _delegationRatio - ) internal returns (Allocation.State memory) { + ) internal { require(_allocationId != address(0), AllocationManagerInvalidZeroAllocationId()); _verifyAllocationProof(_indexer, _allocationId, _allocationProof); @@ -238,7 +237,6 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca allocation.tokens; emit AllocationCreated(_indexer, _allocationId, _subgraphDeploymentId, allocation.tokens, currentEpoch); - return allocation; } /** @@ -361,13 +359,8 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca * @param _allocationId The id of the allocation to be resized * @param _tokens The new amount of tokens to allocate * @param _delegationRatio The delegation ratio to consider when locking tokens - * @return The allocation details */ - function _resizeAllocation( - address _allocationId, - uint256 _tokens, - uint32 _delegationRatio - ) internal returns (Allocation.State memory) { + function _resizeAllocation(address _allocationId, uint256 _tokens, uint32 _delegationRatio) internal { Allocation.State memory allocation = _allocations.get(_allocationId); require(allocation.isOpen(), AllocationManagerAllocationClosed(_allocationId)); require(_tokens != allocation.tokens, AllocationManagerAllocationSameSize(_allocationId, _tokens)); @@ -404,7 +397,6 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca } emit AllocationResized(allocation.indexer, _allocationId, allocation.subgraphDeploymentId, _tokens, oldTokens); - return _allocations[_allocationId]; } /** @@ -466,24 +458,6 @@ abstract contract AllocationManager is EIP712Upgradeable, GraphDirectory, Alloca emit MaxPOIStalenessSet(_maxPOIStaleness); } - /** - * @notice Gets the details of an allocation - * @param _allocationId The id of the allocation - * @return The allocation details - */ - function _getAllocation(address _allocationId) internal view returns (Allocation.State memory) { - return _allocations.get(_allocationId); - } - - /** - * @notice Gets the details of a legacy allocation - * @param _allocationId The id of the legacy allocation - * @return The legacy allocation details - */ - function _getLegacyAllocation(address _allocationId) internal view returns (LegacyAllocation.State memory) { - return _legacyAllocations.get(_allocationId); - } - /** * @notice Encodes the allocation proof for EIP712 signing * @param _indexer The address of the indexer