-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4aac90e
update comments
hieuvubk 30d72a3
consensustypes
hieuvubk 45d4e67
handle err
hieuvubk c907e8a
add epochs for v2
hieuvubk 06ea466
clean up
hieuvubk f250a18
go mod & tests
hieuvubk 42d7553
merge main
hieuvubk fe63167
Merge branch 'main' into hieu/simapp-audit
hieuvubk 819afd2
Merge branch 'main' into hieu/simapp-audit
hieuvubk 98f70e9
revert WithdrawDelegationRewards err handle
hieuvubk 08ebc82
Merge branch 'hieu/simapp-audit' of https://github.com/cosmos/cosmos-…
hieuvubk ab373f2
read app toml config from viper
hieuvubk 23c480e
update simapp-v2-smoke-test
hieuvubk acb8140
Merge branch 'main' into hieu/simapp-audit
hieuvubk adcda83
Merge branch 'main' into hieu/simapp-audit
hieuvubk 18f424e
Merge branch 'main' into hieu/simapp-audit
hieuvubk f201230
reverted
hieuvubk 24d83ba
comet queries not relay on CometBFTServer
hieuvubk 3bd4f72
Merge branch 'hieu/simapp-audit' of https://github.com/cosmos/cosmos-…
hieuvubk e3a98f3
no need app.toml config read
hieuvubk 55701f6
Merge branch 'main' into hieu/simapp-audit
hieuvubk 404241b
Merge branch 'main' into hieu/simapp-audit
hieuvubk f76c488
Merge branch 'main' into hieu/simapp-audit
hieuvubk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,6 @@ 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" | ||
|
@@ -28,35 +27,25 @@ import ( | |
"github.com/cosmos/cosmos-sdk/version" | ||
) | ||
|
||
func (s *CometBFTServer[T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) { | ||
if s.config.AppTomlConfig.Standalone { | ||
client, err := rpchttp.New(client.GetConfigFromCmd(cmd).RPC.ListenAddress) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return client, nil | ||
func rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) { | ||
rpcURI, err := cmd.Flags().GetString(FlagNode) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
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) | ||
} | ||
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 +71,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 +89,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 +123,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 +142,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 +170,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 +185,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 +220,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 +235,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 +308,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 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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