Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: code using main branch cannot send transactions using cli command #18122

Closed
1 task done
luchenqun opened this issue Oct 14, 2023 · 19 comments · Fixed by #19060
Closed
1 task done

[Bug]: code using main branch cannot send transactions using cli command #18122

luchenqun opened this issue Oct 14, 2023 · 19 comments · Fixed by #19060
Assignees
Labels

Comments

@luchenqun
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

First use the command simd testnet init-files --v 1 --output-dir ./nodes --chain-id simulation-app --keyring-backend test to initialize a test network
Then try to send a transfer transaction using the command simd tx bank send node0 cosmos1lh6pmahlkytz7lmrs25a42j6kxlmztyt204kyq 1stake --home ./nodes/node0/simd --keyring-backend test --chain-id simulation-app -y
The following error occurred:

invalid argument "node0" for "--0" flag: invalid account address or key name: decoding bech32 failed: invalid bech32 string length 5

Cosmos SDK Version

main

How to reproduce?

No response

@julienrbrt
Copy link
Member

julienrbrt commented Oct 14, 2023

Hi, is node0 is your keyring?
The error message means that node0 isn't a valid address or isn't a key name in the keyring.

Can you try to list the keys?

Can you verify that it uses the right home? (If not it is the same issue as here: #17822, having a fix incoming soon).

@julienrbrt julienrbrt self-assigned this Oct 14, 2023
@luchenqun
Copy link
Contributor Author

The account exists in the keyring-test directory

simd keys list --keyring-backend test --home ./nodes/node0/simd                                                                                           
- address: cosmos14gd8a9whwa95m6n8qcc7m3rtrx0ep0tjdgn7m8
  name: node0
  pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Amch1JQG486aee4I/Ey+cceRLAFq5pw8jKvK3QTVsUt3"}'
  type: local

@luchenqun
Copy link
Contributor Author

In addition, for the same operation, there is no problem with tag v0.47.5, only the main branch has problems.

@julienrbrt
Copy link
Member

Thank your for checking, I'll have a look 👍

@tac0turtle
Copy link
Member

bank send works for me on main. I tried node0 with a the address you sent and it work fine for me as well. im unable to reproduce your error

@luchenqun
Copy link
Contributor Author

luchenqun commented Oct 16, 2023

Well, I just used the main branch (commit id is bb34c42) and it still doesn’t work. These are all the operations I did in the cosmos-sdk directory (I am on macos, the bold part is the command).

➜ cosmos-sdk git:(main) date
Mon Oct 16 21:09:43 CST 2023
➜ cosmos-sdk git:(main) make build
cd /Users/lcq/go/src/github.com/cosmos/cosmos-sdk/simapp && go build -mod=readonly -tags "netgo ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version=0.46.0-beta2-2745-gbb34c42f06 -X github.com/cosmos/cosmos-sdk/version.Commit=bb34c42f064d4c0b0e1db0d669c0e2f4139c879d -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" -w -s' -trimpath -o /Users/lcq/go/src/github.com/cosmos/cosmos-sdk/build/ ./...
➜ cosmos-sdk git:(main) cd build && ll simd
-rwxr-xr-x 1 lcq staff 92M Oct 16 21:09 simd
➜ build git:(simd) rm -rf nodes
➜ build git:(simd) ./simd testnet init-files --v 1 --output-dir ./nodes --chain-id simulation-app --keyring-backend test
Successfully initialized 1 node directories
➜ build git:(simd) ** nohup ./simd start --home ./nodes/node0/simd >./nodes/simd.log 2>&1 & **
[1] 18213
➜ build git:(simd) ./simd tx bank send node0 cosmos1gfg9ucc7rrzc207y9qfmf58erftzf8z8ww5lr7 1stake --home ./nodes/node0/simd --keyring-backend test --chain-id simulation-app -y
invalid argument "node0" for "--0" flag: invalid account address or key name: decoding bech32 failed: invalid bech32 string length 5
➜ build git:(simd) ./simd keys list --keyring-backend test --home ./nodes/node0/simd

  • address: cosmos1mta067yu6kkr93gzq4m9hettyuaqrlad3h9uzn
    name: node0
    pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A39Zn72TmoyLs7HVCqAUiUbySDty4CPF5YX2pZW2Scq3"}'
    type: local

In addition, for the same operation, there is no problem with tag v0.47.5

➜ cosmos-sdk git:(main) git checkout v0.47.5
Note: switching to 'v0.47.5'.
.......
HEAD is now at 2e9e5d6 chore: prepare v0.47.5 (#17407)
➜ cosmos-sdk git:(2e9e5d6) make build
cd /Users/lcq/go/src/github.com/cosmos/cosmos-sdk/simapp && go build -mod=readonly -tags "netgo ledger" -ldflags '-X github.com/cosmos/cosmos-sdk/version.Name=sim -X github.com/cosmos/cosmos-sdk/version.AppName=simd -X github.com/cosmos/cosmos-sdk/version.Version=0.47.5 -X github.com/cosmos/cosmos-sdk/version.Commit=2e9e5d6eea24d6c11eddc9c002c66e89ae036187 -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger" -X github.com/cometbft/cometbft/version.TMCoreSemVer=v0.37.2 -w -s' -trimpath -o /Users/lcq/go/src/github.com/cosmos/cosmos-sdk/build/ ./...
➜ cosmos-sdk git:(2e9e5d6) cd build
➜ build git:(simd) ./simd testnet init-files --v 1 --output-dir ./nodes --chain-id simulation-app --keyring-backend test
Successfully initialized 1 node directories
➜ build git:(simd) nohup ./simd start --home ./nodes/node0/simd >./nodes/simd.log 2>&1 &
[1] 19255
➜ build git:(simd) ./simd keys list --keyring-backend test --home ./nodes/node0/simd

  • address: cosmos17zy97lv9prfr2v934spuhp56zxh2nmjt57fxe3
    name: node0
    pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A0spAsYG3SL+3w05hJdJQUrvl/NNq2c8pM/8dhTsVCVq"}'
    type: local

➜ build git:(simd) ./simd tx bank send node0 cosmos1gfg9ucc7rrzc207y9qfmf58erftzf8z8ww5lr7 1stake --home ./nodes/node0/simd --keyring-backend test --chain-id simulation-app -y
code: 0
codespace: ""
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: '[]'
timestamp: ""
tx: null
txhash: C6107394F3230361530941989C59935FF3FD98F87B4610AF191A17F516D8F2C6

@julienrbrt
Copy link
Member

julienrbrt commented Oct 16, 2023

I, personally, can reproduce, looking into it as we speak.
This is because the keyring used to parse the input from the autocli flag handlers is created from the root.go and does not read any flag.

@luchenqun
Copy link
Contributor Author

That's right. I think you probably haven't read the --home flag. When I use the default home, the main branch is no problem

➜ build git:(simd) ./simd tx bank send my_validator cosmos1lh6pmahlkytz7lmrs25a42j6kxlmztyt204kyq 1stake --keyring-backend test --chain-id simulation-app -y
code: 0
codespace: ""
data: ""
events: []
gas_used: "0"
gas_wanted: "0"
height: "0"
info: ""
logs: []
raw_log: ""
timestamp: ""
tx: null
txhash: CDF7187321851C413EB12029FA18FEC21717F43E713D6BDEC829F2D1A933ABCA
➜ build git:(simd) ./simd tx bank send node0 cosmos1gfg9ucc7rrzc207y9qfmf58erftzf8z8ww5lr7 1stake --home ./nodes/node0/simd --keyring-backend test --chain-id simulation-app -y
invalid argument "node0" for "--0" flag: invalid account address or key name: decoding bech32 failed: invalid bech32 string length 5

@luchenqun
Copy link
Contributor Author

luchenqun commented Nov 4, 2023

By the way, using --dry-run for simulation testing will not work either, fox exapmle: simd tx bank send node0 cosmos1gfg9ucc7rrzc207y9qfmf58erftzf8z8ww5lr7 1stake --keyring-backend test --chain-id simulation-app --gas auto --fees 129550stake --home ./nodes/node0/simd --dry-run. @julienrbrt
When do you plan to fix this bug?

@julienrbrt
Copy link
Member

julienrbrt commented Nov 4, 2023

Im not in front of my laptop, but what message do you get after dry-run ?

This issue will be fixed next week.

@luchenqun
Copy link
Contributor Author

The same problem occurred as above:invalid argument "node0" for "--0" flag: invalid account address or key name: decoding bech32 failed: invalid bech32 string length 5

@luchenqun
Copy link
Contributor Author

I try to fix this problem but the cli has been basically refactored compared to the previous version v0.46.x, so I haven't found the problem after research for a long time.

@julienrbrt
Copy link
Member

Yes, it is the same problem. Basically the keyring flags aren't working on main for AutoCLI commands. I know the reason, and I'll open a PR fixing it next week 👍

@luchenqun
Copy link
Contributor Author

Looks like this issue hasn't been fixed yet?

@julienrbrt
Copy link
Member

Yep yep. Other features on client/v2 got in first. This fix will come, nw.

@luchenqun
Copy link
Contributor Author

So how do you send transactions use cli command?

@julienrbrt
Copy link
Member

So how do you send transactions use cli command?

For reference: #18506 (comment)

@theforager
Copy link

Just +1'ing this issue. I ran into this error when going through the starter tutorial.

If a fix is hard, could we even just add a note on the tutorial so we don't lose folks?

@julienrbrt
Copy link
Member

julienrbrt commented Dec 30, 2023

Just +1'ing this issue. I ran into this error when going through the starter tutorial.

If a fix is hard, could we even just add a note on the tutorial so we don't lose folks?

The tutorial shouldn't use main, so that shouldn't be an issue.

The fix isn't that hard, I am trying to make it with no wiring changes for chains, but that is harder.

I'd rather include it with the next few refactor of client/v2, but I am definitely still on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants