-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
feat(consensus): add consensus message #19483
Changes from all commits
bc6bf86
2007967
ffbf490
b95e7ea
f183441
d76c1a6
d091a68
ffbc1d1
32e6d7c
381de64
09d8a40
1cbefb3
c4fb275
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Since: cosmos-sdk 0.51 | ||
syntax = "proto3"; | ||
package cosmos.consensus.v1; | ||
|
||
import "tendermint/types/params.proto"; | ||
|
||
option go_package = "github.com/cosmos/cosmos-sdk/x/consensus/types"; | ||
|
||
// ConsensusMsgParams is the Msg/Params request type. This is a consensus message that is sent from cometbft. | ||
message ConsensusMsgParams { | ||
// params defines the x/consensus parameters to be passed from comet. | ||
// | ||
// NOTE: All parameters must be supplied. | ||
tendermint.types.VersionParams version = 1; | ||
tendermint.types.BlockParams block = 2; | ||
tendermint.types.EvidenceParams evidence = 3; | ||
tendermint.types.ValidatorParams validator = 4; | ||
tendermint.types.ABCIParams abci = 5; | ||
} | ||
|
||
// ConsensusMsgParamsResponse defines the response structure for executing a | ||
// ConsensusMsgParams message. | ||
message ConsensusMsgParamsResponse {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,72 @@ sidebar_position: 1 | |
|
||
# `x/consensus` | ||
|
||
## Abstract | ||
|
||
Functionality to modify CometBFT's ABCI consensus params. | ||
|
||
## Contents | ||
|
||
* [State](#state) | ||
* [Params](#params) | ||
* [Keepers](#keepers) | ||
* [Messages](#messages) | ||
* [Consensus Messages](#consensus-messages) | ||
* [Events](#events) | ||
* [Message Events](#message-events) | ||
|
||
|
||
## State | ||
|
||
The `x/consensus` module keeps state of the consensus params from cometbft.: | ||
Comment on lines
+22
to
+24
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. The State section provides a clear but brief description of the module's state management concerning consensus parameters. It would be beneficial to include more detail on how these parameters influence CometBFT's behavior and the overall consensus process. Consider adding a sentence or two explaining the implications of consensus parameter state changes on CometBFT's operation, such as how they can affect block validation, transaction throughput, or network security. |
||
|
||
## Params | ||
|
||
The consensus module stores it's params in state with the prefix of `0x05`, | ||
it can be updated with governance or the address with authority. | ||
|
||
* Params: `0x05 | ProtocolBuffer(cometbft.ConsensusParams)` | ||
|
||
```protobuf reference | ||
https://github.com/cosmos/cosmos-sdk/blob/381de6452693a9338371223c232fba0c42773a4b/proto/cosmos/consensus/v1/consensus.proto#L11-L18 | ||
``` | ||
|
||
## Keepers | ||
|
||
The consensus module provides methods to Set and Get consensus params. It is recommended to use the `x/consensus` module keeper to get consensus params instead of accessing them through the context. | ||
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. The Keepers section mentions the provision of methods to set and get consensus parameters but lacks an example. Including a code snippet would significantly enhance comprehension and usability for developers. Consider adding an example code snippet showing how to use the |
||
|
||
## Messages | ||
|
||
### UpdateParams | ||
|
||
Update consensus params. | ||
|
||
```protobuf reference | ||
https://github.com/cosmos/cosmos-sdk/blob/381de6452693a9338371223c232fba0c42773a4b/proto/cosmos/consensus/v1/tx.proto#L12-L47 | ||
``` | ||
|
||
The message will fail under the following conditions: | ||
|
||
* The signer is not the set authority | ||
* Not all values are set | ||
|
||
Comment on lines
+51
to
+55
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. The Messages section outlines the conditions under which the Consider adding details about the specific consensus parameters that can be updated with the |
||
## Consensus Messages | ||
|
||
The consensus module has a consensus message that is used to set the consensus params when the chain initializes. It is similar to the `UpdateParams` message but it is only used once at the start of the chain. | ||
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. The Consensus Messages section introduces a crucial functionality for chain initialization but lacks detail on how this differs from regular parameter updates post-initialization. Clarifying this distinction could provide valuable context for developers. Consider adding a brief explanation of how consensus messages during chain initialization differ from regular consensus parameter updates, highlighting why this distinction is important for the initial setup of a blockchain network. |
||
|
||
```protobuf reference | ||
https://github.com/cosmos/cosmos-sdk/blob/381de6452693a9338371223c232fba0c42773a4b/proto/cosmos/consensus/v1/consensus.proto#L9-L24 | ||
``` | ||
|
||
## Events | ||
|
||
The consensus module emits the following events: | ||
|
||
### Message Events | ||
|
||
#### MsgUpdateParams | ||
|
||
| Type | Attribute Key | Attribute Value | | ||
|--------|---------------|---------------------| | ||
| string | authority | msg.Signer | | ||
| string | parameters | consensus Parmeters | | ||
Comment on lines
+66
to
+75
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. The Events section, particularly the Message Events subsection, is well-documented. However, including examples of how these events can be subscribed to or used within the Cosmos SDK framework would enhance practical understanding. Consider adding examples or guidance on subscribing to or handling these events within the Cosmos SDK framework, providing developers with actionable insights into leveraging these events for custom logic or monitoring. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package types | ||
|
||
import ( | ||
"errors" | ||
|
||
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" | ||
cmttypes "github.com/cometbft/cometbft/types" | ||
) | ||
|
||
func (msg ConsensusMsgParams) ToProtoConsensusParams() (cmtproto.ConsensusParams, error) { | ||
if msg.Evidence == nil || msg.Block == nil || msg.Validator == nil || msg.Version == nil { | ||
return cmtproto.ConsensusParams{}, errors.New("all parameters must be present") | ||
} | ||
|
||
cp := cmtproto.ConsensusParams{ | ||
Block: &cmtproto.BlockParams{ | ||
MaxBytes: msg.Block.MaxBytes, | ||
MaxGas: msg.Block.MaxGas, | ||
}, | ||
Evidence: &cmtproto.EvidenceParams{ | ||
MaxAgeNumBlocks: msg.Evidence.MaxAgeNumBlocks, | ||
MaxAgeDuration: msg.Evidence.MaxAgeDuration, | ||
MaxBytes: msg.Evidence.MaxBytes, | ||
}, | ||
Validator: &cmtproto.ValidatorParams{ | ||
PubKeyTypes: msg.Validator.PubKeyTypes, | ||
}, | ||
Version: cmttypes.DefaultConsensusParams().ToProto().Version, // Version is stored in x/upgrade | ||
} | ||
|
||
if msg.Abci != nil { | ||
cp.Abci = &cmtproto.ABCIParams{ | ||
VoteExtensionsEnableHeight: msg.Abci.VoteExtensionsEnableHeight, | ||
} | ||
} | ||
|
||
if msg.Version != nil { | ||
cp.Version.App = msg.Version.App | ||
} | ||
|
||
return cp, nil | ||
} |
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.
The abstract succinctly introduces the functionality of modifying CometBFT's ABCI consensus parameters. However, it could be enhanced by briefly explaining the significance of this capability in the broader context of blockchain consensus mechanisms.
Consider expanding the abstract to briefly explain why modifying ABCI consensus parameters is crucial for blockchain networks using CometBFT, highlighting its impact on network flexibility, security, and performance.