Skip to content

Commit 5e1925c

Browse files
committed
chore: fix extra reporting by CSM
1 parent 426fb06 commit 5e1925c

File tree

11 files changed

+31
-97
lines changed

11 files changed

+31
-97
lines changed

globals.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ declare namespace NodeJS {
1717
/* if "on" the integration tests will deploy the contracts to the empty Hardhat Network node using scratch deploy */
1818
INTEGRATION_ON_SCRATCH?: "on" | "off"; // default: "off"
1919

20+
/* if "on" the integration tests will assume CSM module is present in the StakingRouter, and adjust accordingly */
21+
INTEGRATION_WITH_CSM?: "on" | "off"; // default: "off"
22+
2023
/**
2124
* Network configuration for the protocol discovery.
2225
*/

lib/protocol/context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const getProtocolContext = async (): Promise<ProtocolContext> => {
2626
// By default, all flags are "on"
2727
const flags = {
2828
onScratch: process.env.INTEGRATION_ON_SCRATCH === "on",
29+
withCSM: process.env.INTEGRATION_WITH_CSM !== "off",
2930
} as ProtocolContextFlags;
3031

3132
log.debug("Protocol context flags", {

lib/protocol/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export type Signer = keyof ProtocolSigners;
135135

136136
export type ProtocolContextFlags = {
137137
onScratch: boolean;
138+
withCSM: boolean;
138139
};
139140

140141
export type ProtocolContext = {

lib/scratch.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { resetStateFile } from "./state-file";
99
const deployedSteps: string[] = [];
1010

1111
async function applySteps(steps: string[]) {
12-
1312
if (steps.every((step) => deployedSteps.includes(step))) {
1413
return; // All steps have been deployed
1514
}
@@ -30,10 +29,15 @@ export async function deployUpgrade(networkName: string): Promise<void> {
3029
networkName = "mainnet-fork";
3130
}
3231

33-
const stepsFile = `upgrade/steps-${networkName}.json`;
34-
const steps = loadSteps(stepsFile);
32+
try {
33+
const stepsFile = `upgrade/steps-${networkName}.json`;
34+
const steps = loadSteps(stepsFile);
3535

36-
await applySteps(steps);
36+
await applySteps(steps);
37+
} catch (error) {
38+
log.error("Upgrade failed:", (error as Error).message);
39+
log.warning("Upgrade steps not found, assuming the protocol is already deployed");
40+
}
3741
}
3842

3943
export async function deployScratchProtocol(networkName: string): Promise<void> {

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"test:integration": "hardhat test test/integration/**/*.ts",
2626
"test:integration:trace": "hardhat test test/integration/**/*.ts --trace --disabletracer",
2727
"test:integration:fulltrace": "hardhat test test/integration/**/*.ts --fulltrace --disabletracer",
28-
"test:integration:scratch": "INTEGRATION_WITH_SCRATCH_DEPLOY=on hardhat test test/integration/**/*.ts",
29-
"test:integration:scratch:trace": "INTEGRATION_WITH_SCRATCH_DEPLOY=on hardhat test test/integration/**/*.ts --trace --disabletracer",
30-
"test:integration:scratch:fulltrace": "INTEGRATION_WITH_SCRATCH_DEPLOY=on hardhat test test/integration/**/*.ts --fulltrace --disabletracer",
28+
"test:integration:scratch": "INTEGRATION_WITH_CSM=off INTEGRATION_WITH_SCRATCH_DEPLOY=on hardhat test test/integration/**/*.ts",
29+
"test:integration:scratch:trace": "INTEGRATION_WITH_CSM=off INTEGRATION_WITH_SCRATCH_DEPLOY=on hardhat test test/integration/**/*.ts --trace --disabletracer",
30+
"test:integration:scratch:fulltrace": "INTEGRATION_WITH_CSM=off INTEGRATION_WITH_SCRATCH_DEPLOY=on hardhat test test/integration/**/*.ts --fulltrace --disabletracer",
3131
"test:integration:fork:local": "hardhat test test/integration/**/*.ts --network local",
3232
"test:integration:fork:mainnet": "hardhat test test/integration/**/*.ts --network mainnet-fork",
3333
"typecheck": "tsc --noEmit",

scripts/archive/sr-v2-deploy-holesky.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ethers, run } from "hardhat";
22

3-
import { DepositSecurityModule, DepositSecurityModule__factory } from "typechain-types";
3+
import { DepositSecurityModule } from "typechain-types";
44

55
import {
66
deployImplementation,
@@ -114,10 +114,7 @@ async function main() {
114114

115115
log(`New DSM address: ${depositSecurityModuleAddress}`);
116116

117-
const dsmContract = await loadContract<DepositSecurityModule>(
118-
DepositSecurityModule__factory,
119-
depositSecurityModuleAddress,
120-
);
117+
const dsmContract = await loadContract<DepositSecurityModule>("DepositSecurityModule", depositSecurityModuleAddress);
121118
await dsmContract.addGuardians(guardians, quorum);
122119

123120
await dsmContract.setOwner(APP_AGENT_ADDRESS);

scripts/upgrade/steps-local.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/upgrade/steps-mainnet-fork.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

scripts/upgrade/steps.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"steps": ["upgrade/steps/0000-deploy-locator"]
2+
"steps": []
33
}

scripts/upgrade/steps/mainnet-fork/0010-deploy-negative-rebase-sanity-checker.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

test/integration/accounting.integration.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ethers } from "hardhat";
55
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers";
66
import { setBalance } from "@nomicfoundation/hardhat-network-helpers";
77

8-
import { ether, impersonate, ONE_GWEI, trace, updateBalance } from "lib";
8+
import { ether, impersonate, log, ONE_GWEI, trace, updateBalance } from "lib";
99
import { getProtocolContext, ProtocolContext } from "lib/protocol";
1010
import {
1111
finalizeWithdrawalQueue,
@@ -15,7 +15,7 @@ import {
1515
sdvtEnsureOperators,
1616
} from "lib/protocol/helpers";
1717

18-
import { bailOnFailure, Snapshot } from "test/suite";
18+
import { Snapshot } from "test/suite";
1919

2020
const LIMITER_PRECISION_BASE = BigInt(10 ** 9);
2121

@@ -64,8 +64,6 @@ describe("Accounting", () => {
6464
});
6565
});
6666

67-
beforeEach(bailOnFailure);
68-
6967
beforeEach(async () => (originalState = await Snapshot.take()));
7068

7169
afterEach(async () => await Snapshot.restore(originalState));
@@ -282,6 +280,7 @@ describe("Accounting", () => {
282280

283281
// Report
284282
const params = { clDiff: rebaseAmount, excludeVaultsBalances: true };
283+
285284
const { reportTx } = (await report(ctx, params)) as {
286285
reportTx: TransactionResponse;
287286
extraDataTx: TransactionResponse;
@@ -306,6 +305,8 @@ describe("Accounting", () => {
306305
const stakingModulesCount = await stakingRouter.getStakingModulesCount();
307306
const transferSharesEvents = ctx.getEvents(reportTxReceipt, "TransferShares");
308307

308+
log.debug("Staking modules count", { stakingModulesCount });
309+
309310
const mintedSharesSum = transferSharesEvents
310311
.slice(hasWithdrawals ? 1 : 0) // skip burner if withdrawals processed
311312
.reduce((acc, { args }) => acc + args.sharesValue, 0n);
@@ -317,9 +318,11 @@ describe("Accounting", () => {
317318

318319
// if withdrawals processed goes after burner and NOR, if no withdrawals processed goes after NOR
319320
const sdvtSharesAsFees = transferSharesEvents[hasWithdrawals ? 2 : 1];
321+
const feeDistributionTransfer = ctx.flags.withCSM ? 1n : 0n;
320322

323+
// Magic numbers here: 2 – burner and treasury, 1 – only treasury
321324
expect(transferSharesEvents.length).to.equal(
322-
hasWithdrawals ? 2n : 1n + stakingModulesCount,
325+
(hasWithdrawals ? 2n : 1n) + stakingModulesCount + feeDistributionTransfer,
323326
"Expected transfer of shares to DAO and staking modules",
324327
);
325328

@@ -654,9 +657,10 @@ describe("Accounting", () => {
654657

655658
// if withdrawals processed goes after burner and NOR, if no withdrawals processed goes after NOR
656659
const sdvtSharesAsFees = transferSharesEvents[hasWithdrawals ? 2 : 1];
660+
const feeDistributionTransfer = ctx.flags.withCSM ? 1n : 0n;
657661

658662
expect(transferSharesEvents.length).to.equal(
659-
hasWithdrawals ? 2n : 1n + stakingModulesCount,
663+
hasWithdrawals ? 2n : 1n + stakingModulesCount + feeDistributionTransfer,
660664
"Expected transfer of shares to DAO and staking modules",
661665
);
662666

@@ -754,9 +758,10 @@ describe("Accounting", () => {
754758

755759
// if withdrawals processed goes after burner and NOR, if no withdrawals processed goes after NOR
756760
const sdvtSharesAsFees = transferSharesEvents[hasWithdrawals ? 2 : 1];
761+
const feeDistributionTransfer = ctx.flags.withCSM ? 1n : 0n;
757762

758763
expect(transferSharesEvents.length).to.equal(
759-
hasWithdrawals ? 2n : 1n + stakingModulesCount,
764+
hasWithdrawals ? 2n : 1n + stakingModulesCount + feeDistributionTransfer,
760765
"Expected transfer of shares to DAO and staking modules",
761766
);
762767

0 commit comments

Comments
 (0)