An open API service indexing awesome lists of open source software.

https://github.com/tangle-network/protocol-substrate

Webb protocol implementation in Substrate.
https://github.com/tangle-network/protocol-substrate

blockchain bridge cryptography merkle-tree rust zero-knowledge

Last synced: 6 months ago
JSON representation

Webb protocol implementation in Substrate.

Awesome Lists containing this project

README

          


![Webb Logo](./assets/webb_banner_light.png#gh-light-mode-only)
![Webb Logo](./assets/webb_banner_dark.png#gh-dark-mode-only)



๐Ÿš€ Webb's Substrate Pallet Implementation ๐Ÿš€

[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/webb-tools/protocol-substrate/check.yml?branch=main&style=flat-square)](https://github.com/webb-tools/protocol-substrate/actions) [![Codecov](https://img.shields.io/codecov/c/gh/webb-tools/protocol-substrate?style=flat-square&token=A4WGU76TWU)](https://codecov.io/gh/webb-tools/protocol-substrate) [![License Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0) [![Twitter](https://img.shields.io/twitter/follow/webbprotocol.svg?style=flat-square&label=Twitter&color=1DA1F2)](https://twitter.com/webbprotocol) [![Telegram](https://img.shields.io/badge/Telegram-gray?logo=telegram)](https://t.me/webbprotocol) [![Discord](https://img.shields.io/discord/833784453251596298.svg?style=flat-square&label=Discord&logo=discord)](https://discord.gg/cv8EfJu3Tn)

๐Ÿ“– Table of Contents

Table of Contents

Getting Started ๐ŸŽ‰

For additional information, please refer to the [Webb Protocol-Substrate Rust Docs](https://webb-tools.github.io/protocol-substrate/) ๐Ÿ“. Have feedback on how to improve protocol-substrate? Or have a specific question to ask? Checkout the [Anchor Protocol Feedback Discussion](https://github.com/webb-tools/feedback/discussions/categories/anchor-protocol) ๐Ÿ’ฌ.

### Pallet layout

```
pallets/
|____linkable-tree/ # A module for constructing, modifying and inspecting linkable trees.
|____hasher/ # A module for abstracting over arbitrary hash functions primarily for zero-knowledge friendly hash functions that have potentially large parameters to deal with.
|____mixer/ # A simple module for building Mixers.
|____signature-bridge/ # A module for managing voting, resource, and maintainer composition through signature verification.
|____token-wrapper/ # A module for wrapping pooled assets and minting pool share tokens
|____vanchor/ # A simple module for building variable Anchors.
|____vanchor-handler/ # A module for executing the modification of vanchors.
|____verifier/ # A module for abstracting over arbitrary zero-knowledge verifiers for arbitrary zero-knowledge gadgets
|____xanchor/ # A module for managing the linking process between anchors.
```

### Prerequisites

This guide uses installer and the `rustup` tool to manage the Rust toolchain.
First install and configure `rustup`:

```bash
# Install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Configure
source ~/.cargo/env
```

Configure the Rust toolchain to default to the latest nightly version, and add the nightly wasm target:

```bash
rustup default nightly
rustup update
rustup update nightly
rustup target add wasm32-unknown-unknown --toolchain nightly
```

Great! Now your Rust environment is ready! ๐Ÿš€๐Ÿš€

### Installation ๐Ÿ’ป

Install protobuf-compiler

```bash
# For linux
apt install -y protobuf-compiler

# For macos
brew install protobuf
```

Repo environment setup:

```bash
# clone the repo
git clone git@github.com:webb-tools/protocol-substrate.git

# Fetch fixtures
Run the script in `scripts/fetch-fixtures.sh` file.
```

Build the node in `release mode`:

```bash
cargo build --release
```

## Installation Using Nix ๐Ÿ’ป

1. Install [Nix](https://nixos.org/download.html)
2. Enable Flakes (if you are not already see here: [Flakes](https://nixos.wiki/wiki/Flakes))
3. If you have [`direnv`](https://github.com/nix-community/nix-direnv#installation) installed, everything should work out of the box.
4. Alternatively, you can run `nix flake develop` in the root of this repo to get a shell with all the dependencies installed.
5. Happy hacking!

#### Troubleshooting for Apple Silicon users

Install Homebrew if you have not already. You can check if you have it installed with the following command:

```bash
brew help
```

If you do not have it installed open the Terminal application and execute the following commands:

```bash
# Install Homebrew if necessary https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

# Make sure Homebrew is up-to-date, install openssl
brew update
brew install openssl
```

โ— **Note:** Native ARM Homebrew installations are only going to be supported at `/opt/homebrew`. After Homebrew installs, make sure to add `/opt/homebrew/bin` to your PATH.

```bash
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile
```

In order to build **protocol-substrate** in `--release` mode using `aarch64-apple-darwin` Rust toolchain you need to set the following environment variables:

```bash
echo 'export CC="/opt/homebrew/opt/llvm/bin/clang"' >> ~/.bash_profile
echo 'export AR="/opt/homebrew/opt/llvm/bin/llvm-ar"' >> ~/.bash_profile
```

Usage

### Quick Start โšก

#### Standalone Local Testnet

In order to run the standalone development network, you will need to prepare 2 terminal windows. Once the below commands are executed it will set up a development network using the BABE consensus mechanism for a 2 node network.

**Terminal 1:**

```jsx
./target/release/webb-standalone-node --dev --alice --node-key 0000000000000000000000000000000000000000000000000000000000000001
```

**Terminal 2:**

```jsx
./target/release/webb-standalone-node --dev --bob --port 33334 --tmp --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp
```

You now have successfully set up a standalone local testnet! ๐ŸŽ‰

### Docker ๐Ÿณ

To build the [standalone](./docker/Standalone.Dockerfile) docker image specified in `docker/` :

```sh
docker build -f ./docker/Standalone.Dockerfile -t protocol-substrate/standalone .
```

To run docker image:

```sh
docker run protocol-substrate/standalone
```

Testing ๐Ÿงช

The following instructions outlines how to run the protocol-substrate base test suite and integration test suite.

### To run base tests

```
cargo test --release --workspace --exclude webb-client
```

### To run integration tests

1. Run `cd scripts`
2. Run `sh run-integrations.sh`

### Code Coverage

You need to have docker installed to generate code coverage.

> Build docker image:

```sh
docker build -t cov -f docker/Coverage.Dockerfile .
```

> Run docker image and generate code coverage reports:

```sh
docker run --security-opt seccomp=unconfined cov
```

### Benchmarks

To generate benchmarks for a pallet run

```
cargo b --release --features runtime-benchmarks -p webb-standalone-node

./target/release/webb-standalone-node benchmark pallet \
--chain=dev \
--steps=20 \
--repeat=10 \
--log=warn \
--pallet= \
--extrinsic="*" \
--execution=wasm \
--wasm-execution=compiled \
--output=./pallets/signature-bridge/src/weights.rs \
--template=./.maintain/webb-weight-template.hbs
```

## Contributing

Interested in contributing to protocol-substrate? Thank you so much for your interest! We are always appreciative for contributions from the open-source community!

If you have a contribution in mind, please check out our [Contribution Guide](./.github/CONTRIBUTING.md) for information on how to do so. We are excited for your first contribution!

## License

Licensed under Apache 2.0 license.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache 2.0 license, shall be licensed as above, without any additional terms or conditions.

## Supported by