Skip to content

Commit

Permalink
add ga
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Jan 20, 2024
1 parent bd1d350 commit cfd4602
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 104 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ concurrency:
group: 'pages'
cancel-in-progress: true

env:
GA_ID: ${{ secrets.GA_ID }}

jobs:
# Single deploy job since we're just deploying
deploy:
Expand Down
31 changes: 21 additions & 10 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.0",
"vocs": "latest"
},
"devDependencies": {
"vite-plugin-radar": "^0.9.2"
}
}
1 change: 0 additions & 1 deletion docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: Hyperbridge
description: Hyperbridge Protocol Specification
---


# Introduction

Secure interoperability requires the verification of consensus proofs, consensus fault proofs, and state transition validity proofs. Blockchains that want to securely communicate with each other must perform these operations onchain, so that they can be convinced of the finalized (irreversable) state of their counterparty. Finally, through the use of state of state proofs, they are then able to read the outgoing messages queue of their counter party.
Expand Down
43 changes: 23 additions & 20 deletions docs/pages/network/node.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ title: Node Operators
description: Running the Hyperbridge node
---


# Running a node

We provide a variety of ways to obtain a node for running. For now we only officially support x86 linux environments.
Expand All @@ -12,7 +11,6 @@ We provide a variety of ways to obtain a node for running. For now we only offic

Since hyperbridge is a substrate-based blockchain, it has the same hardware requirements as the [Polkadot validator node](https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#requirements).


## Docker

Hyperbridge is available at the official docker repository [`polytopelabs/hyperbridge`](https://hub.docker.com/r/polytopelabs/hyperbridge)
Expand Down Expand Up @@ -42,30 +40,32 @@ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/polytope-labs/hyperbrid

You can follow the steps below if you'd prefer to build the hyperbridge node from source:

::::steps
::::steps

### Install Dependencies

Builinding the hyperbridge node requires some dependencies
- git
- clang
- curl
- make
- build-essential
- libssl-dev
- llvm
- libudev-dev
- protobuf-compiler

Building the hyperbridge node requires some dependencies

- git
- clang
- curl
- make
- build-essential
- libssl-dev
- llvm
- libudev-dev
- protobuf-compiler

:::code-group

```bash [Debian]
sudo apt install --assume-yes git clang curl libssl-dev llvm libudev-dev make protobuf-compiler
```

```bash [Arch]
pacman -Syu --needed --noconfirm curl git clang make protobuf
```

```bash [Fedora]
sudo dnf update
sudo dnf install clang curl git openssl-devel make protobuf-compiler
Expand All @@ -74,6 +74,7 @@ sudo dnf install clang curl git openssl-devel make protobuf-compiler
```bash [Opensuse]
sudo zypper install clang curl git openssl-devel llvm-devel libudev-devel make protobuf
```

:::

### Install rust compiler
Expand All @@ -83,6 +84,7 @@ If you don't have an already existing rust installation, you can install it usin
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

### Install WebAssembly target

Hyperbridge's blockchain runtime compiles to wasm which allows it's code to be forklessly upgraded. In order to build hyperbridge we need the wasm toolchain installed.
Expand All @@ -101,16 +103,17 @@ git clone https://github.com/polytope-labs/hyperbridge.git
cd ./hyperbidge
git checkout v0.2.0
```

### Build the node

```bash
cargo build --release -p hyperbridge
```

::::

## Running the node

```bash
hyperbridge --chain=messier --enable-offchain-indexing --base-path=$HOME/.hyperbridge --pruning-archive
```
```
4 changes: 1 addition & 3 deletions docs/pages/network/relayer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ title: Relayers
description: Running the tesseract relayer
---


# Running a relayer

Critical to the function of Hyperbridge are relayers who transmit requests & responses across it's connected chains. These relayers much like node operators earn rewards for relaying requests. Since requests are paid for ahead of time on the source chain by the initiating application. Relayers can relay these requests and redeem their fees on the source chain. This works by the relayer showing state proofs to the hyperbridge parachain of their successful delivery. Hyperbridge then authorizes the release of the fees to the relayer on the source chain.


## Installation

The tesseract relayer is available through the following methods
Expand All @@ -29,4 +27,4 @@ docker run polytopelabs/tesseract:latest --config=/path/to/config

Unfortunately, tesseract is closed-souce for now.

## Running the relayer
## Running the relayer
37 changes: 17 additions & 20 deletions docs/pages/protocol/consensus.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ description: The ISMP protocol specification for consensus clients

# Blockchains as State Machines

<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
rel="stylesheet"
/>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" rel="stylesheet" />


In a generalised blockchain model, we can describe a blockchain with blocks $B_1, B_2, B_3 \dots B_n$ as a state machine. To create new blocks, we apply a *state transition function* to the state $S_i$ at block height $B_i$ with a transaction list $T_i$, which results in some new state $S_{i+1}$. This can be more formally expressed as follows:
In a generalised blockchain model, we can describe a blockchain with blocks $B_1, B_2, B_3 \dots B_n$ as a state machine. To create new blocks, we apply a _state transition function_ to the state $S_i$ at block height $B_i$ with a transaction list $T_i$, which results in some new state $S_{i+1}$. This can be more formally expressed as follows:

$$
transition(S_i, T_i) = S_{i+1}
$$

This transactions list $T_i$ can be seen as a list of database transactions $\{t_1, t_{2}, t_{3} \dots t_n\}$
Expand All @@ -26,12 +28,13 @@ This transactions list $T_i$ can be seen as a list of database transactions $\{t
<figcaption>Each block holds a new state.</figcaption>
</figure>


> There may potentially be multiple state transitions for a given block, as you can see in the diagram: $B_3$, $B_4$, $B_5$ all have multiple state transitions. This is where the role of a consensus algorithm aka *fork choice rule* comes into play.
>
> There may potentially be multiple state transitions for a given block, as you can see in the diagram: $B_3$, $B_4$, $B_5$ all have multiple state transitions. This is where the role of a consensus algorithm aka _fork choice rule_ comes into play.
<figure>
<img src="/consensus.svg" alt="Consensus is denoted by the blocks marked as green." />
<img
src="/consensus.svg"
alt="Consensus is denoted by the blocks marked as green."
/>
<figcaption>Consensus is denoted by the blocks marked as green.</figcaption>
</figure>

Expand All @@ -41,15 +44,13 @@ ISMP's messaging abstraction is built on top of the `ConsensusClient`. We refer

This document formally defines the `ConsensusClient`, which serves as an oracle for the canonical state of a state machine, and the corresponding handlers which are used to modify the state of the consensus client.


## `ConsensusState`

We define the `ConsensusState` as the minimum data required by consensus clients in order to verify incoming consensus messages and advance it's view of the state machines running on this consenus system.

## `StateCommitment`

We define the `StateCommitment` as a succinct, cryptographic commitment to the entire blockchain state at an arbitrary block height. The state scheme used to derive this commitment must support partial reveals proofs that have a complexity of $O(\log_n)$ or better. This state commitment is also colloquially known as the *state_root*.

We define the `StateCommitment` as a succinct, cryptographic commitment to the entire blockchain state at an arbitrary block height. The state scheme used to derive this commitment must support partial reveals proofs that have a complexity of $O(\log_n)$ or better. This state commitment is also colloquially known as the _state_root_.

## `ConsensusClient`

Expand All @@ -61,7 +62,6 @@ The consensus client is one half of a full blockchain client. It verifies only c

The quest for a mechanism by which a consensus client may observe and come to conclusions about the canonical state of another blockchain leads us to understand the concept of safety in distributed systems. We elaborate further on this in our research article on consensus proofs $^{[1]}$. In summary, we show that safety in on-chain consensus clients will require the use of a challenge window, even after consensus proof verification. This allows us to detect potential Byzantine behavior that may arise without the challenge window in place.


```rust
/// The consensus state of the consensus client
type ConsensusState = Vec<u8>;
Expand Down Expand Up @@ -130,7 +130,6 @@ pub trait Id {

The ISMP consensus subsystem exposes a set of `handlers`, which can be seen as transactions that allows offchain parties to manage the state of it's various consensus clients.


### `create_client`

```rust
Expand Down Expand Up @@ -169,7 +168,7 @@ where
}
```

The `create_client` method is used by offchain parties to initialize a consensus client. This contains a subjectively chosen initial state for the consensus client. A sort of trusted setup for the initiated. Because it is subjectively chosen, it is recommended that this message is initiated either by the "admin" of the state machine or through a quorum of votes which allows the network to properly audit the contents of the initial consensus state. The handler for this message simply persists the consensus client and all of it's intermediate states as is to storage.
The `create_client` method is used by offchain parties to initialize a consensus client. This contains a subjectively chosen initial state for the consensus client. A sort of trusted setup for the initiated. Because it is subjectively chosen, it is recommended that this message is initiated either by the "admin" of the state machine or through a quorum of votes which allows the network to properly audit the contents of the initial consensus state. The handler for this message simply persists the consensus client and all of it's intermediate states as is to storage.

### `update_client`

Expand All @@ -196,9 +195,9 @@ where

The `update_client` method is responsible for advancing the state of the consensus client. This performs the consensus verification of new `StateCommitment`s that have been finalized by a `StateMachine`'s consensus system. The `IsmpHost` must return the concrete implementation of the associated `ConsensusClient` and a previously stored `ConsensusState`. The procedure for updating the consensus client is as follows.

- First the handler must assert that the consensus state is not within a challenge period. The challenge period is enforeced every time a new consensus update is processed and is configured on a per-consensus state basis.
- Next the handler must assert that the consensus client is not yet frozen. ie The last time the consensus client was updated hasn't exceeded the chain's unbonding period. This effectively mitigates any potential long fork attacks that may arise due to a loss of liveness of consensus clients.
- Finally the handler may perform consensus proof verification using the concrete implementation for the consensus client. If verifications pass, the udpated `ConsensusState` and `IntermediateState`s are persisted to storage and enter a new challenge period.
- First the handler must assert that the consensus state is not within a challenge period. The challenge period is enforeced every time a new consensus update is processed and is configured on a per-consensus state basis.
- Next the handler must assert that the consensus client is not yet frozen. ie The last time the consensus client was updated hasn't exceeded the chain's unbonding period. This effectively mitigates any potential long fork attacks that may arise due to a loss of liveness of consensus clients.
- Finally the handler may perform consensus proof verification using the concrete implementation for the consensus client. If verifications pass, the udpated `ConsensusState` and `IntermediateState`s are persisted to storage and enter a new challenge period.

### `freeze_client`

Expand All @@ -222,7 +221,7 @@ where
}
```

The `freeze_client` method is used to prove the existence of a consensus fault to an onchain consensus client. This message will be sent by offchain parties, colloquially known as *fishermen* when they detect the existence of two conflicting views of the network backed by consensus proofs. This may arise from double signing or eclipse attacks. The consensus client after successfully verifying the validity of the conflicting views of the network will go into a frozen state. In this state it can no longer process new consensus messages as well as new requests & responses. Frozen consensus clients cannot be unfrozen and a new consensus client must be initialized through the `create_client` method instead.
The `freeze_client` method is used to prove the existence of a consensus fault to an onchain consensus client. This message will be sent by offchain parties, colloquially known as _fishermen_ when they detect the existence of two conflicting views of the network backed by consensus proofs. This may arise from double signing or eclipse attacks. The consensus client after successfully verifying the validity of the conflicting views of the network will go into a frozen state. In this state it can no longer process new consensus messages as well as new requests & responses. Frozen consensus clients cannot be unfrozen and a new consensus client must be initialized through the `create_client` method instead.

## Events

Expand Down Expand Up @@ -254,8 +253,6 @@ struct ConsensusClientFrozen {

A `ConsensusClientFrozen` event is emitted after a consensus fault is successfully verified and the offending client frozen. This should instruct relayers to shut down any tasks for relaying requests from the byzantine network to the host network.



## References

$^{[1]}$ [Consensus Proofs, Polytope Labs Research](https://research.polytope.technology/consensus-proofs)
4 changes: 2 additions & 2 deletions docs/pages/protocol/dispatcher.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: The ISMP request-response dispatcher interface

# ISMP Dispatcher

The dispatcher is the public interface which `IsmpModule`s use to *dispatch* requests and responses. It is also responsible for committing the outgoing requests and responses to storage. It may do so in an overlay tree or the underlying state trie. This ensures that state proofs maybe obtained for dispatched requests and responses. The dispatcher should also emit relevant events after any dispatch operation. The interface for the Ismp Dispatcher is
The dispatcher is the public interface which `IsmpModule`s use to _dispatch_ requests and responses. It is also responsible for committing the outgoing requests and responses to storage. It may do so in an overlay tree or the underlying state trie. This ensures that state proofs maybe obtained for dispatched requests and responses. The dispatcher should also emit relevant events after any dispatch operation. The interface for the Ismp Dispatcher is

```rust
/// Simplified POST request, intended to be used for sending outgoing requests
Expand Down Expand Up @@ -85,4 +85,4 @@ pub enum Event {
/// Emitted for an outgoing request
Request(Request),
}
```
```
11 changes: 7 additions & 4 deletions docs/pages/protocol/host.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ title: The Host Interface
description: The Host interface specification for ISMP compatible host state machines.
---


<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" rel="stylesheet" />
<link
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
rel="stylesheet"
/>

# The Host Interface

The `IsmpHost` defines the storage interface that is used by the ISMP handlers. These handlers are tasked with modifying the host and executing the relevant storage operations for a particular *handler message*. The host assumes that all key-value pairs will be stored in a *state trie*$^{[1]}$. Where a *state commitment* and *state proof* can be obtained to verify their existence or lack thereof.
The `IsmpHost` defines the storage interface that is used by the ISMP handlers. These handlers are tasked with modifying the host and executing the relevant storage operations for a particular _handler message_. The host assumes that all key-value pairs will be stored in a _state trie_$^{[1]}$. Where a _state commitment_ and _state proof_ can be obtained to verify their existence or lack thereof.

Notably, the handlers are agnostic to the underlying storage mechanism and allows for the storage of requests and responses in an overlay tree. This overlay tree can be selected to minimize the state proof verification cost, consequently reducing the verification cost of outgoing requests and responses.

Expand Down Expand Up @@ -192,6 +194,7 @@ pub trait IsmpHost {
fn ismp_router(&self) -> Box<dyn IsmpRouter>;
}
```

## References

$^{[1]}$ [State (Machine) Proofs, Polytope Labs Research](https://research.polytope.technology/state-(machine)-proofs)
$^{[1]}$ [State (Machine) Proofs, Polytope Labs Research](<https://research.polytope.technology/state-(machine)-proofs>)
Loading

0 comments on commit cfd4602

Please sign in to comment.