-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
refactor(simapp): Audit simapp #21311
Changes from 19 commits
4aac90e
30d72a3
45d4e67
c907e8a
06ea466
f250a18
42d7553
fe63167
819afd2
98f70e9
08ebc82
ab373f2
23c480e
acb8140
adcda83
18f424e
f201230
24d83ba
3bd4f72
e3a98f3
55701f6
404241b
f76c488
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,12 @@ import ( | |
"github.com/cometbft/cometbft/p2p" | ||
pvm "github.com/cometbft/cometbft/privval" | ||
rpchttp "github.com/cometbft/cometbft/rpc/client/http" | ||
"github.com/cometbft/cometbft/rpc/client/local" | ||
cmtversion "github.com/cometbft/cometbft/version" | ||
"github.com/spf13/cobra" | ||
"google.golang.org/protobuf/encoding/protojson" | ||
"sigs.k8s.io/yaml" | ||
|
||
serverv2 "cosmossdk.io/server/v2" | ||
"cosmossdk.io/server/v2/cometbft/client/rpc" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
|
@@ -28,35 +28,40 @@ import ( | |
"github.com/cosmos/cosmos-sdk/version" | ||
) | ||
|
||
func (s *CometBFTServer[T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) { | ||
if s.config.AppTomlConfig.Standalone { | ||
func rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) { | ||
v := client.GetViperFromCmd(cmd) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when doing queries it shouldn't need to read the app.toml actually right, but the client.toml There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah flag node will get if from client.toml, so that's great. Not sure what a standalone check means for query tbh. |
||
appTomlConfig := AppTomlConfig{} | ||
if v != nil { | ||
if err := serverv2.UnmarshalSubConfig(v, ServerName, &appTomlConfig); err != nil { | ||
return nil, fmt.Errorf("failed to unmarshal config: %w", err) | ||
} | ||
} | ||
if appTomlConfig.Standalone { | ||
client, err := rpchttp.New(client.GetConfigFromCmd(cmd).RPC.ListenAddress) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client, nil | ||
} | ||
|
||
if s.Node == nil || cmd.Flags().Changed(FlagNode) { | ||
rpcURI, err := cmd.Flags().GetString(FlagNode) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if rpcURI != "" { | ||
return rpchttp.New(rpcURI) | ||
} | ||
rpcURI, err := cmd.Flags().GetString(FlagNode) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if rpcURI == "" { | ||
return nil, fmt.Errorf("rpc URI is empty") | ||
} | ||
|
||
return local.New(s.Node), nil | ||
return rpchttp.New(rpcURI) | ||
} | ||
|
||
// StatusCommand returns the command to return the status of the network. | ||
func (s *CometBFTServer[T]) StatusCommand() *cobra.Command { | ||
func StatusCommand() *cobra.Command { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comet queries should not relayed on |
||
cmd := &cobra.Command{ | ||
Use: "status", | ||
Short: "Query remote node for status", | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
rpcclient, err := s.rpcClient(cmd) | ||
rpcclient, err := rpcClient(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -82,7 +87,7 @@ func (s *CometBFTServer[T]) StatusCommand() *cobra.Command { | |
} | ||
|
||
// ShowNodeIDCmd - ported from CometBFT, dump node ID to stdout | ||
func (s *CometBFTServer[T]) ShowNodeIDCmd() *cobra.Command { | ||
func ShowNodeIDCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "show-node-id", | ||
Short: "Show this node's ID", | ||
|
@@ -100,7 +105,7 @@ func (s *CometBFTServer[T]) ShowNodeIDCmd() *cobra.Command { | |
} | ||
|
||
// ShowValidatorCmd - ported from CometBFT, show this node's validator info | ||
func (s *CometBFTServer[T]) ShowValidatorCmd() *cobra.Command { | ||
func ShowValidatorCmd() *cobra.Command { | ||
cmd := cobra.Command{ | ||
Use: "show-validator", | ||
Short: "Show this node's CometBFT validator info", | ||
|
@@ -134,7 +139,7 @@ func (s *CometBFTServer[T]) ShowValidatorCmd() *cobra.Command { | |
} | ||
|
||
// ShowAddressCmd - show this node's validator address | ||
func (s *CometBFTServer[T]) ShowAddressCmd() *cobra.Command { | ||
func ShowAddressCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "show-address", | ||
Short: "Shows this node's CometBFT validator consensus address", | ||
|
@@ -153,7 +158,7 @@ func (s *CometBFTServer[T]) ShowAddressCmd() *cobra.Command { | |
} | ||
|
||
// VersionCmd prints CometBFT and ABCI version numbers. | ||
func (s *CometBFTServer[T]) VersionCmd() *cobra.Command { | ||
func VersionCmd() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "version", | ||
Short: "Print CometBFT libraries' version", | ||
|
@@ -181,7 +186,7 @@ func (s *CometBFTServer[T]) VersionCmd() *cobra.Command { | |
} | ||
|
||
// QueryBlocksCmd returns a command to search through blocks by events. | ||
func (s *CometBFTServer[T]) QueryBlocksCmd() *cobra.Command { | ||
func QueryBlocksCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "blocks", | ||
Short: "Query for paginated blocks that match a set of events", | ||
|
@@ -196,7 +201,7 @@ for. Each module documents its respective events under 'xx_events.md'. | |
version.AppName, | ||
), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
rpcclient, err := s.rpcClient(cmd) | ||
rpcclient, err := rpcClient(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -231,7 +236,7 @@ for. Each module documents its respective events under 'xx_events.md'. | |
} | ||
|
||
// QueryBlockCmd implements the default command for a Block query. | ||
func (s *CometBFTServer[T]) QueryBlockCmd() *cobra.Command { | ||
func QueryBlockCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "block --type={height|hash} <height|hash>", | ||
Short: "Query for a committed block by height, hash, or event(s)", | ||
|
@@ -246,7 +251,8 @@ $ %s query block --%s=%s <hash> | |
RunE: func(cmd *cobra.Command, args []string) error { | ||
typ, _ := cmd.Flags().GetString(FlagType) | ||
|
||
rpcclient, err := s.rpcClient(cmd) | ||
rpcclient, err := rpcClient(cmd) | ||
fmt.Println("rpcclient", rpcclient, err) | ||
if err != nil { | ||
return err | ||
} | ||
|
@@ -318,14 +324,14 @@ $ %s query block --%s=%s <hash> | |
} | ||
|
||
// QueryBlockResultsCmd implements the default command for a BlockResults query. | ||
func (s *CometBFTServer[T]) QueryBlockResultsCmd() *cobra.Command { | ||
func QueryBlockResultsCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "block-results [height]", | ||
Short: "Query for a committed block's results by height", | ||
Long: "Query for a specific committed block's results using the CometBFT RPC `block_results` method", | ||
Args: cobra.RangeArgs(0, 1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
node, err := s.rpcClient(cmd) | ||
node, err := rpcClient(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,4 @@ func getConfigTomlFromViper(v *viper.Viper) *cmtcfg.Config { | |
|
||
return conf.SetRoot(rootDir) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update a little bit CI and server/v2/cometbft since we using cometbft queries