Skip to content

fix: default value for delegation ratio (OZ L-06) #1145

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

Open
wants to merge 1 commit into
base: horizon-oz2/h01-slash-accounting
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import { ProvisionManagerV1Storage } from "./ProvisionManagerStorage.sol";
* The parameters are:
* - Provision parameters (thawing period and verifier cut)
* - Provision tokens
*
* Note that default values for all provision parameters provide the most permissive configuration, it's
* highly recommended to override them at the data service level.
*
* @custom:security-contact Please email [email protected] if you find any
* bugs. We may have an active bug bounty program.
*/
Expand All @@ -43,6 +47,9 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa
/// @notice The default maximum provision tokens.
uint256 internal constant DEFAULT_MAX_PROVISION_TOKENS = type(uint256).max;

/// @notice The default delegation ratio.
uint32 internal constant DEFAULT_DELEGATION_RATIO = type(uint32).max;

/**
* @notice Emitted when the provision tokens range is set.
* @param min The minimum allowed value for the provision tokens.
Expand Down Expand Up @@ -138,6 +145,7 @@ abstract contract ProvisionManager is Initializable, GraphDirectory, ProvisionMa
_setProvisionTokensRange(DEFAULT_MIN_PROVISION_TOKENS, DEFAULT_MAX_PROVISION_TOKENS);
_setVerifierCutRange(DEFAULT_MIN_VERIFIER_CUT, DEFAULT_MAX_VERIFIER_CUT);
_setThawingPeriodRange(DEFAULT_MIN_THAWING_PERIOD, DEFAULT_MAX_THAWING_PERIOD);
_setDelegationRatio(DEFAULT_DELEGATION_RATIO);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/horizon/test/data-service/DataService.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract DataServiceTest is HorizonStakingSharedTest {
}

function test_Constructor_WhenTheContractIsDeployedWithAValidController() external view {
_assert_delegationRatio(type(uint32).min);
_assert_delegationRatio(type(uint32).max);
_assert_provisionTokens_range(type(uint256).min, type(uint256).max);
_assert_verifierCut_range(type(uint32).min, uint32(PPMMath.MAX_PPM));
_assert_thawingPeriod_range(type(uint64).min, type(uint64).max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ contract DataServiceUpgradeableTest is GraphBaseTest {
// via proxy - ensure that the proxy was initialized correctly
// these calls validate proxy storage was correctly initialized
uint32 delegationRatio = dataService.getDelegationRatio();
assertEq(delegationRatio, type(uint32).min);
assertEq(delegationRatio, type(uint32).max);

(uint256 minTokens, uint256 maxTokens) = dataService.getProvisionTokensRange();
assertEq(minTokens, type(uint256).min);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract DataServicePausableUpgradeableTest is GraphBaseTest {
// via proxy - ensure that the proxy was initialized correctly
// these calls validate proxy storage was correctly initialized
uint32 delegationRatio = dataService.getDelegationRatio();
assertEq(delegationRatio, type(uint32).min);
assertEq(delegationRatio, type(uint32).max);

(uint256 minTokens, uint256 maxTokens) = dataService.getProvisionTokensRange();
assertEq(minTokens, type(uint256).min);
Expand Down