-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement sending of allocated validator payments (#11197)
- Loading branch information
Showing
7 changed files
with
363 additions
and
3 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
10 changes: 10 additions & 0 deletions
10
packages/protocol/contracts-0.8/common/mocks/EpochManager_WithMocks.sol
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,10 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.7 <0.8.20; | ||
|
||
import "../EpochManager.sol"; | ||
|
||
contract EpochManager_WithMocks is EpochManager(true) { | ||
function _setPaymentAllocation(address validator, uint256 amount) external { | ||
validatorPendingPayments[validator] = amount; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/protocol/contracts-0.8/common/mocks/MockAccounts.sol
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,43 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.7 <0.8.20; | ||
|
||
import "../../../contracts/common/FixidityLib.sol"; | ||
|
||
contract MockAccounts { | ||
using FixidityLib for FixidityLib.Fraction; | ||
|
||
struct PaymentDelegation { | ||
// Address that should receive a fraction of validator payments. | ||
address beneficiary; | ||
// Fraction of payment to delegate to `beneficiary`. | ||
FixidityLib.Fraction fraction; | ||
} | ||
|
||
mapping(address => PaymentDelegation) delegations; | ||
mapping(address => address) accountToSigner; | ||
|
||
function setPaymentDelegationFor( | ||
address validator, | ||
address beneficiary, | ||
uint256 fraction | ||
) public { | ||
delegations[validator] = PaymentDelegation(beneficiary, FixidityLib.wrap(fraction)); | ||
} | ||
|
||
function deletePaymentDelegationFor(address validator) public { | ||
delete delegations[validator]; | ||
} | ||
|
||
function getPaymentDelegation(address account) external view returns (address, uint256) { | ||
PaymentDelegation storage delegation = delegations[account]; | ||
return (delegation.beneficiary, delegation.fraction.unwrap()); | ||
} | ||
|
||
function setValidatorSigner(address account, address signer) external { | ||
accountToSigner[account] = signer; | ||
} | ||
|
||
function getValidatorSigner(address account) external returns (address) { | ||
return accountToSigner[account]; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
packages/protocol/contracts-0.8/governance/test/IMockValidators.sol
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,61 @@ | ||
pragma solidity >=0.8.7 <0.8.20; | ||
|
||
interface IMockValidators { | ||
function isValidator(address) external returns (bool); | ||
function isValidatorGroup(address) external returns (bool); | ||
|
||
function updateEcdsaPublicKey(address, address, bytes calldata) external returns (bool); | ||
|
||
function updatePublicKeys( | ||
address, | ||
address, | ||
bytes calldata, | ||
bytes calldata, | ||
bytes calldata | ||
) external returns (bool); | ||
|
||
function setValidator(address) external; | ||
|
||
function setValidatorGroup(address group) external; | ||
|
||
function affiliate(address group) external returns (bool); | ||
|
||
function setDoesNotMeetAccountLockedGoldRequirements(address account) external; | ||
|
||
function setNumRegisteredValidators(uint256 value) external; | ||
|
||
function setMembers(address group, address[] calldata _members) external; | ||
|
||
function setCommission(address group, uint256 commission) external; | ||
|
||
function setAccountLockedGoldRequirement(address account, uint256 value) external; | ||
|
||
function halveSlashingMultiplier(address) external; | ||
|
||
function forceDeaffiliateIfValidator(address validator) external; | ||
|
||
function getTopGroupValidators(address group, uint256 n) external view returns (address[] memory); | ||
|
||
function getValidatorGroup( | ||
address | ||
) | ||
external | ||
view | ||
returns (address[] memory, uint256, uint256, uint256, uint256[] memory, uint256, uint256); | ||
|
||
function getValidatorGroupSlashingMultiplier(address) external view returns (uint256); | ||
|
||
function meetsAccountLockedGoldRequirements(address account) external view returns (bool); | ||
|
||
function getNumRegisteredValidators() external view returns (uint256); | ||
|
||
function getAccountLockedGoldRequirement(address account) external view returns (uint256); | ||
|
||
function calculateGroupEpochScore(uint256[] calldata uptimes) external view returns (uint256); | ||
|
||
function getGroupsNumMembers(address[] calldata groups) external view returns (uint256[] memory); | ||
|
||
function groupMembershipInEpoch(address addr, uint256, uint256) external view returns (address); | ||
|
||
function getGroupNumMembers(address group) external view returns (uint256); | ||
} |
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.