Skip to content

Commit

Permalink
Add QGB docs (#668)
Browse files Browse the repository at this point in the history
* docs: add QGB docs

* fix: anchor links in imported markdown, tables

* style: add category under Validator for QGB

* align with celestiaorg/orchestrator-relayer#295

* feat: add markdown import to build command

* docs: update markdown files

* add intro section TODO

* reformat menu

* docs: add intro section

* fix: linting from source as test

* add back QGB to titles for clarity

* edit copy of intro

* update from source

* manually add changes from celestiaorg/orchestrator-relayer#334

* add intro and diagrams from #279

* linting

* add "install" section, add variable for QGB for golang, and link to internal pages

* match celestiaorg/orchestrator-relayer#337
  • Loading branch information
jcstein authored Apr 28, 2023
1 parent 4a3bcde commit 52c4520
Show file tree
Hide file tree
Showing 19 changed files with 17,654 additions and 70 deletions.
2 changes: 1 addition & 1 deletion docs/nodes/relayer.md → docs/nodes/ibc-relayer.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_label: Relayer
sidebar_label: IBC Relayer
---

# Relaying
Expand Down
39 changes: 39 additions & 0 deletions docs/nodes/qgb-binary.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Install the QGB binary

import constants from "../../versions/constants.js";
import InlineText from "../../src/components/InlineText.js";

The [orchestrator](../qgb-orchestrator) is the software that signs the
QGB attestations, and the [relayer](../qgb-relayer) is the one that
relays them to the target EVM chain.

## Install

1. [Install Go](https://go.dev/doc/install) <InlineText constant={constants.golangQGB} />
2. Clone the `https://github.com/celestiaorg/orchestrator-relayer` repository
3. Install the QGB CLI

```sh
make install
```

## Usage

```sh
# Print help
qgb --help
```

## How to run

If you are a Celestia-app validator, all you need to do is run the
orchestrator. Check [here](../qgb-orchestrator) for more details.

If you want to post commitments on an EVM chain, you will need to deploy
a new QGB contract and run a relayer. Check [here](../qgb-relayer) for
relayer docs and [here](../qgb-deploy) for how to deploy a new QGB
contract.

Note: the QGB P2P network is a separate network than the consensus or
the data availability one. Thus, you will need its specific
bootstrappers to be able to connect to it.
82 changes: 82 additions & 0 deletions docs/nodes/qgb-deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Deploy the QGB contract

<!-- markdownlint-disable MD013 -->

The `deploy` is a helper command that allows deploying the QGB smart contract to a new EVM chain:

```ssh
qgb deploy --help
Deploys the QGB contract and initializes it using the provided Celestia chain
Usage:
qgb deploy <flags> [flags]
qgb deploy [command]
Available Commands:
keys QGB keys manager
Flags:
-c, --celes-grpc string Specify the grpc address (default "localhost:9090")
-d, --evm-address string Specify the EVM account address to use for signing (Note: the private key should be in the keystore)
-z, --evm-chain-id uint Specify the evm chain id (default 5)
-l, --evm-gas-limit uint Specify the evm gas limit (default 25000000)
--evm-passphrase string the evm account passphrase (if not specified as a flag, it will be asked interactively)
-e, --evm-rpc string Specify the ethereum rpc address (default "http://localhost:8545")
-h, --help help for deploy
--home string The qgb deployer home directory
-n, --starting-nonce string Specify the nonce to start the QGB contract from. "earliest": for genesis, "latest": for latest valset nonce, "nonce": for the latest valset before the provided nonce, provided nonce included. (default "latest")
Use "qgb deploy [command] --help" for more information about a command.
```

## How to run

### Install the QGB binary

Make sure to have the QGB binary installed. Check [here](https://docs.celestia.org/nodes/qgb-binary) for more details.

### Add keys

In order to deploy a QGB smart contract, you will need a funded EVM address and its private key. The `keys` command will help you set up this key:

```ssh
qgb deploy keys --help
```

To import your EVM private key, there is the `import` subcommand to assist you with that:

```ssh
qgb deploy keys evm import --help
```

This subcommand allows you to either import a raw ECDSA private key provided as plaintext, or import it from a file. The files are JSON keystore files encrypted using a passphrase like in [here](https://geth.ethereum.org/docs/developers/dapp-developer/native-accounts).

After adding the key, you can check that it's added via running:

```ssh
qgb deploy keys evm list
```

For more information about the `keys` command, check the `keys` documentation in [here](https://github.com/celestiaorg/orchestrator-relayer/blob/main/docs/keys.md).

### Deploy the contract

Now, we can deploy the QGB contract to a new EVM chain:

```ssh
qgb deploy \
-z 4 \
-d 0x27a1F8CE94187E4b043f4D57548EF2348Ed556c7 \
-c localhost:9090 \
-n latest \
-e http://localhost:8545
```

The `latest` can be replaced by the following:

- `latest`: to deploy the QGB contract starting from the latest validator set.
- `earliest`: to deploy the QGB contract starting from genesis.
- `nonce`: you can provide a custom nonce on where you want the QGB to start. If the provided nonce is not a `Valset` attestation, then the one before it will be used to deploy the QGB smart contract.

And, now you will see the QGB smart contract address in the logs along with the transaction hash.
76 changes: 76 additions & 0 deletions docs/nodes/qgb-intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Quantum Gravity Bridge

The Quantum Gravity Bridge, covered previously in the Celestia blog post
found [here](https://blog.celestia.org/celestiums/), introduces the concept
of a Celestium, which is an EVM L2 rollup that uses Celestia for data availability
but settles on Ethereum (or any other EVM L1 chain).

This page and following tutorials will go over the Quantum Gravity
Bridge and how Validators on Celestia can run it.

If you're looking to learn more, you can view the
`orchestrator-relayer` repository
[here](https://github.com/celestiaorg/orchestrator-relayer), and
read more about the QGB
[here](https://github.com/celestiaorg/quantum-gravity-bridge#how-it-works).

## Overview

The Quantum Gravity Bridge (QGB),
consists of two components: an [Orchestrator](../qgb-orchestrator)
and a [Relayer](../qgb-relayer).

In the following diagram, we show how a celestium would post the data to
Celestia. This will later be attested to by the Celestia validator set, and
eventually posted to the target EVM chain (in this case, Ethereum). Then,
the celestium, or any party, will be able to verify the attestations, i.e. valsets
and data commitments, directly on the EVM chain on the QGB smart contract. You can
reference the QGB smart contract
[here](https://github.com/celestiaorg/quantum-gravity-bridge/blob/master/src/QuantumGravityBridge.sol).

![QGB-Architecture](/img/qgb/qgb-diagram.png)

The specification of the QGB `Valset`s, which track the Celestia validator set
changes, can be found in this [ADR](https://github.com/celestiaorg/celestia-app/blob/main/docs/architecture/adr-002-qgb-valset.md).

The QGB data commitments, which represent commitments over sets of blocks
defined by a data commitment window, are
discussed more in-depth in the following
[ADR](https://github.com/celestiaorg/celestia-app/blob/main/docs/architecture/adr-003-qgb-data-commitments.md).

The Orchestrator is part of the Validator setup and works as follows:

* Celestia App: creates an attestation on the state machine level that needs to
be signed
* The Orchestrator: queries the attestation, signs it, then submits the signature
back to Celestia App

The diagram below goes over this process.

![QGB-Orchestrator](/img/qgb/qgb-orchestrator.png)

The Relayer deploys the QGB smart contract first to the EVM L1 chain (if it is
not deployed before), and then relays the attestations from Celestia App to the
EVM L1 Chain.

The diagram below goes over this process.

![QGB-Relayer](/img/qgb/qgb-relayer.png)

You can learn more about the mechanics behind the Relayer in this
[ADR](https://github.com/celestiaorg/celestia-app/blob/main/docs/architecture/adr-004-qgb-relayer-security.md).

## Setting up the QGB

The following sections in this category presume you have the following setup:

* A Celestia App [Validator](../validator-node) running
* A Celestia Node - [Bridge Node](../bridge-node) running

## Next steps

1. [Install the binary](../qgb-binary)
2. [QGB Orchestrator](../qgb-orchestrator)
3. [Key management](../qgb-keys)
4. [QGB Relayer](../qgb-relayer)
5. [Deploy the QGB contract](../qgb-deploy)
Loading

0 comments on commit 52c4520

Please sign in to comment.