forked from 0xPolygon/polygon-edge
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update predeployed staking SC (0xPolygon#397)
* Update predeployed staking SC Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add CLI flag for providing maximum validator count to PoS Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Fix lint Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add sanity check for max validator count value Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Update check behaviour for max validator count Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add support for configurable minimum validator count Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add missing value in default configuration Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Fix lint error Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add new type for staking contract params Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Update error handling in predeploy process Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Update staking contract bytecode Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add generic error for PoS validator number Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Update SC bytecode Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Update storage write process for min and max validator counts Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add sanity check in predeploy process Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add validator limit test for PoS Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Add test for default max validator limit in PoS Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Fix merge conflicts Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Fix lint errors Signed-off-by: Luca Georges Francois <luca.georges-francois@epitech.eu> * Fix git merge * Remove unnecessary log * change bytecode to match staking-contract repo * fix linter errors * Fix PR comments * Refactor validator setter in genesis * Add missing spacing * Change min and max validator number to uint256 * Change min and max validator count to pointer in switch * Fix linter errors * Add additional check for validator set by prefix * add additional check for pos switch * Fix typo Co-authored-by: AleksaOpacic <aleksaopacic988@gmail.com>
- Loading branch information
1 parent
cc56e29
commit 3543e50
Showing
19 changed files
with
427 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,37 @@ | ||
package command | ||
|
||
import ( | ||
"errors" | ||
"github.com/0xPolygon/polygon-edge/helper/common" | ||
) | ||
|
||
const ( | ||
ConsensusFlag = "consensus" | ||
NoDiscoverFlag = "no-discover" | ||
BootnodeFlag = "bootnode" | ||
LogLevelFlag = "log-level" | ||
) | ||
|
||
var ( | ||
errInvalidValidatorRange = errors.New("minimum number of validators can not be greater than the " + | ||
"maximum number of validators") | ||
errInvalidMinNumValidators = errors.New("minimum number of validators must be greater than 0") | ||
errInvalidMaxNumValidators = errors.New("maximum number of validators must be lower or equal " + | ||
"than MaxSafeJSInt (2^53 - 2)") | ||
) | ||
|
||
func ValidateMinMaxValidatorsNumber(minValidatorCount uint64, maxValidatorCount uint64) error { | ||
if minValidatorCount < 1 { | ||
return errInvalidMinNumValidators | ||
} | ||
|
||
if minValidatorCount > maxValidatorCount { | ||
return errInvalidValidatorRange | ||
} | ||
|
||
if maxValidatorCount > common.MaxSafeJSInt { | ||
return errInvalidMaxNumValidators | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.