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

P2P API changes #2084

Merged
merged 14 commits into from
Jun 2, 2024
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ contracts/coverage.json
contracts/build/
contracts/dist/
contracts/.localKeyValueStorage
contracts/.localKeyValueStorageMainnet
contracts/.localKeyValueStorageHolesky
contracts/.localKeyValueStorage.mainnet
contracts/.localKeyValueStorage.holesky
contracts/scripts/defender-actions/dist/

todo.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,17 @@ 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 operatorIds The operator IDs of the SSV Cluster
/// @param sharesData The validator shares data
/// @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,
uint64[] calldata operatorIds,
bytes calldata sharesData,
uint256 amount,
uint256 ssvAmount,
Cluster calldata cluster
) external onlyRegistrator whenNotPaused {
bytes32 pubKeyHash = keccak256(publicKey);
Expand All @@ -243,7 +248,7 @@ abstract contract ValidatorRegistrator is Governable, Pausable {
publicKey,
operatorIds,
sharesData,
amount,
ssvAmount,
cluster
);
emit SSVValidatorRegistered(pubKeyHash, publicKey, operatorIds);
Expand All @@ -256,6 +261,8 @@ abstract contract ValidatorRegistrator is Governable, Pausable {
/// @notice Exit a validator from the Beacon chain.
/// The staked ETH will eventually swept to this native staking strategy.
/// Only the registrator can call this function.
/// @param publicKey The public key of the validator
/// @param operatorIds The operator IDs of the SSV Cluster
// slither-disable-start reentrancy-no-eth
function exitSsvValidator(
bytes calldata publicKey,
Expand All @@ -277,6 +284,9 @@ abstract contract ValidatorRegistrator is Governable, Pausable {
/// Make sure `exitSsvValidator` is called before and the validate has exited the Beacon chain.
/// If removed before the validator has exited the beacon chain will result in the validator being slashed.
/// Only the registrator can call this function.
/// @param publicKey The public key of the validator
/// @param operatorIds The operator IDs of the SSV Cluster
/// @param cluster The SSV cluster details including the validator count and SSV balance
// slither-disable-start reentrancy-no-eth
function removeSsvValidator(
bytes calldata publicKey,
Expand Down Expand Up @@ -306,16 +316,18 @@ abstract contract ValidatorRegistrator is Governable, Pausable {
/// @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.
/// @param operatorIds The operator IDs of the SSV Cluster
/// @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
function depositSSV(
uint64[] memory operatorIds,
uint256 amount,
uint256 ssvAmount,
Cluster memory cluster
) external onlyStrategist {
ISSVNetwork(SSV_NETWORK_ADDRESS).deposit(
address(this),
operatorIds,
amount,
ssvAmount,
cluster
);
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/docs/NativeStakingSSVStrategySquashed.svg
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-register.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 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.
17 changes: 14 additions & 3 deletions contracts/docs/plantuml/oethProcesses.puml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ api -> api: split(key)
note right : splits validator key into multiple KeyShares
return

reg -> api: status(uuid)
reg -> api: GET\neth/staking/ssv/request/status/uuid
activate api
return status,\nvalidatorRegistration,\nshareData
note right : validatorRegistration contains the pubkey, operatorIds and cluster details
return status,\npubkey\nvalidatorRegistration,\nshareData
note right : validatorRegistration contains the operatorIds and cluster details

reg -> nativeStrat : registerSsvValidator(\npublicKey,\noperatorIds,\nsharesData,\namount,\ncluster)
activate nativeStrat
Expand All @@ -107,6 +107,17 @@ return
return
return

end group

... 60 minutes ...

group Registrator stakes to a new SSV validator

reg -> api: GET\neth/staking/ssv/request/deposit-data/uuid
activate api
return status,\ndepositData
note right : depositData contains the signature and depositDataRoot

reg -> nativeStrat : stakeEth([\npubkey,\nsignature,\ndepositDataRoot])
activate nativeStrat
nativeStrat -> nativeStrat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
const {
KeyValueStoreClient,
} = require("@openzeppelin/defender-kvstore-client");
const { operateValidators } = require("../../tasks/validator");
const { registerValidators } = require("../../tasks/validator");
const addresses = require("../../utils/addresses");

const nativeStakingStrategyAbi = require("../../abi/native_staking_SSV_strategy.json");
Expand Down Expand Up @@ -83,7 +83,7 @@ const handler = async (event) => {
clear: true,
};

await operateValidators({
await registerValidators({
signer,
contracts,
store,
Expand Down
20 changes: 16 additions & 4 deletions contracts/scripts/defender-actions/rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const json = require("@rollup/plugin-json");
const builtins = require("builtin-modules");

const commonConfig = {
plugins: [resolve({ preferBuiltins: true, exportConditions: ["node"] }), commonjs(), json({ compact: true })],
plugins: [
resolve({ preferBuiltins: true, exportConditions: ["node"] }),
commonjs(),
json({ compact: true }),
],
// Do not bundle these packages.
// ethers is required to be bundled even though its an Autotask package.
external: [
Expand All @@ -25,10 +29,18 @@ const commonConfig = {
module.exports = [
{
...commonConfig,
input: "operateValidators.js",
input: "registerValidators.js",
output: {
file: "dist/registerValidators/index.js",
format: "cjs",
},
},
{
...commonConfig,
input: "stakeValidators.js",
output: {
file: "dist/operateValidators/index.js",
file: "dist/stakeValidators/index.js",
format: "cjs",
},
}
},
];
Loading