Skip to content

Commit

Permalink
feat(contracts): symbiotic setup scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Bostoen committed Oct 17, 2024
1 parent 9b112a7 commit f55fbd6
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 3 deletions.
5 changes: 4 additions & 1 deletion bolt-contracts/config/holesky/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"network": "0xAdFC41729fF447974cE27DdFa358A0f2096c3F39",
"operatorRegistry": "0xAdFC41729fF447974cE27DdFa358A0f2096c3F39",
"networkOptInService": "0xF5AFc9FA3Ca63a07E529DDbB6eae55C665cCa83E",
"vaultFactory": "0x5035c15F3cb4364CF2cF35ca53E3d6FC45FC8899"
"vaultFactory": "0x5035c15F3cb4364CF2cF35ca53E3d6FC45FC8899",
"networkRegistry": "0xac5acD8A105C8305fb980734a5AD920b5920106A",
"networkMiddlewareService": "0x683F470440964E353b389391CdDDf8df381C282f",
"networkMiddleware": ""
},
"eigenLayer": {
"avsDirectory": "0x055733000064333CaDDbC92763c58BF0192fFeBf",
Expand Down
31 changes: 29 additions & 2 deletions bolt-contracts/docs/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,46 @@ There are 2 JSON configuration files:
- [`config/holesky/parameters.json`](../config/holesky/parameters.json): contains the launch parameters for `BoltParameters`.


## Deploy Script
## Deployment Guide
Make sure we have a full compilation for the Foundry Upgrades Toolkit:
```bash
forge clean && forge build
```

Run the following script to test deployment on an Anvil fork:
And have a local Anvil fork running to test and validate deployments:

```bash
anvil --fork-url $HOLESKY_RPC
```

### Pre-deployment

Register a Symbiotic network for Bolt with the Symbiotic `NetworkRegistry`. The private key with which the script is run will determine the network address. This private key will also need to be used later.

```bash
forge script script/holesky/SymbioticSetup.s.sol $HOLESKY_RPC --private-key $NETWORK_PRIVATE_KEY --broadcast -vvvv --sig "run(string memory arg)" registerNetwork
```

### Deployment

Run the following script to test deployment on the Anvil fork:
```bash
forge script script/holesky/Deploy.s.sol --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv
```

Run the following script to deploy Bolt V1:
```bash
forge script script/holesky/Deploy.s.sol --rpc-url $HOLESKY_RPC --private-key $PRIVATE_KEY --broadcast -vvvv
```

This will deploy all the contracts. Now update `deployments.json` with the Symbiotic middleware, because we'll need to register it
in the next step.

### Post-deployment

Register the deployed `SymbioticMiddleware` with the Symbiotic `NetworkMiddlewareService`. IMPORTANT: this script needs
to be run with the network private key!

```bash
forge script script/holesky/SymbioticSetup.s.sol $HOLESKY_RPC --private-key $NETWORK_PRIVATE_KEY --broadcast -vvvv --sig "run(string memory arg)" registerMiddleware
```
60 changes: 60 additions & 0 deletions bolt-contracts/script/holesky/helpers/SymbioticSetup.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

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

import {BoltConfig} from "../../../src/lib/Config.sol";

import {INetworkRegistry} from "@symbiotic/interfaces/INetworkRegistry.sol";
import {INetworkMiddlewareService} from "@symbiotic/interfaces/service/INetworkMiddlewareService.sol";

/// forge script script/holesky/SymbioticSetup.s.sol --rpc-url $RPC_HOLESKY --private-key $NETWORK_PRIVATE_KEY --broadcast -vvvv --sig "run(string memory arg)" registerNetwork
/// forge script script/holesky/SymbioticSetup.s.sol --rpc-url $RPC_HOLESKY --private-key $NETWORK_PRIVATE_KEY --broadcast -vvvv --sig "run(string memory arg)" registerMiddleware
contract SymbioticSetup is Script {
function run(
string memory arg
) public {
address networkAdmin = msg.sender;
console.log("Deploying with network admin", networkAdmin);

vm.startBroadcast();

if (keccak256(abi.encode(arg)) == keccak256(abi.encode("registerNetwork"))) {
INetworkRegistry networkRegistry = INetworkRegistry(readNetworkRegistry());

networkRegistry.registerNetwork();
} else if (keccak256(abi.encode(arg)) == keccak256(abi.encode("registerMiddleware"))) {
INetworkMiddlewareService middlewareService = INetworkMiddlewareService(readMiddlewareService());

address middleware = readMiddleware();

middlewareService.setMiddleware(middleware);
}

vm.stopBroadcast();
}

function readNetworkRegistry() public view returns (address) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/network-registry.json");
string memory json = vm.readFile(path);

return vm.parseJsonAddress(json, ".networkRegistry");
}

function readMiddlewareService() public view returns (address) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/config/holesky/middleware-service.json");
string memory json = vm.readFile(path);

return vm.parseJsonAddress(json, ".networkMiddlewareService");
}

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

return vm.parseJsonAddress(json, ".networkMiddleware");
}
}
5 changes: 5 additions & 0 deletions bolt-contracts/src/lib/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ library BoltConfig {
address eigenLayerDelegationManager;
address eigenLayerStrategyManager;
}

struct SymbioticDeployments {
address symbioticNetworkRegistry;
address symbioticNetworkMiddlewareService;
}
}

0 comments on commit f55fbd6

Please sign in to comment.