Git Product home page Git Product logo

raiden's People

Contributors

agatsoh avatar andrevmatos avatar christianbrb avatar cosminnechifor avatar czepluch avatar dependabot[bot] avatar devium avatar dominik1999 avatar eorituz avatar err508 avatar ezdac avatar fredo avatar hackaugusto avatar heikoheiko avatar hrishikeshio avatar jomuel avatar karlb avatar kelsos avatar konradkonrad avatar lefterisjp avatar loredanacirstea avatar manuelwedler avatar palango avatar pcppcp avatar pirapira avatar rakanalh avatar schmir avatar taleldayekh avatar ulope avatar utzig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raiden's Issues

Profiling Framework

Add support for easy profiling
ideally the continuous integration would notify if a commit slows the system down

Event polling

The raiden node needs to keep updated about changes to the (global) state by listening for Events.

Generalize the current implementation to support multiple applications

Generalize the payment channels into state channels that can be used by individual applications.

Protocol Draft:

Envelope

Raiden envelope for payment transfers is comprised of:

  • signature
  • nonce
  • transferred amount
  • locksroot

[ 65bytes signature | 8bytes nonce | 32bytes transferred amount | 32 bytes locksroot | ... arbitrary length data ]

Fields usage

The nonce is a non-global monotonically increasing value used to determine the message ordering. By non-global it's meant that each participant increments it's own nonce without synchronizing with it's partner, this removes a series of synchronization problems. The value must be non-zero (zero is used by the smart contract as a null value).

  • raiden requires not only a monotonically increasing value, but a value increment sequentially (+1).
  • transferred amount is not sufficient to define message order because not all messages change it's value.

The transferred amount is a monotonically increasing value used to determine the balances of each participant, the value must be monotonically increasing because this property only allows each party to give token to the partner and not take any.

  • One's resulting balance is defined as initial_balance + received_amount - transferred_amount where the received_amount = latest_received_transfer.transferred_amount and transferred_amount = latest_sent_transfer.transferred_amount

The locksroot is the root node of a merkle tree encoding all the unexpired & unclaimed locks at the moment the channel is closed, this is used as a proof that a given lock was pending and valid to allow claiming it's value inside the settle_timeout window, this may be done if secret is learned and the lock has not expired yet.

Depends on: #292
A recoverable signature to prove the validity of the message, the signature is defined as ecdsa_recoverable(privkey, nonce || transferred_amount || locksroot || contract_address).

  • the contract_address is the smart contract holding the tokens from both participants in escrow, used to prohibit settling a channel with an invalid message:
    • that Bob reuses a transfer from Alice from a closed channel among them to settle a new channel.
    • that Charlie reuses a transfer from a different channel, eg. among Alice and Bob.
    • this is an alternative implementation to the nonce ranges, the benefit is that all bits from the message may be used.
  • An alternative signature would be comprised of ecdsa_recoverable(privkey, packet_data[65:] || contract_address), where the signature can also be used to validate the data in the envelope.

Base solidity library

Basic struct must contain:

  • closed block number
  • settle timeout
  • both participant addresses
  • the envelope data for a transfer from each participant

Alternatives

Fixed vs. "dynamic" settlement period

The current NettingChannelLibrary has a fixed settlement period, this is used for dispute resolution and for unlocking locks unclaimed at the time the channel was closed, as a consequence the NettingChannelContract settlement period is an upper bound for the lock's expiration timeouts and a limit on the number of hops that can participate in a mediated transfer.

An alternative implementation removes the settlement period of the NettingChannelContract and add it to the message envelope, where the current highest expiration of all locks is used and signed along side with the merkleroot, and the smart contract will only allow settlement after this latest settlement period has elapsed plus a reveal timeout.

Benefits of fixed settlement:

  • smaller envelop size in bytes

Benefis of dynamic settlement:

  • unbound number of hops (at the protocol level, the application might want to use a configuration for it)

claim_locked doesn't update the partner class correctly

Reported by @ryepdx in the gitter channel.

The receiving logic (first block), should increase local balance and decrease the partner balance.

        if hashlock in self.locked:
            amount = self.locked.get(hashlock).lock.amount
            self.balance += amount
            self.partner.balance += amount
            self.locked.remove(hashlock)
        if hashlock in self.partner.locked:
            amount = self.partner.locked.get(hashlock).lock.amount
            self.balance -= amount
            self.partner.balance += amount
            self.partner.locked.remove(hashlock)

Implement temporary ban

ban == not init a transfer involving node X

X seem to be unresponsive. Could be a network glitch, but also X gone byzantine. Therefore we should be him say 10 minutes, then try again, if not good, double the ban, etc. if ban > X, close channel.

Use msgpack serialization

switch serialization to msgpack, especially:

https://github.com/vsergeev/u-msgpack-python
with this extension:

import umsgpack

def _pack_map(obj, fp):
    if len(obj) <= 15:
        fp.write(struct.pack("B", 0x80 | len(obj)))
    elif len(obj) <= 2**16 - 1:
        fp.write(b"\xde" + struct.pack(">H", len(obj)))
    elif len(obj) <= 2**32 - 1:
        fp.write(b"\xdf" + struct.pack(">I", len(obj)))
    else:
        raise umsgpack.UnsupportedTypeException("huge array")

    for k in sorted(obj.iterkeys()):
        umsgpack.pack(k, fp)
        umsgpack.pack(obj[k], fp)

umsgpack._pack_map = _pack_map

check:

how do nested objects work
how to serialize w/o copying too often
how to deserialize to objects without copying the data (e.g. set dict?)

Add raiden's fees

  • For the initiators
    • Reveal or not the secret, depending on the transfer amount reported by the target.
  • For the mediators:
    • Decrease the lock.amount equal to it's fee amount
  • For the target
    • Inform the initiator how much token the receive transfer (Done with the secret request message)

Timeline

The PFS team relies on this implementation before it can incorporate fees into its routing algorithms. A basic implementation until mid-March 2019 would be good.

Harden messages against replay attacks

Depending on the value of self.asset, messages could be re-applicable between two instances of the same state channel (between=[Alice, Bob], asset=BBCoin). Given that:

  • Alice and Bob opened+settled channel for BBCoin yesterday AND
  • Alice and Bob open a new channel for BBCoin

If self.asset resolves to the same value, there seems to be no value unique to the current instance, i.e. yesterdays messages could be valid in today's channel.

So: either the asset-address needs to be unique, or we should include the state-channel address in signed transfer messages.

See:
https://github.com/brainbot-com/raiden/blob/master/raiden/messages.py#L291
https://github.com/brainbot-com/raiden/blob/master/raiden/messages.py#L394

Create a 'InitMediatedTransferTask' to compensate for nondeterministic paths

As an initiator, the expiration of a transfer-lock is critical for a transaction to succeed but the path is not known beforehand.
The maximum valid lock-expiration is dependent on the settle_timeout of the first channel a node chooses for a MediatedTransfer - a very small initial lock-expiration time won't allow the transaction to succeed.
The 'InitMediatedTransferTask' should spawn MediatedTransfers and wait for confirmation or timeout,
then it should alter timeout/expiration-parameters accordingly.

CLI Configuration

  • create commandline argument parsing for node startup see specs
  • start interactive repl
  • document usage for manual transfers

Raiden DApp

The Raiden Application is a DApp. It accesses the Ethereum network using the Ethereum API. It provides services through its websockets API.

Sub Tasks:

Add filter polling

Consider what is a proper bloom filter for the secret revealed events (or if it is required at all)

Channel creation edge cases

We need to make sure that the funds can be recovered in these scenarios:

  • A deposits but B doesn't, A must be able to close the channel and reclaim it's deposit.
  • A deposits and thinks that B did not, B tries to deposit after the channel was closed by A, the deposit should fail

duplicate of #157 #172 ?

Add authentication for the Delivered message

We don't want to sign all messages because ecrecover is an expensive operation, specially we don't want to sign the Delivered messages because that would double the number of signatures, without encryption that means that an Delivered message can be easily forged.

A forged Delivered's can be used to make a channel unusable and maybe to steal some asset.

  • To make a channels unusable an Delivered for a DirectTransfer or Secret message is sufficient, since the sender would update it's state while the partner won't.
  • To steal some asset a MediatedTransfer is required, ABC, B would need to intercept the RevealSecret messages and make sure that C don't receive it until the the BC lock expires, then it can settle the transaction AB on chain with the secret learned from the intercepted message (#473).
    • This is still possible with the Secret Registry iff the lock expiration changes, and this is possible since the settle timeout is not enforced to be constant through out the network

With an encryption scheme faster than ecrecoverable signatures we can drop the signatures from the messages that are not exposed to the smart contract (messages that are signed only to inform us about the sender, eg. SecretRequest, TransferTimeout, etc.)

The NettingContract requires the transfers to be sortable.

All transfers that occurred in the same channel need to be sortable in respect to their creation/acceptance, as a consequence a total order is required among the transfers in a channel.

This is required for the correct settlement of conflicts, since only the very last transaction's balance should be take into account.

Raiden RESTful API

Expose the API of raiden to external clients.

General API Spec:

  • Setting up the initial connection to the raiden network should be possible manually (by opening channels and depositing into them from single API methods)

  • Additionally we want to provide a (semi-)automatic setup to the network from given configuration-parameters
    (e.g. based on available assets, so that the node takes care of an optimal connectivity to the raiden network by opening and depositing into channels without any additional considerations from the user)

  • API calls and responses should include a specification of the API-version (up from v1.0), so that the API is future-proof. The app has to include all versions of the API in the future.

  • MvP: this version of the API needs to provide all neccessary tools to make it possible to build a Wallet style UI (issue #285)

Functionality

add following methods to raiden-service.RaidenAPI:

  • query_endpoint(raiden_address) - for light clients
  • register_endpoint(endpoint, signature)
  • get_channel_info() - retrieve the timeout, deposit, etc

let the caller decide if the called method should be executed asynchronous or waiting
(== gevent.Greenlet.wait())

  • asset_swap(..., wait=<bool>)
  • expect_asset_swap(..., wait=<bool>)
  • transfer(..., wait=<bool>)

The asynchronous method should be the default option,
but when calling via REST the waiting method should be default.
That's because in e.g. JavaScript one can work easily with Promises.

Protocol:

  • Endpoints of all methods in the raiden_service.RaidenAPI are accessible through http-requests and are structured complying to a RESTful-pattern. Resources are kept minimal:
    • (e.g. on /api/channel
      -GET - get channel info,
      -POST - open channel,
      -DELETE - close channel,
      -UPDATE - deposit to channel )
  • All http-requests (-> client-initiated) are 'blocking' and at least include information about the success of the call in their response message. That way we don't have to work with callback-ids on the client side (see #280 ) but rather can work with promises.
  • For non-client initiated actions (e.g. incoming transfers, opened channels, channel closing etc.) there will be the emission of events from the node to the client
  • Filtering of the events will be done on the client side, so all events will be put in a FIFO-queue and sequentially forwarded to the client
  • We assume that only 1 client per node is connected
  • Events and responses will be serialized to JSON, 'difficult' data encoding will be reused from the Ethereum protocol (pyethapp/pyethereum) where possible
    (e.g. hex encoding for addresses)

Transport:

  • Method-calls: TCP (http-requests)

  • Events: the client can choose between

    1. TCP (polling http-requests)
    2. TCP ( long-polling; 'fake' push notifications)
  • The interface for the API has to be uniform, independent of the chosen transport-layer

Tasklist

Throughput test

Tasklist

  • Measure throughput of a node sending mediated transactions through N channels without mediation.
  • The benchmark script must accept an argument for the minimum value for the TPS, and if the given value is not reached it should exit with a status of 1
    • The benchmark must be added to the build with the minimum value for TPS set.

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.