Skip to content
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!: comet_info to struct #17689

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]

* [#17468](https://github.com/cosmos/cosmos-sdk/pull/17468) Add `appmodule.HasPreBlocker` interface.
* [#17689](https://github.com/cosmos/cosmos-sdk/pull/17689) Move Comet service to return structs instead of interfaces.
* `BlockInfo` was renamed to `Info` and `BlockInfoService` was renamed to `CometInfoService`

## [v0.10.0](https://github.com/cosmos/cosmos-sdk/releases/tag/core%2Fv0.10.0)

Expand Down
61 changes: 25 additions & 36 deletions core/comet/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import (
)

// BlockInfoService is an interface that can be used to get information specific to Comet
type BlockInfoService interface {
GetCometBlockInfo(context.Context) BlockInfo
type CometInfoService interface {
GetCometInfo(context.Context) Info
}

// BlockInfo is the information comet provides apps in ABCI
type BlockInfo interface {
GetEvidence() EvidenceList // Evidence misbehavior of the block
// Info is the information comet provides apps in ABCI
type Info struct {
Evidence []Evidence // Evidence misbehavior of the block
// ValidatorsHash returns the hash of the validators
// For Comet, it is the hash of the next validator set
GetValidatorsHash() []byte
GetProposerAddress() []byte // ProposerAddress returns the address of the block proposer
GetLastCommit() CommitInfo // DecidedLastCommit returns the last commit info
ValidatorsHash []byte
ProposerAddress []byte // ProposerAddress is the address of the block proposer
LastCommit CommitInfo // DecidedLastCommit returns the last commit info
}

// MisbehaviorType is the type of misbehavior for a validator
Expand All @@ -29,36 +29,25 @@ const (
LightClientAttack MisbehaviorType = 2
)

// Validator is the validator information of ABCI
type Validator interface {
Address() []byte
Power() int64
}

type EvidenceList interface {
Len() int
Get(int) Evidence
}

// Evidence is the misbehavior information of ABCI
type Evidence interface {
Type() MisbehaviorType
Validator() Validator
Height() int64
Time() time.Time
TotalVotingPower() int64
type Evidence struct {
Type MisbehaviorType
Validator Validator
Height int64
Time time.Time
TotalVotingPower int64
}

// CommitInfo is the commit information of ABCI
type CommitInfo interface {
Round() int32
Votes() VoteInfos
type CommitInfo struct {
Round int32
Votes []VoteInfo
}

// VoteInfos is an interface to get specific votes in a efficient way
type VoteInfos interface {
Len() int
Get(int) VoteInfo
// VoteInfo is the vote information of ABCI
type VoteInfo struct {
Validator Validator
BlockIDFlag BlockIDFlag
}

// BlockIdFlag indicates which BlockID the signature is for
Expand All @@ -74,8 +63,8 @@ const (
BlockIDFlagNil BlockIDFlag = 3
)

// VoteInfo is the vote information of ABCI
type VoteInfo interface {
Validator() Validator
GetBlockIDFlag() BlockIDFlag
// Validator is the validator information of ABCI
type Validator struct {
Address []byte
Power int64
}
Loading