Cosmos-sdk: Generate_only doesn't respect gas

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

Summary of Bug

Sending to POST /bank/accounts/cosmos1am86ggjvxyesmgr9famzau5k7u8h43hnkyaet3/transfers

{  
   "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 the gas difference.

Steps to Reproduce


For Admin Use

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

Most helpful comment

Assigning this to myself as I already had the logic implemented.

All 5 comments

Correct, @faboweb this is expected behavior. You cannot estimate gas for generate only as stated in #3396 because there is no pubkey attached.

This is why I opened this issue as I think it should be possible and the pubkey should not be requirement to do the simulation as for the sake of a simulation the pubkey could be any, am I wrong?

The public key is needed because without it the estimated gas value will be essentially useless -- a bulk of the gas costs come from signature verification.

You'll notice when you don't generate-only, a pubkey is added w/o a signature because you have access to the keybase.

UPDATE:

@faboweb Ok, I believe we can accomplish this by adding an empty array of StdSignature to bypass ValidateBasic.

Assigning this to myself as I already had the logic implemented.

closing this. Please reopen if you can reproduce it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rigelrozanski picture rigelrozanski  Â·  3Comments

kevlubkcm picture kevlubkcm  Â·  3Comments

mossid picture mossid  Â·  3Comments

adrianbrink picture adrianbrink  Â·  3Comments

hendrikhofstadt picture hendrikhofstadt  Â·  3Comments