Skip to content

Commit

Permalink
Added fork tests for second strategy
Browse files Browse the repository at this point in the history
Added index to depositRoot Hardhat task
  • Loading branch information
naddison36 committed Jul 11, 2024
1 parent f993ca4 commit ef0f1ea
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 4 deletions.
12 changes: 10 additions & 2 deletions contracts/tasks/ssv.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,28 @@ const depositSSV = async ({ amount, index, operatorids }) => {
await logTxDetails(tx, "depositSSV");
};

const calcDepositRoot = async ({ pubkey, sig }, hre) => {
const calcDepositRoot = async ({ index, pubkey, sig }, hre) => {
if (hre.network.name !== "hardhat") {
throw new Error("This task can only be run in hardhat network");
}

const factory = await ethers.getContractFactory("DepositContractUtils");
const depositContractUtils = await factory.deploy();

const proxyNumber =
index === undefined || index === 1 ? "" : index.toString();
const strategyAddress =
addresses.mainnet[`NativeStakingSSVStrategy${proxyNumber}Proxy`];
log(
`Resolved Native Staking Strategy with index ${index} to address to ${strategyAddress}`
);

const withdrawalCredentials = solidityPack(
["bytes1", "bytes11", "address"],
[
"0x01",
"0x0000000000000000000000",
addresses.mainnet.NativeStakingSSVStrategyProxy,
addresses.mainnet[`NativeStakingSSVStrategy${proxyNumber}Proxy`],
]
);
log(`Withdrawal Credentials: ${withdrawalCredentials}`);
Expand Down
6 changes: 6 additions & 0 deletions contracts/tasks/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,12 @@ subtask(
undefined,
types.string
)
.addOptionalParam(
"index",
"The number of the Native Staking Contract deployed.",
undefined,
types.int
)
.setAction(calcDepositRoot);
task("depositRoot").setAction(async (_, __, runSuper) => {
return runSuper();
Expand Down
3 changes: 2 additions & 1 deletion contracts/tasks/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ async function snapStaking({ block, admin, index }) {
}

const resolveNativeStakingStrategyProxy = async (index) => {
const proxyNumber = index === undefined ? "" : index.toString();
const proxyNumber =
index === undefined || index === 1 ? "" : index.toString();

const strategy = await resolveContract(
`NativeStakingSSVStrategy${proxyNumber}Proxy`,
Expand Down
57 changes: 56 additions & 1 deletion contracts/test/strategies/nativeSsvStaking.mainnet.fork-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,31 @@ const {
const addresses = require("../../utils/addresses");
const loadFixture = createFixtureLoader(nativeStakingSSVStrategyFixture);
const { shouldBehaveLikeAnSsvStrategy } = require("../behaviour/ssvStrategy");
const { resolveContract } = require("../../utils/resolvers");

describe("ForkTest: Native SSV Staking Strategy", function () {
describe("ForkTest: First Native SSV Staking Strategy", function () {
this.timeout(0);

let fixture;
let nativeStakingSSVStrategy;
let nativeStakingFeeAccumulator;
beforeEach(async () => {
fixture = await loadFixture();
nativeStakingSSVStrategy = await resolveContract(
"NativeStakingSSVStrategyProxy",
"NativeStakingSSVStrategy"
);
nativeStakingFeeAccumulator = await resolveContract(
"NativeStakingFeeAccumulatorProxy",
"FeeAccumulator"
);
});

shouldBehaveLikeAnSsvStrategy(async () => {
return {
...fixture,
nativeStakingSSVStrategy,
nativeStakingFeeAccumulator,
addresses: addresses.mainnet,
testValidator: {
publicKey:
Expand All @@ -33,3 +46,45 @@ describe("ForkTest: Native SSV Staking Strategy", function () {
};
});
});

describe("ForkTest: Second Native SSV Staking Strategy", function () {
this.timeout(0);

let fixture;
let nativeStakingSSVStrategy;
let nativeStakingFeeAccumulator;
beforeEach(async () => {
fixture = await loadFixture();
nativeStakingSSVStrategy = await resolveContract(
"NativeStakingSSVStrategy2Proxy",
"NativeStakingSSVStrategy2"
);
nativeStakingFeeAccumulator = await resolveContract(
"NativeStakingFeeAccumulator2Proxy",
"FeeAccumulator2"
);
});

shouldBehaveLikeAnSsvStrategy(async () => {
return {
...fixture,
nativeStakingSSVStrategy,
nativeStakingFeeAccumulator,
addresses: addresses.mainnet,
// TODO change to new SSV cluster when ready
testValidator: {
publicKey:
"0xae24289bd670bfbdd3bc904596b475d080dde3415506f1abe1fb76ff292ff6bd743d710061b9e2b16fd8541a76fe53ee",
operatorIds: [348, 352, 361, 377],
sharesData:
"0xb2cff426a8898f801feed0e3efb1d036def14590809426995df98ad243c0927987c0f207a3c2d9b48d47a0ceec80eb2d0b1839d84ab1a2d75fd48aaf4a859ab8d2ae776b55f64e2c40733a44697c924882a5a8688790ec4203b8847a61e84803a8252f2a2812ec9854b381fc12a222ea8764e07084c8a7873426f62a43ca1b88dfa258713a5ff7749290add650843533a5b2a8430c1cf5e476d5498736b384464db057b05f8a120c4a08b84dfb8a9c2c6adfdcb5660386cd582c610eb06422628dfc08496bf0edfffc6e1e05964c710a104ed6c2d700c823243fce8a3c76575ca1618113e036498f839830c5d24d604ab13769367f9467b8f3771082a29a8ce96194da370a0550ce5d09975590ba5e1fa154382ba0bc2d7ebd7fd2192978998d53d845103bbfa2f8f3680245b005bc802109ea6a8449fce0fffcfa712cc8bbf6672eda7bbfd209644190a1c383faac861aad1534f50acd7c58104c4ad27e0b6d4b44c80e52ede1b0f066cae285e193f356f193872d40586020c75a68c011d2ca172126139d1728985c9ca9b76db5639ec0d265b9bf239ad3ed94a55709442031b18db6fd430b25138b1d7a17484cde1433e8d5837c3c806630135187d27261991e94f84d3ceb1fc2eaa44042cc09f10cea84b0ef6a00cb07aebdd7df6a4e14fd6efce5954d19219efd3419c338a6fa9644db5fdeb5b226cc008c0599f0c02bf3c99c74ff80e5ea2c2d0e47304ee21dfdf870599288dedd0977711af5cc467179765df58b0a489c906d85f5855c1d7359cab73e22229f354d9f9e0a1e623d9264988df14da8b710dfe42a895cbdc10ac25bd0d3412e9c90a632c8f1890b3d412bf6756367893f800b8895f000645fb56bf1b956cca68ee19238e64047b4b75be13c0316c5a220af0e28f0d9948fd74b7e261cddb0e79f80349686a0089a9d50baa79bdccd4ac9392ec857530456a9f7302ca091a640feb4a6f1c31c1c6fd1847e20986d2e87f84a01522d3004ddf002c56d5e9549eca04ce3738b8bc5a7e239c967906305d820f6a3b8f1f6a61af7fcdfabd935d068f8cd0cc58c84dc120ef20df1ea492c70937282a9e5a0857511ab7c6d6300947da3f0f7fa4d022453163c1d82e78b15182d9a2878fb96ba0f08a71288772249f52a34dff4b7ae106bb76055e05309c4701abdf685d68163d0a705b162e91c409c7d8c386dc24f2d7c01c150017b365c6d72304f082d4030057917fb55a927ed5a6150e9e70a8b12cfadca1bfba0e85f694c946ef781fb8344285c28adc2e358513ed9ec2a1fb80935de88ec2cdac6e0d538e25043716ec8b29c157fb41a3d887c2025ffc71b414b977f9b81c497ee8bd9db042d4121dc4a8c5220a0f438dbdcde55580fb8c8b3aec3a53ffe958056653fd9bf58aa3b060a99c38c94035a27a6bfd66767965090526f1f403f7332914d2726d2f2bdd979895031a1afad4e112d4471193080e13a301e7a6ad24a217d94a5c964a6118dbcc9b2dfd3a0180189c0ca4dee3e8d24a18b904e826e324256d478deb66b9b47cdb65de2a2b951787dad3536a839b230313d6fd202364a8a3a0ce033fb8bf6a32d4b7c94af54f5ca7d861497d50a593606437f7420485ccda17977eb495967f700ef4bcc9f8d2c2ed4933b26418768b31ae02a0ca2fbaa7b63f349619278bac3f3ef5796c669c3ecb9ed19f2ffa453b4801f4ac78938a11c8e7a778a7ae8e5813dd93414b1b9912e4466519216ac58a6b538d03128feee6235adef2ecc57d9b2d9fec719fb8c8aac0bd7f491860658e8f32ee6285c264c843c6142d578abfc9bab330355bed41a12862669f0b88f894cce277bcdbd94",
// This sig isn't correct but will do for testing
signature:
"0x90157a1c1b26384f0b4d41bec867d1a000f75e7b634ac7c4c6d8dfc0b0eaeb73bcc99586333d42df98c6b0a8c5ef0d8d071c68991afcd8fbbaa8b423e3632ee4fe0782bc03178a30a8bc6261f64f84a6c833fb96a0f29de1c34ede42c4a859b0",
// Calculated from npx hardhat depositRoot
depositDataRoot:
"0x6f9cc503009ceb0960637bbf2482b19a62153144ab091f0b9f66d5800f02cc2c",
},
};
});
});

0 comments on commit ef0f1ea

Please sign in to comment.