mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-25 07:45:18 +00:00
commit
7a6cdec4bc
150
README.md
150
README.md
@ -3,137 +3,29 @@
|
||||
</h1>
|
||||
|
||||
A decentralized fast-finality blockchain for interoperable payment channel networks.
|
||||
Building on the work of Tendermint and Interledger.
|
||||
|
||||
Project status: We're currently in a very early public testnet. With future features being implemented.
|
||||
Providing a base layer currency to settle interoperable payments at high throughput. Leveraging fast finality to allow short cross currency channel timeouts. Proof of stake to provide performance and effective light clients. Payment channels to enable high volume low value transfers at realistic throughput. Streaming credit payments for effective routing and interoperability across chains.
|
||||
|
||||
Try it out - run a full node to sync to the testnet, [send some off chain payments](internal/x/paychan/README.md), or set up as a validator.
|
||||
Proudly building on the work of [Cosmos](https://github.com/cosmos/cosmos-sdk) and [Interledger](https://github.com/interledger/rfcs).
|
||||
|
||||
# Project Status
|
||||
[![Testnet](https://img.shields.io/badge/testnet-live-brightgreen.svg)](http://validator.connector.kava.io:26657/abci_info)
|
||||
[![Go Report Card](https://goreportcard.com/badge/github.com/kava-labs/kava)](https://goreportcard.com/report/github.com/kava-labs/kava)
|
||||
![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)
|
||||
|
||||
We're currently in a very early public testnet, with future features being implemented.
|
||||
|
||||
If you're interested in being a validator join the chat and checkout the setup instructions below.
|
||||
|
||||
## Community
|
||||
|
||||
- [Telegram](https://t.me/kavalabs)
|
||||
- [Medium](https://medium.com/kava-labs)
|
||||
- [Validator Chat](https://riot.im/app/#/room/#kava-validators:matrix.org)
|
||||
|
||||
|
||||
## Install
|
||||
# Find Out More
|
||||
|
||||
<!--### Source-->
|
||||
|
||||
Requirements: go installed and set up (version 1.10+).
|
||||
|
||||
0. If installing from a new Ubuntu server (16.04 or 18.04), here's how to setup go:
|
||||
|
||||
sudo apt update
|
||||
sudo apt upgrade -y
|
||||
sudo apt install git gcc make wget -y
|
||||
wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
|
||||
sudo tar -xvf go1.10.3.linux-amd64.tar.gz
|
||||
sudo mv go /usr/local
|
||||
|
||||
cat >> ~/.profile <<EOF
|
||||
export GOROOT=/usr/local/go
|
||||
export GOPATH=\$HOME/go
|
||||
export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH
|
||||
EOF
|
||||
|
||||
source ~/.profile
|
||||
|
||||
1. Get the code.
|
||||
|
||||
mkdir -p $GOPATH/src/github.com/kava-labs
|
||||
cd $GOPATH/src/github.com/kava-labs
|
||||
git clone https://github.com/kava-labs/kava
|
||||
cd kava
|
||||
git checkout 8c9406c
|
||||
|
||||
2. Install the dependencies.
|
||||
|
||||
mkdir $GOPATH/bin
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
|
||||
3. Install the code
|
||||
|
||||
go install ./cmd/kvd
|
||||
go install ./cmd/kvcli
|
||||
|
||||
<!--### Docker
|
||||
|
||||
Requirements: docker installed.
|
||||
|
||||
No installation necessary, just prepend commands with `docker run kava/kava`. TODO name necessary to avoid new contianer being created each time?
|
||||
|
||||
This will use our docker container `kava/kava` and store all blockchain data and keys within the container. -->
|
||||
|
||||
<!-- To store this data outisde the conatiner, attach volumes to the container:
|
||||
|
||||
docker run --rm -v $HOME/.kvd:/root/.kvd -v $HOME/.kvcli:/root/.kvcli kava/kava <further commands>
|
||||
|
||||
Now blockchain data will be stored in `$HOME/.kvd` and keys in `$HOME/.kvcli`. Also the `--rm` flag removes the contianer after each run.
|
||||
|
||||
-->
|
||||
<!-- ## Send Transactions
|
||||
|
||||
You can send transactions on the testnet using our node without yncing a local node.
|
||||
Requirements
|
||||
|
||||
TODO users need to set up keys first?
|
||||
|
||||
kvcli <args> --node validator.connector.kava.io:26657 --chain-id kava-test-<current version>
|
||||
-->
|
||||
|
||||
## Run a Full Node
|
||||
|
||||
kvd init --name <your-name> --chain-id kava-test-2
|
||||
|
||||
This will generate config and keys in `$HOME/.kvd` and `$HOME/.kvcli`. The default password is 'password'.
|
||||
|
||||
> Note: Make sure `GOBIN` is set and added to your path if you want to be able to run installed go programs from any folder.
|
||||
|
||||
Copy the testnet genesis file (from https://raw.githubusercontent.com/Kava-Labs/kava/master/testnets/kava-test-2/genesis.json) into `$HOME/.kvd/config/`, replacing the existing one.
|
||||
|
||||
Add the kava node address, `5c2bc5a95b014e4b2897791565398ee6bfd0a04a@validator.connector.kava.io:26656`, to `seeds` in `$HOME/.kvd/config/config.toml`
|
||||
|
||||
Start your full node
|
||||
|
||||
kvd start
|
||||
|
||||
Or, to start in background and send to log:
|
||||
|
||||
kvd start &> kvd.log &
|
||||
|
||||
To see the output of the log:
|
||||
|
||||
tail -f kvd.log
|
||||
> Note: It might take a while to fully sync. Check the latest block height [here](http://validator.connector.kava.io:26657/abci_info).
|
||||
|
||||
|
||||
## Run a Validator
|
||||
Join the [validator chat](https://riot.im/app/#/room/#kava-validators:matrix.org). Follow setup for a full node above.
|
||||
|
||||
Get you address with `kvcli keys list`. Should look something like `cosmosaccaddr10jpp289accvkhsvrpz4tlj9zhqdaey2tl9m4rg`.
|
||||
|
||||
Ask @rhuairahrighairidh in the chat to give you some coins.
|
||||
|
||||
Get your validator pubkey with `kvd tendermint show_validator`
|
||||
|
||||
Then, your full running in the background or separate window, run:
|
||||
|
||||
kvcli stake create-validator \
|
||||
--amount 900KVA \
|
||||
--pubkey <you validator pubkey from above> \
|
||||
--address-validator <your address from above> \
|
||||
--moniker "<your name>" \
|
||||
--chain-id kava-test-2 \
|
||||
--from <your name> \
|
||||
--gas 1000000
|
||||
|
||||
> Note You'll need to type in the default password "password"
|
||||
|
||||
Now your full node should be participating in consensus and validating blocks!
|
||||
|
||||
Running a validator requires that you keep validating blocks. If you stop, your stake will be slashed.
|
||||
In order to stop validating, first remove yourself as validator, then you can stop your node.
|
||||
|
||||
kvcli stake unbond begin \
|
||||
--address-delegator <your address> \
|
||||
--address-validator <your address> \
|
||||
--chain-id kava-test-2 \
|
||||
--shares-percent 1 \
|
||||
--from <your name> \
|
||||
--gas 1000000
|
||||
- [Installation and Setup](docs/setup.md)
|
||||
- [Basic Usage](docs/usage.md)
|
||||
- [Payment Channels](docs/paychans.md)
|
||||
|
39
docs/paychans.md
Normal file
39
docs/paychans.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Payment Channels
|
||||
|
||||
Payment channels are designed to enable high speed and throughput for transactions while requiring no counter-party risk.
|
||||
|
||||
This initial implementation is for unidirectional channels. Channels can be opened by a sender and closed immediately by the receiver, or by the sender subject to a dispute period. There are no top-ups or partial withdrawals (yet).
|
||||
|
||||
|
||||
# Usage
|
||||
>The following commands require communication with a full node. By default they expect one to be running locally (accessible on localhost), but a remote can be provided with the `--node` flag.
|
||||
|
||||
## Create a channel
|
||||
|
||||
kvcli paychan create --from <your account name> --to <receivers address> --amount 100KVA --chain-id <your chain ID>
|
||||
|
||||
## Send an off-chain payment
|
||||
Send a payment for 10 KVA.
|
||||
|
||||
kvcli paychan pay --from <your account name> --sen-amt 90KVA --rec-amt 10KVA --chan-id <ID of channel> --filename payment.json --chain-id <your chain ID>
|
||||
|
||||
Send the file `payment.json` to your receiver. Then they run the following to verify.
|
||||
|
||||
kvcli paychan verify --filename payment.json
|
||||
|
||||
## Close a channel
|
||||
The receiver can close immediately at any time.
|
||||
|
||||
kvcli paychan submit --from <receiver's account name> --payment payment.json --chain-id <your chain ID>
|
||||
|
||||
The sender can submit a close request, causing the channel will close automatically after a dispute period. During this period a receiver can still close immediately, overruling the sender's request.
|
||||
|
||||
kvcli paychan submit --from <receiver's account name> --payment payment.json --chain-id <your chain ID>
|
||||
|
||||
>Note: The dispute period on the testnet is 30 seconds for ease of testing.
|
||||
|
||||
## Get info on a channel
|
||||
|
||||
kvcli get --chan-id <ID of channel>
|
||||
|
||||
This will print out a channel, if it exists, and any submitted close requests.
|
112
docs/setup.md
Normal file
112
docs/setup.md
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
# Installation and Setup
|
||||
|
||||
#### Who this guide is for
|
||||
The code currently consists of a full node daemon (`kvd`) and it's command line interface (`kvcli`).
|
||||
|
||||
Full nodes are fairly resource intensive and are designed to be run continuously on servers, primarily by people validating the network. While it is possible to run locally it is not recommended unless for development purposes. In the future light clients will enable secure transactions for clients.
|
||||
|
||||
A **full node** syncs with the blockchain and processes transactions. A **validator** is a full node that has declared itself to be a "validator" on chain. This obligates it to participate in consensus by proposing and signing blocks and maintaining uptime. By not following the protocol, the validator's stake will be slashed.
|
||||
|
||||
Use these instructions to set up a full node, and to optionally declare yourself as a validator.
|
||||
|
||||
## Install
|
||||
|
||||
Requirements: go installed and set up (version 1.10+).
|
||||
|
||||
0. If installing from a new Ubuntu server (16.04 or 18.04), here's how to setup go:
|
||||
|
||||
sudo apt update
|
||||
sudo apt upgrade -y
|
||||
sudo apt install git gcc make wget -y
|
||||
wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
|
||||
sudo tar -xvf go1.10.3.linux-amd64.tar.gz
|
||||
sudo mv go /usr/local
|
||||
|
||||
cat >> ~/.profile <<EOF
|
||||
export GOROOT=/usr/local/go
|
||||
export GOPATH=\$HOME/go
|
||||
export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH
|
||||
EOF
|
||||
|
||||
source ~/.profile
|
||||
|
||||
1. Get the code.
|
||||
|
||||
mkdir -p $GOPATH/src/github.com/kava-labs
|
||||
cd $GOPATH/src/github.com/kava-labs
|
||||
git clone https://github.com/kava-labs/kava
|
||||
cd kava
|
||||
git checkout 8c9406c
|
||||
|
||||
2. Install the dependencies.
|
||||
|
||||
mkdir $GOPATH/bin
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure -vendor-only
|
||||
|
||||
3. Install the code
|
||||
|
||||
go install ./cmd/kvd
|
||||
go install ./cmd/kvcli
|
||||
|
||||
## Run a Full Node
|
||||
|
||||
kvd init --name <your-name> --chain-id kava-test-2
|
||||
|
||||
This will generate config and keys in `$HOME/.kvd` and `$HOME/.kvcli`. The default password is 'password'.
|
||||
|
||||
> Note: Make sure `GOBIN` is set and added to your path if you want to be able to run installed go programs from any folder.
|
||||
|
||||
Copy the testnet genesis file (from https://raw.githubusercontent.com/Kava-Labs/kava/master/testnets/kava-test-2/genesis.json) into `$HOME/.kvd/config/`, replacing the existing one.
|
||||
|
||||
Add the kava node address, `5c2bc5a95b014e4b2897791565398ee6bfd0a04a@validator.connector.kava.io:26656`, to `seeds` in `$HOME/.kvd/config/config.toml`
|
||||
|
||||
Start your full node
|
||||
|
||||
kvd start
|
||||
|
||||
Or, to start in the background and capture output to a log file:
|
||||
|
||||
kvd start &> kvd.log &
|
||||
|
||||
To see the output of the log:
|
||||
|
||||
tail -f kvd.log
|
||||
> Note: It might take a while to fully sync. Check the latest block height [here](http://validator.connector.kava.io:26657/abci_info).
|
||||
|
||||
|
||||
## Become a Validator
|
||||
Join the [validator chat](https://riot.im/app/#/room/#kava-validators:matrix.org). Follow setup for a full node above.
|
||||
|
||||
Get you address with `kvcli keys list`.
|
||||
|
||||
Ask @rhuairahrighairidh in the chat to give you some coins.
|
||||
|
||||
Get your validator pubkey with `kvd tendermint show_validator`
|
||||
|
||||
Then, your full running in the background or separate window, run:
|
||||
|
||||
kvcli stake create-validator \
|
||||
--amount 900KVA \
|
||||
--pubkey <you validator pubkey from above> \
|
||||
--address-validator <your address from above> \
|
||||
--moniker "<your name>" \
|
||||
--chain-id kava-test-2 \
|
||||
--from <your name> \
|
||||
--gas 1000000
|
||||
|
||||
> Note You'll need to type in the default password "password"
|
||||
|
||||
Now your full node should be participating in consensus and validating blocks!
|
||||
|
||||
Running a validator requires that you keep validating blocks. If you stop, your stake will be slashed.
|
||||
In order to stop validating, first remove yourself as validator, then you can stop your node.
|
||||
|
||||
kvcli stake unbond begin \
|
||||
--address-delegator <your address> \
|
||||
--address-validator <your address> \
|
||||
--chain-id kava-test-2 \
|
||||
--shares-percent 1 \
|
||||
--from <your name> \
|
||||
--gas 1000000
|
19
docs/usage.md
Normal file
19
docs/usage.md
Normal file
@ -0,0 +1,19 @@
|
||||
# Basic Usage
|
||||
>The following commands require communication with a full node. By default they expect one to be running locally (accessible on localhost), but a remote can be provided with the `--node` flag.
|
||||
## View Your Address
|
||||
List locally stored account addresses and their names. The name is used in other commands to specify which address to use to sign the transaction.
|
||||
|
||||
kvcli keys list
|
||||
|
||||
## View Account Balances
|
||||
|
||||
kvcli account <address>
|
||||
|
||||
## Send Some KVA
|
||||
|
||||
kvcli send --from <your key name> \
|
||||
--to <address> \
|
||||
--amount 100KVA \
|
||||
--chain-id kava-test-<current testnet #>
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
# Unidrectional Payment Channels
|
||||
|
||||
This module implements simple but feature complete unidirectional payment channels. Channels can be opened by a sender and closed immediately by the receiver, or by the sender subject to a dispute period. There are no top-ups or partial withdrawals (yet). Channels support multiple currencies.
|
||||
|
||||
>Note: This module is still a bit rough around the edges. More feature planned. More test cases needed.
|
||||
|
||||
# Usage
|
||||
|
||||
## Create a channel
|
||||
|
||||
kvcli paychan create --from <your account name> --to <receivers address> --amount 100KVA --chain-id <your chain ID>
|
||||
|
||||
## Send an off-chain payment
|
||||
Send a payment for 10 KVA.
|
||||
|
||||
kvcli paychan pay --from <your account name> --sen-amt 90KVA --rec-amt 10KVA --chan-id <ID of channel> --filename payment.json --chain-id <your chain ID>
|
||||
|
||||
Send the file `payment.json` to your receiver. Then they run the following to verify.
|
||||
|
||||
kvcli paychan verify --filename payment.json
|
||||
|
||||
## Close a channel
|
||||
The receiver can close immediately at any time.
|
||||
|
||||
kvcli paychan submit --from <receiver's account name> --payment payment.json --chain-id <your chain ID>
|
||||
|
||||
The sender can submit a close request, causing the channel will close automatically after a dispute period. During this period a receiver can still close immediately.
|
||||
|
||||
kvcli paychan submit --from <receiver's account name> --payment payment.json --chain-id <your chain ID>
|
||||
|
||||
>Note: The dispute period on the testnet is 30 seconds for ease of testing.
|
||||
|
||||
## Get info on a channel
|
||||
|
||||
kvcli get --chan-id <ID of channel>
|
||||
|
||||
This will print out a channel, if it exists, and any submitted close requests.
|
||||
|
||||
# TODOs
|
||||
|
||||
- in code TODOs
|
||||
- Tidy up - method descriptions, heading comments, remove uneccessary comments, README/docs
|
||||
- Find a better name for Queue - clarify distinction between int slice and abstract queue concept
|
||||
- write some sort of integration test
|
||||
- possible bug in submitting same update repeatedly
|
||||
- find nicer name for payout
|
||||
- add Gas usage
|
||||
- add tags (return channel id on creation)
|
||||
- refactor cmds to be able to test them, then test them
|
||||
- verify doesn’t throw json parsing error on invalid json
|
||||
- can’t submit an update from an unitialised account
|
||||
- pay without a --from returns confusing error
|
||||
- use custom errors instead of using sdk.ErrInternal
|
||||
- split off signatures from update as with txs/msgs - testing easier, code easier to use, doesn't store sigs unecessarily on chain
|
||||
- consider removing pubKey from UpdateSignature - instead let channel module access accountMapper
|
||||
- refactor queue into one object
|
||||
- remove printout during tests caused by mock app initialisation
|
@ -1,5 +1,32 @@
|
||||
/*
|
||||
High level package documentation.
|
||||
Package paychan provides unidirectional payment channels.
|
||||
|
||||
This module implements simple but feature complete unidirectional payment channels. Channels can be opened by a sender and closed immediately by the receiver, or by the sender subject to a dispute period. There are no top-ups or partial withdrawals (yet). Channels support multiple currencies.
|
||||
|
||||
>Note: This module is still a bit rough around the edges. More feature planned. More test cases needed.
|
||||
|
||||
|
||||
TODO Explain how the payment channels are implemented.
|
||||
|
||||
# TODOs
|
||||
|
||||
- in code TODOs
|
||||
- Tidy up - method descriptions, heading comments, remove uneccessary comments, README/docs
|
||||
- Find a better name for Queue - clarify distinction between int slice and abstract queue concept
|
||||
- write some sort of integration test
|
||||
- possible bug in submitting same update repeatedly
|
||||
- find nicer name for payout
|
||||
- add Gas usage
|
||||
- add tags (return channel id on creation)
|
||||
- refactor cmds to be able to test them, then test them
|
||||
- verify doesn’t throw json parsing error on invalid json
|
||||
- can’t submit an update from an unitialised account
|
||||
- pay without a --from returns confusing error
|
||||
- use custom errors instead of using sdk.ErrInternal
|
||||
- split off signatures from update as with txs/msgs - testing easier, code easier to use, doesn't store sigs unecessarily on chain
|
||||
- consider removing pubKey from UpdateSignature - instead let channel module access accountMapper
|
||||
- refactor queue into one object
|
||||
- remove printout during tests caused by mock app initialisation
|
||||
|
||||
*/
|
||||
package paychan
|
||||
|
Loading…
Reference in New Issue
Block a user