diff --git a/bolt-contracts/config/config.holesky.json b/bolt-contracts/config/config.holesky.json new file mode 100644 index 000000000..09fd09acb --- /dev/null +++ b/bolt-contracts/config/config.holesky.json @@ -0,0 +1,11 @@ +{ + "epochDuration": 86400, + "slashingWindow": 604800, + "maxChallengeDuration": 604800, + "challengeBond": 1000000000000000000, + "blockhashEvmLookback": 256, + "justificationDelay": 32, + "eth2GenesisTimestamp": 1694786400, + "slotTime": 12, + "allowUnsafeRegistration": true +} \ No newline at end of file diff --git a/bolt-contracts/config/config.test.json b/bolt-contracts/config/config.test.json new file mode 100644 index 000000000..59251d1aa --- /dev/null +++ b/bolt-contracts/config/config.test.json @@ -0,0 +1,11 @@ +{ + "epochDuration": 86400, + "slashingWindow": 604800, + "maxChallengeDuration": 604800, + "challengeBond": 1000000000000000000, + "blockhashEvmLookback": 256, + "justificationDelay": 32, + "eth2GenesisTimestamp": 1606824023, + "slotTime": 12, + "allowUnsafeRegistration": true +} \ No newline at end of file diff --git a/bolt-contracts/src/contracts/BoltManager.sol b/bolt-contracts/src/contracts/BoltManager.sol index 313c8d3af..0f9716109 100644 --- a/bolt-contracts/src/contracts/BoltManager.sol +++ b/bolt-contracts/src/contracts/BoltManager.sol @@ -41,11 +41,11 @@ contract BoltManager is IBoltManager, OwnableUpgradeable, UUPSUpgradeable { /// associated Bolt Middleware contract. EnumerableSet.AddressSet private restakingProtocols; - // --> Storage layout marker: 4 slots - /// @notice Start timestamp of the first epoch. uint48 public START_TIMESTAMP; + // --> Storage layout marker: 5 slots (26 bytes left) + /** * @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. @@ -54,7 +54,7 @@ contract BoltManager is IBoltManager, OwnableUpgradeable, UUPSUpgradeable { * * Total storage slots: 50 */ - uint256[46] private __gap; + uint256[45] private __gap; modifier onlyMiddleware() { if (!restakingProtocols.contains(msg.sender)) { diff --git a/bolt-contracts/src/lib/Config.sol b/bolt-contracts/src/lib/Config.sol new file mode 100644 index 000000000..e18b6ab76 --- /dev/null +++ b/bolt-contracts/src/lib/Config.sol @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.25; + +library BoltConfig { + struct ParametersConfig { + uint48 epochDuration; + uint48 slashingWindow; + uint48 maxChallengeDuration; + uint256 challengeBond; + uint256 blockhashEvmLookback; + uint256 justificationDelay; + uint256 eth2GenesisTimestamp; + uint256 slotTime; + bool allowUnsafeRegistration; + } +} diff --git a/bolt-contracts/test/BoltChallenger.t.sol b/bolt-contracts/test/BoltChallenger.t.sol index 33a2038b0..da3484de0 100644 --- a/bolt-contracts/test/BoltChallenger.t.sol +++ b/bolt-contracts/test/BoltChallenger.t.sol @@ -2,11 +2,13 @@ pragma solidity 0.8.25; import {Test, console} from "forge-std/Test.sol"; +import {Utils} from "./Utils.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import {BoltParameters} from "../src/contracts/BoltParameters.sol"; import {BoltChallenger} from "../src/contracts/BoltChallenger.sol"; +import {BoltConfig} from "../src/lib/Config.sol"; import {IBoltChallenger} from "../src/interfaces/IBoltChallenger.sol"; import {RLPReader} from "../src/lib/rlp/RLPReader.sol"; import {RLPWriter} from "../src/lib/rlp/RLPWriter.sol"; @@ -56,28 +58,20 @@ contract BoltChallengerTest is Test { vm.pauseGasMetering(); (target, targetPK) = makeAddrAndKey("target"); - 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_606_824_023; - uint256 slotTime = 12; + BoltConfig.ParametersConfig memory config = new Utils().readParameters(); BoltParameters parameters = new BoltParameters(); parameters.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 ); boltChallenger = new BoltChallengerExt(); diff --git a/bolt-contracts/test/BoltManager.EigenLayer.t.sol b/bolt-contracts/test/BoltManager.EigenLayer.t.sol index 4e6c6fc1e..fd3d99da1 100644 --- a/bolt-contracts/test/BoltManager.EigenLayer.t.sol +++ b/bolt-contracts/test/BoltManager.EigenLayer.t.sol @@ -6,10 +6,12 @@ import {Test, console} from "forge-std/Test.sol"; import {BoltValidators} from "../src/contracts/BoltValidators.sol"; import {BoltManager} from "../src/contracts/BoltManager.sol"; import {BoltParameters} from "../src/contracts/BoltParameters.sol"; +import {BoltConfig} from "../src/lib/Config.sol"; import {BoltEigenLayerMiddleware} from "../src/contracts/BoltEigenLayerMiddleware.sol"; import {IBoltValidators} from "../src/interfaces/IBoltValidators.sol"; import {IBoltManager} from "../src/interfaces/IBoltManager.sol"; import {IBoltMiddleware} from "../src/interfaces/IBoltMiddleware.sol"; +import {Utils} from "./Utils.sol"; import {AVSDirectoryStorage} from "@eigenlayer/src/contracts/core/AVSDirectoryStorage.sol"; import {DelegationManagerStorage} from "@eigenlayer/src/contracts/core/DelegationManagerStorage.sol"; @@ -45,34 +47,25 @@ contract BoltManagerEigenLayerTest is Test { // Set-up accounts (operator, operatorSk) = makeAddrAndKey("operator"); - // vm.setEnv("CHAIN_ID", "100000000"); // Deploy EigenLayer contracts. // This also deploy a `weth` token and `wethStrat` strategy base available as properties of the contract. eigenLayerDeployer = new EigenLayerDeployer(staker); eigenLayerDeployer.setUp(); - 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_606_824_023; - uint256 slotTime = 12; + BoltConfig.ParametersConfig memory config = new Utils().readParameters(); BoltParameters parameters = new BoltParameters(); parameters.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 ); // Deploy Bolt contracts diff --git a/bolt-contracts/test/BoltManager.Symbiotic.t.sol b/bolt-contracts/test/BoltManager.Symbiotic.t.sol index 225c1fdcd..0f16bf9f6 100644 --- a/bolt-contracts/test/BoltManager.Symbiotic.t.sol +++ b/bolt-contracts/test/BoltManager.Symbiotic.t.sol @@ -28,6 +28,8 @@ import {BoltValidators} from "../src/contracts/BoltValidators.sol"; import {BoltManager} from "../src/contracts/BoltManager.sol"; import {BoltSymbioticMiddleware} from "../src/contracts/BoltSymbioticMiddleware.sol"; import {BLS12381} from "../src/lib/bls/BLS12381.sol"; +import {BoltConfig} from "../src/lib/Config.sol"; +import {Utils} from "./Utils.sol"; import {SymbioticSetupFixture} from "./fixtures/SymbioticSetup.f.sol"; @@ -151,28 +153,20 @@ contract BoltManagerSymbioticTest is Test { // --- Deploy Bolt contracts --- - 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_606_824_023; - uint256 slotTime = 12; + BoltConfig.ParametersConfig memory config = new Utils().readParameters(); BoltParameters parameters = new BoltParameters(); parameters.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 ); validators = new BoltValidators(); diff --git a/bolt-contracts/test/BoltValidators.t.sol b/bolt-contracts/test/BoltValidators.t.sol index f36d0fb3e..ed119e3b0 100644 --- a/bolt-contracts/test/BoltValidators.t.sol +++ b/bolt-contracts/test/BoltValidators.t.sol @@ -7,6 +7,8 @@ import {BoltParameters} from "../src/contracts/BoltParameters.sol"; import {BoltValidators} from "../src/contracts/BoltValidators.sol"; import {IBoltValidators} from "../src/interfaces/IBoltValidators.sol"; import {BLS12381} from "../src/lib/bls/BLS12381.sol"; +import {BoltConfig} from "../src/lib/Config.sol"; +import {Utils} from "./Utils.sol"; contract BoltValidatorsTest is Test { using BLS12381 for BLS12381.G1Point; @@ -22,30 +24,22 @@ contract BoltValidatorsTest is Test { address validator = makeAddr("validator"); function setUp() public { - 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_606_824_023; - uint256 slotTime = 12; + BoltConfig.ParametersConfig memory config = new Utils().readParameters(); parameters = new BoltParameters(); - parameters.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 ); + validators = new BoltValidators(); validators.initialize(admin, address(parameters)); } diff --git a/bolt-contracts/test/Utils.sol b/bolt-contracts/test/Utils.sol new file mode 100644 index 000000000..9c985ed7f --- /dev/null +++ b/bolt-contracts/test/Utils.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.25; + +import {Test, console} from "forge-std/Test.sol"; + +import {BoltConfig} from "../src/lib/Config.sol"; + +contract Utils is Test { + function readParameters() public view returns (BoltConfig.ParametersConfig memory) { + string memory root = vm.projectRoot(); + string memory path = string.concat(root, "/config/config.test.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"); + + return BoltConfig.ParametersConfig({ + epochDuration: epochDuration, + slashingWindow: slashingWindow, + maxChallengeDuration: maxChallengeDuration, + challengeBond: challengeBond, + blockhashEvmLookback: blockhashEvmLookback, + justificationDelay: justificationDelay, + eth2GenesisTimestamp: eth2GenesisTimestamp, + slotTime: slotTime, + allowUnsafeRegistration: allowUnsafeRegistration + }); + } +}