Documentation ¶
Index ¶
- Constants
- Variables
- func Bytes2Hash(txBytes []byte, height int64) string
- func CanonicalTime(t time.Time) string
- func ComputeAminoOverhead(tx Tx, fieldNum int) int64
- func EventQueryTxFor(tx Tx, height int64) tmpubsub.Query
- func EvidenceToProto(evidence Evidence) (*tmproto.Evidence, error)
- func GetCodec() *amino.Codec
- func GetEarthHeight() int64
- func GetMarsHeight() int64
- func GetMercuryHeight() int64
- func GetMilestoneVenusHeight() int64
- func GetNodePruneHeight() int64
- func GetStartBlockHeight() int64
- func GetVenus1Height() int64
- func GetVenus2Height() int64
- func GetVenus3Height() int64
- func GetVenus4Height() int64
- func GetVenusHeight() int64
- func HigherThanEarth(h int64) bool
- func HigherThanMars(height int64) bool
- func HigherThanMercury(height int64) bool
- func HigherThanVenus(height int64) bool
- func HigherThanVenus1(h int64) bool
- func HigherThanVenus2(h int64) bool
- func HigherThanVenus3(h int64) bool
- func HigherThanVenus4(h int64) bool
- func IBCCanonicalizeBlockID(rbid *BlockID) *tmproto.CanonicalBlockID
- func IBCCanonicalizePartSetHeader(psh PartSetHeader) tmproto.CanonicalPartSetHeader
- func IBCCanonicalizeProposal(chainID string, proposal *Proposal) tmproto.CanonicalProposal
- func IBCCanonicalizeVote(chainID string, vote *Vote) tmproto.CanonicalVote
- func InitSignatureCache()
- func IsBlockDataCompressed(payload []byte) bool
- func IsErrNotEnoughVotingPowerSigned(err error) bool
- func IsMainNet() bool
- func IsTestNet() bool
- func IsVoteTypeValid(t SignedMsgType) bool
- func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64
- func MaxDataBytesUnknownEvidence(maxBytes int64, valsCount int) int64
- func MaxEvidencePerBlock(blockMaxBytes int64) (int64, int64)
- func ProposalSignBytes(chainID string, p *Proposal) []byte
- func QueryForEvent(eventType string) tmpubsub.Query
- func RandValidator(randPower bool, minPower int64) (*Validator, PrivValidator)
- func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []PrivValidator)
- func RegisterBlockAmino(cdc *amino.Codec)
- func RegisterEventDatas(cdc *amino.Codec)
- func RegisterEvidences(cdc *amino.Codec)
- func RegisterMockEvidences(cdc *amino.Codec)
- func RegisterMockEvidencesGlobal()
- func SetupMainNetEnvironment(pruneH int64)
- func SetupTestNetEnvironment(pruneH int64)
- func UncompressBlockFromBytes(payload []byte) (res []byte, compressSign int, err error)
- func UncompressBlockFromBytesTo(payload []byte, buf *bytes.Buffer) (compressSign int, err error)
- func UncompressBlockFromReader(pbpReader io.Reader) (io.Reader, error)
- func UnittestOnlySetMilestoneEarthHeight(h int64)
- func UnittestOnlySetMilestoneMarsHeight(height int64)
- func UnittestOnlySetMilestoneVenus1Height(h int64)
- func UnittestOnlySetMilestoneVenus2Height(h int64)
- func UnittestOnlySetMilestoneVenus3Height(h int64)
- func UnittestOnlySetMilestoneVenus4Height(h int64)
- func UnittestOnlySetMilestoneVenusHeight(height int64)
- func UpdateBlockPartSizeBytes(size int)
- func ValidateHash(h []byte) error
- func ValidateTime(t time.Time) error
- func ValidatorListString(vals []*Validator) string
- func VoteSignBytes(chainID string, vote *Vote) []byte
- type ABCIResult
- type ABCIResults
- type Address
- type Block
- func (b *Block) AminoSize(cdc *amino.Codec) int
- func (b *Block) FastSize() (size int)
- func (b *Block) Hash() tmbytes.HexBytes
- func (b *Block) HashesTo(hash []byte) bool
- func (b *Block) MakePartSet(partSize int) *PartSet
- func (b *Block) MakePartSetByExInfo(exInfo *BlockExInfo) *PartSet
- func (b *Block) Marshal() ([]byte, error)
- func (b *Block) MarshalTo(data []byte) (int, error)
- func (b *Block) Size() int
- func (b *Block) String() string
- func (b *Block) StringIndented(indent string) string
- func (b *Block) StringShort() string
- func (b Block) To() CM40Block
- func (b *Block) Unmarshal(bs []byte) error
- func (b *Block) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
- func (b *Block) ValidateBasic() error
- type BlockEventPublisher
- type BlockExInfo
- type BlockID
- func (blockID BlockID) AminoSize(_ *amino.Codec) int
- func (blockID BlockID) Equals(other BlockID) bool
- func (blockID BlockID) IsComplete() bool
- func (blockID BlockID) IsZero() bool
- func (blockID BlockID) Key() string
- func (blockID BlockID) String() string
- func (blockID *BlockID) ToIBCProto() tmproto.BlockID
- func (blockID *BlockID) ToProto() tmproto.BlockID
- func (blockID *BlockID) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
- func (blockID BlockID) ValidateBasic() error
- type BlockIDFlag
- type BlockMeta
- func (bm *BlockMeta) Marshal() ([]byte, error)
- func (bm *BlockMeta) MarshalTo(data []byte) (int, error)
- func (bm *BlockMeta) Size() int
- func (bm *BlockMeta) Unmarshal(bs []byte) error
- func (bm *BlockMeta) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
- func (bm *BlockMeta) ValidateBasic() error
- type BlockParams
- type CM40Block
- type CM40EventDataNewBlock
- type Cache
- type CanonicalBlockID
- type CanonicalPartSetHeader
- type CanonicalProposal
- type CanonicalVote
- type Commit
- func (commit Commit) AminoSize(cdc *amino.Codec) int
- func (commit *Commit) BitArray() *bits.BitArray
- func (commit *Commit) GetByIndex(valIdx int) *Vote
- func (commit *Commit) GetHeight() int64
- func (commit *Commit) GetRound() int
- func (commit *Commit) GetVote(valIdx int) *Vote
- func (commit *Commit) Hash() tmbytes.HexBytes
- func (commit *Commit) IBCVoteSignBytes(chainID string, valIdx int) []byte
- func (commit *Commit) IsCommit() bool
- func (commit *Commit) Size() int
- func (commit *Commit) StringIndented(indent string) string
- func (c Commit) To() IBCCommit
- func (commit *Commit) ToProto() *tmproto.Commit
- func (commit *Commit) Type() byte
- func (commit *Commit) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
- func (commit *Commit) ValidateBasic() error
- func (commit *Commit) VoteSignBytes(chainID string, valIdx int) []byte
- type CommitSig
- func (cs CommitSig) Absent() bool
- func (cs CommitSig) AminoSize(_ *amino.Codec) int
- func (cs CommitSig) BlockID(commitBlockID BlockID) BlockID
- func (cs CommitSig) ForBlock() bool
- func (cs *CommitSig) FromProto(csp tmproto.CommitSig) error
- func (cs CommitSig) String() string
- func (cs *CommitSig) ToProto() *tmproto.CommitSig
- func (cs *CommitSig) UnmarshalFromAmino(_ *amino.Codec, data []byte) error
- func (cs CommitSig) ValidateBasic() error
- type ConsensusParams
- type Data
- type DeltaPayload
- func (payload *DeltaPayload) AminoSize(_ *amino.Codec) int
- func (payload *DeltaPayload) MarshalAminoTo(_ *amino.Codec, buf *bytes.Buffer) error
- func (payload *DeltaPayload) MarshalToAmino(cdc *amino.Codec) ([]byte, error)
- func (payload *DeltaPayload) UnmarshalFromAmino(_ *amino.Codec, data []byte) error
- type Deltas
- func (d *Deltas) ABCIRsp() []byte
- func (d *Deltas) CompressOrUncompressElapsed() time.Duration
- func (d *Deltas) DeltasBytes() []byte
- func (d *Deltas) HashElapsed() time.Duration
- func (d *Deltas) Marshal() ([]byte, error)
- func (d *Deltas) MarshalOrUnmarshalElapsed() time.Duration
- func (d *Deltas) Size() int
- func (d *Deltas) String() string
- func (d *Deltas) Unmarshal(bs []byte) error
- func (dds *Deltas) Validate(height int64) bool
- func (d *Deltas) WasmWatchBytes() []byte
- func (d *Deltas) WatchBytes() []byte
- type DeltasMessage
- type DuplicateVoteEvidence
- func (dve *DuplicateVoteEvidence) Address() []byte
- func (dve DuplicateVoteEvidence) AminoSize(cdc *amino.Codec) int
- func (dve *DuplicateVoteEvidence) Bytes() []byte
- func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool
- func (dve *DuplicateVoteEvidence) Hash() []byte
- func (dve *DuplicateVoteEvidence) Height() int64
- func (dve *DuplicateVoteEvidence) String() string
- func (dve *DuplicateVoteEvidence) Time() time.Time
- func (dve *DuplicateVoteEvidence) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
- func (dve *DuplicateVoteEvidence) ValidateBasic() error
- func (dve *DuplicateVoteEvidence) Verify(chainID string, pubKey crypto.PubKey) error
- type ErrEvidenceInvalid
- type ErrEvidenceOverflow
- type ErrInvalidCommitHeight
- type ErrInvalidCommitSignatures
- type ErrNotEnoughVotingPowerSigned
- type ErrVoteConflictingVotes
- type ErroringMockPV
- type EventBus
- func (b *EventBus) NumClientSubscriptions(clientID string) int
- func (b *EventBus) NumClients() int
- func (b *EventBus) OnStart() error
- func (b *EventBus) OnStop()
- func (b *EventBus) Publish(eventType string, eventData TMEventData) error
- func (b *EventBus) PublishEventCompleteProposal(data EventDataCompleteProposal) error
- func (b *EventBus) PublishEventLatestBlockTime(data EventDataBlockTime) error
- func (b *EventBus) PublishEventLock(data EventDataRoundState) error
- func (b *EventBus) PublishEventNewBlock(data EventDataNewBlock) error
- func (b *EventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error
- func (b *EventBus) PublishEventNewRound(data EventDataNewRound) error
- func (b *EventBus) PublishEventNewRoundStep(data EventDataRoundState) error
- func (b *EventBus) PublishEventPendingTx(data EventDataTx) error
- func (b *EventBus) PublishEventPolka(data EventDataRoundState) error
- func (b *EventBus) PublishEventRelock(data EventDataRoundState) error
- func (b *EventBus) PublishEventRmPendingTx(data EventDataRmPendingTx) error
- func (b *EventBus) PublishEventTimeoutPropose(data EventDataRoundState) error
- func (b *EventBus) PublishEventTimeoutWait(data EventDataRoundState) error
- func (b *EventBus) PublishEventTx(data EventDataTx) error
- func (b *EventBus) PublishEventTxs(data EventDataTxs) error
- func (b *EventBus) PublishEventUnlock(data EventDataRoundState) error
- func (b *EventBus) PublishEventValidBlock(data EventDataRoundState) error
- func (b *EventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error
- func (b *EventBus) PublishEventVote(data EventDataVote) error
- func (b *EventBus) SetLogger(l log.Logger)
- func (b *EventBus) Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, ...) (Subscription, error)
- func (b *EventBus) SubscribeUnbuffered(ctx context.Context, subscriber string, query tmpubsub.Query) (Subscription, error)
- func (b *EventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error
- func (b *EventBus) UnsubscribeAll(ctx context.Context, subscriber string) error
- type EventBusSubscriber
- type EventDataBlockTime
- type EventDataCompleteProposal
- type EventDataNewBlock
- type EventDataNewBlockHeader
- type EventDataNewRound
- type EventDataRmPendingTx
- type EventDataRoundState
- type EventDataString
- type EventDataTx
- type EventDataTxs
- type EventDataValidatorSetUpdates
- type EventDataVote
- type Evidence
- type EvidenceData
- type EvidenceList
- type EvidenceParams
- type GenesisDoc
- type GenesisValidator
- type HashedParams
- type Header
- func (h Header) AminoSize(cdc *amino.Codec) int
- func (h *Header) Hash() tmbytes.HexBytes
- func (h *Header) IBCHash() tmbytes.HexBytes
- func (h *Header) Populate(version version.Consensus, chainID string, timestamp time.Time, ...)
- func (h *Header) PureIBCHash() tmbytes.HexBytes
- func (h *Header) StringIndented(indent string) string
- func (h *Header) ToProto() *tmproto.Header
- func (h *Header) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
- func (h Header) ValidateBasic() error
- type IBCBlockID
- type IBCCommit
- type IBCHeader
- type IBCPartSetHeader
- type IBCSignedHeader
- type MockEvidence
- func (e MockEvidence) Address() []byte
- func (e MockEvidence) Bytes() []byte
- func (e MockEvidence) Equal(ev Evidence) bool
- func (e MockEvidence) Hash() []byte
- func (e MockEvidence) Height() int64
- func (e MockEvidence) String() string
- func (e MockEvidence) Time() time.Time
- func (e MockEvidence) ValidateBasic() error
- func (e MockEvidence) Verify(chainID string, pubKey crypto.PubKey) error
- type MockPV
- func (pv MockPV) DisableChecks()
- func (pv MockPV) GetPubKey() (crypto.PubKey, error)
- func (pv MockPV) SignBytes(bz []byte) ([]byte, error)
- func (pv MockPV) SignProposal(chainID string, proposal *Proposal) error
- func (pv MockPV) SignVote(chainID string, vote *Vote) error
- func (pv MockPV) String() string
- type MockRandomEvidence
- type NopEventBus
- func (NopEventBus) PublishEventCompleteProposal(data EventDataRoundState) error
- func (NopEventBus) PublishEventLatestBlockTime(data EventDataBlockTime) error
- func (NopEventBus) PublishEventLock(data EventDataRoundState) error
- func (NopEventBus) PublishEventNewBlock(data EventDataNewBlock) error
- func (NopEventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error
- func (NopEventBus) PublishEventNewRound(data EventDataRoundState) error
- func (NopEventBus) PublishEventNewRoundStep(data EventDataRoundState) error
- func (NopEventBus) PublishEventPendingTx(data EventDataTx) error
- func (NopEventBus) PublishEventPolka(data EventDataRoundState) error
- func (NopEventBus) PublishEventRelock(data EventDataRoundState) error
- func (NopEventBus) PublishEventRmPendingTx(EventDataRmPendingTx) error
- func (NopEventBus) PublishEventTimeoutPropose(data EventDataRoundState) error
- func (NopEventBus) PublishEventTimeoutWait(data EventDataRoundState) error
- func (NopEventBus) PublishEventTx(data EventDataTx) error
- func (NopEventBus) PublishEventTxs(data EventDataTxs) error
- func (NopEventBus) PublishEventUnlock(data EventDataRoundState) error
- func (NopEventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error
- func (NopEventBus) PublishEventVote(data EventDataVote) error
- func (NopEventBus) Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, ...) error
- func (NopEventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error
- func (NopEventBus) UnsubscribeAll(ctx context.Context, subscriber string) error
- type P2PID
- type Part
- type PartSet
- func (ps *PartSet) AddPart(part *Part) (bool, error)
- func (ps *PartSet) BitArray() *bits.BitArray
- func (ps *PartSet) Count() int
- func (ps *PartSet) GetPart(index int) *Part
- func (ps *PartSet) GetReader() io.Reader
- func (ps *PartSet) HasHeader(header PartSetHeader) bool
- func (ps *PartSet) Hash() []byte
- func (ps *PartSet) HashesTo(hash []byte) bool
- func (ps *PartSet) Header() PartSetHeader
- func (ps *PartSet) IsComplete() bool
- func (ps *PartSet) MarshalJSON() ([]byte, error)
- func (ps *PartSet) StringShort() string
- func (ps *PartSet) Total() int
- type PartSetHeader
- func (psh PartSetHeader) AminoSize() int
- func (psh PartSetHeader) Equals(other PartSetHeader) bool
- func (psh PartSetHeader) IsZero() bool
- func (psh PartSetHeader) String() string
- func (psh *PartSetHeader) ToIBCProto() tmproto.PartSetHeader
- func (psh *PartSetHeader) ToProto() tmproto.PartSetHeader
- func (psh *PartSetHeader) UnmarshalFromAmino(_ *amino.Codec, data []byte) error
- func (psh PartSetHeader) ValidateBasic() error
- type PartSetReader
- type PrivValidator
- type PrivValidatorsByAddress
- type Proposal
- type RmPendingTxReason
- type Signable
- type SignedHeader
- type SignedMsgType
- type Subscription
- type TMEventData
- type Tx
- type TxEventPublisher
- type TxProof
- type TxResult
- type Txs
- type UpgradeAble
- type Validator
- func (v *Validator) Bytes() []byte
- func (v *Validator) CompareProposerPriority(other *Validator) *Validator
- func (v *Validator) Copy() *Validator
- func (v *Validator) HeightBytes(h int64) []byte
- func (v *Validator) IBCHeightBytes() []byte
- func (v *Validator) OriginBytes() []byte
- func (v *Validator) String() string
- func (v *Validator) ToProto() (*tmproto.Validator, error)
- type ValidatorInfo
- type ValidatorParams
- type ValidatorSet
- func (vals *ValidatorSet) Copy() *ValidatorSet
- func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet
- func (vals *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
- func (vals *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
- func (vals *ValidatorSet) GetProposer() (proposer *Validator)
- func (vals *ValidatorSet) HasAddress(address []byte) bool
- func (vals *ValidatorSet) Hash(h int64) []byte
- func (vals *ValidatorSet) IBCGetByAddress(address []byte) (index int, val *Validator)
- func (vals *ValidatorSet) IBCHash() []byte
- func (vals *ValidatorSet) IBCVerifyCommitLight(chainID string, blockID BlockID, height int64, commit *Commit) error
- func (vals *ValidatorSet) IBCVerifyCommitLightTrusting(chainID string, blockID BlockID, height int64, commit *Commit, ...) error
- func (vals *ValidatorSet) IncrementProposerPriority(times int)
- func (vals *ValidatorSet) IsNilOrEmpty() bool
- func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (vals *ValidatorSet) RescalePriorities(diffMax int64)
- func (vals *ValidatorSet) Size() int
- func (vals *ValidatorSet) String() string
- func (vals *ValidatorSet) StringIndented(indent string) string
- func (vals *ValidatorSet) ToProto() (*tmproto.ValidatorSet, error)
- func (vals *ValidatorSet) TotalVotingPower() int64
- func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error
- func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
- func (vals *ValidatorSet) VerifyCommitLight(chainID string, blockID BlockID, height int64, commit *Commit) error
- func (vals *ValidatorSet) VerifyCommitLightTrusting(chainID string, blockID BlockID, height int64, commit *Commit, ...) error
- func (vals *ValidatorSet) VerifyFutureCommit(newSet *ValidatorSet, chainID string, blockID BlockID, height int64, ...) error
- type ValidatorsByAddress
- type ValidatorsByVotingPower
- type Vote
- func (vote Vote) AminoSize(cdc *amino.Codec) int
- func (vote *Vote) CommitSig() CommitSig
- func (vote *Vote) Copy() *Vote
- func (vote *Vote) SignBytes(chainID string) []byte
- func (vote *Vote) String() string
- func (vote *Vote) ToProto() *tmproto.Vote
- func (vote *Vote) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
- func (vote *Vote) ValidateBasic() error
- func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *bits.BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *bits.BitArray
- func (voteSet *VoteSet) BitArrayString() string
- func (voteSet *VoteSet) ChainID() string
- func (voteSet *VoteSet) GetByAddress(address []byte) *Vote
- func (voteSet *VoteSet) GetByIndex(valIndex int) *Vote
- func (voteSet *VoteSet) GetHeight() int64
- func (voteSet *VoteSet) GetRound() int
- func (voteSet *VoteSet) HasAll() bool
- func (voteSet *VoteSet) HasTwoThirdsAny() bool
- func (voteSet *VoteSet) HasTwoThirdsMajority() bool
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeCommit() *Commit
- func (voteSet *VoteSet) MarshalJSON() ([]byte, error)
- func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID) error
- func (voteSet *VoteSet) Size() int
- func (voteSet *VoteSet) String() string
- func (voteSet *VoteSet) StringIndented(indent string) string
- func (voteSet *VoteSet) StringShort() string
- func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)
- func (voteSet *VoteSet) Type() byte
- func (voteSet *VoteSet) VoteStrings() []string
- type VoteSetJSON
- type VoteSetReader
Constants ¶
const ( // MaxHeaderBytes is a maximum header size (including amino overhead). MaxHeaderBytes int64 = 632 // MaxAminoOverheadForBlock - maximum amino overhead to encode a block (up to // MaxBlockSizeBytes in size) not including it's parts except Data. // This means it also excludes the overhead for individual transactions. // To compute individual transactions' overhead use types.ComputeAminoOverhead(tx types.Tx, fieldNum int). // // Uvarint length of MaxBlockSizeBytes: 4 bytes // 2 fields (2 embedded): 2 bytes // Uvarint length of Data.Txs: 4 bytes // Data.Txs field: 1 byte MaxAminoOverheadForBlock int64 = 11 // CompressDividing is used to divide compressType and compressFlag of compressSign // the compressSign = CompressType * CompressDividing + CompressFlag CompressDividing int = 10 FlagBlockCompressType = "block-compress-type" FlagBlockCompressFlag = "block-compress-flag" FlagBlockCompressThreshold = "block-compress-threshold" )
const ( FlagDownloadDDS = "download-delta" FlagUploadDDS = "upload-delta" FlagAppendPid = "append-pid" FlagBufferSize = "delta-buffer-size" FlagDDSCompressType = "compress-type" FlagDDSCompressFlag = "compress-flag" // redis // url fmt (ip:port) FlagRedisUrl = "delta-redis-url" FlagRedisAuth = "delta-redis-auth" // expire unit: second FlagRedisExpire = "delta-redis-expire" FlagRedisDB = "delta-redis-db" FlagFastQuery = "fast-query" // FlagDeltaVersion specify the DeltaVersion FlagDeltaVersion = "delta-version" )
const ( // Block level events for mass consumption by users. // These events are triggered from the state package, // after a block has been committed. // These are also used by the tx indexer for async indexing. // All of this data can be fetched through the rpc. EventNewBlock = "NewBlock" EventNewBlockHeader = "NewBlockHeader" EventTx = "Tx" EventPendingTx = "PendingTx" EventRmPendingTx = "RmPendingTx" EventValidatorSetUpdates = "ValidatorSetUpdates" EventBlockTime = "BlockTime" EventTxs = "Txs" // Internal consensus events. // These are used for testing the consensus state machine. // They can also be used to build real-time consensus visualizers. EventCompleteProposal = "CompleteProposal" EventLock = "Lock" EventNewRound = "NewRound" EventNewRoundStep = "NewRoundStep" EventPolka = "Polka" EventRelock = "Relock" EventTimeoutPropose = "TimeoutPropose" EventTimeoutWait = "TimeoutWait" EventUnlock = "Unlock" EventValidBlock = "ValidBlock" EventVote = "Vote" EventSignVote = "SignVote" EventBlockPart = "BlockPart" EventProposeRequest = "ProposeRequest" )
Reserved event types (alphabetically sorted).
const ( // EventTypeKey is a reserved composite key for event name. EventTypeKey = "tm.event" // TxHashKey is a reserved key, used to specify transaction's hash. // see EventBus#PublishEventTx TxHashKey = "tx.hash" // TxHeightKey is a reserved key, used to specify transaction block's height. // see EventBus#PublishEventTx TxHeightKey = "tx.height" // BlockHeightKey is a reserved key used for indexing BeginBlock and Endblock // events. BlockHeightKey = "block.height" )
const ( // MaxEvidenceBytes is a maximum size of any evidence (including amino overhead). MaxEvidenceBytes int64 = 484 DuplicateVoteEvidenceName = "tendermint/DuplicateVoteEvidence" )
const ( MainNet = "exchain-66" TestNet = "exchain-65" )
const ( MainNetVeneus1Height = 12988000 TestNetVeneus1Height = 12067000 MainNetVeneusHeight = 8200000 TestNetVeneusHeight = 8510000 MainNetMercuyHeight = 5150000 TestNetMercuryHeight = 5300000 MainNetGenesisHeight = 2322600 TestNetGenesisHeight = 1121818 TestNetChangeChainId = 2270901 TestNetChainName1 = "okexchain-65" )
const ( // MaxBlockSizeBytes is the maximum permitted size of the blocks. MaxBlockSizeBytes = 104857600 // 100MB // TimeoutCommit is set for the stable of blockTime TimeoutCommit = 3800 // 3.8s )
const ( ABCIEvidenceTypeDuplicateVote = "duplicate/vote" ABCIEvidenceTypeMock = "mock/evidence" )
const ( ABCIPubKeyTypeEd25519 = "ed25519" ABCIPubKeyTypeSr25519 = "sr25519" ABCIPubKeyTypeSecp256k1 = "secp256k1" )
const ( TxHashLen = 32 AddressStringLen = 2 + 20*2 )
const ( // MaxTotalVotingPower - the maximum allowed total voting power. // It needs to be sufficiently small to, in all cases: // 1. prevent clipping in incrementProposerPriority() // 2. let (diff+diffMax-1) not overflow in IncrementProposerPriority() // (Proof of 1 is tricky, left to the reader). // It could be higher, but this is sufficiently large for our purposes, // and leaves room for defensive purposes. MaxTotalVotingPower = int64(math.MaxInt64) / 8 // PriorityWindowSizeFactor - is a constant that when multiplied with the total voting power gives // the maximum allowed distance between validator priorities. PriorityWindowSizeFactor = 2 )
const FlagSigCacheSize = "signature-cache-size"
const (
// MaxChainIDLen is a maximum length of the chain ID.
MaxChainIDLen = 50
)
const (
MaxEvidenceBytesDenominator = 10
)
const ( // MaxVoteBytes is a maximum vote size (including amino overhead). MaxVoteBytes int64 = 223 )
const ( // MaxVotesCount is the maximum number of votes in a set. Used in ValidateBasic funcs for // protection against DOS attacks. Note this implies a corresponding equal limit to // the number of validators. MaxVotesCount = 10000 )
const TimeFormat = time.RFC3339Nano
TimeFormat is used for generating the sigs
Variables ¶
var ( BlockCompressType = 0x00 BlockCompressFlag = 0 BlockCompressThreshold = 1024000 )
var ( FastQuery = false DownloadDelta = false UploadDelta = false )
var ( EventQueryCompleteProposal = QueryForEvent(EventCompleteProposal) EventQueryLock = QueryForEvent(EventLock) EventQueryNewBlock = QueryForEvent(EventNewBlock) EventQueryNewBlockHeader = QueryForEvent(EventNewBlockHeader) EventQueryNewRound = QueryForEvent(EventNewRound) EventQueryNewRoundStep = QueryForEvent(EventNewRoundStep) EventQueryPolka = QueryForEvent(EventPolka) EventQueryRelock = QueryForEvent(EventRelock) EventQueryTimeoutPropose = QueryForEvent(EventTimeoutPropose) EventQueryTimeoutWait = QueryForEvent(EventTimeoutWait) EventQueryTx = QueryForEvent(EventTx) EventQueryUnlock = QueryForEvent(EventUnlock) EventQueryValidatorSetUpdates = QueryForEvent(EventValidatorSetUpdates) EventQueryValidBlock = QueryForEvent(EventValidBlock) EventQueryVote = QueryForEvent(EventVote) )
var ( MILESTONE_GENESIS_HEIGHT string MILESTONE_MERCURY_HEIGHT string MILESTONE_VENUS_HEIGHT string MILESTONE_MARS_HEIGHT string MILESTONE_VENUS1_HEIGHT string MILESTONE_VENUS2_HEIGHT string MILESTONE_VENUS3_HEIGHT string MILESTONE_EARTH_HEIGHT string MILESTONE_VENUS4_HEIGHT string )
var ( // BlockPartSizeBytes is the size of one block part. BlockPartSizeBytes = 65536 // 64kB // MaxBlockPartsCount is the maximum number of block parts. MaxBlockPartsCount = (MaxBlockSizeBytes / BlockPartSizeBytes) + 1 )
var ( ErrPartSetUnexpectedIndex = errors.New("error part set unexpected index") ErrPartSetInvalidProof = errors.New("error part set invalid proof") )
var ( ErrInvalidBlockPartSignature = errors.New("error invalid block part signature") ErrInvalidBlockPartHash = errors.New("error invalid block part hash") )
var ( ErrVoteUnexpectedStep = errors.New("unexpected step") ErrVoteInvalidValidatorIndex = errors.New("invalid validator index") ErrVoteInvalidValidatorAddress = errors.New("invalid validator address") ErrVoteInvalidSignature = errors.New("invalid signature") ErrVoteInvalidBlockHash = errors.New("invalid block hash") ErrVoteNonDeterministicSignature = errors.New("non-deterministic signature") ErrVoteNil = errors.New("nil vote") )
var ABCIPubKeyTypesToAminoNames = map[string]string{ ABCIPubKeyTypeEd25519: ed25519.PubKeyAminoName, ABCIPubKeyTypeSr25519: sr25519.PubKeyAminoName, ABCIPubKeyTypeSecp256k1: secp256k1.PubKeyAminoName, }
var DBBackend = string(dbm.GoLevelDBBackend)
DBBackend This is set at compile time.
var ( // DeltaVersion do not apply delta if version does not match // if user specify the flag 'FlagDeltaVersion'(--delta-version) use user's setting, // otherwise use the default value DeltaVersion = 10 )
var EnableEventBlockTime = false
var ErroringMockPVErr = errors.New("erroringMockPV always returns an error")
var ( // MaxSignatureSize is a maximum allowed signature size for the Proposal // and Vote. // XXX: secp256k1 does not have Size nor MaxSize defined. MaxSignatureSize = tmmath.MaxInt(ed25519.SignatureSize, 64) )
var PB2TM = pb2tm{}
PB2TM is used for converting protobuf ABCI to Tendermint ABCI. UNSTABLE
var (
PeerStateKey = "ConsensusReactor.peerState"
)
UNSTABLE
var TM2PB = tm2pb{}
TM2PB is used for converting Tendermint ABCI to protobuf ABCI. UNSTABLE
Functions ¶
func Bytes2Hash ¶ added in v1.1.9
func CanonicalTime ¶
CanonicalTime can be used to stringify time in a canonical way.
func ComputeAminoOverhead ¶
ComputeAminoOverhead calculates the overhead for amino encoding a transaction. The overhead consists of varint encoding the field number and the wire type (= length-delimited = 2), and another varint encoding the length of the transaction. The field number can be the field number of the particular transaction, or the field number of the parenting struct that contains the transactions []Tx as a field (this field number is repeated for each contained Tx). If some []Tx are encoded directly (without a parenting struct), the default fieldNum is also 1 (see BinFieldNum in amino.MarshalBinaryBare).
func GetEarthHeight ¶ added in v1.6.4
func GetEarthHeight() int64
func GetMarsHeight ¶ added in v1.5.0
func GetMarsHeight() int64
func GetMercuryHeight ¶ added in v1.1.0
func GetMercuryHeight() int64
func GetMilestoneVenusHeight ¶ added in v1.1.3
func GetMilestoneVenusHeight() int64
GetMilestoneVenusHeight returns milestoneVenusHeight
func GetNodePruneHeight ¶ added in v1.6.2
func GetNodePruneHeight() int64
func GetStartBlockHeight ¶
func GetStartBlockHeight() int64
func GetVenus1Height ¶ added in v1.3.0
func GetVenus1Height() int64
func GetVenus2Height ¶ added in v1.6.0
func GetVenus2Height() int64
func GetVenus3Height ¶ added in v1.6.3
func GetVenus3Height() int64
func GetVenus4Height ¶ added in v1.6.7
func GetVenus4Height() int64
func GetVenusHeight ¶ added in v1.1.0
func GetVenusHeight() int64
func HigherThanEarth ¶ added in v1.6.4
func HigherThanMars ¶ added in v1.5.0
use MPT storage model to replace IAVL storage model
func HigherThanMercury ¶ added in v1.1.0
depracate homstead signer support
func HigherThanVenus ¶ added in v1.1.0
func HigherThanVenus1 ¶ added in v1.3.0
================================== =========== Venus1 ===============
func HigherThanVenus2 ¶ added in v1.6.0
================================== =========== Venus2 ===============
func HigherThanVenus3 ¶ added in v1.6.3
================================== =========== Venus3 ===============
func HigherThanVenus4 ¶ added in v1.6.7
================================== =========== Venus3 ===============
func IBCCanonicalizeBlockID ¶ added in v1.3.0
func IBCCanonicalizeBlockID(rbid *BlockID) *tmproto.CanonicalBlockID
func IBCCanonicalizePartSetHeader ¶ added in v1.3.0
func IBCCanonicalizePartSetHeader(psh PartSetHeader) tmproto.CanonicalPartSetHeader
CanonicalizeVote transforms the given PartSetHeader to a CanonicalPartSetHeader.
func IBCCanonicalizeProposal ¶ added in v1.3.0
func IBCCanonicalizeProposal(chainID string, proposal *Proposal) tmproto.CanonicalProposal
CanonicalizeVote transforms the given Proposal to a CanonicalProposal.
func IBCCanonicalizeVote ¶ added in v1.3.0
func IBCCanonicalizeVote(chainID string, vote *Vote) tmproto.CanonicalVote
func InitSignatureCache ¶ added in v1.1.9
func InitSignatureCache()
func IsBlockDataCompressed ¶ added in v1.6.3
func IsErrNotEnoughVotingPowerSigned ¶
IsErrNotEnoughVotingPowerSigned returns true if err is ErrNotEnoughVotingPowerSigned.
func IsVoteTypeValid ¶
func IsVoteTypeValid(t SignedMsgType) bool
IsVoteTypeValid returns true if t is a valid vote type.
func MaxDataBytes ¶
MaxDataBytes returns the maximum size of block's data.
XXX: Panics on negative result.
func MaxDataBytesUnknownEvidence ¶
MaxDataBytesUnknownEvidence returns the maximum size of block's data when evidence count is unknown. MaxEvidencePerBlock will be used for the size of evidence.
XXX: Panics on negative result.
func MaxEvidencePerBlock ¶
MaxEvidencePerBlock returns the maximum number of evidences allowed in the block and their maximum total size (limitted to 1/10th of the maximum block size). TODO: change to a constant, or to a fraction of the validator set size. See https://github.com/tendermint/tendermint/issues/2590
func ProposalSignBytes ¶ added in v1.3.0
func QueryForEvent ¶
func RandValidator ¶
func RandValidator(randPower bool, minPower int64) (*Validator, PrivValidator)
RandValidator returns a randomized validator, useful for testing. UNSTABLE
func RandValidatorSet ¶
func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []PrivValidator)
RandValidatorSet returns a randomized validator set, useful for testing. NOTE: PrivValidator are in order. UNSTABLE
func RegisterBlockAmino ¶
func RegisterEventDatas ¶
func RegisterEvidences ¶
func RegisterMockEvidences ¶
func SetupMainNetEnvironment ¶ added in v1.6.2
func SetupMainNetEnvironment(pruneH int64)
func SetupTestNetEnvironment ¶ added in v1.6.2
func SetupTestNetEnvironment(pruneH int64)
func UncompressBlockFromBytes ¶ added in v1.5.0
UncompressBlockFromBytes uncompress from compressBytes to blockPart bytes, and returns the compressSign compressSign contains compressType and compressFlag the compressSign: XY means, compressType: X, compressFlag: Y
func UncompressBlockFromBytesTo ¶ added in v1.6.3
UncompressBlockFromBytesTo uncompress payload to buf, and returns the compressSign, if payload is not compressed, compressSign will be 0, and buf will not be changed.
func UncompressBlockFromReader ¶ added in v1.5.0
func UnittestOnlySetMilestoneEarthHeight ¶ added in v1.6.4
func UnittestOnlySetMilestoneEarthHeight(h int64)
================================== =========== Earth ===============
func UnittestOnlySetMilestoneMarsHeight ¶ added in v1.5.0
func UnittestOnlySetMilestoneMarsHeight(height int64)
can be used in unit test only
func UnittestOnlySetMilestoneVenus1Height ¶ added in v1.3.0
func UnittestOnlySetMilestoneVenus1Height(h int64)
func UnittestOnlySetMilestoneVenus2Height ¶ added in v1.6.0
func UnittestOnlySetMilestoneVenus2Height(h int64)
func UnittestOnlySetMilestoneVenus3Height ¶ added in v1.6.3
func UnittestOnlySetMilestoneVenus3Height(h int64)
func UnittestOnlySetMilestoneVenus4Height ¶ added in v1.6.7
func UnittestOnlySetMilestoneVenus4Height(h int64)
func UnittestOnlySetMilestoneVenusHeight ¶ added in v1.1.3
func UnittestOnlySetMilestoneVenusHeight(height int64)
can be used in unit test only
func UpdateBlockPartSizeBytes ¶ added in v1.5.0
func UpdateBlockPartSizeBytes(size int)
func ValidateHash ¶
ValidateHash returns an error if the hash is not empty, but its size != tmhash.Size.
func ValidateTime ¶
ValidateTime does a basic time validation ensuring time does not drift too much: +/- one year. TODO: reduce this to eg 1 day NOTE: DO NOT USE in ValidateBasic methods in this package. This function can only be used for real time validation, like on proposals and votes in the consensus. If consensus is stuck, and rounds increase for more than a day, having only a 1-day band here could break things... Can't use for validating blocks because we may be syncing years worth of history.
func ValidatorListString ¶
ValidatorListString returns a prettified validator list for logging purposes.
func VoteSignBytes ¶ added in v1.3.0
Types ¶
type ABCIResult ¶
ABCIResult is the deterministic component of a ResponseDeliverTx. TODO: add tags and other fields https://github.com/tendermint/tendermint/issues/1007
func NewResultFromResponse ¶
func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult
NewResultFromResponse creates ABCIResult from ResponseDeliverTx.
func (ABCIResult) AminoSize ¶ added in v1.1.9
func (a ABCIResult) AminoSize() int
func (ABCIResult) Bytes ¶
func (a ABCIResult) Bytes() []byte
Bytes returns the amino encoded ABCIResult
func (ABCIResult) MarshalToAmino ¶ added in v1.1.9
func (a ABCIResult) MarshalToAmino(_ *amino.Codec) ([]byte, error)
type ABCIResults ¶
type ABCIResults []ABCIResult
ABCIResults wraps the deliver tx results to return a proof
func NewResults ¶
func NewResults(responses []*abci.ResponseDeliverTx) ABCIResults
NewResults creates ABCIResults from the list of ResponseDeliverTx.
func (ABCIResults) Bytes ¶
func (a ABCIResults) Bytes() []byte
Bytes serializes the ABCIResponse using amino
func (ABCIResults) Hash ¶
func (a ABCIResults) Hash() []byte
Hash returns a merkle hash of all results
func (ABCIResults) ProveResult ¶
func (a ABCIResults) ProveResult(i int) merkle.SimpleProof
ProveResult returns a merkle proof of one result from the set
type Block ¶
type Block struct { Header `json:"header"` Data `json:"data"` Evidence EvidenceData `json:"evidence"` LastCommit *Commit `json:"last_commit"` // contains filtered or unexported fields }
Block defines the atomic unit of a Tendermint blockchain.
func MakeBlock ¶
MakeBlock returns a new block with an empty header, except what can be computed from itself. It populates the same set of fields validated by ValidateBasic.
func (*Block) FastSize ¶ added in v1.1.9
FastSize returns size of the block in bytes. and more efficient than Size(). But we can't make sure it's completely correct yet, when we're done testing, we'll replace Size with FastSize
func (*Block) Hash ¶
Hash computes and returns the block hash. If the block is incomplete, block hash is nil for safety.
func (*Block) HashesTo ¶
HashesTo is a convenience function that checks if a block hashes to the given argument. Returns false if the block is nil or the hash is empty.
func (*Block) MakePartSet ¶
MakePartSet returns a PartSet containing parts of a serialized block. This is the form in which the block is gossipped to peers. CONTRACT: partSize is greater than zero.
func (*Block) MakePartSetByExInfo ¶ added in v1.5.0
func (b *Block) MakePartSetByExInfo(exInfo *BlockExInfo) *PartSet
func (*Block) StringIndented ¶
StringIndented returns a string representation of the block
func (*Block) StringShort ¶
StringShort returns a shortened string representation of the block
func (*Block) UnmarshalFromAmino ¶ added in v1.1.5
func (*Block) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data. It checks the internal consistency of the block. Further validation is done using state#ValidateBlock.
type BlockEventPublisher ¶
type BlockEventPublisher interface { PublishEventNewBlock(block EventDataNewBlock) error PublishEventNewBlockHeader(header EventDataNewBlockHeader) error PublishEventTx(EventDataTx) error PublishEventTxs(EventDataTxs) error PublishEventPendingTx(EventDataTx) error PublishEventValidatorSetUpdates(EventDataValidatorSetUpdates) error PublishEventLatestBlockTime(time EventDataBlockTime) error PublishEventRmPendingTx(EventDataRmPendingTx) error }
BlockEventPublisher publishes all block related events
type BlockExInfo ¶ added in v1.5.0
func (BlockExInfo) IsCompressed ¶ added in v1.6.3
func (info BlockExInfo) IsCompressed() bool
type BlockID ¶
type BlockID struct { Hash tmbytes.HexBytes `json:"hash"` PartsHeader PartSetHeader `json:"parts"` }
BlockID defines the unique ID of a block as its Hash and its PartSetHeader
func BlockIDFromProto ¶
FromProto sets a protobuf BlockID to the given pointer. It returns an error if the block id is invalid.
func (BlockID) IsComplete ¶
IsComplete returns true if this is a valid BlockID of a non-nil block.
func (*BlockID) ToIBCProto ¶ added in v1.3.0
func (*BlockID) UnmarshalFromAmino ¶ added in v1.1.5
func (BlockID) ValidateBasic ¶
ValidateBasic performs basic validation.
type BlockIDFlag ¶
type BlockIDFlag byte
BlockIDFlag indicates which BlockID the signature is for.
const ( // BlockIDFlagAbsent - no vote was received from a validator. BlockIDFlagAbsent BlockIDFlag = iota + 1 // BlockIDFlagCommit - voted for the Commit.BlockID. BlockIDFlagCommit // BlockIDFlagNil - voted for nil. BlockIDFlagNil )
type BlockMeta ¶
type BlockMeta struct { BlockID BlockID `json:"block_id"` BlockSize int `json:"block_size"` Header Header `json:"header"` NumTxs int `json:"num_txs"` }
BlockMeta contains meta information.
func NewBlockMeta ¶
NewBlockMeta returns a new BlockMeta.
func (*BlockMeta) UnmarshalFromAmino ¶ added in v1.6.3
func (*BlockMeta) ValidateBasic ¶
ValidateBasic performs basic validation.
type BlockParams ¶
type BlockParams struct { MaxBytes int64 `json:"max_bytes"` MaxGas int64 `json:"max_gas"` // Minimum time increment between consecutive blocks (in milliseconds) // Not exposed to the application. TimeIotaMs int64 `json:"time_iota_ms"` }
BlockParams define limits on the block size and gas plus minimum time between blocks.
func DefaultBlockParams ¶
func DefaultBlockParams() BlockParams
DefaultBlockParams returns a default BlockParams.
type CM40Block ¶ added in v1.6.2
type CM40Block struct { IBCHeader `json:"header"` Data `json:"data"` Evidence EvidenceData `json:"evidence"` LastCommit *IBCCommit `json:"last_commit"` // contains filtered or unexported fields }
type CM40EventDataNewBlock ¶ added in v1.6.7
type CM40EventDataNewBlock struct { Block *CM40Block `json:"block"` ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"` ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"` }
func (CM40EventDataNewBlock) From ¶ added in v1.6.7
func (e CM40EventDataNewBlock) From(block EventDataNewBlock) CM40EventDataNewBlock
type Cache ¶ added in v1.1.9
type Cache struct {
// contains filtered or unexported fields
}
func SignatureCache ¶ added in v1.1.9
func SignatureCache() *Cache
type CanonicalBlockID ¶
type CanonicalBlockID struct { Hash bytes.HexBytes PartsHeader CanonicalPartSetHeader }
func CanonicalizeBlockID ¶
func CanonicalizeBlockID(blockID BlockID) CanonicalBlockID
type CanonicalPartSetHeader ¶
func CanonicalizePartSetHeader ¶
func CanonicalizePartSetHeader(psh PartSetHeader) CanonicalPartSetHeader
type CanonicalProposal ¶
type CanonicalProposal struct { Type SignedMsgType // type alias for byte Height int64 `binary:"fixed64"` Round int64 `binary:"fixed64"` POLRound int64 `binary:"fixed64"` BlockID CanonicalBlockID Timestamp time.Time ChainID string }
func CanonicalizeProposal ¶
func CanonicalizeProposal(chainID string, proposal *Proposal) CanonicalProposal
type CanonicalVote ¶
type CanonicalVote struct { Type SignedMsgType // type alias for byte Height int64 `binary:"fixed64"` Round int64 `binary:"fixed64"` BlockID CanonicalBlockID Timestamp time.Time ChainID string }
func CanonicalizeVote ¶
func CanonicalizeVote(chainID string, vote *Vote) CanonicalVote
type Commit ¶
type Commit struct { // NOTE: The signatures are in order of address to preserve the bonded // ValidatorSet order. // Any peer with a block can gossip signatures by index with a peer without // recalculating the active ValidatorSet. Height int64 `json:"height"` Round int `json:"round"` BlockID BlockID `json:"block_id"` Signatures []CommitSig `json:"signatures"` // contains filtered or unexported fields }
Commit contains the evidence that a block was committed by a set of validators. NOTE: Commit is empty for height 1, but never nil.
func CommitFromProto ¶
FromProto sets a protobuf Commit to the given pointer. It returns an error if the commit is invalid.
func MakeCommit ¶
func (*Commit) BitArray ¶
BitArray returns a BitArray of which validators voted for BlockID or nil in this commit. Implements VoteSetReader.
func (*Commit) GetByIndex ¶
GetByIndex returns the vote corresponding to a given validator index. Panics if `index >= commit.Size()`. Implements VoteSetReader.
func (*Commit) GetVote ¶
GetVote converts the CommitSig for the given valIdx to a Vote. Returns nil if the precommit at valIdx is nil. Panics if valIdx >= commit.Size().
func (*Commit) IBCVoteSignBytes ¶ added in v1.5.2
func (*Commit) IsCommit ¶
IsCommit returns true if there is at least one signature. Implements VoteSetReader.
func (*Commit) Size ¶
Size returns the number of signatures in the commit. Implements VoteSetReader.
func (*Commit) StringIndented ¶
StringIndented returns a string representation of the commit
func (*Commit) Type ¶
Type returns the vote type of the commit, which is always VoteTypePrecommit Implements VoteSetReader.
func (*Commit) UnmarshalFromAmino ¶ added in v1.1.5
func (*Commit) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.
func (*Commit) VoteSignBytes ¶
VoteSignBytes constructs the SignBytes for the given CommitSig. The only unique part of the SignBytes is the Timestamp - all other fields signed over are otherwise the same for all validators. Panics if valIdx >= commit.Size().
type CommitSig ¶
type CommitSig struct { BlockIDFlag BlockIDFlag `json:"block_id_flag"` ValidatorAddress Address `json:"validator_address"` Timestamp time.Time `json:"timestamp"` Signature []byte `json:"signature"` }
CommitSig is a part of the Vote included in a Commit.
func NewCommitSigAbsent ¶
func NewCommitSigAbsent() CommitSig
NewCommitSigAbsent returns new CommitSig with BlockIDFlagAbsent. Other fields are all empty.
func NewCommitSigForBlock ¶
NewCommitSigForBlock returns new CommitSig with BlockIDFlagCommit.
func (CommitSig) BlockID ¶
BlockID returns the Commit's BlockID if CommitSig indicates signing, otherwise - empty BlockID.
func (*CommitSig) FromProto ¶
FromProto sets a protobuf CommitSig to the given pointer. It returns an error if the CommitSig is invalid.
func (*CommitSig) UnmarshalFromAmino ¶ added in v1.1.5
func (CommitSig) ValidateBasic ¶
ValidateBasic performs basic validation.
type ConsensusParams ¶
type ConsensusParams struct { Block BlockParams `json:"block"` Evidence EvidenceParams `json:"evidence"` Validator ValidatorParams `json:"validator"` }
ConsensusParams contains consensus critical parameters that determine the validity of blocks.
func DefaultConsensusParams ¶
func DefaultConsensusParams() *ConsensusParams
DefaultConsensusParams returns a default ConsensusParams.
func (*ConsensusParams) Equals ¶
func (params *ConsensusParams) Equals(params2 *ConsensusParams) bool
func (*ConsensusParams) Hash ¶
func (params *ConsensusParams) Hash() []byte
Hash returns a hash of a subset of the parameters to store in the block header. Only the Block.MaxBytes and Block.MaxGas are included in the hash. This allows the ConsensusParams to evolve more without breaking the block protocol. No need for a Merkle tree here, just a small struct to hash.
func (ConsensusParams) Update ¶
func (params ConsensusParams) Update(params2 *abci.ConsensusParams) ConsensusParams
Update returns a copy of the params with updates from the non-zero fields of p2. NOTE: note: must not modify the original
func (*ConsensusParams) Validate ¶
func (params *ConsensusParams) Validate() error
Validate validates the ConsensusParams to ensure all values are within their allowed limits, and returns an error if they are not.
type Data ¶
type Data struct { // Txs that will be applied by state @ block.Height+1. // NOTE: not all txs here are valid. We're just agreeing on the order first. // This means that block.AppHash does not include these txs. Txs Txs `json:"txs"` // contains filtered or unexported fields }
Data contains the set of transactions included in the block
func (*Data) StringIndented ¶
StringIndented returns a string representation of the transactions
func (*Data) UnmarshalFromAmino ¶ added in v1.1.5
type DeltaPayload ¶ added in v1.0.1
type DeltaPayload struct { ABCIRsp []byte DeltasBytes []byte WatchBytes []byte WasmWatchBytes []byte }
func (*DeltaPayload) AminoSize ¶ added in v1.6.3
func (payload *DeltaPayload) AminoSize(_ *amino.Codec) int
func (*DeltaPayload) MarshalAminoTo ¶ added in v1.6.3
func (payload *DeltaPayload) MarshalAminoTo(_ *amino.Codec, buf *bytes.Buffer) error
func (*DeltaPayload) MarshalToAmino ¶ added in v1.6.3
func (payload *DeltaPayload) MarshalToAmino(cdc *amino.Codec) ([]byte, error)
func (*DeltaPayload) UnmarshalFromAmino ¶ added in v1.6.3
func (payload *DeltaPayload) UnmarshalFromAmino(_ *amino.Codec, data []byte) error
type Deltas ¶ added in v1.0.0
type Deltas struct { Height int64 Payload DeltaPayload CompressType int CompressFlag int From string // contains filtered or unexported fields }
Deltas defines the ABCIResponse and state delta
func (*Deltas) CompressOrUncompressElapsed ¶ added in v1.0.1
func (*Deltas) DeltasBytes ¶ added in v1.0.0
func (*Deltas) HashElapsed ¶ added in v1.0.3
func (*Deltas) MarshalOrUnmarshalElapsed ¶ added in v1.0.1
func (*Deltas) WasmWatchBytes ¶ added in v1.6.2
func (*Deltas) WatchBytes ¶ added in v1.0.0
type DeltasMessage ¶ added in v1.0.1
type DeltasMessage struct { Metadata []byte `json:"metadata"` MetadataHash []byte `json:"metadata_hash"` Height int64 `json:"height"` CompressType int `json:"compress_type"` From string `json:"from"` }
func (*DeltasMessage) AminoSize ¶ added in v1.6.3
func (m *DeltasMessage) AminoSize(_ *amino.Codec) int
func (*DeltasMessage) MarshalAminoTo ¶ added in v1.6.3
func (m *DeltasMessage) MarshalAminoTo(_ *amino.Codec, buf *bytes.Buffer) error
func (*DeltasMessage) MarshalToAmino ¶ added in v1.6.3
func (m *DeltasMessage) MarshalToAmino(cdc *amino.Codec) ([]byte, error)
func (*DeltasMessage) UnmarshalFromAmino ¶ added in v1.6.3
func (m *DeltasMessage) UnmarshalFromAmino(_ *amino.Codec, data []byte) error
type DuplicateVoteEvidence ¶
DuplicateVoteEvidence contains evidence a validator signed two conflicting votes.
func NewDuplicateVoteEvidence ¶
func NewDuplicateVoteEvidence(pubkey crypto.PubKey, vote1 *Vote, vote2 *Vote) *DuplicateVoteEvidence
NewDuplicateVoteEvidence creates DuplicateVoteEvidence with right ordering given two conflicting votes. If one of the votes is nil, evidence returned is nil as well
func (*DuplicateVoteEvidence) Address ¶
func (dve *DuplicateVoteEvidence) Address() []byte
Address returns the address of the validator.
func (DuplicateVoteEvidence) AminoSize ¶ added in v1.1.9
func (dve DuplicateVoteEvidence) AminoSize(cdc *amino.Codec) int
func (*DuplicateVoteEvidence) Bytes ¶
func (dve *DuplicateVoteEvidence) Bytes() []byte
Hash returns the hash of the evidence.
func (*DuplicateVoteEvidence) Equal ¶
func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool
Equal checks if two pieces of evidence are equal.
func (*DuplicateVoteEvidence) Hash ¶
func (dve *DuplicateVoteEvidence) Hash() []byte
Hash returns the hash of the evidence.
func (*DuplicateVoteEvidence) Height ¶
func (dve *DuplicateVoteEvidence) Height() int64
Height returns the height this evidence refers to.
func (*DuplicateVoteEvidence) String ¶
func (dve *DuplicateVoteEvidence) String() string
String returns a string representation of the evidence.
func (*DuplicateVoteEvidence) Time ¶
func (dve *DuplicateVoteEvidence) Time() time.Time
Time return the time the evidence was created
func (*DuplicateVoteEvidence) UnmarshalFromAmino ¶ added in v1.1.5
func (dve *DuplicateVoteEvidence) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
func (*DuplicateVoteEvidence) ValidateBasic ¶
func (dve *DuplicateVoteEvidence) ValidateBasic() error
ValidateBasic performs basic validation.
type ErrEvidenceInvalid ¶
ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid.
func NewErrEvidenceInvalid ¶
func NewErrEvidenceInvalid(ev Evidence, err error) *ErrEvidenceInvalid
NewErrEvidenceInvalid returns a new EvidenceInvalid with the given err.
func (*ErrEvidenceInvalid) Error ¶
func (err *ErrEvidenceInvalid) Error() string
Error returns a string representation of the error.
type ErrEvidenceOverflow ¶
ErrEvidenceOverflow is for when there is too much evidence in a block.
func NewErrEvidenceOverflow ¶
func NewErrEvidenceOverflow(max, got int64) *ErrEvidenceOverflow
NewErrEvidenceOverflow returns a new ErrEvidenceOverflow where got > max.
func (*ErrEvidenceOverflow) Error ¶
func (err *ErrEvidenceOverflow) Error() string
Error returns a string representation of the error.
type ErrInvalidCommitHeight ¶
ErrInvalidCommitHeight is returned when we encounter a commit with an unexpected height.
func NewErrInvalidCommitHeight ¶
func NewErrInvalidCommitHeight(expected, actual int64) ErrInvalidCommitHeight
func (ErrInvalidCommitHeight) Error ¶
func (e ErrInvalidCommitHeight) Error() string
type ErrInvalidCommitSignatures ¶
ErrInvalidCommitSignatures is returned when we encounter a commit where the number of signatures doesn't match the number of validators.
func NewErrInvalidCommitSignatures ¶
func NewErrInvalidCommitSignatures(expected, actual int) ErrInvalidCommitSignatures
func (ErrInvalidCommitSignatures) Error ¶
func (e ErrInvalidCommitSignatures) Error() string
type ErrNotEnoughVotingPowerSigned ¶
ErrNotEnoughVotingPowerSigned is returned when not enough validators signed a commit.
func (ErrNotEnoughVotingPowerSigned) Error ¶
func (e ErrNotEnoughVotingPowerSigned) Error() string
type ErrVoteConflictingVotes ¶
type ErrVoteConflictingVotes struct {
*DuplicateVoteEvidence
}
func NewConflictingVoteError ¶
func NewConflictingVoteError(val *Validator, vote1, vote2 *Vote) *ErrVoteConflictingVotes
func (*ErrVoteConflictingVotes) Error ¶
func (err *ErrVoteConflictingVotes) Error() string
type ErroringMockPV ¶
type ErroringMockPV struct {
MockPV
}
func NewErroringMockPV ¶
func NewErroringMockPV() *ErroringMockPV
func (*ErroringMockPV) SignProposal ¶
func (pv *ErroringMockPV) SignProposal(chainID string, proposal *Proposal) error
Implements PrivValidator.
type EventBus ¶
type EventBus struct { service.BaseService // contains filtered or unexported fields }
EventBus is a common bus for all events going through the system. All calls are proxied to underlying pubsub server. All events must be published using EventBus to ensure correct data types.
func NewEventBusWithBufferCapacity ¶
NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity.
func (*EventBus) NumClientSubscriptions ¶
func (*EventBus) NumClients ¶
func (*EventBus) Publish ¶
func (b *EventBus) Publish(eventType string, eventData TMEventData) error
func (*EventBus) PublishEventCompleteProposal ¶
func (b *EventBus) PublishEventCompleteProposal(data EventDataCompleteProposal) error
func (*EventBus) PublishEventLatestBlockTime ¶ added in v1.6.4
func (b *EventBus) PublishEventLatestBlockTime(data EventDataBlockTime) error
func (*EventBus) PublishEventLock ¶
func (b *EventBus) PublishEventLock(data EventDataRoundState) error
func (*EventBus) PublishEventNewBlock ¶
func (b *EventBus) PublishEventNewBlock(data EventDataNewBlock) error
func (*EventBus) PublishEventNewBlockHeader ¶
func (b *EventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error
func (*EventBus) PublishEventNewRound ¶
func (b *EventBus) PublishEventNewRound(data EventDataNewRound) error
func (*EventBus) PublishEventNewRoundStep ¶
func (b *EventBus) PublishEventNewRoundStep(data EventDataRoundState) error
func (*EventBus) PublishEventPendingTx ¶
func (b *EventBus) PublishEventPendingTx(data EventDataTx) error
func (*EventBus) PublishEventPolka ¶
func (b *EventBus) PublishEventPolka(data EventDataRoundState) error
func (*EventBus) PublishEventRelock ¶
func (b *EventBus) PublishEventRelock(data EventDataRoundState) error
func (*EventBus) PublishEventRmPendingTx ¶ added in v1.6.7
func (b *EventBus) PublishEventRmPendingTx(data EventDataRmPendingTx) error
func (*EventBus) PublishEventTimeoutPropose ¶
func (b *EventBus) PublishEventTimeoutPropose(data EventDataRoundState) error
func (*EventBus) PublishEventTimeoutWait ¶
func (b *EventBus) PublishEventTimeoutWait(data EventDataRoundState) error
func (*EventBus) PublishEventTx ¶
func (b *EventBus) PublishEventTx(data EventDataTx) error
PublishEventTx publishes tx event with events from Result. Note it will add predefined keys (EventTypeKey, TxHashKey). Existing events with the same keys will be overwritten.
func (*EventBus) PublishEventTxs ¶ added in v1.6.4
func (b *EventBus) PublishEventTxs(data EventDataTxs) error
func (*EventBus) PublishEventUnlock ¶
func (b *EventBus) PublishEventUnlock(data EventDataRoundState) error
func (*EventBus) PublishEventValidBlock ¶
func (b *EventBus) PublishEventValidBlock(data EventDataRoundState) error
func (*EventBus) PublishEventValidatorSetUpdates ¶
func (b *EventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error
func (*EventBus) PublishEventVote ¶
func (b *EventBus) PublishEventVote(data EventDataVote) error
func (*EventBus) SubscribeUnbuffered ¶
func (b *EventBus) SubscribeUnbuffered( ctx context.Context, subscriber string, query tmpubsub.Query, ) (Subscription, error)
This method can be used for a local consensus explorer and synchronous testing. Do not use for for public facing / untrusted subscriptions!
func (*EventBus) Unsubscribe ¶
type EventBusSubscriber ¶
type EventBusSubscriber interface { Subscribe(ctx context.Context, subscriber string, query tmpubsub.Query, outCapacity ...int) (Subscription, error) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error UnsubscribeAll(ctx context.Context, subscriber string) error NumClients() int NumClientSubscriptions(clientID string) int }
type EventDataBlockTime ¶ added in v1.6.4
latest blockTime
type EventDataNewBlock ¶
type EventDataNewBlock struct { Block *Block `json:"block"` ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"` ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"` }
func (EventDataNewBlock) Upgrade ¶ added in v1.6.7
func (e EventDataNewBlock) Upgrade() interface{}
type EventDataNewBlockHeader ¶
type EventDataNewBlockHeader struct { Header Header `json:"header"` NumTxs int64 `json:"num_txs"` // Number of txs in a block ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"` ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"` }
type EventDataNewRound ¶
type EventDataNewRound struct { Height int64 `json:"height"` Round int `json:"round"` Step string `json:"step"` Proposer ValidatorInfo `json:"proposer"` }
type EventDataRmPendingTx ¶ added in v1.6.7
type EventDataRmPendingTx struct { Hash []byte From string Nonce uint64 Reason RmPendingTxReason }
type EventDataRoundState ¶
type EventDataRoundState struct { Height int64 `json:"height"` Round int `json:"round"` Step string `json:"step"` }
NOTE: This goes into the replay WAL
type EventDataString ¶
type EventDataString string
type EventDataTxs ¶ added in v1.6.4
type EventDataTxs struct { Height int64 //Txs Txs Results []*abci.ResponseDeliverTx }
type EventDataValidatorSetUpdates ¶
type EventDataValidatorSetUpdates struct {
ValidatorUpdates []*Validator `json:"validator_updates"`
}
type EventDataVote ¶
type EventDataVote struct {
Vote *Vote
}
type Evidence ¶
type Evidence interface { Height() int64 // height of the equivocation Time() time.Time // time of the equivocation Address() []byte // address of the equivocating validator Bytes() []byte // bytes which comprise the evidence Hash() []byte // hash of the evidence Verify(chainID string, pubKey crypto.PubKey) error // verify the evidence Equal(Evidence) bool // check equality of evidence ValidateBasic() error String() string }
Evidence represents any provable malicious activity by a validator
type EvidenceData ¶
type EvidenceData struct { Evidence EvidenceList `json:"evidence"` // contains filtered or unexported fields }
EvidenceData contains any evidence of malicious wrong-doing by validators
func (EvidenceData) AminoSize ¶ added in v1.1.9
func (d EvidenceData) AminoSize(cdc *amino.Codec) int
func (*EvidenceData) Hash ¶
func (data *EvidenceData) Hash() tmbytes.HexBytes
Hash returns the hash of the data.
func (*EvidenceData) StringIndented ¶
func (data *EvidenceData) StringIndented(indent string) string
StringIndented returns a string representation of the evidence.
func (*EvidenceData) UnmarshalFromAmino ¶ added in v1.1.5
func (d *EvidenceData) UnmarshalFromAmino(cdc *amino.Codec, data []byte) error
type EvidenceList ¶
type EvidenceList []Evidence
EvidenceList is a list of Evidence. Evidences is not a word.
func (EvidenceList) Has ¶
func (evl EvidenceList) Has(evidence Evidence) bool
Has returns true if the evidence is in the EvidenceList.
func (EvidenceList) Hash ¶
func (evl EvidenceList) Hash() []byte
Hash returns the simple merkle root hash of the EvidenceList.
func (EvidenceList) String ¶
func (evl EvidenceList) String() string
type EvidenceParams ¶
type EvidenceParams struct { MaxAgeNumBlocks int64 `json:"max_age_num_blocks"` // only accept new evidence more recent than this MaxAgeDuration time.Duration `json:"max_age_duration"` }
EvidenceParams determine how we handle evidence of malfeasance.
func DefaultEvidenceParams ¶
func DefaultEvidenceParams() EvidenceParams
DefaultEvidenceParams Params returns a default EvidenceParams.
type GenesisDoc ¶
type GenesisDoc struct { GenesisTime time.Time `json:"genesis_time"` ChainID string `json:"chain_id"` ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"` Validators []GenesisValidator `json:"validators,omitempty"` AppHash tmbytes.HexBytes `json:"app_hash"` AppState json.RawMessage `json:"app_state,omitempty"` }
GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.
func GenesisDocFromFile ¶
func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error)
GenesisDocFromFile reads JSON data from a file and unmarshalls it into a GenesisDoc.
func GenesisDocFromJSON ¶
func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error)
GenesisDocFromJSON unmarshalls JSON data into a GenesisDoc.
func (*GenesisDoc) SaveAs ¶
func (genDoc *GenesisDoc) SaveAs(file string) error
SaveAs is a utility method for saving GenensisDoc as a JSON file.
func (*GenesisDoc) ValidateAndComplete ¶
func (genDoc *GenesisDoc) ValidateAndComplete() error
ValidateAndComplete checks that all necessary fields are present and fills in defaults for optional fields left empty
func (*GenesisDoc) ValidatorHash ¶
func (genDoc *GenesisDoc) ValidatorHash() []byte
ValidatorHash returns the hash of the validator set contained in the GenesisDoc
type GenesisValidator ¶
type GenesisValidator struct { Address Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` Power int64 `json:"power"` Name string `json:"name"` }
GenesisValidator is an initial validator.
type HashedParams ¶
HashedParams is a subset of ConsensusParams. It is amino encoded and hashed into the Header.ConsensusHash.
type Header ¶
type Header struct { // basic block info Version version.Consensus `json:"version"` ChainID string `json:"chain_id"` Height int64 `json:"height"` Time time.Time `json:"time"` // prev block info LastBlockID BlockID `json:"last_block_id"` // hashes of block data LastCommitHash tmbytes.HexBytes `json:"last_commit_hash"` // commit from validators from the last block DataHash tmbytes.HexBytes `json:"data_hash"` // transactions // hashes from the app output from the prev block ValidatorsHash tmbytes.HexBytes `json:"validators_hash"` // validators for the current block NextValidatorsHash tmbytes.HexBytes `json:"next_validators_hash"` // validators for the next block ConsensusHash tmbytes.HexBytes `json:"consensus_hash"` // consensus params for current block AppHash tmbytes.HexBytes `json:"app_hash"` // state after txs from the previous block // root hash of all results from the txs from the previous block LastResultsHash tmbytes.HexBytes `json:"last_results_hash"` // consensus info EvidenceHash tmbytes.HexBytes `json:"evidence_hash"` // evidence included in the block ProposerAddress Address `json:"proposer_address"` // original proposer of the block }
Header defines the structure of a Tendermint block header. NOTE: changes to the Header should be duplicated in: - header.Hash() - abci.Header - https://github.com/tendermint/spec/blob/master/spec/blockchain/blockchain.md
func HeaderFromProto ¶
FromProto sets a protobuf Header to the given pointer. It returns an error if the header is invalid.
func (*Header) Populate ¶
func (h *Header) Populate( version version.Consensus, chainID string, timestamp time.Time, lastBlockID BlockID, valHash, nextValHash []byte, consensusHash, appHash, lastResultsHash []byte, proposerAddress Address, )
Populate the Header with state-derived data. Call this after MakeBlock to complete the Header.
func (*Header) PureIBCHash ¶ added in v1.5.2
func (*Header) StringIndented ¶
StringIndented returns a string representation of the header
func (*Header) UnmarshalFromAmino ¶ added in v1.1.5
func (Header) ValidateBasic ¶
ValidateBasic performs stateless validation on a Header returning an error if any validation fails.
NOTE: Timestamp validation is subtle and handled elsewhere.
type IBCBlockID ¶ added in v1.3.0
type IBCBlockID struct { Hash tmbytes.HexBytes `json:"hash"` PartSetHeader IBCPartSetHeader `json:"parts"` }
func (IBCBlockID) From ¶ added in v1.6.7
func (b IBCBlockID) From(bb BlockID) IBCBlockID
func (IBCBlockID) ToBlockID ¶ added in v1.3.0
func (b IBCBlockID) ToBlockID() BlockID
type IBCCommit ¶ added in v1.3.0
type IBCCommit struct { // NOTE: The signatures are in order of address to preserve the bonded // ValidatorSet order. // Any peer with a block can gossip signatures by index with a peer without // recalculating the active ValidatorSet. Height int64 `json:"height"` Round int32 `json:"round"` BlockID IBCBlockID `json:"block_id"` Signatures []CommitSig `json:"signatures"` // contains filtered or unexported fields }
type IBCHeader ¶ added in v1.3.0
type IBCHeader struct { // basic block info Version tmversion.Consensus `json:"version"` ChainID string `json:"chain_id"` Height int64 `json:"height"` Time time.Time `json:"time"` // prev block info LastBlockID IBCBlockID `json:"last_block_id"` // hashes of block data LastCommitHash tmbytes.HexBytes `json:"last_commit_hash"` // commit from validators from the last block DataHash tmbytes.HexBytes `json:"data_hash"` // transactions // hashes from the app output from the prev block ValidatorsHash tmbytes.HexBytes `json:"validators_hash"` // validators for the current block NextValidatorsHash tmbytes.HexBytes `json:"next_validators_hash"` // validators for the next block ConsensusHash tmbytes.HexBytes `json:"consensus_hash"` // consensus params for current block AppHash tmbytes.HexBytes `json:"app_hash"` // state after txs from the previous block // root hash of all results from the txs from the previous block // see `deterministicResponseDeliverTx` to understand which parts of a tx is hashed into here LastResultsHash tmbytes.HexBytes `json:"last_results_hash"` // consensus info EvidenceHash tmbytes.HexBytes `json:"evidence_hash"` // evidence included in the block ProposerAddress Address `json:"proposer_address"` // original proposer of the block }
func (IBCHeader) ToCM39Header ¶ added in v1.6.2
type IBCPartSetHeader ¶ added in v1.3.0
func (IBCPartSetHeader) From ¶ added in v1.6.7
func (p IBCPartSetHeader) From(header PartSetHeader) IBCPartSetHeader
type IBCSignedHeader ¶ added in v1.3.0
SignedHeader is a header along with the commits that prove it.
type MockEvidence ¶
UNSTABLE
func NewMockEvidence ¶
UNSTABLE
func (MockEvidence) Address ¶
func (e MockEvidence) Address() []byte
func (MockEvidence) Bytes ¶
func (e MockEvidence) Bytes() []byte
func (MockEvidence) Equal ¶
func (e MockEvidence) Equal(ev Evidence) bool
func (MockEvidence) Hash ¶
func (e MockEvidence) Hash() []byte
func (MockEvidence) Height ¶
func (e MockEvidence) Height() int64
func (MockEvidence) String ¶
func (e MockEvidence) String() string
func (MockEvidence) Time ¶
func (e MockEvidence) Time() time.Time
func (MockEvidence) ValidateBasic ¶
func (e MockEvidence) ValidateBasic() error
type MockPV ¶
MockPV implements PrivValidator without any safety or persistence. Only use it for testing.
func NewMockPVWithParams ¶
func NewMockPVWithParams(privKey crypto.PrivKey, breakProposalSigning, breakVoteSigning bool) MockPV
NewMockPVWithParams allows one to create a MockPV instance, but with finer grained control over the operation of the mock validator. This is useful for mocking test failures.
func (MockPV) SignProposal ¶
Implements PrivValidator.
type MockRandomEvidence ¶
type MockRandomEvidence struct { MockEvidence // contains filtered or unexported fields }
UNSTABLE
func NewMockRandomEvidence ¶
func NewMockRandomEvidence(height int64, eTime time.Time, address []byte, randBytes []byte) MockRandomEvidence
UNSTABLE
func (MockRandomEvidence) Hash ¶
func (e MockRandomEvidence) Hash() []byte
type NopEventBus ¶
type NopEventBus struct{}
-----------------------------------------------------------------------------
func (NopEventBus) PublishEventCompleteProposal ¶
func (NopEventBus) PublishEventCompleteProposal(data EventDataRoundState) error
func (NopEventBus) PublishEventLatestBlockTime ¶ added in v1.6.4
func (NopEventBus) PublishEventLatestBlockTime(data EventDataBlockTime) error
func (NopEventBus) PublishEventLock ¶
func (NopEventBus) PublishEventLock(data EventDataRoundState) error
func (NopEventBus) PublishEventNewBlock ¶
func (NopEventBus) PublishEventNewBlock(data EventDataNewBlock) error
func (NopEventBus) PublishEventNewBlockHeader ¶
func (NopEventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error
func (NopEventBus) PublishEventNewRound ¶
func (NopEventBus) PublishEventNewRound(data EventDataRoundState) error
func (NopEventBus) PublishEventNewRoundStep ¶
func (NopEventBus) PublishEventNewRoundStep(data EventDataRoundState) error
func (NopEventBus) PublishEventPendingTx ¶
func (NopEventBus) PublishEventPendingTx(data EventDataTx) error
func (NopEventBus) PublishEventPolka ¶
func (NopEventBus) PublishEventPolka(data EventDataRoundState) error
func (NopEventBus) PublishEventRelock ¶
func (NopEventBus) PublishEventRelock(data EventDataRoundState) error
func (NopEventBus) PublishEventRmPendingTx ¶ added in v1.6.7
func (NopEventBus) PublishEventRmPendingTx(EventDataRmPendingTx) error
func (NopEventBus) PublishEventTimeoutPropose ¶
func (NopEventBus) PublishEventTimeoutPropose(data EventDataRoundState) error
func (NopEventBus) PublishEventTimeoutWait ¶
func (NopEventBus) PublishEventTimeoutWait(data EventDataRoundState) error
func (NopEventBus) PublishEventTx ¶
func (NopEventBus) PublishEventTx(data EventDataTx) error
func (NopEventBus) PublishEventTxs ¶ added in v1.6.4
func (NopEventBus) PublishEventTxs(data EventDataTxs) error
func (NopEventBus) PublishEventUnlock ¶
func (NopEventBus) PublishEventUnlock(data EventDataRoundState) error
func (NopEventBus) PublishEventValidatorSetUpdates ¶
func (NopEventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error
func (NopEventBus) PublishEventVote ¶
func (NopEventBus) PublishEventVote(data EventDataVote) error
func (NopEventBus) Unsubscribe ¶
func (NopEventBus) UnsubscribeAll ¶
func (NopEventBus) UnsubscribeAll(ctx context.Context, subscriber string) error
type P2PID ¶
type P2PID string
UNSTABLE XXX: duplicate of p2p.ID to avoid dependence between packages. Perhaps we can have a minimal types package containing this (and other things?) that both `types` and `p2p` import ?
type Part ¶
type Part struct { Index int `json:"index"` Bytes tmbytes.HexBytes `json:"bytes"` Proof merkle.SimpleProof `json:"proof"` }
func (*Part) StringIndented ¶
func (*Part) UnmarshalFromAmino ¶ added in v1.1.5
func (*Part) ValidateBasic ¶
ValidateBasic performs basic validation.
type PartSet ¶
type PartSet struct {
// contains filtered or unexported fields
}
func NewPartSetFromData ¶
Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed.
func NewPartSetFromHeader ¶
func NewPartSetFromHeader(header PartSetHeader) *PartSet
Returns an empty PartSet ready to be populated.
func (*PartSet) HasHeader ¶
func (ps *PartSet) HasHeader(header PartSetHeader) bool
func (*PartSet) Header ¶
func (ps *PartSet) Header() PartSetHeader
func (*PartSet) IsComplete ¶
func (*PartSet) MarshalJSON ¶
func (*PartSet) StringShort ¶
type PartSetHeader ¶
func PartSetHeaderFromProto ¶
func PartSetHeaderFromProto(ppsh *tmproto.PartSetHeader) (*PartSetHeader, error)
FromProto sets a protobuf PartSetHeader to the given pointer
func (PartSetHeader) AminoSize ¶ added in v1.1.5
func (psh PartSetHeader) AminoSize() int
func (PartSetHeader) Equals ¶
func (psh PartSetHeader) Equals(other PartSetHeader) bool
func (PartSetHeader) IsZero ¶
func (psh PartSetHeader) IsZero() bool
func (PartSetHeader) String ¶
func (psh PartSetHeader) String() string
func (*PartSetHeader) ToIBCProto ¶ added in v1.3.0
func (psh *PartSetHeader) ToIBCProto() tmproto.PartSetHeader
func (*PartSetHeader) ToProto ¶
func (psh *PartSetHeader) ToProto() tmproto.PartSetHeader
ToProto converts BloPartSetHeaderckID to protobuf
func (*PartSetHeader) UnmarshalFromAmino ¶ added in v1.1.5
func (psh *PartSetHeader) UnmarshalFromAmino(_ *amino.Codec, data []byte) error
func (PartSetHeader) ValidateBasic ¶
func (psh PartSetHeader) ValidateBasic() error
ValidateBasic performs basic validation.
type PartSetReader ¶
type PartSetReader struct {
// contains filtered or unexported fields
}
func NewPartSetReader ¶
func NewPartSetReader(parts []*Part) *PartSetReader
type PrivValidator ¶
type PrivValidator interface { GetPubKey() (crypto.PubKey, error) SignVote(chainID string, vote *Vote) error SignProposal(chainID string, proposal *Proposal) error SignBytes(bz []byte) ([]byte, error) }
PrivValidator defines the functionality of a local Tendermint validator that signs votes and proposals, and never double signs.
type PrivValidatorsByAddress ¶
type PrivValidatorsByAddress []PrivValidator
func (PrivValidatorsByAddress) Len ¶
func (pvs PrivValidatorsByAddress) Len() int
func (PrivValidatorsByAddress) Less ¶
func (pvs PrivValidatorsByAddress) Less(i, j int) bool
func (PrivValidatorsByAddress) Swap ¶
func (pvs PrivValidatorsByAddress) Swap(i, j int)
type Proposal ¶
type Proposal struct { Type SignedMsgType Height int64 `json:"height"` Round int `json:"round"` POLRound int `json:"pol_round"` // -1 if null. BlockID BlockID `json:"block_id"` Timestamp time.Time `json:"timestamp"` Signature []byte `json:"signature"` HasVC bool `json:"has_vc"` // enterNewRoundAVC at this Height }
Proposal defines a block proposal for the consensus. It refers to the block by BlockID field. It must be signed by the correct proposer for the given Height/Round to be considered valid. It may depend on votes from a previous round, a so-called Proof-of-Lock (POL) round, as noted in the POLRound. If POLRound >= 0, then BlockID corresponds to the block that is locked in POLRound.
func NewProposal ¶
NewProposal returns a new Proposal. If there is no POLRound, polRound should be -1.
func ProposalFromProto ¶
FromProto sets a protobuf Proposal to the given pointer. It returns an error if the proposal is invalid.
func (*Proposal) ValidateBasic ¶
ValidateBasic performs basic validation.
type RmPendingTxReason ¶ added in v1.6.7
type RmPendingTxReason int
const ( Recheck RmPendingTxReason = iota MinGasPrice Confirmed )
type Signable ¶
Signable is an interface for all signable things. It typically removes signatures before serializing. SignBytes returns the bytes to be signed NOTE: chainIDs are part of the SignBytes but not necessarily the object themselves. NOTE: Expected to panic if there is an error marshalling.
type SignedHeader ¶
SignedHeader is a header along with the commits that prove it. It is the basis of the lite client.
func SignedHeaderFromProto ¶
func SignedHeaderFromProto(shp *tmproto.SignedHeader) (*SignedHeader, error)
FromProto sets a protobuf SignedHeader to the given pointer. It returns an error if the hader or the commit is invalid.
func (SignedHeader) String ¶
func (sh SignedHeader) String() string
func (SignedHeader) StringIndented ¶
func (sh SignedHeader) StringIndented(indent string) string
StringIndented returns a string representation of the SignedHeader.
func (*SignedHeader) ToProto ¶
func (sh *SignedHeader) ToProto() *tmproto.SignedHeader
ToProto converts SignedHeader to protobuf
func (SignedHeader) ValidateBasic ¶
func (sh SignedHeader) ValidateBasic(chainID string) error
ValidateBasic does basic consistency checks and makes sure the header and commit are consistent. NOTE: This does not actually check the cryptographic signatures. Make sure to use a Verifier to validate the signatures actually provide a significantly strong proof for this header's validity.
func (SignedHeader) ValidateBasicForIBC ¶ added in v1.5.2
func (sh SignedHeader) ValidateBasicForIBC(chainID string) error
type SignedMsgType ¶
type SignedMsgType byte
SignedMsgType is a type of signed message in the consensus.
const ( // Votes PrevoteType SignedMsgType = 0x01 PrecommitType SignedMsgType = 0x02 // Proposals ProposalType SignedMsgType = 0x20 )
type Subscription ¶
type Tx ¶
type Tx []byte
Tx is an arbitrary byte array. NOTE: Tx has no types at this level, so when wire encoded it's just length-prefixed. Might we want types here ?
type TxEventPublisher ¶
type TxEventPublisher interface { PublishEventTx(EventDataTx) error PublishEventPendingTx(EventDataTx) error PublishEventRmPendingTx(EventDataRmPendingTx) error }
type TxProof ¶
type TxProof struct { RootHash tmbytes.HexBytes `json:"root_hash"` Data Tx `json:"data"` Proof merkle.SimpleProof `json:"proof"` }
TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
type TxResult ¶
type TxResult struct { Height int64 `json:"height"` Index uint32 `json:"index"` Tx Tx `json:"tx"` Result abci.ResponseDeliverTx `json:"result"` }
TxResult contains results of executing the transaction.
One usage is indexing transaction results.
func (*TxResult) UnmarshalFromAmino ¶ added in v1.1.5
type Txs ¶
type Txs []Tx
Txs is a slice of Tx.
func (Txs) Hash ¶
Hash returns the Merkle root hash of the transaction hashes. i.e. the leaves of the tree are the hashes of the txs.
func (Txs) IndexByHash ¶
IndexByHash returns the index of this transaction hash in the list, or -1 if not found
type UpgradeAble ¶ added in v1.6.7
type UpgradeAble interface {
Upgrade() interface{}
}
type Validator ¶
type Validator struct { Address Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower int64 `json:"voting_power"` ProposerPriority int64 `json:"proposer_priority"` }
Volatile state for each Validator NOTE: The ProposerPriority is not included in Validator.Hash(); make sure to update that method if changes are made here
func ValidatorFromProto ¶
FromProto sets a protobuf Validator to the given pointer. It returns an error if the public key is invalid.
func (*Validator) Bytes ¶
Bytes computes the unique encoding of a validator with a given voting power. These are the bytes that gets hashed in consensus. It excludes address as its redundant with the pubkey. This also excludes ProposerPriority which changes every round.
func (*Validator) CompareProposerPriority ¶
Returns the one with higher ProposerPriority.
func (*Validator) Copy ¶
Creates a new copy of the validator so we can mutate ProposerPriority. Panics if the validator is nil.
func (*Validator) HeightBytes ¶ added in v1.3.0
func (*Validator) IBCHeightBytes ¶ added in v1.5.2
func (*Validator) OriginBytes ¶ added in v1.3.0
type ValidatorInfo ¶
type ValidatorParams ¶
type ValidatorParams struct {
PubKeyTypes []string `json:"pub_key_types"`
}
ValidatorParams restrict the public key types validators can use. NOTE: uses ABCI pubkey naming, not Amino names.
func DefaultValidatorParams ¶
func DefaultValidatorParams() ValidatorParams
DefaultValidatorParams returns a default ValidatorParams, which allows only ed25519 pubkeys.
func (*ValidatorParams) IsValidPubkeyType ¶
func (params *ValidatorParams) IsValidPubkeyType(pubkeyType string) bool
type ValidatorSet ¶
type ValidatorSet struct { // NOTE: persisted via reflect, must be exported. Validators []*Validator `json:"validators"` Proposer *Validator `json:"proposer"` // contains filtered or unexported fields }
ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height - ie. the validators are sorted by their address. On the other hand, the .ProposerPriority of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementProposerPriority(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety.
func NewValidatorSet ¶
func NewValidatorSet(valz []*Validator) *ValidatorSet
NewValidatorSet initializes a ValidatorSet by copying over the values from `valz`, a list of Validators. If valz is nil or empty, the new ValidatorSet will have an empty list of Validators. The addresses of validators in `valz` must be unique otherwise the function panics. Note the validator set size has an implied limit equal to that of the MaxVotesCount - commits by a validator set larger than this will fail validation.
func ValidatorSetFromProto ¶
func ValidatorSetFromProto(vp *tmproto.ValidatorSet) (*ValidatorSet, error)
ValidatorSetFromProto sets a protobuf ValidatorSet to the given pointer. It returns an error if any of the validators from the set or the proposer is invalid
func (*ValidatorSet) Copy ¶
func (vals *ValidatorSet) Copy() *ValidatorSet
Copy each validator into a new ValidatorSet.
func (*ValidatorSet) CopyIncrementProposerPriority ¶
func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet
CopyIncrementProposerPriority increments ProposerPriority and updates the proposer on a copy, and returns it.
func (*ValidatorSet) GetByAddress ¶
func (vals *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)
GetByAddress returns an index of the validator with address and validator itself if found. Otherwise, -1 and nil are returned.
func (*ValidatorSet) GetByIndex ¶
func (vals *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)
GetByIndex returns the validator's address and validator itself by index. It returns nil values if index is less than 0 or greater or equal to len(ValidatorSet.Validators).
func (*ValidatorSet) GetProposer ¶
func (vals *ValidatorSet) GetProposer() (proposer *Validator)
GetProposer returns the current proposer. If the validator set is empty, nil is returned.
func (*ValidatorSet) HasAddress ¶
func (vals *ValidatorSet) HasAddress(address []byte) bool
HasAddress returns true if address given is in the validator set, false - otherwise.
func (*ValidatorSet) Hash ¶
func (vals *ValidatorSet) Hash(h int64) []byte
Hash returns the Merkle root hash build using validators (as leaves) in the set.
func (*ValidatorSet) IBCGetByAddress ¶ added in v1.3.0
func (vals *ValidatorSet) IBCGetByAddress(address []byte) (index int, val *Validator)
func (*ValidatorSet) IBCHash ¶ added in v1.5.2
func (vals *ValidatorSet) IBCHash() []byte
func (*ValidatorSet) IBCVerifyCommitLight ¶ added in v1.5.2
func (*ValidatorSet) IBCVerifyCommitLightTrusting ¶ added in v1.3.0
func (*ValidatorSet) IncrementProposerPriority ¶
func (vals *ValidatorSet) IncrementProposerPriority(times int)
IncrementProposerPriority increments ProposerPriority of each validator and updates the proposer. Panics if validator set is empty. `times` must be positive.
func (*ValidatorSet) IsNilOrEmpty ¶
func (vals *ValidatorSet) IsNilOrEmpty() bool
IsNilOrEmpty returns true if validator set is nil or empty.
func (*ValidatorSet) Iterate ¶
func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
Iterate will run the given function over the set.
func (*ValidatorSet) RescalePriorities ¶
func (vals *ValidatorSet) RescalePriorities(diffMax int64)
RescalePriorities rescales the priorities such that the distance between the maximum and minimum is smaller than `diffMax`.
func (*ValidatorSet) Size ¶
func (vals *ValidatorSet) Size() int
Size returns the length of the validator set.
func (*ValidatorSet) String ¶
func (vals *ValidatorSet) String() string
func (*ValidatorSet) StringIndented ¶
func (vals *ValidatorSet) StringIndented(indent string) string
StringIndented returns an intended string representation of ValidatorSet.
func (*ValidatorSet) ToProto ¶
func (vals *ValidatorSet) ToProto() (*tmproto.ValidatorSet, error)
ToProto converts ValidatorSet to protobuf
func (*ValidatorSet) TotalVotingPower ¶
func (vals *ValidatorSet) TotalVotingPower() int64
TotalVotingPower returns the sum of the voting powers of all validators. It recomputes the total voting power if required.
func (*ValidatorSet) UpdateWithChangeSet ¶
func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error
UpdateWithChangeSet attempts to update the validator set with 'changes'. It performs the following steps:
- validates the changes making sure there are no duplicates and splits them in updates and deletes
- verifies that applying the changes will not result in errors
- computes the total voting power BEFORE removals to ensure that in the next steps the priorities across old and newly added validators are fair
- computes the priorities of new validators against the final set
- applies the updates against the validator set
- applies the removals against the validator set
- performs scaling and centering of priority values
If an error is detected during verification steps, it is returned and the validator set is not changed.
func (*ValidatorSet) VerifyCommit ¶
func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
VerifyCommit verifies +2/3 of the set had signed the given commit.
It checks all the signatures! While it's safe to exit as soon as we have 2/3+ signatures, doing so would impact incentivization logic in the ABCI application that depends on the LastCommitInfo sent in BeginBlock, which includes which validators signed. For instance, Gaia incentivizes proposers with a bonus for including more than +2/3 of the signatures.
func (*ValidatorSet) VerifyCommitLight ¶
func (vals *ValidatorSet) VerifyCommitLight(chainID string, blockID BlockID, height int64, commit *Commit) error
VerifyCommitLight verifies +2/3 of the set had signed the given commit.
This method is primarily used by the light client and does not check all the signatures.
func (*ValidatorSet) VerifyCommitLightTrusting ¶
func (vals *ValidatorSet) VerifyCommitLightTrusting(chainID string, blockID BlockID, height int64, commit *Commit, trustLevel tmmath.Fraction) error
VerifyCommitLightTrusting verifies that trustLevel of the validator set signed this commit.
This method is primarily used by the light client and does not check all the signatures.
NOTE the given validators do not necessarily correspond to the validator set for this commit, but there may be some intersection.
Panics if trustLevel is invalid.
func (*ValidatorSet) VerifyFutureCommit ¶
func (vals *ValidatorSet) VerifyFutureCommit(newSet *ValidatorSet, chainID string, blockID BlockID, height int64, commit *Commit) error
VerifyFutureCommit will check to see if the set would be valid with a different validator set.
vals is the old validator set that we know. Over 2/3 of the power in old signed this block.
In Tendermint, 1/3 of the voting power can halt or fork the chain, but 1/3 can't make arbitrary state transitions. You still need > 2/3 Byzantine to make arbitrary state transitions.
To preserve this property in the light client, we also require > 2/3 of the old vals to sign the future commit at H, that way we preserve the property that if they weren't being truthful about the validator set at H (block hash -> vals hash) or about the app state (block hash -> app hash) we can slash > 2/3. Otherwise, the lite client isn't providing the same security guarantees.
Even if we added a slashing condition that if you sign a block header with the wrong validator set, then we would only need > 1/3 of signatures from the old vals on the new commit, it wouldn't be sufficient because the new vals can be arbitrary and commit some arbitrary app hash.
newSet is the validator set that signed this block. Only votes from new are sufficient for 2/3 majority in the new set as well, for it to be a valid commit.
NOTE: This doesn't check whether the commit is a future commit, because the current height isn't part of the ValidatorSet. Caller must check that the commit height is greater than the height for this validator set.
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
ValidatorsByAddress implements the sort of validators by address.
func (ValidatorsByAddress) Len ¶
func (valz ValidatorsByAddress) Len() int
func (ValidatorsByAddress) Less ¶
func (valz ValidatorsByAddress) Less(i, j int) bool
func (ValidatorsByAddress) Swap ¶
func (valz ValidatorsByAddress) Swap(i, j int)
type ValidatorsByVotingPower ¶ added in v1.5.3
type ValidatorsByVotingPower []*Validator
ValidatorsByVotingPower implements sort.Interface for []*Validator based on the VotingPower and Address fields.
func (ValidatorsByVotingPower) Len ¶ added in v1.5.3
func (valz ValidatorsByVotingPower) Len() int
func (ValidatorsByVotingPower) Less ¶ added in v1.5.3
func (valz ValidatorsByVotingPower) Less(i, j int) bool
func (ValidatorsByVotingPower) Swap ¶ added in v1.5.3
func (valz ValidatorsByVotingPower) Swap(i, j int)
type Vote ¶
type Vote struct { Type SignedMsgType `json:"type"` Height int64 `json:"height"` Round int `json:"round"` BlockID BlockID `json:"block_id"` // zero if vote is nil. Timestamp time.Time `json:"timestamp"` ValidatorAddress Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Signature []byte `json:"signature"` HasVC bool `json:"has_vc"` // enterNewRoundAVC at this Height }
Vote represents a prevote, precommit, or commit vote from validators for consensus.
func MakeVote ¶
func MakeVote( height int64, blockID BlockID, valSet *ValidatorSet, privVal PrivValidator, chainID string, now time.Time, ) (*Vote, error)
func VoteFromProto ¶
FromProto converts a proto generetad type to a handwritten type return type, nil if everything converts safely, otherwise nil, error
func (*Vote) ToProto ¶
ToProto converts the handwritten type to proto generated type return type, nil if everything converts safely, otherwise nil, error
func (*Vote) UnmarshalFromAmino ¶ added in v1.1.5
func (*Vote) ValidateBasic ¶
ValidateBasic performs basic validation.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet helps collect signatures from validators at each height+round for a predefined vote type.
We need VoteSet to be able to keep track of conflicting votes when validators double-sign. Yet, we can't keep track of *all* the votes seen, as that could be a DoS attack vector.
There are two storage areas for votes. 1. voteSet.votes 2. voteSet.votesByBlock
`.votes` is the "canonical" list of votes. It always has at least one vote, if a vote from a validator had been seen at all. Usually it keeps track of the first vote seen, but when a 2/3 majority is found, votes for that get priority and are copied over from `.votesByBlock`.
`.votesByBlock` keeps track of a list of votes for a particular block. There are two ways a &blockVotes{} gets created in `.votesByBlock`. 1. the first vote seen by a validator was for the particular block. 2. a peer claims to have seen 2/3 majority for the particular block.
Since the first vote from a validator will always get added in `.votesByBlock` , all votes in `.votes` will have a corresponding entry in `.votesByBlock`.
When a &blockVotes{} in `.votesByBlock` reaches a 2/3 majority quorum, its votes are copied into `.votes`.
All this is memory bounded because conflicting votes only get added if a peer told us to track that block, each peer only gets to tell us 1 such block, and, there's only a limited number of peers.
NOTE: Assumes that the sum total of voting power does not exceed MaxUInt64.
func CommitToVoteSet ¶
func CommitToVoteSet(chainID string, commit *Commit, vals *ValidatorSet) *VoteSet
CommitToVoteSet constructs a VoteSet from the Commit and validator set. Panics if signatures from the commit can't be added to the voteset. Inverse of VoteSet.MakeCommit().
func NewVoteSet ¶
func NewVoteSet(chainID string, height int64, round int, signedMsgType SignedMsgType, valSet *ValidatorSet) *VoteSet
Constructs a new VoteSet struct used to accumulate votes for given height/round.
func (*VoteSet) AddVote ¶
Returns added=true if vote is valid and new. Otherwise returns err=ErrVote[
UnexpectedStep | InvalidIndex | InvalidAddress | InvalidSignature | InvalidBlockHash | ConflictingVotes ]
Duplicate votes return added=false, err=nil. Conflicting votes return added=*, err=ErrVoteConflictingVotes. NOTE: vote should not be mutated after adding. NOTE: VoteSet must not be nil NOTE: Vote must not be nil
func (*VoteSet) BitArrayByBlockID ¶
func (*VoteSet) BitArrayString ¶
Return the bit-array of votes including the fraction of power that has voted like: "BA{29:xx__x__x_x___x__x_______xxx__} 856/1304 = 0.66"
func (*VoteSet) GetByAddress ¶
func (*VoteSet) GetByIndex ¶
NOTE: if validator has conflicting votes, returns "canonical" vote Implements VoteSetReader.
func (*VoteSet) HasTwoThirdsAny ¶
func (*VoteSet) HasTwoThirdsMajority ¶
func (*VoteSet) MakeCommit ¶
MakeCommit constructs a Commit from the VoteSet. It only includes precommits for the block, which has 2/3+ majority, and nil.
Panics if the vote type is not PrecommitType or if there's no +2/3 votes for a single block.
func (*VoteSet) MarshalJSON ¶
Marshal the VoteSet to JSON. Same as String(), just in JSON, and without the height/round/signedMsgType (since its already included in the votes).
func (*VoteSet) SetPeerMaj23 ¶
If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too NOTE: VoteSet must not be nil
func (*VoteSet) StringIndented ¶
func (*VoteSet) StringShort ¶
func (*VoteSet) TwoThirdsMajority ¶
If there was a +2/3 majority for blockID, return blockID and true. Else, return the empty BlockID{} and false.
func (*VoteSet) VoteStrings ¶
Returns a list of votes compressed to more readable strings.
type VoteSetJSON ¶
type VoteSetJSON struct { Votes []string `json:"votes"` VotesBitArray string `json:"votes_bit_array"` PeerMaj23s map[P2PID]BlockID `json:"peer_maj_23s"` }
More human readable JSON of the vote set NOTE: insufficient for unmarshalling from (compressed votes) TODO: make the peerMaj23s nicer to read (eg just the block hash)
Source Files ¶
- block.go
- block_ibc.go
- block_meta.go
- canonical.go
- codec.go
- db.go
- deltas.go
- encoding_helper.go
- errors.go
- event_bus.go
- events.go
- events_cm40.go
- evidence.go
- from.go
- genesis.go
- ibc.go
- ibc_adapter.go
- keys.go
- milestone.go
- params.go
- part_set.go
- priv_validator.go
- proposal.go
- protobuf.go
- results.go
- signable.go
- signed_msg_type.go
- test_util.go
- to.go
- tx.go
- tx_signature_cache.go
- upgradable.go
- utils.go
- validation.go
- validator.go
- validator_set.go
- validator_set_ibc.go
- vote.go
- vote_set.go