gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + gno.land: a blockchain for timeless code and fair open-source.
https://gno.land/
Other
896 stars 375 forks source link

gnokey does not accept -pkgpath #555

Closed tadvi closed 1 year ago

tadvi commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Hey @tadvi,

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

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 commented 1 year ago

@tadvi

I've identified the underlying issue and have a hotfix on the way to master: https://github.com/gnolang/gno/pull/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 🙏

tadvi commented 1 year ago

Did git pull.

Now on commit 001eb58ff3b7496d2d8830e6bc98af918c775d91 .

Did make build .

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

zivkovicmilos commented 1 year ago

@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 commented 1 year ago
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 commented 1 year ago

@tadvi Did you pull on https://github.com/gnolang/gno/commit/74ca2bcab03cfddf8421330233188a9965fd19cf ? I think that commit resolved the nil error .

tadvi commented 1 year ago

Commit aa8a7d8e77106128450a655487921ddaaae9ba8a

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 commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Commit a693e08a78faca85373df89eebc299edc933c7c8

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 commented 1 year ago

@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