Cosmos-sdk: Automatic gas calculation doesn't work with generate_only

Created on 29 Jan 2019  Â·  8Comments  Â·  Source: cosmos/cosmos-sdk

Summary of Bug

If I try to generate a tx to be signed outside gaia and want to set gas = auto I get an error: Key anonymous not found.

Replicate:

POST /bank/accounts/cosmos1am86ggjvxyesmgr9famzau5k7u8h43hnkyaet3/transfers
Body:

{"amount":[{"denom":"photino","amount":"10"}],"base_req":{"sequence":"7","name":"anonymous","from":"cosmos1am86ggjvxyesmgr9famzau5k7u8h43hnkyaet3","account_number":"0","chain_id":"local-testnet","gas":"auto","generate_only":true}}

Steps to Reproduce


For Admin Use

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

All 8 comments

Cannot reproduce this, at least in #3396

Sending

{  
   "submitType":"local",
   "password":"1234567890",
   "amount":[  
      {  
         "denom":"photino",
         "amount":"10"
      }
   ],
   "base_req":{  
      "sequence":"6",
      "from":"cosmos1w2y9602gnz0xd5c73jwyffnlkdkgzj23vaympz",
      "account_number":"0",
      "chain_id":"local-testnet",
      "gas":"auto",
      "generate_only":true
   }
}

Returns

{  
   "type":"auth/StdTx",
   "value":{  
      "msg":[  
         {  
            "type":"cosmos-sdk/Send",
            "value":{  
               "inputs":[  
                  {  
                     "address":"cosmos1w2y9602gnz0xd5c73jwyffnlkdkgzj23vaympz",
                     "coins":[  
                        {  
                           "denom":"photino",
                           "amount":"10"
                        }
                     ]
                  }
               ],
               "outputs":[  
                  {  
                     "address":"cosmos1w2y9602gnz0xd5c73jwyffnlkdkgzj23vaympz",
                     "coins":[  
                        {  
                           "denom":"photino",
                           "amount":"10"
                        }
                     ]
                  }
               ]
            }
         }
      ],
      "fee":{  
         "amount":null,
         "gas":"0"
      },
      "signatures":null,
      "memo":""
   }
}

See gas is now "0". So this was probably the issue.

{  
   "tx":{  
      "msg":[  
         {  
            "type":"cosmos-sdk/Send",
            "value":{  
               "inputs":[  
                  {  
                     "address":"cosmos1w2y9602gnz0xd5c73jwyffnlkdkgzj23vaympz",
                     "coins":[  
                        {  
                           "denom":"photino",
                           "amount":"10"
                        }
                     ]
                  }
               ],
               "outputs":[  
                  {  
                     "address":"cosmos1w2y9602gnz0xd5c73jwyffnlkdkgzj23vaympz",
                     "coins":[  
                        {  
                           "denom":"photino",
                           "amount":"10"
                        }
                     ]
                  }
               ]
            }
         }
      ],
      "fee":{  
         "amount":null,
         "gas":"auto"
      },
      "signatures":[  
         {  
            "pub_key":{  
               "type":"tendermint/PubKeySecp256k1",
               "value":"A+4lzuXXM4OJNHnIytTositlLomevcE9dw4JVO4IZaB6"
            },
            "signature":"Z5UaGpawpTFnAVuK4WDvcUIa+Wi0vw0QLgqALaZRZR5NEUqT1mwYk6j9fqQtym1o7uMYLQJpeZgvcYCs9tliUg==",
            "account_number":"0",
            "sequence":"6"
         }
      ],
      "memo":""
   },
   "return":"block"
}

Broadcasting this returns:

invalid character 'a' looking for beginning of value

@faboweb what exact steps and payloads are you running? The fees looks invalid.

I am posting against /bank/accounts/cosmos1am86ggjvxyesmgr9famzau5k7u8h43hnkyaet3/transfers

Check payload and response at https://github.com/cosmos/cosmos-sdk/issues/3423#issuecomment-458643986

Then I am broadcasting the response plus the signature: https://github.com/cosmos/cosmos-sdk/issues/3423#issuecomment-458646794

This all works when using a fixed gas amount.

Thanks @faboweb -- I'll take a deeper look into this shortly.

@jackzampolin do you deem this needed for the next milestone RC?

@alexanderbez I think it would be _nice_. Since we are trying to not have too many breaking state machine changes these small UX improvements would be good to get in that release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adrianbrink picture adrianbrink  Â·  3Comments

kevlubkcm picture kevlubkcm  Â·  3Comments

jackzampolin picture jackzampolin  Â·  3Comments

rigelrozanski picture rigelrozanski  Â·  3Comments

hendrikhofstadt picture hendrikhofstadt  Â·  3Comments