Skip to content

Commit 62c4209

Browse files
committed
fix: ignore thawing tokens on provision token check (TRST-L13)
Signed-off-by: Tomás Migone <[email protected]>
1 parent 0c0d090 commit 62c4209

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

packages/horizon/contracts/data-service/utilities/ProvisionManager.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,12 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa
205205
* @param _provision The provision to check.
206206
*/
207207
function _checkProvisionTokens(IHorizonStaking.Provision memory _provision) internal view virtual {
208-
_checkValueInRange(_provision.tokens, minimumProvisionTokens, maximumProvisionTokens, "tokens");
208+
_checkValueInRange(
209+
_provision.tokens - _provision.tokensThawing,
210+
minimumProvisionTokens,
211+
maximumProvisionTokens,
212+
"tokens"
213+
);
209214
}
210215

211216
/**

packages/horizon/test/data-service/DataService.t.sol

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ contract DataServiceTest is HorizonStakingSharedTest {
6565
assertEq(max, dataServiceOverride.PROVISION_TOKENS_MAX());
6666
}
6767

68+
function test_ProvisionTokens_WhenCheckingAValidProvision_WithThawing(uint256 tokens, uint256 tokensThaw) external useIndexer {
69+
dataService.setProvisionTokensRange(dataService.PROVISION_TOKENS_MIN(), dataService.PROVISION_TOKENS_MAX());
70+
tokens = bound(tokens, dataService.PROVISION_TOKENS_MIN(), dataService.PROVISION_TOKENS_MAX());
71+
tokensThaw = bound(tokensThaw, tokens - dataService.PROVISION_TOKENS_MIN() + 1, tokens);
72+
73+
_createProvision(users.indexer, address(dataService), tokens, 0, 0);
74+
staking.thaw(users.indexer, address(dataService), tokensThaw);
75+
vm.expectRevert(
76+
abi.encodeWithSelector(
77+
ProvisionManager.ProvisionManagerInvalidValue.selector,
78+
"tokens",
79+
tokens - tokensThaw,
80+
dataService.PROVISION_TOKENS_MIN(),
81+
dataService.PROVISION_TOKENS_MAX()
82+
)
83+
);
84+
dataService.checkProvisionTokens(users.indexer);
85+
}
86+
6887
function test_ProvisionTokens_WhenCheckingAValidProvision(uint256 tokens) external useIndexer {
6988
dataService.setProvisionTokensRange(dataService.PROVISION_TOKENS_MIN(), dataService.PROVISION_TOKENS_MAX());
7089
tokens = bound(tokens, dataService.PROVISION_TOKENS_MIN(), dataService.PROVISION_TOKENS_MAX());

0 commit comments

Comments
 (0)