Skip to content

feat/add SSV Pool#205

Open
sanjay-staderlabs wants to merge 4 commits intomainnet_V0from
feat/ssv-pool
Open

feat/add SSV Pool#205
sanjay-staderlabs wants to merge 4 commits intomainnet_V0from
feat/ssv-pool

Conversation

@sanjay-staderlabs
Copy link
Copy Markdown
Contributor

Adding new SSV Pool under DVT section, following are the big changes

  • SSV Node Registry contract similar to the existing pool having functionality of registering and removing validator with SSV Network
  • SSV Pool contract to make beacon chain deposit work like permissioned Pool
  • New vault proxy - SSVVaultProxy, as we don't need all the inputs of current vaultProxy
  • New vaultImplementation - different calculation for reward and settlement as now 4 operators per validator
  • Changes in SDCollateral to slash SD
  • Changes in insurance fund to reimburse user 1 ETH in case of front running or invalid signature
  • Changes in StaderConfig to add SSV related contracts

}
isPoolThresholdValid(_poolId);
uint256 sdToSlash = convertETHToSD(poolThresholdbyPoolId[_poolId].minThreshold);
for (uint8 i; i < operatorIds.length; i++) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gas optimization: use uint256 for i instead of uint8. use temporary variable for operatorIds.length and use it.

Suggested change
for (uint8 i; i < operatorIds.length; i++) {
uint256 numOperatorIds = operatorIds.length;
for (uint256 i; i < numOperatorIds; ++i) {

if you don't much care about the readability, you can move ++i to the end of the loop and put it to unchecked block.

import '../../../library/ValidatorStatus.sol';

struct SSVOperator {
bool operatorType; // 0 for permissionless and 1 for permissioned
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: true or false instead of 1 or 0.

Comment on lines +8 to +16
struct SSVOperator {
bool operatorType; // 0 for permissionless and 1 for permissioned
string operatorName; // name of the operator
address payable operatorRewardAddress; //Eth1 address of node for reward
address operatorAddress; // address of operator to interact with stader
uint64 operatorSSVID; // operator ID on SSV Network
uint64 keyShareCount; // count of key-share operator is running
uint256 bondAmount; // amount of ETH bond for new key shares
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct SSVOperator {
bool operatorType; // 0 for permissionless and 1 for permissioned
string operatorName; // name of the operator
address payable operatorRewardAddress; //Eth1 address of node for reward
address operatorAddress; // address of operator to interact with stader
uint64 operatorSSVID; // operator ID on SSV Network
uint64 keyShareCount; // count of key-share operator is running
uint256 bondAmount; // amount of ETH bond for new key shares
}
/// @param operatorType false for permissionless and true for permissioned
/// @param operatorName Name of the operator
/// @param operatorRewardAddress Eth1 address of node for reward
/// @param operatorAddress Address of operator to interact with stader
/// @param operatorSSVID Operator ID on SSV Network
/// @param keyShareCount Count of key-share operator is running
/// @param bondAmount Amount of ETH bond for new key shares
struct SSVOperator {
bool operatorType;
string operatorName;
address payable operatorRewardAddress;
address operatorAddress;
uint64 operatorSSVID;
uint64 keyShareCount;
uint256 bondAmount;
}

struct SSVOperator {
bool operatorType; // 0 for permissionless and 1 for permissioned
string operatorName; // name of the operator
address payable operatorRewardAddress; //Eth1 address of node for reward
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missed space


function fullDepositOnBeaconChain(bytes[] calldata _pubkey) external;

//Getters
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missed space

event UpdatedOwner(address owner);
event UpdatedStaderConfig(address staderConfig);

//Getters
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missed space


function staderConfig() external view returns (IStaderConfig);

//Setters
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missed space

// Distribute rewards
uint64[] memory operatorIds = nodeRegistry.getOperatorsIdsForValidatorId(validatorId);
uint256 totalOperators = operatorIds.length;
for (uint8 i; i < totalOperators; ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gas optimization: use uint256 instead of uint8 for i

IPenalty(staderConfig.getPenaltyContract()).markValidatorSettled(poolId, validatorId);
IStaderStakePoolManager(staderConfig.getStakePoolManager()).receiveWithdrawVaultUserShare{value: userShare}();
UtilLib.sendValue(payable(staderConfig.getStaderTreasury()), protocolShare);
for (uint8 i; i < totalOperators; i++) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gas optimization: same here, uint256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants