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
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ contract FeeAccumulator is Governable {
Address.sendValue(payable(STRATEGY), eth);
}
}

/**
* @dev Accept ETH
*/
receive() external payable {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract NativeStakingSSVStrategy is
/// executing transactions on the Ethereum network as part of block proposals. They include
/// priority fees (fees paid by users for their transactions to be included) and MEV rewards
/// (rewards for arranging transactions in a way that benefits the validator).
address public immutable FEE_ACCUMULATOR_ADDRESS;
address payable public immutable FEE_ACCUMULATOR_ADDRESS;

// For future use
uint256[50] private __gap;
Expand Down Expand Up @@ -60,7 +60,7 @@ contract NativeStakingSSVStrategy is
)
{
SSV_TOKEN_ADDRESS = _ssvToken;
FEE_ACCUMULATOR_ADDRESS = _feeAccumulator;
FEE_ACCUMULATOR_ADDRESS = payable(_feeAccumulator);
}

/// @notice initialize function, to set up initial internal state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ abstract contract ValidatorAccountant is ValidatorRegistrator {
uint256 public constant MAX_STAKE = 32 ether;

/// @notice Keeps track of the total consensus rewards swept from the beacon chain
uint256 public consensusRewards = 0;
uint256 public consensusRewards;

/// @notice start of fuse interval
uint256 public fuseIntervalStart = 0;
uint256 public fuseIntervalStart;
/// @notice end of fuse interval
uint256 public fuseIntervalEnd = 0;
uint256 public fuseIntervalEnd;

uint256[50] private __gap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ abstract contract ValidatorRegistrator is Governable, Pausable {
// Convert required ETH from WETH
IWETH9(WETH_TOKEN_ADDRESS).withdraw(requiredETH);

uint256 validatorsLength = validators.length;
// For each validator
for (uint256 i = 0; i < validators.length; ) {
for (uint256 i = 0; i < validatorsLength; ) {
bytes32 pubkeyHash = keccak256(validators[i].pubkey);
VALIDATOR_STATE currentState = validatorsStates[pubkeyHash];

Expand Down Expand Up @@ -143,7 +144,6 @@ abstract contract ValidatorRegistrator is Governable, Pausable {
validators[i].depositDataRoot
);

activeDepositedValidators += 1;
emit ETHStaked(
validators[i].pubkey,
32 ether,
Expand All @@ -156,6 +156,8 @@ abstract contract ValidatorRegistrator is Governable, Pausable {
++i;
}
}
// save gas by changing this storage variable only once rather each time in the loop.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice optimization

activeDepositedValidators += validatorsLength;
}

/// @notice Registers a new validator in the SSV Cluster.
Expand Down
27 changes: 27 additions & 0 deletions contracts/deploy/deployActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,32 @@ const deployFraxEthStrategy = async () => {
return cFraxETHStrategy;
};

/**
* upgradeNativeStakingFeeAccumulator
*/
const upgradeNativeStakingFeeAccumulator = async () => {
const { deployerAddr } = await getNamedAccounts();
const sDeployer = await ethers.provider.getSigner(deployerAddr);

const strategyProxy = await ethers.getContract(
"NativeStakingSSVStrategyProxy"
);
const feeAccumulatorProxy = await ethers.getContract(
"NativeStakingFeeAccumulatorProxy"
);

log("Deploy fee accumulator implementation");
const dFeeAccumulatorImpl = await deployWithConfirmation("FeeAccumulator", [
strategyProxy.address, // STRATEGY
]);

await withConfirmation(
feeAccumulatorProxy
.connect(sDeployer)
.upgradeTo(dFeeAccumulatorImpl.address)
);
};

/**
* Upgrade NativeStakingSSVStrategy
*/
Expand Down Expand Up @@ -1538,4 +1564,5 @@ module.exports = {
deployOETHSwapper,
deployOUSDSwapper,
upgradeNativeStakingSSVStrategy,
upgradeNativeStakingFeeAccumulator,
};
25 changes: 25 additions & 0 deletions contracts/deploy/holesky/007_upgrade_strategy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const {
upgradeNativeStakingSSVStrategy,
upgradeNativeStakingFeeAccumulator,
} = require("../deployActions");
const { withConfirmation } = require("../../utils/deploy");

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

console.log("Upgrading native staking fee accumulator");
await upgradeNativeStakingFeeAccumulator();

console.log("Upgrading native staking strategy");
await upgradeNativeStakingSSVStrategy();

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

mainExport.id = "007_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 @@ -4,5 +4,6 @@
"003_deposit_to_native_strategy": 1714307581,
"004_upgrade_strategy": 1714944723,
"005_deploy_new_harvester": 1714998707,
"006_update_registrator": 1715184342
"006_update_registrator": 1715184342,
"007_upgrade_strategy": 1715251466
}
46 changes: 25 additions & 21 deletions contracts/deployments/holesky/FeeAccumulator.json

Large diffs are not rendered by default.

94 changes: 47 additions & 47 deletions contracts/deployments/holesky/NativeStakingSSVStrategy.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion contracts/test/behaviour/ssvStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,12 @@ const shouldBehaveLikeAnSsvStrategy = (context) => {

// add some ETH to the FeeAccumulator to simulate execution rewards
const executionRewards = parseEther("7");
await setBalance(nativeStakingFeeAccumulator.address, executionRewards);
//await setBalance(nativeStakingFeeAccumulator.address, executionRewards);
await josh.sendTransaction({
to: nativeStakingFeeAccumulator.address,
value: executionRewards,
});

// simulate consensus rewards
const consensusRewards = parseEther("5");
await setBalance(nativeStakingSSVStrategy.address, consensusRewards);
Expand Down