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

gnokey does not accept -pkgpath #555

Closed
tadvi opened this issue Mar 3, 2023 · 13 comments · Fixed by #563
Closed

gnokey does not accept -pkgpath #555

tadvi opened this issue Mar 3, 2023 · 13 comments · Fixed by #563
Assignees
Labels
🐞 bug Something isn't working

Comments

@tadvi
Copy link

tadvi commented Mar 3, 2023

CLI stopped working

Description

Fails to read some CLI parameters

Your environment

Steps to reproduce

Trying to run this:

gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -broadcast "true" -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

fails with error: "pkgpath not specified"

Tried few other permutations of "pkgpath". All fail.

Proposed solution

My guess: CLI refactor broke some of the CLI parameter parsing.

@zivkovicmilos zivkovicmilos self-assigned this Mar 4, 2023
@zivkovicmilos zivkovicmilos added the investigating This behavior is still being tested out label Mar 4, 2023
@zivkovicmilos
Copy link
Member

Hey @tadvi,

Thank you for opening up an issue 🙏

I'll look into this and get back to you soon with what I find

@zivkovicmilos
Copy link
Member

Hey @tadvi,

It seems to be related with the way you're calling the command:

  • the broadcast flag does not take in a value, if you set -broadcast it will be true
  • the flags for maketx need to go before you invoke the subcommand addpkg

So having these fixes in mind, this should work:
gnokey maketx -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -broadcast -remote "localhost:26657" -chainid "dev" addpkg -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

I'll look into whether or not this flag positioning is strict in terms of subcommand invocation (this is probably enforced by the cli package we use). In the meantime, the command I've written down should work

@zivkovicmilos zivkovicmilos added ❓ question Questions about Gno investigating This behavior is still being tested out and removed investigating This behavior is still being tested out ❓ question Questions about Gno labels Mar 4, 2023
@zivkovicmilos
Copy link
Member

@tadvi

I've identified the underlying issue and have a hotfix on the way to master:
#563

After we merge out this PR, your original command should work just fine, without having to worry about flag positions in relation to subcommands.

Again, thank you for opening up this issue 🙏

@moul moul closed this as completed in #563 Mar 6, 2023
@zivkovicmilos zivkovicmilos added bug and removed investigating This behavior is still being tested out labels Mar 6, 2023
@tadvi
Copy link
Author

tadvi commented Mar 6, 2023

Did git pull.

Now on commit 001eb58 .

Did make build .

Same issue. Still getting error message "pkgpath not specified" .

@zivkovicmilos
Copy link
Member

zivkovicmilos commented Mar 6, 2023

@tadvi

How are you running gnokey?
Are you running it from the build folder after running make build:
./build/gnokey

or are you running the globally installed binary: gnokey ...?

If you are doing the latter, you need to install the updated binary again:
make install_gnokey

EDIT:
Please make sure you don't specify a value for the --broadcast flag as you did in the original command. This flag is true if it's listed as-is, and false if it's not. So the command that you should be running is:
gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -broadcast -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

@tadvi
Copy link
Author

tadvi commented Mar 7, 2023

make build

Run gnoland binary in separate terminal.

Then cd into build directory and run like this:

./gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -broadcast -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

This panics with :

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xae6cb7]

goroutine 1 [running]:
github.com/gnolang/gno/pkgs/crypto/keys/client.signAndBroadcast(0xc000330370, {0xc0000023a0?, 0x1000?, 0x7fe9198eefff?}, {{0xc00034b470, 0x1, 0x1}, {0x4c4b40, {{0x7ffec2542260, 0x5}, ...}}, ...}, ...)
	/home/tad/sage/gno/pkgs/crypto/keys/client/addpkg.go:160 +0x177
github.com/gnolang/gno/pkgs/crypto/keys/client.execAddPkg(0xc0003013c0, {0xc0000023a0?, 0x1, 0x2}, 0x10?)
	/home/tad/sage/gno/pkgs/crypto/keys/client/addpkg.go:126 +0x3f8
github.com/gnolang/gno/pkgs/crypto/keys/client.newAddPkgCmd.func1({0x0?, 0x0?}, {0xc0000023a0, 0x1, 0x2})
	/home/tad/sage/gno/pkgs/crypto/keys/client/addpkg.go:38 +0x4d
./gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

This keeps printing stream of byte values what appears to be infinite loop.

@anarcher
Copy link
Contributor

anarcher commented Mar 7, 2023

@tadvi Did you pull on 74ca2bc ?
I think that commit resolved the nil error .

@tadvi
Copy link
Author

tadvi commented Mar 7, 2023

Commit aa8a7d8

Tried both :

./gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" "true" -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1
./gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -broadcast "true" -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

Both fail with "pkgpath not specified".

My hello.gno file is in /build directory:

// hello.gno

package types

import (
	"errors"

	"gno.land/p/demo/avl"
)

var (
	gInt		int      	= -42
	gUint		uint    	= 42
	gString		string  	= "a string"
	gStringSlice	[]string	= []string{"a", "string", "slice"}
	gError		error   	= errors.New("an error")
	gIntSlice  	[]int    	= []int{-42, 0, 42}
	gUintSlice  	[]uint   	= []uint{0, 42, 84}
	
	gTree        	avl.Tree
)

func init() {
	gTree.Set("a", 	gInt)
	gTree.Set("A", 	"A FOR ALPHA")
	gTree.Set("1", 	"1 for one")
	gTree.Set("b", 	"b for beta")
	gTree.Set("g", 	"g for gamma")
	gTree.Set("!", 	"! for !")
	gTree.Set("d", 	"d for delta")
	gTree.Set("%", 	"% for percent")
	gTree.Set("|", 	"| for pipeline")
}

@zivkovicmilos
Copy link
Member

zivkovicmilos commented Mar 7, 2023

@tadvi

You need to drop "true" from either command, as it can't be parsed.

This works fine:
./gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

as well as this (with broadcast)
./gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -broadcast -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

@anarcher
Copy link
Contributor

anarcher commented Mar 7, 2023

I'm not sure but would you try that -gas-fee="1ugnot" insteads of -gas-fee "1ugnot" ?

gnokey maketx addpkg -pkgdir=. -gas-fee="1ugnot" -gas-wanted="5000000" -pkgpath="gno.land/r/test2" -broadcast=true anarcher
Enter password.

OK!
GAS WANTED: 5000000
GAS USED:   179565

@tadvi
Copy link
Author

tadvi commented Mar 7, 2023

Thanks. I am making progress:

./gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -broadcast -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1

This runs for awhile then gives this error:

RPC error -32600 - Invalid Request: http: request body too large

@tadvi
Copy link
Author

tadvi commented Mar 8, 2023

Commit a693e08

Still produces error due to CLI parameter not getting set.

build/gnokey maketx addpkg -deposit "1ugnot" -gas-fee "1ugnot" -gas-wanted "5000000" -remote "localhost:26657" -chainid "dev" -pkgdir "." -pkgpath "gno.land/r/demo/hello" test1
panic: cannot create package with invalid name ""

goroutine 1 [running]:
github.com/gnolang/gno/pkgs/gnolang.validatePkgName({0x0, 0x0})
	/home/tad/sage/gno/pkgs/gnolang/nodes.go:2023 +0x9f
github.com/gnolang/gno/pkgs/gnolang.ReadMemPackage({0x7ffdcf99f2a8, 0x1}, {0x7ffdcf99f2b3, 0x15})
	/home/tad/sage/gno/pkgs/gnolang/nodes.go:1131 +0xe5
github.com/gnolang/gno/pkgs/crypto/keys/client.execAddPkg(0xc000123f40, {0xc000036230?, 0x1, 0x1}, 0xf?)
	/home/tad/sage/gno/pkgs/crypto/keys/client/addpkg.go:98 +0x165
github.com/gnolang/gno/pkgs/crypto/keys/client.newAddPkgCmd.func1({0x0?, 0x0?}, {0xc000036230, 0x1, 0x1})
	/home/tad/sage/gno/pkgs/crypto/keys/client/addpkg.go:38 +0x4d

@zivkovicmilos
Copy link
Member

@tadvi

This is unrelated to the CLI, and it has to do with how addpkg executes.

Please check the pkdir param you're providing (it should point to the actual package that has .gno files), ex:
examples/gno.land/p/demo/stack

@ajnavarro ajnavarro added 🐞 bug Something isn't working and removed bug labels May 15, 2023
@moul moul moved this to 🚀 Needed for Launch in 🚀 The Launch [DEPRECATED] Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Status: 🚀 Needed for Launch
Development

Successfully merging a pull request may close this issue.

4 participants