Skip to content
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

new ban mechanism based on validator participation #17

Conversation

Vitomir2
Copy link
Contributor

  • create the Participation struct and the mapping for the validator's participation;
  • create a new status for active validator and activate it when initially stake;
  • update the status check of the validator with active where applicable;
  • set the activeFrom the current block number when activating the validator;
  • create a new function in the ValidatorSet interface to update the lastlyActive for the validator participation;
  • update the unstaking to take into account the delegation when unstaking the full amount;
  • fix tests and write some new ones to cover the new changes;

contracts/ValidatorSet/modules/Inspector/Inspector.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/modules/Inspector/Inspector.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/modules/Staking/Staking.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/IValidatorSet.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/modules/Staking/Staking.sol Outdated Show resolved Hide resolved
contracts/RewardPool/RewardPool.sol Outdated Show resolved Hide resolved
contracts/RewardPool/RewardPool.sol Show resolved Hide resolved
Vitomir2 added 3 commits May 20, 2024 18:36
create the Participation struct and the mapping for the validator's participation;
create new status for active validator and activate it when initially stake;
update the status check of the validator with active where applicable;
set the activeFrom the current block number when activate the validator;
create new function in the ValidatorSet interface to update the lastlyActive for the validator participation;
update the unstaking to take into account the delegation when unstaking full amount;
fix tests and write some new ones to cover the new changes;
make the participation just a mapping with address and uint;
move the participation in the validatorset;
withdraw a reward for the reporter when ban a validator;
add a parameter for the onlyValidator modifier in order to be able to re-use in more scenarios;
delete banValidatorByOwner;
add some more tests and delete the ones for the banValidatorByOwner;
some other minor optimizations in the descriptions;
@Vitomir2 Vitomir2 force-pushed the 125-implement-a-mechanism-to-measure-the-participation-of-every-validator-based-on-uptime-data-provided-to-the-rewardpool-so-a-validator-can-be-banned-in-case-offline-for-more-than-72-hours branch from b9e3e01 to 562f1cc Compare May 20, 2024 15:45
@Vitomir2 Vitomir2 requested a review from R-Santev May 20, 2024 15:45
contracts/ValidatorSet/ValidatorSetBase.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/modules/Inspector/Inspector.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/modules/Inspector/Inspector.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/modules/Staking/Staking.sol Outdated Show resolved Hide resolved
contracts/ValidatorSet/modules/Staking/Staking.sol Outdated Show resolved Hide resolved
// if (amount > totalStake || amount + delegation > totalStake)
if (amount > validatorStake) revert StakeRequirement({src: "unstake", msg: "INSUFFICIENT_BALANCE"});

// uint256 validatorStake = totalStake - delegation;
totalStakeLeft = totalStake - amount;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totalStakeLeft is unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but it is part of the named return params.

R-Santev and others added 2 commits May 21, 2024 10:36
burn the penalty for the ban;
delete some redundant comments and optimize others;
rename the _mint and _burn methods to _increaseAccountBalance and _decreaseAccountBalance, respectively;
add some more expects in the ban tests to assert that the penalty has been burned;
@Vitomir2 Vitomir2 requested a review from R-Santev May 21, 2024 10:40
@Vitomir2 Vitomir2 merged commit a7b6b39 into main May 22, 2024
0 of 7 checks passed
@Vitomir2 Vitomir2 deleted the 125-implement-a-mechanism-to-measure-the-participation-of-every-validator-based-on-uptime-data-provided-to-the-rewardpool-so-a-validator-can-be-banned-in-case-offline-for-more-than-72-hours branch May 22, 2024 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstaking/Banning will withdraw all the funds, include the delegators' ones
3 participants