connext / vector

↗️ Vector is an ultra-minimal state channel network implementation.
MIT License
109 stars 44 forks source link
connext vector-node

production

↗️ Vector

Vector is an ultra-simple, flexible state channel protocol and implementation.

At Connext, our goal is to build the cross-chain routing and micropayment layer of the decentralized web. Vector sits on top of Ethereum, evm-compatible L2 blockchains, and other turing-complete chains, and enables instant, near free transfers that can be routed across chains and over liquidity in any asset.

Out of the box, it supports the following features:

This monorepo contains a number of packages hoisted using lerna. Documentation for each package can be found in their respective readme, with some helpful links in Architecture below.

Contents:

Quick Start - Local Development

Prerequisites:

To start, clone & enter the Vector repo:

git clone https://github.com/connext/vector.git
cd vector

To build everything and deploy a Vector node in dev-mode, run the following:

make start-router

# view the node's logs
bash ops/logs.sh node

# view the router's logs
bash ops/logs.sh router

That's all! But beware: the first time make start-node is run, it will take a very long time (maybe 10 minutes, depends on your internet speed) but have no fear: downloads will be cached & most build steps won't ever need to be repeated again so subsequent make start runs will go much more quickly. Get this started asap & browse the rest of the README while the first make start runs.

By default, Vector will launch using two local chains (ganache with chain id 1337 and 1338) but you can also run a local Vector stack against a public chain (or multiple chains!) such as Rinkeby. To do so, edit the chainProviders and chainAddresses fields of config.json according to the chain you want to support.

Note: this will start a local Connext node pointed at a remote chain, so make sure the mnemonic used to start your node is funded in the appropriate native currencies and supported chain assets. By default, the node starts with the account:

mnemonic: "candy maple cake sugar pudding cream honey rich smooth crumble sweet treat";
privateKey: "0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3";
address: "0x627306090abaB3A6e1400e9345bC60c78a8BEf57";

To apply updates to config.json, you'll need to restart your vector node with make restart-node.

(make start/make restart are aliases for make start-router/make restart-router)

Four different Vector stacks are supported:

For any of these stacks, you can manage them with:

You can find WIP documentation on integrating and using Vector here.

Architecture and Module Breakdown

Vector uses a layered-approach to compartmentalize risk and delegate tasks throughout protocol usage. In general, lower layers are not context-aware of higher level actions. Information flows downwards through call params and upwards through events. The only exception to this are services, which are set up at the services layer and passed down to the protocol directly.

alt

You can find documentation on each layer in its respective readme:

Note that the engine and protocol are isomorphic. Immediately after the core implementation is done, we plan to build a browser-node implementation which sets up services in a browser-compatible way and exposes a direct JS interface to be consumed by a dApp developer.

Development and Running Tests

You can build the whole stack by running make.

Running tests: