generated from ethereum-optimism/.github
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add op-conductor-ops script with updated readme and example con…
…fig file (#44)
- Loading branch information
Showing
10 changed files
with
950 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# op-conductor-ops | ||
|
||
op-conductor-ops is a CLI tool for managing op-conductor sequencer clusters. | ||
|
||
**WARNING!!! This tool can cause a network outage if used improperly. Please consult #pod-devinfra before using.** | ||
|
||
## Setup | ||
|
||
Requires [poetry](https://github.com/python-poetry/poetry). | ||
|
||
Install python dependencies with `poetry install`. | ||
|
||
## Usage | ||
|
||
After installing dependencies with `poetry`, the tool can be invoked with `./op-conductor-ops`, | ||
which just calls `poetry run python main.py` and passes on any arguments. | ||
|
||
### Example Usage | ||
|
||
* Example usage with implicit config file with lookup at ./config.toml | ||
```./op-conductor-ops status <network-name>``` | ||
|
||
* Usage with explicit path to config and certificate | ||
```./op-conductor-ops -c ./<path>/config.toml --cert ./<path>/cacert.pem <command> <network-name>``` | ||
|
||
## Example Configuration File: example.config.toml | ||
|
||
This configuration file is used to set up the networks and sequencers for your application. | ||
|
||
### Structure | ||
|
||
The configuration file is divided into two main sections: | ||
|
||
1. **Networks**: This section defines the networks that your application will use. There is an example network configuration (`op-network-1`) and a blank network configuration (`op-network-N`) for you to fill out. | ||
|
||
2. **Sequencers**: This section defines the sequencers for each network. Again, there is an example sequencer configuration for `op-network-1` and a blank sequencer configuration for `op-network-N`. | ||
|
||
Is is recommended to update the network name and sequencer names for your specifc configuration in the toml object declaration | ||
|
||
### Config Usage | ||
|
||
1. Copy this file to `config.toml` in your application's root directory. | ||
2. Modify the example configurations or fill out the blank configurations as needed for your application. | ||
3. Save the `config.toml` file and use it to configure your application's networks and sequencers. | ||
|
||
Remember, the example configurations are provided for your convenience, but you should review and update them to match your specific requirements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from network import Network | ||
from sequencer import Sequencer | ||
import toml | ||
|
||
|
||
def read_config(config_path: str) -> tuple[dict[str, Sequencer], str]: | ||
config = toml.load(config_path) | ||
|
||
cert_path = config.get('cert_path', "") | ||
|
||
# load sequencers into a map | ||
sequencers = {} | ||
for name, seq_config in config['sequencers'].items(): | ||
sequencers[name] = Sequencer( | ||
sequencer_id=name, | ||
raft_addr=seq_config['raft_addr'], | ||
conductor_rpc_url=seq_config['conductor_rpc_url'], | ||
node_rpc_url=seq_config['node_rpc_url'], | ||
voting=seq_config['voting'] | ||
) | ||
|
||
# Initialize network, with list of sequencers | ||
networks = {} | ||
for network_name, network_config in config['networks'].items(): | ||
network_sequencers = [sequencers[seq_name] | ||
for seq_name in network_config['sequencers']] | ||
networks[network_name] = Network(network_name, network_sequencers) | ||
|
||
return networks, cert_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Path to the SSL/TLS certificate file | ||
cert_path = "./cacert.pem" | ||
|
||
# Network configurations | ||
[networks] | ||
|
||
# Example network configuration | ||
[networks.op-network-1] | ||
sequencers = [ | ||
"op-network-1-sequencer-0", | ||
"op-network-1-sequencer-1", | ||
"op-network-1-sequencer-2", | ||
] | ||
|
||
# Blank network configuration | ||
[networks.op-network-N] | ||
sequencers = [ | ||
"op-network-N-sequencer-0", | ||
"op-network-N-sequencer-1", | ||
"op-network-N-sequencer-2", | ||
] | ||
|
||
# Sequencer configurations | ||
[sequencers] | ||
|
||
# Example sequencer configuration for op-network-1 with three sequencers | ||
[sequencers.op-network-1-sequencer-0] | ||
raft_addr = "op-network-1-sequencer-0-op-conductor-raft:50050" | ||
conductor_rpc_url = "https://op-network-1-sequencer-0-op-conductor" | ||
node_rpc_url = "https://op-network-1-sequencer-0-op-node" | ||
voting = true | ||
|
||
[sequencers.op-network-1-sequencer-1] | ||
raft_addr = "op-network-1-sequencer-1-op-conductor-raft.50050" | ||
conductor_rpc_url = "https://op-network-1-sequencer-1-op-conductor" | ||
node_rpc_url = "https://op-network-1-sequencer-1-op-node" | ||
voting = false | ||
|
||
[sequencers.op-network-1-sequencer-2] | ||
raft_addr = "op-network-1-sequencer-2-op-conductor-raft:50050" | ||
conductor_rpc_url = "https://op-network-1-sequencer-2-op-conductor" | ||
node_rpc_url = "https://op-network-1-sequencer-2-op-node" | ||
voting = true | ||
|
||
# Blank sequencer configuration for op-network-N with three blank sequencers | ||
[sequencers.op-network-N-sequencer-0] | ||
raft_addr = "" | ||
conductor_rpc_url = "" | ||
node_rpc_url = "" | ||
voting = true | ||
|
||
[sequencers.op-network-N-sequencer-1] | ||
raft_addr = "" | ||
conductor_rpc_url = "" | ||
node_rpc_url = "" | ||
voting = true | ||
|
||
[sequencers.op-network-N-sequencer-2] | ||
raft_addr = "" | ||
conductor_rpc_url = "" | ||
node_rpc_url = "" | ||
voting = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import concurrent.futures | ||
|
||
|
||
class Network: | ||
def __init__(self, name, sequencers): | ||
self.name = name | ||
self.sequencers = sequencers | ||
|
||
def update(self): | ||
def _update(sequencer): | ||
sequencer.update() | ||
with concurrent.futures.ThreadPoolExecutor() as executor: | ||
list(executor.map(_update, self.sequencers)) | ||
|
||
def get_sequencer_by_id(self, sequencer_id: str): | ||
return next( | ||
( | ||
sequencer | ||
for sequencer in self.sequencers | ||
if sequencer.sequencer_id == sequencer_id | ||
), | ||
None, | ||
) | ||
|
||
def find_conductor_leader(self): | ||
return next( | ||
(sequencer for sequencer in self.sequencers if sequencer.conductor_leader), | ||
None, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
poetry run python op-conductor-ops.py "${@}" |
Oops, something went wrong.