Skip to content

Commit

Permalink
fix(contracts): validate storage layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 15, 2024
1 parent e873863 commit a23ded0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 20 deletions.
6 changes: 4 additions & 2 deletions bolt-contracts/src/contracts/BoltChallenger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
/// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades
/// with the use of storage gaps.
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
/// To validate the storage layout, use the Openzeppelin Foundry Upgrades toolkit.
/// You can also validate manually with forge: forge inspect <contract> storage-layout --pretty
contract BoltChallenger is IBoltChallenger, OwnableUpgradeable, UUPSUpgradeable {
using RLPReader for bytes;
using RLPReader for RLPReader.RLPItem;
Expand All @@ -39,7 +41,7 @@ contract BoltChallenger is IBoltChallenger, OwnableUpgradeable, UUPSUpgradeable
/// @notice The mapping of challenge IDs to their respective challenges.
mapping(bytes32 => Challenge) internal challenges;

// --> Storage layout marker: 3 slots
// --> Storage layout marker: 4 slots

/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand All @@ -49,7 +51,7 @@ contract BoltChallenger is IBoltChallenger, OwnableUpgradeable, UUPSUpgradeable
*
* Total storage slots: 50
*/
uint256[47] private __gap;
uint256[46] private __gap;

// ========= INITIALIZER =========

Expand Down
12 changes: 7 additions & 5 deletions bolt-contracts/src/contracts/BoltEigenLayerMiddleware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ import {StrategyManagerStorage} from "@eigenlayer/src/contracts/core/StrategyMan
/// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades
/// with the use of storage gaps.
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
/// To validate the storage layout, use the Openzeppelin Foundry Upgrades toolkit.
/// You can also validate manually with forge: forge inspect <contract> storage-layout --pretty
contract BoltEigenLayerMiddleware is IBoltMiddleware, OwnableUpgradeable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableMap for EnumerableMap.AddressToUintMap;
using MapWithTimeData for EnumerableMap.AddressToUintMap;

// ========= STORAGE =========

/// @notice Start timestamp of the first epoch.
uint48 public START_TIMESTAMP;

/// @notice Bolt Parameters contract.
IBoltParameters public parameters;

Expand All @@ -60,10 +65,7 @@ contract BoltEigenLayerMiddleware is IBoltMiddleware, OwnableUpgradeable, UUPSUp
/// @notice Name hash of the restaking protocol for identifying the instance of `IBoltMiddleware`.
bytes32 public NAME_HASH;

// --> Storage layout marker: 8 slots

/// @notice Start timestamp of the first epoch.
uint48 public START_TIMESTAMP;
// --> Storage layout marker: 11 slots

/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand All @@ -73,7 +75,7 @@ contract BoltEigenLayerMiddleware is IBoltMiddleware, OwnableUpgradeable, UUPSUp
*
* Total storage slots: 50
*/
uint256[42] private __gap;
uint256[39] private __gap;

// ========= ERRORS =========

Expand Down
11 changes: 6 additions & 5 deletions bolt-contracts/src/contracts/BoltManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ import {IBoltManager} from "../interfaces/IBoltManager.sol";
/// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades
/// with the use of storage gaps.
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
/// To validate the storage layout, use the Openzeppelin Foundry Upgrades toolkit.
/// You can also validate manually with forge: forge inspect <contract> storage-layout --pretty
contract BoltManager is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableMap for EnumerableMap.OperatorMap;
using OperatorMapWithTime for EnumerableMap.OperatorMap;

// ========= STORAGE =========
/// @notice Start timestamp of the first epoch.
uint48 public START_TIMESTAMP;

/// @notice Bolt Parameters contract.
IBoltParameters public parameters;
Expand All @@ -41,10 +45,7 @@ contract BoltManager is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
/// associated Bolt Middleware contract.
EnumerableSet.AddressSet private restakingProtocols;

/// @notice Start timestamp of the first epoch.
uint48 public START_TIMESTAMP;

// --> Storage layout marker: 5 slots (26 bytes left)
// --> Storage layout marker: 7 slots

/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand All @@ -54,7 +55,7 @@ contract BoltManager is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
*
* Total storage slots: 50
*/
uint256[45] private __gap;
uint256[43] private __gap;

modifier onlyMiddleware() {
if (!restakingProtocols.contains(msg.sender)) {
Expand Down
2 changes: 2 additions & 0 deletions bolt-contracts/src/contracts/BoltParameters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeab
/// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades
/// with the use of storage gaps.
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
/// To validate the storage layout, use the Openzeppelin Foundry Upgrades toolkit.
/// You can also validate manually with forge: forge inspect <contract> storage-layout --pretty
contract BoltParameters is OwnableUpgradeable, UUPSUpgradeable {
// =========== CONSTANTS ========= //
/// @dev See EIP-4788 for more info
Expand Down
12 changes: 7 additions & 5 deletions bolt-contracts/src/contracts/BoltSymbioticMiddleware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {IBoltManager} from "../interfaces/IBoltManager.sol";
/// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades
/// with the use of storage gaps.
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
/// To validate the storage layout, use the Openzeppelin Foundry Upgrades toolkit.
/// You can also validate manually with forge: forge inspect <contract> storage-layout --pretty
contract BoltSymbioticMiddleware is IBoltMiddleware, OwnableUpgradeable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableMap for EnumerableMap.AddressToUintMap;
Expand All @@ -43,6 +45,9 @@ contract BoltSymbioticMiddleware is IBoltMiddleware, OwnableUpgradeable, UUPSUpg

// ========= STORAGE ========= //

/// @notice Start timestamp of the first epoch.
uint48 public START_TIMESTAMP;

/// @notice Bolt Parameters contract.
IBoltParameters public parameters;

Expand All @@ -68,12 +73,9 @@ contract BoltSymbioticMiddleware is IBoltMiddleware, OwnableUpgradeable, UUPSUpg
/// @notice Address of the Symbiotic Operator Network Opt-In contract.
address public OPERATOR_NET_OPTIN;

/// @notice Start timestamp of the first epoch.
uint48 public START_TIMESTAMP;

bytes32 public NAME_HASH;

// --> Storage layout marker: 10 slots
// --> Storage layout marker: 14 slots

/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand All @@ -83,7 +85,7 @@ contract BoltSymbioticMiddleware is IBoltMiddleware, OwnableUpgradeable, UUPSUpg
*
* Total storage slots: 50
*/
uint256[40] private __gap;
uint256[36] private __gap;

// ========= ERRORS =========

Expand Down
8 changes: 5 additions & 3 deletions bolt-contracts/src/contracts/BoltValidators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
/// @dev This contract is upgradeable using the UUPSProxy pattern. Storage layout remains fixed across upgrades
/// with the use of storage gaps.
/// See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
/// To validate the storage layout, use the Openzeppelin Foundry Upgrades toolkit.
/// You can also validate manually with forge: forge inspect <contract> storage-layout --pretty
contract BoltValidators is IBoltValidators, BLSSignatureVerifier, OwnableUpgradeable, UUPSUpgradeable {
using BLS12381 for BLS12381.G1Point;

Expand All @@ -35,13 +37,13 @@ contract BoltValidators is IBoltValidators, BLSSignatureVerifier, OwnableUpgrade
/// @dev This is used internally to easily query the pubkey hash of a validator.
mapping(uint64 => bytes32) private sequenceNumberToPubkeyHash;

// --> Storage layout marker: 3 slots

/// @notice counter of the next index to be assigned to a validator.
/// @dev This incremental index is only used to identify validators in the registry.
/// It is not related to the `validatorIndex` assigned by the Beacon Chain.
uint64 internal nextValidatorSequenceNumber;

// --> Storage layout marker: 4 slots

/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
Expand All @@ -50,7 +52,7 @@ contract BoltValidators is IBoltValidators, BLSSignatureVerifier, OwnableUpgrade
*
* Total storage slots: 50
*/
uint256[47] private __gap;
uint256[46] private __gap;

// ========= EVENTS =========

Expand Down

0 comments on commit a23ded0

Please sign in to comment.