Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions contracts/contracts/interfaces/ISSVNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ interface ISSVNetwork {
function exitValidator(bytes memory publicKey, uint64[] memory operatorIds)
external;

function bulkExitValidator(
bytes[] calldata publicKeys,
uint64[] calldata operatorIds
) external;

function getVersion() external pure returns (string memory version);

function initialize(
Expand Down Expand Up @@ -216,6 +221,14 @@ interface ISSVNetwork {
Cluster memory cluster
) external;

function bulkRegisterValidator(
bytes[] calldata publicKeys,
uint64[] calldata operatorIds,
bytes[] calldata sharesData,
uint256 amount,
Cluster memory cluster
) external;

function removeOperator(uint64 operatorId) external;

function removeValidator(
Expand All @@ -224,6 +237,12 @@ interface ISSVNetwork {
Cluster memory cluster
) external;

function bulkRemoveValidator(
bytes[] calldata publicKeys,
uint64[] calldata operatorIds,
Cluster memory cluster
) external;

function renounceOwnership() external;

function setFeeRecipientAddress(address recipientAddress) external;
Expand Down
8 changes: 8 additions & 0 deletions contracts/contracts/mocks/MockSSVNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ contract MockSSVNetwork {
Cluster memory cluster
) external {}

function bulkRegisterValidator(
bytes[] calldata publicKeys,
uint64[] calldata operatorIds,
bytes[] calldata sharesData,
uint256 amount,
Cluster memory cluster
) external {}

function exitValidator(
bytes calldata publicKey,
uint64[] calldata operatorIds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,36 +225,46 @@ abstract contract ValidatorRegistrator is Governable, Pausable {

/// @notice Registers a new validator in the SSV Cluster.
/// Only the registrator can call this function.
/// @param publicKey The public key of the validator
/// @param publicKeys The public keys of the validators
/// @param operatorIds The operator IDs of the SSV Cluster
/// @param sharesData The validator shares data
/// @param sharesData The shares data for each validator
/// @param ssvAmount The amount of SSV tokens to be deposited to the SSV cluster
/// @param cluster The SSV cluster details including the validator count and SSV balance
// slither-disable-start reentrancy-no-eth
function registerSsvValidator(
bytes calldata publicKey,
function registerSsvValidators(
bytes[] calldata publicKeys,
uint64[] calldata operatorIds,
bytes calldata sharesData,
bytes[] calldata sharesData,
uint256 ssvAmount,
Cluster calldata cluster
) external onlyRegistrator whenNotPaused {
bytes32 pubKeyHash = keccak256(publicKey);
VALIDATOR_STATE currentState = validatorsStates[pubKeyHash];
require(
currentState == VALIDATOR_STATE.NON_REGISTERED,
"Validator already registered"
publicKeys.length == sharesData.length,
"Pubkey sharesData mismatch"
);
ISSVNetwork(SSV_NETWORK).registerValidator(
publicKey,
// Check each public key has not already been used
bytes32 pubKeyHash;
VALIDATOR_STATE currentState;
for (uint256 i = 0; i < publicKeys.length; ++i) {
pubKeyHash = keccak256(publicKeys[i]);
currentState = validatorsStates[pubKeyHash];
require(
currentState == VALIDATOR_STATE.NON_REGISTERED,
"Validator already registered"
);

validatorsStates[pubKeyHash] = VALIDATOR_STATE.REGISTERED;

emit SSVValidatorRegistered(pubKeyHash, publicKeys[i], operatorIds);
}

ISSVNetwork(SSV_NETWORK).bulkRegisterValidator(
publicKeys,
operatorIds,
sharesData,
ssvAmount,
cluster
);

validatorsStates[pubKeyHash] = VALIDATOR_STATE.REGISTERED;

emit SSVValidatorRegistered(pubKeyHash, publicKey, operatorIds);
}

// slither-disable-end reentrancy-no-eth
Expand Down
17 changes: 17 additions & 0 deletions contracts/deploy/holesky/014_upgrade_strategy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { upgradeNativeStakingSSVStrategy } = require("../deployActions");

const mainExport = async () => {
console.log("Running 014 deployment on Holesky...");

await upgradeNativeStakingSSVStrategy();

console.log("Running 014 deployment done");
return true;
};

mainExport.id = "014_upgrade_strategy";
mainExport.tags = [];
mainExport.dependencies = [];
mainExport.skip = () => false;

module.exports = mainExport;
3 changes: 2 additions & 1 deletion contracts/deployments/holesky/.migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"010_upgrade_strategy": 1716890877,
"011_upgrade_strategy": 1717309951,
"012_upgrade_strategy": 1717477122,
"013_upgrade_strategy": 1717803989
"013_upgrade_strategy": 1717803989,
"014_upgrade_strategy": 1717806940
}
122 changes: 61 additions & 61 deletions contracts/deployments/holesky/NativeStakingSSVStrategy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file added contracts/docs/plantuml/oethProcesses-admin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed contracts/docs/plantuml/oethProcesses-pause.png
Binary file not shown.
Binary file modified contracts/docs/plantuml/oethProcesses-register.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified contracts/docs/plantuml/oethProcesses.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions contracts/docs/plantuml/oethProcesses.puml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ group Governor sets staked ETH threshold

gov -> nativeStrat : setStakeETHThreshold()
activate nativeStrat
note right: set ETH that can be staked before the staking monitor has to reset
note right: set ETH that can be staked\nbefore the staking monitor has to reset
return

end group
Expand All @@ -62,7 +62,7 @@ group Staking monitor resets staked ETH

admin -> nativeStrat : resetStakeETHTally()
activate nativeStrat
note right: resets the ETH that can be staked going forward
note right: resets the ETH that\ncan be staked going forward
return

end group
Expand All @@ -88,7 +88,7 @@ activate api
return status,\npubkey\nvalidatorRegistration,\nshareData
note right : validatorRegistration contains the operatorIds and cluster details

reg -> nativeStrat : registerSsvValidator(\npublicKey,\noperatorIds,\nsharesData,\namount,\ncluster)
reg -> nativeStrat : registerSsvValidators(\npublicKeys[],\noperatorIds,\nsharesData[],\namount,\ncluster)
activate nativeStrat
note right
cluster data:
Expand All @@ -98,7 +98,7 @@ The last index calculated for the cluster
Flag indicating whether the cluster is active
The SSV balance of the cluster
end note
nativeStrat -> ssvNet : registerValidator(\npublicKey,\noperatorIds,\nsharesData,\namount,\ncluster)
nativeStrat -> ssvNet : bulkRegisterValidator(\npublicKeys[],\noperatorIds,\nsharesData[],\namount,\ncluster)
activate ssvNet
ssvNet -> ssv : transferFrom(\nfrom\nto\namount)
activate ssv
Expand Down
30 changes: 29 additions & 1 deletion contracts/tasks/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const {
setStakeETHThreshold,
fixAccounting,
pauseStaking,
snapStaking,
} = require("./validator");
const { harvestAndSwap } = require("./harvest");

Expand Down Expand Up @@ -1031,7 +1032,13 @@ subtask(
.addOptionalParam(
"days",
"SSV Cluster operational time in days",
40,
2,
types.int
)
.addOptionalParam(
"validators",
"The number of validators to register. defaults to the max that can be registered",
undefined,
types.int
)
.addOptionalParam("clear", "Clear storage", false, types.boolean)
Expand Down Expand Up @@ -1170,6 +1177,27 @@ task("pauseStaking").setAction(async (_, __, runSuper) => {
return runSuper();
});

subtask(
"snapStaking",
"Takes a snapshot of the key Native Staking Strategy data at a block"
)
.addOptionalParam(
"block",
"Block number. (default: latest)",
undefined,
types.int
)
.addOptionalParam(
"admin",
"Include addresses of admin accounts",
true,
types.boolean
)
.setAction(snapStaking);
task("snapStaking").setAction(async (_, __, runSuper) => {
return runSuper();
});

// Encryption

subtask("genECDHKey", "Generate Elliptic-curve Diffie–Hellman (ECDH) key pair")
Expand Down
Loading