From ff5641d78016c2ad10d087daa5c258eb1f16fcef Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Mon, 28 Oct 2024 19:04:46 -0600 Subject: [PATCH] fix: txs query and clarify vars --- ...0001-chore-use-cosmossdk.io-log-slog.patch | 6 +- ...allow-customizing-query-and-tx-flags.patch | 2 +- ...ht-not-passing-through-sdk-client-co.patch | 120 +++++++++++++++++- gserver/cmtclient.go | 18 +-- internal/gci/command.go | 6 +- 5 files changed, 134 insertions(+), 18 deletions(-) diff --git a/_cosmosvendor/patches/0001-chore-use-cosmossdk.io-log-slog.patch b/_cosmosvendor/patches/0001-chore-use-cosmossdk.io-log-slog.patch index 54393b1..a9e0bb6 100644 --- a/_cosmosvendor/patches/0001-chore-use-cosmossdk.io-log-slog.patch +++ b/_cosmosvendor/patches/0001-chore-use-cosmossdk.io-log-slog.patch @@ -1,4 +1,4 @@ -From 350a5e27a2b3973d3795ec674895bcf8a7da19ec Mon Sep 17 00:00:00 2001 +From 1cf60bd15d87beb91b125ce4e3cb96db54310dc6 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Fri, 25 Oct 2024 15:35:39 -0400 Subject: [PATCH 1/3] chore: use cosmossdk.io/log/slog @@ -47,7 +47,7 @@ index c64fbc1f0d..4e07773667 100644 return SetCmdServerContext(cmd, v, logger) } diff --git a/server/v2/go.mod b/server/v2/go.mod -index 3a17088382..82f738fa42 100644 +index 1e2e763424..ad92f6dd06 100644 --- a/server/v2/go.mod +++ b/server/v2/go.mod @@ -4,6 +4,7 @@ go 1.23 @@ -59,7 +59,7 @@ index 3a17088382..82f738fa42 100644 cosmossdk.io/server/v2/stf => ./stf cosmossdk.io/store/v2 => ../../store/v2 diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod -index 130734beed..1fc6926c75 100644 +index f98bb35c54..6901e92b48 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -250,6 +250,7 @@ require ( diff --git a/_cosmosvendor/patches/0002-fix-allow-customizing-query-and-tx-flags.patch b/_cosmosvendor/patches/0002-fix-allow-customizing-query-and-tx-flags.patch index d484596..ba18da4 100644 --- a/_cosmosvendor/patches/0002-fix-allow-customizing-query-and-tx-flags.patch +++ b/_cosmosvendor/patches/0002-fix-allow-customizing-query-and-tx-flags.patch @@ -1,4 +1,4 @@ -From 9fcefeaab547f7ebb883d5a3127eea8420b04eea Mon Sep 17 00:00:00 2001 +From 5919943a70d3e554f29f1b0e44bf4b127c3629e3 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Fri, 25 Oct 2024 16:25:31 -0600 Subject: [PATCH 2/3] fix: allow customizing query and tx flags diff --git a/_cosmosvendor/patches/0003-hack-to-fix-height-not-passing-through-sdk-client-co.patch b/_cosmosvendor/patches/0003-hack-to-fix-height-not-passing-through-sdk-client-co.patch index c71286f..ed3c3b0 100644 --- a/_cosmosvendor/patches/0003-hack-to-fix-height-not-passing-through-sdk-client-co.patch +++ b/_cosmosvendor/patches/0003-hack-to-fix-height-not-passing-through-sdk-client-co.patch @@ -1,12 +1,126 @@ -From abcb8e5e1c3c37d7a11ad4a5555cf2948d397831 Mon Sep 17 00:00:00 2001 +From 2b13a63a06740e65303292bf7bf5db2f4b7140ed Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Sat, 26 Oct 2024 11:18:57 -0600 Subject: [PATCH 3/3] hack to fix height not passing through sdk client context --- - x/auth/types/account_retriever.go | 8 +++++++- - 1 file changed, 7 insertions(+), 1 deletion(-) + client/flags/flags.go | 94 +++++++++++++++---------------- + x/auth/types/account_retriever.go | 8 ++- + 2 files changed, 54 insertions(+), 48 deletions(-) +diff --git a/client/flags/flags.go b/client/flags/flags.go +index 14c798329e..a805f66a07 100644 +--- a/client/flags/flags.go ++++ b/client/flags/flags.go +@@ -42,49 +42,49 @@ const ( + + // List of CLI flags + const ( +- FlagHome = "home" +- FlagKeyringDir = "keyring-dir" +- FlagUseLedger = "ledger" +- FlagChainID = "chain-id" +- FlagNode = "node" +- FlagGRPC = "grpc-addr" +- FlagGRPCInsecure = "grpc-insecure" +- FlagGRPCTx = "grpc-addr-tx" +- FlagGRPCInsecureTx = "grpc-insecure-tx" +- FlagHeight = "height" +- FlagGasAdjustment = "gas-adjustment" +- FlagFrom = "from" +- FlagName = "name" +- FlagAccountNumber = "account-number" +- FlagSequence = "sequence" +- FlagNote = "note" +- FlagFees = "fees" +- FlagGas = "gas" +- FlagGasPrices = "gas-prices" +- FlagBroadcastMode = "broadcast-mode" +- FlagDryRun = "dry-run" +- FlagGenerateOnly = "generate-only" +- FlagOffline = "offline" +- FlagOutputDocument = "output-document" // inspired by wget -O +- FlagSkipConfirmation = "yes" +- FlagProve = "prove" +- FlagKeyringBackend = "keyring-backend" +- FlagPage = "page" +- FlagLimit = "limit" +- FlagSignMode = "sign-mode" +- FlagPageKey = "page-key" +- FlagOffset = "offset" +- FlagCountTotal = "count-total" +- FlagTimeoutTimestamp = "timeout-timestamp" +- FlagUnordered = "unordered" +- FlagKeyAlgorithm = "algo" +- FlagKeyType = "key-type" +- FlagFeePayer = "fee-payer" +- FlagFeeGranter = "fee-granter" +- FlagReverse = "reverse" +- FlagTip = "tip" +- FlagAux = "aux" +- FlagInitHeight = "initial-height" ++ FlagHome = "home" ++ FlagKeyringDir = "keyring-dir" ++ FlagUseLedger = "ledger" ++ FlagChainID = "chain-id" ++ FlagNode = "node" ++ FlagGRPC = "grpc-addr" ++ FlagGRPCInsecure = "grpc-insecure" ++ FlagGRPCConsensus = "grpc-addr-consensus" ++ FlagGRPCInsecureConsensus = "grpc-insecure-consensus" ++ FlagHeight = "height" ++ FlagGasAdjustment = "gas-adjustment" ++ FlagFrom = "from" ++ FlagName = "name" ++ FlagAccountNumber = "account-number" ++ FlagSequence = "sequence" ++ FlagNote = "note" ++ FlagFees = "fees" ++ FlagGas = "gas" ++ FlagGasPrices = "gas-prices" ++ FlagBroadcastMode = "broadcast-mode" ++ FlagDryRun = "dry-run" ++ FlagGenerateOnly = "generate-only" ++ FlagOffline = "offline" ++ FlagOutputDocument = "output-document" // inspired by wget -O ++ FlagSkipConfirmation = "yes" ++ FlagProve = "prove" ++ FlagKeyringBackend = "keyring-backend" ++ FlagPage = "page" ++ FlagLimit = "limit" ++ FlagSignMode = "sign-mode" ++ FlagPageKey = "page-key" ++ FlagOffset = "offset" ++ FlagCountTotal = "count-total" ++ FlagTimeoutTimestamp = "timeout-timestamp" ++ FlagUnordered = "unordered" ++ FlagKeyAlgorithm = "algo" ++ FlagKeyType = "key-type" ++ FlagFeePayer = "fee-payer" ++ FlagFeeGranter = "fee-granter" ++ FlagReverse = "reverse" ++ FlagTip = "tip" ++ FlagAux = "aux" ++ FlagInitHeight = "initial-height" + // FlagOutput is the flag to set the output format. + // This differs from FlagOutputDocument that is used to set the output file. + FlagOutput = "output" +@@ -165,11 +165,11 @@ func AddNodeFlags(f *pflag.FlagSet, tx bool) { + if tx { + if txOpts == nil || txOpts.DefaultGRPC == "" { + addDefaultCometRPCNodeFlag = true +- f.String(FlagGRPCTx, "", FlagGRPCDesc) +- f.Bool(FlagGRPCInsecureTx, false, FlagGRPCInsecureDesc) ++ f.String(FlagGRPCConsensus, "", FlagGRPCDesc) ++ f.Bool(FlagGRPCInsecureConsensus, false, FlagGRPCInsecureDesc) + } else { +- f.String(FlagGRPCTx, txOpts.DefaultGRPC, FlagGRPCDesc) +- f.Bool(FlagGRPCInsecureTx, true, FlagGRPCInsecureDesc) ++ f.String(FlagGRPCConsensus, txOpts.DefaultGRPC, FlagGRPCDesc) ++ f.Bool(FlagGRPCInsecureConsensus, true, FlagGRPCInsecureDesc) + } + } + if addDefaultCometRPCNodeFlag { diff --git a/x/auth/types/account_retriever.go b/x/auth/types/account_retriever.go index c46d433065..de59c9fc63 100644 --- a/x/auth/types/account_retriever.go diff --git a/gserver/cmtclient.go b/gserver/cmtclient.go index efedaaa..f142747 100644 --- a/gserver/cmtclient.go +++ b/gserver/cmtclient.go @@ -20,7 +20,7 @@ var _ client.CometRPC = (*Client)(nil) type Client struct { cmd *cobra.Command - gclient ggrpc.GordianGRPCClient + gClient ggrpc.GordianGRPCClient } func NewClient( @@ -34,12 +34,12 @@ func NewClient( } cc, err := grpc.NewClient(grpcAddress, dialOpts...) if err != nil { - return nil, fmt.Errorf("failed to dial gRPC: %w", err) + return nil, fmt.Errorf("failed to dial gordian gRPC: %w", err) } return &Client{ cmd: cmd, - gclient: ggrpc.NewGordianGRPCClient(cc), + gClient: ggrpc.NewGordianGRPCClient(cc), }, nil } @@ -48,10 +48,12 @@ func (c *Client) ABCIInfo(ctx context.Context) (*coretypes.ResultABCIInfo, error } func (c *Client) ABCIQuery(ctx context.Context, path string, data bytes.HexBytes) (*coretypes.ResultABCIQuery, error) { + // DO NOT IMPLEMENT unless very good reason to, app level queries should hit SDK grpc or other app interface directly. panic(fmt.Errorf("not implemented")) } func (c *Client) ABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, opts cmtclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) { + // DO NOT IMPLEMENT unless very good reason to, app level queries should hit SDK grpc or other app interface directly. panic(fmt.Errorf("not implemented")) } @@ -80,7 +82,7 @@ func (c *Client) BroadcastTxSync(ctx context.Context, tx cmttypes.Tx) (*coretype return nil, fmt.Errorf("failed to encode tx: %w", err) } - res, err := c.gclient.SimulateTransaction(ctx, &ggrpc.SubmitSimulationTransactionRequest{ + res, err := c.gClient.SimulateTransaction(ctx, &ggrpc.SubmitSimulationTransactionRequest{ Tx: txJson, }) if err != nil { @@ -90,7 +92,7 @@ func (c *Client) BroadcastTxSync(ctx context.Context, tx cmttypes.Tx) (*coretype return nil, fmt.Errorf("failure expecting simulated transaction: %s", res.Error) } - res, err = c.gclient.SubmitTransaction(ctx, &ggrpc.SubmitTransactionRequest{ + res, err = c.gClient.SubmitTransaction(ctx, &ggrpc.SubmitTransactionRequest{ Tx: txJson, }) if err != nil { @@ -110,7 +112,7 @@ func (c *Client) BroadcastTxSync(ctx context.Context, tx cmttypes.Tx) (*coretype } func (c *Client) Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error) { - valsRes, err := c.gclient.GetValidators(ctx, &ggrpc.GetValidatorsRequest{}) + valsRes, err := c.gClient.GetValidators(ctx, &ggrpc.GetValidatorsRequest{}) if err != nil { return nil, fmt.Errorf("failed to get validators: %w", err) } @@ -136,7 +138,7 @@ func (c *Client) Validators(ctx context.Context, height *int64, page, perPage *i } func (c *Client) Status(ctx context.Context) (*coretypes.ResultStatus, error) { - gRes, err := c.gclient.GetBlocksWatermark(ctx, &ggrpc.CurrentBlockRequest{}) + gRes, err := c.gClient.GetBlocksWatermark(ctx, &ggrpc.CurrentBlockRequest{}) if err != nil { return nil, fmt.Errorf("failed to get blocks watermark: %w", err) } @@ -144,7 +146,7 @@ func (c *Client) Status(ctx context.Context) (*coretypes.ResultStatus, error) { // TODO fill out remaining fields return &coretypes.ResultStatus{ SyncInfo: coretypes.SyncInfo{ - LatestBlockHeight: int64(gRes.CommittingHeight) - 1, + LatestBlockHeight: int64(gRes.CommittingHeight), }, }, nil } diff --git a/internal/gci/command.go b/internal/gci/command.go index 1ebf1ab..feea094 100644 --- a/internal/gci/command.go +++ b/internal/gci/command.go @@ -45,16 +45,16 @@ func NewSimdRootCmdWithGordian(lifeCtx context.Context, log *slog.Logger, homeDi return err } - grpcAddress, _ := cmd.Flags().GetString(sdkflags.FlagGRPCTx) + grpcAddress, _ := cmd.Flags().GetString(sdkflags.FlagGRPCConsensus) if grpcAddress == "" { return nil } - grpcInsecure, _ := cmd.Flags().GetBool(sdkflags.FlagGRPCInsecure) + grpcInsecure, _ := cmd.Flags().GetBool(sdkflags.FlagGRPCInsecureConsensus) clientShim, err := gserver.NewClient(cmd, grpcAddress, grpcInsecure) if err != nil { - return fmt.Errorf("failed to create gRPC client: %w", err) + return fmt.Errorf("failed to create gordian gRPC client: %w", err) } clientCtx := client.GetClientContextFromCmd(cmd)