Giter VIP home page Giter VIP logo

perun-eth-demo's Introduction


Perun

Perun Ethereum Demo CLI

Goreportcard status License: Apache 2.0 CI Testing status

perun-eth-demo allows you to interact with perun Payment-Channels over a CLI powered by go-perun.
You can open a Payment-Channel, send off-chain payments and close it, whereby all interaction with the Ethereum blockchain is handled by go-perun. Give it a try and be amazed by Perun Network 🚀 🌔 !

Security Disclaimer

The authors take no responsibility for any loss of digital assets or other damage caused by the use of this software.
Do not use this software with real funds.

Getting Started

Running perun-eth-demo requires a working Go distribution, see go.mod for the required version. To follow the walkthrough we recommend to also install ganache-cli, but perun-eth-demo works with any ethereum node.

# Clone the repository into a directory of your choice
git clone https://github.com/perun-network/perun-eth-demo
cd perun-eth-demo
# Compile with
go build
# Check that the binary works
./perun-eth-demo

Demo

Currently, the only available sub-command of perun-eth-demo is demo, which starts the CLI node. The node's configuration file can be chosen with the --config flag. Two sample configurations alice.yaml and bob.yaml are provided. A default network configuration for Alice and Bob is provided in file network.yaml.

Example Walkthrough

In a first terminal, start a ganache-cli development blockchain, prefunding the accounts of Alice and Bob derived from the mnemonic seed:

ganache-cli -m "pistol kiwi shrug future ozone ostrich match remove crucial oblige cream critic" --block-time 5 -e 1000

In a second terminal, start the node of Alice with

./perun-eth-demo demo --config alice.yaml

and in a third terminal, start the node of Bob with

./perun-eth-demo demo --config bob.yaml

It is important to start Alice first as she is the one deploying the channel contracts. Bob validates the contracts at startup and quits if the contracts have not been deployed correctly. You can see two transactions in the ganache terminal corresponding to the deployment of the AssetHolder and Adjudicator contracts.

Once both CLIs are running, e.g. in Alice's terminal, propose a payment channel to Bob with 100 ETH deposit from both sides via the following command.

> open bob 100 100

In Alice's terminal, accept the appearing channel proposal.

🔁 Incoming channel proposal from alice with funding [My: 100 Ξ, Peer: 100 Ξ].
Accept (y/n)? > y

In the ganache terminal, you can see two new transactions, which correspond to the funding transactions by Alice and Bob.

Now you can execute off-chain payments, e.g. in Bob's terminal with

> send alice 10

The updated balance will immediately be printed in both terminals, but no transaction will be visible in the ganache's terminal.

You may always check the current status with command info.

You can also run a performance benchmark with command

> benchmark alice 10 100

which will send 10 ETH in 100 micro-transactions from Bob to Alice. Transaction performance will be printed in a table.

Finally, you can settle the channel on either side with

> close alice

which will send one concludeFinal and two withdrawal transactions to the ganache blockchain.

Now you can exit the CLI with command exit.

Copyright

Copyright © 2021 Chair of Applied Cryptography, Technische Universität Darmstadt, Germany. All rights reserved. Use of the source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

Contact us at [email protected].

perun-eth-demo's People

Contributors

cryptphil avatar ggwpez avatar manoranjith avatar matthiasgeihs avatar sebastianst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

perun-eth-demo's Issues

Error when delaying walkthrough

Problem

The following error occurs when when the node commands in the demo walkthrough are delayed by a small amount of time (e.g., 1 minute).

WARN[0188] error while funding channel: fund asset: sending funding tx: mining transaction: sending transaction: context canceled channel=26850eb3bd329f1e44808b687b1f03d1b20888f57cfa2837b62694c2ac93de26 id=0xA298Fc05bccff341f340a11FffA30567a00e651f
ERRO[0188] accepting channel proposal: error while funding channel: fund asset: sending funding tx: mining transaction: sending transaction: context canceled
ERRO[0192] received update for unknown channel channel=26850eb3bd329f1e44808b687b1f03d1b20888f57cfa2837b62694c2ac93de26 id=0xA298Fc05bccff341f340a11FffA30567a00e651f peer=0x05e71027e7d3bd6261de7634cf50F0e2142067C4

Steps to reproduce

  1. Start ganache-cli
  2. Start Alice and Bob nodes
  3. Wait for about 1 minute
  4. Open channel and send ether from Alice to Bob

Error accepting channel proposal when running demo twice without restarting ganache-cli

Problem:

The following error occurs when running the demo walkthrough twice without restarting ganache-cli:

WARN[0007] error while funding channel: fund asset: sending funding tx: depositing asset 0: VM Exception while processing transaction: revert wrong amount of ETH for deposit channel=68c440c697c7b65ab8b43da7f0a11e44362198818846f2a92b6cc66ed0bf021d id=0xA298Fc05bccff341f340a11FffA30567a00e651f
ERRO[0007] accepting channel proposal: error while funding channel: fund asset: sending funding tx: depositing asset 0: VM Exception while processing transaction: revert wrong amount of ETH for deposit

Steps to reproduce:

  1. Start ganache-cli
  2. Start Alice and Bob nodes
  3. Open channel and send ether from Alice to Bob
  4. Close channel and shutdown Alice and Bob
  5. Start Alice and Bob again (don't restart ganache-cli)
  6. Open channel and send ether from Alice to Bob

README: Required Go version incorrect

The README says that go >= 1.15 is required, but in fact the most recent go-perun requires go >= 1.17. Proposal: Do not mention concrete version, just write that go is required. The version requirement can be looked up in go.mod. This is also how we do it in go-perun since recently.

Transaction failure on close channel

when running the demo with ganache-cli --block-time 5, the following warning occurs at bob when alice closes the channel:

WARN[0030] TX failed; error determining reason: CallContract: VM Exception while processing transaction: revert channel already concluded
WARN[0030] Calling conclude(Final) failed, waiting for event anyways... account=0xA298Fc05bccff341f340a11FffA30567a00e651f

"./perun-eth-demo help" returns error

Running ./perun-eth-demo lists help among the available commands, but running ./perun-eth-demo help returns error Error reading config file, open config.yaml: no such file or directory.

Validate chain ID

The demo node (and even go-perun) does not verify the chain id upon startup.
I had multiple problems now with incorrect chain ID, which could easily be fixed.

AppDef config option

Add an option to the config *.yaml files channel.AppDef which defines the App Definition (ethereum Address).

Charon update; enable LevelDB persistence

We should update the demo's go-perun to Charon and also enable persistence (using leveldb) to showcase how it works in practice. Would also deliver an additional good test of our persistence impl.

I propose that we add an additional persistence section to the configuration with a dbpath for the path to the leveldb file and possible additional settings relevant for the leveldb persistence backend.

Could also additionally expose this as a cmdline flag dbpath.

What to you think @ggwpez?

Upgrade to Despina

We did a big refactor in go-perun and moved connection handling out of the client.Client into a wire/net.Bus. The tcp/unix dialer and listener implementations were moved into wire/net/simple. This repo should be updated:

  • Before creating the client, create a net.Bus with a tcp dialer and listener.
  • Start Listening with the net.Bus, not with the client.
  • Pass this bus to the client's constructor instead of a tcp dialer and listener, which were given to the bus before.
  • Client.Reconnect was renamed to Restore and the meaning of this method changed. Use it when persistence is active.

Maybe I forgot something, but this should become apparent while testing.

Use Watcher

If we use the Watcher, the settling of a channel should be handled automatically and it would also work with disputes.

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.