-
Notifications
You must be signed in to change notification settings - Fork 8
[CSM v3 / CM v2] feat: SettleGeneralDelayedPenalty + SetMerkleGateTree + SubmitWithdrawals factories #96
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
Open
vgorkavenko
wants to merge
24
commits into
develop
Choose a base branch
from
feat/csm-settle-el-stealing-penalty-with-max-values
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,818
−694
Open
[CSM v3 / CM v2] feat: SettleGeneralDelayedPenalty + SetMerkleGateTree + SubmitWithdrawals factories #96
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
e46faac
feat: add `maxValues` for `CSMSettleElStealingPenalty`
vgorkavenko 809d9f3
feat: rename factory. introduce curated v2 things
vgorkavenko e5b2bf0
Merge remote-tracking branch 'origin/develop' into feat/csm-settle-el…
vgorkavenko a1e1300
fix
vgorkavenko 11b8959
feat: add `name` for factory
vgorkavenko 7ee484c
fix: name in scripts
vgorkavenko 9947aa2
fix: more renames
vgorkavenko 217b3dd
feat: add deployment script for CM
vgorkavenko dc69bce
feat: add SubmitWithdrawals factory
madlabman 6773e4d
chore: pin solidity 0.8.6
madlabman 396934c
chore: add name to the factory
madlabman c406bc8
feat: add deploy script for SubmitWithdrawals
madlabman 14c14b7
test: add scenario/integration test for SubmitWithdrawals
madlabman f226362
feat: rename set vetted gate tree factory
vgorkavenko 70cf3b0
feat: allowed gates registry
vgorkavenko 6fb6e02
fix: review
vgorkavenko a66790e
chore: make allowedGates private variable
madlabman a91b082
test: few tweaks to allowed gate registry
madlabman fdb4222
fix: use the updated method
madlabman 83b6aba
refactor: rename the factory one more time
madlabman ef9ee2b
Merge branch 'feat/csm-settle-el-stealing-penalty-with-max-values' in…
vgorkavenko a1bd033
Merge pull request #100 from lidofinance/csm-submit-withdrawals
vgorkavenko 00642cc
fix: `reportWithdrawnValidators` -> `reportSlashedWithdrawnValidators`
vgorkavenko e36ddf4
feat: settle general delayed penalty deploy script
vgorkavenko 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
99 changes: 0 additions & 99 deletions
99
contracts/EVMScriptFactories/CSMSettleELStealingPenalty.sol
This file was deleted.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
contracts/EVMScriptFactories/SettleGeneralDelayedPenalty.sol
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,119 @@ | ||
| // SPDX-FileCopyrightText: 2024 Lido <[email protected]> | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
|
|
||
| pragma solidity 0.8.6; | ||
|
|
||
| import "../TrustedCaller.sol"; | ||
| import "../libraries/EVMScriptCreator.sol"; | ||
| import "../interfaces/IEVMScriptFactory.sol"; | ||
| import "../interfaces/ICSModule.sol"; | ||
| import "../interfaces/ICSAccounting.sol"; | ||
|
|
||
| /// @author vgorkavenko | ||
| /// @notice Creates EVMScript to settle general delayed penalty for a specific node operators | ||
| contract SettleGeneralDelayedPenalty is TrustedCaller, IEVMScriptFactory { | ||
|
|
||
| // ------------- | ||
| // ERRORS | ||
| // ------------- | ||
|
|
||
| string private constant ERROR_EMPTY_NODE_OPERATORS_IDS = | ||
| "EMPTY_NODE_OPERATORS_IDS"; | ||
| string private constant ERROR_OUT_OF_RANGE_NODE_OPERATOR_ID = | ||
| "OUT_OF_RANGE_NODE_OPERATOR_ID"; | ||
| string private constant ERROR_NODE_OPERATORS_IDS_AND_MAX_AMOUNTS_LENGTH_MISMATCH = | ||
| "NODE_OPERATORS_IDS_AND_MAX_AMOUNTS_LENGTH_MISMATCH"; | ||
| string private constant ERROR_MAX_AMOUNT_SHOULD_BE_GREATER_OR_EQUAL_THAN_ACTUAL_LOCKED = | ||
| "MAX_AMOUNT_SHOULD_BE_GREATER_OR_EQUAL_THAN_ACTUAL_LOCKED"; | ||
| string private constant ERROR_MAX_AMOUNT_SHOULD_BE_GREATER_THAN_ZERO = | ||
| "MAX_AMOUNT_SHOULD_BE_GREATER_THAN_ZERO"; | ||
|
|
||
| // ------------- | ||
| // VARIABLES | ||
| // ------------- | ||
|
|
||
| /// @notice Address of Module Contract | ||
| ICSModule public immutable module; | ||
| ICSAccounting public immutable accounting; | ||
|
|
||
| // ------------- | ||
| // CONSTRUCTOR | ||
| // ------------- | ||
|
|
||
| constructor(address _trustedCaller, address _module) | ||
| TrustedCaller(_trustedCaller) | ||
| { | ||
| module = ICSModule(_module); | ||
| accounting = ICSAccounting(ICSModule(_module).ACCOUNTING()); | ||
| } | ||
|
|
||
| // ------------- | ||
| // EXTERNAL METHODS | ||
| // ------------- | ||
|
|
||
| /// @notice Creates EVMScript to settle general delayed penalty for the specific node operators | ||
| /// @param _creator Address who creates EVMScript | ||
| /// @param _evmScriptCallData Encoded: uint256[] memory nodeOperatorIds, uint256[] memory maxAmounts | ||
| function createEVMScript(address _creator, bytes memory _evmScriptCallData) | ||
| external | ||
| view | ||
| override | ||
| onlyTrustedCaller(_creator) | ||
| returns (bytes memory) | ||
| { | ||
| (uint256[] memory nodeOperatorIds, uint256[] memory maxAmounts) = _decodeEVMScriptCallData(_evmScriptCallData); | ||
|
|
||
| _validateInputData(nodeOperatorIds, maxAmounts); | ||
|
|
||
| return | ||
| EVMScriptCreator.createEVMScript( | ||
| address(module), | ||
| ICSModule.settleGeneralDelayedPenalty.selector, | ||
| _evmScriptCallData | ||
| ); | ||
| } | ||
|
|
||
| /// @notice Decodes call data used by createEVMScript method | ||
| /// @param _evmScriptCallData Encoded: uint256[] memory nodeOperatorIds, uint256[] memory maxAmounts | ||
| /// @return Node operator IDs and max amounts to settle general delayed penalty | ||
| function decodeEVMScriptCallData(bytes memory _evmScriptCallData) | ||
| external | ||
| pure | ||
| returns (uint256[] memory, uint256[] memory) | ||
| { | ||
| return _decodeEVMScriptCallData(_evmScriptCallData); | ||
| } | ||
|
|
||
| // ------------------ | ||
| // PRIVATE METHODS | ||
| // ------------------ | ||
|
|
||
| function _decodeEVMScriptCallData(bytes memory _evmScriptCallData) | ||
| private | ||
| pure | ||
| returns (uint256[] memory, uint256[] memory) | ||
| { | ||
| return abi.decode(_evmScriptCallData, (uint256[], uint256[])); | ||
| } | ||
|
|
||
| function _validateInputData( | ||
| uint256[] memory nodeOperatorsIds, | ||
| uint256[] memory maxAmounts | ||
| ) private view { | ||
| require(nodeOperatorsIds.length > 0, ERROR_EMPTY_NODE_OPERATORS_IDS); | ||
| require( | ||
| nodeOperatorsIds.length == maxAmounts.length, | ||
| ERROR_NODE_OPERATORS_IDS_AND_MAX_AMOUNTS_LENGTH_MISMATCH | ||
| ); | ||
| uint256 nodeOperatorsCount = module.getNodeOperatorsCount(); | ||
| for (uint256 i = 0; i < nodeOperatorsIds.length; ++i) { | ||
| (uint256 nodeOperatorId, uint256 maxAmount) = (nodeOperatorsIds[i], maxAmounts[i]); | ||
| require(nodeOperatorId < nodeOperatorsCount, ERROR_OUT_OF_RANGE_NODE_OPERATOR_ID); | ||
| uint256 actualLocked = accounting.getActualLockedBond( | ||
| nodeOperatorId | ||
| ); | ||
| require(maxAmount > 0, ERROR_MAX_AMOUNT_SHOULD_BE_GREATER_THAN_ZERO); | ||
| require(maxAmount >= actualLocked, ERROR_MAX_AMOUNT_SHOULD_BE_GREATER_OR_EQUAL_THAN_ACTUAL_LOCKED); | ||
| } | ||
| } | ||
| } | ||
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,14 @@ | ||
| // SPDX-FileCopyrightText: 2024 Lido <[email protected]> | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
|
|
||
| pragma solidity 0.8.6; | ||
|
|
||
| /// @title Lido's CSM accounting interface | ||
| interface ICSAccounting { | ||
| /// @notice Get amount of the locked bond in ETH (stETH) by the given Node Operator | ||
| /// @param nodeOperatorId ID of the Node Operator | ||
| /// @return Amount of the actual locked bond | ||
| function getActualLockedBond( | ||
| uint256 nodeOperatorId | ||
| ) external view returns (uint256); | ||
| } |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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.