mukan-sdk/baseapp/info.go
Mukan Erkin Törük abb1ff956e
Some checks are pending
Build SimApp / build (amd64) (push) Waiting to run
Build SimApp / build (arm64) (push) Waiting to run
CodeQL / Analyze (push) Waiting to run
Build & Push / build (push) Waiting to run
Run Gosec / Gosec (push) Waiting to run
Lint / golangci-lint (push) Waiting to run
Checks dependencies and mocks generation / Check go mod tidy (push) Waiting to run
Checks dependencies and mocks generation / Check up to date mocks (push) Waiting to run
System Tests / setup (push) Waiting to run
System Tests / test-system (push) Blocked by required conditions
System Tests / test-system-legacy (push) Blocked by required conditions
Tests / Code Coverage / split-test-files (push) Waiting to run
Tests / Code Coverage / tests (00) (push) Blocked by required conditions
Tests / Code Coverage / tests (01) (push) Blocked by required conditions
Tests / Code Coverage / tests (02) (push) Blocked by required conditions
Tests / Code Coverage / tests (03) (push) Blocked by required conditions
Tests / Code Coverage / test-integration (push) Waiting to run
Tests / Code Coverage / test-e2e (push) Waiting to run
Tests / Code Coverage / repo-analysis (push) Blocked by required conditions
Tests / Code Coverage / test-sim-nondeterminism (push) Waiting to run
Tests / Code Coverage / test-clientv2 (push) Waiting to run
Tests / Code Coverage / test-core (push) Waiting to run
Tests / Code Coverage / test-depinject (push) Waiting to run
Tests / Code Coverage / test-errors (push) Waiting to run
Tests / Code Coverage / test-math (push) Waiting to run
Tests / Code Coverage / test-schema (push) Waiting to run
Tests / Code Coverage / test-collections (push) Waiting to run
Tests / Code Coverage / test-cosmovisor (push) Waiting to run
Tests / Code Coverage / test-confix (push) Waiting to run
Tests / Code Coverage / test-store (push) Waiting to run
Tests / Code Coverage / test-log (push) Waiting to run
Tests / Code Coverage / test-x-tx (push) Waiting to run
Tests / Code Coverage / test-x-nft (push) Waiting to run
Tests / Code Coverage / test-x-circuit (push) Waiting to run
Tests / Code Coverage / test-x-feegrant (push) Waiting to run
Tests / Code Coverage / test-x-evidence (push) Waiting to run
Tests / Code Coverage / test-x-upgrade (push) Waiting to run
Tests / Code Coverage / test-tools-benchmark (push) Waiting to run
refactor: complete sovereign stack cleanup — all github.com upstream refs purged
2026-05-11 03:46:06 +03:00

211 lines
4.8 KiB
Go

package baseapp
import (
"time"
abci "git.cw.tr/mukan-network/mukan-consensus/abci/types"
"cosmossdk.io/core/comet"
)
// NewBlockInfo returns a new BlockInfo instance
// This function should be only used in tests
func NewBlockInfo(
misbehavior []abci.Misbehavior,
validatorsHash []byte,
proposerAddress []byte,
lastCommit abci.CommitInfo,
) comet.BlockInfo {
return &cometInfo{
Misbehavior: misbehavior,
ValidatorsHash: validatorsHash,
ProposerAddress: proposerAddress,
LastCommit: lastCommit,
}
}
// CometInfo defines the properties provided by comet to the application
type cometInfo struct {
Misbehavior []abci.Misbehavior
ValidatorsHash []byte
ProposerAddress []byte
LastCommit abci.CommitInfo
}
func (r cometInfo) GetEvidence() comet.EvidenceList {
return evidenceWrapper{evidence: r.Misbehavior}
}
func (r cometInfo) GetValidatorsHash() []byte {
return r.ValidatorsHash
}
func (r cometInfo) GetProposerAddress() []byte {
return r.ProposerAddress
}
func (r cometInfo) GetLastCommit() comet.CommitInfo {
return commitInfoWrapper{r.LastCommit}
}
type evidenceWrapper struct {
evidence []abci.Misbehavior
}
func (e evidenceWrapper) Len() int {
return len(e.evidence)
}
func (e evidenceWrapper) Get(i int) comet.Evidence {
return misbehaviorWrapper{e.evidence[i]}
}
// commitInfoWrapper is a wrapper around abci.CommitInfo that implements CommitInfo interface
type commitInfoWrapper struct {
abci.CommitInfo
}
var _ comet.CommitInfo = (*commitInfoWrapper)(nil)
func (c commitInfoWrapper) Round() int32 {
return c.CommitInfo.Round
}
func (c commitInfoWrapper) Votes() comet.VoteInfos {
return abciVoteInfoWrapper{c.CommitInfo.Votes}
}
// abciVoteInfoWrapper is a wrapper around abci.VoteInfo that implements VoteInfos interface
type abciVoteInfoWrapper struct {
votes []abci.VoteInfo
}
var _ comet.VoteInfos = (*abciVoteInfoWrapper)(nil)
func (e abciVoteInfoWrapper) Len() int {
return len(e.votes)
}
func (e abciVoteInfoWrapper) Get(i int) comet.VoteInfo {
return voteInfoWrapper{e.votes[i]}
}
// voteInfoWrapper is a wrapper around abci.VoteInfo that implements VoteInfo interface
type voteInfoWrapper struct {
abci.VoteInfo
}
var _ comet.VoteInfo = (*voteInfoWrapper)(nil)
func (v voteInfoWrapper) GetBlockIDFlag() comet.BlockIDFlag {
return comet.BlockIDFlag(v.BlockIdFlag)
}
func (v voteInfoWrapper) Validator() comet.Validator {
return validatorWrapper{v.VoteInfo.Validator}
}
// validatorWrapper is a wrapper around abci.Validator that implements Validator interface
type validatorWrapper struct {
abci.Validator
}
var _ comet.Validator = (*validatorWrapper)(nil)
func (v validatorWrapper) Address() []byte {
return v.Validator.Address
}
func (v validatorWrapper) Power() int64 {
return v.Validator.Power
}
type misbehaviorWrapper struct {
abci.Misbehavior
}
func (m misbehaviorWrapper) Type() comet.MisbehaviorType {
return comet.MisbehaviorType(m.Misbehavior.Type)
}
func (m misbehaviorWrapper) Height() int64 {
return m.Misbehavior.Height
}
func (m misbehaviorWrapper) Validator() comet.Validator {
return validatorWrapper{m.Misbehavior.Validator}
}
func (m misbehaviorWrapper) Time() time.Time {
return m.Misbehavior.Time
}
func (m misbehaviorWrapper) TotalVotingPower() int64 {
return m.Misbehavior.TotalVotingPower
}
type prepareProposalInfo struct {
*abci.RequestPrepareProposal
}
var _ comet.BlockInfo = (*prepareProposalInfo)(nil)
func (r prepareProposalInfo) GetEvidence() comet.EvidenceList {
return evidenceWrapper{r.Misbehavior}
}
func (r prepareProposalInfo) GetValidatorsHash() []byte {
return r.NextValidatorsHash
}
func (r prepareProposalInfo) GetProposerAddress() []byte {
return r.ProposerAddress
}
func (r prepareProposalInfo) GetLastCommit() comet.CommitInfo {
return extendedCommitInfoWrapper{r.LocalLastCommit}
}
var _ comet.BlockInfo = (*prepareProposalInfo)(nil)
type extendedCommitInfoWrapper struct {
abci.ExtendedCommitInfo
}
var _ comet.CommitInfo = (*extendedCommitInfoWrapper)(nil)
func (e extendedCommitInfoWrapper) Round() int32 {
return e.ExtendedCommitInfo.Round
}
func (e extendedCommitInfoWrapper) Votes() comet.VoteInfos {
return extendedVoteInfoWrapperList{e.ExtendedCommitInfo.Votes}
}
type extendedVoteInfoWrapperList struct {
votes []abci.ExtendedVoteInfo
}
var _ comet.VoteInfos = (*extendedVoteInfoWrapperList)(nil)
func (e extendedVoteInfoWrapperList) Len() int {
return len(e.votes)
}
func (e extendedVoteInfoWrapperList) Get(i int) comet.VoteInfo {
return extendedVoteInfoWrapper{e.votes[i]}
}
type extendedVoteInfoWrapper struct {
abci.ExtendedVoteInfo
}
var _ comet.VoteInfo = (*extendedVoteInfoWrapper)(nil)
func (e extendedVoteInfoWrapper) GetBlockIDFlag() comet.BlockIDFlag {
return comet.BlockIDFlag(e.BlockIdFlag)
}
func (e extendedVoteInfoWrapper) Validator() comet.Validator {
return validatorWrapper{e.ExtendedVoteInfo.Validator}
}