Skip to content

Commit

Permalink
feat(contracts): deployment config, minimumOperatorStake parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mempirate committed Oct 15, 2024
1 parent 8448b1c commit e873863
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 28 deletions.
3 changes: 2 additions & 1 deletion bolt-contracts/config/config.holesky.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"justificationDelay": 32,
"eth2GenesisTimestamp": 1694786400,
"slotTime": 12,
"allowUnsafeRegistration": true
"allowUnsafeRegistration": true,
"minimumOperatorStake": 1000000000000000000
}
3 changes: 2 additions & 1 deletion bolt-contracts/config/config.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"justificationDelay": 32,
"eth2GenesisTimestamp": 1606824023,
"slotTime": 12,
"allowUnsafeRegistration": true
"allowUnsafeRegistration": true,
"minimumOperatorStake": 1000000000000000000
}
60 changes: 42 additions & 18 deletions bolt-contracts/script/deploy/holesky/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {BoltValidators} from "../../../src/contracts/BoltValidators.sol";
import {BoltManager} from "../../../src/contracts/BoltManager.sol";
import {BoltEigenLayerMiddleware} from "../../../src/contracts/BoltEigenLayerMiddleware.sol";
import {BoltSymbioticMiddleware} from "../../../src/contracts/BoltSymbioticMiddleware.sol";
import {BoltConfig} from "../../../src/lib/Config.sol";

/// @notice Script to deploy the BoltManager and BoltValidators contracts.
contract DeployBolt is Script {
Expand All @@ -29,29 +30,22 @@ contract DeployBolt is Script {
// on the contract implementations, as well as upgrade the contracts.
address admin = msg.sender;

uint48 epochDuration = 1 days;
uint48 slashingWindow = 7 days;
uint48 maxChallengeDuration = 7 days;
bool allowUnsafeRegistration = true;
uint256 challengeBond = 1 ether;
uint256 blockhashEvmLookback = 256;
uint256 justificationDelay = 32;
uint256 eth2GenesisTimestamp = 1_694_786_400;
uint256 slotTime = 12;
BoltConfig.ParametersConfig memory config = readParameters();

bytes memory initParameters = abi.encodeCall(
BoltParameters.initialize,
(
admin,
epochDuration,
slashingWindow,
maxChallengeDuration,
allowUnsafeRegistration,
challengeBond,
blockhashEvmLookback,
justificationDelay,
eth2GenesisTimestamp,
slotTime
config.epochDuration,
config.slashingWindow,
config.maxChallengeDuration,
config.allowUnsafeRegistration,
config.challengeBond,
config.blockhashEvmLookback,
config.justificationDelay,
config.eth2GenesisTimestamp,
config.slotTime,
config.minimumOperatorStake
)
);
address parametersProxy = Upgrades.deployUUPSProxy("BoltParameters.sol", initParameters);
Expand Down Expand Up @@ -100,4 +94,34 @@ contract DeployBolt is Script {

vm.stopBroadcast();
}

function readParameters() public view returns (BoltConfig.ParametersConfig memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/config.holesky.json");
string memory json = vm.readFile(path);

uint48 epochDuration = uint48(vm.parseJsonUint(json, ".epochDuration"));
uint48 slashingWindow = uint48(vm.parseJsonUint(json, ".slashingWindow"));
uint48 maxChallengeDuration = uint48(vm.parseJsonUint(json, ".maxChallengeDuration"));
bool allowUnsafeRegistration = vm.parseJsonBool(json, ".allowUnsafeRegistration");
uint256 challengeBond = vm.parseJsonUint(json, ".challengeBond");
uint256 blockhashEvmLookback = vm.parseJsonUint(json, ".blockhashEvmLookback");
uint256 justificationDelay = vm.parseJsonUint(json, ".justificationDelay");
uint256 eth2GenesisTimestamp = vm.parseJsonUint(json, ".eth2GenesisTimestamp");
uint256 slotTime = vm.parseJsonUint(json, ".slotTime");
uint256 minimumOperatorStake = vm.parseJsonUint(json, ".minimumOperatorStake");

return BoltConfig.ParametersConfig({
epochDuration: epochDuration,
slashingWindow: slashingWindow,
maxChallengeDuration: maxChallengeDuration,
challengeBond: challengeBond,
blockhashEvmLookback: blockhashEvmLookback,
justificationDelay: justificationDelay,
eth2GenesisTimestamp: eth2GenesisTimestamp,
slotTime: slotTime,
allowUnsafeRegistration: allowUnsafeRegistration,
minimumOperatorStake: minimumOperatorStake
});
}
}
11 changes: 8 additions & 3 deletions bolt-contracts/src/contracts/BoltParameters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ contract BoltParameters is OwnableUpgradeable, UUPSUpgradeable {

/// @notice The duration of a slot in seconds.
uint256 public SLOT_TIME;
// --> Storage layout marker: 6 words

/// @notice The minimum stake required for an operator to be considered active in wei.
uint256 public MINIMUM_OPERATOR_STAKE;
// --> Storage layout marker: 7 words

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

/// @notice Error emitted when a beacon block root is not found
error BeaconRootNotFound();
Expand All @@ -78,7 +81,8 @@ contract BoltParameters is OwnableUpgradeable, UUPSUpgradeable {
uint256 _blockhashEvmLookback,
uint256 _justificationDelay,
uint256 _eth2GenesisTimestamp,
uint256 _slotTime
uint256 _slotTime,
uint256 _minimumOperatorStake
) public initializer {
__Ownable_init(_owner);

Expand All @@ -91,6 +95,7 @@ contract BoltParameters is OwnableUpgradeable, UUPSUpgradeable {
JUSTIFICATION_DELAY = _justificationDelay;
ETH2_GENESIS_TIMESTAMP = _eth2GenesisTimestamp;
SLOT_TIME = _slotTime;
MINIMUM_OPERATOR_STAKE = _minimumOperatorStake;
}

function _authorizeUpgrade(
Expand Down
1 change: 1 addition & 0 deletions bolt-contracts/src/interfaces/IBoltParameters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ interface IBoltParameters {
function SLOT_TIME() external view returns (uint256);
function ETH2_GENESIS_TIMESTAMP() external view returns (uint256);
function BEACON_ROOTS_CONTRACT() external view returns (address);
function MINIMUM_OPERATOR_STAKE() external view returns (uint256);
}
1 change: 1 addition & 0 deletions bolt-contracts/src/lib/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ library BoltConfig {
uint256 eth2GenesisTimestamp;
uint256 slotTime;
bool allowUnsafeRegistration;
uint256 minimumOperatorStake;
}
}
3 changes: 2 additions & 1 deletion bolt-contracts/test/BoltChallenger.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ contract BoltChallengerTest is Test {
config.blockhashEvmLookback,
config.justificationDelay,
config.eth2GenesisTimestamp,
config.slotTime
config.slotTime,
config.minimumOperatorStake
);

boltChallenger = new BoltChallengerExt();
Expand Down
3 changes: 2 additions & 1 deletion bolt-contracts/test/BoltManager.EigenLayer.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ contract BoltManagerEigenLayerTest is Test {
config.blockhashEvmLookback,
config.justificationDelay,
config.eth2GenesisTimestamp,
config.slotTime
config.slotTime,
config.minimumOperatorStake
);

// Deploy Bolt contracts
Expand Down
3 changes: 2 additions & 1 deletion bolt-contracts/test/BoltManager.Symbiotic.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ contract BoltManagerSymbioticTest is Test {
config.blockhashEvmLookback,
config.justificationDelay,
config.eth2GenesisTimestamp,
config.slotTime
config.slotTime,
config.minimumOperatorStake
);

validators = new BoltValidators();
Expand Down
3 changes: 2 additions & 1 deletion bolt-contracts/test/BoltValidators.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ contract BoltValidatorsTest is Test {
config.blockhashEvmLookback,
config.justificationDelay,
config.eth2GenesisTimestamp,
config.slotTime
config.slotTime,
config.minimumOperatorStake
);

validators = new BoltValidators();
Expand Down
4 changes: 3 additions & 1 deletion bolt-contracts/test/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ contract Utils is Test {
uint256 justificationDelay = vm.parseJsonUint(json, ".justificationDelay");
uint256 eth2GenesisTimestamp = vm.parseJsonUint(json, ".eth2GenesisTimestamp");
uint256 slotTime = vm.parseJsonUint(json, ".slotTime");
uint256 minimumOperatorStake = vm.parseJsonUint(json, ".minimumOperatorStake");

return BoltConfig.ParametersConfig({
epochDuration: epochDuration,
Expand All @@ -30,7 +31,8 @@ contract Utils is Test {
justificationDelay: justificationDelay,
eth2GenesisTimestamp: eth2GenesisTimestamp,
slotTime: slotTime,
allowUnsafeRegistration: allowUnsafeRegistration
allowUnsafeRegistration: allowUnsafeRegistration,
minimumOperatorStake: minimumOperatorStake
});
}
}

0 comments on commit e873863

Please sign in to comment.