Skip to content

perun-network/perun-polkadot-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Perun

Perun Polkadot Node

License: Apache 2.0

Perun Polkadot Node demonstrates how to integrate the Perun Pallet into a substrate chain.
It uses the Node template and Frontend template from substrate and configures them for Perun.

Repo Structure

Quickstart

You can use docker to start the node and the frontend to try out the Perun Pallet.

docker-compose build
docker-compose up

The frontend will be available at localhost:8000/substrate-front-end-template.

You can try out different Extrinsic calls in the Pallet Interactor.
This is currently not very practical since hashes and off-chain signatures are required, which are hard to enter manually. Using mocked hashes and sigs could be done here.

Docker images

Instead of building the project yourself, you can use our images and start them individually:

docker run --rm -it -p9944:9944 ghcr.io/perun-network/polkadot-test-node
docker run --rm -it -p8000:8000 ghcr.io/perun-network/polkadot-test-frontend

The frontend will be available at localhost:8000/substrate-front-end-template.

Development

Clone the repository with submodules.

git clone --recurse-submodules https://github.com/perun-network/perun-polkadot-node
cd perun-polkadot-node

Ensure that the Rust toolchain is installed. Then build the node.

cd node
cargo build --release

For testing, run the compiled node binary as follows.

cd node/target/release
./node-template --dev --ws-external --rpc-methods=Unsafe -lruntime=debug

You can start the frontend in a second terminal.

cd frontend
yarn install
yarn start

This should automatically open your browser with localhost:8000/substrate-front-end-template.

Logging

In the node, you can print log messages using frame_support::runtime_print.

frame_support::runtime_print!("CustomValue: {:?}", val);

In order to see the log messages, make sure to run the node with -lruntime=debug.

Benchmarking

This node provides a runtime for benchmarking the Perun Pallet. Enter the node/ directory and run the following command:

cargo run --release --features runtime-benchmarks benchmark --execution wasm --wasm-execution compiled --chain dev --pallet 'pallet_perun' --extrinsic '*' --steps 20 --repeat 10 --raw --output pallets/pallet-perun/src/weights.rs

This will write the updated weights into the weights.rs file of the pallet.
More information can be found in the Substrate Benchmarking Doc.

Installing the Rust toolchain

Check out rust-land.org to install rustup, then adjust your toolchain for this repo:

rustup default stable
rustup update nightly
rustup update stable
rustup target add wasm32-unknown-unknown --toolchain nightly

Funding

The development of this project is supported by the Web3 Foundation through the Open Grants Program.
The development of the go-perun library is supported by the German Ministry of Education and Science (BMBF) through a Startup Secure grant.

Security Disclaimer

This software is still under development. The authors take no responsibility for any loss of digital assets or other damage caused by the use of it.

Copyright

Copyright 2021 PolyCrypt GmbH.
Use of the source code is governed by the Apache 2.0 license that can be found in the LICENSE file.