Documentation ¶
Index ¶
- Constants
- Variables
- func CanonicalTime(t time.Time) string
- func EventQueryTxFor(tx Tx) tmpubsub.Query
- func GetCodec() *amino.Codec
- func IsVoteTypeValid(t SignedMsgType) bool
- func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64
- func MaxDataBytesUnknownEvidence(maxBytes int64, valsCount int) int64
- func MaxEvidenceBytesPerBlock(blockMaxBytes int64) int64
- func NewErroringMockPV() *erroringMockPV
- 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 ValidateHash(h []byte) error
- func ValidateTime(t time.Time) error
- type ABCIResult
- type ABCIResults
- type Address
- type Block
- func (b *Block) Hash() cmn.HexBytes
- func (b *Block) HashesTo(hash []byte) bool
- func (b *Block) MakePartSet(partSize int) *PartSet
- 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) ValidateBasic() error
- type BlockEventPublisher
- type BlockID
- type BlockMeta
- type BlockSizeParams
- type CanonicalBlockID
- type CanonicalHeartbeat
- type CanonicalPartSetHeader
- type CanonicalProposal
- type CanonicalVote
- type Commit
- func (commit *Commit) BitArray() *cmn.BitArray
- func (commit *Commit) FirstPrecommit() *Vote
- func (commit *Commit) GetByIndex(index int) *Vote
- func (commit *Commit) Hash() cmn.HexBytes
- func (commit *Commit) Height() int64
- func (commit *Commit) IsCommit() bool
- func (commit *Commit) Round() int
- func (commit *Commit) Size() int
- func (commit *Commit) StringIndented(indent string) string
- func (commit *Commit) Type() byte
- func (commit *Commit) ValidateBasic() error
- type ConsensusParams
- type Data
- type DuplicateVoteEvidence
- func (dve *DuplicateVoteEvidence) Address() []byte
- 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) ValidateBasic() error
- func (dve *DuplicateVoteEvidence) Verify(chainID string, pubKey crypto.PubKey) error
- type ErrEvidenceInvalid
- type ErrEvidenceOverflow
- type ErrVoteConflictingVotes
- type EventBus
- func (b *EventBus) OnStart() error
- func (b *EventBus) OnStop()
- func (b *EventBus) Publish(eventType string, eventData TMEventData) error
- func (b *EventBus) PublishEventCompleteProposal(data EventDataRoundState) 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 EventDataRoundState) error
- func (b *EventBus) PublishEventNewRoundStep(data EventDataRoundState) error
- func (b *EventBus) PublishEventPolka(data EventDataRoundState) error
- func (b *EventBus) PublishEventProposalHeartbeat(data EventDataProposalHeartbeat) error
- func (b *EventBus) PublishEventRelock(data EventDataRoundState) 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) 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, ...) 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 EventDataNewBlock
- type EventDataNewBlockHeader
- type EventDataProposalHeartbeat
- type EventDataRoundState
- type EventDataString
- type EventDataTx
- type EventDataValidatorSetUpdates
- type EventDataVote
- type Evidence
- type EvidenceData
- type EvidenceList
- type EvidenceParams
- type GenesisDoc
- type GenesisValidator
- type Header
- type Heartbeat
- type MockBadEvidence
- type MockGoodEvidence
- func (e MockGoodEvidence) Address() []byte
- func (e MockGoodEvidence) Bytes() []byte
- func (e MockGoodEvidence) Equal(ev Evidence) bool
- func (e MockGoodEvidence) Hash() []byte
- func (e MockGoodEvidence) Height() int64
- func (e MockGoodEvidence) String() string
- func (e MockGoodEvidence) ValidateBasic() error
- func (e MockGoodEvidence) Verify(chainID string, pubKey crypto.PubKey) error
- type MockPV
- func (pv *MockPV) DisableChecks()
- func (pv *MockPV) GetAddress() Address
- func (pv *MockPV) GetPubKey() crypto.PubKey
- func (pv *MockPV) SignHeartbeat(chainID string, heartbeat *Heartbeat) 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 NopEventBus
- func (NopEventBus) PublishEventCompleteProposal(data EventDataRoundState) 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) PublishEventPolka(data EventDataRoundState) error
- func (NopEventBus) PublishEventRelock(data EventDataRoundState) error
- func (NopEventBus) PublishEventTimeoutPropose(data EventDataRoundState) error
- func (NopEventBus) PublishEventTimeoutWait(data EventDataRoundState) error
- func (NopEventBus) PublishEventTx(data EventDataTx) 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() *cmn.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
- type PartSetReader
- type PrivValidator
- type PrivValidatorsByAddress
- type Proposal
- type Signable
- type SignedHeader
- type SignedMsgType
- type TMEventData
- type Tx
- type TxEventPublisher
- type TxProof
- type TxResult
- type Txs
- type Validator
- type ValidatorParams
- type ValidatorSet
- func (vals *ValidatorSet) Add(val *Validator) (added bool)
- func (vals *ValidatorSet) Copy() *ValidatorSet
- func (vals *ValidatorSet) CopyIncrementAccum(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() []byte
- func (vals *ValidatorSet) IncrementAccum(times int)
- func (vals *ValidatorSet) IsNilOrEmpty() bool
- func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (vals *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
- func (vals *ValidatorSet) Size() int
- func (vals *ValidatorSet) String() string
- func (vals *ValidatorSet) StringIndented(indent string) string
- func (vals *ValidatorSet) TotalVotingPower() int64
- func (vals *ValidatorSet) Update(val *Validator) (updated bool)
- func (vals *ValidatorSet) VerifyCommit(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 Vote
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *cmn.BitArray
- func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *cmn.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) HasAll() bool
- func (voteSet *VoteSet) HasTwoThirdsAny() bool
- func (voteSet *VoteSet) HasTwoThirdsMajority() bool
- func (voteSet *VoteSet) Height() int64
- func (voteSet *VoteSet) IsCommit() bool
- func (voteSet *VoteSet) MakeCommit() *Commit
- func (voteSet *VoteSet) MarshalJSON() ([]byte, error)
- func (voteSet *VoteSet) Round() int
- 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 = 653 // MaxAminoOverheadForBlock - maximum amino overhead to encode a block (up to // MaxBlockSizeBytes in size) not including it's parts except Data. // // 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 )
const ( EventCompleteProposal = "CompleteProposal" EventLock = "Lock" EventNewBlock = "NewBlock" EventNewBlockHeader = "NewBlockHeader" EventNewRound = "NewRound" EventNewRoundStep = "NewRoundStep" EventPolka = "Polka" EventProposalHeartbeat = "ProposalHeartbeat" EventRelock = "Relock" EventTimeoutPropose = "TimeoutPropose" EventTimeoutWait = "TimeoutWait" EventTx = "Tx" EventUnlock = "Unlock" EventValidBlock = "ValidBlock" EventValidatorSetUpdates = "ValidatorSetUpdates" EventVote = "Vote" )
Reserved event types (alphabetically sorted).
const ( // EventTypeKey is a reserved key, used to specify event type in tags. 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" )
const ( // MaxBlockSizeBytes is the maximum permitted size of the blocks. MaxBlockSizeBytes = 104857600 // 100MB // BlockPartSizeBytes is the size of one block part. BlockPartSizeBytes = 65536 // 64kB )
const ( ABCIEvidenceTypeDuplicateVote = "duplicate/vote" ABCIEvidenceTypeMockGood = "mock/good" )
const ( ABCIPubKeyTypeEd25519 = "ed25519" ABCIPubKeyTypeSecp256k1 = "secp256k1" )
const (
// MaxChainIDLen is a maximum length of the chain ID.
MaxChainIDLen = 50
)
const ( // MaxEvidenceBytes is a maximum size of any evidence (including amino overhead). MaxEvidenceBytes int64 = 484 )
const ( // MaxVoteBytes is a maximum vote size (including amino overhead). MaxVoteBytes int64 = 223 )
const TimeFormat = time.RFC3339Nano
TimeFormat is used for generating the sigs
Variables ¶
var ( EventQueryCompleteProposal = QueryForEvent(EventCompleteProposal) EventQueryLock = QueryForEvent(EventLock) EventQueryNewBlock = QueryForEvent(EventNewBlock) EventQueryNewBlockHeader = QueryForEvent(EventNewBlockHeader) EventQueryNewRound = QueryForEvent(EventNewRound) EventQueryNewRoundStep = QueryForEvent(EventNewRoundStep) EventQueryPolka = QueryForEvent(EventPolka) EventQueryProposalHeartbeat = QueryForEvent(EventProposalHeartbeat) 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 ( 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 ABCIPubKeyTypesToAminoRoutes = map[string]string{ ABCIPubKeyTypeEd25519: ed25519.PubKeyAminoRoute, ABCIPubKeyTypeSecp256k1: secp256k1.PubKeyAminoRoute, }
TODO: Make non-global by allowing for registration of more pubkey types
var ErroringMockPVErr = errors.New("erroringMockPV always returns an error")
var ( // MaxSignatureSize is a maximum allowed signature size for the Heartbeat, // Proposal and Vote. // XXX: secp256k1 does not have Size nor MaxSize defined. MaxSignatureSize = cmn.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 CanonicalTime ¶ added in v0.15.0
CanonicalTime can be used to stringify time in a canonical way.
func EventQueryTxFor ¶ added in v0.15.0
func GetCodec ¶ added in v0.26.0
GetCodec returns a codec used by the package. For testing purposes only.
func IsVoteTypeValid ¶ added in v0.9.2
func IsVoteTypeValid(t SignedMsgType) bool
IsVoteTypeValid returns true if t is a valid vote type.
func MaxDataBytes ¶ added in v0.26.0
MaxDataBytes returns the maximum size of block's data.
XXX: Panics on negative result.
func MaxDataBytesUnknownEvidence ¶ added in v0.26.0
MaxDataBytesUnknownEvidence returns the maximum size of block's data when evidence count is unknown. MaxEvidenceBytesPerBlock will be used as the size of evidence.
XXX: Panics on negative result.
func MaxEvidenceBytesPerBlock ¶ added in v0.26.0
MaxEvidenceBytesPerBlock returns the maximum evidence size per block - 1/10th of the maximum block size.
func NewErroringMockPV ¶ added in v0.26.0
func NewErroringMockPV() *erroringMockPV
NewErroringMockPV returns a MockPV that fails on each signing request. Again, for testing only.
func QueryForEvent ¶ added in v0.15.0
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 ¶ added in v0.26.0
func RegisterEventDatas ¶ added in v0.19.7
func RegisterEvidences ¶ added in v0.19.7
func RegisterMockEvidences ¶ added in v0.26.0
func ValidateHash ¶ added in v0.26.0
ValidateHash returns an error if the hash is not empty, but its size != tmhash.Size.
func ValidateTime ¶ added in v0.26.0
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.
Types ¶
type ABCIResult ¶ added in v0.15.0
ABCIResult is the deterministic component of a ResponseDeliverTx. TODO: add Tags
func NewResultFromResponse ¶ added in v0.15.0
func NewResultFromResponse(response *abci.ResponseDeliverTx) ABCIResult
NewResultFromResponse creates ABCIResult from ResponseDeliverTx.
func (ABCIResult) Bytes ¶ added in v0.26.0
func (a ABCIResult) Bytes() []byte
func (ABCIResult) Hash ¶ added in v0.15.0
func (a ABCIResult) Hash() []byte
Hash returns the canonical hash of the ABCIResult
type ABCIResults ¶ added in v0.15.0
type ABCIResults []ABCIResult
ABCIResults wraps the deliver tx results to return a proof
func NewResults ¶ added in v0.15.0
func NewResults(responses []*abci.ResponseDeliverTx) ABCIResults
NewResults creates ABCIResults from the list of ResponseDeliverTx.
func (ABCIResults) Bytes ¶ added in v0.15.0
func (a ABCIResults) Bytes() []byte
Bytes serializes the ABCIResponse using wire
func (ABCIResults) Hash ¶ added in v0.15.0
func (a ABCIResults) Hash() []byte
Hash returns a merkle hash of all results
func (ABCIResults) ProveResult ¶ added in v0.15.0
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 ¶ added in v0.9.2
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) 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) StringIndented ¶
StringIndented returns a string representation of the block
func (*Block) StringShort ¶
StringShort returns a shortened string representation of the block
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 ¶ added in v0.15.0
type BlockEventPublisher interface { PublishEventNewBlock(block EventDataNewBlock) error PublishEventNewBlockHeader(header EventDataNewBlockHeader) error PublishEventTx(EventDataTx) error PublishEventValidatorSetUpdates(EventDataValidatorSetUpdates) error }
BlockEventPublisher publishes all block related events
type BlockID ¶ added in v0.9.2
type BlockID struct { Hash cmn.HexBytes `json:"hash"` PartsHeader PartSetHeader `json:"parts"` }
BlockID defines the unique ID of a block as its Hash and its PartSetHeader
func (BlockID) Equals ¶ added in v0.9.2
Equals returns true if the BlockID matches the given BlockID
func (BlockID) Key ¶ added in v0.9.2
Key returns a machine-readable string representation of the BlockID
func (BlockID) String ¶ added in v0.9.2
String returns a human readable string representation of the BlockID
func (BlockID) ValidateBasic ¶ added in v0.26.0
ValidateBasic performs basic validation.
type BlockMeta ¶
type BlockMeta struct { BlockID BlockID `json:"block_id"` // the block hash and partsethash Header Header `json:"header"` // The block's Header }
BlockMeta contains meta information about a block - namely, it's ID and Header.
func NewBlockMeta ¶
NewBlockMeta returns a new BlockMeta from the block and its blockParts.
type BlockSizeParams ¶ added in v0.26.0
BlockSizeParams define limits on the block size.
func DefaultBlockSizeParams ¶ added in v0.26.0
func DefaultBlockSizeParams() BlockSizeParams
DefaultBlockSizeParams returns a default BlockSizeParams.
type CanonicalBlockID ¶ added in v0.9.2
type CanonicalBlockID struct { Hash cmn.HexBytes PartsHeader CanonicalPartSetHeader }
func CanonicalizeBlockID ¶ added in v0.26.0
func CanonicalizeBlockID(blockID BlockID) CanonicalBlockID
type CanonicalHeartbeat ¶ added in v0.15.0
type CanonicalHeartbeat struct { Type byte Height int64 `binary:"fixed64"` Round int `binary:"fixed64"` Sequence int `binary:"fixed64"` ValidatorAddress Address ValidatorIndex int ChainID string }
func CanonicalizeHeartbeat ¶ added in v0.26.0
func CanonicalizeHeartbeat(chainID string, heartbeat *Heartbeat) CanonicalHeartbeat
type CanonicalPartSetHeader ¶ added in v0.9.2
func CanonicalizePartSetHeader ¶ added in v0.26.0
func CanonicalizePartSetHeader(psh PartSetHeader) CanonicalPartSetHeader
type CanonicalProposal ¶ added in v0.9.2
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 ¶ added in v0.26.0
func CanonicalizeProposal(chainID string, proposal *Proposal) CanonicalProposal
type CanonicalVote ¶ added in v0.9.2
type CanonicalVote struct { Type SignedMsgType // type alias for byte Height int64 `binary:"fixed64"` Round int64 `binary:"fixed64"` Timestamp time.Time BlockID CanonicalBlockID ChainID string }
func CanonicalizeVote ¶ added in v0.26.0
func CanonicalizeVote(chainID string, vote *Vote) CanonicalVote
type Commit ¶
type Commit struct { // NOTE: The Precommits are in order of address to preserve the bonded ValidatorSet order. // Any peer with a block can gossip precommits by index with a peer without recalculating the // active ValidatorSet. BlockID BlockID `json:"block_id"` Precommits []*Vote `json:"precommits"` // 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 MakeCommit ¶ added in v0.15.0
func (*Commit) FirstPrecommit ¶
FirstPrecommit returns the first non-nil precommit in the commit. If all precommits are nil, it returns an empty precommit with height 0.
func (*Commit) GetByIndex ¶
GetByIndex returns the vote corresponding to a given validator index
func (*Commit) StringIndented ¶
StringIndented returns a string representation of the commit
func (*Commit) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.
type ConsensusParams ¶ added in v0.15.0
type ConsensusParams struct { BlockSize BlockSizeParams `json:"block_size"` Evidence EvidenceParams `json:"evidence"` Validator ValidatorParams `json:"validator"` }
ConsensusParams contains consensus critical parameters that determine the validity of blocks.
func DefaultConsensusParams ¶ added in v0.15.0
func DefaultConsensusParams() *ConsensusParams
DefaultConsensusParams returns a default ConsensusParams.
func (*ConsensusParams) Equals ¶ added in v0.26.0
func (params *ConsensusParams) Equals(params2 *ConsensusParams) bool
func (*ConsensusParams) Hash ¶ added in v0.15.0
func (params *ConsensusParams) Hash() []byte
Hash returns a hash of the parameters to store in the block header No Merkle tree here, only three values are hashed here thus benefit from saving space < drawbacks from proofs' overhead Revisit this function if new fields are added to ConsensusParams
func (ConsensusParams) Update ¶ added in v0.15.0
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 ¶ added in v0.15.0
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
type DuplicateVoteEvidence ¶ added in v0.15.0
DuplicateVoteEvidence contains evidence a validator signed two conflicting votes.
func (*DuplicateVoteEvidence) Address ¶ added in v0.15.0
func (dve *DuplicateVoteEvidence) Address() []byte
Address returns the address of the validator.
func (*DuplicateVoteEvidence) Bytes ¶ added in v0.26.0
func (dve *DuplicateVoteEvidence) Bytes() []byte
Hash returns the hash of the evidence.
func (*DuplicateVoteEvidence) Equal ¶ added in v0.15.0
func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool
Equal checks if two pieces of evidence are equal.
func (*DuplicateVoteEvidence) Hash ¶ added in v0.15.0
func (dve *DuplicateVoteEvidence) Hash() []byte
Hash returns the hash of the evidence.
func (*DuplicateVoteEvidence) Height ¶ added in v0.15.0
func (dve *DuplicateVoteEvidence) Height() int64
Height returns the height this evidence refers to.
func (*DuplicateVoteEvidence) String ¶ added in v0.15.0
func (dve *DuplicateVoteEvidence) String() string
String returns a string representation of the evidence.
func (*DuplicateVoteEvidence) ValidateBasic ¶ added in v0.26.0
func (dve *DuplicateVoteEvidence) ValidateBasic() error
ValidateBasic performs basic validation.
func (*DuplicateVoteEvidence) Verify ¶ added in v0.15.0
func (dve *DuplicateVoteEvidence) Verify(chainID string, pubKey crypto.PubKey) error
Verify returns an error if the two votes aren't conflicting. To be conflicting, they must be from the same validator, for the same H/R/S, but for different blocks.
type ErrEvidenceInvalid ¶ added in v0.15.0
ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid.
func NewErrEvidenceInvalid ¶ added in v0.26.0
func NewErrEvidenceInvalid(ev Evidence, err error) *ErrEvidenceInvalid
NewErrEvidenceInvalid returns a new EvidenceInvalid with the given err.
func (*ErrEvidenceInvalid) Error ¶ added in v0.15.0
func (err *ErrEvidenceInvalid) Error() string
Error returns a string representation of the error.
type ErrEvidenceOverflow ¶ added in v0.26.0
ErrEvidenceOverflow is for when there is too much evidence in a block.
func NewErrEvidenceOverflow ¶ added in v0.26.0
func NewErrEvidenceOverflow(max, got int64) *ErrEvidenceOverflow
NewErrEvidenceOverflow returns a new ErrEvidenceOverflow where got > max.
func (*ErrEvidenceOverflow) Error ¶ added in v0.26.0
func (err *ErrEvidenceOverflow) Error() string
Error returns a string representation of the error.
type ErrVoteConflictingVotes ¶ added in v0.9.2
type ErrVoteConflictingVotes struct {
*DuplicateVoteEvidence
}
func NewConflictingVoteError ¶ added in v0.15.0
func NewConflictingVoteError(val *Validator, voteA, voteB *Vote) *ErrVoteConflictingVotes
func (*ErrVoteConflictingVotes) Error ¶ added in v0.9.2
func (err *ErrVoteConflictingVotes) Error() string
type EventBus ¶ added in v0.15.0
type EventBus struct { cmn.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 NewEventBus ¶ added in v0.15.0
func NewEventBus() *EventBus
NewEventBus returns a new event bus.
func NewEventBusWithBufferCapacity ¶ added in v0.15.0
NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity.
func (*EventBus) Publish ¶ added in v0.15.0
func (b *EventBus) Publish(eventType string, eventData TMEventData) error
func (*EventBus) PublishEventCompleteProposal ¶ added in v0.15.0
func (b *EventBus) PublishEventCompleteProposal(data EventDataRoundState) error
func (*EventBus) PublishEventLock ¶ added in v0.15.0
func (b *EventBus) PublishEventLock(data EventDataRoundState) error
func (*EventBus) PublishEventNewBlock ¶ added in v0.15.0
func (b *EventBus) PublishEventNewBlock(data EventDataNewBlock) error
func (*EventBus) PublishEventNewBlockHeader ¶ added in v0.15.0
func (b *EventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error
func (*EventBus) PublishEventNewRound ¶ added in v0.15.0
func (b *EventBus) PublishEventNewRound(data EventDataRoundState) error
func (*EventBus) PublishEventNewRoundStep ¶ added in v0.15.0
func (b *EventBus) PublishEventNewRoundStep(data EventDataRoundState) error
func (*EventBus) PublishEventPolka ¶ added in v0.15.0
func (b *EventBus) PublishEventPolka(data EventDataRoundState) error
func (*EventBus) PublishEventProposalHeartbeat ¶ added in v0.15.0
func (b *EventBus) PublishEventProposalHeartbeat(data EventDataProposalHeartbeat) error
func (*EventBus) PublishEventRelock ¶ added in v0.15.0
func (b *EventBus) PublishEventRelock(data EventDataRoundState) error
func (*EventBus) PublishEventTimeoutPropose ¶ added in v0.15.0
func (b *EventBus) PublishEventTimeoutPropose(data EventDataRoundState) error
func (*EventBus) PublishEventTimeoutWait ¶ added in v0.15.0
func (b *EventBus) PublishEventTimeoutWait(data EventDataRoundState) error
func (*EventBus) PublishEventTx ¶ added in v0.15.0
func (b *EventBus) PublishEventTx(data EventDataTx) error
PublishEventTx publishes tx event with tags from Result. Note it will add predefined tags (EventTypeKey, TxHashKey). Existing tags with the same names will be overwritten.
func (*EventBus) PublishEventUnlock ¶ added in v0.15.0
func (b *EventBus) PublishEventUnlock(data EventDataRoundState) error
func (*EventBus) PublishEventValidBlock ¶ added in v0.26.0
func (b *EventBus) PublishEventValidBlock(data EventDataRoundState) error
func (*EventBus) PublishEventValidatorSetUpdates ¶ added in v0.26.0
func (b *EventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error
func (*EventBus) PublishEventVote ¶ added in v0.15.0
func (b *EventBus) PublishEventVote(data EventDataVote) error
func (*EventBus) Unsubscribe ¶ added in v0.15.0
type EventBusSubscriber ¶ added in v0.15.0
type EventDataNewBlock ¶
type EventDataNewBlock struct {
Block *Block `json:"block"`
}
type EventDataNewBlockHeader ¶
type EventDataNewBlockHeader struct {
Header Header `json:"header"`
}
light weight event for benchmarking
type EventDataProposalHeartbeat ¶ added in v0.15.0
type EventDataProposalHeartbeat struct {
Heartbeat *Heartbeat
}
type EventDataRoundState ¶
type EventDataRoundState struct { Height int64 `json:"height"` Round int `json:"round"` Step string `json:"step"` // private, not exposed to websockets RoundState interface{} `json:"-"` }
NOTE: This goes into the replay WAL
type EventDataString ¶ added in v0.19.7
type EventDataString string
type EventDataValidatorSetUpdates ¶ added in v0.26.0
type EventDataValidatorSetUpdates struct {
ValidatorUpdates []*Validator `json:"validator_updates"`
}
type EventDataVote ¶
type EventDataVote struct {
Vote *Vote
}
type Evidence ¶ added in v0.15.0
type Evidence interface { Height() int64 // height of the equivocation Address() []byte // address of the equivocating validator Bytes() []byte // bytes which compromise 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 ¶ added in v0.15.0
type EvidenceData struct { Evidence EvidenceList `json:"evidence"` // contains filtered or unexported fields }
EvidenceData contains any evidence of malicious wrong-doing by validators
func (*EvidenceData) Hash ¶ added in v0.15.0
func (data *EvidenceData) Hash() cmn.HexBytes
Hash returns the hash of the data.
func (*EvidenceData) StringIndented ¶ added in v0.15.0
func (data *EvidenceData) StringIndented(indent string) string
StringIndented returns a string representation of the evidence.
type EvidenceList ¶ added in v0.15.0
type EvidenceList []Evidence
EvidenceList is a list of Evidence. Evidences is not a word.
func (EvidenceList) Has ¶ added in v0.15.0
func (evl EvidenceList) Has(evidence Evidence) bool
Has returns true if the evidence is in the EvidenceList.
func (EvidenceList) Hash ¶ added in v0.15.0
func (evl EvidenceList) Hash() []byte
Hash returns the simple merkle root hash of the EvidenceList.
func (EvidenceList) String ¶ added in v0.15.0
func (evl EvidenceList) String() string
type EvidenceParams ¶ added in v0.15.0
type EvidenceParams struct {
MaxAge int64 `json:"max_age"` // only accept new evidence more recent than this
}
EvidenceParams determine how we handle evidence of malfeasance
func DefaultEvidenceParams ¶ added in v0.15.0
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 cmn.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 ¶ added in v0.15.0
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 ¶ added in v0.15.0
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 ¶ added in v0.15.0
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 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"` NumTxs int64 `json:"num_txs"` TotalTxs int64 `json:"total_txs"` // prev block info LastBlockID BlockID `json:"last_block_id"` // hashes of block data LastCommitHash cmn.HexBytes `json:"last_commit_hash"` // commit from validators from the last block DataHash cmn.HexBytes `json:"data_hash"` // transactions // hashes from the app output from the prev block ValidatorsHash cmn.HexBytes `json:"validators_hash"` // validators for the current block NextValidatorsHash cmn.HexBytes `json:"next_validators_hash"` // validators for the next block ConsensusHash cmn.HexBytes `json:"consensus_hash"` // consensus params for current block AppHash cmn.HexBytes `json:"app_hash"` // state after txs from the previous block LastResultsHash cmn.HexBytes `json:"last_results_hash"` // root hash of all results from the txs from the previous block // consensus info EvidenceHash cmn.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 - /docs/spec/blockchain/blockchain.md
func (*Header) Hash ¶
Hash returns the hash of the header. It computes a Merkle tree from the header fields ordered as they appear in the Header. Returns nil if ValidatorHash is missing, since a Header is not valid unless there is a ValidatorsHash (corresponding to the validator set).
func (*Header) Populate ¶ added in v0.26.0
func (h *Header) Populate( version version.Consensus, chainID string, timestamp time.Time, lastBlockID BlockID, totalTxs int64, 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) StringIndented ¶
StringIndented returns a string representation of the header
type Heartbeat ¶ added in v0.15.0
type Heartbeat struct { ValidatorAddress Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Height int64 `json:"height"` Round int `json:"round"` Sequence int `json:"sequence"` Signature []byte `json:"signature"` }
Heartbeat is a simple vote-like structure so validators can alert others that they are alive and waiting for transactions. Note: We aren't adding ",omitempty" to Heartbeat's json field tags because we always want the JSON representation to be in its canonical form.
func (*Heartbeat) SignBytes ¶ added in v0.19.7
SignBytes returns the Heartbeat bytes for signing. It panics if the Heartbeat is nil.
func (*Heartbeat) String ¶ added in v0.15.0
String returns a string representation of the Heartbeat.
func (*Heartbeat) ValidateBasic ¶ added in v0.26.0
ValidateBasic performs basic validation.
type MockBadEvidence ¶ added in v0.15.0
type MockBadEvidence struct {
MockGoodEvidence
}
UNSTABLE
func (MockBadEvidence) Equal ¶ added in v0.15.0
func (e MockBadEvidence) Equal(ev Evidence) bool
func (MockBadEvidence) String ¶ added in v0.15.0
func (e MockBadEvidence) String() string
func (MockBadEvidence) ValidateBasic ¶ added in v0.26.0
func (e MockBadEvidence) ValidateBasic() error
type MockGoodEvidence ¶ added in v0.15.0
UNSTABLE
func NewMockGoodEvidence ¶ added in v0.15.0
func NewMockGoodEvidence(height int64, idx int, address []byte) MockGoodEvidence
UNSTABLE
func (MockGoodEvidence) Address ¶ added in v0.15.0
func (e MockGoodEvidence) Address() []byte
func (MockGoodEvidence) Bytes ¶ added in v0.26.0
func (e MockGoodEvidence) Bytes() []byte
func (MockGoodEvidence) Equal ¶ added in v0.15.0
func (e MockGoodEvidence) Equal(ev Evidence) bool
func (MockGoodEvidence) Hash ¶ added in v0.15.0
func (e MockGoodEvidence) Hash() []byte
func (MockGoodEvidence) Height ¶ added in v0.15.0
func (e MockGoodEvidence) Height() int64
func (MockGoodEvidence) String ¶ added in v0.15.0
func (e MockGoodEvidence) String() string
func (MockGoodEvidence) ValidateBasic ¶ added in v0.26.0
func (e MockGoodEvidence) ValidateBasic() error
type MockPV ¶ added in v0.19.7
type MockPV struct {
// contains filtered or unexported fields
}
MockPV implements PrivValidator without any safety or persistence. Only use it for testing.
func (*MockPV) GetAddress ¶ added in v0.19.7
Implements PrivValidator.
func (*MockPV) SignHeartbeat ¶ added in v0.19.7
signHeartbeat signs the heartbeat without any checking.
func (*MockPV) SignProposal ¶ added in v0.19.7
Implements PrivValidator.
type NopEventBus ¶ added in v0.15.0
type NopEventBus struct{}
-----------------------------------------------------------------------------
func (NopEventBus) PublishEventCompleteProposal ¶ added in v0.15.0
func (NopEventBus) PublishEventCompleteProposal(data EventDataRoundState) error
func (NopEventBus) PublishEventLock ¶ added in v0.15.0
func (NopEventBus) PublishEventLock(data EventDataRoundState) error
func (NopEventBus) PublishEventNewBlock ¶ added in v0.15.0
func (NopEventBus) PublishEventNewBlock(data EventDataNewBlock) error
func (NopEventBus) PublishEventNewBlockHeader ¶ added in v0.15.0
func (NopEventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error
func (NopEventBus) PublishEventNewRound ¶ added in v0.15.0
func (NopEventBus) PublishEventNewRound(data EventDataRoundState) error
func (NopEventBus) PublishEventNewRoundStep ¶ added in v0.15.0
func (NopEventBus) PublishEventNewRoundStep(data EventDataRoundState) error
func (NopEventBus) PublishEventPolka ¶ added in v0.15.0
func (NopEventBus) PublishEventPolka(data EventDataRoundState) error
func (NopEventBus) PublishEventRelock ¶ added in v0.15.0
func (NopEventBus) PublishEventRelock(data EventDataRoundState) error
func (NopEventBus) PublishEventTimeoutPropose ¶ added in v0.15.0
func (NopEventBus) PublishEventTimeoutPropose(data EventDataRoundState) error
func (NopEventBus) PublishEventTimeoutWait ¶ added in v0.15.0
func (NopEventBus) PublishEventTimeoutWait(data EventDataRoundState) error
func (NopEventBus) PublishEventTx ¶ added in v0.15.0
func (NopEventBus) PublishEventTx(data EventDataTx) error
func (NopEventBus) PublishEventUnlock ¶ added in v0.15.0
func (NopEventBus) PublishEventUnlock(data EventDataRoundState) error
func (NopEventBus) PublishEventValidatorSetUpdates ¶ added in v0.26.0
func (NopEventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error
func (NopEventBus) PublishEventVote ¶ added in v0.15.0
func (NopEventBus) PublishEventVote(data EventDataVote) error
func (NopEventBus) Unsubscribe ¶ added in v0.15.0
func (NopEventBus) UnsubscribeAll ¶ added in v0.15.0
func (NopEventBus) UnsubscribeAll(ctx context.Context, subscriber string) error
type P2PID ¶ added in v0.19.7
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 cmn.HexBytes `json:"bytes"` Proof merkle.SimpleProof `json:"proof"` // contains filtered or unexported fields }
func (*Part) StringIndented ¶
func (*Part) ValidateBasic ¶ added in v0.26.0
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 ¶ added in v0.19.7
func (*PartSet) StringShort ¶
type PartSetHeader ¶
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) ValidateBasic ¶ added in v0.26.0
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 { GetAddress() Address // redundant since .PubKey().Address() GetPubKey() crypto.PubKey SignVote(chainID string, vote *Vote) error SignProposal(chainID string, proposal *Proposal) error SignHeartbeat(chainID string, heartbeat *Heartbeat) error }
PrivValidator defines the functionality of a local Tendermint validator that signs votes, proposals, and heartbeats, 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"` }
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 (*Proposal) ValidateBasic ¶ added in v0.26.0
ValidateBasic performs basic validation.
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 ¶ added in v0.15.0
SignedHeader is a header along with the commits that prove it.
func (SignedHeader) String ¶ added in v0.26.0
func (sh SignedHeader) String() string
func (SignedHeader) StringIndented ¶ added in v0.26.0
func (sh SignedHeader) StringIndented(indent string) string
StringIndented returns a string representation of the SignedHeader.
func (SignedHeader) ValidateBasic ¶ added in v0.26.0
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.
type SignedMsgType ¶ added in v0.26.0
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 // Heartbeat HeartbeatType SignedMsgType = 0x30 )
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 ¶ added in v0.15.0
type TxEventPublisher interface {
PublishEventTx(EventDataTx) error
}
type TxProof ¶ added in v0.9.2
type TxProof struct { RootHash cmn.HexBytes Data Tx Proof merkle.SimpleProof }
TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
type TxResult ¶ added in v0.9.2
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.
type Txs ¶
type Txs []Tx
Txs is a slice of Tx.
func (Txs) Index ¶ added in v0.9.2
Index returns the index of this transaction in the list, or -1 if not found
func (Txs) IndexByHash ¶ added in v0.9.2
IndexByHash returns the index of this transaction hash in the list, or -1 if not found
type Validator ¶
type Validator struct { Address Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower int64 `json:"voting_power"` Accum int64 `json:"accum"` }
Volatile state for each Validator NOTE: The Accum is not included in Validator.Hash(); make sure to update that method if changes are made here
func NewValidator ¶ added in v0.9.2
func (*Validator) Bytes ¶ added in v0.26.0
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 accum which changes every round.
func (*Validator) CompareAccum ¶
Returns the one with higher Accum.
func (*Validator) Copy ¶
Creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.
type ValidatorParams ¶ added in v0.26.0
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 routes.
func DefaultValidatorParams ¶ added in v0.26.0
func DefaultValidatorParams() ValidatorParams
DefaultValidatorParams returns a default ValidatorParams, which allows only ed25519 pubkeys.
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. On the other hand, the .AccumPower of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety.
func NewValidatorSet ¶
func NewValidatorSet(valz []*Validator) *ValidatorSet
func (*ValidatorSet) Add ¶
func (vals *ValidatorSet) Add(val *Validator) (added bool)
Add adds val to the validator set and returns true. It returns false if val is already in the set.
func (*ValidatorSet) Copy ¶
func (vals *ValidatorSet) Copy() *ValidatorSet
Copy each validator into a new ValidatorSet
func (*ValidatorSet) CopyIncrementAccum ¶ added in v0.26.0
func (vals *ValidatorSet) CopyIncrementAccum(times int) *ValidatorSet
Increment Accum and update the proposer on a copy, and return 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 ¶ added in v0.9.2
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() []byte
Hash returns the Merkle root hash build using validators (as leaves) in the set.
func (*ValidatorSet) IncrementAccum ¶
func (vals *ValidatorSet) IncrementAccum(times int)
IncrementAccum increments accum of each validator and updates the proposer. Panics if validator set is empty.
func (*ValidatorSet) IsNilOrEmpty ¶ added in v0.26.0
func (vals *ValidatorSet) IsNilOrEmpty() bool
Nil or empty validator sets are invalid.
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) Remove ¶
func (vals *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)
Remove deletes the validator with address. It returns the validator removed and true. If returns nil and false if validator is not present in the set.
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
String
func (*ValidatorSet) TotalVotingPower ¶
func (vals *ValidatorSet) TotalVotingPower() int64
TotalVotingPower returns the sum of the voting powers of all validators.
func (*ValidatorSet) Update ¶
func (vals *ValidatorSet) Update(val *Validator) (updated bool)
Update updates val and returns true. It returns false if val is not present in the set.
func (*ValidatorSet) VerifyCommit ¶
func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
Verify that +2/3 of the set had signed the given signBytes.
func (*ValidatorSet) VerifyFutureCommit ¶ added in v0.26.0
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
Sort 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 Vote ¶
type Vote struct { Type SignedMsgType `json:"type"` Height int64 `json:"height"` Round int `json:"round"` Timestamp time.Time `json:"timestamp"` BlockID BlockID `json:"block_id"` // zero if vote is nil. ValidatorAddress Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Signature []byte `json:"signature"` }
Vote represents a prevote, precommit, or commit vote from validators for consensus.
func (*Vote) ValidateBasic ¶ added in v0.26.0
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 NewVoteSet ¶
func NewVoteSet(chainID string, height int64, round int, type_ SignedMsgType, valSet *ValidatorSet) *VoteSet
Constructs a new VoteSet struct used to accumulate votes for given height/round.
func (*VoteSet) AddVote ¶ added in v0.9.2
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 ¶ added in v0.9.2
func (*VoteSet) BitArrayString ¶ added in v0.19.7
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
func (*VoteSet) HasTwoThirdsAny ¶
func (*VoteSet) HasTwoThirdsMajority ¶
func (*VoteSet) MakeCommit ¶
func (*VoteSet) MarshalJSON ¶ added in v0.19.7
Marshal the VoteSet to JSON. Same as String(), just in JSON, and without the height/round/type_ (since its already included in the votes).
func (*VoteSet) SetPeerMaj23 ¶ added in v0.9.2
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 ¶ added in v0.19.7
Returns a list of votes compressed to more readable strings.
type VoteSetJSON ¶ added in v0.19.7
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_meta.go
- canonical.go
- encoding_helper.go
- event_bus.go
- events.go
- evidence.go
- genesis.go
- heartbeat.go
- keys.go
- params.go
- part_set.go
- priv_validator.go
- proposal.go
- protobuf.go
- results.go
- signable.go
- signed_msg_type.go
- test_util.go
- tx.go
- validation.go
- validator.go
- validator_set.go
- vote.go
- vote_set.go
- wire.go