Cosmos-sdk: Unbonding fractional shares causes crash

Created on 1 Nov 2018  Â·  12Comments  Â·  Source: cosmos/cosmos-sdk

Summary of Bug

Commit: ce23ad41ce7bc53494c80a2d73fdc1c9e39f7ec7

Trying to undelegate fractional shares like this on a one node testnet:

POST /stake/delegators/cosmos1u275j7enpehhvenv5d79shegn495mjsj2e0vvx/delegations
body:

{"begin_unbondings":[{"delegator_addr":"cosmos1u275j7enpehhvenv5d79shegn495mjsj2e0vvx","validator_addr":"cosmosvaloper1u275j7enpehhvenv5d79shegn495mjsj0dmeq4","shares":"99.5000000000"}],"base_req":{"sequence":"0","name":"local","password":"1234567890","account_number":"0","chain_id":"test-chain-CB49oT"},"gas":"50000000"}

causes:

  • timeout of request
  • sequence number is now expected to be 1 but querying for the sequence number I get 0
  • restarting the node always crashes:
panic: interface conversion: interface {} is nil, not *types.Validator

goroutine 1 [running]:
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/types.(*ValidatorSet).IncrementAccum(0xc00084aed0, 0x1)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/types/validator_set.go:77 +0x3a9
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/state.updateState(0xc000b623a0, 0x11, 0x1e, 0x0, 0xc000b623c0, 0x14, 0x14, 0x1, 0xc000b62400, 0x14, ...)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/state/execution.go:355 +0xae
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/state.(*BlockExecutor).ApplyBlock(0xc000874190, 0xc000b623a0, 0x11, 0x1e, 0x0, 0xc000b623c0, 0x14, 0x14, 0x1, 0xc000b62400, ...)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/state/execution.go:90 +0x217
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus.(*Handshaker).replayBlock(0xc000875958, 0xc000b623a0, 0x11, 0x1e, 0x0, 0xc000b623c0, 0x14, 0x14, 0x1, 0xc000b62400, ...)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus/replay.go:412 +0x21a
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus.(*Handshaker).ReplayBlocks(0xc000875958, 0xc000b623a0,0x11, 0x1e, 0x0, 0xc000b623c0, 0x14, 0x14, 0x1, 0xc000b62400, ...)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus/replay.go:343 +0x747
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus.(*Handshaker).Handshake(0xc000875958, 0x1d92320, 0xc0001e09a0, 0x2, 0x1d88200)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/consensus/replay.go:246 +0x3d2
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/node.NewNode(0xc000b7b9e0, 0x1d89800, 0xc0001e54a0, 0xc000077ac0, 0x1d7c760, 0xc00090b360, 0xc000077ce0, 0x1ca4fb0, 0xc000077cf0, 0x1d88200, ...)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/node/node.go:203 +0x6c4
github.com/cosmos/cosmos-sdk/server.startInProcess(0xc00017d480, 0x1ca57e8, 0x1d, 0x0, 0x0)
        /go/src/github.com/cosmos/cosmos-sdk/server/start.go:119 +0x3f1
github.com/cosmos/cosmos-sdk/server.StartCmd.func1(0xc000b7d8c0, 0xc00017d720, 0x0, 0x2, 0x0, 0x0)
        /go/src/github.com/cosmos/cosmos-sdk/server/start.go:40 +0xab
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).execute(0xc000b7d8c0, 0xc00017d6e0, 0x2, 0x2, 0xc000b7d8c0, 0xc00017d6e0)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:698 +0x47a
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc000b7c6c0, 0xc00017d640, 0xc000823e60, 0x181560d)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:783 +0x2dc
github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra.(*Command).Execute(0xc000b7c6c0, 0x1814ec2, 0xc0001c8d10)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/spf13/cobra/command.go:736 +0x2b
github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli.Executor.Execute(0xc000b7c6c0, 0x1ca5bd0, 0x2, 0xc0000c85e0)
        /go/src/github.com/cosmos/cosmos-sdk/vendor/github.com/tendermint/tendermint/libs/cli/setup.go:89 +0x4e
main.main()

Steps to Reproduce


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned
bug staking

Most helpful comment

Created a new account, bonded 3 steak to a validator, and unbonded 2.5 (via the CLI) successfully. I have not yet tried via the LCD.

All 12 comments

Wow, this looks bad, this is a state machine bug. Thanks @faboweb.

It's possible we've fixed this since that commit (15 days old) but we should check.

@faboweb can you report back if this is reproducible on the latest v0.25.0?

@alexanderbez I won't get to it before Monday. I put it on my todo list. Does it work on the CLI?

Don't sweat it, I'll test it out. Maybe during the process I'll also figure out the issue ;-)

Created a new account, bonded 3 steak to a validator, and unbonded 2.5 (via the CLI) successfully. I have not yet tried via the LCD.

wondering if is this isolated to lcd as well

Yeah. @fedekunze can you verify the LCD gaia lite when you have a moment?

If I unbond 2.5 steak, my delegation correctly drops to 97.5 steak but my undelegation shows only 2 steak. Is that correct behavior? In sum the undelegation tx would reduce my total steaks by 0.5 steak.

If I unbond 2.5 steak, my delegation correctly drops to 97.5 steak but my undelegation shows only 2 steak. Is that correct behavior? In sum the undelegation tx would reduce my total steaks by 0.5 steak.

That's correct; the amount of tokens you receive is rounded down.

So is this a documentation fix then?

Ahhh I think we still need to verify it works via Gaia Lite. I tried via the CLI and it works, I just haven't had time to test Gaia Lite. Can you test @jackzampolin?

Closing this but please reopen @faboweb if you can reproduce on the develop branch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ValarDragon picture ValarDragon  Â·  3Comments

hendrikhofstadt picture hendrikhofstadt  Â·  3Comments

ValarDragon picture ValarDragon  Â·  3Comments

mossid picture mossid  Â·  3Comments

ValarDragon picture ValarDragon  Â·  3Comments