Ran through the docs, more cleanup, everything except ibc ready

This commit is contained in:
Ethan Frey 2017-06-19 15:13:13 +02:00
parent 1e76d92d85
commit 9bb3493f78
4 changed files with 58 additions and 29 deletions

View File

@ -100,12 +100,12 @@ make test
Great! Now when I run `tendermint` I have the newest of the new, the develop branch! But please note that this branch is not considered production ready and may have issues. This should only be done if you want to develop code for the future and run locally. Great! Now when I run `tendermint` I have the newest of the new, the develop branch! But please note that this branch is not considered production ready and may have issues. This should only be done if you want to develop code for the future and run locally.
But wait, I want to mix and match. There is a bugfix in `go-p2p:persistent_peer` that I want to use with tendermint. How to compile this. I will show with a simple example, please update the repo and commit numbers for your usecase. Also, make sure these branches are compatible, so if `persistent_peer` is close to `master` it should work. But if it is 15 commits ahead, you will probably need the `develop` branch of tendermint to compile with it. But I assume you know your way around git and can figure that out. But wait, I want to mix and match. There is a bugfix in `go-crypto:unstable` that I want to use with tendermint. How to compile this. I will show with a simple example, please update the repo and commit numbers for your usecase. Also, make sure these branches are compatible, so if `unstable` is close to `master` it should work. But if it is 15 commits ahead, you will probably need the `develop` branch of tendermint to compile with it. But I assume you know your way around git and can figure that out.
In the dependent repo: In the dependent repo:
``` ```
cd $GOPATH/src/github.com/tendermint/go-p2p cd $GOPATH/src/github.com/tendermint/go-crypto
git checkout persistent_peer git checkout unstable
git pull git pull
# double-check this makes sense or if it is too far off # double-check this makes sense or if it is too far off
git log --oneline --decorate --graph git log --oneline --decorate --graph
@ -118,7 +118,7 @@ In the main repo (tendermint, basecoin, ...) where the binary will be built:
cd $GOPATH/src/github.com/tendermint/tendermint cd $GOPATH/src/github.com/tendermint/tendermint
git checkout master git checkout master
git pull git pull
# -> edit glide.lock, set the version of go-p2p (for example) # -> edit glide.lock, set the version of go-crypto (for example)
# to the commit number you got above (the 40 char version) # to the commit number you got above (the 40 char version)
make get_vendor_deps make get_vendor_deps
make install make install

View File

@ -9,7 +9,7 @@ and what is happening under the hood.
Installing Basecoin is simple: Installing Basecoin is simple:
``` ```
go get -u github.com/tendermint/basecoin/cmd/basecoin go get -u github.com/tendermint/basecoin/cmd/...
``` ```
If you have trouble, see the [installation guide](install.md). If you have trouble, see the [installation guide](install.md).
@ -19,6 +19,9 @@ If you have trouble, see the [installation guide](install.md).
To initialize a new Basecoin blockchain, run: To initialize a new Basecoin blockchain, run:
``` ```
# WARNING: this will wipe out any existing info in the ~/.basecoin dir
# don't run if you have lots of local state already
rm -rf ~/.basecoin
basecoin init basecoin init
``` ```
@ -30,6 +33,9 @@ For this example, we will change the genesis account to a new account named
`cool`. First create a new account: `cool`. First create a new account:
``` ```
# WARNING: this will wipe out any existing info in the ~/.basecli dir
# including private keys, don't run if you have lots of local state already
basecli reset_all
basecli keys new cool basecli keys new cool
``` ```
@ -57,6 +63,7 @@ Hurray! you are very rich and cool on this blockchain now.
## Start ## Start
Now we can start Basecoin: Now we can start Basecoin:
``` ```
@ -106,7 +113,7 @@ basecli query account $YOU
We can send some of these coins back like so: We can send some of these coins back like so:
``` ```
basecli tx send --name=friend --amount=500mycoin --to=0x$ME --sequence=1 basecli tx send --name=friend --amount=500mycoin --to=$ME --sequence=1
``` ```
Note how we use the `--name` flag to select a different account to send from. Note how we use the `--name` flag to select a different account to send from.
@ -114,7 +121,16 @@ Note how we use the `--name` flag to select a different account to send from.
If we try to send too much, we'll get an error: If we try to send too much, we'll get an error:
``` ```
basecli tx send --name=friend --amount=500000mycoin --to=0x$ME --sequence=1 basecli tx send --name=friend --amount=500000mycoin --to=$ME --sequence=1
```
And if you want to see the original tx, as well as verifying that it
really is in the blockchain, look at the send response:
```
basecli tx send --name=cool --amount=2345mycoin --to=$YOU --sequence=2
# TXHASH from the json output
basecli query tx $TXHASH
``` ```
See `basecli tx send --help` for additional details. See `basecli tx send --help` for additional details.

View File

@ -25,6 +25,10 @@ A new blockchain can be initialized and started just like with in the [previous
guide](basecoin-basics.md): guide](basecoin-basics.md):
``` ```
# WARNING: this wipes out data - but counter is only for demos...
rm -rf ~/.counter
countercli reset_all
counter init counter init
countercli keys new cool countercli keys new cool
countercli keys new friend countercli keys new friend
@ -70,15 +74,25 @@ If we send another transaction, and then query again, we will see the value
increment: increment:
``` ```
countercli tx counter --name cool --amount=1mycoin --sequence=4 --valid countercli tx counter --name cool --amount=2mycoin --sequence=4 --valid --countfee=2mycoin
countercli query counter countercli query counter
``` ```
The value Counter value should be 2, because we sent a second valid transaction. The value Counter value should be 2, because we sent a second valid transaction.
Notice how the result of the query comes with a proof. This is a Merkle proof And this time, since we sent a countfee (which must be less than or equal to the
that the state is what we say it is. In a latter [guide on InterBlockchain total amount sent with the tx), it stores the `TotalFees` on the counter as well.
Communication](ibc.md), we'll put this proof to work!
Even if you don't see it in the UI, the result of the query comes with a proof.
This is a Merkle proof that the state is what we say it is, and ties that query
to a particular header. Behind the scenes, `countercli` will not only verify that
this state matches the header, but also that the header is properly signed by
the known validator set. It will even update the validator set as needed, so long
as there have not been major changes and it is secure to do so. So, if you wonder
why the query may take a second... there is a lot of work going on in the
background to make sure even a lying full node can't trick your client.
In a latter [guide on InterBlockchainCommunication](ibc.md), we'll use these
proofs to post transactions to other chains.
Now, before we implement our own plugin and tooling, it helps to understand the Now, before we implement our own plugin and tooling, it helps to understand the
`AppTx` and the design of the plugin system. `AppTx` and the design of the plugin system.
@ -161,7 +175,8 @@ more details.
First is the `cmd/counter/main.go`, which drives the program. It can be left First is the `cmd/counter/main.go`, which drives the program. It can be left
alone, but you should change any occurrences of `counter` to whatever your alone, but you should change any occurrences of `counter` to whatever your
plugin tool is going to be called. plugin tool is going to be called. You must also register your plugin(s) with
the basecoin app with `RegisterStartPlugin`.
The light-client which is located in `cmd/countercli/main.go` allows for is The light-client which is located in `cmd/countercli/main.go` allows for is
where transaction and query commands are designated. Similarity this command where transaction and query commands are designated. Similarity this command
@ -170,9 +185,9 @@ references to new plugin commands
Next is the custom commands in `cmd/countercli/commands/`. These files is Next is the custom commands in `cmd/countercli/commands/`. These files is
where we extend the tool with any new commands and flags we need to send where we extend the tool with any new commands and flags we need to send
transactions or queries to our plugin. Note the `init()` function, where we transactions or queries to our plugin. You define custom `tx` and `query`
register a new transaction subcommand with `RegisterTxSubcommand`, and where we subcommands, which are registered in `main.go` (avoiding `init()`
load the plugin into the Basecoin app with `RegisterStartPlugin`. auto-registration, for less magic and more control in the main executable).
Finally is `plugins/counter/counter.go`, where we provide an implementation of Finally is `plugins/counter/counter.go`, where we provide an implementation of
the `Plugin` interface. The most important part of the implementation is the the `Plugin` interface. The most important part of the implementation is the

View File

@ -3,8 +3,7 @@
On a good day, basecoin can be installed like a normal Go program: On a good day, basecoin can be installed like a normal Go program:
``` ```
go get github.com/tendermint/basecoin/ go get -u github.com/tendermint/basecoin/cmd/...
make all
``` ```
In some cases, if that fails, or if another branch is required, In some cases, if that fails, or if another branch is required,
@ -15,7 +14,6 @@ the correct way to install is:
``` ```
cd $GOPATH/src/github.com/tendermint/basecoin cd $GOPATH/src/github.com/tendermint/basecoin
git pull origin master git pull origin master
make get_vendor_deps
make all make all
``` ```