From 266ea5ce82a25963ac3bdee2e1e5abde22ef38e6 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sun, 4 Mar 2018 00:37:01 -0500 Subject: [PATCH 01/12] docs cleanup --- docs/{ => old}/basecoin/basics.rst | 0 docs/{ => old}/basecoin/extensions.rst | 0 docs/{sdk => old}/glossary.rst | 0 docs/{ => old}/ibc.rst | 0 docs/{x => old}/replay-protection.rst | 0 docs/{ => old}/staking/intro.rst | 0 docs/{ => old}/staking/key-management.rst | 0 docs/{ => old}/staking/local-testnet.rst | 0 docs/{ => old}/staking/public-testnet.rst | 0 docs/{ => sdk}/apps.md | 2 +- docs/sdk/install.rst | 17 ++++++----------- 11 files changed, 7 insertions(+), 12 deletions(-) rename docs/{ => old}/basecoin/basics.rst (100%) rename docs/{ => old}/basecoin/extensions.rst (100%) rename docs/{sdk => old}/glossary.rst (100%) rename docs/{ => old}/ibc.rst (100%) rename docs/{x => old}/replay-protection.rst (100%) rename docs/{ => old}/staking/intro.rst (100%) rename docs/{ => old}/staking/key-management.rst (100%) rename docs/{ => old}/staking/local-testnet.rst (100%) rename docs/{ => old}/staking/public-testnet.rst (100%) rename docs/{ => sdk}/apps.md (97%) diff --git a/docs/basecoin/basics.rst b/docs/old/basecoin/basics.rst similarity index 100% rename from docs/basecoin/basics.rst rename to docs/old/basecoin/basics.rst diff --git a/docs/basecoin/extensions.rst b/docs/old/basecoin/extensions.rst similarity index 100% rename from docs/basecoin/extensions.rst rename to docs/old/basecoin/extensions.rst diff --git a/docs/sdk/glossary.rst b/docs/old/glossary.rst similarity index 100% rename from docs/sdk/glossary.rst rename to docs/old/glossary.rst diff --git a/docs/ibc.rst b/docs/old/ibc.rst similarity index 100% rename from docs/ibc.rst rename to docs/old/ibc.rst diff --git a/docs/x/replay-protection.rst b/docs/old/replay-protection.rst similarity index 100% rename from docs/x/replay-protection.rst rename to docs/old/replay-protection.rst diff --git a/docs/staking/intro.rst b/docs/old/staking/intro.rst similarity index 100% rename from docs/staking/intro.rst rename to docs/old/staking/intro.rst diff --git a/docs/staking/key-management.rst b/docs/old/staking/key-management.rst similarity index 100% rename from docs/staking/key-management.rst rename to docs/old/staking/key-management.rst diff --git a/docs/staking/local-testnet.rst b/docs/old/staking/local-testnet.rst similarity index 100% rename from docs/staking/local-testnet.rst rename to docs/old/staking/local-testnet.rst diff --git a/docs/staking/public-testnet.rst b/docs/old/staking/public-testnet.rst similarity index 100% rename from docs/staking/public-testnet.rst rename to docs/old/staking/public-testnet.rst diff --git a/docs/apps.md b/docs/sdk/apps.md similarity index 97% rename from docs/apps.md rename to docs/sdk/apps.md index 29fb905cb..01210cb66 100644 --- a/docs/apps.md +++ b/docs/sdk/apps.md @@ -15,7 +15,7 @@ while defining as little about that state machine as possible (staying true to t BaseApp requires stores to be mounted via capabilities keys - handlers can only access stores they're given the key for. The BaseApp ensures all stores are properly loaded, cached, and committed. One mounted store is considered the "main" - it holds the latest block header, from which we can find and load the -most recent state. +most recent state ([TODO](https://github.com/cosmos/cosmos-sdk/issues/522)). BaseApp distinguishes between two handler types - the `AnteHandler` and the `MsgHandler`. The former is a global validity check (checking nonces, sigs and sufficient balances to pay fees, diff --git a/docs/sdk/install.rst b/docs/sdk/install.rst index c5a82475a..b4c0ad5da 100644 --- a/docs/sdk/install.rst +++ b/docs/sdk/install.rst @@ -6,7 +6,8 @@ version of the code, please head to our `downloads `__ page to get a pre-compiled binary for your platform. -Usually, Cosmos SDK can be installed like a normal Go program: +Usually, Cosmos SDK can be installed to +`$GOPATH/src/github.com/cosmos/cosmos-sdk` like a normal Go program: :: @@ -23,13 +24,7 @@ repo, the correct way to install is: git pull origin master make all -This will create the ``basecoin`` binary in ``$GOPATH/bin``. -``make all`` implies ``make get_vendor_deps`` and uses ``dep`` to -install the correct version of all dependencies. It also tests the code, -including some cli tests to make sure your binary behaves properly. - -If you need another branch, make sure to run ``git checkout `` -before ``make all``. And if you switch branches a lot, especially -touching other tendermint repos, you may need to ``make fresh`` -sometimes so dep doesn't get confused with all the branches and -versions lying around. +This will create the ``basecoind`` and ``basecli`` binaries locally in +``./build/bin``. ``make all`` implies ``make get_vendor_deps`` and uses +``glide`` to install the correct version of all dependencies. It also tests the +code, including some cli tests to make sure your binary behaves properly. From f386946d4cae7da38bd06dc13618c42842f6769f Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Fri, 30 Mar 2018 11:30:25 -0700 Subject: [PATCH 02/12] docs update part 1 --- docs/old/staking/intro.rst | 171 ++++++++++++++++++++++++++++--------- 1 file changed, 132 insertions(+), 39 deletions(-) diff --git a/docs/old/staking/intro.rst b/docs/old/staking/intro.rst index ca1d002f5..a8f4ea078 100644 --- a/docs/old/staking/intro.rst +++ b/docs/old/staking/intro.rst @@ -1,77 +1,166 @@ -Using Gaia -========== +Using The Staking Module +======================== -This project is a demonstration of the Cosmos Hub with staking functionality; it is -designed to get validator acquianted with staking concepts and procedure. +This project is a demonstration of the Cosmos Hub staking functionality; it is +designed to get validator acquianted with staking concepts and procedures. Potential validators will be declaring their candidacy, after which users can delegate and, if they so wish, unbond. This can be practiced using a local or public testnet. +This example covers initial setup of a two-node testnet between a server in the cloud and a local machine. Begin this tutorial from a cloud machine that you've ``ssh``'d into. + Install ------- -The ``gaia`` tooling is an extension of the Cosmos-SDK; to install: +The ``basecoind`` and ``basecli`` binaries: :: - go get github.com/cosmos/gaia - cd $GOPATH/src/github.com/cosmos/gaia + go get github.com/cosmos/cosmos-sdk + cd $GOPATH/src/github.com/cosmos/cosmos-sdk make get_vendor_deps make install -It has three primary commands: +Let's jump right into it. First, we initialize some default files: :: - Available Commands: - node The Cosmos Network delegation-game blockchain test - rest-server REST client for gaia commands - client Gaia light client - - version Show version info - help Help about any command + basecoind init -and a handful of flags that are highlighted only as necessary. +which will output: -The ``gaia node`` command is a proxt for running a tendermint node. You'll be using -this command to either initialize a new node, or - using existing files - joining -the testnet. +:: -The ``gaia rest-server`` command is used by the `cosmos UI `__. + I[03-30|11:20:13.365] Found private validator module=main path=/root/.basecoind/config/priv_validator.json + I[03-30|11:20:13.365] Found genesis file module=main path=/root/.basecoind/config/genesis.json + Secret phrase to access coins: + citizen hungry tennis noise park hire glory exercise link glow dolphin labor design grit apple abandon -Lastly, the ``gaia client`` command is the workhorse of the staking module. It allows -for sending various transactions and other types of interaction with a running chain. -that you've setup or joined a testnet. +This tell us we have a ``priv_validator.json`` and ``genesis.json`` in the ``~/.basecoind/config`` directory. A ``config.toml`` was also created in the same directory. It is a good idea to get familiar with those files. Write down the seed. -Generating Keys ---------------- +The next thing we'll need to is add the key from ``priv_validator.json`` to the ``basecli`` key manager. For this we need a seed and a password: -Review the `key management tutorial <../key-management.html>`__ and create one key -if you'll be joining the public testnet, and three keys if you'll be trying out a local -testnet. +:: + + basecli keys add alice --recover + +which will give you three prompts: + +:: + + Enter a passphrase for your key: + Repeat the passphrase: + Enter your recovery seed phrase: + +create a password and copy in your seed phrase. The name and address of the key will be output: + +:: + + alice 67997DD03D527EB439B7193F2B813B05B219CC02 + +You can see all available keys with: + +:: + + basecli keys list + +See the `key management tutorial <../key-management.html>`__ for more information on managing keys. Setup Testnet ------------- -The first thing you'll want to do is either `create a local testnet <./local-testnet.html>`__ or -join a `public testnet <./public-testnet.html>`__. Either step is required before proceeding. +Next, we start the daemon (do this in another window): -The rest of this tutorial will assume a local testnet with three participants: ``alice`` will be -the initial validator, ``bob`` will first receives tokens from ``alice`` then declare candidacy -as a validator, and ``charlie`` will bond then unbond to ``bob``. If you're joining the public -testnet, the token amounts will need to be adjusted. +:: + + basecoind start + +and you'll see blocks start streaming through. + +For this example, we're doing the above on a cloud machine. The next steps should be done on your local machine or another server in the cloud, which will join the running testnet then bond/unbond. + +Accounts +-------- + +We have: + +- ``alice`` the initial validator (in the cloud) +- ``bob`` receives tokens from ``alice`` then declares candidacy (from local machine) +- ``charlie`` will bond and unbond to ``bob`` (from local machine) + +Remember that ``alice`` was already created. On your second machine, install the binaries and create two new keys: + +:: + + basecli keys add bob + basecli keys add charlie + +both of which will prompt you for a password. Now we need to copy the ``genesis.json`` and ``config.toml`` from the first machine (with ``alice``) to the second machine. This is a good time to look at both these files. + +The ``genesis.json`` should look something like: + +:: + + { + "app_hash": "", + "app_state": { + "accounts": [ + { + "address": "1FEADCDC8CCB22244769B9CC93C1F6D7489FC5AF", + "coins": [ + { + "denom": "mycoin", + "amount": 9007199254740992 + } + ] + } + ] + }, + "chain_id": "test-chain-EsYka3", + "genesis_time": "0001-01-01T00:00:00Z", + "validators": [ + { + "pub_key": { + "type": "ed25519", + "data": "57B89D41F18FE3FE69250B44693A7D68DE4E03EC563F54C27F9A86CE8B81A4B7" + }, + "power": 10, + "name": "" + } + ] + } + +To notice is that the ``accounts`` field has a an address and a whole bunch of "mycoin". This is ``alice``'s address (todo: dbl check). Under ``validators`` we see the ``pub_key.data`` field, which will match the same field in the ``priv_validator.json`` file. + +The ``config.toml`` is long so let's focus on one field: + +:: + + # Comma separated list of seed nodes to connect to + seeds = "" + +On the ``alice`` cloud machine, we don't need to do anything here. Instead, we need its IP address. After copying this file (and the ``genesis.json`` to your local machine, you'll want to put the IP in the ``seeds = "138.197.161.74"`` field, in this case, we have a made-up IP. For joining testnets with many nodes, you can add more comma-seperated IPs to the list. + + +Now that your files are all setup, it's time to join the network. On your local machine, run: + +:: + + basecoind start + +and your new node will connect to the running validator (``alice``). Sending Tokens -------------- -We'll have ``alice`` who is currently quite rich, send some ``fermions`` to ``bob``: +We'll have ``alice`` send some ``mycoin`` to ``bob``, who has now joined the network: :: - gaia client tx send --amount=1000fermion --sequence=1 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 + basecli send --amount=1000fermion --seq=0 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 -where the ``--sequence`` flag is to be incremented for each transaction, the ``--name`` flag names the sender, and the ``--to`` flag takes ``bob``'s address. You'll see something like: +where the ``--seq`` flag is to be incremented for each transaction, the ``--name`` flag names the sender, and the ``--to`` flag takes ``bob``'s address. You'll see something like: :: @@ -101,11 +190,13 @@ where the ``--sequence`` flag is to be incremented for each transaction, the ``- "height": 2963 } +TODO: check the above with current actual output. + Check out ``bob``'s account, which should now have 992 fermions: :: - gaia client query account 5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 + basecli account 5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 Adding a Second Validator ------------------------- @@ -114,6 +205,8 @@ Next, let's add the second node as a validator. First, we need the pub_key data: +** need to make bob a priv_Val above! + :: cat $HOME/.gaia2/priv_validator.json @@ -130,7 +223,7 @@ Now ``bob`` can declare candidacy to that pubkey: :: - gaia client tx declare-candidacy --amount=10fermion --name=bob --pubkey= --moniker=bobby + basecli declare-candidacy --amount=10mycoin --name=bob --pubkey= --moniker=bobby with an output like: From 6a7dc0966f2ca7676c61a51431319ef8dbf25c25 Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Tue, 3 Apr 2018 05:09:24 -0700 Subject: [PATCH 03/12] docs: update binary --- docs/old/staking/intro.rst | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/old/staking/intro.rst b/docs/old/staking/intro.rst index a8f4ea078..3a8973df1 100644 --- a/docs/old/staking/intro.rst +++ b/docs/old/staking/intro.rst @@ -65,8 +65,6 @@ You can see all available keys with: basecli keys list -See the `key management tutorial <../key-management.html>`__ for more information on managing keys. - Setup Testnet ------------- @@ -158,9 +156,9 @@ We'll have ``alice`` send some ``mycoin`` to ``bob``, who has now joined the net :: - basecli send --amount=1000fermion --seq=0 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 + basecli send --amount=1000mycoin --seq=0 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 -where the ``--seq`` flag is to be incremented for each transaction, the ``--name`` flag names the sender, and the ``--to`` flag takes ``bob``'s address. You'll see something like: +where the ``--seq`` flag is to be incremented for each transaction, the ``--name`` flag is the sender (alice), and the ``--to`` flag takes ``bob``'s address. You'll see something like: :: @@ -192,12 +190,16 @@ where the ``--seq`` flag is to be incremented for each transaction, the ``--name TODO: check the above with current actual output. -Check out ``bob``'s account, which should now have 992 fermions: +Check out ``bob``'s account, which should now have 1000 mycoin: :: basecli account 5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 + + + + Adding a Second Validator ------------------------- @@ -205,7 +207,7 @@ Next, let's add the second node as a validator. First, we need the pub_key data: -** need to make bob a priv_Val above! +** need to make bob a priv_Val above? :: @@ -240,11 +242,11 @@ with an output like: } -We should see ``bob``'s account balance decrease by 10 fermions: +We should see ``bob``'s account balance decrease by 10 mycoin: :: - gaia client query account 5D93A6059B6592833CBC8FA3DA90EE0382198985 + basecli account 5D93A6059B6592833CBC8FA3DA90EE0382198985 To confirm for certain the new validator is active, ask the tendermint node: @@ -256,7 +258,7 @@ If you now kill either node, blocks will stop streaming in, because there aren't enough validators online. Turn it back on and they will start streaming again. -Now that ``bob`` has declared candidacy, which essentially bonded 10 fermions and made him a validator, we're going to get ``charlie`` to delegate some coins to ``bob``. +Now that ``bob`` has declared candidacy, which essentially bonded 10 mycoin and made him a validator, we're going to get ``charlie`` to delegate some coins to ``bob``. Delegating ---------- @@ -265,13 +267,13 @@ First let's have ``alice`` send some coins to ``charlie``: :: - gaia client tx send --amount=1000fermion --sequence=2 --name=alice --to=48F74F48281C89E5E4BE9092F735EA519768E8EF + basecli tx --amount=1000mycoin --sequence=2 --name=alice --to=48F74F48281C89E5E4BE9092F735EA519768E8EF -Then ``charlie`` will delegate some fermions to ``bob``: +Then ``charlie`` will delegate some mycoin to ``bob``: :: - gaia client tx delegate --amount=10fermion --name=charlie --pubkey= + basecli tx delegate --amount=10mycoin --name=charlie --pubkey= You'll see output like: @@ -287,13 +289,13 @@ You'll see output like: "height": 51585 } -And that's it. You can query ``charlie``'s account to see the decrease in fermions. +And that's it. You can query ``charlie``'s account to see the decrease in mycoin. To get more information about the candidate, try: :: - gaia client query candidate --pubkey= + basecli query candidate --pubkey= and you'll see output similar to: @@ -326,7 +328,7 @@ It's also possible the query the delegator's bond like so: :: - gaia client query delegator-bond --delegator-address 48F74F48281C89E5E4BE9092F735EA519768E8EF --pubkey 52D6FCD8C92A97F7CCB01205ADF310A18411EA8FDCC10E65BF2FCDB05AD1689B + basecli query delegator-bond --delegator-address 48F74F48281C89E5E4BE9092F735EA519768E8EF --pubkey 52D6FCD8C92A97F7CCB01205ADF310A18411EA8FDCC10E65BF2FCDB05AD1689B with an output similar to: @@ -355,9 +357,7 @@ your VotingPower reduce and your account balance increase. :: - gaia client tx unbond --amount=5fermion --name=charlie --pubkey= - gaia client query account 48F74F48281C89E5E4BE9092F735EA519768E8EF + basecli unbond --amount=5mycoin --name=charlie --pubkey= + basecli account 48F74F48281C89E5E4BE9092F735EA519768E8EF -See the bond decrease with ``gaia client query delegator-bond`` like above. - -That concludes an overview of the ``gaia`` tooling for local testing. +See the bond decrease with ``basecli query delegator-bond`` like above. From 15011eaf2277b14455866d2012d2a4f6ec16208d Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Wed, 11 Apr 2018 10:14:34 -0400 Subject: [PATCH 04/12] docs: use correct binary --- docs/old/staking/intro.rst | 52 ++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/docs/old/staking/intro.rst b/docs/old/staking/intro.rst index 3a8973df1..d6f046aba 100644 --- a/docs/old/staking/intro.rst +++ b/docs/old/staking/intro.rst @@ -13,7 +13,7 @@ This example covers initial setup of a two-node testnet between a server in the Install ------- -The ``basecoind`` and ``basecli`` binaries: +The ``gaiad`` and ``gaiacli`` binaries: :: @@ -26,24 +26,24 @@ Let's jump right into it. First, we initialize some default files: :: - basecoind init + gaiad init which will output: :: - I[03-30|11:20:13.365] Found private validator module=main path=/root/.basecoind/config/priv_validator.json - I[03-30|11:20:13.365] Found genesis file module=main path=/root/.basecoind/config/genesis.json + I[03-30|11:20:13.365] Found private validator module=main path=/root/.gaiad/config/priv_validator.json + I[03-30|11:20:13.365] Found genesis file module=main path=/root/.gaiad/config/genesis.json Secret phrase to access coins: citizen hungry tennis noise park hire glory exercise link glow dolphin labor design grit apple abandon -This tell us we have a ``priv_validator.json`` and ``genesis.json`` in the ``~/.basecoind/config`` directory. A ``config.toml`` was also created in the same directory. It is a good idea to get familiar with those files. Write down the seed. +This tell us we have a ``priv_validator.json`` and ``genesis.json`` in the ``~/.gaiad/config`` directory. A ``config.toml`` was also created in the same directory. It is a good idea to get familiar with those files. Write down the seed. -The next thing we'll need to is add the key from ``priv_validator.json`` to the ``basecli`` key manager. For this we need a seed and a password: +The next thing we'll need to is add the key from ``priv_validator.json`` to the ``gaiacli`` key manager. For this we need a seed and a password: :: - basecli keys add alice --recover + gaiacli keys add alice --recover which will give you three prompts: @@ -63,7 +63,7 @@ You can see all available keys with: :: - basecli keys list + gaiacli keys list Setup Testnet ------------- @@ -72,7 +72,7 @@ Next, we start the daemon (do this in another window): :: - basecoind start + gaiad start and you'll see blocks start streaming through. @@ -91,8 +91,8 @@ Remember that ``alice`` was already created. On your second machine, install the :: - basecli keys add bob - basecli keys add charlie + gaiacli keys add bob + gaiacli keys add charlie both of which will prompt you for a password. Now we need to copy the ``genesis.json`` and ``config.toml`` from the first machine (with ``alice``) to the second machine. This is a good time to look at both these files. @@ -145,7 +145,7 @@ Now that your files are all setup, it's time to join the network. On your local :: - basecoind start + gaiad start and your new node will connect to the running validator (``alice``). @@ -156,7 +156,7 @@ We'll have ``alice`` send some ``mycoin`` to ``bob``, who has now joined the net :: - basecli send --amount=1000mycoin --seq=0 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 + gaiacli send --amount=1000mycoin --seq=0 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 where the ``--seq`` flag is to be incremented for each transaction, the ``--name`` flag is the sender (alice), and the ``--to`` flag takes ``bob``'s address. You'll see something like: @@ -194,15 +194,13 @@ Check out ``bob``'s account, which should now have 1000 mycoin: :: - basecli account 5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 - - - - + gaiacli account 5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 Adding a Second Validator ------------------------- +**This section is wrong/needs to be updated** + Next, let's add the second node as a validator. First, we need the pub_key data: @@ -225,7 +223,7 @@ Now ``bob`` can declare candidacy to that pubkey: :: - basecli declare-candidacy --amount=10mycoin --name=bob --pubkey= --moniker=bobby + gaiacli declare-candidacy --amount=10mycoin --name=bob --pubkey= --moniker=bobby with an output like: @@ -246,7 +244,7 @@ We should see ``bob``'s account balance decrease by 10 mycoin: :: - basecli account 5D93A6059B6592833CBC8FA3DA90EE0382198985 + gaiacli account 5D93A6059B6592833CBC8FA3DA90EE0382198985 To confirm for certain the new validator is active, ask the tendermint node: @@ -267,13 +265,13 @@ First let's have ``alice`` send some coins to ``charlie``: :: - basecli tx --amount=1000mycoin --sequence=2 --name=alice --to=48F74F48281C89E5E4BE9092F735EA519768E8EF + gaiacli tx --amount=1000mycoin --sequence=2 --name=alice --to=48F74F48281C89E5E4BE9092F735EA519768E8EF Then ``charlie`` will delegate some mycoin to ``bob``: :: - basecli tx delegate --amount=10mycoin --name=charlie --pubkey= + gaiacli tx delegate --amount=10mycoin --name=charlie --pubkey= You'll see output like: @@ -295,7 +293,7 @@ To get more information about the candidate, try: :: - basecli query candidate --pubkey= + gaiacli query candidate --pubkey= and you'll see output similar to: @@ -328,7 +326,7 @@ It's also possible the query the delegator's bond like so: :: - basecli query delegator-bond --delegator-address 48F74F48281C89E5E4BE9092F735EA519768E8EF --pubkey 52D6FCD8C92A97F7CCB01205ADF310A18411EA8FDCC10E65BF2FCDB05AD1689B + gaiacli query delegator-bond --delegator-address 48F74F48281C89E5E4BE9092F735EA519768E8EF --pubkey 52D6FCD8C92A97F7CCB01205ADF310A18411EA8FDCC10E65BF2FCDB05AD1689B with an output similar to: @@ -357,7 +355,7 @@ your VotingPower reduce and your account balance increase. :: - basecli unbond --amount=5mycoin --name=charlie --pubkey= - basecli account 48F74F48281C89E5E4BE9092F735EA519768E8EF + gaiacli unbond --amount=5mycoin --name=charlie --pubkey= + gaiacli account 48F74F48281C89E5E4BE9092F735EA519768E8EF -See the bond decrease with ``basecli query delegator-bond`` like above. +See the bond decrease with ``gaiacli query delegator-bond`` like above. From d7d09f3feab5b7d6bfd4eccdcd2cef8f7d59cd8d Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Wed, 11 Apr 2018 10:47:55 -0400 Subject: [PATCH 05/12] docs: cleanup --- docs/conf.py | 2 +- docs/index.rst | 25 +++++++++---------------- docs/sdk/install.rst | 20 +++++++------------- 3 files changed, 17 insertions(+), 30 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 3af51ef95..f0fa0a634 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ master_doc = 'index' # General information about the project. project = u'Cosmos-SDK' -copyright = u'2017, The Authors' +copyright = u'2018, The Authors' author = u'The Authors' # The version info for the project you're documenting, acts as replacement for diff --git a/docs/index.rst b/docs/index.rst index 80d5dd48d..23dd1e87a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -21,7 +21,7 @@ SDK sdk/overview.rst sdk/install.rst - sdk/glossary.rst +.. old/glossary.rst # not completely up to date but has good content .. Basecoin .. -------- @@ -29,19 +29,17 @@ SDK .. .. toctree:: :maxdepth: 2 -.. basecoin/basics.rst -.. basecoin/extensions.rst +.. old/basecoin/basics.rst # has a decent getting-start tutorial that's relatively up to date, should be consolidated with the other getting started doc Extensions ---------- -Replay Protection -~~~~~~~~~~~~~~~~~ +.. old/basecoin/extensions.rst # probably not worth salvaging -.. toctree:: - :maxdepth: 1 +.. Replay Protection +.. ~~~~~~~~~~~~~~~~~ - x/replay-protection.rst +.. old/replay-protection.rst # not sure if worth salvaging Staking @@ -55,12 +53,7 @@ Staking staking/local-testnet.rst staking/public-testnet.rst -Extras ------- +.. IBC +.. --- -.. One maxdepth for now - -.. toctree:: - :maxdepth: 1 - - ibc.rst +.. old/ibc.rst # needs to be updated diff --git a/docs/sdk/install.rst b/docs/sdk/install.rst index b4c0ad5da..33c176913 100644 --- a/docs/sdk/install.rst +++ b/docs/sdk/install.rst @@ -1,17 +1,12 @@ Install ======= -If you aren't used to compile go programs and just want the released -version of the code, please head to our -`downloads `__ page to get a -pre-compiled binary for your platform. - -Usually, Cosmos SDK can be installed to +Cosmos SDK can be installed to `$GOPATH/src/github.com/cosmos/cosmos-sdk` like a normal Go program: :: - go get -u github.com/cosmos/cosmos-sdk + go get github.com/cosmos/cosmos-sdk If the dependencies have been updated with breaking changes, or if another branch is required, ``dep`` is used for dependency management. @@ -21,10 +16,9 @@ repo, the correct way to install is: :: cd $GOPATH/src/github.com/cosmos/cosmos-sdk - git pull origin master - make all + make get_vendor_deps + make install + make install_examples -This will create the ``basecoind`` and ``basecli`` binaries locally in -``./build/bin``. ``make all`` implies ``make get_vendor_deps`` and uses -``glide`` to install the correct version of all dependencies. It also tests the -code, including some cli tests to make sure your binary behaves properly. +This will install ``gaiad`` and ``gaiacli`` and four example binaries: +``basecoind``, ``basecli``, ``democoind``, and ``democli``. From 4c0a5a6c209fd28fe8349a6781c42e2a49916a3d Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Wed, 11 Apr 2018 10:53:50 -0400 Subject: [PATCH 06/12] docs: move back updated intro --- docs/{old => }/staking/intro.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{old => }/staking/intro.rst (100%) diff --git a/docs/old/staking/intro.rst b/docs/staking/intro.rst similarity index 100% rename from docs/old/staking/intro.rst rename to docs/staking/intro.rst From c3cabbf78622e1e50744946802b63b9c4072e849 Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Wed, 11 Apr 2018 11:25:17 -0400 Subject: [PATCH 07/12] docs: add testnet doc from @kidinamoto01 --- docs/staking/testnet.rst | 211 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 docs/staking/testnet.rst diff --git a/docs/staking/testnet.rst b/docs/staking/testnet.rst new file mode 100644 index 000000000..b18adf5eb --- /dev/null +++ b/docs/staking/testnet.rst @@ -0,0 +1,211 @@ +# Cosmos Testnet Setup + +## Installment + +Requirement : + + [Go 1.9+](https://golang.org/dl/) + + [dep](https://github.com/golang/dep) + +### STEPS + +**Get Source Code** + +``` +go get github.com/cosmos/cosmos-sdk +``` + +Now we can fetch the correct versions of each dependency by running: + +``` +cd $GOPATH/src/github.com/cosmos/cosmos-sdk +git fetch --all +git checkout develop +make get_tools +make get_vendor_deps +make install +make install_examples +``` + +The latest cosmos-sdk should now be installed. Verify that everything is OK by running: + +``` +gaiad version +``` +You should see: + +``` +0.15.0-rc1-9d90c6b +``` + +And also: + +``` +basecli version +``` + +You should see: + +``` +0.15.0-rc1-9d90c6b +``` + +### Local-Test Example + +Here is a quick example to get you off your feet: + +First, generate a new key with a name, and save the address: +``` +MYNAME= +basecli keys new $MYNAME +basecli keys list +MYADDR= +``` +Now initialize a gaia chain: +``` +gaiad init --home=$HOME/.gaiad1 +``` + +you should see seed phrase for genesis account in the output & config & data folder int the home directory + +In the config folder, there will be the following file: config.toml , genesis.json, node_key.json ,priv_validator.json + +The genesis file should look like this: + +``` +{ + "genesis_time": "0001-01-01T00:00:00Z", + "chain_id": "test-chain-0TRiTa", + "validators": [ + { + "pub_key": { + "type": "AC26791624DE60", + "value": "" + }, + "power": 10, + "name": "" + } + ], + "app_hash": "", + "app_state": { + "accounts": [ + { + "address": "", + "coins": [ + { + "denom": "steak", + "amount": 9007199254740992 + } + ] + } + ] + } +} +``` + +**Note: ** We need to change the denomination of token from default to `steak` in genesis file. + +Then, recover the genesis account with `basecli` + +``` +basecli keys add --recover +``` + +By now, you have set up the first node. This is great! + +We can add a second node on our local machine by initiating a node in a new directory, and copying in the genesis. + +``` +gaiad init --home=$HOME/.gaiad2 +``` + +Replace the genesis file and toml file to another folder + +``` +cp $HOME/.gaiad/config/genesis.json $HOME/.gaiad2/config +cp $HOME/.gaiad/config/config.toml $HOME/.gaiad2/config +``` + +Get the node id of first node. +``` +gaiad show_node_id --home=$HOME/.gaiad1 +``` +We need to also modify $HOME/.gaiad2/config.toml to set new seeds and ports. It should look like: +``` +proxy_app = "tcp://127.0.0.1:46668" +moniker = "anonymous" +fast_sync = true +db_backend = "leveldb" +log_level = "state:info,*:error" + +[rpc] +laddr = "tcp://0.0.0.0:46667" + +[p2p] +laddr = "tcp://0.0.0.0:46666" +persistent_peers = "@0.0.0.0:46656" +``` +Great, now that we've initialized the chains, we can start both nodes in the background: +``` +gaiad start --home=$HOME/.gaiad1 &> gaia1.log & +NODE1_PID=$! +gaia start --home=$HOME/.gaiad2 &> gaia2.log & +NODE2_PID=$! +``` +Note we save the PID so we can later kill the processes. Of course, you can peak at your logs with tail gaia1.log, or follow them for a bit with tail -f gaia1.log. +Nice. We can also lookup the validator set: + +``` +basecli validatorset +``` +There is only **one** validator now. Let's add another one! +First, we need to create a new account: + +``` +basecli keys new +``` +Check that we now have two accounts: +``` +basecli keys list +``` +Then, we try to transfer some `strak` to another account: +``` +basecli send --amount=1000steak --to=$MYADDR2 --name=$NAME --chain-id= --node=tcp://localhost:46657 --sequence=0 +``` +**Note** We need to be careful with the `chain-id` & `sequence` + +Check the balance & sequence by : +``` +basecli account $MYADDR +``` +We can see the balance of $MYADDR2 is 1000 now. + +Findally, let's bind the validator in `$HOME/gaiad2`, get the pubkey first +``` +cat $HOME/.gaiad2/config/priv_validator.json | jq .pub_key.value +``` + +Go to [this website](http://tomeko.net/online_tools/base64.php?lang=en) to change pubkey from base64 to Hex. +Ok, now we can bond some coins to that pubkey: +``` +basecli bond --stake=1steak --validator= --sequence=0 --chain-id= --name=test +``` +Nice. We can see there are two validators: + +``` +basecli validatorset +``` +Check the balance of $MYADDR2 to see the difference: it has 1 less `steak`! +``` +basecli account $MYADDR2 +``` +To confirm for certain the new validator is active, check tendermint: +``` +curl localhost:46657/validators +``` +Finally, to relinquish all your power, unbond some coins. You should see your VotingPower reduce and your account balance increase. +``` +basecli unbond --sequence=# --chain-id= --name=test +``` + From 90d03a81b0a54032b64499bfb74697037aaed484 Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Wed, 11 Apr 2018 11:44:44 -0400 Subject: [PATCH 08/12] docs: rst-ify testnet doc --- docs/sdk/install.rst | 24 +++ docs/staking/testnet.rst | 316 +++++++++++++++++++-------------------- 2 files changed, 175 insertions(+), 165 deletions(-) diff --git a/docs/sdk/install.rst b/docs/sdk/install.rst index 33c176913..213c49a37 100644 --- a/docs/sdk/install.rst +++ b/docs/sdk/install.rst @@ -22,3 +22,27 @@ repo, the correct way to install is: This will install ``gaiad`` and ``gaiacli`` and four example binaries: ``basecoind``, ``basecli``, ``democoind``, and ``democli``. + +Verify that everything is OK by running: + +:: + + gaiad version + +you should see: + +:: + + 0.15.0-rc1-9d90c6b + +then with: + +:: + + basecli version + +you should see: + +:: + + 0.15.0-rc1-9d90c6b diff --git a/docs/staking/testnet.rst b/docs/staking/testnet.rst index b18adf5eb..eabe18bb6 100644 --- a/docs/staking/testnet.rst +++ b/docs/staking/testnet.rst @@ -1,211 +1,197 @@ -# Cosmos Testnet Setup +Testnet Setup +============= -## Installment +Install +------- -Requirement : +See the `installation guide <../sdk/install.html>`__ for details on installation. - [Go 1.9+](https://golang.org/dl/) - - [dep](https://github.com/golang/dep) - -### STEPS - -**Get Source Code** - -``` -go get github.com/cosmos/cosmos-sdk -``` - -Now we can fetch the correct versions of each dependency by running: - -``` -cd $GOPATH/src/github.com/cosmos/cosmos-sdk -git fetch --all -git checkout develop -make get_tools -make get_vendor_deps -make install -make install_examples -``` - -The latest cosmos-sdk should now be installed. Verify that everything is OK by running: - -``` -gaiad version -``` -You should see: - -``` -0.15.0-rc1-9d90c6b -``` - -And also: - -``` -basecli version -``` - -You should see: - -``` -0.15.0-rc1-9d90c6b -``` ### Local-Test Example Here is a quick example to get you off your feet: First, generate a new key with a name, and save the address: -``` -MYNAME= -basecli keys new $MYNAME -basecli keys list -MYADDR= -``` + +:: + + MYNAME= + basecli keys new $MYNAME + basecli keys list + MYADDR= + + Now initialize a gaia chain: -``` -gaiad init --home=$HOME/.gaiad1 -``` -you should see seed phrase for genesis account in the output & config & data folder int the home directory +:: + gaiad init --home=$HOME/.gaiad1 -In the config folder, there will be the following file: config.toml , genesis.json, node_key.json ,priv_validator.json +you should see seed phrase for genesis account in the output & config & data folder in the home directory. + +In the config folder, there will be the following files: ``config.toml``, ``genesis.json``, ``node_key.json``, and ``priv_validator.json``. The genesis file should look like this: -``` -{ - "genesis_time": "0001-01-01T00:00:00Z", - "chain_id": "test-chain-0TRiTa", - "validators": [ +:: + { - "pub_key": { - "type": "AC26791624DE60", - "value": "" - }, - "power": 10, - "name": "" - } - ], - "app_hash": "", - "app_state": { - "accounts": [ - { - "address": "", - "coins": [ + "genesis_time": "0001-01-01T00:00:00Z", + "chain_id": "test-chain-0TRiTa", + "validators": [ + { + "pub_key": { + "type": "AC26791624DE60", + "value": "" + }, + "power": 10, + "name": "" + } + ], + "app_hash": "", + "app_state": { + "accounts": [ { - "denom": "steak", - "amount": 9007199254740992 + "address": "", + "coins": [ + { + "denom": "steak", + "amount": 9007199254740992 + } + ] } ] } - ] - } -} -``` + } -**Note: ** We need to change the denomination of token from default to `steak` in genesis file. -Then, recover the genesis account with `basecli` +**Note:** We need to change the denomination of token from default to ``steak`` in genesis file. -``` -basecli keys add --recover -``` +Then, recover the genesis account with ``basecli``: + +:: + + basecli keys add --recover By now, you have set up the first node. This is great! -We can add a second node on our local machine by initiating a node in a new directory, and copying in the genesis. +We can add a second node on our local machine by initiating a node in a new directory, and copying in the ``genesis.json``: -``` -gaiad init --home=$HOME/.gaiad2 -``` +:: -Replace the genesis file and toml file to another folder + gaiad init --home=$HOME/.gaiad2 -``` -cp $HOME/.gaiad/config/genesis.json $HOME/.gaiad2/config -cp $HOME/.gaiad/config/config.toml $HOME/.gaiad2/config -``` +and replace the ``genesis.json`` and ``config.toml`` file: + +:: + + cp $HOME/.gaiad/config/genesis.json $HOME/.gaiad2/config + cp $HOME/.gaiad/config/config.toml $HOME/.gaiad2/config + +then, get the node id of first node: + +:: + + gaiad show_node_id --home=$HOME/.gaiad1 -Get the node id of first node. -``` -gaiad show_node_id --home=$HOME/.gaiad1 -``` We need to also modify $HOME/.gaiad2/config.toml to set new seeds and ports. It should look like: -``` -proxy_app = "tcp://127.0.0.1:46668" -moniker = "anonymous" -fast_sync = true -db_backend = "leveldb" -log_level = "state:info,*:error" -[rpc] -laddr = "tcp://0.0.0.0:46667" +:: + + proxy_app = "tcp://127.0.0.1:46668" + moniker = "anonymous" + fast_sync = true + db_backend = "leveldb" + log_level = "state:info,*:error" + + [rpc] + laddr = "tcp://0.0.0.0:46667" + + [p2p] + laddr = "tcp://0.0.0.0:46666" + persistent_peers = "@0.0.0.0:46656" + -[p2p] -laddr = "tcp://0.0.0.0:46666" -persistent_peers = "@0.0.0.0:46656" -``` Great, now that we've initialized the chains, we can start both nodes in the background: -``` -gaiad start --home=$HOME/.gaiad1 &> gaia1.log & -NODE1_PID=$! -gaia start --home=$HOME/.gaiad2 &> gaia2.log & -NODE2_PID=$! -``` -Note we save the PID so we can later kill the processes. Of course, you can peak at your logs with tail gaia1.log, or follow them for a bit with tail -f gaia1.log. + +:: + + gaiad start --home=$HOME/.gaiad1 &> gaia1.log & + NODE1_PID=$! + gaia start --home=$HOME/.gaiad2 &> gaia2.log & + NODE2_PID=$! + +Note that we save the PID so we can later kill the processes. You can peak at your logs with ``tail gaia1.log``, or follow them for a bit with ``tail -f gaia1.log``. + Nice. We can also lookup the validator set: -``` -basecli validatorset -``` -There is only **one** validator now. Let's add another one! +:: + + basecli validatorset + +There is only **one** validator now. Let's add another one! + First, we need to create a new account: -``` -basecli keys new -``` +:: + + basecli keys new + Check that we now have two accounts: -``` -basecli keys list -``` -Then, we try to transfer some `strak` to another account: -``` -basecli send --amount=1000steak --to=$MYADDR2 --name=$NAME --chain-id= --node=tcp://localhost:46657 --sequence=0 -``` -**Note** We need to be careful with the `chain-id` & `sequence` -Check the balance & sequence by : -``` -basecli account $MYADDR -``` -We can see the balance of $MYADDR2 is 1000 now. +:: + basecli keys list -Findally, let's bind the validator in `$HOME/gaiad2`, get the pubkey first -``` -cat $HOME/.gaiad2/config/priv_validator.json | jq .pub_key.value -``` +Then, we try to transfer some ``steak`` to another account: + +:: + + basecli send --amount=1000steak --to=$MYADDR2 --name=$NAME --chain-id= --node=tcp://localhost:46657 --sequence=0 + +**Note** We need to be careful with the ``chain-id`` and ``sequence`` + +Check the balance & sequence with: + +:: + + basecli account $MYADDR + +We can see the balance of ``$MYADDR2`` is 1000 now. + +Finally, let's bond the validator in ``$HOME/gaiad2``. Get the pubkey first: + +:: + + cat $HOME/.gaiad2/config/priv_validator.json | jq .pub_key.value + +Go to [this website](http://tomeko.net/online_tools/base64.php?lang=en) to change pubkey from base64 to Hex. -Go to [this website](http://tomeko.net/online_tools/base64.php?lang=en) to change pubkey from base64 to Hex. Ok, now we can bond some coins to that pubkey: -``` -basecli bond --stake=1steak --validator= --sequence=0 --chain-id= --name=test -``` -Nice. We can see there are two validators: -``` -basecli validatorset -``` -Check the balance of $MYADDR2 to see the difference: it has 1 less `steak`! -``` -basecli account $MYADDR2 -``` +:: + + basecli bond --stake=1steak --validator= --sequence=0 --chain-id= --name=test + +Nice. We can see there are now two validators: + +:: + + basecli validatorset + +Check the balance of ``$MYADDR2`` to see the difference: it has 1 less ``steak``! + +:: + basecli account $MYADDR2 + To confirm for certain the new validator is active, check tendermint: -``` -curl localhost:46657/validators -``` -Finally, to relinquish all your power, unbond some coins. You should see your VotingPower reduce and your account balance increase. -``` -basecli unbond --sequence=# --chain-id= --name=test -``` +:: + + curl localhost:46657/validators + +Finally, to relinquish all your power, unbond some coins. You should see your VotingPower reduce and your account balance increase. + +:: + + basecli unbond --sequence=# --chain-id= --name=test + +That's it! From 9924b1cb11b5eaf8984de446bdaedd40289a2d0f Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Wed, 11 Apr 2018 11:46:50 -0400 Subject: [PATCH 09/12] docs: build fixes --- docs/conf.py | 2 +- docs/index.rst | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index f0fa0a634..73a0220fd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -69,7 +69,7 @@ language = None # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'old'] # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' diff --git a/docs/index.rst b/docs/index.rst index 23dd1e87a..3bf1c06ad 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -49,9 +49,10 @@ Staking :maxdepth: 1 staking/intro.rst - staking/key-management.rst - staking/local-testnet.rst - staking/public-testnet.rst + staking/testnet.rst +.. staking/key-management.rst +.. staking/local-testnet.rst +.. staking/public-testnet.rst .. IBC .. --- From f9fc2e88d99701bbae40a07a42024aa871cce6d0 Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Wed, 11 Apr 2018 11:55:22 -0400 Subject: [PATCH 10/12] lil fixes --- docs/index.rst | 10 ++++------ docs/sdk/install.rst | 2 +- docs/staking/testnet.rst | 18 +++++++----------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 3bf1c06ad..1dc8eb35f 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -14,13 +14,11 @@ Welcome to the Cosmos SDK! SDK --- -.. One maxdepth for now - .. toctree:: :maxdepth: 1 - sdk/overview.rst sdk/install.rst +.. sdk/overview.rst # needs to be updated .. old/glossary.rst # not completely up to date but has good content .. Basecoin @@ -31,8 +29,8 @@ SDK .. old/basecoin/basics.rst # has a decent getting-start tutorial that's relatively up to date, should be consolidated with the other getting started doc -Extensions ----------- +.. Extensions +.. ---------- .. old/basecoin/extensions.rst # probably not worth salvaging @@ -48,8 +46,8 @@ Staking .. toctree:: :maxdepth: 1 - staking/intro.rst staking/testnet.rst +.. staking/intro.rst .. staking/key-management.rst .. staking/local-testnet.rst .. staking/public-testnet.rst diff --git a/docs/sdk/install.rst b/docs/sdk/install.rst index 213c49a37..d0e90b838 100644 --- a/docs/sdk/install.rst +++ b/docs/sdk/install.rst @@ -2,7 +2,7 @@ Install ======= Cosmos SDK can be installed to -`$GOPATH/src/github.com/cosmos/cosmos-sdk` like a normal Go program: +``$GOPATH/src/github.com/cosmos/cosmos-sdk`` like a normal Go program: :: diff --git a/docs/staking/testnet.rst b/docs/staking/testnet.rst index eabe18bb6..a04383690 100644 --- a/docs/staking/testnet.rst +++ b/docs/staking/testnet.rst @@ -1,14 +1,8 @@ Testnet Setup ============= -Install -------- - See the `installation guide <../sdk/install.html>`__ for details on installation. - -### Local-Test Example - Here is a quick example to get you off your feet: First, generate a new key with a name, and save the address: @@ -24,6 +18,7 @@ First, generate a new key with a name, and save the address: Now initialize a gaia chain: :: + gaiad init --home=$HOME/.gaiad1 you should see seed phrase for genesis account in the output & config & data folder in the home directory. @@ -63,8 +58,7 @@ The genesis file should look like this: } } - -**Note:** We need to change the denomination of token from default to ``steak`` in genesis file. +**Note:** We need to change the denomination of token from default to ``steak`` in the genesis file. Then, recover the genesis account with ``basecli``: @@ -80,7 +74,7 @@ We can add a second node on our local machine by initiating a node in a new dire gaiad init --home=$HOME/.gaiad2 -and replace the ``genesis.json`` and ``config.toml`` file: +and replace the ``genesis.json`` and ``config.toml`` files: :: @@ -139,6 +133,7 @@ First, we need to create a new account: Check that we now have two accounts: :: + basecli keys list Then, we try to transfer some ``steak`` to another account: @@ -147,7 +142,7 @@ Then, we try to transfer some ``steak`` to another account: basecli send --amount=1000steak --to=$MYADDR2 --name=$NAME --chain-id= --node=tcp://localhost:46657 --sequence=0 -**Note** We need to be careful with the ``chain-id`` and ``sequence`` +**Note:** We need to be careful with the ``chain-id`` and ``sequence`` Check the balance & sequence with: @@ -163,7 +158,7 @@ Finally, let's bond the validator in ``$HOME/gaiad2``. Get the pubkey first: cat $HOME/.gaiad2/config/priv_validator.json | jq .pub_key.value -Go to [this website](http://tomeko.net/online_tools/base64.php?lang=en) to change pubkey from base64 to Hex. +Go to `this website `__ to change pubkey from base64 to Hex. Ok, now we can bond some coins to that pubkey: @@ -180,6 +175,7 @@ Nice. We can see there are now two validators: Check the balance of ``$MYADDR2`` to see the difference: it has 1 less ``steak``! :: + basecli account $MYADDR2 To confirm for certain the new validator is active, check tendermint: From 0fd69d56ee7fc09af323416ca958d7f0b8731b48 Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Thu, 19 Apr 2018 12:14:06 -0400 Subject: [PATCH 11/12] docs: PR comments --- docs/sdk/install.rst | 2 +- docs/staking/intro.rst | 65 ++++++++++++++++++++++++++++++++-------- docs/staking/testnet.rst | 26 ++++++++-------- 3 files changed, 67 insertions(+), 26 deletions(-) diff --git a/docs/sdk/install.rst b/docs/sdk/install.rst index d0e90b838..03b219cb5 100644 --- a/docs/sdk/install.rst +++ b/docs/sdk/install.rst @@ -39,7 +39,7 @@ then with: :: - basecli version + gaiacli version you should see: diff --git a/docs/staking/intro.rst b/docs/staking/intro.rst index d6f046aba..68032c536 100644 --- a/docs/staking/intro.rst +++ b/docs/staking/intro.rst @@ -101,34 +101,75 @@ The ``genesis.json`` should look something like: :: { - "app_hash": "", "app_state": { "accounts": [ { - "address": "1FEADCDC8CCB22244769B9CC93C1F6D7489FC5AF", + "address": "1D9B2356CAADF46D3EE3488E3CCE3028B4283DEE", "coins": [ { - "denom": "mycoin", - "amount": 9007199254740992 + "denom": "fermion", + "amount": 100000 } ] } - ] + ], + "stake": { + "pool": { + "total_supply": 0, + "bonded_shares": { + "num": 0, + "denom": 1 + }, + "unbonded_shares": { + "num": 0, + "denom": 1 + }, + "bonded_pool": 0, + "unbonded_pool": 0, + "inflation_last_time": 0, + "inflation": { + "num": 7, + "denom": 100 + } + }, + "params": { + "inflation_rate_change": { + "num": 13, + "denom": 100 + }, + "inflation_max": { + "num": 20, + "denom": 100 + }, + "inflation_min": { + "num": 7, + "denom": 100 + }, + "goal_bonded": { + "num": 67, + "denom": 100 + }, + "max_validators": 100, + "bond_denom": "fermion" + } + } }, - "chain_id": "test-chain-EsYka3", - "genesis_time": "0001-01-01T00:00:00Z", "validators": [ { "pub_key": { - "type": "ed25519", - "data": "57B89D41F18FE3FE69250B44693A7D68DE4E03EC563F54C27F9A86CE8B81A4B7" + "type": "AC26791624DE60", + "value": "rgpc/ctVld6RpSfwN5yxGBF17R1PwMTdhQ9gKVUZp5g=" }, "power": 10, "name": "" } - ] + ], + "app_hash": "", + "genesis_time": "0001-01-01T00:00:00Z", + "chain_id": "test-chain-Uv1EVU" } + To notice is that the ``accounts`` field has a an address and a whole bunch of "mycoin". This is ``alice``'s address (todo: dbl check). Under ``validators`` we see the ``pub_key.data`` field, which will match the same field in the ``priv_validator.json`` file. The ``config.toml`` is long so let's focus on one field: @@ -156,9 +197,9 @@ We'll have ``alice`` send some ``mycoin`` to ``bob``, who has now joined the net :: - gaiacli send --amount=1000mycoin --seq=0 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 + gaiacli send --amount=1000mycoin --sequence=0 --name=alice --to=5A35E4CC7B7DC0A5CB49CEA91763213A9AE92AD6 --chain-id=test-chain-Uv1EVU -where the ``--seq`` flag is to be incremented for each transaction, the ``--name`` flag is the sender (alice), and the ``--to`` flag takes ``bob``'s address. You'll see something like: +where the ``--sequence`` flag is to be incremented for each transaction, the ``--name`` flag is the sender (alice), and the ``--to`` flag takes ``bob``'s address. You'll see something like: :: diff --git a/docs/staking/testnet.rst b/docs/staking/testnet.rst index a04383690..484ec3b5d 100644 --- a/docs/staking/testnet.rst +++ b/docs/staking/testnet.rst @@ -10,8 +10,8 @@ First, generate a new key with a name, and save the address: :: MYNAME= - basecli keys new $MYNAME - basecli keys list + gaiacli keys new $MYNAME + gaiacli keys list MYADDR= @@ -60,11 +60,11 @@ The genesis file should look like this: **Note:** We need to change the denomination of token from default to ``steak`` in the genesis file. -Then, recover the genesis account with ``basecli``: +Then, recover the genesis account with ``gaiacli``: :: - basecli keys add --recover + gaiacli keys add --recover By now, you have set up the first node. This is great! @@ -120,7 +120,7 @@ Nice. We can also lookup the validator set: :: - basecli validatorset + gaiacli validatorset There is only **one** validator now. Let's add another one! @@ -128,19 +128,19 @@ First, we need to create a new account: :: - basecli keys new + gaiacli keys new Check that we now have two accounts: :: - basecli keys list + gaiacli keys list Then, we try to transfer some ``steak`` to another account: :: - basecli send --amount=1000steak --to=$MYADDR2 --name=$NAME --chain-id= --node=tcp://localhost:46657 --sequence=0 + gaiacli send --amount=1000steak --to=$MYADDR2 --name=$NAME --chain-id= --node=tcp://localhost:46657 --sequence=0 **Note:** We need to be careful with the ``chain-id`` and ``sequence`` @@ -148,7 +148,7 @@ Check the balance & sequence with: :: - basecli account $MYADDR + gaiacli account $MYADDR We can see the balance of ``$MYADDR2`` is 1000 now. @@ -164,19 +164,19 @@ Ok, now we can bond some coins to that pubkey: :: - basecli bond --stake=1steak --validator= --sequence=0 --chain-id= --name=test + gaiacli bond --stake=1steak --validator= --sequence=0 --chain-id= --name=test Nice. We can see there are now two validators: :: - basecli validatorset + gaiacli validatorset Check the balance of ``$MYADDR2`` to see the difference: it has 1 less ``steak``! :: - basecli account $MYADDR2 + gaiacli account $MYADDR2 To confirm for certain the new validator is active, check tendermint: @@ -188,6 +188,6 @@ Finally, to relinquish all your power, unbond some coins. You should see your Vo :: - basecli unbond --sequence=# --chain-id= --name=test + gaiacli unbond --sequence=# --chain-id= --name=test That's it! From 57b150960c226eaee761720cdd5bc14149ee795c Mon Sep 17 00:00:00 2001 From: Zach Ramsay Date: Thu, 19 Apr 2018 12:25:00 -0400 Subject: [PATCH 12/12] docs: add key generation pseudo code --- docs/index.rst | 3 ++- docs/sdk/key-management.rst | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 docs/sdk/key-management.rst diff --git a/docs/index.rst b/docs/index.rst index 1dc8eb35f..66e3f7cb8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,8 +18,9 @@ SDK :maxdepth: 1 sdk/install.rst + sdk/key-management.rst .. sdk/overview.rst # needs to be updated -.. old/glossary.rst # not completely up to date but has good content +.. old/glossary.rst # not completely up to date but has good content .. Basecoin .. -------- diff --git a/docs/sdk/key-management.rst b/docs/sdk/key-management.rst new file mode 100644 index 000000000..d2b657729 --- /dev/null +++ b/docs/sdk/key-management.rst @@ -0,0 +1,18 @@ +Key Management +============== + +Here we cover many aspects of handling keys within the Cosmos SDK framework. + +Pseudo Code +----------- + +Generating an address for an ed25519 public key (in pseudo code): + +:: + + const TypeDistinguisher = HexToBytes("1624de6220") + + // prepend the TypeDistinguisher as Bytes + SerializedBytes = TypeDistinguisher ++ PubKey.asBytes() + + Address = ripemd160(SerializedBytes)