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
5 changes: 1 addition & 4 deletions contracts/deploy/deployActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ const {
isMainnetOrFork,
isHolesky,
} = require("../test/helpers.js");
const {
deployWithConfirmation,
withConfirmation,
} = require("../utils/deploy");
const { deployWithConfirmation, withConfirmation } = require("../utils/deploy");
const {
metapoolLPCRVPid,
lusdMetapoolLPCRVPid,
Expand Down
83 changes: 83 additions & 0 deletions contracts/tasks/ssv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
const { ClusterScanner, NonceScanner } = require("ssv-scanner");
const log = require("../utils/logger")("task:ssv");

const getClusterInfo = async ({
ownerAddress,
operatorids,
chainId,
ssvNetwork,
}) => {
const operatorIds = operatorids.split(".").map((id) => parseInt(id));

const ssvNetworkName = chainId === 1 ? "MAINNET" : "PRATER";
const providerUrl =
chainId === 1 ? process.env.PROVIDER_URL : process.env.HOLESKY_PROVIDER_URL;

const params = {
nodeUrl: providerUrl, // this can be an Infura, or Alchemy node, necessary to query the blockchain
contractAddress: ssvNetwork, // this is the address of SSV smart contract
ownerAddress, // this is the wallet address of the cluster owner
/* Based on the network they fetch contract ABIs. See code: https://github.com/bloxapp/ssv-scanner/blob/v1.0.3/src/lib/contract.provider.ts#L16-L22
* and the ABIs are fetched from here: https://github.com/bloxapp/ssv-scanner/tree/v1.0.3/src/shared/abi
*
* Prater seems to work for Goerli at the moment
*/
network: ssvNetworkName,
operatorIds: operatorIds, // this is a list of operator IDs chosen by the owner for their cluster
};

// ClusterScanner is initialized with the given parameters
const clusterScanner = new ClusterScanner(params);
// and when run, it returns the Cluster Snapshot
const result = await clusterScanner.run(params.operatorIds);
const cluster = {
block: result.payload.Block,
snapshot: result.cluster,
cluster: Object.values(result.cluster),
};
log(`Cluster info ${JSON.stringify(cluster)}`);
return cluster;
};

const getClusterNonce = async ({
ownerAddress,
operatorids,
chainId,
ssvNetwork,
}) => {
const operatorIds = operatorids.split(".").map((id) => parseInt(id));

const ssvNetworkName = chainId === 1 ? "MAINNET" : "PRATER";
const providerUrl =
chainId === 1 ? process.env.PROVIDER_URL : process.env.HOLESKY_PROVIDER_URL;

const params = {
nodeUrl: providerUrl, // this can be an Infura, or Alchemy node, necessary to query the blockchain
contractAddress: ssvNetwork, // this is the address of SSV smart contract
ownerAddress, // this is the wallet address of the cluster owner
/* Based on the network they fetch contract ABIs. See code: https://github.com/bloxapp/ssv-scanner/blob/v1.0.3/src/lib/contract.provider.ts#L16-L22
* and the ABIs are fetched from here: https://github.com/bloxapp/ssv-scanner/tree/v1.0.3/src/shared/abi
*
* Prater seems to work for Goerli at the moment
*/
network: ssvNetworkName,
operatorIds: operatorIds, // this is a list of operator IDs chosen by the owner for their cluster
};

const nonceScanner = new NonceScanner(params);
const nextNonce = await nonceScanner.run();
return nextNonce;
};

const printClusterInfo = async (options) => {
const cluster = await getClusterInfo(options);
const nextNonce = await getClusterNonce(options);
console.log(`block ${cluster.block}`);
console.log(`Cluster: ${JSON.stringify(cluster.snapshot, null, " ")}`);
console.log("Next Nonce:", nextNonce);
};

module.exports = {
printClusterInfo,
getClusterInfo,
};
37 changes: 36 additions & 1 deletion contracts/tasks/tasks.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const { subtask, task, types } = require("hardhat/config");

const { fund } = require("./account");
const { debug } = require("./debug");
const { env } = require("./env");
const { execute, executeOnFork, proposal, governors } = require("./governance");
const { smokeTest, smokeTestCheck } = require("./smokeTest");
const addresses = require("../utils/addresses");
const { networkMap } = require("../utils/hardhat-helpers");

const {
storeStorageLayoutForAllContracts,
assertStorageLayoutChangeSafe,
Expand Down Expand Up @@ -46,13 +48,15 @@ const {
curveSwapTask,
curvePoolTask,
} = require("./curve");
const { printClusterInfo } = require("./ssv");
const {
amoStrategyTask,
mintAndAddOTokensTask,
removeAndBurnOTokensTask,
removeOnlyAssetsTask,
} = require("./amoStrategy");
const { proxyUpgrades } = require("./proxy");
const log = require("../utils/logger")("tasks");

// Environment tasks.
task("env", "Check env vars are properly set for a Mainnet deployment", env);
Expand Down Expand Up @@ -739,3 +743,34 @@ task("proxyUpgrades", "Lists all proxy implementation changes")
types.int
)
.setAction(proxyUpgrades);

subtask("getClusterInfo", "Print out information regarding SSV cluster")
.addParam(
"operatorids",
"4 operator ids separated with a dot: same as IP format. E.g. 60.79.220.349",
"",
types.string
)
.addParam(
"owner",
"Address of the cluster owner. Default to NodeDelegator",
undefined,
types.string
)
.setAction(async (taskArgs) => {
const network = await ethers.provider.getNetwork();
const ssvNetwork = addresses[networkMap[network.chainId]].SSVNetwork;

log(
`Fetching cluster info for cluster owner ${taskArgs.owner} with operator ids: ${taskArgs.operatorids} from the ${network.name} network using ssvNetworkContract ${ssvNetwork}`
);
await printClusterInfo({
...taskArgs,
ownerAddress: taskArgs.owner,
chainId: network.chainId,
ssvNetwork,
});
});
task("getClusterInfo").setAction(async (_, __, runSuper) => {
return runSuper();
});
8 changes: 8 additions & 0 deletions contracts/utils/hardhat-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ const getHardhatNetworkProperties = () => {
return { chainId, provider };
};

const networkMap = {
1: "mainnet",
17000: "holesky",
42161: "arbitrumOne",
1337: "hardhat",
};

module.exports = {
isFork,
isArbitrumFork,
Expand All @@ -123,4 +130,5 @@ module.exports = {
holeskyProviderUrl,
adjustTheForkBlockNumber,
getHardhatNetworkProperties,
networkMap,
};