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

Update Oracle Storage Layout #256

Merged
merged 11 commits into from
May 16, 2024
25 changes: 16 additions & 9 deletions src/PufferOracleV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { IGuardianModule } from "puffer/interface/IGuardianModule.sol";
import { IPufferOracleV2 } from "puffer/interface/IPufferOracleV2.sol";
import { IPufferOracle } from "pufETH/interface/IPufferOracle.sol";

Check warning on line 6 in src/PufferOracleV2.sol

View workflow job for this annotation

GitHub Actions / solhint

imported name IPufferOracle is not used
import { AccessManaged } from "@openzeppelin/contracts/access/manager/AccessManaged.sol";

/**
Expand Down Expand Up @@ -31,22 +31,22 @@
* @dev Number of active Puffer validators
* Slot 0
*/
uint64 internal _numberOfActivePufferValidators;
uint256 internal _numberOfActivePufferValidators;

/**
* @dev Total number of Validators
* Slot 0
* Slot 1
*/
uint64 internal _totalNumberOfValidators;
uint256 internal _totalNumberOfValidators;
/**
* @dev Epoch number of the update
* Slot 0
* Slot 2
*/
uint64 internal _epochNumber;
uint256 internal _epochNumber;

/**
* @dev Price in wei to mint one Validator Ticket
* Slot 1
* Slot 3
*/
uint256 internal _validatorTicketPrice;

Expand All @@ -65,7 +65,7 @@
* @dev Restricted to PufferProtocol contract
*/
function exitValidators(uint256 numberOfExits) public restricted {
_numberOfActivePufferValidators -= uint64(numberOfExits);
_numberOfActivePufferValidators -= numberOfExits;
emit NumberOfActiveValidators(_numberOfActivePufferValidators);
}

Expand Down Expand Up @@ -105,8 +105,8 @@
}
GUARDIAN_MODULE.validateTotalNumberOfValidators(newTotalNumberOfValidators, epochNumber, guardianEOASignatures);
emit TotalNumberOfValidatorsUpdated(_totalNumberOfValidators, newTotalNumberOfValidators, epochNumber);
_totalNumberOfValidators = uint64(newTotalNumberOfValidators);
_epochNumber = uint64(epochNumber);
_totalNumberOfValidators = newTotalNumberOfValidators;
_epochNumber = epochNumber;
}

/**
Expand Down Expand Up @@ -137,6 +137,13 @@
return _validatorTicketPrice;
}

/**
* @inheritdoc IPufferOracleV2
*/
function getNumberOfActiveValidators() external view returns (uint256) {
return _numberOfActivePufferValidators;
}

function _setMintPrice(uint256 newPrice) internal {
emit ValidatorTicketMintPriceUpdated(_validatorTicketPrice, newPrice);
_validatorTicketPrice = newPrice;
Expand Down
5 changes: 5 additions & 0 deletions src/interface/IPufferOracleV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ interface IPufferOracleV2 is IPufferOracle {
*/
function getTotalNumberOfValidators() external view returns (uint256);

/**
* @notice Returns the number of active puffer validators on Ethereum
*/
function getNumberOfActiveValidators() external view returns (uint256);

/**
* @notice Exits `validatorNumber` validators, decreasing the `lockedETHAmount` by validatorNumber * 32 ETH.
* It is called when when the validator exits the system in the `batchHandleWithdrawals` on the PufferProtocol.
Expand Down
Loading