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

Fix Types.shrink() #265

Merged
merged 5 commits into from
Oct 2, 2023
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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- [22d2859](https://github.com/bloxapp/ssv-network/pull/262/commits/22d2859d8fe6267b09c7a1c9c645df19bdaa03ff) Fix bug in network earnings withdrawals.
- [d25d188](https://github.com/bloxapp/ssv-network/pull/265/commits/d25d18886459e631fb4453df7a47db19982ec80e) Fix Types.shrink() bug.

### Added
- [bf0c51d](https://github.com/bloxapp/ssv-network/pull/263/commits/bf0c51d4df191018052d11425c9fcc252de61431) A validator can voluntarily exit.
- [bf0c51d](https://github.com/bloxapp/ssv-network/pull/263/commits/bf0c51d4df191018052d11425c9fcc252de61431) A validator can voluntarily exit.


## [v1.0.0.rc4] - 2023-08-31

- Audit fixes/recommendations
- Validate a cluster with 0 validators can not be liquidated
- Deployment process now uses hardhat tasks
- The DAO can set a maximum operator fee (SSV)
- Remove the setRegisterAuth function (register operator/validator without restrictions)
- SSVNetworkViews contract does not throw an error as a way of return.
2 changes: 1 addition & 1 deletion contracts/libraries/Types.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ library Types64 {

library Types256 {
function shrink(uint256 value) internal pure returns (uint64) {
require(value <= (2 ** 64 * DEDUCTED_DIGITS), "Max value exceeded");
require(value < (2 ** 64 * DEDUCTED_DIGITS), "Max value exceeded");
return uint64(shrinkable(value) / DEDUCTED_DIGITS);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/SSVDAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract SSVDAO is ISSVDAO {
uint64 previousFee = sp.networkFee;

sp.updateNetworkFee(fee);
emit NetworkFeeUpdated(previousFee.expand(), fee);
emit NetworkFeeUpdated(previousFee.expand(), sp.networkFee.expand());
}

function withdrawNetworkEarnings(uint256 amount) external override {
Expand Down
6 changes: 6 additions & 0 deletions test/dao/network-fee-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ describe('Network Fee Tests', () => {
)).to.emit(ssvNetworkContract, 'NetworkFeeUpdated').withArgs(0, networkFee);
});

it('Change network fee providing UINT64 max value reverts "Max value exceeded"', async () => {
const amount = (ethers.BigNumber.from(2).pow(64)).mul(ethers.BigNumber.from(1e8));
await expect(ssvNetworkContract.updateNetworkFee(amount
)).to.be.revertedWith('Max value exceeded');
});

it('Change network fee when it was set emits "NetworkFeeUpdated"', async () => {
const initialNetworkFee = helpers.CONFIG.minimalOperatorFee;
await ssvNetworkContract.updateNetworkFee(initialNetworkFee);
Expand Down
6 changes: 6 additions & 0 deletions test/dao/network-fee-withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ describe('DAO Network Fee Withdraw Tests', () => {
)).to.be.revertedWith('Ownable: caller is not the owner');
});

it('Withdraw network earnings providing UINT64 max value reverts "Max value exceeded"', async () => {
const amount = (ethers.BigNumber.from(2).pow(64)).mul(ethers.BigNumber.from(1e8));
await expect(ssvNetworkContract.withdrawNetworkEarnings(amount
)).to.be.revertedWith('Max value exceeded');
});

it('Withdraw network earnings sequentially when not enough balance reverts "InsufficientBalance"', async () => {
const amount = await ssvViews.getNetworkEarnings() / 2;

Expand Down
Loading