Skip to content

Commit

Permalink
chore(contracts): version interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 18, 2024
1 parent 2b841c9 commit 06bdd8e
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 119 deletions.
10 changes: 5 additions & 5 deletions bolt-contracts/src/contracts/BoltChallengerV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {MerkleTrie} from "../lib/trie/MerkleTrie.sol";
import {RLPReader} from "../lib/rlp/RLPReader.sol";
import {RLPWriter} from "../lib/rlp/RLPWriter.sol";
import {TransactionDecoder} from "../lib/TransactionDecoder.sol";
import {IBoltChallenger} from "../interfaces/IBoltChallenger.sol";
import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
import {IBoltChallengerV1} from "../interfaces/IBoltChallengerV1.sol";
import {IBoltParametersV1} from "../interfaces/IBoltParametersV1.sol";

/// @title Bolt Challenger
/// @notice Contract for managing (creating & resolving) challenges for Bolt inclusion commitments.
Expand All @@ -23,7 +23,7 @@ import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
/// 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 BoltChallengerV1 is IBoltChallenger, OwnableUpgradeable, UUPSUpgradeable {
contract BoltChallengerV1 is IBoltChallengerV1, OwnableUpgradeable, UUPSUpgradeable {
using RLPReader for bytes;
using RLPReader for RLPReader.RLPItem;
using TransactionDecoder for bytes;
Expand All @@ -33,7 +33,7 @@ contract BoltChallengerV1 is IBoltChallenger, OwnableUpgradeable, UUPSUpgradeabl
// ========= STORAGE =========

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

/// @notice The set of existing unique challenge IDs.
EnumerableSet.Bytes32Set internal challengeIDs;
Expand Down Expand Up @@ -61,7 +61,7 @@ contract BoltChallengerV1 is IBoltChallenger, OwnableUpgradeable, UUPSUpgradeabl
function initialize(address _owner, address _parameters) public initializer {
__Ownable_init(_owner);

parameters = IBoltParameters(_parameters);
parameters = IBoltParametersV1(_parameters);
}

function _authorizeUpgrade(
Expand Down
18 changes: 9 additions & 9 deletions bolt-contracts/src/contracts/BoltEigenLayerMiddlewareV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/Own
import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";

import {MapWithTimeData} from "../lib/MapWithTimeData.sol";
import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
import {IBoltValidators} from "../interfaces/IBoltValidators.sol";
import {IBoltMiddleware} from "../interfaces/IBoltMiddleware.sol";
import {IBoltManager} from "../interfaces/IBoltManager.sol";
import {IBoltParametersV1} from "../interfaces/IBoltParametersV1.sol";
import {IBoltValidatorsV1} from "../interfaces/IBoltValidatorsV1.sol";
import {IBoltMiddlewareV1} from "../interfaces/IBoltMiddlewareV1.sol";
import {IBoltManagerV1} from "../interfaces/IBoltManagerV1.sol";

import {IStrategyManager} from "@eigenlayer/src/contracts/interfaces/IStrategyManager.sol";
import {IAVSDirectory} from "@eigenlayer/src/contracts/interfaces/IAVSDirectory.sol";
Expand All @@ -30,7 +30,7 @@ import {StrategyManagerStorage} from "@eigenlayer/src/contracts/core/StrategyMan
/// 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 BoltEigenLayerMiddlewareV1 is IBoltMiddleware, OwnableUpgradeable, UUPSUpgradeable {
contract BoltEigenLayerMiddlewareV1 is IBoltMiddlewareV1, OwnableUpgradeable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableMap for EnumerableMap.AddressToUintMap;
using MapWithTimeData for EnumerableMap.AddressToUintMap;
Expand All @@ -41,11 +41,11 @@ contract BoltEigenLayerMiddlewareV1 is IBoltMiddleware, OwnableUpgradeable, UUPS
uint48 public START_TIMESTAMP;

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

/// @notice Validators registry, where validators are registered via their
/// BLS pubkey and are assigned a sequence number.
IBoltManager public manager;
IBoltManagerV1 public manager;

/// @notice Set of EigenLayer protocol strategies that are used in Bolt Protocol.
EnumerableMap.AddressToUintMap private strategies;
Expand Down Expand Up @@ -99,8 +99,8 @@ contract BoltEigenLayerMiddlewareV1 is IBoltMiddleware, OwnableUpgradeable, UUPS
address _eigenlayerStrategyManager
) public initializer {
__Ownable_init(_owner);
parameters = IBoltParameters(_parameters);
manager = IBoltManager(_manager);
parameters = IBoltParametersV1(_parameters);
manager = IBoltManagerV1(_manager);
START_TIMESTAMP = Time.timestamp();

AVS_DIRECTORY = IAVSDirectory(_eigenlayerAVSDirectory);
Expand Down
34 changes: 17 additions & 17 deletions bolt-contracts/src/contracts/BoltManagerV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import {OperatorMapWithTime} from "../lib/OperatorMapWithTime.sol";
import {EnumerableMap} from "../lib/EnumerableMap.sol";
import {IBoltValidators} from "../interfaces/IBoltValidators.sol";
import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
import {IBoltMiddleware} from "../interfaces/IBoltMiddleware.sol";
import {IBoltManager} from "../interfaces/IBoltManager.sol";
import {IBoltValidatorsV1} from "../interfaces/IBoltValidatorsV1.sol";
import {IBoltParametersV1} from "../interfaces/IBoltParametersV1.sol";
import {IBoltMiddlewareV1} from "../interfaces/IBoltMiddlewareV1.sol";
import {IBoltManagerV1} from "../interfaces/IBoltManagerV1.sol";

/// @title Bolt Manager
/// @notice The Bolt Manager contract is responsible for managing operators & restaking middlewares, and is the
Expand All @@ -22,7 +22,7 @@ import {IBoltManager} from "../interfaces/IBoltManager.sol";
/// 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 BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
contract BoltManagerV1 is IBoltManagerV1, OwnableUpgradeable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableMap for EnumerableMap.OperatorMap;
using OperatorMapWithTime for EnumerableMap.OperatorMap;
Expand All @@ -32,11 +32,11 @@ contract BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
uint48 public START_TIMESTAMP;

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

/// @notice Validators registry, where validators are registered via their
/// BLS pubkey and are assigned a sequence number.
IBoltValidators public validators;
IBoltValidatorsV1 public validators;

/// @notice Set of operator addresses that have opted in to Bolt Protocol.
EnumerableMap.OperatorMap private operators;
Expand Down Expand Up @@ -71,8 +71,8 @@ contract BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
function initialize(address _owner, address _parameters, address _validators) public initializer {
__Ownable_init(_owner);

parameters = IBoltParameters(_parameters);
validators = IBoltValidators(_validators);
parameters = IBoltParametersV1(_parameters);
validators = IBoltValidatorsV1(_validators);

START_TIMESTAMP = Time.timestamp();
}
Expand Down Expand Up @@ -132,8 +132,8 @@ contract BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
/// @return statuses The statuses of the proposers, including their operator and active stake.
function getProposerStatuses(
bytes32[] calldata pubkeyHashes
) public view returns (IBoltValidators.ProposerStatus[] memory statuses) {
statuses = new IBoltValidators.ProposerStatus[](pubkeyHashes.length);
) public view returns (IBoltValidatorsV1.ProposerStatus[] memory statuses) {
statuses = new IBoltValidatorsV1.ProposerStatus[](pubkeyHashes.length);
for (uint256 i = 0; i < pubkeyHashes.length; ++i) {
statuses[i] = getProposerStatus(pubkeyHashes[i]);
}
Expand All @@ -144,14 +144,14 @@ contract BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
/// @return status The status of the proposer, including their operator and active stake.
function getProposerStatus(
bytes32 pubkeyHash
) public view returns (IBoltValidators.ProposerStatus memory status) {
) public view returns (IBoltValidatorsV1.ProposerStatus memory status) {
if (pubkeyHash == bytes32(0)) {
revert InvalidQuery();
}

uint48 epochStartTs = getEpochStartTs(getEpochAtTs(Time.timestamp()));
// NOTE: this will revert when the proposer does not exist.
IBoltValidators.Validator memory validator = validators.getValidatorByPubkeyHash(pubkeyHash);
IBoltValidatorsV1.Validator memory validator = validators.getValidatorByPubkeyHash(pubkeyHash);

Operator memory operator = operators.get(validator.authorizedOperator);

Expand All @@ -165,7 +165,7 @@ contract BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
}

(status.collaterals, status.amounts) =
IBoltMiddleware(operator.middleware).getOperatorCollaterals(validator.authorizedOperator);
IBoltMiddlewareV1(operator.middleware).getOperatorCollaterals(validator.authorizedOperator);

// NOTE: check if the sum of the collaterals covers the minimum operator stake required.

Expand All @@ -187,7 +187,7 @@ contract BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
function getOperatorStake(address operator, address collateral) public view returns (uint256) {
Operator memory operatorData = operators.get(operator);

return IBoltMiddleware(operatorData.middleware).getOperatorStake(operator, collateral);
return IBoltMiddlewareV1(operatorData.middleware).getOperatorStake(operator, collateral);
}

/// @notice Get the total amount staked of a given collateral asset.
Expand All @@ -196,8 +196,8 @@ contract BoltManagerV1 is IBoltManager, OwnableUpgradeable, UUPSUpgradeable {
) public view returns (uint256 amount) {
// Loop over all of the operators, get their middleware, and retrieve their staked amount.
for (uint256 i = 0; i < operators.length(); ++i) {
(address operator, IBoltManager.Operator memory operatorData) = operators.at(i);
amount += IBoltMiddleware(operatorData.middleware).getOperatorStake(operator, collateral);
(address operator, IBoltManagerV1.Operator memory operatorData) = operators.at(i);
amount += IBoltMiddlewareV1(operatorData.middleware).getOperatorStake(operator, collateral);
}

return amount;
Expand Down
18 changes: 9 additions & 9 deletions bolt-contracts/src/contracts/BoltSymbioticMiddlewareV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import {IVetoSlasher} from "@symbiotic/interfaces/slasher/IVetoSlasher.sol";
import {IEntity} from "@symbiotic/interfaces/common/IEntity.sol";

import {MapWithTimeData} from "../lib/MapWithTimeData.sol";
import {IBoltValidators} from "../interfaces/IBoltValidators.sol";
import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
import {IBoltMiddleware} from "../interfaces/IBoltMiddleware.sol";
import {IBoltManager} from "../interfaces/IBoltManager.sol";
import {IBoltValidatorsV1} from "../interfaces/IBoltValidatorsV1.sol";
import {IBoltParametersV1} from "../interfaces/IBoltParametersV1.sol";
import {IBoltMiddlewareV1} from "../interfaces/IBoltMiddlewareV1.sol";
import {IBoltManagerV1} from "../interfaces/IBoltManagerV1.sol";

/// @title Bolt Symbiotic Middleware
/// @notice This contract is responsible for interfacing with the Symbiotic restaking protocol.
Expand All @@ -30,7 +30,7 @@ import {IBoltManager} from "../interfaces/IBoltManager.sol";
/// 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 BoltSymbioticMiddlewareV1 is IBoltMiddleware, OwnableUpgradeable, UUPSUpgradeable {
contract BoltSymbioticMiddlewareV1 is IBoltMiddlewareV1, OwnableUpgradeable, UUPSUpgradeable {
using EnumerableSet for EnumerableSet.AddressSet;
using EnumerableMap for EnumerableMap.AddressToUintMap;
using MapWithTimeData for EnumerableMap.AddressToUintMap;
Expand All @@ -49,11 +49,11 @@ contract BoltSymbioticMiddlewareV1 is IBoltMiddleware, OwnableUpgradeable, UUPSU
uint48 public START_TIMESTAMP;

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

/// @notice Validators registry, where validators are registered via their
/// BLS pubkey and are assigned a sequence number.
IBoltManager public manager;
IBoltManagerV1 public manager;

/// @notice Set of Symbiotic protocol vaults that are used in Bolt Protocol.
EnumerableMap.AddressToUintMap private vaults;
Expand Down Expand Up @@ -112,8 +112,8 @@ contract BoltSymbioticMiddlewareV1 is IBoltMiddleware, OwnableUpgradeable, UUPSU
address _symbioticVaultFactory
) public initializer {
__Ownable_init(_owner);
parameters = IBoltParameters(_parameters);
manager = IBoltManager(_manager);
parameters = IBoltParametersV1(_parameters);
manager = IBoltManagerV1(_manager);
START_TIMESTAMP = Time.timestamp();

BOLT_SYMBIOTIC_NETWORK = _symbioticNetwork;
Expand Down
10 changes: 5 additions & 5 deletions bolt-contracts/src/contracts/BoltValidatorsV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {UUPSUpgradeable} from "@openzeppelin/contracts/proxy/utils/UUPSUpgradeab

import {BLS12381} from "../lib/bls/BLS12381.sol";
import {BLSSignatureVerifier} from "../lib/bls/BLSSignatureVerifier.sol";
import {IBoltValidators} from "../interfaces/IBoltValidators.sol";
import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
import {IBoltValidatorsV1} from "../interfaces/IBoltValidatorsV1.sol";
import {IBoltParametersV1} from "../interfaces/IBoltParametersV1.sol";

/// @title Bolt Validators
/// @notice This contract is responsible for registering validators and managing their configuration
Expand All @@ -16,13 +16,13 @@ import {IBoltParameters} from "../interfaces/IBoltParameters.sol";
/// 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 BoltValidatorsV1 is IBoltValidators, BLSSignatureVerifier, OwnableUpgradeable, UUPSUpgradeable {
contract BoltValidatorsV1 is IBoltValidatorsV1, BLSSignatureVerifier, OwnableUpgradeable, UUPSUpgradeable {
using BLS12381 for BLS12381.G1Point;

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

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

/// @notice Validators (aka Blockspace providers)
/// @dev For our purpose, validators are blockspace providers for commitments.
Expand Down Expand Up @@ -69,7 +69,7 @@ contract BoltValidatorsV1 is IBoltValidators, BLSSignatureVerifier, OwnableUpgra
function initialize(address _owner, address _parameters) public initializer {
__Ownable_init(_owner);

parameters = IBoltParameters(_parameters);
parameters = IBoltParametersV1(_parameters);
}

function _authorizeUpgrade(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

interface IBoltChallenger {
interface IBoltChallengerV1 {
enum ChallengeStatus {
Open,
Defended,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {IBoltValidators} from "./IBoltValidators.sol";
import {IBoltValidatorsV1} from "./IBoltValidatorsV1.sol";

interface IBoltManager {
interface IBoltManagerV1 {
error InvalidQuery();
error OperatorAlreadyRegistered();
error OperatorNotRegistered();
Expand Down Expand Up @@ -34,15 +34,15 @@ interface IBoltManager {
address operator
) external view returns (bool);

function validators() external view returns (IBoltValidators);
function validators() external view returns (IBoltValidatorsV1);

function getProposerStatus(
bytes32 pubkeyHash
) external view returns (IBoltValidators.ProposerStatus memory status);
) external view returns (IBoltValidatorsV1.ProposerStatus memory status);

function getProposerStatuses(
bytes32[] calldata pubkeyHashes
) external view returns (IBoltValidators.ProposerStatus[] memory statuses);
) external view returns (IBoltValidatorsV1.ProposerStatus[] memory statuses);

function isOperatorAuthorizedForValidator(address operator, bytes32 pubkeyHash) external view returns (bool);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity 0.8.25;

import {BLS12381} from "../lib/bls/BLS12381.sol";
import {IBoltValidators} from "./IBoltValidators.sol";
import {IBoltValidatorsV1} from "./IBoltValidatorsV1.sol";

interface IBoltMiddleware {
interface IBoltMiddlewareV1 {
error InvalidQuery();
error AlreadyRegistered();
error NotRegistered();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

interface IBoltParameters {
interface IBoltParametersV1 {
function EPOCH_DURATION() external view returns (uint48);
function SLASHING_WINDOW() external view returns (uint48);
function ALLOW_UNSAFE_REGISTRATION() external view returns (bool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.25;

import {BLS12381} from "../lib/bls/BLS12381.sol";

interface IBoltValidators {
interface IBoltValidatorsV1 {
/// @notice Validator info
struct Validator {
// whether the validator exists in the registry
Expand Down
10 changes: 5 additions & 5 deletions bolt-contracts/src/lib/EnumerableMap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.25;

import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

import {IBoltManager} from "../interfaces/IBoltManager.sol";
import {IBoltManagerV1} from "../interfaces/IBoltManagerV1.sol";

library EnumerableMap {
using EnumerableSet for EnumerableSet.Bytes32Set;
Expand All @@ -13,10 +13,10 @@ library EnumerableMap {
struct OperatorMap {
// Storage of keys
EnumerableSet.Bytes32Set _keys;
mapping(bytes32 key => IBoltManager.Operator) _values;
mapping(bytes32 key => IBoltManagerV1.Operator) _values;
}

function set(OperatorMap storage self, address key, IBoltManager.Operator memory value) internal returns (bool) {
function set(OperatorMap storage self, address key, IBoltManagerV1.Operator memory value) internal returns (bool) {
bytes32 keyBytes = bytes32(uint256(uint160(key)));
self._values[keyBytes] = value;
return self._keys.add(keyBytes);
Expand All @@ -41,12 +41,12 @@ library EnumerableMap {
function at(
OperatorMap storage self,
uint256 index
) internal view returns (address, IBoltManager.Operator memory) {
) internal view returns (address, IBoltManagerV1.Operator memory) {
bytes32 key = self._keys.at(index);
return (address(uint160(uint256(key))), self._values[key]);
}

function get(OperatorMap storage self, address key) internal view returns (IBoltManager.Operator memory) {
function get(OperatorMap storage self, address key) internal view returns (IBoltManagerV1.Operator memory) {
if (!contains(self, key)) {
revert KeyNotFound();
}
Expand Down
Loading

0 comments on commit 06bdd8e

Please sign in to comment.