Skip to content
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

feat/add SSV Pool #205

Open
wants to merge 4 commits into
base: mainnet_V0
Choose a base branch
from
Open

feat/add SSV Pool #205

wants to merge 4 commits into from

Conversation

sanjay-staderlabs
Copy link
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++) {

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

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
}

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

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

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

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

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; ) {

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++) {

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