Categorygithub.com/hyperledger-labs/perun-node
modulepackage
0.6.2
Repository: https://github.com/hyperledger-labs/perun-node.git
Documentation: pkg.go.dev

# README

Perun Node - Go implementation join the chat

DevelopMain
CircleCICircleCI

Perun is an open source project that aims to increase blockchain transaction throughput by using just a handful of main chain transactions to move an entire peer-to-peer network of activity off the main chain. After an initial setup of a set of basic transaction channels, this network lets any participant transact with any other participant via virtual channels which do not require additional on-chain setup. We do this by implementing the Perun protocol, which has been formally proven to allow for secure off-chain transactions.

Project Status

At the moment the perun-node is neither ready for production nor does it implement the complete perun protocol yet. But with basic features available, the project is at a stage where you can try it out and start to get involved.

This is a complete re-implementation of the previous version (available under the previous name of the project: dst-go) in branch legacy/master. This version builds on top of the go-perun SDK that implements a state channel client based on perun protocol. See Description for more details.

Description

The perun-node is multi-user state channel node that can be used for opening, transacting on and closing state channels. It builds on the state channel client implemented by go-perun and implements the following functionalities:

  1. Payment App: For using perun protocol to establish and use bi-directional payment channels.
  2. ID Provider: For the user to define a list of known participants in the off-chain network.
  3. Key management: For managing the cryptographic keys of the user.
  4. User session: For allowing multiple users to use a single node, each with a dedicated key manager and ID provider.
  5. User API interface: For the user to interact with the perun-node.

The current version provides the following features:

FeatureImplementation
Blockchain BackendEthereum
Key managementEthereum keystore
ID ProviderLocal
User APITwo Party Payment API
User API AdaptergRPC
PersistenceLevelDB
CurrenciesETH, Any ERC20 token

This project currently contains three executable packages located in the cmd directory.

  • perunnode: An app for starting a running instance of perun node. It can also generate configuration artifacts for trying out the node.

  • perunnodecli is an app with interactive CLI interface that serves two purposes:

    • easy way to try out payment channel API.
    • reference implementation for using the generated grpc client stubs for payment channel API.
  • perunnodetui is an app with interactive text based user interface. With visual representation most of the actions, it is easy way to try out payment channel API and understand the perun protocol.

For a tutorial on using perun-node with perunnodecli, see the tutorial section on the project documentation website.

For a tutorial on using perun-node with perunnodetui, see this section. A talk on overview of perun, including a hands-on demo of using the perunnode with perunnodetui can be found here.

Getting Started

Install the following pre-requisites.

1. Go (v1.14 or later).
2. ganache-cli (v6.9.1 or later).

Clone the project and sync the dependencies:

git clone https://github.com/hyperledger-labs/perun-node.git
cd perun-node
go mod tidy

Start the ganache-cli node for running integration tests:

# These funded accounts will be used in tests. "-b 1" configures the
# ganache-cli node to mine one block every second. It is required as our
# contracts use blockchain based timeout for settling a state channel on-chain.
ganache-cli -b 1 \
--account="0x1fedd636dbc7e8d41a0622a2040b86fea8842cef9d4aa4c582aad00465b7acff,100000000000000000000" \
--account="0xb0309c60b4622d3071fad3e16c2ce4d0b1e7758316c187754f4dd0cfb44ceb33,100000000000000000000"

Run the linter and tests from the project root directory:

# Lint
golangci-lint run ./...

# Test
go test -tags=integration -count=1 ./...

# Build perunnode and perunnodecli binaries
make

License

perun-node is open-sourced under the Apache-2.0 license. See the LICENSE file for details.

# Packages

No description provided by the author
No description provided by the author
Package blockchain contains definitions and functions that are shared by different implementations of the chain interface.
No description provided by the author
No description provided by the author
Package currency implements conversion backends for different currencies used in a channel.
Package idprovider contains definitions and functions that are shared by different implementations of the ID provider.
Package log implements a simple logger that directly uses the logrus library.
Package node implements the node API.
Package peruntest implements test helpers for functionalities defined in perun package.
Package session implements a session to which a user can attach his or her credentials.

# Functions

APIErrAsMap returns a map containing entries for the method and each of the fields in the api error (except message).
NewAPIErr returns an APIErr with given parameters.
NewAPIErrChainNotReachable returns an ErrChainNotReachable API Error with the given error message.
NewAPIErrFailedPreCondition returns an ErrFailedPreCondition API Error with the given error message.
NewAPIErrFailedPreConditionUnclosedChs returns an ErrFailedPreCondition API Error for the special case where channel close was closed with no-force option and, one or more open channels exists.
NewAPIErrInvalidArgument returns an ErrInvalidArgument API Error with the given argument name and value.
NewAPIErrInvalidConfig returns an ErrInvalidConfig, API Error with the given config name and value.
NewAPIErrInvalidContracts returns an ErrInvalidContracts API Error with the given contract error infos.
NewAPIErrPeerNotFunded returns an ErrPeerNotFunded API Error with the given peer alias.
NewAPIErrPeerRejected returns an ErrPeerRejected API Error with the given peer alias and reason.
NewAPIErrPeerRequestTimedOut returns an ErrPeerRequestTimedOut API Error with the given peer alias and response timeout.
NewAPIErrResourceExists returns an ErrResourceExists API Error with the given resource type and ID.
NewAPIErrResourceNotFound returns an ErrResourceNotFound API Error with the given resource type and ID.
NewAPIErrTxTimedOut returns an ErrTxTimedOut API Error with the given error message.
NewAPIErrUnknownInternal returns an ErrUnknownInternal API Error with the given error message.
NewAPIErrUserResponseTimedOut returns an ErrUserResponseTimedOut API Error with the given expiry.

# Constants

Enumeration of values for ChUpdateType: Open: If accepted, channel will be updated and it will remain in open for off-chain tx.
Enumeration of values for ChUpdateType: Open: If accepted, channel will be updated and it will remain in open for off-chain tx.
Enumeration of values for ChUpdateType: Open: If accepted, channel will be updated and it will remain in open for off-chain tx.
ClientError is caused by the errors in the request from the client.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
Error code definitions.
InternalError is caused due to unintended behavior in the node software.
OwnAlias is the alias for the entry of the user's own PeerID details.
ParticipantError is caused by one of the channel participants not acting as per the perun protocol.
ProtocolFatalError is caused when the protocol aborts due to unexpected failure in external system during execution.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Credential represents the parameters required to access the keys and make signatures for a given address.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NodeConfig represents the configurable parameters of a perun node.
PeerID represents any participant in the off-chain network that the user wants to transact with.

# Interfaces

APIError represents the newer version of error returned by node, session and channel APIs.
ChainBackend wraps the methods required for deploy contracts, validating them and instantiating funde, adjudicator instances.
ChAPI represents the APIs that can be accessed in the context of a perun channel.
CommBackend defines the set of methods required for initializing components required for off-chain communication.
ContractRegistry provides an interface to register and retrieve adjudicator and asset contracts.
Currency represents a parser that can convert between string representation of a currency and its equivalent value in base unit represented as a big integer.
CurrencyRegistry provides an interface to register and retrieve currency parsers.
Dialer extends net.Dialer with Registerer interface.
Funder wraps the methods required on ETH funder.
IDProvider represents the functions to read, write peer IDs from and to the local cache connected to a peer ID provider.
IDReader represents the functions to read peer IDs from a cache connected to a peer ID provider.
NodeAPI represents the APIs that can be accessed in the context of a perun node.
Registerer is used to register the commAddr corresponding to an offChainAddr to the wire.Bus in runtime.
ROChainBackend wraps the methods required for validating contracts.
ROContractRegistry provides an interface to retrieve contracts.
ROCurrencyRegistry provides an interface to retrieve currency parsers.
SessionAPI represents the APIs that can be accessed in the context of a perun node.
WalletBackend wraps the methods for instantiating wallets and accounts that are specific to a blockchain platform.
WireBus is an extension of the wire.Bus interface in go-perun to include a "Close" method.

# Type aliases

ArgumentName type is used enumerate valid argument names for use InvalidArgument error.
No description provided by the author
No description provided by the author
No description provided by the author
ErrorCategory represents the category of the error, which describes how the error should be handled by the client.
ErrorCode is a numeric code assigned to identify the specific type of error.
ResourceType is used to enumerate valid resource types in ResourceNotFound and ResourceExists errors.
No description provided by the author