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.
- Host: GitHub
- URL: https://github.com/tangle-network/protocol-substrate
- Owner: tangle-network
- License: apache-2.0
- Created: 2021-06-09T15:32:03.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-23T17:38:27.000Z (over 2 years ago)
- Last Synced: 2025-03-29T10:23:57.136Z (6 months ago)
- Topics: blockchain, bridge, cryptography, merkle-tree, rust, zero-knowledge
- Language: TypeScript
- Homepage: https://docs.webb.tools/v1/anchor-system/overview/
- Size: 29.7 MB
- Stars: 37
- Watchers: 4
- Forks: 11
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
๐ Webb's Substrate Pallet Implementation ๐[](https://github.com/webb-tools/protocol-substrate/actions) [](https://codecov.io/gh/webb-tools/protocol-substrate) [](https://opensource.org/licenses/Apache-2.0) [](https://twitter.com/webbprotocol) [](https://t.me/webbprotocol) [](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