tendermint: github.com/tendermint/tendermint/types Index | Files | Directories

package types

import "github.com/tendermint/tendermint/types"

Index

Package Files

block.go block_meta.go canonical.go encoding_helper.go errors.go event_bus.go events.go evidence.go genesis.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 utils.go validation.go validator.go validator_set.go vote.go vote_set.go

Constants

const (
    // MaxHeaderBytes is a maximum header size.
    MaxHeaderBytes int64 = 626

    // MaxOverheadForBlock - maximum 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.
    //
    // Uvarint length of MaxBlockSizeBytes: 4 bytes
    // 2 fields (2 embedded):               2 bytes
    // Uvarint length of Data.Txs:          4 bytes
    // Data.Txs field:                      1 byte
    MaxOverheadForBlock int64 = 11
)
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"
    EventNewEvidence         = "NewEvidence"
    EventTx                  = "Tx"
    EventValidatorSetUpdates = "ValidatorSetUpdates"

    // 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"
)

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"
)
const (
    // MaxEvidenceBytes is a maximum size of any evidence (including amino overhead).
    MaxEvidenceBytes int64 = 444

    // An invalid field in the header from LunaticValidatorEvidence.
    // Must be a function of the ABCI application state.
    ValidatorsHashField     = "ValidatorsHash"
    NextValidatorsHashField = "NextValidatorsHash"
    ConsensusHashField      = "ConsensusHash"
    AppHashField            = "AppHash"
    LastResultsHashField    = "LastResultsHash"
)
const (
    // MaxBlockSizeBytes is the maximum permitted size of the blocks.
    MaxBlockSizeBytes = 104857600 // 100MB

    // BlockPartSizeBytes is the size of one block part.
    BlockPartSizeBytes uint32 = 65536 // 64kB

    // MaxBlockPartsCount is the maximum number of block parts.
    MaxBlockPartsCount = (MaxBlockSizeBytes / BlockPartSizeBytes) + 1

    // Restrict the upper bound of the amount of evidence (uses uint16 for safe conversion)
    MaxEvidencePerBlock = 65535
)
const (
    ABCIEvidenceTypeDuplicateVote = "duplicate/vote"
    ABCIEvidenceTypeLunatic       = "lunatic"
    ABCIEvidenceTypeAmnesia       = "amnesia"
)
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 (
    ABCIPubKeyTypeEd25519 = "ed25519"
)
const (
    // MaxChainIDLen is a maximum length of the chain ID.
    MaxChainIDLen = 50
)
const (
    // MaxVoteBytes is a maximum vote size (including amino overhead).
    MaxVoteBytes int64 = 209
)
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 (
    EventQueryCompleteProposal    = QueryForEvent(EventCompleteProposal)
    EventQueryLock                = QueryForEvent(EventLock)
    EventQueryNewBlock            = QueryForEvent(EventNewBlock)
    EventQueryNewBlockHeader      = QueryForEvent(EventNewBlockHeader)
    EventQueryNewEvidence         = QueryForEvent(EventNewEvidence)
    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 (
    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 ABCIPubKeyTypesToNames = map[string]string{
    ABCIPubKeyTypeEd25519: ed25519.PubKeyName,
}
var ErrTotalVotingPowerOverflow = fmt.Errorf("total voting power of resulting valset exceeds max %d",
    MaxTotalVotingPower)

ErrTotalVotingPowerOverflow is returned if the total voting power of the resulting validator set exceeds MaxTotalVotingPower.

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

func CanonicalTime Uses

func CanonicalTime(t time.Time) string

CanonicalTime can be used to stringify time in a canonical way.

func CanonicalizeBlockID Uses

func CanonicalizeBlockID(bid tmproto.BlockID) *tmproto.CanonicalBlockID

func CanonicalizePartSetHeader Uses

func CanonicalizePartSetHeader(psh tmproto.PartSetHeader) tmproto.CanonicalPartSetHeader

CanonicalizeVote transforms the given PartSetHeader to a CanonicalPartSetHeader.

func CanonicalizeProposal Uses

func CanonicalizeProposal(chainID string, proposal *tmproto.Proposal) tmproto.CanonicalProposal

CanonicalizeVote transforms the given Proposal to a CanonicalProposal.

func CanonicalizeVote Uses

func CanonicalizeVote(chainID string, vote *tmproto.Vote) tmproto.CanonicalVote

CanonicalizeVote transforms the given Vote to a CanonicalVote, which does not contain ValidatorIndex and ValidatorAddress fields.

func DefaultBlockParams Uses

func DefaultBlockParams() tmproto.BlockParams

DefaultBlockParams returns a default BlockParams.

func DefaultConsensusParams Uses

func DefaultConsensusParams() *tmproto.ConsensusParams

DefaultConsensusParams returns a default ConsensusParams.

func DefaultEvidenceParams Uses

func DefaultEvidenceParams() tmproto.EvidenceParams

DefaultEvidenceParams returns a default EvidenceParams.

func DefaultValidatorParams Uses

func DefaultValidatorParams() tmproto.ValidatorParams

DefaultValidatorParams returns a default ValidatorParams, which allows only ed25519 pubkeys.

func DefaultVersionParams Uses

func DefaultVersionParams() tmproto.VersionParams

func EventQueryTxFor Uses

func EventQueryTxFor(tx Tx) tmpubsub.Query

func EvidenceToProto Uses

func EvidenceToProto(evidence Evidence) (*tmproto.Evidence, error)

func HashConsensusParams Uses

func HashConsensusParams(params tmproto.ConsensusParams) []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 IsErrNotEnoughVotingPowerSigned Uses

func IsErrNotEnoughVotingPowerSigned(err error) bool

IsErrNotEnoughVotingPowerSigned returns true if err is ErrNotEnoughVotingPowerSigned.

func IsValidPubkeyType Uses

func IsValidPubkeyType(params tmproto.ValidatorParams, pubkeyType string) bool

func IsVoteTypeValid Uses

func IsVoteTypeValid(t tmproto.SignedMsgType) bool

IsVoteTypeValid returns true if t is a valid vote type.

func MaxDataBytes Uses

func MaxDataBytes(maxBytes int64, valsCount, evidenceCount int) int64

MaxDataBytes returns the maximum size of block's data.

XXX: Panics on negative result.

func MaxDataBytesUnknownEvidence Uses

func MaxDataBytesUnknownEvidence(maxBytes int64, valsCount int, maxNumEvidence uint32) int64

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 ProposalSignBytes Uses

func ProposalSignBytes(chainID string, p *tmproto.Proposal) []byte

ProposalSignBytes returns the proto-encoding of the canonicalized Proposal, for signing.

Panics if the marshaling fails.

See CanonicalizeProposal

func QueryForEvent Uses

func QueryForEvent(eventType string) tmpubsub.Query

func RandValidator Uses

func RandValidator(randPower bool, minPower int64) (*Validator, PrivValidator)

RandValidator returns a randomized validator, useful for testing. UNSTABLE

func RandValidatorSet Uses

func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []PrivValidator)

RandValidatorSet returns a randomized validator set (size: +numValidators+), where each validator has a voting power of +votingPower+.

EXPOSED FOR TESTING.

func UpdateConsensusParams Uses

func UpdateConsensusParams(params tmproto.ConsensusParams, params2 *abci.ConsensusParams) tmproto.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 ValidateConsensusParams Uses

func ValidateConsensusParams(params tmproto.ConsensusParams) error

Validate validates the ConsensusParams to ensure all values are within their allowed limits, and returns an error if they are not.

func ValidateHash Uses

func ValidateHash(h []byte) error

ValidateHash returns an error if the hash is not empty, but its size != tmhash.Size.

func ValidateTime Uses

func ValidateTime(t time.Time) error

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 Uses

func ValidatorListString(vals []*Validator) string

ValidatorListString returns a prettified validator list for logging purposes.

func VoteSignBytes Uses

func VoteSignBytes(chainID string, vote *tmproto.Vote) []byte

VoteSignBytes returns the proto-encoding of the canonicalized Vote, for signing.

Panics if the marshaling fails.

See CanonicalizeVote

type ABCIResults Uses

type ABCIResults []*abci.ResponseDeliverTx

ABCIResults wraps the deliver tx results to return a proof.

func NewResults Uses

func NewResults(responses []*abci.ResponseDeliverTx) ABCIResults

NewResults strips non-deterministic fields from ResponseDeliverTx responses and returns ABCIResults.

func (ABCIResults) Hash Uses

func (a ABCIResults) Hash() []byte

Hash returns a merkle hash of all results.

func (ABCIResults) ProveResult Uses

func (a ABCIResults) ProveResult(i int) merkle.Proof

ProveResult returns a merkle proof of one result from the set

type Address Uses

type Address = crypto.Address

Address is hex bytes.

type AmnesiaEvidence Uses

type AmnesiaEvidence struct {
    *PotentialAmnesiaEvidence
    Polc *ProofOfLockChange
}

AmnesiaEvidence is the progression of PotentialAmnesiaEvidence and is used to prove an infringement of the Tendermint consensus when a validator incorrectly sends a vote in a later round without correctly changing the lock

func AmnesiaEvidenceFromProto Uses

func AmnesiaEvidenceFromProto(pb *tmproto.AmnesiaEvidence) (*AmnesiaEvidence, error)

func NewAmnesiaEvidence Uses

func NewAmnesiaEvidence(pe *PotentialAmnesiaEvidence, proof *ProofOfLockChange) *AmnesiaEvidence

func (*AmnesiaEvidence) Bytes Uses

func (e *AmnesiaEvidence) Bytes() []byte

func (*AmnesiaEvidence) Equal Uses

func (e *AmnesiaEvidence) Equal(ev Evidence) bool

Note: Amnesia evidence with or without a polc are considered the same

func (*AmnesiaEvidence) String Uses

func (e *AmnesiaEvidence) String() string

func (*AmnesiaEvidence) ToProto Uses

func (e *AmnesiaEvidence) ToProto() *tmproto.AmnesiaEvidence

func (*AmnesiaEvidence) ValidateBasic Uses

func (e *AmnesiaEvidence) ValidateBasic() error

func (*AmnesiaEvidence) ViolatedConsensus Uses

func (e *AmnesiaEvidence) ViolatedConsensus() (bool, string)

ViolatedConsensus assess on the basis of the AmnesiaEvidence whether the validator has violated the Tendermint consensus. Evidence must be validated first (see ValidateBasic). We are only interested in proving that the latter of the votes in terms of time was correctly done.

type Block Uses

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 BlockFromProto Uses

func BlockFromProto(bp *tmproto.Block) (*Block, error)

FromProto sets a protobuf Block to the given pointer. It returns an error if the block is invalid.

func MakeBlock Uses

func MakeBlock(height int64, txs []Tx, lastCommit *Commit, evidence []Evidence) *Block

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 Uses

func (b *Block) Hash() tmbytes.HexBytes

Hash computes and returns the block hash. If the block is incomplete, block hash is nil for safety.

func (*Block) HashesTo Uses

func (b *Block) HashesTo(hash []byte) bool

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 Uses

func (b *Block) MakePartSet(partSize uint32) *PartSet

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) Size Uses

func (b *Block) Size() int

Size returns size of the block in bytes.

func (*Block) String Uses

func (b *Block) String() string

String returns a string representation of the block

See StringIndented.

func (*Block) StringIndented Uses

func (b *Block) StringIndented(indent string) string

StringIndented returns an indented String.

Header Data Evidence LastCommit Hash

func (*Block) StringShort Uses

func (b *Block) StringShort() string

StringShort returns a shortened string representation of the block.

func (*Block) ToProto Uses

func (b *Block) ToProto() (*tmproto.Block, error)

ToProto converts Block to protobuf

func (*Block) ValidateBasic Uses

func (b *Block) ValidateBasic() error

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 Uses

type BlockEventPublisher interface {
    PublishEventNewBlock(block EventDataNewBlock) error
    PublishEventNewBlockHeader(header EventDataNewBlockHeader) error
    PublishEventNewEvidence(evidence EventDataNewEvidence) error
    PublishEventTx(EventDataTx) error
    PublishEventValidatorSetUpdates(EventDataValidatorSetUpdates) error
}

BlockEventPublisher publishes all block related events

type BlockID Uses

type BlockID struct {
    Hash          tmbytes.HexBytes `json:"hash"`
    PartSetHeader PartSetHeader    `json:"parts"`
}

BlockID

func BlockIDFromProto Uses

func BlockIDFromProto(bID *tmproto.BlockID) (*BlockID, error)

FromProto sets a protobuf BlockID to the given pointer. It returns an error if the block id is invalid.

func (BlockID) Equals Uses

func (blockID BlockID) Equals(other BlockID) bool

Equals returns true if the BlockID matches the given BlockID

func (BlockID) IsComplete Uses

func (blockID BlockID) IsComplete() bool

IsComplete returns true if this is a valid BlockID of a non-nil block.

func (BlockID) IsZero Uses

func (blockID BlockID) IsZero() bool

IsZero returns true if this is the BlockID of a nil block.

func (BlockID) Key Uses

func (blockID BlockID) Key() string

Key returns a machine-readable string representation of the BlockID

func (BlockID) String Uses

func (blockID BlockID) String() string

String returns a human readable string representation of the BlockID.

1. hash 2. part set header

See PartSetHeader#String

func (*BlockID) ToProto Uses

func (blockID *BlockID) ToProto() tmproto.BlockID

ToProto converts BlockID to protobuf

func (BlockID) ValidateBasic Uses

func (blockID BlockID) ValidateBasic() error

ValidateBasic performs basic validation.

type BlockIDFlag Uses

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 Uses

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 BlockMetaFromProto Uses

func BlockMetaFromProto(pb *tmproto.BlockMeta) (*BlockMeta, error)

func NewBlockMeta Uses

func NewBlockMeta(block *Block, blockParts *PartSet) *BlockMeta

NewBlockMeta returns a new BlockMeta.

func (*BlockMeta) ToProto Uses

func (bm *BlockMeta) ToProto() *tmproto.BlockMeta

func (*BlockMeta) ValidateBasic Uses

func (bm *BlockMeta) ValidateBasic() error

ValidateBasic performs basic validation.

type Commit Uses

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      int32       `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 Uses

func CommitFromProto(cp *tmproto.Commit) (*Commit, error)

FromProto sets a protobuf Commit to the given pointer. It returns an error if the commit is invalid.

func MakeCommit Uses

func MakeCommit(blockID BlockID, height int64, round int32,
    voteSet *VoteSet, validators []PrivValidator, now time.Time) (*Commit, error)

func NewCommit Uses

func NewCommit(height int64, round int32, blockID BlockID, commitSigs []CommitSig) *Commit

NewCommit returns a new Commit.

func (*Commit) BitArray Uses

func (commit *Commit) BitArray() *bits.BitArray

BitArray returns a BitArray of which validators voted for BlockID or nil in this commit. Implements VoteSetReader.

func (*Commit) GetByIndex Uses

func (commit *Commit) GetByIndex(valIdx int32) *Vote

GetByIndex returns the vote corresponding to a given validator index. Panics if `index >= commit.Size()`. Implements VoteSetReader.

func (*Commit) GetHeight Uses

func (commit *Commit) GetHeight() int64

GetHeight returns height of the commit. Implements VoteSetReader.

func (*Commit) GetRound Uses

func (commit *Commit) GetRound() int32

GetRound returns height of the commit. Implements VoteSetReader.

func (*Commit) GetVote Uses

func (commit *Commit) GetVote(valIdx int32) *Vote

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) Hash Uses

func (commit *Commit) Hash() tmbytes.HexBytes

Hash returns the hash of the commit

func (*Commit) IsCommit Uses

func (commit *Commit) IsCommit() bool

IsCommit returns true if there is at least one signature. Implements VoteSetReader.

func (*Commit) Size Uses

func (commit *Commit) Size() int

Size returns the number of signatures in the commit. Implements VoteSetReader.

func (*Commit) StringIndented Uses

func (commit *Commit) StringIndented(indent string) string

StringIndented returns a string representation of the commit.

func (*Commit) ToProto Uses

func (commit *Commit) ToProto() *tmproto.Commit

ToProto converts Commit to protobuf

func (*Commit) Type Uses

func (commit *Commit) Type() byte

Type returns the vote type of the commit, which is always VoteTypePrecommit Implements VoteSetReader.

func (*Commit) ValidateBasic Uses

func (commit *Commit) ValidateBasic() error

ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.

func (*Commit) VoteSignBytes Uses

func (commit *Commit) VoteSignBytes(chainID string, valIdx int32) []byte

VoteSignBytes returns the bytes of the Vote corresponding to valIdx for signing.

The only unique part is the Timestamp - all other fields signed over are otherwise the same for all validators.

Panics if valIdx >= commit.Size().

See VoteSignBytes

type CommitSig Uses

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 Uses

func NewCommitSigAbsent() CommitSig

NewCommitSigAbsent returns new CommitSig with BlockIDFlagAbsent. Other fields are all empty.

func NewCommitSigForBlock Uses

func NewCommitSigForBlock(signature []byte, valAddr Address, ts time.Time) CommitSig

NewCommitSigForBlock returns new CommitSig with BlockIDFlagCommit.

func (CommitSig) Absent Uses

func (cs CommitSig) Absent() bool

Absent returns true if CommitSig is absent.

func (CommitSig) BlockID Uses

func (cs CommitSig) BlockID(commitBlockID BlockID) BlockID

BlockID returns the Commit's BlockID if CommitSig indicates signing, otherwise - empty BlockID.

func (CommitSig) ForBlock Uses

func (cs CommitSig) ForBlock() bool

ForBlock returns true if CommitSig is for the block.

func (*CommitSig) FromProto Uses

func (cs *CommitSig) FromProto(csp tmproto.CommitSig) error

FromProto sets a protobuf CommitSig to the given pointer. It returns an error if the CommitSig is invalid.

func (CommitSig) String Uses

func (cs CommitSig) String() string

CommitSig returns a string representation of CommitSig.

1. first 6 bytes of signature 2. first 6 bytes of validator address 3. block ID flag 4. timestamp

func (*CommitSig) ToProto Uses

func (cs *CommitSig) ToProto() *tmproto.CommitSig

ToProto converts CommitSig to protobuf

func (CommitSig) ValidateBasic Uses

func (cs CommitSig) ValidateBasic() error

ValidateBasic performs basic validation.

type CompositeEvidence Uses

type CompositeEvidence interface {
    VerifyComposite(committedHeader *Header, valSet *ValidatorSet) error
    Split(committedHeader *Header, valSet *ValidatorSet) []Evidence
}

type ConflictingHeadersEvidence Uses

type ConflictingHeadersEvidence struct {
    H1  *SignedHeader `json:"h_1"`
    H2  *SignedHeader `json:"h_2"`
}

ConflictingHeadersEvidence is primarily used by the light client when it observes two conflicting headers, both having 1/3+ of the voting power of the currently trusted validator set.

func ConflictingHeadersEvidenceFromProto Uses

func ConflictingHeadersEvidenceFromProto(pb *tmproto.ConflictingHeadersEvidence) (*ConflictingHeadersEvidence, error)

func NewConflictingHeadersEvidence Uses

func NewConflictingHeadersEvidence(h1, h2 *SignedHeader) *ConflictingHeadersEvidence

NewConflictingHeadersEvidence creates a new instance of the respective evidence

func (*ConflictingHeadersEvidence) Address Uses

func (ev *ConflictingHeadersEvidence) Address() []byte

func (*ConflictingHeadersEvidence) Bytes Uses

func (ev *ConflictingHeadersEvidence) Bytes() []byte

func (*ConflictingHeadersEvidence) Equal Uses

func (ev *ConflictingHeadersEvidence) Equal(ev2 Evidence) bool

func (*ConflictingHeadersEvidence) Hash Uses

func (ev *ConflictingHeadersEvidence) Hash() []byte

func (*ConflictingHeadersEvidence) Height Uses

func (ev *ConflictingHeadersEvidence) Height() int64

func (*ConflictingHeadersEvidence) Split Uses

func (ev *ConflictingHeadersEvidence) Split(committedHeader *Header, valSet *ValidatorSet) []Evidence

Split breaks up evidence into smaller chunks of evidence: LunaticValidatorEvidence, DuplicateVoteEvidence and PotentialAmnesiaEvidence.

committedHeader - header at height H1.Height == H2.Height valSet - validator set at height H1.Height == H2.Height

func (*ConflictingHeadersEvidence) String Uses

func (ev *ConflictingHeadersEvidence) String() string

func (*ConflictingHeadersEvidence) Time Uses

func (ev *ConflictingHeadersEvidence) Time() time.Time

Time returns time of the latest header.

func (*ConflictingHeadersEvidence) ToProto Uses

func (ev *ConflictingHeadersEvidence) ToProto() *tmproto.ConflictingHeadersEvidence

func (*ConflictingHeadersEvidence) ValidateBasic Uses

func (ev *ConflictingHeadersEvidence) ValidateBasic() error

func (*ConflictingHeadersEvidence) Verify Uses

func (ev *ConflictingHeadersEvidence) Verify(chainID string, _ crypto.PubKey) error

func (*ConflictingHeadersEvidence) VerifyComposite Uses

func (ev *ConflictingHeadersEvidence) VerifyComposite(committedHeader *Header, valSet *ValidatorSet) error

VerifyComposite verifies that both headers belong to the same chain, same height and signed by 1/3+ of validators at height H1.Height == H2.Height.

type Data Uses

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 DataFromProto Uses

func DataFromProto(dp *tmproto.Data) (Data, error)

DataFromProto takes a protobuf representation of Data & returns the native type.

func (*Data) Hash Uses

func (data *Data) Hash() tmbytes.HexBytes

Hash returns the hash of the data

func (*Data) StringIndented Uses

func (data *Data) StringIndented(indent string) string

StringIndented returns an indented string representation of the transactions.

func (*Data) ToProto Uses

func (data *Data) ToProto() tmproto.Data

ToProto converts Data to protobuf

type DuplicateVoteEvidence Uses

type DuplicateVoteEvidence struct {
    VoteA *Vote `json:"vote_a"`
    VoteB *Vote `json:"vote_b"`
}

DuplicateVoteEvidence contains evidence a validator signed two conflicting votes.

func DuplicateVoteEvidenceFromProto Uses

func DuplicateVoteEvidenceFromProto(pb *tmproto.DuplicateVoteEvidence) (*DuplicateVoteEvidence, error)

func NewDuplicateVoteEvidence Uses

func NewDuplicateVoteEvidence(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 NewMockDuplicateVoteEvidence Uses

func NewMockDuplicateVoteEvidence(height int64, time time.Time, chainID string) *DuplicateVoteEvidence

assumes the round to be 0 and the validator index to be 0

func NewMockDuplicateVoteEvidenceWithValidator Uses

func NewMockDuplicateVoteEvidenceWithValidator(height int64, time time.Time,
    pv PrivValidator, chainID string) *DuplicateVoteEvidence

func (*DuplicateVoteEvidence) Address Uses

func (dve *DuplicateVoteEvidence) Address() []byte

Address returns the address of the validator.

func (*DuplicateVoteEvidence) Bytes Uses

func (dve *DuplicateVoteEvidence) Bytes() []byte

Hash returns the hash of the evidence.

func (*DuplicateVoteEvidence) Equal Uses

func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool

Equal checks if two pieces of evidence are equal.

func (*DuplicateVoteEvidence) Hash Uses

func (dve *DuplicateVoteEvidence) Hash() []byte

Hash returns the hash of the evidence.

func (*DuplicateVoteEvidence) Height Uses

func (dve *DuplicateVoteEvidence) Height() int64

Height returns the height this evidence refers to.

func (*DuplicateVoteEvidence) String Uses

func (dve *DuplicateVoteEvidence) String() string

String returns a string representation of the evidence.

func (*DuplicateVoteEvidence) Time Uses

func (dve *DuplicateVoteEvidence) Time() time.Time

Time returns time of the latest vote.

func (*DuplicateVoteEvidence) ToProto Uses

func (dve *DuplicateVoteEvidence) ToProto() *tmproto.DuplicateVoteEvidence

func (*DuplicateVoteEvidence) ValidateBasic Uses

func (dve *DuplicateVoteEvidence) ValidateBasic() error

ValidateBasic performs basic validation.

func (*DuplicateVoteEvidence) Verify Uses

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 Uses

type ErrEvidenceInvalid struct {
    Evidence   Evidence
    ErrorValue error
}

ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid.

func NewErrEvidenceInvalid Uses

func NewErrEvidenceInvalid(ev Evidence, err error) *ErrEvidenceInvalid

NewErrEvidenceInvalid returns a new EvidenceInvalid with the given err.

func (*ErrEvidenceInvalid) Error Uses

func (err *ErrEvidenceInvalid) Error() string

Error returns a string representation of the error.

type ErrEvidenceOverflow Uses

type ErrEvidenceOverflow struct {
    MaxNum int
    GotNum int
}

ErrEvidenceOverflow is for when there is too much evidence in a block.

func NewErrEvidenceOverflow Uses

func NewErrEvidenceOverflow(max, got int) *ErrEvidenceOverflow

NewErrEvidenceOverflow returns a new ErrEvidenceOverflow where got > max.

func (*ErrEvidenceOverflow) Error Uses

func (err *ErrEvidenceOverflow) Error() string

Error returns a string representation of the error.

type ErrInvalidCommitHeight Uses

type ErrInvalidCommitHeight struct {
    Expected int64
    Actual   int64
}

ErrInvalidCommitHeight is returned when we encounter a commit with an unexpected height.

func NewErrInvalidCommitHeight Uses

func NewErrInvalidCommitHeight(expected, actual int64) ErrInvalidCommitHeight

func (ErrInvalidCommitHeight) Error Uses

func (e ErrInvalidCommitHeight) Error() string

type ErrInvalidCommitSignatures Uses

type ErrInvalidCommitSignatures struct {
    Expected int
    Actual   int
}

ErrInvalidCommitSignatures is returned when we encounter a commit where the number of signatures doesn't match the number of validators.

func NewErrInvalidCommitSignatures Uses

func NewErrInvalidCommitSignatures(expected, actual int) ErrInvalidCommitSignatures

func (ErrInvalidCommitSignatures) Error Uses

func (e ErrInvalidCommitSignatures) Error() string

type ErrNotEnoughVotingPowerSigned Uses

type ErrNotEnoughVotingPowerSigned struct {
    Got    int64
    Needed int64
}

ErrNotEnoughVotingPowerSigned is returned when not enough validators signed a commit.

func (ErrNotEnoughVotingPowerSigned) Error Uses

func (e ErrNotEnoughVotingPowerSigned) Error() string

type ErrVoteConflictingVotes Uses

type ErrVoteConflictingVotes struct {
    *DuplicateVoteEvidence
}

func NewConflictingVoteError Uses

func NewConflictingVoteError(val *Validator, vote1, vote2 *Vote) *ErrVoteConflictingVotes

func (*ErrVoteConflictingVotes) Error Uses

func (err *ErrVoteConflictingVotes) Error() string

type ErroringMockPV Uses

type ErroringMockPV struct {
    MockPV
}

func NewErroringMockPV Uses

func NewErroringMockPV() *ErroringMockPV

func (*ErroringMockPV) SignProposal Uses

func (pv *ErroringMockPV) SignProposal(chainID string, proposal *tmproto.Proposal) error

Implements PrivValidator.

func (*ErroringMockPV) SignVote Uses

func (pv *ErroringMockPV) SignVote(chainID string, vote *tmproto.Vote) error

Implements PrivValidator.

type EventBus Uses

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 NewEventBus Uses

func NewEventBus() *EventBus

NewEventBus returns a new event bus.

func NewEventBusWithBufferCapacity Uses

func NewEventBusWithBufferCapacity(cap int) *EventBus

NewEventBusWithBufferCapacity returns a new event bus with the given buffer capacity.

func (*EventBus) NumClientSubscriptions Uses

func (b *EventBus) NumClientSubscriptions(clientID string) int

func (*EventBus) NumClients Uses

func (b *EventBus) NumClients() int

func (*EventBus) OnStart Uses

func (b *EventBus) OnStart() error

func (*EventBus) OnStop Uses

func (b *EventBus) OnStop()

func (*EventBus) Publish Uses

func (b *EventBus) Publish(eventType string, eventData TMEventData) error

func (*EventBus) PublishEventCompleteProposal Uses

func (b *EventBus) PublishEventCompleteProposal(data EventDataCompleteProposal) error

func (*EventBus) PublishEventLock Uses

func (b *EventBus) PublishEventLock(data EventDataRoundState) error

func (*EventBus) PublishEventNewBlock Uses

func (b *EventBus) PublishEventNewBlock(data EventDataNewBlock) error

func (*EventBus) PublishEventNewBlockHeader Uses

func (b *EventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error

func (*EventBus) PublishEventNewEvidence Uses

func (b *EventBus) PublishEventNewEvidence(evidence EventDataNewEvidence) error

func (*EventBus) PublishEventNewRound Uses

func (b *EventBus) PublishEventNewRound(data EventDataNewRound) error

func (*EventBus) PublishEventNewRoundStep Uses

func (b *EventBus) PublishEventNewRoundStep(data EventDataRoundState) error

func (*EventBus) PublishEventPolka Uses

func (b *EventBus) PublishEventPolka(data EventDataRoundState) error

func (*EventBus) PublishEventRelock Uses

func (b *EventBus) PublishEventRelock(data EventDataRoundState) error

func (*EventBus) PublishEventTimeoutPropose Uses

func (b *EventBus) PublishEventTimeoutPropose(data EventDataRoundState) error

func (*EventBus) PublishEventTimeoutWait Uses

func (b *EventBus) PublishEventTimeoutWait(data EventDataRoundState) error

func (*EventBus) PublishEventTx Uses

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) PublishEventUnlock Uses

func (b *EventBus) PublishEventUnlock(data EventDataRoundState) error

func (*EventBus) PublishEventValidBlock Uses

func (b *EventBus) PublishEventValidBlock(data EventDataRoundState) error

func (*EventBus) PublishEventValidatorSetUpdates Uses

func (b *EventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error

func (*EventBus) PublishEventVote Uses

func (b *EventBus) PublishEventVote(data EventDataVote) error

func (*EventBus) SetLogger Uses

func (b *EventBus) SetLogger(l log.Logger)

func (*EventBus) Subscribe Uses

func (b *EventBus) Subscribe(
    ctx context.Context,
    subscriber string,
    query tmpubsub.Query,
    outCapacity ...int,
) (Subscription, error)

func (*EventBus) SubscribeUnbuffered Uses

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 Uses

func (b *EventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error

func (*EventBus) UnsubscribeAll Uses

func (b *EventBus) UnsubscribeAll(ctx context.Context, subscriber string) error

type EventBusSubscriber Uses

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 EventDataCompleteProposal Uses

type EventDataCompleteProposal struct {
    Height int64  `json:"height"`
    Round  int32  `json:"round"`
    Step   string `json:"step"`

    BlockID BlockID `json:"block_id"`
}

type EventDataNewBlock Uses

type EventDataNewBlock struct {
    Block *Block `json:"block"`

    ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"`
    ResultEndBlock   abci.ResponseEndBlock   `json:"result_end_block"`
}

type EventDataNewBlockHeader Uses

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 EventDataNewEvidence Uses

type EventDataNewEvidence struct {
    Evidence Evidence `json:"evidence"`

    Height int64 `json:"height"`
}

type EventDataNewRound Uses

type EventDataNewRound struct {
    Height int64  `json:"height"`
    Round  int32  `json:"round"`
    Step   string `json:"step"`

    Proposer ValidatorInfo `json:"proposer"`
}

type EventDataRoundState Uses

type EventDataRoundState struct {
    Height int64  `json:"height"`
    Round  int32  `json:"round"`
    Step   string `json:"step"`
}

NOTE: This goes into the replay WAL

type EventDataString Uses

type EventDataString string

type EventDataTx Uses

type EventDataTx struct {
    abci.TxResult
}

All txs fire EventDataTx

type EventDataValidatorSetUpdates Uses

type EventDataValidatorSetUpdates struct {
    ValidatorUpdates []*Validator `json:"validator_updates"`
}

type EventDataVote Uses

type EventDataVote struct {
    Vote *Vote
}

type Evidence Uses

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.

func EvidenceFromProto Uses

func EvidenceFromProto(evidence *tmproto.Evidence) (Evidence, error)

type EvidenceData Uses

type EvidenceData struct {
    Evidence EvidenceList `json:"evidence"`
    // contains filtered or unexported fields
}

EvidenceData contains any evidence of malicious wrong-doing by validators

func (*EvidenceData) FromProto Uses

func (data *EvidenceData) FromProto(eviData *tmproto.EvidenceData) error

FromProto sets a protobuf EvidenceData to the given pointer.

func (*EvidenceData) Hash Uses

func (data *EvidenceData) Hash() tmbytes.HexBytes

Hash returns the hash of the data.

func (*EvidenceData) StringIndented Uses

func (data *EvidenceData) StringIndented(indent string) string

StringIndented returns a string representation of the evidence.

func (*EvidenceData) ToProto Uses

func (data *EvidenceData) ToProto() (*tmproto.EvidenceData, error)

ToProto converts EvidenceData to protobuf

type EvidenceList Uses

type EvidenceList []Evidence

EvidenceList is a list of Evidence. Evidences is not a word.

func (EvidenceList) Has Uses

func (evl EvidenceList) Has(evidence Evidence) bool

Has returns true if the evidence is in the EvidenceList.

func (EvidenceList) Hash Uses

func (evl EvidenceList) Hash() []byte

Hash returns the simple merkle root hash of the EvidenceList.

func (EvidenceList) String Uses

func (evl EvidenceList) String() string

type GenesisDoc Uses

type GenesisDoc struct {
    GenesisTime     time.Time                `json:"genesis_time"`
    ChainID         string                   `json:"chain_id"`
    ConsensusParams *tmproto.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 Uses

func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error)

GenesisDocFromFile reads JSON data from a file and unmarshalls it into a GenesisDoc.

func GenesisDocFromJSON Uses

func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error)

GenesisDocFromJSON unmarshalls JSON data into a GenesisDoc.

func (*GenesisDoc) SaveAs Uses

func (genDoc *GenesisDoc) SaveAs(file string) error

SaveAs is a utility method for saving GenensisDoc as a JSON file.

func (*GenesisDoc) ValidateAndComplete Uses

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 Uses

func (genDoc *GenesisDoc) ValidatorHash() []byte

ValidatorHash returns the hash of the validator set contained in the GenesisDoc

type GenesisValidator Uses

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 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 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 Uses

func HeaderFromProto(ph *tmproto.Header) (Header, error)

FromProto sets a protobuf Header to the given pointer. It returns an error if the header is invalid.

func (*Header) Hash Uses

func (h *Header) Hash() tmbytes.HexBytes

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 Uses

func (h *Header) Populate(
    version tmversion.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) StringIndented Uses

func (h *Header) StringIndented(indent string) string

StringIndented returns an indented string representation of the header.

func (*Header) ToProto Uses

func (h *Header) ToProto() *tmproto.Header

ToProto converts Header to protobuf

func (Header) ValidateBasic Uses

func (h Header) ValidateBasic() error

ValidateBasic performs stateless validation on a Header returning an error if any validation fails.

NOTE: Timestamp validation is subtle and handled elsewhere.

type LunaticValidatorEvidence Uses

type LunaticValidatorEvidence struct {
    Header             *Header `json:"header"`
    Vote               *Vote   `json:"vote"`
    InvalidHeaderField string  `json:"invalid_header_field"`
}

func LunaticValidatorEvidenceFromProto Uses

func LunaticValidatorEvidenceFromProto(pb *tmproto.LunaticValidatorEvidence) (*LunaticValidatorEvidence, error)

func NewLunaticValidatorEvidence Uses

func NewLunaticValidatorEvidence(header *Header, vote *Vote, invalidHeaderField string) *LunaticValidatorEvidence

NewLunaticValidatorEvidence creates a new instance of the respective evidence

func (*LunaticValidatorEvidence) Address Uses

func (e *LunaticValidatorEvidence) Address() []byte

func (*LunaticValidatorEvidence) Bytes Uses

func (e *LunaticValidatorEvidence) Bytes() []byte

func (*LunaticValidatorEvidence) Equal Uses

func (e *LunaticValidatorEvidence) Equal(ev Evidence) bool

func (*LunaticValidatorEvidence) Hash Uses

func (e *LunaticValidatorEvidence) Hash() []byte

func (*LunaticValidatorEvidence) Height Uses

func (e *LunaticValidatorEvidence) Height() int64

func (*LunaticValidatorEvidence) String Uses

func (e *LunaticValidatorEvidence) String() string

func (*LunaticValidatorEvidence) Time Uses

func (e *LunaticValidatorEvidence) Time() time.Time

Time returns the maximum between the header's time and vote's time.

func (*LunaticValidatorEvidence) ToProto Uses

func (e *LunaticValidatorEvidence) ToProto() *tmproto.LunaticValidatorEvidence

func (*LunaticValidatorEvidence) ValidateBasic Uses

func (e *LunaticValidatorEvidence) ValidateBasic() error

func (*LunaticValidatorEvidence) Verify Uses

func (e *LunaticValidatorEvidence) Verify(chainID string, pubKey crypto.PubKey) error

func (*LunaticValidatorEvidence) VerifyHeader Uses

func (e *LunaticValidatorEvidence) VerifyHeader(committedHeader *Header) error

type MockPV Uses

type MockPV struct {
    PrivKey crypto.PrivKey
    // contains filtered or unexported fields
}

MockPV implements PrivValidator without any safety or persistence. Only use it for testing.

func NewMockPV Uses

func NewMockPV() MockPV

func NewMockPVWithParams Uses

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) DisableChecks Uses

func (pv MockPV) DisableChecks()

XXX: Implement.

func (MockPV) ExtractIntoValidator Uses

func (pv MockPV) ExtractIntoValidator(votingPower int64) *Validator

func (MockPV) GetPubKey Uses

func (pv MockPV) GetPubKey() (crypto.PubKey, error)

Implements PrivValidator.

func (MockPV) SignProposal Uses

func (pv MockPV) SignProposal(chainID string, proposal *tmproto.Proposal) error

Implements PrivValidator.

func (MockPV) SignVote Uses

func (pv MockPV) SignVote(chainID string, vote *tmproto.Vote) error

Implements PrivValidator.

func (MockPV) String Uses

func (pv MockPV) String() string

String returns a string representation of the MockPV.

type NopEventBus Uses

type NopEventBus struct{}

-----------------------------------------------------------------------------

func (NopEventBus) PublishEventCompleteProposal Uses

func (NopEventBus) PublishEventCompleteProposal(data EventDataRoundState) error

func (NopEventBus) PublishEventLock Uses

func (NopEventBus) PublishEventLock(data EventDataRoundState) error

func (NopEventBus) PublishEventNewBlock Uses

func (NopEventBus) PublishEventNewBlock(data EventDataNewBlock) error

func (NopEventBus) PublishEventNewBlockHeader Uses

func (NopEventBus) PublishEventNewBlockHeader(data EventDataNewBlockHeader) error

func (NopEventBus) PublishEventNewEvidence Uses

func (NopEventBus) PublishEventNewEvidence(evidence EventDataNewEvidence) error

func (NopEventBus) PublishEventNewRound Uses

func (NopEventBus) PublishEventNewRound(data EventDataRoundState) error

func (NopEventBus) PublishEventNewRoundStep Uses

func (NopEventBus) PublishEventNewRoundStep(data EventDataRoundState) error

func (NopEventBus) PublishEventPolka Uses

func (NopEventBus) PublishEventPolka(data EventDataRoundState) error

func (NopEventBus) PublishEventRelock Uses

func (NopEventBus) PublishEventRelock(data EventDataRoundState) error

func (NopEventBus) PublishEventTimeoutPropose Uses

func (NopEventBus) PublishEventTimeoutPropose(data EventDataRoundState) error

func (NopEventBus) PublishEventTimeoutWait Uses

func (NopEventBus) PublishEventTimeoutWait(data EventDataRoundState) error

func (NopEventBus) PublishEventTx Uses

func (NopEventBus) PublishEventTx(data EventDataTx) error

func (NopEventBus) PublishEventUnlock Uses

func (NopEventBus) PublishEventUnlock(data EventDataRoundState) error

func (NopEventBus) PublishEventValidatorSetUpdates Uses

func (NopEventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpdates) error

func (NopEventBus) PublishEventVote Uses

func (NopEventBus) PublishEventVote(data EventDataVote) error

func (NopEventBus) Subscribe Uses

func (NopEventBus) Subscribe(
    ctx context.Context,
    subscriber string,
    query tmpubsub.Query,
    out chan<- interface{},
) error

func (NopEventBus) Unsubscribe Uses

func (NopEventBus) Unsubscribe(ctx context.Context, subscriber string, query tmpubsub.Query) error

func (NopEventBus) UnsubscribeAll Uses

func (NopEventBus) UnsubscribeAll(ctx context.Context, subscriber string) error

type P2PID Uses

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 Uses

type Part struct {
    Index uint32           `json:"index"`
    Bytes tmbytes.HexBytes `json:"bytes"`
    Proof merkle.Proof     `json:"proof"`
}

func PartFromProto Uses

func PartFromProto(pb *tmproto.Part) (*Part, error)

func (*Part) String Uses

func (part *Part) String() string

String returns a string representation of Part.

See StringIndented.

func (*Part) StringIndented Uses

func (part *Part) StringIndented(indent string) string

StringIndented returns an indented Part.

See merkle.Proof#StringIndented

func (*Part) ToProto Uses

func (part *Part) ToProto() (*tmproto.Part, error)

func (*Part) ValidateBasic Uses

func (part *Part) ValidateBasic() error

ValidateBasic performs basic validation.

type PartSet Uses

type PartSet struct {
    // contains filtered or unexported fields
}

func NewPartSetFromData Uses

func NewPartSetFromData(data []byte, partSize uint32) *PartSet

Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed. CONTRACT: partSize is greater than zero.

func NewPartSetFromHeader Uses

func NewPartSetFromHeader(header PartSetHeader) *PartSet

Returns an empty PartSet ready to be populated.

func (*PartSet) AddPart Uses

func (ps *PartSet) AddPart(part *Part) (bool, error)

func (*PartSet) BitArray Uses

func (ps *PartSet) BitArray() *bits.BitArray

func (*PartSet) Count Uses

func (ps *PartSet) Count() uint32

func (*PartSet) GetPart Uses

func (ps *PartSet) GetPart(index int) *Part

func (*PartSet) GetReader Uses

func (ps *PartSet) GetReader() io.Reader

func (*PartSet) HasHeader Uses

func (ps *PartSet) HasHeader(header PartSetHeader) bool

func (*PartSet) Hash Uses

func (ps *PartSet) Hash() []byte

func (*PartSet) HashesTo Uses

func (ps *PartSet) HashesTo(hash []byte) bool

func (*PartSet) Header Uses

func (ps *PartSet) Header() PartSetHeader

func (*PartSet) IsComplete Uses

func (ps *PartSet) IsComplete() bool

func (*PartSet) MarshalJSON Uses

func (ps *PartSet) MarshalJSON() ([]byte, error)

func (*PartSet) StringShort Uses

func (ps *PartSet) StringShort() string

StringShort returns a short version of String.

(Count of Total)

func (*PartSet) Total Uses

func (ps *PartSet) Total() uint32

type PartSetHeader Uses

type PartSetHeader struct {
    Total uint32           `json:"total"`
    Hash  tmbytes.HexBytes `json:"hash"`
}

func PartSetHeaderFromProto Uses

func PartSetHeaderFromProto(ppsh *tmproto.PartSetHeader) (*PartSetHeader, error)

FromProto sets a protobuf PartSetHeader to the given pointer

func (PartSetHeader) Equals Uses

func (psh PartSetHeader) Equals(other PartSetHeader) bool

func (PartSetHeader) IsZero Uses

func (psh PartSetHeader) IsZero() bool

func (PartSetHeader) String Uses

func (psh PartSetHeader) String() string

String returns a string representation of PartSetHeader.

1. total number of parts 2. first 6 bytes of the hash

func (*PartSetHeader) ToProto Uses

func (psh *PartSetHeader) ToProto() tmproto.PartSetHeader

ToProto converts BloPartSetHeaderckID to protobuf

func (PartSetHeader) ValidateBasic Uses

func (psh PartSetHeader) ValidateBasic() error

ValidateBasic performs basic validation.

type PartSetReader Uses

type PartSetReader struct {
    // contains filtered or unexported fields
}

func NewPartSetReader Uses

func NewPartSetReader(parts []*Part) *PartSetReader

func (*PartSetReader) Read Uses

func (psr *PartSetReader) Read(p []byte) (n int, err error)

type PotentialAmnesiaEvidence Uses

type PotentialAmnesiaEvidence struct {
    VoteA *Vote `json:"vote_a"`
    VoteB *Vote `json:"vote_b"`

    HeightStamp int64
}

PotentialAmnesiaEvidence is constructed when a validator votes on two different blocks at different rounds in the same height. PotentialAmnesiaEvidence can then evolve into AmnesiaEvidence if the indicted validator is incapable of providing the proof of lock change that validates voting twice in the allotted trial period. Heightstamp is used for each node to keep a track of how much time has passed so as to know when the trial period is finished and is set when the node first receives the evidence. Votes are ordered based on their timestamp

func NewPotentialAmnesiaEvidence Uses

func NewPotentialAmnesiaEvidence(voteA *Vote, voteB *Vote) *PotentialAmnesiaEvidence

NewPotentialAmnesiaEvidence creates a new instance of the evidence and orders the votes correctly

func PotentialAmnesiaEvidenceFromProto Uses

func PotentialAmnesiaEvidenceFromProto(pb *tmproto.PotentialAmnesiaEvidence) (*PotentialAmnesiaEvidence, error)

func (*PotentialAmnesiaEvidence) Address Uses

func (e *PotentialAmnesiaEvidence) Address() []byte

func (*PotentialAmnesiaEvidence) Bytes Uses

func (e *PotentialAmnesiaEvidence) Bytes() []byte

func (*PotentialAmnesiaEvidence) Equal Uses

func (e *PotentialAmnesiaEvidence) Equal(ev Evidence) bool

func (*PotentialAmnesiaEvidence) Hash Uses

func (e *PotentialAmnesiaEvidence) Hash() []byte

NOTE: Heightstamp must not be included in hash

func (*PotentialAmnesiaEvidence) Height Uses

func (e *PotentialAmnesiaEvidence) Height() int64

func (*PotentialAmnesiaEvidence) Primed Uses

func (e *PotentialAmnesiaEvidence) Primed(trialPeriod, currentHeight int64) bool

Primed finds whether the PotentialAmnesiaEvidence is ready to be upgraded to Amnesia Evidence. It is decided if either the prosecuted node voted in the past or if the allocated trial period has expired without a proof of lock change having been provided.

func (*PotentialAmnesiaEvidence) String Uses

func (e *PotentialAmnesiaEvidence) String() string

func (*PotentialAmnesiaEvidence) Time Uses

func (e *PotentialAmnesiaEvidence) Time() time.Time

func (*PotentialAmnesiaEvidence) ToProto Uses

func (e *PotentialAmnesiaEvidence) ToProto() *tmproto.PotentialAmnesiaEvidence

func (*PotentialAmnesiaEvidence) ValidateBasic Uses

func (e *PotentialAmnesiaEvidence) ValidateBasic() error

func (*PotentialAmnesiaEvidence) Verify Uses

func (e *PotentialAmnesiaEvidence) Verify(chainID string, pubKey crypto.PubKey) error

type PrivValidator Uses

type PrivValidator interface {
    GetPubKey() (crypto.PubKey, error)

    SignVote(chainID string, vote *tmproto.Vote) error
    SignProposal(chainID string, proposal *tmproto.Proposal) error
}

PrivValidator defines the functionality of a local Tendermint validator that signs votes and proposals, and never double signs.

type PrivValidatorsByAddress Uses

type PrivValidatorsByAddress []PrivValidator

func (PrivValidatorsByAddress) Len Uses

func (pvs PrivValidatorsByAddress) Len() int

func (PrivValidatorsByAddress) Less Uses

func (pvs PrivValidatorsByAddress) Less(i, j int) bool

func (PrivValidatorsByAddress) Swap Uses

func (pvs PrivValidatorsByAddress) Swap(i, j int)

type ProofOfLockChange Uses

type ProofOfLockChange struct {
    Votes  []*Vote       `json:"votes"`
    PubKey crypto.PubKey `json:"pubkey"`
}

ProofOfLockChange (POLC) proves that a node followed the consensus protocol and voted for a precommit in two different rounds because the node received a majority of votes for a different block in the latter round. In cases of amnesia evidence, a suspected node will need ProofOfLockChange to prove that the node did not break protocol.

func NewEmptyPOLC Uses

func NewEmptyPOLC() *ProofOfLockChange

EmptyPOLC returns an empty polc. This is used when no polc has been provided in the allocated trial period time and the node now needs to move to upgrading to AmnesiaEvidence and hence uses an empty polc

func NewMockPOLC Uses

func NewMockPOLC(height int64, time time.Time, pubKey crypto.PubKey) ProofOfLockChange

mock polc - fails validate basic, not stable

func NewPOLC Uses

func NewPOLC(votes []*Vote, pubKey crypto.PubKey) *ProofOfLockChange

NewPOLC creates a POLC

func NewPOLCFromVoteSet Uses

func NewPOLCFromVoteSet(voteSet *VoteSet, pubKey crypto.PubKey, blockID BlockID) (*ProofOfLockChange, error)

MakePOLCFromVoteSet can be used when a majority of prevotes or precommits for a block is seen that the node has itself not yet voted for in order to process the vote set into a proof of lock change

func ProofOfLockChangeFromProto Uses

func ProofOfLockChangeFromProto(pb *tmproto.ProofOfLockChange) (*ProofOfLockChange, error)

func (*ProofOfLockChange) Address Uses

func (e *ProofOfLockChange) Address() []byte

func (*ProofOfLockChange) BlockID Uses

func (e *ProofOfLockChange) BlockID() BlockID

func (*ProofOfLockChange) Equal Uses

func (e *ProofOfLockChange) Equal(e2 *ProofOfLockChange) bool

func (*ProofOfLockChange) Height Uses

func (e *ProofOfLockChange) Height() int64

func (*ProofOfLockChange) IsAbsent Uses

func (e *ProofOfLockChange) IsAbsent() bool

IsAbsent checks if the polc is empty

func (*ProofOfLockChange) Round Uses

func (e *ProofOfLockChange) Round() int32

func (*ProofOfLockChange) String Uses

func (e *ProofOfLockChange) String() string

func (*ProofOfLockChange) Time Uses

func (e *ProofOfLockChange) Time() time.Time

Time returns time of the latest vote.

func (*ProofOfLockChange) ToProto Uses

func (e *ProofOfLockChange) ToProto() (*tmproto.ProofOfLockChange, error)

func (*ProofOfLockChange) ValidateBasic Uses

func (e *ProofOfLockChange) ValidateBasic() error

func (*ProofOfLockChange) ValidateVotes Uses

func (e *ProofOfLockChange) ValidateVotes(valSet *ValidatorSet, chainID string) error

ValidateVotes checks the polc against the validator set of that height. The function makes sure that the polc contains a majority of votes and that each

type Proposal Uses

type Proposal struct {
    Type      tmproto.SignedMsgType
    Height    int64     `json:"height"`
    Round     int32     `json:"round"`     // there can not be greater than 2_147_483_647 rounds
    POLRound  int32     `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 Uses

func NewProposal(height int64, round int32, polRound int32, blockID BlockID) *Proposal

NewProposal returns a new Proposal. If there is no POLRound, polRound should be -1.

func ProposalFromProto Uses

func ProposalFromProto(pp *tmproto.Proposal) (*Proposal, error)

FromProto sets a protobuf Proposal to the given pointer. It returns an error if the proposal is invalid.

func (*Proposal) String Uses

func (p *Proposal) String() string

String returns a string representation of the Proposal.

1. height 2. round 3. block ID 4. POL round 5. first 6 bytes of signature 6. timestamp

See BlockID#String.

func (*Proposal) ToProto Uses

func (p *Proposal) ToProto() *tmproto.Proposal

ToProto converts Proposal to protobuf

func (*Proposal) ValidateBasic Uses

func (p *Proposal) ValidateBasic() error

ValidateBasic performs basic validation.

type Signable Uses

type Signable interface {
    SignBytes(chainID string) []byte
}

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 Uses

type SignedHeader struct {
    *Header `json:"header"`

    Commit *Commit `json:"commit"`
}

SignedHeader is a header along with the commits that prove it. It is the basis of the light client.

func SignedHeaderFromProto Uses

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 Uses

func (sh SignedHeader) String() string

String returns a string representation of SignedHeader.

func (SignedHeader) StringIndented Uses

func (sh SignedHeader) StringIndented(indent string) string

StringIndented returns an indented string representation of SignedHeader.

Header Commit

func (*SignedHeader) ToProto Uses

func (sh *SignedHeader) ToProto() *tmproto.SignedHeader

ToProto converts SignedHeader to protobuf

func (SignedHeader) ValidateBasic Uses

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 Subscription Uses

type Subscription interface {
    Out() <-chan tmpubsub.Message
    Cancelled() <-chan struct{}
    Err() error
}

type TMEventData Uses

type TMEventData interface {
}

TMEventData implements events.EventData.

type Tx Uses

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 ?

func (Tx) Hash Uses

func (tx Tx) Hash() []byte

Hash computes the TMHASH hash of the wire encoded transaction.

func (Tx) String Uses

func (tx Tx) String() string

String returns the hex-encoded transaction as a string.

type TxEventPublisher Uses

type TxEventPublisher interface {
    PublishEventTx(EventDataTx) error
}

type TxProof Uses

type TxProof struct {
    RootHash tmbytes.HexBytes `json:"root_hash"`
    Data     Tx               `json:"data"`
    Proof    merkle.Proof     `json:"proof"`
}

TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.

func TxProofFromProto Uses

func TxProofFromProto(pb tmproto.TxProof) (TxProof, error)

func (TxProof) Leaf Uses

func (tp TxProof) Leaf() []byte

Leaf returns the hash(tx), which is the leaf in the merkle tree which this proof refers to.

func (TxProof) ToProto Uses

func (tp TxProof) ToProto() tmproto.TxProof

func (TxProof) Validate Uses

func (tp TxProof) Validate(dataHash []byte) error

Validate verifies the proof. It returns nil if the RootHash matches the dataHash argument, and if the proof is internally consistent. Otherwise, it returns a sensible error.

type Txs Uses

type Txs []Tx

Txs is a slice of Tx.

func (Txs) Hash Uses

func (txs Txs) Hash() []byte

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) Index Uses

func (txs Txs) Index(tx Tx) int

Index returns the index of this transaction in the list, or -1 if not found

func (Txs) IndexByHash Uses

func (txs Txs) IndexByHash(hash []byte) int

IndexByHash returns the index of this transaction hash in the list, or -1 if not found

func (Txs) Proof Uses

func (txs Txs) Proof(i int) TxProof

Proof returns a simple merkle proof for this node. Panics if i < 0 or i >= len(txs) TODO: optimize this!

type Validator Uses

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 NewValidator Uses

func NewValidator(pubKey crypto.PubKey, votingPower int64) *Validator

NewValidator returns a new validator with the given pubkey and voting power.

func ValidatorFromProto Uses

func ValidatorFromProto(vp *tmproto.Validator) (*Validator, error)

FromProto sets a protobuf Validator to the given pointer. It returns an error if the public key is invalid.

func (*Validator) Bytes Uses

func (v *Validator) Bytes() []byte

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 Uses

func (v *Validator) CompareProposerPriority(other *Validator) *Validator

Returns the one with higher ProposerPriority.

func (*Validator) Copy Uses

func (v *Validator) Copy() *Validator

Creates a new copy of the validator so we can mutate ProposerPriority. Panics if the validator is nil.

func (*Validator) String Uses

func (v *Validator) String() string

String returns a string representation of String.

1. address 2. public key 3. voting power 4. proposer priority

func (*Validator) ToProto Uses

func (v *Validator) ToProto() (*tmproto.Validator, error)

ToProto converts Valiator to protobuf

func (*Validator) ValidateBasic Uses

func (v *Validator) ValidateBasic() error

ValidateBasic performs basic validation.

type ValidatorInfo Uses

type ValidatorInfo struct {
    Address Address `json:"address"`
    Index   int32   `json:"index"`
}

type ValidatorSet Uses

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 .VotingPower, so the indices are fixed for all rounds of a given blockchain height - ie. the validators are sorted by their voting power (descending). Secondary index - .Address (ascending).

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 Uses

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 Uses

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 Uses

func (vals *ValidatorSet) Copy() *ValidatorSet

Copy each validator into a new ValidatorSet.

func (*ValidatorSet) CopyIncrementProposerPriority Uses

func (vals *ValidatorSet) CopyIncrementProposerPriority(times int32) *ValidatorSet

CopyIncrementProposerPriority increments ProposerPriority and updates the proposer on a copy, and returns it.

func (*ValidatorSet) GetByAddress Uses

func (vals *ValidatorSet) GetByAddress(address []byte) (index int32, val *Validator)

GetByAddress returns an index of the validator with address and validator itself (copy) if found. Otherwise, -1 and nil are returned.

func (*ValidatorSet) GetByIndex Uses

func (vals *ValidatorSet) GetByIndex(index int32) (address []byte, val *Validator)

GetByIndex returns the validator's address and validator itself (copy) by index. It returns nil values if index is less than 0 or greater or equal to len(ValidatorSet.Validators).

func (*ValidatorSet) GetProposer Uses

func (vals *ValidatorSet) GetProposer() (proposer *Validator)

GetProposer returns the current proposer. If the validator set is empty, nil is returned.

func (*ValidatorSet) HasAddress Uses

func (vals *ValidatorSet) HasAddress(address []byte) bool

HasAddress returns true if address given is in the validator set, false - otherwise.

func (*ValidatorSet) Hash Uses

func (vals *ValidatorSet) Hash() []byte

Hash returns the Merkle root hash build using validators (as leaves) in the set.

func (*ValidatorSet) IncrementProposerPriority Uses

func (vals *ValidatorSet) IncrementProposerPriority(times int32)

IncrementProposerPriority increments ProposerPriority of each validator and updates the proposer. Panics if validator set is empty. `times` must be positive.

func (*ValidatorSet) IsNilOrEmpty Uses

func (vals *ValidatorSet) IsNilOrEmpty() bool

IsNilOrEmpty returns true if validator set is nil or empty.

func (*ValidatorSet) Iterate Uses

func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)

Iterate will run the given function over the set.

func (*ValidatorSet) RescalePriorities Uses

func (vals *ValidatorSet) RescalePriorities(diffMax int64)

RescalePriorities rescales the priorities such that the distance between the maximum and minimum is smaller than `diffMax`. Panics if validator set is empty.

func (*ValidatorSet) Size Uses

func (vals *ValidatorSet) Size() int

Size returns the length of the validator set.

func (*ValidatorSet) String Uses

func (vals *ValidatorSet) String() string

String returns a string representation of ValidatorSet.

See StringIndented.

func (*ValidatorSet) StringIndented Uses

func (vals *ValidatorSet) StringIndented(indent string) string

StringIndented returns an intended String.

See Validator#String.

func (*ValidatorSet) ToProto Uses

func (vals *ValidatorSet) ToProto() (*tmproto.ValidatorSet, error)

ToProto converts ValidatorSet to protobuf

func (*ValidatorSet) TotalVotingPower Uses

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 Uses

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) ValidateBasic Uses

func (vals *ValidatorSet) ValidateBasic() error

func (*ValidatorSet) VerifyCommit Uses

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 Uses

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 Uses

func (vals *ValidatorSet) VerifyCommitLightTrusting(chainID string, commit *Commit, trustLevel tmmath.Fraction) error

VerifyCommitLightTrusting verifies that trustLevel of the validator set signed this commit.

NOTE the given validators do not necessarily correspond to the validator set for this commit, but there may be some intersection.

This method is primarily used by the light client and does not check all the signatures.

type ValidatorsByAddress Uses

type ValidatorsByAddress []*Validator

ValidatorsByAddress implements sort.Interface for []*Validator based on the Address field.

func (ValidatorsByAddress) Len Uses

func (valz ValidatorsByAddress) Len() int

func (ValidatorsByAddress) Less Uses

func (valz ValidatorsByAddress) Less(i, j int) bool

func (ValidatorsByAddress) Swap Uses

func (valz ValidatorsByAddress) Swap(i, j int)

type ValidatorsByVotingPower Uses

type ValidatorsByVotingPower []*Validator

ValidatorsByVotingPower implements sort.Interface for []*Validator based on the VotingPower and Address fields.

func (ValidatorsByVotingPower) Len Uses

func (valz ValidatorsByVotingPower) Len() int

func (ValidatorsByVotingPower) Less Uses

func (valz ValidatorsByVotingPower) Less(i, j int) bool

func (ValidatorsByVotingPower) Swap Uses

func (valz ValidatorsByVotingPower) Swap(i, j int)

type Vote Uses

type Vote struct {
    Type             tmproto.SignedMsgType `json:"type"`
    Height           int64                 `json:"height"`
    Round            int32                 `json:"round"`    // assume there will not be greater than 2_147_483_647 rounds
    BlockID          BlockID               `json:"block_id"` // zero if vote is nil.
    Timestamp        time.Time             `json:"timestamp"`
    ValidatorAddress Address               `json:"validator_address"`
    ValidatorIndex   int32                 `json:"validator_index"`
    Signature        []byte                `json:"signature"`
}

Vote represents a prevote, precommit, or commit vote from validators for consensus.

func MakeVote Uses

func MakeVote(
    height int64,
    blockID BlockID,
    valSet *ValidatorSet,
    privVal PrivValidator,
    chainID string,
    now time.Time,
) (*Vote, error)

func VoteFromProto Uses

func VoteFromProto(pv *tmproto.Vote) (*Vote, error)

FromProto converts a proto generetad type to a handwritten type return type, nil if everything converts safely, otherwise nil, error

func (*Vote) CommitSig Uses

func (vote *Vote) CommitSig() CommitSig

CommitSig converts the Vote to a CommitSig.

func (*Vote) Copy Uses

func (vote *Vote) Copy() *Vote

func (*Vote) String Uses

func (vote *Vote) String() string

String returns a string representation of Vote.

1. validator index 2. first 6 bytes of validator address 3. height 4. round, 5. type byte 6. type string 7. first 6 bytes of block hash 8. first 6 bytes of signature 9. timestamp

func (*Vote) ToProto Uses

func (vote *Vote) ToProto() *tmproto.Vote

ToProto converts the handwritten type to proto generated type return type, nil if everything converts safely, otherwise nil, error

func (*Vote) ValidateBasic Uses

func (vote *Vote) ValidateBasic() error

ValidateBasic performs basic validation.

func (*Vote) Verify Uses

func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error

type VoteSet Uses

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 Uses

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 Uses

func NewVoteSet(chainID string, height int64, round int32,
    signedMsgType tmproto.SignedMsgType, valSet *ValidatorSet) *VoteSet

Constructs a new VoteSet struct used to accumulate votes for given height/round.

func (*VoteSet) AddVote Uses

func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)

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) BitArray Uses

func (voteSet *VoteSet) BitArray() *bits.BitArray

Implements VoteSetReader.

func (*VoteSet) BitArrayByBlockID Uses

func (voteSet *VoteSet) BitArrayByBlockID(blockID BlockID) *bits.BitArray

func (*VoteSet) BitArrayString Uses

func (voteSet *VoteSet) BitArrayString() string

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) ChainID Uses

func (voteSet *VoteSet) ChainID() string

func (*VoteSet) GetByAddress Uses

func (voteSet *VoteSet) GetByAddress(address []byte) *Vote

func (*VoteSet) GetByIndex Uses

func (voteSet *VoteSet) GetByIndex(valIndex int32) *Vote

NOTE: if validator has conflicting votes, returns "canonical" vote Implements VoteSetReader.

func (*VoteSet) GetHeight Uses

func (voteSet *VoteSet) GetHeight() int64

Implements VoteSetReader.

func (*VoteSet) GetRound Uses

func (voteSet *VoteSet) GetRound() int32

Implements VoteSetReader.

func (*VoteSet) HasAll Uses

func (voteSet *VoteSet) HasAll() bool

func (*VoteSet) HasTwoThirdsAny Uses

func (voteSet *VoteSet) HasTwoThirdsAny() bool

func (*VoteSet) HasTwoThirdsMajority Uses

func (voteSet *VoteSet) HasTwoThirdsMajority() bool

func (*VoteSet) IsCommit Uses

func (voteSet *VoteSet) IsCommit() bool

Implements VoteSetReader.

func (*VoteSet) MakeCommit Uses

func (voteSet *VoteSet) MakeCommit() *Commit

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 Uses

func (voteSet *VoteSet) MarshalJSON() ([]byte, error)

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 Uses

func (voteSet *VoteSet) SetPeerMaj23(peerID P2PID, blockID BlockID) error

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) Size Uses

func (voteSet *VoteSet) Size() int

Implements VoteSetReader.

func (*VoteSet) String Uses

func (voteSet *VoteSet) String() string

String returns a string representation of VoteSet.

See StringIndented.

func (*VoteSet) StringIndented Uses

func (voteSet *VoteSet) StringIndented(indent string) string

StringIndented returns an indented String.

Height Round Type Votes Votes bit array 2/3+ majority

See Vote#String.

func (*VoteSet) StringShort Uses

func (voteSet *VoteSet) StringShort() string

StringShort returns a short representation of VoteSet.

1. height 2. round 3. signed msg type 4. first 2/3+ majority 5. fraction of voted power 6. votes bit array 7. 2/3+ majority for each peer

func (*VoteSet) TwoThirdsMajority Uses

func (voteSet *VoteSet) TwoThirdsMajority() (blockID BlockID, ok bool)

If there was a +2/3 majority for blockID, return blockID and true. Else, return the empty BlockID{} and false.

func (*VoteSet) Type Uses

func (voteSet *VoteSet) Type() byte

Implements VoteSetReader.

func (*VoteSet) VoteStrings Uses

func (voteSet *VoteSet) VoteStrings() []string

Returns a list of votes compressed to more readable strings.

type VoteSetJSON Uses

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)

type VoteSetReader Uses

type VoteSetReader interface {
    GetHeight() int64
    GetRound() int32
    Type() byte
    Size() int
    BitArray() *bits.BitArray
    GetByIndex(int32) *Vote
    IsCommit() bool
}

Common interface between *consensus.VoteSet and types.Commit

Directories

PathSynopsis
time

Package types imports 36 packages (graph) and is imported by 631 packages. Updated 2020-08-04. Refresh now. Tools for package owners.