Skip to content

tangle-network/protocol-substrate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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

GitHub Workflow Status Codecov License Apache 2.0 Twitter Telegram Discord

πŸ“– Table of Contents

Table of Contents

Getting Started πŸŽ‰

For additional information, please refer to the Webb Protocol-Substrate Rust Docs πŸ“. Have feedback on how to improve protocol-substrate? Or have a specific question to ask? Checkout the Anchor Protocol Feedback Discussion πŸ’¬.

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 https://rustup.rs installer and the rustup tool to manage the Rust toolchain. First install and configure rustup:

# 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:

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

# For linux
apt install -y protobuf-compiler

# For macos
brew install protobuf

Repo environment setup:

# 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:

cargo build --release

Installation Using Nix πŸ’»

  1. Install Nix
  2. Enable Flakes (if you are not already see here: Flakes)
  3. If you have direnv 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:

brew help

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

# 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.

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:

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:

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

Terminal 2:

./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 image specified in docker/ :

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

To run docker image:

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:

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

Run docker image and generate code coverage reports:

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=<pallet_name> \
--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 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