-
Notifications
You must be signed in to change notification settings - Fork 7
feat(contracts): collect validator registration fee #970
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
a377f38
Add comment
sebastijankuzner ad4d5a4
Rename to validatorsCount
sebastijankuzner 32ccef5
Remove _validatorsCount
sebastijankuzner 4d2baec
Add _activeValidators list
sebastijankuzner c4988eb
Use _activeValidators for measurement
sebastijankuzner 00e81e7
Add activeValidatorsCount
sebastijankuzner 9558ef9
Shuffle without parameters
sebastijankuzner 57bffb5
Use _activeValidators in calculateRoundValidators
sebastijankuzner da5f1b2
Add fee
sebastijankuzner 352fba1
Collect and return fee
sebastijankuzner d5efd1a
Fix add tests
sebastijankuzner ccca8ed
Test registration
sebastijankuzner e8ec95f
Check balance
sebastijankuzner 4344a4c
Check resignation
sebastijankuzner c0c81a1
Test fee
sebastijankuzner 71e4014
Check refund
sebastijankuzner 720b63f
Add tests
sebastijankuzner c7232b7
Improve _isActiveValidator
sebastijankuzner 30a3e6f
Fix reentrancy
sebastijankuzner 5c0d531
Fee optimisation
sebastijankuzner 18fe975
Fee in initializer
sebastijankuzner 4acab12
Test fee
sebastijankuzner 982a32d
Merge branch 'develop' into feat/contracts/validator-fee
sebastijankuzner 322e9be
Improve packing
sebastijankuzner 1677775
Set fee to uint128
sebastijankuzner c55034f
Update contract
sebastijankuzner 94c9a6a
Fix deployer
sebastijankuzner e429496
Set milestone
sebastijankuzner 1b30560
Support validatorRegistrationFee option
sebastijankuzner 83e441c
Calculate total supply
sebastijankuzner 7f4ee0b
Set validatorRegistrationFee
sebastijankuzner 7d16611
Generate network
sebastijankuzner 6575755
style: resolve style guide violations
sebastijankuzner dd93074
regenerate networks
oXtxNt9U a3f03c4
fixes
oXtxNt9U ce76a99
style: resolve style guide violations
oXtxNt9U File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // SPDX-License-Identifier: GNU GENERAL PUBLIC LICENSE | ||
| pragma solidity ^0.8.13; | ||
|
|
||
| import {ConsensusV1} from "@contracts/consensus/ConsensusV1.sol"; | ||
| import {Base} from "./Base.sol"; | ||
| import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
| import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
|
|
||
| contract ConsensusTest is Base { | ||
| function test_default_fee() public view { | ||
| assertEq(consensus.fee(), 0); | ||
| } | ||
|
|
||
| function test_default_fee_custom() public { | ||
| uint256 initialFee = 10; | ||
| bytes memory data = abi.encodeWithSelector(ConsensusV1.initialize.selector, initialFee); | ||
| address proxy = address(new ERC1967Proxy(address(new ConsensusV1()), data)); | ||
| ConsensusV1 consensusCustom = ConsensusV1(proxy); | ||
|
|
||
| assertEq(consensusCustom.fee(), initialFee); | ||
| } | ||
|
|
||
| function test_default_fee_should_be_adjustable() public { | ||
| assertEq(consensus.fee(), 0); | ||
|
|
||
| uint128 newFee = 1000; | ||
| vm.expectEmit(address(consensus)); | ||
| emit ConsensusV1.FeeUpdated(newFee); | ||
| consensus.setFee(newFee); | ||
|
|
||
| assertEq(consensus.fee(), newFee); | ||
| } | ||
| } |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.