Coder Social home page Coder Social logo

perun-network / perun-polkadot-pallet Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 1.0 422 KB

Perun channels on Polkadot.

Home Page: https://perun.network/

License: Apache License 2.0

Dockerfile 0.18% Rust 99.82%
perun channels blockchain polkadot substrate

perun-polkadot-pallet's Introduction


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.

perun-polkadot-pallet's People

Contributors

ggwpez avatar matthiasgeihs avatar rmbrt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

perun-polkadot-pallet's Issues

Add MaxNumParts

The number of participants, and therefore the number of off-chain signatures is currently not limited.
The implementer should also check for other cases of arbitrary long inputs.

To get some deterministic bench-marking results, all inputs should have defined maximum lengths.

Recover funds after failed funding

Currently, the Pallet does not allow to recover funds from an unfunded channel. A dispute conclusion will just fail in this case.

ensure!(sum_deposit >= sum_outcome, Error::<T>::InsufficientDeposits);

We need to revise the Pallet so that we payout the initial deposits in case of an underfunded channel.

Transactional conclusion

Currently, the conclude functionality has two writes:

  1. Set the outcome.
  2. Conclude the registered state.

Problem: There is a risk that the first transaction goes through, while the second fails. In this case we might end up in an inconsistent state.

We need to investigate further whether the current solution is problematic and if so, how to resolve the situation. Maybe using the transaction decorator might be a solution, as pointed out here.

Store hash of state instead of full state

Currently, we store the full state on-chain. However, as an optimization we could only store the hash of the state and provide the state always in the calldata. Then we simply check whether the hash of the provided state matches the hash in the state registry. Thereby we save on-chain storage.

Think about disputing unfunded channels

It is currently possible to dispute channels that were never funded. This could be used to inflate the on-chain state.
Im not sure if it is really a problem but it seems weird since the on-chian state should be minimal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.