Skip to content

Commit 8ce6b87

Browse files
committed
fix: document possible temporary thaw requests blockage when thawing period is shortened (OZ L-02)
Signed-off-by: Tomás Migone <[email protected]>
1 parent fe8f0ba commit 8ce6b87

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

packages/horizon/contracts/data-service/extensions/DataServiceFees.sol

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ abstract contract DataServiceFees is DataService, DataServiceFeesV1Storage, IDat
6363
/**
6464
* @notice Releases expired stake claims for a service provider.
6565
* @dev This function can be overriden and/or disabled.
66+
* @dev Note that the list is traversed by creation date not by releasableAt date. Traversing will stop
67+
* when the first stake claim that is not yet expired is found even if later stake claims have expired. This
68+
* could happen if stake claims are genereted with different unlock periods.
6669
* @dev Emits a {StakeClaimsReleased} event, and a {StakeClaimReleased} event for each claim released.
6770
* @param _serviceProvider The address of the service provider
6871
* @param _numClaimsToRelease Amount of stake claims to process. If 0, all stake claims are processed.

packages/horizon/contracts/interfaces/internal/IHorizonStakingBase.sol

+5-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,11 @@ interface IHorizonStakingBase {
169169
) external view returns (LinkedList.List memory);
170170

171171
/**
172-
* @notice Gets the amount of thawed tokens for a given provision.
172+
* @notice Gets the amount of thawed tokens that can be releasedfor a given provision.
173+
* @dev Note that the value returned by this function does not return the total amount of thawed tokens
174+
* but only those that can be released. If thaw requests are created with different thawing periods it's
175+
* possible that an unexpired thaw request temporarily blocks the release of other ones that have already
176+
* expired. This function will stop counting when it encounters the first thaw request that is not yet expired.
173177
* @param thawRequestType The type of thaw request.
174178
* @param serviceProvider The address of the service provider.
175179
* @param verifier The address of the verifier.

packages/horizon/contracts/interfaces/internal/IHorizonStakingMain.sol

+4-2
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ interface IHorizonStakingMain {
659659
/**
660660
* @notice Remove tokens from a provision and move them back to the service provider's idle stake.
661661
* @dev The parameter `nThawRequests` can be set to a non zero value to fulfill a specific number of thaw
662-
* requests in the event that fulfilling all of them results in a gas limit error.
662+
* requests in the event that fulfilling all of them results in a gas limit error. Otherwise, the function
663+
* will attempt to fulfill all thaw requests until the first one that is not yet expired is found.
663664
*
664665
* Requirements:
665666
* - Must have previously initiated a thaw request using {thaw}.
@@ -783,7 +784,8 @@ interface IHorizonStakingMain {
783784
/**
784785
* @notice Withdraw undelegated tokens from a provision after thawing.
785786
* @dev The parameter `nThawRequests` can be set to a non zero value to fulfill a specific number of thaw
786-
* requests in the event that fulfilling all of them results in a gas limit error.
787+
* requests in the event that fulfilling all of them results in a gas limit error. Otherwise, the function
788+
* will attempt to fulfill all thaw requests until the first one that is not yet expired is found.
787789
* @dev If the delegation pool was completely slashed before withdrawing, calling this function will fulfill
788790
* the thaw requests with an amount equal to zero.
789791
*

packages/horizon/contracts/staking/HorizonStaking.sol

+7-2
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
800800
/**
801801
* @notice Remove tokens from a provision and move them back to the service provider's idle stake.
802802
* @dev The parameter `nThawRequests` can be set to a non zero value to fulfill a specific number of thaw
803-
* requests in the event that fulfilling all of them results in a gas limit error.
803+
* requests in the event that fulfilling all of them results in a gas limit error. Otherwise, the function
804+
* will attempt to fulfill all thaw requests until the first one that is not yet expired is found.
804805
* @param _serviceProvider The service provider address
805806
* @param _verifier The verifier address
806807
* @param _nThawRequests The number of thaw requests to fulfill. Set to 0 to fulfill all thaw requests.
@@ -956,7 +957,8 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
956957
/**
957958
* @notice Withdraw undelegated tokens from a provision after thawing.
958959
* @dev The parameter `nThawRequests` can be set to a non zero value to fulfill a specific number of thaw
959-
* requests in the event that fulfilling all of them results in a gas limit error.
960+
* requests in the event that fulfilling all of them results in a gas limit error. Otherwise, the function
961+
* will attempt to fulfill all thaw requests until the first one that is not yet expired is found.
960962
* @dev If the delegation pool was completely slashed before withdrawing, calling this function will fulfill
961963
* the thaw requests with an amount equal to zero.
962964
* @param _requestType The type of thaw request (Provision or Delegation).
@@ -1073,6 +1075,9 @@ contract HorizonStaking is HorizonStakingBase, IHorizonStakingMain {
10731075

10741076
/**
10751077
* @notice Traverses a thaw request list and fulfills expired thaw requests.
1078+
* @dev Note that the list is traversed by creation date not by thawing until date. Traversing will stop
1079+
* when the first thaw request that is not yet expired is found even if later thaw requests have expired. This
1080+
* could happen for example when the thawing period is shortened.
10761081
* @param _params The parameters for fulfilling thaw requests
10771082
* @return The amount of thawed tokens
10781083
* @return The amount of tokens still thawing

0 commit comments

Comments
 (0)