Skip to content

Commit

Permalink
fix: set last byte to 0 in lib storages (#919)
Browse files Browse the repository at this point in the history
  • Loading branch information
rndquu authored Mar 20, 2024
1 parent 82b5492 commit c016c6d
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ library LibAccessControl {
bytes32 constant ACCESS_CONTROL_STORAGE_SLOT =
bytes32(
uint256(keccak256("ubiquity.contracts.access.control.storage")) - 1
);
) & ~bytes32(uint256(0xff));

/// @notice Structure to keep all role members with their admin role
struct RoleData {
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/dollar/libraries/LibBondingCurve.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ library LibBondingCurve {

/// @notice Storage slot used to store data for this library
bytes32 constant BONDING_CONTROL_STORAGE_SLOT =
bytes32(uint256(keccak256("ubiquity.contracts.bonding.storage")) - 1);
bytes32(uint256(keccak256("ubiquity.contracts.bonding.storage")) - 1) &
~bytes32(uint256(0xff));

/// @notice Emitted when collateral is deposited
event Deposit(address indexed user, uint256 amount);
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/dollar/libraries/LibChef.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ library LibChef {
bytes32 constant UBIQUITY_CHEF_STORAGE_POSITION =
bytes32(
uint256(keccak256("diamond.standard.ubiquity.chef.storage")) - 1
);
) & ~bytes32(uint256(0xff));

/**
* @notice Returns struct used as a storage for this library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ library LibCollectableDust {
bytes32(
uint256(keccak256("ubiquity.contracts.collectable.dust.storage")) -
1
);
) & ~bytes32(uint256(0xff));

/**
* @notice Returns struct used as a storage for this library
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/dollar/libraries/LibCreditClock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ library LibCreditClock {
bytes32 constant CREDIT_CLOCK_STORAGE_POSITION =
bytes32(
uint256(keccak256("ubiquity.contracts.credit.clock.storage")) - 1
);
) & ~bytes32(uint256(0xff));

/// @notice Struct used as a storage for the current library
struct CreditClockData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ library LibCreditNftManager {
uint256(
keccak256("ubiquity.contracts.credit.nft.manager.storage")
) - 1
);
) & ~bytes32(uint256(0xff));

/// @notice Emitted when Credit NFT to Governance conversion rate was updated
event ExpiredCreditNftConversionRateChanged(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ library LibCreditRedemptionCalculator {
"ubiquity.contracts.credit.redemption.calculator.storage"
)
) - 1
);
) & ~bytes32(uint256(0xff));

/**
* @notice Sets the `p` param in the Credit mint calculation formula:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ library LibCurveDollarIncentive {

/// @notice Storage slot used to store data for this library
bytes32 constant CURVE_DOLLAR_STORAGE_SLOT =
bytes32(uint256(keccak256("ubiquity.contracts.curve.storage")) - 1);
bytes32(uint256(keccak256("ubiquity.contracts.curve.storage")) - 1) &
~bytes32(uint256(0xff));

/// @notice One point in `bytes16`
bytes16 constant _one = bytes16(abi.encodePacked(uint256(1 ether)));
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/dollar/libraries/LibDiamond.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ error InitializationFunctionReverted(
library LibDiamond {
/// @notice Storage slot used to store data for this library
bytes32 constant DIAMOND_STORAGE_POSITION =
bytes32(uint256(keccak256("diamond.standard.diamond.storage")) - 1);
bytes32(uint256(keccak256("diamond.standard.diamond.storage")) - 1) &
~bytes32(uint256(0xff));

/// @notice Struct used as a mapping of facet to function selector position
struct FacetAddressAndPosition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ library LibDirectGovernanceFarmer {
bytes32(
uint256(keccak256("ubiquity.contracts.direct.governance.storage")) -
1
);
) & ~bytes32(uint256(0xff));

/// @notice Struct used as a storage for the current library
struct DirectGovernanceData {
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/src/dollar/libraries/LibStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ library LibStaking {

/// @notice Storage slot used to store data for this library
bytes32 constant STAKING_CONTROL_STORAGE_SLOT =
bytes32(uint256(keccak256("ubiquity.contracts.staking.storage")) - 1);
bytes32(uint256(keccak256("ubiquity.contracts.staking.storage")) - 1) &
~bytes32(uint256(0xff));

/// @notice Emitted when Dollar or 3CRV tokens are removed from Curve MetaPool
event PriceReset(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ library LibUbiquityPool {
bytes32 constant UBIQUITY_POOL_STORAGE_POSITION =
bytes32(
uint256(keccak256("ubiquity.contracts.ubiquity.pool.storage")) - 1
);
) & ~bytes32(uint256(0xff));

/// @notice Struct used as a storage for this library
struct UbiquityPoolStorage {
Expand Down

0 comments on commit c016c6d

Please sign in to comment.