-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(consensus): add consensus message (#19483)
Co-authored-by: Likhita Polavarapu <78951027+likhita-809@users.noreply.github.com>
- Loading branch information
1 parent
6d96e1d
commit 6c9a785
Showing
10 changed files
with
2,340 additions
and
5 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -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 {} |
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
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 | ||
} |
Oops, something went wrong.