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

fix: txs query and clarify vars #12

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Date: Fri, 25 Oct 2024 15:35:39 -0400
Subject: [PATCH 1/3] chore: use cosmossdk.io/log/slog
Expand Down Expand Up @@ -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
Expand All @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
Date: Fri, 25 Oct 2024 16:25:31 -0600
Subject: [PATCH 2/3] fix: allow customizing query and tx flags
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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
Expand Down
18 changes: 10 additions & 8 deletions gserver/cmtclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var _ client.CometRPC = (*Client)(nil)

type Client struct {
cmd *cobra.Command
gclient ggrpc.GordianGRPCClient
gClient ggrpc.GordianGRPCClient
}

func NewClient(
Expand All @@ -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
}

Expand All @@ -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"))
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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)
}
Expand All @@ -136,15 +138,15 @@ 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)
}

// TODO fill out remaining fields
return &coretypes.ResultStatus{
SyncInfo: coretypes.SyncInfo{
LatestBlockHeight: int64(gRes.CommittingHeight) - 1,
LatestBlockHeight: int64(gRes.CommittingHeight),
},
}, nil
}
Expand Down
6 changes: 3 additions & 3 deletions internal/gci/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down