Cosmos-sdk: Wrong expected sequence number

Created on 19 Jul 2018  ·  5Comments  ·  Source: cosmos/cosmos-sdk

Summary of Bug


I was trying to delegate some steaks from a fresh account without sending any tx before. I expect it will take the sequece correctly as 0 but it doesn't.

Steps to Reproduce


I first run the following command.

gaiacli stake delegate --address-validator cosmosaccaddr10505nl7yftsme9jk2glhjhta7w0475uva87paj --address-delegator cosmosaccaddr16xae9kqqllsjak3ntxmlgn4s3jmvvyeqcwzgen --amount 5steak --from kwunyeung --chain-id=gaia-7001 --gas 10000000

Then there is an error

"Invalid sequence. Got 0, expected 1"

Then I put --sequence=1 at the end

gaiacli stake delegate --address-validator cosmosaccaddr10505nl7yftsme9jk2glhjhta7w0475uva87paj --address-delegator cosmosaccaddr16xae9kqqllsjak3ntxmlgn4s3jmvvyeqcwzgen --amount 5steak --from kwunyeung --chain-id=gaia-7001 --gas 10000000 --sequence=1

And the error became

"Invalid sequence. Got 1, expected 0"

I then switched back to --sequence=0 and tx can be commited.

It only happens when account sequence is 0.


For Admin Use

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

Most helpful comment

Yeah this used to exist a while back I remember - it was resolved

All 5 comments

I am able to reproduce the same results. It seems it only happens when you send/invoke your first tx. I.e. you don't need to specify the sequence on any future subsequent calls.

I'll take a look at this 👍

https://github.com/cosmos/cosmos-sdk/blob/5aae4740db678ad13627d16722b11d46835f91f4/store/iavlstore.go#L180-L191
this code make me some confuse,after a block was committed,I'm except to query the newest value which reflect the previous commit,but getHeight delayed a block,which cause I often got

“Data: common.FmtError{format:"Invalid sequence. Got 37, expected 38", args:[]interface {}(nil)}”

@ebuchman was this a bug? I saw this code exist on it‘s initial commit by Ethan Frey.

Yikes! This slipped my radar somehow. Looking into this now.

I was actually not able to reproduce this on the latest develop. I created a local testnet, from one of the nodes, I delegated successfully. Additionally, I created a new key, sent it some steak, and delegated from that with no problem.

If you are still having this problem on the latest develop, please report. Otherwise, we should close this issue :-)

Yeah this used to exist a while back I remember - it was resolved

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ValarDragon picture ValarDragon  ·  3Comments

fedekunze picture fedekunze  ·  3Comments

rigelrozanski picture rigelrozanski  ·  3Comments

cwgoes picture cwgoes  ·  3Comments

ValarDragon picture ValarDragon  ·  3Comments