cosmos / cosmos-sdk

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

[Bug]: protocolpool create-continuous-pool panics #20935

Open JulianToledano opened 1 month ago

JulianToledano commented 1 month ago

Is there an existing issue for this?

What happened?

When calling create-continuous-fund with a percentage expressed as a float, the command panics.

As I understand, auto-cli generates dynamicpb messages using protoreflect message Descriptor() and Interface(). In the case of MsgCreateContinuousFund, the percentage is set as a human-readable number.

Screenshot 2024-07-11 at 10 39 02

Thus, it fails when decoding, as the unmarshalling of LegacyDec expects a machine representation of the floating-point number.

https://github.com/cosmos/cosmos-sdk/blob/ab6400fbfd4e6310214c19a9e536d56dc6e30c38/x/protocolpool/types/tx.pb.go#L2885-L2887

panic: math/big: cannot unmarshal "0.1" into a *big.Int

goroutine 1 [running]:
cosmossdk.io/x/auth/tx.(*builder).GetTx(0x1400157a240)
        /Users/user/github.com/cosmos/cosmos-sdk/x/auth/tx/builder.go:99 +0xd8
github.com/cosmos/cosmos-sdk/client/tx.BroadcastTx({{0x1055f12e8, 0x140013b5650}, 0x0, {0x14001041b08, 0x4}, {0x10560dca8, 0x14000e37150}, {0x1055edf40, 0x14000d67040}, {0x105595da0, ...}, ...}, ...)
        /Users/user/github.com/cosmos/cosmos-sdk/client/tx/tx.go:108 +0x510
github.com/cosmos/cosmos-sdk/client/tx.GenerateOrBroadcastTxWithFactory({{0x1055f12e8, 0x140013b5650}, 0x0, {0x14001041b08, 0x4}, {0x10560dca8, 0x14000e37150}, {0x1055edf40, 0x14000d67040}, {0x105595da0, ...}, ...}, ...)
        /Users/user/github.com/cosmos/cosmos-sdk/client/tx/tx.go:67 +0x448
github.com/cosmos/cosmos-sdk/client/tx.GenerateOrBroadcastTxCLI({{0x1055f12e8, 0x140013b5650}, 0x0, {0x14001041b08, 0x4}, {0x10560dca8, 0x14000e37150}, {0x1055edf40, 0x14000d67040}, {0x105595da0, ...}, ...}, ...)
        /Users/user/github.com/cosmos/cosmos-sdk/client/tx/tx.go:32 +0x180
cosmossdk.io/client/v2/autocli.(*Builder).handleGovProposal(_, _, {_, _}, {{0x1055f12e8, 0x140013b5650}, 0x0, {0x14001041b08, 0x4}, {0x10560dca8, ...}, ...}, ...)
        /Users/user/github.com/cosmos/cosmos-sdk/client/v2/autocli/msg.go:227 +0x724
cosmossdk.io/client/v2/autocli.(*Builder).BuildMsgMethodCommand.func1(0x14001355808, {0x1056051c8, 0x140013ae8a0})
        /Users/user/github.com/cosmos/cosmos-sdk/client/v2/autocli/msg.go:136 +0x30c
cosmossdk.io/client/v2/autocli.(*Builder).buildMethodCommandCommon.func1(0x14001355808, {0x14000e90080, 0x2, 0x8})
        /Users/user/github.com/cosmos/cosmos-sdk/client/v2/autocli/common.go:97 +0x3dc
github.com/spf13/cobra.(*Command).execute(0x14001355808, {0x14000e90000, 0x8, 0x8})
        /Users/user/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:985 +0xbd8
github.com/spf13/cobra.(*Command).ExecuteC(0x14000eb6f08)
        /Users/user/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1117 +0x7d0
github.com/spf13/cobra.(*Command).Execute(0x14000eb6f08)
        /Users/user/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1041 +0x30
github.com/spf13/cobra.(*Command).ExecuteContext(0x14000eb6f08, {0x1055d12c8, 0x140013b4e70})
        /Users/user/go/pkg/mod/github.com/spf13/cobra@v1.8.1/command.go:1034 +0x70
github.com/cosmos/cosmos-sdk/server/cmd.Execute(0x14000eb6f08, {0x0, 0x0}, {0x14001029350, 0x21})
        /Users/user/github.com/cosmos/cosmos-sdk/server/cmd/execute.go:40 +0x2ac
main.main()
        /Users/user/github.com/cosmos/cosmos-sdk/simapp/simd/main.go:15 +0x40
Exiting.

Cosmos SDK Version

main

How to reproduce?

./simd tx protocolpool create-continuous-fund cosmos18mfx85veapt3xs0vdr2cx9skeregs9sqawku8f 0.1 --summary test --title test --deposit 100000stake

facundomedica commented 1 month ago

This looks like an issue, but made me realize we shouldn't be exposing that command at all, given that it's meant to be used only through gov proposals

julienrbrt commented 1 month ago

This looks like an issue, but made me realize we shouldn't be exposing that command at all, given that it's meant to be used only through gov proposals

We should expose the command, it will create a gov proposal thanks to https://github.com/cosmos/cosmos-sdk/blob/03d70aa/x/protocolpool/autocli.go#L73