Documentation ¶
Index ¶
- Constants
- Variables
- func CanonicalTime(t time.Time) string
- func DefaultBlockParams() *abci.BlockParams
- func DefaultConsensusParams() abci.ConsensusParams
- func DefaultValidatorParams() *abci.ValidatorParams
- func IsBlockIDReprEmpty(goor BlockID) (empty bool)
- func IsBlockReprEmpty(goor Block) (empty bool)
- func IsCommitReprEmpty(goor Commit) (empty bool)
- func IsCommitSigReprEmpty(goor CommitSig) (empty bool)
- func IsDataReprEmpty(goor Data) (empty bool)
- func IsDuplicateVoteEvidenceReprEmpty(goor DuplicateVoteEvidence) (empty bool)
- func IsErrTooMuchChange(err error) bool
- func IsEventNewBlockHeaderReprEmpty(goor EventNewBlockHeader) (empty bool)
- func IsEventNewBlockReprEmpty(goor EventNewBlock) (empty bool)
- func IsEventStringReprEmpty(goor EventString) (empty bool)
- func IsEventTxReprEmpty(goor EventTx) (empty bool)
- func IsEventValidatorSetUpdatesReprEmpty(goor EventValidatorSetUpdates) (empty bool)
- func IsEventVoteReprEmpty(goor EventVote) (empty bool)
- func IsHeaderReprEmpty(goor Header) (empty bool)
- func IsMockBadEvidenceReprEmpty(goor MockBadEvidence) (empty bool)
- func IsMockGoodEvidenceReprEmpty(goor MockGoodEvidence) (empty bool)
- func IsMockRandomGoodEvidenceReprEmpty(goor MockRandomGoodEvidence) (empty bool)
- func IsPartSetHeaderReprEmpty(goor PartSetHeader) (empty bool)
- func IsTxResultReprEmpty(goor TxResult) (empty bool)
- func IsValidatorReprEmpty(goor Validator) (empty bool)
- func IsVoteReprEmpty(goor Vote) (empty bool)
- func IsVoteTypeValid(t SignedMsgType) bool
- func MaxEvidencePerBlock(blockMaxBytes int64) (int64, int64)
- func NewErroringMockPV() *erroringMockPV
- func RandValidator(randPower bool, minPower int64) (*Validator, PrivValidator)
- func RandValidatorSet(numValidators int, votingPower int64) (*ValidatorSet, []PrivValidator)
- func ValidateConsensusParams(params abci.ConsensusParams) error
- func ValidateHash(h []byte) error
- func ValidateTime(t time.Time) error
- type ABCIResult
- type ABCIResults
- type Address
- type Block
- func (goo Block) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *Block) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ Block) GetTypeURL() (typeURL string)
- func (b *Block) Hash() []byte
- 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 (goo Block) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (b *Block) ValidateBasic() error
- type BlockID
- func (goo BlockID) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (blockID BlockID) Equals(other BlockID) bool
- func (goo *BlockID) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ BlockID) GetTypeURL() (typeURL string)
- func (blockID BlockID) IsComplete() bool
- func (blockID BlockID) IsZero() bool
- func (blockID BlockID) Key() string
- func (blockID BlockID) String() string
- func (goo BlockID) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (blockID BlockID) ValidateBasic() error
- type BlockMeta
- type CanonicalBlockID
- type CanonicalPartSetHeader
- type CanonicalProposal
- type CanonicalVote
- type Commit
- func (commit *Commit) BitArray() *cmn.BitArray
- func (goo Commit) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *Commit) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (commit *Commit) GetByIndex(valIdx int) *Vote
- func (_ Commit) GetTypeURL() (typeURL string)
- func (commit *Commit) GetVote(valIdx int) *Vote
- func (commit *Commit) Hash() []byte
- 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 (goo Commit) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (commit *Commit) Type() byte
- func (commit *Commit) ValidateBasic() error
- func (commit *Commit) VoteSignBytes(chainID string, valIdx int) []byte
- type CommitSig
- func (goo CommitSig) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *CommitSig) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ CommitSig) GetTypeURL() (typeURL string)
- func (cs *CommitSig) String() string
- func (goo CommitSig) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type Data
- func (goo Data) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *Data) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ Data) GetTypeURL() (typeURL string)
- func (data *Data) Hash() []byte
- func (data *Data) StringIndented(indent string) string
- func (goo Data) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type DuplicateVoteEvidence
- func (dve *DuplicateVoteEvidence) AssertABCIEvidence()
- func (dve *DuplicateVoteEvidence) Bytes() []byte
- func (goo DuplicateVoteEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool
- func (goo *DuplicateVoteEvidence) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ DuplicateVoteEvidence) GetTypeURL() (typeURL string)
- func (dve *DuplicateVoteEvidence) Hash() []byte
- func (dve *DuplicateVoteEvidence) String() string
- func (goo DuplicateVoteEvidence) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (dve *DuplicateVoteEvidence) ValidateBasic() error
- func (dve *DuplicateVoteEvidence) Verify(chainID string, pubKey crypto.PubKey) error
- type ErrEvidenceInvalid
- type ErrEvidenceOverflow
- type ErrInvalidCommitHeight
- type ErrInvalidCommitPrecommits
- type ErrVoteConflictingVotes
- type EventNewBlock
- func (_ EventNewBlock) AssertEvent()
- func (goo EventNewBlock) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *EventNewBlock) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ EventNewBlock) GetTypeURL() (typeURL string)
- func (goo EventNewBlock) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type EventNewBlockHeader
- func (_ EventNewBlockHeader) AssertEvent()
- func (goo EventNewBlockHeader) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *EventNewBlockHeader) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ EventNewBlockHeader) GetTypeURL() (typeURL string)
- func (goo EventNewBlockHeader) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type EventString
- func (_ EventString) AssertEvent()
- func (goo EventString) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *EventString) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ EventString) GetTypeURL() (typeURL string)
- func (goo EventString) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type EventTx
- func (_ EventTx) AssertEvent()
- func (goo EventTx) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *EventTx) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ EventTx) GetTypeURL() (typeURL string)
- func (goo EventTx) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type EventValidatorSetUpdates
- func (_ EventValidatorSetUpdates) AssertEvent()
- func (goo EventValidatorSetUpdates) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *EventValidatorSetUpdates) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ EventValidatorSetUpdates) GetTypeURL() (typeURL string)
- func (goo EventValidatorSetUpdates) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type EventVote
- func (_ EventVote) AssertEvent()
- func (goo EventVote) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *EventVote) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ EventVote) GetTypeURL() (typeURL string)
- func (goo EventVote) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type Evidence
- type EvidenceList
- type GenesisDoc
- type GenesisValidator
- type Header
- func (h *Header) AssertABCIHeader()
- func (h *Header) Copy() *Header
- func (goo Header) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *Header) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ Header) GetTypeURL() (typeURL string)
- func (h *Header) Hash() []byte
- func (h *Header) Populate(chainID string, timestamp time.Time, lastBlockID BlockID, totalTxs int64, ...)
- func (h *Header) StringIndented(indent string) string
- func (goo Header) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type MockBadEvidence
- func (e MockBadEvidence) AssertABCIEvidence()
- func (goo MockBadEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (e MockBadEvidence) Equal(ev Evidence) bool
- func (goo *MockBadEvidence) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ MockBadEvidence) GetTypeURL() (typeURL string)
- func (e MockBadEvidence) String() string
- func (goo MockBadEvidence) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (e MockBadEvidence) ValidateBasic() error
- func (e MockBadEvidence) Verify(chainID string, pubKey crypto.PubKey) error
- type MockGoodEvidence
- func (e MockGoodEvidence) AssertABCIEvidence()
- func (e MockGoodEvidence) Bytes() []byte
- func (goo MockGoodEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (e MockGoodEvidence) Equal(ev Evidence) bool
- func (goo *MockGoodEvidence) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ MockGoodEvidence) GetTypeURL() (typeURL string)
- func (e MockGoodEvidence) Hash() []byte
- func (e MockGoodEvidence) String() string
- func (goo MockGoodEvidence) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (e MockGoodEvidence) ValidateBasic() error
- func (e MockGoodEvidence) Verify(chainID string, pubKey crypto.PubKey) error
- type MockPV
- type MockRandomGoodEvidence
- func (e MockRandomGoodEvidence) AssertABCIEvidence()
- func (goo MockRandomGoodEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *MockRandomGoodEvidence) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ MockRandomGoodEvidence) GetTypeURL() (typeURL string)
- func (e MockRandomGoodEvidence) Hash() []byte
- func (goo MockRandomGoodEvidence) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err 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
- func (goo PartSetHeader) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (psh PartSetHeader) Equals(other PartSetHeader) bool
- func (goo *PartSetHeader) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ PartSetHeader) GetTypeURL() (typeURL string)
- func (psh PartSetHeader) IsZero() bool
- func (psh PartSetHeader) String() string
- func (goo PartSetHeader) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (psh PartSetHeader) ValidateBasic() error
- type PartSetReader
- type PrivValidator
- type PrivValidatorsByAddress
- type Proposal
- type Signable
- type SignedHeader
- type SignedMsgType
- type TMEvent
- type Tx
- type TxProof
- type TxResult
- type Txs
- type Validator
- func (v *Validator) ABCIValidatorUpdate() abci.ValidatorUpdate
- func (v *Validator) Bytes() []byte
- func (v *Validator) CompareProposerPriority(other *Validator) *Validator
- func (v *Validator) Copy() *Validator
- func (goo Validator) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *Validator) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ Validator) GetTypeURL() (typeURL string)
- func (v *Validator) String() string
- func (goo Validator) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- type ValidatorSet
- func (vals *ValidatorSet) ABCIValidatorUpdates() (updates []abci.ValidatorUpdate)
- func (vals *ValidatorSet) Copy() *ValidatorSet
- func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet
- func (vals *ValidatorSet) GetByAddress(address crypto.Address) (index int, val *Validator)
- func (vals *ValidatorSet) GetByIndex(index int) (address crypto.Address, val *Validator)
- func (vals *ValidatorSet) GetProposer() (proposer *Validator)
- func (vals *ValidatorSet) HasAddress(address crypto.Address) bool
- func (vals *ValidatorSet) Hash() []byte
- func (vals *ValidatorSet) IncrementProposerPriority(times int)
- func (vals *ValidatorSet) IsNilOrEmpty() bool
- func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)
- func (vals *ValidatorSet) RescalePriorities(diffMax int64)
- func (vals *ValidatorSet) Size() int
- func (vals *ValidatorSet) String() string
- func (vals *ValidatorSet) StringIndented(indent string) string
- func (vals *ValidatorSet) TotalVotingPower() int64
- func (vals *ValidatorSet) UpdateWithABCIValidatorUpdates(updates []abci.ValidatorUpdate) error
- func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error
- 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
- func (vote *Vote) CommitSig() *CommitSig
- func (vote *Vote) Copy() *Vote
- func (goo Vote) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
- func (goo *Vote) FromPBMessage(cdc *amino.Codec, msg proto.Message) (err error)
- func (_ Vote) GetTypeURL() (typeURL string)
- func (vote *Vote) SignBytes(chainID string) []byte
- func (vote *Vote) String() string
- func (goo Vote) ToPBMessage(cdc *amino.Codec) (msg proto.Message, err error)
- func (vote *Vote) ValidateBasic() error
- func (vote *Vote) Verify(chainID string, pubKey crypto.PubKey) error
- type VoteSet
- func (voteSet *VoteSet) AddVote(vote *Vote) (added bool, err error)
- func (voteSet *VoteSet) BitArray() *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 crypto.Address) *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 ( // MaxBlockSizeBytes is the maximum permitted size of the blocks. MaxBlockSizeBytes = 104857600 // 100MB // BlockPartSizeBytes is the size of one block part. BlockPartSizeBytes = 65536 // 64kB // MaxBlockPartsCount is the maximum count of block parts. MaxBlockPartsCount = (MaxBlockSizeBytes / BlockPartSizeBytes) + 1 )
const ( MaxTotalVotingPower = int64(math.MaxInt64) / 8 PriorityWindowSizeFactor = 2 )
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 (
MaxEvidenceBytesDenominator = 10
)
const ( // MaxVoteBytes is a maximum vote size (including amino overhead). MaxVoteBytes int = 227 )
const ( // MaxVotesCount is the maximum votes count. Used in ValidateBasic funcs for // protection against DOS attacks. MaxVotesCount = 10000 )
const TimeFormat = time.RFC3339Nano
TimeFormat is used for generating the sigs
Variables ¶
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 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 = cmn.MaxInt(ed25519.SignatureSize, 64) )
var Package = amino.RegisterPackage(amino.NewPackage( "github.com/tendermint/classic/types", "tm", amino.GetCallersDirname(), ). WithDependencies( abci.Package, ). WithTypes( Block{}, Header{}, Data{}, Commit{}, BlockID{}, CommitSig{}, PartSetHeader{}, Vote{}, Validator{}, EventNewBlock{}, EventNewBlockHeader{}, EventTx{}, EventVote{}, EventString(""), EventValidatorSetUpdates{}, DuplicateVoteEvidence{}, MockGoodEvidence{}, MockRandomGoodEvidence{}, MockBadEvidence{}, TxResult{}, ))
var (
PeerStateKey = "ConsensusReactor.peerState"
)
UNSTABLE
Functions ¶
func CanonicalTime ¶
CanonicalTime can be used to stringify time in a canonical way.
func DefaultBlockParams ¶
func DefaultBlockParams() *abci.BlockParams
func DefaultConsensusParams ¶
func DefaultConsensusParams() abci.ConsensusParams
func DefaultValidatorParams ¶
func DefaultValidatorParams() *abci.ValidatorParams
func IsBlockIDReprEmpty ¶
func IsBlockReprEmpty ¶
func IsCommitReprEmpty ¶
func IsCommitSigReprEmpty ¶
func IsDataReprEmpty ¶
func IsDuplicateVoteEvidenceReprEmpty ¶
func IsDuplicateVoteEvidenceReprEmpty(goor DuplicateVoteEvidence) (empty bool)
func IsErrTooMuchChange ¶
func IsEventNewBlockHeaderReprEmpty ¶
func IsEventNewBlockHeaderReprEmpty(goor EventNewBlockHeader) (empty bool)
func IsEventNewBlockReprEmpty ¶
func IsEventNewBlockReprEmpty(goor EventNewBlock) (empty bool)
func IsEventStringReprEmpty ¶
func IsEventStringReprEmpty(goor EventString) (empty bool)
func IsEventTxReprEmpty ¶
func IsEventValidatorSetUpdatesReprEmpty ¶
func IsEventValidatorSetUpdatesReprEmpty(goor EventValidatorSetUpdates) (empty bool)
func IsEventVoteReprEmpty ¶
func IsHeaderReprEmpty ¶
func IsMockBadEvidenceReprEmpty ¶
func IsMockBadEvidenceReprEmpty(goor MockBadEvidence) (empty bool)
func IsMockGoodEvidenceReprEmpty ¶
func IsMockGoodEvidenceReprEmpty(goor MockGoodEvidence) (empty bool)
func IsMockRandomGoodEvidenceReprEmpty ¶
func IsMockRandomGoodEvidenceReprEmpty(goor MockRandomGoodEvidence) (empty bool)
func IsPartSetHeaderReprEmpty ¶
func IsPartSetHeaderReprEmpty(goor PartSetHeader) (empty bool)
func IsTxResultReprEmpty ¶
func IsValidatorReprEmpty ¶
func IsVoteReprEmpty ¶
func IsVoteTypeValid ¶
func IsVoteTypeValid(t SignedMsgType) bool
IsVoteTypeValid returns true if t is a valid vote type.
func MaxEvidencePerBlock ¶
MaxEvidencePerBlock returns the maximum number of evidences allowed in the block and their maximum total size (limitted to 1/10th of the maximum block size). TODO: change to a constant, or to a fraction of the validator set size. See https://github.com/tendermint/classic/issues/2590
func NewErroringMockPV ¶
func NewErroringMockPV() *erroringMockPV
NewErroringMockPV returns a MockPV that fails on each signing request. Again, for testing only.
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 ValidateConsensusParams ¶
func ValidateConsensusParams(params abci.ConsensusParams) error
func ValidateHash ¶
ValidateHash returns an error if the hash is not empty, but its size != tmhash.Size.
func ValidateTime ¶
ValidateTime does a basic time validation ensuring time does not drift too much: +/- one year. TODO: reduce this to eg 1 day NOTE: DO NOT USE in ValidateBasic methods in this package. This function can only be used for real time validation, like on proposals and votes in the consensus. If consensus is stuck, and rounds increase for more than a day, having only a 1-day band here could break things... Can't use for validating blocks because we may be syncing years worth of history.
Types ¶
type ABCIResult ¶
type ABCIResult struct { Error abci.Error `json:"error"` Data []byte `json:"data"` Events []abci.Event `json:"events"` }
ABCIResult is the deterministic component of a ResponseDeliverTx. TODO: add tags and other fields https://github.com/tendermint/classic/issues/1007
func NewResultFromResponse ¶
func NewResultFromResponse(response abci.ResponseDeliverTx) ABCIResult
NewResultFromResponse creates ABCIResult from ResponseDeliverTx.
func (ABCIResult) Bytes ¶
func (a ABCIResult) Bytes() []byte
Bytes returns the amino encoded ABCIResult
type ABCIResults ¶
type ABCIResults []ABCIResult
ABCIResults wraps the deliver tx results to return a proof
func NewResults ¶
func NewResults(responses []abci.ResponseDeliverTx) ABCIResults
NewResults creates ABCIResults from the list of ResponseDeliverTx.
func (ABCIResults) Bytes ¶
func (a ABCIResults) Bytes() []byte
Bytes serializes the ABCIResponse using amino
func (ABCIResults) Hash ¶
func (a ABCIResults) Hash() []byte
Hash returns a merkle hash of all results
func (ABCIResults) ProveResult ¶
func (a ABCIResults) ProveResult(i int) merkle.SimpleProof
ProveResult returns a merkle proof of one result from the set
type Block ¶
type Block struct { Header `json:"header"` Data `json:"data"` LastCommit *Commit `json:"last_commit"` // contains filtered or unexported fields }
Block defines the atomic unit of a Tendermint blockchain.
func MakeBlock ¶
MakeBlock returns a new block with an empty header, except what can be computed from itself. It populates the same set of fields validated by ValidateBasic.
func (*Block) FromPBMessage ¶
func (Block) GetTypeURL ¶
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) ToPBMessage ¶
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 BlockID ¶
type BlockID struct { Hash []byte `json:"hash"` PartsHeader PartSetHeader `json:"parts"` }
BlockID defines the unique ID of a block as its Hash and its PartSetHeader
func (BlockID) EmptyPBMessage ¶
func (*BlockID) FromPBMessage ¶
func (BlockID) GetTypeURL ¶
func (BlockID) IsComplete ¶
IsComplete returns true if this is a valid BlockID of a non-nil block.
func (BlockID) ToPBMessage ¶
func (BlockID) ValidateBasic ¶
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 CanonicalBlockID ¶
type CanonicalBlockID struct { Hash []byte PartsHeader CanonicalPartSetHeader }
func CanonicalizeBlockID ¶
func CanonicalizeBlockID(blockID BlockID) CanonicalBlockID
type CanonicalPartSetHeader ¶
func CanonicalizePartSetHeader ¶
func CanonicalizePartSetHeader(psh PartSetHeader) CanonicalPartSetHeader
type CanonicalProposal ¶
type CanonicalProposal struct { Type SignedMsgType // type alias for byte Height int64 `binary:"fixed64"` Round int64 `binary:"fixed64"` POLRound int64 `binary:"fixed64"` BlockID CanonicalBlockID Timestamp time.Time ChainID string }
func CanonicalizeProposal ¶
func CanonicalizeProposal(chainID string, proposal *Proposal) CanonicalProposal
type CanonicalVote ¶
type CanonicalVote struct { Type SignedMsgType // type alias for byte Height int64 `binary:"fixed64"` Round int64 `binary:"fixed64"` BlockID CanonicalBlockID Timestamp time.Time ChainID string }
func CanonicalizeVote ¶
func CanonicalizeVote(chainID string, vote *Vote) CanonicalVote
type Commit ¶
type Commit struct { // NOTE: The 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 []*CommitSig `json:"precommits" amino:"nil_elements"` // 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 ¶
func NewCommit ¶
NewCommit returns a new Commit with the given blockID and precommits. TODO: memoize ValidatorSet in constructor so votes can be easily reconstructed from CommitSig after #1648.
func (Commit) EmptyPBMessage ¶
func (*Commit) FromPBMessage ¶
func (*Commit) GetByIndex ¶
GetByIndex returns the vote corresponding to a given validator index. Panics if `index >= commit.Size()`. Implements VoteSetReader.
func (Commit) GetTypeURL ¶
func (*Commit) GetVote ¶
GetVote converts the CommitSig for the given valIdx to a Vote. Returns nil if the precommit at valIdx is nil. Panics if valIdx >= commit.Size().
func (*Commit) StringIndented ¶
StringIndented returns a string representation of the commit
func (Commit) ToPBMessage ¶
func (*Commit) ValidateBasic ¶
ValidateBasic performs basic validation that doesn't involve state data. Does not actually check the cryptographic signatures.
func (*Commit) VoteSignBytes ¶
VoteSignBytes constructs the SignBytes for the given CommitSig. The only unique part of the SignBytes is the Timestamp - all other fields signed over are otherwise the same for all validators. Panics if valIdx >= commit.Size().
type CommitSig ¶
type CommitSig Vote
CommitSig is a vote included in a Commit. For now, it is identical to a vote, but in the future it will contain fewer fields to eliminate the redundancy in commits. See https://github.com/tendermint/classic/issues/1648.
func (CommitSig) EmptyPBMessage ¶
func (*CommitSig) FromPBMessage ¶
func (CommitSig) GetTypeURL ¶
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) FromPBMessage ¶
func (Data) GetTypeURL ¶
func (*Data) StringIndented ¶
StringIndented returns a string representation of the transactions
type DuplicateVoteEvidence ¶
DuplicateVoteEvidence contains evidence a validator signed two conflicting votes.
func (*DuplicateVoteEvidence) AssertABCIEvidence ¶
func (dve *DuplicateVoteEvidence) AssertABCIEvidence()
func (*DuplicateVoteEvidence) Bytes ¶
func (dve *DuplicateVoteEvidence) Bytes() []byte
Hash returns the hash of the evidence.
func (DuplicateVoteEvidence) EmptyPBMessage ¶
func (goo DuplicateVoteEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (*DuplicateVoteEvidence) Equal ¶
func (dve *DuplicateVoteEvidence) Equal(ev Evidence) bool
Equal checks if two pieces of evidence are equal.
func (*DuplicateVoteEvidence) FromPBMessage ¶
func (DuplicateVoteEvidence) GetTypeURL ¶
func (_ DuplicateVoteEvidence) GetTypeURL() (typeURL string)
func (*DuplicateVoteEvidence) Hash ¶
func (dve *DuplicateVoteEvidence) Hash() []byte
Hash returns the hash of the evidence.
func (*DuplicateVoteEvidence) String ¶
func (dve *DuplicateVoteEvidence) String() string
String returns a string representation of the evidence.
func (DuplicateVoteEvidence) ToPBMessage ¶
func (*DuplicateVoteEvidence) ValidateBasic ¶
func (dve *DuplicateVoteEvidence) ValidateBasic() error
ValidateBasic performs basic validation.
type ErrEvidenceInvalid ¶
ErrEvidenceInvalid wraps a piece of evidence and the error denoting how or why it is invalid.
func NewErrEvidenceInvalid ¶
func NewErrEvidenceInvalid(ev Evidence, err error) *ErrEvidenceInvalid
NewErrEvidenceInvalid returns a new EvidenceInvalid with the given err.
func (*ErrEvidenceInvalid) Error ¶
func (err *ErrEvidenceInvalid) Error() string
Error returns a string representation of the error.
type ErrEvidenceOverflow ¶
ErrEvidenceOverflow is for when there is too much evidence in a block.
func NewErrEvidenceOverflow ¶
func NewErrEvidenceOverflow(max, got int64) *ErrEvidenceOverflow
NewErrEvidenceOverflow returns a new ErrEvidenceOverflow where got > max.
func (*ErrEvidenceOverflow) Error ¶
func (err *ErrEvidenceOverflow) Error() string
Error returns a string representation of the error.
type ErrInvalidCommitHeight ¶
ErrInvalidCommitHeight is returned when we encounter a commit with an unexpected height.
func NewErrInvalidCommitHeight ¶
func NewErrInvalidCommitHeight(expected, actual int64) ErrInvalidCommitHeight
func (ErrInvalidCommitHeight) Error ¶
func (e ErrInvalidCommitHeight) Error() string
type ErrInvalidCommitPrecommits ¶
ErrInvalidCommitPrecommits is returned when we encounter a commit where the number of precommits doesn't match the number of validators.
func NewErrInvalidCommitPrecommits ¶
func NewErrInvalidCommitPrecommits(expected, actual int) ErrInvalidCommitPrecommits
func (ErrInvalidCommitPrecommits) Error ¶
func (e ErrInvalidCommitPrecommits) Error() string
type ErrVoteConflictingVotes ¶
type ErrVoteConflictingVotes struct {
*DuplicateVoteEvidence
}
func NewConflictingVoteError ¶
func NewConflictingVoteError(val *Validator, voteA, voteB *Vote) *ErrVoteConflictingVotes
func (*ErrVoteConflictingVotes) Error ¶
func (err *ErrVoteConflictingVotes) Error() string
type EventNewBlock ¶
type EventNewBlock struct { Block *Block `json:"block"` ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"` ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"` }
func (EventNewBlock) AssertEvent ¶
func (_ EventNewBlock) AssertEvent()
func (EventNewBlock) EmptyPBMessage ¶
func (goo EventNewBlock) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (*EventNewBlock) FromPBMessage ¶
func (EventNewBlock) GetTypeURL ¶
func (_ EventNewBlock) GetTypeURL() (typeURL string)
func (EventNewBlock) ToPBMessage ¶
type EventNewBlockHeader ¶
type EventNewBlockHeader struct { Header Header `json:"header"` ResultBeginBlock abci.ResponseBeginBlock `json:"result_begin_block"` ResultEndBlock abci.ResponseEndBlock `json:"result_end_block"` }
light weight event for benchmarking
func (EventNewBlockHeader) AssertEvent ¶
func (_ EventNewBlockHeader) AssertEvent()
func (EventNewBlockHeader) EmptyPBMessage ¶
func (goo EventNewBlockHeader) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (*EventNewBlockHeader) FromPBMessage ¶
func (EventNewBlockHeader) GetTypeURL ¶
func (_ EventNewBlockHeader) GetTypeURL() (typeURL string)
func (EventNewBlockHeader) ToPBMessage ¶
type EventString ¶
type EventString string
func (EventString) AssertEvent ¶
func (_ EventString) AssertEvent()
func (EventString) EmptyPBMessage ¶
func (goo EventString) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (*EventString) FromPBMessage ¶
func (EventString) GetTypeURL ¶
func (_ EventString) GetTypeURL() (typeURL string)
func (EventString) ToPBMessage ¶
type EventTx ¶
type EventTx struct {
Result TxResult `json:"result"`
}
All txs fire EventTx
func (EventTx) AssertEvent ¶
func (_ EventTx) AssertEvent()
func (EventTx) EmptyPBMessage ¶
func (*EventTx) FromPBMessage ¶
func (EventTx) GetTypeURL ¶
type EventValidatorSetUpdates ¶
type EventValidatorSetUpdates struct {
ValidatorUpdates []abci.ValidatorUpdate `json:"validator_updates"`
}
func (EventValidatorSetUpdates) AssertEvent ¶
func (_ EventValidatorSetUpdates) AssertEvent()
func (EventValidatorSetUpdates) EmptyPBMessage ¶
func (goo EventValidatorSetUpdates) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (*EventValidatorSetUpdates) FromPBMessage ¶
func (EventValidatorSetUpdates) GetTypeURL ¶
func (_ EventValidatorSetUpdates) GetTypeURL() (typeURL string)
func (EventValidatorSetUpdates) ToPBMessage ¶
type EventVote ¶
type EventVote struct {
Vote *Vote `json:"vote"`
}
func (EventVote) AssertEvent ¶
func (_ EventVote) AssertEvent()
func (EventVote) EmptyPBMessage ¶
func (*EventVote) FromPBMessage ¶
func (EventVote) GetTypeURL ¶
type Evidence ¶
type Evidence interface { 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 EvidenceList ¶
type EvidenceList []Evidence
EvidenceList is a list of Evidence. Evidences is not a word.
func (EvidenceList) Has ¶
func (evl EvidenceList) Has(evidence Evidence) bool
Has returns true if the evidence is in the EvidenceList.
func (EvidenceList) Hash ¶
func (evl EvidenceList) Hash() []byte
Hash returns the simple merkle root hash of the EvidenceList.
func (EvidenceList) String ¶
func (evl EvidenceList) String() string
type GenesisDoc ¶
type GenesisDoc struct { GenesisTime time.Time `json:"genesis_time"` ChainID string `json:"chain_id"` ConsensusParams abci.ConsensusParams `json:"consensus_params,omitempty"` Validators []GenesisValidator `json:"validators,omitempty"` AppHash []byte `json:"app_hash"` AppState json.RawMessage `json:"app_state,omitempty"` }
GenesisDoc defines the initial conditions for a tendermint blockchain, in particular its validator set.
func GenesisDocFromFile ¶
func GenesisDocFromFile(genDocFile string) (*GenesisDoc, error)
GenesisDocFromFile reads JSON data from a file and unmarshalls it into a GenesisDoc.
func GenesisDocFromJSON ¶
func GenesisDocFromJSON(jsonBlob []byte) (*GenesisDoc, error)
GenesisDocFromJSON unmarshalls JSON data into a GenesisDoc.
func (*GenesisDoc) SaveAs ¶
func (genDoc *GenesisDoc) SaveAs(file string) error
SaveAs is a utility method for saving GenensisDoc as a JSON file.
func (*GenesisDoc) ValidateAndComplete ¶
func (genDoc *GenesisDoc) ValidateAndComplete() error
ValidateAndComplete checks that all necessary fields are present and fills in defaults for optional fields left empty
func (*GenesisDoc) ValidatorHash ¶
func (genDoc *GenesisDoc) ValidatorHash() []byte
ValidatorHash returns the hash of the validator set contained in the GenesisDoc
type GenesisValidator ¶
type GenesisValidator struct { Address Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` Power int64 `json:"power"` Name string `json:"name"` }
GenesisValidator is an initial validator.
type Header ¶
type Header struct { // basic block info Version string `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"` AppVersion string `json:"app_version"` // prev block info LastBlockID BlockID `json:"last_block_id"` // hashes of block data LastCommitHash []byte `json:"last_commit_hash"` // commit from validators from the last block DataHash []byte `json:"data_hash"` // transactions // hashes from the app output from the prev block ValidatorsHash []byte `json:"validators_hash"` // validators for the current block NextValidatorsHash []byte `json:"next_validators_hash"` // validators for the next block ConsensusHash []byte `json:"consensus_hash"` // consensus params for current block AppHash []byte `json:"app_hash"` // state after txs from the previous block LastResultsHash []byte `json:"last_results_hash"` // root hash of all results from the txs from the previous block // consensus info 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) AssertABCIHeader ¶
func (h *Header) AssertABCIHeader()
func (Header) EmptyPBMessage ¶
func (*Header) FromPBMessage ¶
func (Header) GetTypeURL ¶
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 ¶
func (h *Header) Populate( chainID string, timestamp time.Time, lastBlockID BlockID, totalTxs int64, appVersion string, 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 MockBadEvidence ¶
type MockBadEvidence struct {
MockGoodEvidence
}
UNSTABLE
func (MockBadEvidence) AssertABCIEvidence ¶
func (e MockBadEvidence) AssertABCIEvidence()
func (MockBadEvidence) EmptyPBMessage ¶
func (goo MockBadEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (MockBadEvidence) Equal ¶
func (e MockBadEvidence) Equal(ev Evidence) bool
func (*MockBadEvidence) FromPBMessage ¶
func (MockBadEvidence) GetTypeURL ¶
func (_ MockBadEvidence) GetTypeURL() (typeURL string)
func (MockBadEvidence) String ¶
func (e MockBadEvidence) String() string
func (MockBadEvidence) ToPBMessage ¶
func (MockBadEvidence) ValidateBasic ¶
func (e MockBadEvidence) ValidateBasic() error
type MockGoodEvidence ¶
UNSTABLE
func NewMockGoodEvidence ¶
func NewMockGoodEvidence(height int64, idx int, address crypto.Address) MockGoodEvidence
UNSTABLE
func (MockGoodEvidence) AssertABCIEvidence ¶
func (e MockGoodEvidence) AssertABCIEvidence()
func (MockGoodEvidence) Bytes ¶
func (e MockGoodEvidence) Bytes() []byte
func (MockGoodEvidence) EmptyPBMessage ¶
func (goo MockGoodEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (MockGoodEvidence) Equal ¶
func (e MockGoodEvidence) Equal(ev Evidence) bool
func (*MockGoodEvidence) FromPBMessage ¶
func (MockGoodEvidence) GetTypeURL ¶
func (_ MockGoodEvidence) GetTypeURL() (typeURL string)
func (MockGoodEvidence) Hash ¶
func (e MockGoodEvidence) Hash() []byte
func (MockGoodEvidence) String ¶
func (e MockGoodEvidence) String() string
func (MockGoodEvidence) ToPBMessage ¶
func (MockGoodEvidence) ValidateBasic ¶
func (e MockGoodEvidence) ValidateBasic() error
type MockPV ¶
type MockPV struct {
// contains filtered or unexported fields
}
MockPV implements PrivValidator without any safety or persistence. Only use it for testing.
func NewMockPVWithParams ¶
func NewMockPVWithParams(privKey crypto.PrivKey, breakProposalSigning, breakVoteSigning bool) *MockPV
NewMockPVWithParams allows one to create a MockPV instance, but with finer grained control over the operation of the mock validator. This is useful for mocking test failures.
func (*MockPV) SignProposal ¶
Implements PrivValidator.
type MockRandomGoodEvidence ¶
type MockRandomGoodEvidence struct { MockGoodEvidence // contains filtered or unexported fields }
UNSTABLE
func NewMockRandomGoodEvidence ¶
func NewMockRandomGoodEvidence(height int64, address crypto.Address, randBytes []byte) MockRandomGoodEvidence
UNSTABLE
func (MockRandomGoodEvidence) AssertABCIEvidence ¶
func (e MockRandomGoodEvidence) AssertABCIEvidence()
func (MockRandomGoodEvidence) EmptyPBMessage ¶
func (goo MockRandomGoodEvidence) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (*MockRandomGoodEvidence) FromPBMessage ¶
func (MockRandomGoodEvidence) GetTypeURL ¶
func (_ MockRandomGoodEvidence) GetTypeURL() (typeURL string)
func (MockRandomGoodEvidence) Hash ¶
func (e MockRandomGoodEvidence) Hash() []byte
func (MockRandomGoodEvidence) ToPBMessage ¶
type P2PID ¶
type P2PID string
UNSTABLE XXX: duplicate of p2p.ID to avoid dependence between packages. Perhaps we can have a minimal types package containing this (and other things?) that both `types` and `p2p` import ?
type Part ¶
type Part struct { Index int `json:"index"` Bytes []byte `json:"bytes"` Proof merkle.SimpleProof `json:"proof"` }
func (*Part) StringIndented ¶
func (*Part) ValidateBasic ¶
ValidateBasic performs basic validation.
type PartSet ¶
type PartSet struct {
// contains filtered or unexported fields
}
func NewPartSetFromData ¶
Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed.
func NewPartSetFromHeader ¶
func NewPartSetFromHeader(header PartSetHeader) *PartSet
Returns an empty PartSet ready to be populated.
func (*PartSet) HasHeader ¶
func (ps *PartSet) HasHeader(header PartSetHeader) bool
func (*PartSet) Header ¶
func (ps *PartSet) Header() PartSetHeader
func (*PartSet) IsComplete ¶
func (*PartSet) MarshalJSON ¶
func (*PartSet) StringShort ¶
type PartSetHeader ¶
func (PartSetHeader) EmptyPBMessage ¶
func (goo PartSetHeader) EmptyPBMessage(cdc *amino.Codec) (msg proto.Message)
func (PartSetHeader) Equals ¶
func (psh PartSetHeader) Equals(other PartSetHeader) bool
func (*PartSetHeader) FromPBMessage ¶
func (PartSetHeader) GetTypeURL ¶
func (_ PartSetHeader) GetTypeURL() (typeURL string)
func (PartSetHeader) IsZero ¶
func (psh PartSetHeader) IsZero() bool
func (PartSetHeader) String ¶
func (psh PartSetHeader) String() string
func (PartSetHeader) ToPBMessage ¶
func (PartSetHeader) ValidateBasic ¶
func (psh PartSetHeader) ValidateBasic() error
ValidateBasic performs basic validation.
type PartSetReader ¶
type PartSetReader struct {
// contains filtered or unexported fields
}
func NewPartSetReader ¶
func NewPartSetReader(parts []*Part) *PartSetReader
type PrivValidator ¶
type PrivValidator interface { // TODO: Extend the interface to return errors too. Issue: https://github.com/tendermint/classic/issues/3602 GetPubKey() crypto.PubKey SignVote(chainID string, vote *Vote) error SignProposal(chainID string, proposal *Proposal) error }
PrivValidator defines the functionality of a local Tendermint validator that signs votes and proposals, and never double signs.
type PrivValidatorsByAddress ¶
type PrivValidatorsByAddress []PrivValidator
func (PrivValidatorsByAddress) Len ¶
func (pvs PrivValidatorsByAddress) Len() int
func (PrivValidatorsByAddress) Less ¶
func (pvs PrivValidatorsByAddress) Less(i, j int) bool
func (PrivValidatorsByAddress) Swap ¶
func (pvs PrivValidatorsByAddress) Swap(i, j int)
type Proposal ¶
type Proposal struct { Type SignedMsgType Height int64 `json:"height"` Round int `json:"round"` POLRound int `json:"pol_round"` // -1 if null. BlockID BlockID `json:"block_id"` Timestamp time.Time `json:"timestamp"` Signature []byte `json:"signature"` }
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 ¶
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 ¶
SignedHeader is a header along with the commits that prove it. It is the basis of the lite client.
func (SignedHeader) String ¶
func (sh SignedHeader) String() string
func (SignedHeader) StringIndented ¶
func (sh SignedHeader) StringIndented(indent string) string
StringIndented returns a string representation of the SignedHeader.
func (SignedHeader) ValidateBasic ¶
func (sh SignedHeader) ValidateBasic(chainID string) error
ValidateBasic does basic consistency checks and makes sure the header and commit are consistent.
NOTE: This does not actually check the cryptographic signatures. Make sure to use a Verifier to validate the signatures actually provide a significantly strong proof for this header's validity.
type SignedMsgType ¶
type SignedMsgType byte
SignedMsgType is a type of signed message in the consensus.
const ( // Votes PrevoteType SignedMsgType = 0x01 PrecommitType SignedMsgType = 0x02 // Proposals ProposalType SignedMsgType = 0x20 )
type 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 TxProof ¶
type TxProof struct { RootHash []byte `json:"root_hash"` Data Tx `json:"data"` Proof merkle.SimpleProof `json:"proof"` }
TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree.
type TxResult ¶
type TxResult struct { Height int64 `json:"height"` Index uint32 `json:"index"` Tx Tx `json:"tx"` Response abci.ResponseDeliverTx `json:"response"` }
TxResult contains results of executing the transaction.
func (TxResult) EmptyPBMessage ¶
func (*TxResult) FromPBMessage ¶
func (TxResult) GetTypeURL ¶
type Txs ¶
type Txs []Tx
Txs is a slice of Tx.
func (Txs) Hash ¶
Hash returns the Merkle root hash of the transaction hashes. i.e. the leaves of the tree are the hashes of the txs.
func (Txs) IndexByHash ¶
IndexByHash returns the index of this transaction hash in the list, or -1 if not found
type Validator ¶
type Validator struct { Address Address `json:"address"` PubKey crypto.PubKey `json:"pub_key"` VotingPower int64 `json:"voting_power"` ProposerPriority int64 `json:"proposer_priority"` }
Volatile state for each Validator NOTE: The ProposerPriority is not included in Validator.Hash(); make sure to update that method if changes are made here
func ABCIValidatorUpdatesToValidators ¶
func ABCIValidatorUpdatesToValidators(updates []abci.ValidatorUpdate) (vals []*Validator)
func NewValidatorFromABCIValidatorUpdate ¶
func NewValidatorFromABCIValidatorUpdate(update abci.ValidatorUpdate) *Validator
func (*Validator) ABCIValidatorUpdate ¶
func (v *Validator) ABCIValidatorUpdate() abci.ValidatorUpdate
func (*Validator) Bytes ¶
Bytes computes the unique encoding of a validator with a given voting power. These are the bytes that gets hashed in consensus. It excludes address as its redundant with the pubkey. This also excludes ProposerPriority which changes every round.
func (*Validator) CompareProposerPriority ¶
Returns the one with higher ProposerPriority.
func (*Validator) Copy ¶
Creates a new copy of the validator so we can mutate ProposerPriority. Panics if the validator is nil.
func (Validator) EmptyPBMessage ¶
func (*Validator) FromPBMessage ¶
func (Validator) GetTypeURL ¶
type ValidatorSet ¶
type ValidatorSet struct { // NOTE: persisted via reflect, must be exported. Validators []*Validator `json:"validators"` Proposer *Validator `json:"proposer"` // contains filtered or unexported fields }
ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height - ie. the validators are sorted by their address. On the other hand, the .ProposerPriority of each validator and the designated .GetProposer() of a set changes every round, upon calling .IncrementProposerPriority(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety.
func NewValidatorSet ¶
func NewValidatorSet(valz []*Validator) *ValidatorSet
NewValidatorSet initializes a ValidatorSet by copying over the values from `valz`, a list of Validators. If valz is nil or empty, the new ValidatorSet will have an empty list of Validators. The addresses of validators in `valz` must be unique otherwise the function panics.
func NewValidatorSetFromABCIValidatorUpdates ¶
func NewValidatorSetFromABCIValidatorUpdates(updates []abci.ValidatorUpdate) *ValidatorSet
func (*ValidatorSet) ABCIValidatorUpdates ¶
func (vals *ValidatorSet) ABCIValidatorUpdates() (updates []abci.ValidatorUpdate)
func (*ValidatorSet) Copy ¶
func (vals *ValidatorSet) Copy() *ValidatorSet
Copy each validator into a new ValidatorSet.
func (*ValidatorSet) CopyIncrementProposerPriority ¶
func (vals *ValidatorSet) CopyIncrementProposerPriority(times int) *ValidatorSet
Increment ProposerPriority and update the proposer on a copy, and return it.
func (*ValidatorSet) GetByAddress ¶
func (vals *ValidatorSet) GetByAddress(address crypto.Address) (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 crypto.Address, val *Validator)
GetByIndex returns the validator's address and validator itself by index. It returns nil values if index is less than 0 or greater or equal to len(ValidatorSet.Validators).
func (*ValidatorSet) GetProposer ¶
func (vals *ValidatorSet) GetProposer() (proposer *Validator)
GetProposer returns the current proposer. If the validator set is empty, nil is returned.
func (*ValidatorSet) HasAddress ¶
func (vals *ValidatorSet) HasAddress(address crypto.Address) 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) IncrementProposerPriority ¶
func (vals *ValidatorSet) IncrementProposerPriority(times int)
IncrementProposerPriority increments ProposerPriority of each validator and updates the proposer. Panics if validator set is empty. `times` must be positive.
func (*ValidatorSet) IsNilOrEmpty ¶
func (vals *ValidatorSet) IsNilOrEmpty() bool
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) RescalePriorities ¶
func (vals *ValidatorSet) RescalePriorities(diffMax int64)
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. It recomputes the total voting power if required.
func (*ValidatorSet) UpdateWithABCIValidatorUpdates ¶
func (vals *ValidatorSet) UpdateWithABCIValidatorUpdates(updates []abci.ValidatorUpdate) error
Same as UpdateWithChangeSet, but with abci.ValidatorUpdate. The ProposerPriority gets set to 0 for new/existing validators.
func (*ValidatorSet) UpdateWithChangeSet ¶
func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error
UpdateWithChangeSet attempts to update the validator set with 'changes'. It performs the following steps:
- validates the changes making sure there are no duplicates and splits them in updates and deletes
- verifies that applying the changes will not result in errors
- computes the total voting power BEFORE removals to ensure that in the next steps the priorities across old and newly added validators are fair
- computes the priorities of new validators against the final set
- applies the updates against the validator set
- applies the removals against the validator set
- performs scaling and centering of priority values
If an error is detected during verification steps, it is returned and the validator set is not changed.
func (*ValidatorSet) VerifyCommit ¶
func (vals *ValidatorSet) VerifyCommit(chainID string, blockID BlockID, height int64, commit *Commit) error
Verify that +2/3 of the set had signed the given signBytes.
func (*ValidatorSet) VerifyFutureCommit ¶
func (vals *ValidatorSet) VerifyFutureCommit(newSet *ValidatorSet, chainID string, blockID BlockID, height int64, commit *Commit) error
VerifyFutureCommit will check to see if the set would be valid with a different validator set.
vals is the old validator set that we know. Over 2/3 of the power in old signed this block.
In Tendermint, 1/3 of the voting power can halt or fork the chain, but 1/3 can't make arbitrary state transitions. You still need > 2/3 Byzantine to make arbitrary state transitions.
To preserve this property in the light client, we also require > 2/3 of the old vals to sign the future commit at H, that way we preserve the property that if they weren't being truthful about the validator set at H (block hash -> vals hash) or about the app state (block hash -> app hash) we can slash > 2/3. Otherwise, the lite client isn't providing the same security guarantees.
Even if we added a slashing condition that if you sign a block header with the wrong validator set, then we would only need > 1/3 of signatures from the old vals on the new commit, it wouldn't be sufficient because the new vals can be arbitrary and commit some arbitrary app hash.
newSet is the validator set that signed this block. Only votes from new are sufficient for 2/3 majority in the new set as well, for it to be a valid commit.
NOTE: This doesn't check whether the commit is a future commit, because the current height isn't part of the ValidatorSet. Caller must check that the commit height is greater than the height for this validator set.
type ValidatorsByAddress ¶
type ValidatorsByAddress []*Validator
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"` BlockID BlockID `json:"block_id"` // zero if vote is nil. Timestamp time.Time `json:"timestamp"` ValidatorAddress Address `json:"validator_address"` ValidatorIndex int `json:"validator_index"` Signature []byte `json:"signature"` }
Vote represents a prevote, precommit, or commit vote from validators for consensus.
func MakeVote ¶
func MakeVote(height int64, blockID BlockID, valSet *ValidatorSet, privVal PrivValidator, chainID string) (*Vote, error)
func (*Vote) CommitSig ¶
CommitSig converts the Vote to a CommitSig. If the Vote is nil, the CommitSig will be nil.
func (*Vote) FromPBMessage ¶
func (Vote) GetTypeURL ¶
func (Vote) ToPBMessage ¶
func (*Vote) ValidateBasic ¶
ValidateBasic performs basic validation.
type VoteSet ¶
type VoteSet struct {
// contains filtered or unexported fields
}
VoteSet helps collect signatures from validators at each height+round for a predefined vote type.
We need VoteSet to be able to keep track of conflicting votes when validators double-sign. Yet, we can't keep track of *all* the votes seen, as that could be a DoS attack vector.
There are two storage areas for votes. 1. voteSet.votes 2. voteSet.votesByBlock
`.votes` is the "canonical" list of votes. It always has at least one vote, if a vote from a validator had been seen at all. Usually it keeps track of the first vote seen, but when a 2/3 majority is found, votes for that get priority and are copied over from `.votesByBlock`.
`.votesByBlock` keeps track of a list of votes for a particular block. There are two ways a &blockVotes{} gets created in `.votesByBlock`. 1. the first vote seen by a validator was for the particular block. 2. a peer claims to have seen 2/3 majority for the particular block.
Since the first vote from a validator will always get added in `.votesByBlock` , all votes in `.votes` will have a corresponding entry in `.votesByBlock`.
When a &blockVotes{} in `.votesByBlock` reaches a 2/3 majority quorum, its votes are copied into `.votes`.
All this is memory bounded because conflicting votes only get added if a peer told us to track that block, each peer only gets to tell us 1 such block, and, there's only a limited number of peers.
NOTE: Assumes that the sum total of voting power does not exceed MaxUInt64.
func CommitToVoteSet ¶
func CommitToVoteSet(chainID string, commit *Commit, vals *ValidatorSet) *VoteSet
Construct a VoteSet from the Commit and validator set. Panics if precommits from the commit can't be added to the voteset. Inverse of VoteSet.MakeCommit().
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 ¶
Returns added=true if vote is valid and new. Otherwise returns err=ErrVote[
UnexpectedStep | InvalidIndex | InvalidAddress | InvalidSignature | InvalidBlockHash | ConflictingVotes ]
Duplicate votes return added=false, err=nil. Conflicting votes return added=*, err=ErrVoteConflictingVotes. NOTE: vote should not be mutated after adding. NOTE: VoteSet must not be nil NOTE: Vote must not be nil
func (*VoteSet) BitArrayByBlockID ¶
func (*VoteSet) BitArrayString ¶
Return the bit-array of votes including the fraction of power that has voted like: "BA{29:xx__x__x_x___x__x_______xxx__} 856/1304 = 0.66"
func (*VoteSet) GetByIndex ¶
NOTE: if validator has conflicting votes, returns "canonical" vote
func (*VoteSet) HasTwoThirdsAny ¶
func (*VoteSet) HasTwoThirdsMajority ¶
func (*VoteSet) MakeCommit ¶
MakeCommit constructs a Commit from the VoteSet. Panics if the vote type is not PrecommitType or if there's no +2/3 votes for a single block.
func (*VoteSet) MarshalJSON ¶
Marshal the VoteSet to JSON. Same as String(), just in JSON, and without the height/round/type_ (since its already included in the votes).
func (*VoteSet) SetPeerMaj23 ¶
If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too NOTE: VoteSet must not be nil
func (*VoteSet) StringIndented ¶
func (*VoteSet) StringShort ¶
func (*VoteSet) TwoThirdsMajority ¶
If there was a +2/3 majority for blockID, return blockID and true. Else, return the empty BlockID{} and false.
func (*VoteSet) VoteStrings ¶
Returns a list of votes compressed to more readable strings.
type VoteSetJSON ¶
type VoteSetJSON struct { Votes []string `json:"votes"` VotesBitArray string `json:"votes_bit_array"` PeerMaj23s map[P2PID]BlockID `json:"peer_maj_23s"` }
More human readable JSON of the vote set NOTE: insufficient for unmarshalling from (compressed votes) TODO: make the peerMaj23s nicer to read (eg just the block hash)
Source Files ¶
- block.go
- block_meta.go
- canonical.go
- encoding_helper.go
- errors.go
- events.go
- evidence.go
- genesis.go
- keys.go
- package.go
- params.go
- part_set.go
- pbbindings.go
- priv_validator.go
- proposal.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