Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbonding, Redelegation #1119

Merged
merged 84 commits into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from 72 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
3d0e7ff
stake/fees spec updates
rigelrozanski May 17, 2018
43a0ed9
staking overview.md revisions, moving files
rigelrozanski May 18, 2018
a49f9cb
docs reorganization
rigelrozanski May 18, 2018
f972cab
staking spec state revisions
rigelrozanski May 23, 2018
752f084
transaction stake updates
rigelrozanski May 25, 2018
5a77d7d
complete staking spec update
rigelrozanski May 29, 2018
26681a8
WIP adding unbonding/redelegation commands
rigelrozanski Jun 2, 2018
8e677e8
added msg types for unbonding, redelegation
rigelrozanski Jun 2, 2018
43429ef
stake sub-package reorg
rigelrozanski Jun 2, 2018
482a3c5
...
rigelrozanski Jun 2, 2018
fd1eb5f
working stake reorg
rigelrozanski Jun 3, 2018
63a0dcc
...
rigelrozanski Jun 5, 2018
7eaa715
...
rigelrozanski Jun 5, 2018
3fac834
modify lcd tests to not use hardcoded json strings
rigelrozanski Jun 5, 2018
d69d179
add description update
rigelrozanski Jun 5, 2018
0efb0a4
index keys
rigelrozanski Jun 5, 2018
2153e0d
...
rigelrozanski Jun 5, 2018
f6b9893
...
rigelrozanski Jun 5, 2018
e460c06
key managment for unbonding redelegation complete
rigelrozanski Jun 6, 2018
8639f91
...
rigelrozanski Jun 6, 2018
9ee70ea
update stake errors
rigelrozanski Jun 6, 2018
bd41980
...
rigelrozanski Jun 6, 2018
40ad0a5
completed handleMsgCompleteUnbonding fn
rigelrozanski Jun 6, 2018
4be5e41
updated to use begin/complete unbonding/redelegation
rigelrozanski Jun 7, 2018
03c6804
...
rigelrozanski Jun 7, 2018
98dad7d
fix token shares bug
rigelrozanski Jun 13, 2018
4601bd5
develop docs into unbonding
rigelrozanski Jun 14, 2018
fc6ee07
...
rigelrozanski Jun 14, 2018
ffc8cc4
...
rigelrozanski Jun 14, 2018
6a5bc2d
Merge remote-tracking branch 'origin/develop' into rigel/unbonding
rigelrozanski Jun 16, 2018
436f32d
got non-tests compiling after merge develop
rigelrozanski Jun 17, 2018
37190aa
working fixing tests
rigelrozanski Jun 19, 2018
ed7b90e
PrivlegedKeeper -> PrivilegedKeeper
rigelrozanski Jun 19, 2018
af4fd6e
tests compile
rigelrozanski Jun 19, 2018
1d7d4d4
Merge remote-tracking branch 'origin/develop' into rigel/unbonding
rigelrozanski Jun 20, 2018
d427af7
fix some tests
rigelrozanski Jun 20, 2018
a0ac5e9
fixing tests
rigelrozanski Jun 20, 2018
b72a219
Merge branch 'develop' into rigel/unbonding
rigelrozanski Jun 20, 2018
8860fa3
remove PrivilegedKeeper
rigelrozanski Jun 20, 2018
24395fd
...
rigelrozanski Jun 20, 2018
258834f
...
rigelrozanski Jun 20, 2018
9ce6759
get unbonding bug
rigelrozanski Jun 20, 2018
1ae48da
only rpc sig verification failed tests now
rigelrozanski Jun 20, 2018
bc2e0d7
Merge branch 'develop' into rigel/unbonding
rigelrozanski Jun 20, 2018
ad73cd1
...
rigelrozanski Jun 20, 2018
60158d5
move percent unbonding/redelegation to the CLI and out of handler logic
rigelrozanski Jun 20, 2018
b1cb149
remove min unbonding height
rigelrozanski Jun 21, 2018
3cd8478
add lcd txs
rigelrozanski Jun 21, 2018
a3e04ce
add pool sanity checks, fix a buncha tests
rigelrozanski Jun 21, 2018
782afbb
fix ante. set lcd log to debug (#1322)
ebuchman Jun 21, 2018
ad9da64
Merge branch 'develop' into rigel/unbonding
rigelrozanski Jun 21, 2018
071d47b
redelegation tests, adding query functionality for bonds
rigelrozanski Jun 22, 2018
5dc163c
add self-delegations at genesis ref #1165
rigelrozanski Jun 22, 2018
6e2c66c
PR comments (mostly) addressed
rigelrozanski Jun 23, 2018
f004c6c
cleanup, added Query LCD functionality
rigelrozanski Jun 25, 2018
ceb8856
test cleanup/fixes
rigelrozanski Jun 25, 2018
9f99a17
Merge remote-tracking branch 'origin/develop' into rigel/unbonding
rigelrozanski Jun 25, 2018
32b75c5
fix governance test
rigelrozanski Jun 25, 2018
85c3639
Merge branch 'develop' into rigel/unbonding
rigelrozanski Jun 25, 2018
177ab4c
SlashValidatorSet -> ValidatorSet
rigelrozanski Jun 25, 2018
3f4e528
changelog
rigelrozanski Jun 25, 2018
40b9faf
stake lcd fix
rigelrozanski Jun 25, 2018
a500931
...
rigelrozanski Jun 25, 2018
c916f21
...
rigelrozanski Jun 25, 2018
82f3529
Merge branch 'develop' into rigel/unbonding
ebuchman Jun 25, 2018
d5ab2f3
x/auth: fix chainID in ante
ebuchman Jun 25, 2018
b8571b6
Merge branch 'rigel/unbonding' of https://github.com/cosmos/cosmos-sd…
rigelrozanski Jun 25, 2018
2511ef1
fix lcd test
rigelrozanski Jun 25, 2018
a029cb9
...
rigelrozanski Jun 25, 2018
9cddb06
fix lint, update lint make command for spelling
rigelrozanski Jun 25, 2018
7170bd9
Merge remote-tracking branch 'origin/develop' into rigel/unbonding
rigelrozanski Jun 26, 2018
74e0fb8
lowercase error string
rigelrozanski Jun 26, 2018
5329d73
don't expose coinkeeper in staking
rigelrozanski Jun 26, 2018
1a945a2
Merge remote-tracking branch 'origin/develop' into rigel/unbonding
rigelrozanski Jun 26, 2018
ffaefec
remove a few duplicate lines in changelog
rigelrozanski Jun 26, 2018
0012a46
...
rigelrozanski Jun 26, 2018
6f2c29b
chain_id in stake lcd tests
rigelrozanski Jun 26, 2018
637b275
Merge branch 'develop' into rigel/unbonding
cwgoes Jun 27, 2018
4908504
added transient redelegation
rigelrozanski Jun 27, 2018
34e46ac
Merge branch 'rigel/unbonding' of https://github.com/cosmos/cosmos-sd…
rigelrozanski Jun 27, 2018
f499b88
'transient' => 'transitive'
cwgoes Jun 27, 2018
bcace44
Merge branch 'develop' into rigel/unbonding
cwgoes Jun 27, 2018
de77006
Re-add nolint instruction
cwgoes Jun 27, 2018
791ad9c
Fix tiny linter error
cwgoes Jun 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ BREAKING CHANGES
* Removed MsgChangePubKey from auth
* Removed setPubKey from account mapper
* Removed GetMemo from Tx (it is still on StdTx)
* [cli] rearranged commands under subcommands
* [stake] remove Tick and add EndBlocker
* [stake] introduce concept of unbonding for delegations and validators
* `gaiacli stake unbond` replaced with `gaiacli stake begin-unbonding`
* introduced:
* `gaiacli stake complete-unbonding`
* `gaiacli stake begin-redelegation`
* `gaiacli stake complete-redelegation`

FEATURES
* [gaiacli] You can now attach a simple text-only memo to any transaction, with the `--memo` flag
Expand All @@ -27,7 +35,15 @@ FEATURES
* [server] Default config now creates a profiler at port 6060, and increase p2p send/recv rates
* [tests] Add WaitForNextNBlocksTM helper method

FIXES
FIXES
* [gaia] Added self delegation for validators in the genesis creation
* [cli] fixed cli-bash tests
* [ci] added cli-bash tests
* [basecoin] updated basecoin for stake and slashing
* [docs] fixed references to old cli commands
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did that happen in this PR? Some of these changelog entries look unrelated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah not sure how that got in there, removed the duplicate lines

* [lcd] tests now don't depend on raw json text
* [stake] error strings lower case
* [stake] pool loose tokens now accounts for unbonding and unbonding tokens not associated with any validator
* \#1259 - fix bug where certain tests that could have a nil pointer in defer
* \#1052 - Make all now works
* Retry on HTTP request failure in CLI tests, add option to retry tests in Makefile
Expand All @@ -37,6 +53,16 @@ FIXES
* \#1353 - CLI: Show pool shares fractions in human-readable format
* \#1258 - printing big.rat's can no longer overflow int64

IMPROVEMENTS
* bank module uses go-wire codec instead of 'encoding/json'
* auth module uses go-wire codec instead of 'encoding/json'
* revised use of endblock and beginblock
* [stake] module reorganized to include `types` and `keeper` package
* [stake] keeper always loads the store (instead passing around which doesn't really boost efficiency)
* [stake] edit-validator changes now can use the keyword [do-not-modify] to not modify unspecified `--flag` (aka won't set them to `""` value)
* [types] added common tag constants
* [stake] offload more generic functionality from the handler into the keeper

## 0.19.0

*June 13, 2018*
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ test_cover:
@bash tests/test_cover.sh

test_lint:
gometalinter.v2 --disable-all --enable='golint' --vendor ./...
gometalinter.v2 --disable-all --enable='golint' --enable='misspell' --vendor ./...

benchmark:
@go test -bench=. $(PACKAGES_NOCLITEST)
Expand Down
1 change: 1 addition & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) {
// Write the Deliver state and commit the MultiStore
app.deliverState.ms.Write()
commitID := app.cms.Commit()
// TODO: this is missing a module identifier and dumps byte array
app.Logger.Debug("Commit synced",
"commit", commitID,
)
Expand Down
89 changes: 70 additions & 19 deletions client/lcd/lcd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
func TestKeys(t *testing.T) {
name, password := "test", "1234567890"
addr, seed := CreateAddr(t, "test", password, GetKB(t))
cleanup, _, port := InitializeTestLCD(t, 2, []sdk.Address{addr})
cleanup, _, port := InitializeTestLCD(t, 1, []sdk.Address{addr})
defer cleanup()

// get seed
Expand Down Expand Up @@ -218,7 +218,7 @@ func TestValidators(t *testing.T) {
func TestCoinSend(t *testing.T) {
name, password := "test", "1234567890"
addr, seed := CreateAddr(t, "test", password, GetKB(t))
cleanup, _, port := InitializeTestLCD(t, 2, []sdk.Address{addr})
cleanup, _, port := InitializeTestLCD(t, 1, []sdk.Address{addr})
defer cleanup()

bz, err := hex.DecodeString("8FA6AB57AD6870F6B5B2E57735F38F2F30E73CB6")
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestCoinSend(t *testing.T) {
func TestIBCTransfer(t *testing.T) {
name, password := "test", "1234567890"
addr, seed := CreateAddr(t, "test", password, GetKB(t))
cleanup, _, port := InitializeTestLCD(t, 2, []sdk.Address{addr})
cleanup, _, port := InitializeTestLCD(t, 1, []sdk.Address{addr})
defer cleanup()

acc := getAccount(t, port, addr)
Expand Down Expand Up @@ -289,7 +289,7 @@ func TestIBCTransfer(t *testing.T) {
func TestTxs(t *testing.T) {
name, password := "test", "1234567890"
addr, seed := CreateAddr(t, "test", password, GetKB(t))
cleanup, _, port := InitializeTestLCD(t, 2, []sdk.Address{addr})
cleanup, _, port := InitializeTestLCD(t, 1, []sdk.Address{addr})
defer cleanup()

// query wrong
Expand Down Expand Up @@ -378,13 +378,13 @@ func TestValidatorsQuery(t *testing.T) {
func TestBonding(t *testing.T) {
name, password, denom := "test", "1234567890", "steak"
addr, seed := CreateAddr(t, "test", password, GetKB(t))
cleanup, pks, port := InitializeTestLCD(t, 2, []sdk.Address{addr})
cleanup, pks, port := InitializeTestLCD(t, 1, []sdk.Address{addr})
defer cleanup()

validator1Owner := pks[0].Address()

// create bond TX
resultTx := doBond(t, port, seed, name, password, addr, validator1Owner)
resultTx := doDelegate(t, port, seed, name, password, addr, validator1Owner)
tests.WaitForHeight(resultTx.Height+1, port)

// check if tx was committed
Expand All @@ -405,7 +405,7 @@ func TestBonding(t *testing.T) {
// testing unbonding

// create unbond TX
resultTx = doUnbond(t, port, seed, name, password, addr, validator1Owner)
resultTx = doBeginUnbonding(t, port, seed, name, password, addr, validator1Owner)
tests.WaitForHeight(resultTx.Height+1, port)

// query validator
Expand All @@ -416,12 +416,13 @@ func TestBonding(t *testing.T) {
assert.Equal(t, uint32(0), resultTx.CheckTx.Code)
assert.Equal(t, uint32(0), resultTx.DeliverTx.Code)

// TODO fix shares fn in staking
// should the sender should have not received any coins as the unbonding has only just begun
// query sender
//acc := getAccount(t, sendAddr)
//coins := acc.GetCoins()
//assert.Equal(t, int64(98), coins.AmountOf(coinDenom))
acc = getAccount(t, port, addr)
coins = acc.GetCoins()
assert.Equal(t, int64(40), coins.AmountOf("steak").Int64())

// TODO add redelegation, need more complex capabilities such to mock context and
}

func TestSubmitProposal(t *testing.T) {
Expand Down Expand Up @@ -606,15 +607,15 @@ func getDelegation(t *testing.T, port string, delegatorAddr, validatorAddr sdk.A
validatorAddrBech := sdk.MustBech32ifyVal(validatorAddr)

// get the account to get the sequence
res, body := Request(t, port, "GET", "/stake/"+delegatorAddrBech+"/bonding_status/"+validatorAddrBech, nil)
res, body := Request(t, port, "GET", "/stake/"+delegatorAddrBech+"/delegation/"+validatorAddrBech, nil)
require.Equal(t, http.StatusOK, res.StatusCode, body)
var bond stake.Delegation
err := cdc.UnmarshalJSON([]byte(body), &bond)
require.Nil(t, err)
return bond
}

func doBond(t *testing.T, port, seed, name, password string, delegatorAddr, validatorAddr sdk.Address) (resultTx ctypes.ResultBroadcastTxCommit) {
func doDelegate(t *testing.T, port, seed, name, password string, delegatorAddr, validatorAddr sdk.Address) (resultTx ctypes.ResultBroadcastTxCommit) {
// get the account to get the sequence
acc := getAccount(t, port, delegatorAddr)
accnum := acc.GetAccountNumber()
Expand All @@ -630,14 +631,17 @@ func doBond(t *testing.T, port, seed, name, password string, delegatorAddr, vali
"account_number": %d,
"sequence": %d,
"gas": 10000,
"delegate": [
"delegations": [
{
"delegator_addr": "%s",
"validator_addr": "%s",
"bond": { "denom": "%s", "amount": 60 }
}
],
"unbond": []
"begin_unbondings": [],
"complete_unbondings": [],
"begin_redelegates": [],
"complete_redelegates": []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chain_id might be needed here if not specified already (can't see entire JSON struct in diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added, using viper to receive in the test (which needs to be changed), I think that'll be my next PR, refactor out viper usage, pretty much the same as using global variables

}`, name, password, accnum, sequence, delegatorAddrBech, validatorAddrBech, "steak"))
res, body := Request(t, port, "POST", "/stake/delegations", jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body)
Expand All @@ -649,7 +653,9 @@ func doBond(t *testing.T, port, seed, name, password string, delegatorAddr, vali
return results[0]
}

func doUnbond(t *testing.T, port, seed, name, password string, delegatorAddr, validatorAddr sdk.Address) (resultTx ctypes.ResultBroadcastTxCommit) {
func doBeginUnbonding(t *testing.T, port, seed, name, password string,
delegatorAddr, validatorAddr sdk.Address) (resultTx ctypes.ResultBroadcastTxCommit) {

// get the account to get the sequence
acc := getAccount(t, port, delegatorAddr)
accnum := acc.GetAccountNumber()
Expand All @@ -665,14 +671,17 @@ func doUnbond(t *testing.T, port, seed, name, password string, delegatorAddr, va
"account_number": %d,
"sequence": %d,
"gas": 10000,
"delegate": [],
"unbond": [
"delegations": [],
"begin_unbondings": [
{
"delegator_addr": "%s",
"validator_addr": "%s",
"shares": "30"
}
]
],
"complete_unbondings": [],
"begin_redelegates": [],
"complete_redelegates": []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chain_id might be needed here (can't see entire JSON struct in diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

}`, name, password, accnum, sequence, delegatorAddrBech, validatorAddrBech))
res, body := Request(t, port, "POST", "/stake/delegations", jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body)
Expand All @@ -684,6 +693,48 @@ func doUnbond(t *testing.T, port, seed, name, password string, delegatorAddr, va
return results[0]
}

func doBeginRedelegation(t *testing.T, port, seed, name, password string,
delegatorAddr, validatorSrcAddr, validatorDstAddr sdk.Address) (resultTx ctypes.ResultBroadcastTxCommit) {

// get the account to get the sequence
acc := getAccount(t, port, delegatorAddr)
accnum := acc.GetAccountNumber()
sequence := acc.GetSequence()

delegatorAddrBech := sdk.MustBech32ifyAcc(delegatorAddr)
validatorSrcAddrBech := sdk.MustBech32ifyVal(validatorSrcAddr)
validatorDstAddrBech := sdk.MustBech32ifyVal(validatorDstAddr)

// send
jsonStr := []byte(fmt.Sprintf(`{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here might be where you want to pass chain_id, and set ctx.ChainID = body.ChainID in the handler

"name": "%s",
"password": "%s",
"account_number": %d,
"sequence": %d,
"gas": 10000,
"delegations": [],
"begin_unbondings": [],
"complete_unbondings": [],
"begin_redelegates": [
{
"delegator_addr": "%s",
"validator_src_addr": "%s",
"validator_dst_addr": "%s",
"shares": "30"
}
],
"complete_redelegates": []
}`, name, password, accnum, sequence, delegatorAddrBech, validatorSrcAddrBech, validatorDstAddrBech))
res, body := Request(t, port, "POST", "/stake/delegations", jsonStr)
require.Equal(t, http.StatusOK, res.StatusCode, body)

var results []ctypes.ResultBroadcastTxCommit
err := cdc.UnmarshalJSON([]byte(body), &results)
require.Nil(t, err)

return results[0]
}

func getValidators(t *testing.T, port string) []stakerest.StakeValidatorOutput {
// get the account to get the sequence
res, body := Request(t, port, "GET", "/stake/validators", nil)
Expand Down
5 changes: 3 additions & 2 deletions client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.Address) (
config.TxIndex.IndexAllTags = true

logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout))
logger = log.NewFilter(logger, log.AllowError())
logger = log.NewFilter(logger, log.AllowDebug())
privValidatorFile := config.PrivValidatorFile()
privVal := pvm.LoadOrGenFilePV(privValidatorFile)
privVal.Reset()
db := dbm.NewMemDB()
app := gapp.NewGaiaApp(logger, db)
cdc = gapp.MakeCodec() // XXX
cdc = gapp.MakeCodec()

genesisFile := config.GenesisFile()
genDoc, err := tmtypes.GenesisDocFromFile(genesisFile)
Expand Down Expand Up @@ -146,6 +146,7 @@ func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.Address) (
accAuth.Coins = sdk.Coins{sdk.NewCoin("steak", 100)}
acc := gapp.NewGenesisAccount(&accAuth)
genesisState.Accounts = append(genesisState.Accounts, acc)
genesisState.StakeData.Pool.LooseTokens += 100
}

appState, err := wire.MarshalJSONIndent(cdc, genesisState)
Expand Down
30 changes: 21 additions & 9 deletions cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"encoding/json"
"errors"

"github.com/spf13/pflag"
crypto "github.com/tendermint/go-crypto"
tmtypes "github.com/tendermint/tendermint/types"
Expand All @@ -17,8 +18,8 @@ import (

var (
// bonded tokens given to genesis validators/accounts
freeFermionVal = sdk.NewInt(100)
freeFermionsAcc = sdk.NewInt(50)
freeFermionVal = int64(100)
freeFermionsAcc = int64(50)
)

// State to Unmarshal
Expand Down Expand Up @@ -124,7 +125,7 @@ func GaiaAppGenTxNF(cdc *wire.Codec, pk crypto.PubKey, addr sdk.Address, name st

validator = tmtypes.GenesisValidator{
PubKey: pk,
Power: freeFermionVal.Int64(),
Power: freeFermionVal,
}
return
}
Expand Down Expand Up @@ -155,22 +156,33 @@ func GaiaAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState
accAuth := auth.NewBaseAccountWithAddress(genTx.Address)
accAuth.Coins = sdk.Coins{
{genTx.Name + "Token", sdk.NewInt(1000)},
{"steak", freeFermionsAcc},
{"steak", sdk.NewInt(freeFermionsAcc)},
}
acc := NewGenesisAccount(&accAuth)
genaccs[i] = acc
stakeData.Pool.LooseUnbondedTokens = stakeData.Pool.LooseUnbondedTokens.Add(freeFermionsAcc) // increase the supply
stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens + freeFermionsAcc // increase the supply

// add the validator
if len(genTx.Name) > 0 {
desc := stake.NewDescription(genTx.Name, "", "", "")
validator := stake.NewValidator(genTx.Address, genTx.PubKey, desc)
validator.PoolShares = stake.NewBondedShares(sdk.NewRatFromInt(freeFermionVal))

stakeData.Pool.LooseTokens = stakeData.Pool.LooseTokens + freeFermionVal // increase the supply

// add some new shares to the validator
var issuedDelShares sdk.Rat
validator, stakeData.Pool, issuedDelShares = validator.AddTokensFromDel(stakeData.Pool, freeFermionVal)
stakeData.Validators = append(stakeData.Validators, validator)

// pool logic
stakeData.Pool.BondedTokens = stakeData.Pool.BondedTokens.Add(freeFermionVal)
stakeData.Pool.BondedShares = sdk.NewRatFromInt(stakeData.Pool.BondedTokens)
// create the self-delegation from the issuedDelShares
delegation := stake.Delegation{
DelegatorAddr: validator.Owner,
ValidatorAddr: validator.Owner,
Shares: issuedDelShares,
Height: 0,
}

stakeData.Bonds = append(stakeData.Bonds, delegation)
}
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/gaia/cmd/gaiacli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func main() {
stakecmd.GetCmdCreateValidator(cdc),
stakecmd.GetCmdEditValidator(cdc),
stakecmd.GetCmdDelegate(cdc),
stakecmd.GetCmdUnbond(cdc),
stakecmd.GetCmdUnbond("stake", cdc),
stakecmd.GetCmdRedelegate("stake", cdc),
slashingcmd.GetCmdUnrevoke(cdc),
)...)
rootCmd.AddCommand(
Expand Down
4 changes: 2 additions & 2 deletions docs/spec/staking/end_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ processProvisions():

provisions = pool.Inflation * (pool.TotalSupply / hrsPerYr)

pool.LooseUnbondedTokens += provisions
feePool += LooseUnbondedTokens
pool.LooseTokens += provisions
feePool += LooseTokens

setPool(pool)

Expand Down
2 changes: 1 addition & 1 deletion docs/spec/staking/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ information, etc.

```golang
type Pool struct {
LooseUnbondedTokens int64 // tokens not associated with any validator
LooseTokens int64 // tokens not associated with any validator
UnbondedTokens int64 // reserve of unbonded tokens held with validators
UnbondingTokens int64 // tokens moving from bonded to unbonded pool
BondedTokens int64 // reserve of bonded tokens
Expand Down
3 changes: 2 additions & 1 deletion examples/basecoin/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ func (app *BasecoinApp) ExportAppStateAndValidators() (appState json.RawMessage,
app.accountMapper.IterateAccounts(ctx, appendAccount)

genState := types.GenesisState{
Accounts: accounts,
Accounts: accounts,
StakeData: stake.WriteGenesis(ctx, app.stakeKeeper),
}
appState, err = wire.MarshalJSONIndent(app.cdc, genState)
if err != nil {
Expand Down
Loading