Skip to content

Commit

Permalink
fix(docs/cli): add tools section and fix cli devnet commands (#985)
Browse files Browse the repository at this point in the history
This PR adds a tools section to the docs. 

Also fixes omni CLI devnet commands.

task: https://app.asana.com/0/1206208509925075/1207188240612896/f
  • Loading branch information
idea404 authored May 6, 2024
1 parent fdaae16 commit b5b804e
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 23 deletions.
16 changes: 5 additions & 11 deletions cli/cmd/devnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func cleanupDevnet(ctx context.Context) error {
}

func printDevnetInfo(ctx context.Context) error {
// Read the actual devnet external network.json.
// It contains correct portal addrs and external (localhost) RPCs.
network, endpoints, err := loadDevnetNetwork(ctx)
if err != nil {
Expand Down Expand Up @@ -194,14 +193,6 @@ func loadDevnetNetwork(ctx context.Context) (netconf.Network, xchain.RPCEndpoint
return netconf.Network{}, nil, err
}

networkFile := filepath.Join(devnetPath, "network.json")
if _, err := os.Stat(networkFile); os.IsNotExist(err) {
return netconf.Network{}, nil, &cliError{
Msg: "failed to load ~/.omni/devnet/network.json",
Suggest: "Have you run `omni devnet start` yet?",
}
}

endpointsFile := filepath.Join(devnetPath, "endpoints.json")
if _, err := os.Stat(endpointsFile); os.IsNotExist(err) {
return netconf.Network{}, nil, &cliError{
Expand All @@ -224,9 +215,12 @@ func loadDevnetNetwork(ctx context.Context) (netconf.Network, xchain.RPCEndpoint
return netconf.Network{}, nil, errors.Wrap(err, "make portal registry")
}

network, err := netconf.AwaitOnChain(ctx, netID, portalReg, endpoints.Keys())
network, err := netconf.CheckOnChain(ctx, netID, portalReg, endpoints.Keys())
if err != nil {
return netconf.Network{}, nil, errors.Wrap(err, "load network file")
return netconf.Network{}, nil, &cliError{
Msg: "failed to check on-chain registry",
Suggest: "Have you run `omni devnet start` yet?",
}
}

return network, endpoints, nil
Expand Down
2 changes: 1 addition & 1 deletion docs/site/docs/operate/onboarding/client.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 3
---

# Run the Client
Expand Down
8 changes: 7 additions & 1 deletion docs/site/docs/operate/onboarding/register.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
---
sidebar_position: 3
sidebar_position: 2
---

# Omni AVS Contract Registration

:::warning Omni CLI Required

If you haven't installed the Omni CLI yet, you can follow the instructions [here](../../tools/cli/cli.md).

:::

This tells EigenLayer that you'd like to be an operator specifically for the Omni AVS. Thus, the **\$ETH** that you, and your delegators restaked, will be used to secure Omni.

You will need to have an `operator.yml` file to perform this registration. This file is created as part of [registering as an operator with the EigenLayer CLI](https://docs.eigenlayer.xyz/eigenlayer/operator-guides/operator-installation). You should use the same file created then, and don't need to modify it at all.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
---
sidebar_position: 2
sidebar_position: 1
---

# Installing the Omni CLI
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Installation

The Omni CLI will allow you to interact with the Omni network and simplifies the process of performing actions.
The Omni CLI is a command-line interface for managing your Omni projects as a developer and interacting with the network as an operator. This guide will walk you through the installation process.

## Install from Binary

The easiest way to install the Omni CLI is to download the latest release from the [GitHub releases page](https://github.com/omni-network/omni/releases). Once downloaded, you can extract the binary and move it to a location in your $PATH.
The easiest way to install the Omni CLI is to download the latest release from the [GitHub releases page](https://github.com/omni-network/omni/releases). Once downloaded, you can extract the binary and move it to a location in your `$PATH`.

## Install from Script

Expand All @@ -20,9 +23,6 @@ curl -sSfL https://raw.githubusercontent.com/omni-network/omni/main/scripts/inst

## Install from Source

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs>
<TabItem value="source" label="src with make">
```bash
Expand Down
56 changes: 56 additions & 0 deletions docs/site/docs/tools/cli/developer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
sidebar_position: 2
---

# Developer Commands

## Scaffolding a Templated Project

The `developer new` command is used to scaffold a new project from a template. The command can be called from your new project directory with:

```bash
omni developer new
```

This will scaffold a new Forge project with an [`XGreeter`](../../develop/xapp/example.md#xgreeter-contract) contract
accompanied by simple mocked testing and a multi-chain deployment script.

## Starting a Local Devnet

:::info Docker Required

Docker is required to run the local development network. If you don't have Docker installed, you can download it from the [official Docker website](https://docs.docker.com/get-docker/).

:::

The `devnet start` command is used to start a local development network. The command can be called from your project directory with:

```bash
omni devnet start
```

This will start a local development network with a single Omni validator node and Omni EVM, two (rollup) anvil nodes and a relayer node.

All EVM nodes have the same rich accounts as anvils nodes regularly do.

Configuration files are created in `~/.omni/devnet`.

## Get Local Devnet Information

The `devnet info` command is used to obtain information about the local development network. The command can be called from your project directory with:

```bash
omni devnet info
```

This will display information about the local development network, including the chain ID, RPC URLs, and Portal contract addresses.

## Clean Up Local Devnet

The `devnet clean` command is used to clean up the local development network. The command can be called from your project directory with:

```bash
omni devnet clean
```

This will stop and remove the local development network containers and clean up the configuration files.
15 changes: 15 additions & 0 deletions docs/site/docs/tools/cli/operator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
sidebar_position: 3
---

# Operator Commands

## Registering as an Operator

Registers EigenLayer operator to Omni using the `operator.yml` file.

```bash
omni operator register --config-file ~/path/to/operator.yaml
```

Performs a contract call to the RPC URL found in the configuration file to register the operator (using the address variables in the file).
43 changes: 43 additions & 0 deletions docs/site/docs/tools/cli/updating.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
sidebar_position: 4
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Updating

This guide will walk you through the process of updating your Omni CLI to the latest version.

## Update from Binary

Similar to installation, locate the old binary in your `$PATH` and replace it with the new binary. You can download the latest release from the [GitHub releases page](https://github.com/omni-network/omni/releases/).

## Update from Script

You can also update the Omni CLI using the installation script, which will overwrite the binary with the latest version:

```bash
curl -sSfL https://raw.githubusercontent.com/omni-network/omni/main/scripts/install_omni_cli.sh | sh -s
```

## Update from Source

If you have the Omni monorepo, you can update it by installing it from the `main` branch:

<Tabs>
<TabItem value="source" label="src with make">
```bash
git clone https://github.com/omni-network/omni.git
cd omni
make install-cli
```
</TabItem>
<TabItem value="go" label="src with go">
```bash
git clone https://github.com/omni-network/omni.git
cd omni
go install ./cli/cmd/omni
```
</TabItem>
</Tabs>
16 changes: 16 additions & 0 deletions docs/site/docs/tools/contracts/contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
sidebar_position: 1
---

# Contract and dApp Helpers

Omni includes the following Solidity helpers to help you develop your Omni projects:

- [`XApp`](../../develop/xapp/installation.md) - A base contract that provides a set of common functions and variables for your contracts.
- [`XGreeter`](../../develop/xapp/example.md#xgreeter-contract) - A simple contract that demonstrates how to use the `XApp` contract.
- [`XGreeter Template`](https://github.com/omni/omni-forge-template) - A template that you can use to scaffold a new project with an `XGreeter` contract. Used by the Omni CLI `developer new` command.
- [`XRegistry`](https://github.com/omni-network/omni/blob/main/contracts/src/protocol/XRegistry.sol) - A contract that provides a registry for contracts to register themselves.

## Awesome Omni Examples and Templates

See the [Awesome Omni](https://github.com/omni-network/awesome-omni) repo for a list of Omni examples and templates that you can use to get started with your Omni projects.
12 changes: 12 additions & 0 deletions docs/site/docs/tools/tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
sidebar_position: 1
---

# Omni Tools

Omni Tools is a collection of tools that help you manage your Omni projects.

It includes the following tools:

- [Omni CLI](cli/cli.md) - A command-line interface for managing your Omni projects, interacting with the network as an operator.
- [Omni Contracts](contracts/contracts.md) - Smart contracts that you can use while developing your Omni projects.
5 changes: 5 additions & 0 deletions docs/site/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ const config: Config = {
label: "Operate",
to: "/operate/introduction",
},
{
position: "right",
label: "Tools",
to: "/tools",
},
{
href: "https://github.com/omni-network/omni",
label: "GitHub",
Expand Down
57 changes: 54 additions & 3 deletions docs/site/sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const sidebars: SidebarsConfig = {
},
{
type: "html",
value: "<div class='sidebar-separator'></div>",
value: "<p></p><div class='sidebar-separator'></div>",
},
{
type: "category",
Expand Down Expand Up @@ -186,8 +186,16 @@ const sidebars: SidebarsConfig = {
"protocol/future"
],
developSidebar: [
"develop/introduction",
"develop/state",
{
type: "category",
label: "Introduction",
className: "sidebar-title",
collapsible: false,
items: [
"develop/introduction",
"develop/state",
]
},
{
type: "html",
value: "<div class='sidebar-separator'></div>",
Expand Down Expand Up @@ -256,6 +264,49 @@ const sidebars: SidebarsConfig = {
]
}
],
toolsSidebar: [
{
type: "category",
label: "Introduction",
className: "sidebar-title",
collapsible: false,
items: [
"tools/tools",
]
},
{
type: "html",
value: "<div class='sidebar-separator'></div>",
},
{
type: "category",
label: "CLI",
className: "sidebar-title",
collapsible: false,
items: [
{
type: "autogenerated",
dirName: "tools/cli",
}
]
},
{
type: "html",
value: "<div class='sidebar-separator'></div>",
},
{
type: "category",
label: "dApp Utilities",
className: "sidebar-title",
collapsible: false,
items: [
{
type: "autogenerated",
dirName: "tools/contracts",
}
]
},
],
};

export default sidebars;
18 changes: 18 additions & 0 deletions lib/netconf/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ func AwaitOnChain(ctx context.Context, netID ID, portalRegistry *bindings.Portal
}
}

// CheckOnChain returns the network configuration if all expected chains are registered in the on-chain registry.
// It returns an error if the context is canceled or if any of the expected chains are missing.
func CheckOnChain(ctx context.Context, netID ID, portalRegistry *bindings.PortalRegistry, expected []string) (Network, error) {
portals, err := portalRegistry.List(&bind.CallOpts{Context: ctx})
if err != nil {
return Network{}, errors.Wrap(err, "failed fetching xchain registry from omni_evm")
}

network := networkFromPortals(netID, portals)
if !containsAll(network, expected) {
return Network{}, errors.New("xchain registry doesn't contain all expected chains")
}

log.Info(ctx, "XChain network configuration initialized from on-chain registry", "chains", network.ChainNamesByIDs())

return network, nil
}

// containsAll returns true if the network contains the all expected chains (by name or ID).
func containsAll(network Network, expected []string) bool {
want := make(map[string]struct{}, len(expected))
Expand Down

0 comments on commit b5b804e

Please sign in to comment.