-
Notifications
You must be signed in to change notification settings - Fork 93
Native staking changes and unit tests #2029
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
naddison36
merged 5 commits into
sparrowDom/nativeStaking
from
nicka/native-staking-tests
Apr 25, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6dcc982
Fixed native staking deployment since the strategist is got from the …
naddison36 78082be
Refactor of some Native Staking events
naddison36 5689686
Renamed AccountingBeaconChainRewards to AccountingConsensusRewards
naddison36 66d5564
fixed bug not accounting for previous consensus rewards
naddison36 7af69e4
Pause collectRewardTokens and doAccounting on accounting failure.
naddison36 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ pragma solidity ^0.8.0; | |
| import { Pausable } from "@openzeppelin/contracts/security/Pausable.sol"; | ||
| import { Governable } from "../../governance/Governable.sol"; | ||
| import { IDepositContract } from "../../interfaces/IDepositContract.sol"; | ||
| import { IVault } from "../../interfaces/IVault.sol"; | ||
| import { IWETH9 } from "../../interfaces/IWETH9.sol"; | ||
| import { ISSVNetwork, Cluster } from "../../interfaces/ISSVNetwork.sol"; | ||
|
|
||
|
|
@@ -25,6 +26,8 @@ abstract contract ValidatorRegistrator is Governable, Pausable { | |
| address public immutable BEACON_CHAIN_DEPOSIT_CONTRACT; | ||
| /// @notice The address of the SSV Network contract used to interface with | ||
| address public immutable SSV_NETWORK_ADDRESS; | ||
| /// @notice Address of the OETH Vault proxy contract | ||
| address public immutable VAULT_ADDRESS; | ||
|
|
||
| /// @notice Address of the registrator - allowed to register, exit and remove validators | ||
| address public validatorRegistrator; | ||
|
|
@@ -45,7 +48,7 @@ abstract contract ValidatorRegistrator is Governable, Pausable { | |
| EXIT_COMPLETE // validator has funds withdrawn to the EigenPod and is removed from the SSV | ||
| } | ||
|
|
||
| event RegistratorAddressChanged(address oldAddress, address newAddress); | ||
| event RegistratorChanged(address newAddress); | ||
| event ETHStaked(bytes pubkey, uint256 amount, bytes withdrawal_credentials); | ||
| event SSVValidatorRegistered(bytes pubkey, uint64[] operatorIds); | ||
| event SSVValidatorExitInitiated(bytes pubkey, uint64[] operatorIds); | ||
|
|
@@ -60,22 +63,34 @@ abstract contract ValidatorRegistrator is Governable, Pausable { | |
| _; | ||
| } | ||
|
|
||
| /// @dev Throws if called by any account other than the Strategist | ||
| modifier onlyStrategist() { | ||
| require( | ||
| msg.sender == IVault(VAULT_ADDRESS).strategistAddr(), | ||
| "Caller is not the Strategist" | ||
| ); | ||
| _; | ||
| } | ||
|
|
||
| /// @param _wethAddress Address of the Erc20 WETH Token contract | ||
| /// @param _vaultAddress Address of the Vault | ||
| /// @param _beaconChainDepositContract Address of the beacon chain deposit contract | ||
| /// @param _ssvNetwork Address of the SSV Network contract | ||
| constructor( | ||
| address _wethAddress, | ||
| address _vaultAddress, | ||
| address _beaconChainDepositContract, | ||
| address _ssvNetwork | ||
| ) { | ||
| WETH_TOKEN_ADDRESS = _wethAddress; | ||
| BEACON_CHAIN_DEPOSIT_CONTRACT = _beaconChainDepositContract; | ||
| SSV_NETWORK_ADDRESS = _ssvNetwork; | ||
| VAULT_ADDRESS = _vaultAddress; | ||
| } | ||
|
|
||
| /// @notice Set the address of the registrator | ||
| function setRegistratorAddress(address _address) external onlyGovernor { | ||
| emit RegistratorAddressChanged(validatorRegistrator, _address); | ||
| /// @notice Set the address of the registrator which can register, exit and remove validators | ||
| function setRegistrator(address _address) external onlyGovernor { | ||
| emit RegistratorChanged(_address); | ||
| validatorRegistrator = _address; | ||
| } | ||
|
|
||
|
|
@@ -201,4 +216,22 @@ abstract contract ValidatorRegistrator is Governable, Pausable { | |
|
|
||
| validatorsStates[keccak256(publicKey)] = VALIDATOR_STATE.EXIT_COMPLETE; | ||
| } | ||
|
|
||
| /// @notice Deposits more SSV Tokens to the SSV Network contract which is used to pay the SSV Operators. | ||
| /// @dev A SSV cluster is defined by the SSVOwnerAddress and the set of operatorIds. | ||
| /// uses "onlyStrategist" modifier so continuous front-running can't DOS our maintenance service | ||
| /// that tries to top up SSV tokens. | ||
| /// @param cluster The SSV cluster details that must be derived from emitted events from the SSVNetwork contract. | ||
| function depositSSV( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much better location for it |
||
| uint64[] memory operatorIds, | ||
| uint256 amount, | ||
| Cluster memory cluster | ||
| ) external onlyStrategist { | ||
| ISSVNetwork(SSV_NETWORK_ADDRESS).deposit( | ||
| address(this), | ||
| operatorIds, | ||
| amount, | ||
| cluster | ||
| ); | ||
| } | ||
| } | ||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good sanity check