-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate with precompile of picking validator set. Feat bridge opera…
…tors. (#32) * Squad commit * Add ValidatorFlag * Clean up * Fix pick new validator set contract. Add precompile. * Fix arrange validators test * Fix wrapupEpoch function - Refactor wrapUpEpoch function, separate into smaller modules - Update to new requirements. Sorting & arranging validators, then disable their ability of producing blocks regarding their in jail and maintaining status - Fix distribute delegating amount * Refactor function order * Update doc * Fix precompile and precompile-usage * Fix arrange validator precompile * Fix RoninValidatorSet test * Fix contract to deactivate block producers * Emit BridgeOperatorSetUpdated. Fix query operators function. * Fix mock contracts * Fix test * Fix EnumFlags. Fix test. * Fix (de)activate block producers function. Fix test. * Move precompile address to precompile-usage contracts * Fix test of slashing indicator * Fix test. * Fix bug in _removeCandidate function * Fix WrapUpEpoch integration test * Fix submit reward integration test * Clean up precompile contracts * Add docs for private functions * Clean up wrapping up epoch function * Add more parameters for WrappedUpEpoch event * Update docs for MiningRewardDistributed event Co-authored-by: Duc Tho Tran <[email protected]> * Update docs for BridgeOperatorRewardDistributed event Co-authored-by: Duc Tho Tran <[email protected]> * Minor saving gas Co-authored-by: Duc Tho Tran <[email protected]> * Minor saving gas Co-authored-by: Duc Tho Tran <[email protected]> * Minor fix for test of validator set * Refactor Sorting contract * Update docs for isValidator method * Add epoch number for WrappedUpEpoch event * Remove redundant casting to `IStaking` * Remove duplicated code * Fix `isValidator` callers * Fix revert message in test * Remove (De)ActivatedBlockProducers event. Add BlockProducerSetUpdated event. * Fix `_pcPickValidatorSet` result length * Fix catch precompile result length Co-authored-by: Duc Tho Tran <[email protected]>
- Loading branch information
1 parent
2d51d29
commit 3eb0823
Showing
44 changed files
with
1,645 additions
and
780 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* @dev This library implements checking flag of an enumerated value. | ||
* The originated idea is inherited from [Enum.HashFlag(Enum)](https://learn.microsoft.com/en-us/dotnet/api/system.enum.hasflag?view=net-6.0) method of C#. | ||
*/ | ||
library EnumFlags { | ||
enum ValidatorFlag { | ||
None, // bit(00) | ||
BlockProducer, // bit(01) | ||
BridgeOperator, // bit(10) | ||
Both // bit(11) | ||
} | ||
|
||
function isNone(ValidatorFlag _value) internal pure returns (bool) { | ||
return uint8(_value) == 0; | ||
} | ||
|
||
/** | ||
* @dev Checks if `_value` has `_flag`. | ||
*/ | ||
function hasFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (bool) { | ||
return (uint8(_value) & uint8(_flag)) != 0; | ||
} | ||
|
||
/** | ||
* @dev Calculate new value of `_value` after adding `_flag`. | ||
*/ | ||
function addFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) { | ||
return ValidatorFlag(uint8(_value) | uint8(_flag)); | ||
} | ||
|
||
/** | ||
* @dev Calculate new value of `_value` after remove `_flag`. | ||
*/ | ||
function removeFlag(ValidatorFlag _value, ValidatorFlag _flag) internal pure returns (ValidatorFlag) { | ||
return ValidatorFlag(uint8(_value) & ~uint8(_flag)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.