-
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: migrate consensus to collections #15553
Changes from all commits
c8d3377
fd46770
774c88f
5c373d5
d1b4cc4
0179f15
8304b8a
fd01db1
05fecfa
52f8f06
8f27bd5
3526d4b
dca8d4e
3fcc6e2
ee8b994
fd8d899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -434,29 +434,25 @@ func (app *BaseApp) setState(mode runTxMode, header cmtproto.Header) { | |
|
||
// GetConsensusParams returns the current consensus parameters from the BaseApp's | ||
// ParamStore. If the BaseApp has no ParamStore defined, nil is returned. | ||
func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *cmtproto.ConsensusParams { | ||
func (app *BaseApp) GetConsensusParams(ctx sdk.Context) cmtproto.ConsensusParams { | ||
if app.paramStore == nil { | ||
return nil | ||
return cmtproto.ConsensusParams{} | ||
} | ||
|
||
cp, err := app.paramStore.Get(ctx) | ||
if err != nil { | ||
panic(err) | ||
panic(fmt.Errorf("consensus key is nil: %w", err)) | ||
Check warning Code scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
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. nit: The key isn't nil, the value is empty/nil. 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. Thanks. I'll amend in another pr. |
||
} | ||
|
||
return cp | ||
} | ||
|
||
// StoreConsensusParams sets the consensus parameters to the baseapp's param store. | ||
func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *cmtproto.ConsensusParams) error { | ||
func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp cmtproto.ConsensusParams) error { | ||
if app.paramStore == nil { | ||
panic("cannot store consensus params with no params store set") | ||
} | ||
|
||
if cp == nil { | ||
return nil | ||
} | ||
|
||
return app.paramStore.Set(ctx, cp) | ||
// We're explicitly not storing the CometBFT app_version in the param store. It's | ||
// stored instead in the x/upgrade store, with its own bump logic. | ||
|
@@ -474,7 +470,7 @@ func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) { | |
// one. | ||
func (app *BaseApp) GetMaximumBlockGas(ctx sdk.Context) uint64 { | ||
cp := app.GetConsensusParams(ctx) | ||
if cp == nil || cp.Block == nil { | ||
if cp.Block == nil { | ||
return 0 | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,16 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/consensus/types"; | |
// Query defines the gRPC querier service. | ||
service Query { | ||
// Params queries the parameters of x/consensus_param module. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
rpc GetParams(QueryGetParamsRequest) returns (QueryGetParamsResponse) { | ||
option (google.api.http).get = "/cosmos/consensus/v1/params"; | ||
} | ||
} | ||
|
||
// QueryParamsRequest defines the request type for querying x/consensus parameters. | ||
message QueryParamsRequest {} | ||
message QueryGetParamsRequest {} | ||
|
||
// QueryParamsResponse defines the response type for querying x/consensus parameters. | ||
message QueryParamsResponse { | ||
message QueryGetParamsResponse { | ||
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. Is that proto breaking warning ok to be ignored? cc @AmauryM 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. Reverted in #15627 |
||
// params are the tendermint consensus params stored in the consensus module. | ||
// Please note that `params.version` is not populated in this response, it is | ||
// tracked separately in the x/upgrade module. | ||
|
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods