Skip to content

perun-network/perun-polkadot-pallet

Repository files navigation


Perun

Perun Polkadot Pallet

License: Apache 2.0

Perun Polkadot Pallet provides go-perun state channels for all Substrate compatible blockchains.
Using it in your blockchain means to include it just like any other Substrate Pallet.

Repo Structure

Protocol

A channel is opened by depositing funds for it into the contract by calling Deposit. The participants of the channel can then do as many off-chain channel updates as they want. When all participants come to the conclusion that the channel should be closed, they set the final flag on the channel state, and call ConcludeFinal. All of them can then withdraw the outcome by calling Withdraw.

Dispute. If the participants do not arrive at a final channel state off-chain, they need to resolve a dispute on-chain. This allows any participant to enforce the last valid state, i.e., the mutually-signed state with the highest version number. A dispute is initiated by calling Dispute with the latest available state. A registered state can be refuted within a specified challenge period by calling Dispute with a newer state. After the challenge period, the dispute can be concluded by calling Conclude and the funds can be withdrawn.

On-chain progression. This is an optional phase for channels with an app. It takes place after the dispute registration and allows to update the channel state without full consenus by calling the function Progress.

State diagram

state diagram

Tests

The tests require at least rust version 1.52.0 and can be run with:

cargo test

or in docker:

# Run this each time you change something.
docker build -t perun .
docker run --rm perun

Benchmarking

The benchmarks use cryptographic primitives which are only available in a Substrate node.
A node is provided by the Polkadot Node repo of which this repo is a sub-repo.
Have a look there for instructions on how to run the benchmarks.

Documentation

The in-code documentation can be opened with:

cargo doc --no-deps --open --package pallet-perun

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 2022 PolyCrypt GmbH.
Use of the source code is governed by the Apache 2.0 license that can be found in the LICENSE file.