cosmos / cosmos-sdk

:chains: A Framework for Building High Value Public Blockchains :sparkles:
https://cosmos.network/
Apache License 2.0
6.24k stars 3.61k forks source link

Basecoin CLI errors with apptx #19

Closed ethanfrey closed 7 years ago

ethanfrey commented 7 years ago

Start Server:

tendermint init
tendermint unsafe_reset_all
cd $GOPATH/src/github.com/tendermint/basecoin/data
basecoin start --in-proc --counter-plugin

Try client:

cd $GOPATH/src/github.com/tendermint/basecoin/data
basecoin apptx counter --valid
-> Error about no coins send :(
basecoin apptx --amount 10 counter --valid
-> Another error about fees
basecoin apptx --amount 10 --fee 2 counter --valid
-> Finally works!

The other tutorials (with sendtx and ibc didn't require fees...)

ethanfrey commented 7 years ago

When I try the same in mintcoin, I get invalid signatures.

You can reproduce here: https://github.com/tendermint/basecoin-examples/blob/master/mintcoin/README.md#testing-with-a-cli

I will investigate more tomorrow, but any hints are welcome.

ebuchman commented 7 years ago

That's just how the counter plugin is written... https://github.com/tendermint/basecoin/blob/develop/plugins/counter/counter.go#L57

Not really an issue, is it?

ethanfrey commented 7 years ago

Okay, if it is done in the plugin, that is fine. I saw the same issue with the Mintcoin plugin, which doesn't include those lines, and figured there was some cause in the framework. I'll just investigate mintcoin and accept the counter plugin behavior as correct.

ethanfrey commented 7 years ago

The issue is not due to the plugin. There are a number of requirements set in basecoin core, that I don't feel need to be there. In particular, requiring a non-zero amount of coins.

https://github.com/tendermint/basecoin/blob/develop/types/tx.go#L56-L61

(This was an issue, as I gave an account the right to create coin, but without already having some, it couldn't execute the apptx to mint more coin)

ethanfrey commented 7 years ago

Got beyond this an really weird issue. If I run basecoin start --in-proc --counter-plugin, I can use the counter plugin fine:

mintcoin apptx --fee 1 --amount 2 counter --valid
CounterTx: {"Valid":true,"Fee":[{"denom":"blank","amount":1}]}
Signed AppTx:
{"gas":0,"fee":{"denom":"blank","amount":1},"type":"counter","input":{"address":"D397BC62B435F3CF50570FBAB4340FE52C60858F","coins":[{"denom":"blank","amount":2}],"sequence":1,"signature":[1,"5B2D87E4FFBFB72C06784D61F5496AD289810B8484FAA0C48BE4F7DC49781A2242D88D4D6C4E50AE3A6F309348E6BD563F8164F2E949141674713DD5576F4702"],"pub_key":[1,"B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF"]},"data":"0101010105626C616E6B0000000000000001"}

However, if I clean up the data dir and run mintcoin start --in-proc --counter-plugin (which should have the same code), I get:

mintcoin apptx --fee 1 --amount 2 counter --valid
CounterTx: {"Valid":true,"Fee":[{"denom":"blank","amount":1}]}
Signed AppTx:
{"gas":0,"fee":{"denom":"blank","amount":1},"type":"counter","input":{"address":"D397BC62B435F3CF50570FBAB4340FE52C60858F","coins":[{"denom":"blank","amount":2}],"sequence":1,"signature":[1,"5B2D87E4FFBFB72C06784D61F5496AD289810B8484FAA0C48BE4F7DC49781A2242D88D4D6C4E50AE3A6F309348E6BD563F8164F2E949141674713DD5576F4702"],"pub_key":[1,"B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF"]},"data":"0101010105626C616E6B0000000000000001"}
BroadcastTxCommit got non-zero exit code: BaseInvalidSignature. ; Error in CheckTx;in validateInputAdvanced();Error (base) invalid signature;SignBytes: 010D6D696E745F636861696E5F69640100000000000000000105626C616E6B00000000000000010107636F756E7465720114D397BC62B435F3CF50570FBAB4340FE52C60858F01010105626C616E6B000000000000000201010001B3588BDC92015ED3CDB6F57A86379E8C79A7111063610B7E625487C76496F4DF01120101010105626C616E6B0000000000000001

Notice the exact same payload, pub key and signature in both cases.

Resolved this, I need to specify the chain_id in the client!

mintcoin apptx --chain_id mint_chain_id --fee 1 --amount 2 counter --valid

Added this comment in case anyone else has a similar problem, they may find the answer with search....