Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contracts): registry updates #278

Merged
merged 54 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7c8d63a
feat(contracts): consolidate EigenLayer registration, add deregister …
mempirate Oct 7, 2024
fd9c01e
feat(contracts): add opt-out, register operator RPC
mempirate Oct 8, 2024
c4a4135
fix(contracts): rpc memory -> calldata
mempirate Oct 8, 2024
f4992df
fix(contracts): tests + memory -> calldata
mempirate Oct 8, 2024
79f9db2
feat(contracts): return operator RPC in getProposerStatus
mempirate Oct 8, 2024
9c80589
feat(contracts): WIP update EigenLayer middleware, manager as entrypoint
mempirate Oct 8, 2024
95650a5
feat(contracts): WIP update Symbiotic middleware, tests failing
mempirate Oct 8, 2024
abdb69c
test(contracts): WIP on tests
mempirate Oct 9, 2024
eb1d9fe
test(contracts): WIP on tests
mempirate Oct 9, 2024
b06d368
chore: update gitignore
mempirate Oct 9, 2024
3c5b783
forge install: openzeppelin-contracts-upgradeable
mempirate Oct 9, 2024
b51aede
fix: rm
mempirate Oct 9, 2024
5e37a6b
chore(contracts): fix oz remappings
mempirate Oct 9, 2024
242df15
feat(contracts): implement UUPSProxy everywhere
mempirate Oct 9, 2024
14e8e06
fix(contracts): make tests work with initializers instead of construc…
mempirate Oct 9, 2024
07dc130
forge install: openzeppelin-foundry-upgrades
mempirate Oct 9, 2024
c217890
feat(contracts): import OZ Foundry Upgrades
mempirate Oct 9, 2024
f91a941
forge install: forge-std
mempirate Oct 9, 2024
eb5c531
feat(contracts): deploy with OZ Upgrades library
mempirate Oct 9, 2024
67df143
fix(contracts): fix tests, operator map bug
mempirate Oct 9, 2024
27fafed
fix: rm unused gitmodule
mempirate Oct 9, 2024
5fed1c4
fix(contracts): msg.sender check on registerOperator
mempirate Oct 10, 2024
16c6dcc
fix(contracts): add operator pause + unpause on EigenLayerMiddleware
mempirate Oct 10, 2024
52c6ef4
feat(contracts): add `getTotalStake` method on `BoltManager`
mempirate Oct 10, 2024
28148a8
feat(contracts): initial BoltParameters contract
mempirate Oct 11, 2024
c2a0732
feat(contracts): update deploy script with parameters
mempirate Oct 11, 2024
6da5685
fix(contracts): fix tests, integrate parameters
mempirate Oct 11, 2024
d497935
chore(testnets): rm logs
mempirate Oct 14, 2024
61ea21c
chore(testnets): rm logs
mempirate Oct 14, 2024
37e6c43
fix(contracts): use named error messages instead of require
mempirate Oct 14, 2024
33553f9
chore(contracts): nits
mempirate Oct 14, 2024
db0946a
feat: merge
mempirate Oct 14, 2024
147467c
feat(contracts): integrate challenger
mempirate Oct 14, 2024
d676783
feat(contracts): add storage gaps + documentation
mempirate Oct 14, 2024
f12505c
feat(contracts): integrate `BeaconChainUtils` in params + challenger,…
mempirate Oct 15, 2024
e2a726c
feat(contracts): add admin parameter setters
mempirate Oct 15, 2024
7bcd4b1
fix(contracts): move some storage variables to constants
mempirate Oct 15, 2024
6fa1359
feat(contracts): update deploy script directory structure
mempirate Oct 15, 2024
a10a15d
feat(contracts): rm redundant checks on BoltManager
mempirate Oct 15, 2024
104b1e6
test(contracts): restore some tests
mempirate Oct 15, 2024
8448b1c
feat(contracts): read configs from files
mempirate Oct 15, 2024
e873863
feat(contracts): deployment config, minimumOperatorStake parameter
mempirate Oct 15, 2024
a23ded0
fix(contracts): validate storage layout
mempirate Oct 15, 2024
e7467c6
chore: rm unrelated
mempirate Oct 15, 2024
1f779d4
feat(contracts): add Foundry profile settings for OZ Foundry Upgrades…
mempirate Oct 15, 2024
ff311eb
feat(contracts): indicate minimum collateral requirements in manager …
mempirate Oct 16, 2024
983d07b
docs(contracts): add ERD
mempirate Oct 16, 2024
08681c9
docs(contracts): update README
mempirate Oct 16, 2024
fb3dfe1
docs(contracts): update diagram
mempirate Oct 16, 2024
ce4b85b
docs(contracts): reduce img size
mempirate Oct 16, 2024
6ea2c48
feat(contracts): add parameter setters for operator stake and justifi…
mempirate Oct 16, 2024
50f4439
docs(contracts): more README updates
mempirate Oct 16, 2024
deb3c7d
docs(contracts): more README updates
mempirate Oct 16, 2024
2515d31
feat(contracts): update gas snapshot
mempirate Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*_dump.log
logs/
target/
.DS_Store
.env
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
[submodule "bolt-contracts/lib/eigenlayer-contracts"]
path = bolt-contracts/lib/eigenlayer-contracts
url = https://github.com/layr-labs/eigenlayer-contracts
[submodule "bolt-contracts/lib/openzeppelin-contracts-upgradeable"]
path = bolt-contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "bolt-contracts/lib/openzeppelin-foundry-upgrades"]
path = bolt-contracts/lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
1 change: 1 addition & 0 deletions bolt-contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cache/
out/
broadcast/
logs/

.env

Expand Down
5 changes: 5 additions & 0 deletions bolt-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ The Bolt smart contracts cover the following components:
- Flexible restaking integrations for staking pools and node operators
- (WIP) Fault proof challenge and slashing logic for validators

### Architecture
A high-level overview of architecture is depicted in the diagram below:

<img src="./docs/erd.png" width="700"/>

## Validator Registration: `BoltValidators`

The [`BoltValidators`](./src/contracts/BoltValidators.sol) contract is the only point of entry for
Expand Down
12 changes: 12 additions & 0 deletions bolt-contracts/config/config.holesky.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"epochDuration": 86400,
"slashingWindow": 604800,
"maxChallengeDuration": 604800,
"challengeBond": 1000000000000000000,
"blockhashEvmLookback": 256,
"justificationDelay": 32,
"eth2GenesisTimestamp": 1694786400,
"slotTime": 12,
"allowUnsafeRegistration": true,
"minimumOperatorStake": 1000000000000000000
}
12 changes: 12 additions & 0 deletions bolt-contracts/config/config.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"epochDuration": 86400,
"slashingWindow": 604800,
"maxChallengeDuration": 604800,
"challengeBond": 1000000000000000000,
"blockhashEvmLookback": 256,
"justificationDelay": 32,
"eth2GenesisTimestamp": 1606824023,
"slotTime": 12,
"allowUnsafeRegistration": true,
"minimumOperatorStake": 1000000000000000000
}
Binary file added bolt-contracts/docs/erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion bolt-contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read-write", path = "./" }]
gas_reports = ["*"]
# Required options for the OpenZeppelin Foundry Upgrades toolkit: https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
ffi = true
ast = true
build_info = true
extra_output = ["storageLayout"]

# silence some warnings during compilation
# https://book.getfoundry.sh/reference/config/solidity-compiler#ignored_error_codes
Expand All @@ -21,7 +26,9 @@ remappings = [
"@relic/=lib/relic-sdk/packages/contracts",
"@symbiotic/=lib/core/src/",
"@eigenlayer/=lib/eigenlayer-contracts/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@openzeppelin-foundry-upgrades/=lib/openzeppelin-foundry-upgrades/",

# Symbiotic remappings contexts
"lib/core/:forge-std/=lib/core/lib/forge-std/src/",
Expand All @@ -41,6 +48,7 @@ remappings = [
"lib/openzeppelin-contracts/:@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
]


[rpc_endpoints]
mainnet = "${ETH_RPC_URL}"
holesky = "${ETH_RPC_URL_HOLESKY}"
Expand Down
1 change: 1 addition & 0 deletions bolt-contracts/lib/openzeppelin-foundry-upgrades
47 changes: 0 additions & 47 deletions bolt-contracts/script/Deploy.s.sol

This file was deleted.

127 changes: 127 additions & 0 deletions bolt-contracts/script/deploy/holesky/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {Script, console} from "forge-std/Script.sol";

import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import {Upgrades} from "@openzeppelin-foundry-upgrades/src/Upgrades.sol";

import {BoltParameters} from "../../../src/contracts/BoltParameters.sol";
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 {
function run(
address symbioticNetwork,
address symbioticOperatorRegistry,
address symbioticOperatorNetOptIn,
address symbioticVaultRegistry,
address eigenlayerAVSDirectory,
address eigenlayerDelegationManager,
address eigenlayerStrategyManager
) public {
vm.startBroadcast();

// The admin address will be authorized to call the adminOnly functions
// on the contract implementations, as well as upgrade the contracts.
address admin = msg.sender;

BoltConfig.ParametersConfig memory config = readParameters();

bytes memory initParameters = abi.encodeCall(
BoltParameters.initialize,
(
admin,
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);
console.log("BoltParameters proxy deployed at", parametersProxy);

// Generate the `initialize` call data for the contract.
bytes memory initValidators = abi.encodeCall(BoltValidators.initialize, (admin, parametersProxy));
// Deploy the UUPSProxy through the `Upgrades` library, with the correct `initialize` call data.
address validatorsProxy = Upgrades.deployUUPSProxy("BoltValidators.sol", initValidators);
console.log("BoltValidators proxy deployed at", validatorsProxy);

bytes memory initManager = abi.encodeCall(BoltManager.initialize, (admin, parametersProxy, validatorsProxy));
address managerProxy = Upgrades.deployUUPSProxy("BoltManager.sol", initManager);
console.log("BoltManager proxy deployed at", managerProxy);

bytes memory initEigenLayerMiddleware = abi.encodeCall(
BoltEigenLayerMiddleware.initialize,
(
admin,
parametersProxy,
managerProxy,
eigenlayerAVSDirectory,
eigenlayerDelegationManager,
eigenlayerStrategyManager
)
);
address eigenLayerMiddlewareProxy =
Upgrades.deployUUPSProxy("BoltEigenLayerMiddleware.sol", initEigenLayerMiddleware);
console.log("BoltEigenLayerMiddleware proxy deployed at", eigenLayerMiddlewareProxy);

bytes memory initSymbioticMiddleware = abi.encodeCall(
BoltSymbioticMiddleware.initialize,
(
admin,
parametersProxy,
managerProxy,
symbioticNetwork,
symbioticOperatorRegistry,
symbioticOperatorNetOptIn,
symbioticVaultRegistry
)
);
address symbioticMiddlewareProxy =
Upgrades.deployUUPSProxy("BoltSymbioticMiddleware.sol", initSymbioticMiddleware);
console.log("BoltSymbioticMiddleware proxy deployed at", address(symbioticMiddlewareProxy));

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
});
}
}
Loading
Loading