Documentation ¶
Index ¶
- Constants
- Variables
- func ExecCommitBlock(ctx context.Context, be *BlockExecutor, appConn abciclient.Client, ...) ([]byte, error)
- func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error)
- func Rollback(bs BlockStore, ss Store, removeBlock bool, ...) (int64, []byte, error)
- func TxPostCheckForState(state State) mempool.PostCheckFunc
- func TxPostCheckFromStore(store Store) mempool.PostCheckFunc
- func TxPreCheckForState(state State) mempool.PreCheckFunc
- func TxPreCheckFromStore(store Store) mempool.PreCheckFunc
- type BlockExecutor
- func (blockExec *BlockExecutor) ApplyBlock(ctx context.Context, state State, blockID types.BlockID, block *types.Block, ...) (State, error)
- func (blockExec *BlockExecutor) CheckTxFromPeerProposal(ctx context.Context, tx types.Tx)
- func (blockExec *BlockExecutor) Commit(ctx context.Context, state State, block *types.Block, ...) (int64, error)
- func (blockExec *BlockExecutor) CreateProposalBlock(ctx context.Context, height int64, state State, ...) (*types.Block, error)
- func (blockExec *BlockExecutor) ExtendVote(ctx context.Context, vote *types.Vote) ([]byte, error)
- func (blockExec *BlockExecutor) GetMissingTxs(txKeys []types.TxKey) []types.TxKey
- func (blockExec *BlockExecutor) GetTxsForKeys(txKeys []types.TxKey) types.Txs
- func (blockExec *BlockExecutor) ProcessProposal(ctx context.Context, block *types.Block, state State) (bool, error)
- func (blockExec *BlockExecutor) Store() Store
- func (blockExec *BlockExecutor) ValidateBlock(ctx context.Context, state State, block *types.Block) error
- func (blockExec *BlockExecutor) VerifyVoteExtension(ctx context.Context, vote *types.Vote) error
- type BlockStore
- type EmptyEvidencePool
- func (EmptyEvidencePool) AddEvidence(context.Context, types.Evidence) error
- func (EmptyEvidencePool) CheckEvidence(ctx context.Context, evList types.EvidenceList) error
- func (EmptyEvidencePool) PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64)
- func (EmptyEvidencePool) ReportConflictingVotes(voteA, voteB *types.Vote)
- func (EmptyEvidencePool) Update(context.Context, State, types.EvidenceList)
- type ErrAppBlockHeightTooHigh
- type ErrAppBlockHeightTooLow
- type ErrBlockHashMismatch
- type ErrInvalidBlock
- type ErrLastStateMismatch
- type ErrNoConsensusParamsForHeight
- type ErrNoFinalizeBlockResponsesForHeight
- type ErrNoValSetForHeight
- type ErrProxyAppConn
- type ErrStateMismatch
- type ErrUnknownBlock
- type EvidencePool
- type Metrics
- type State
- func (state State) Bytes() ([]byte, error)
- func (state State) Copy() State
- func (state State) Equals(state2 State) (bool, error)
- func (state State) IsEmpty() bool
- func (state State) MakeBlock(height int64, txs []types.Tx, commit *types.Commit, evidence []types.Evidence, ...) *types.Block
- func (state *State) ToProto() (*tmstate.State, error)
- func (state State) Update(blockID types.BlockID, header *types.Header, resultsHash []byte, ...) (State, error)
- type Store
- type Version
Constants ¶
const ( // MetricsSubsystem is a subsystem shared by all metrics exposed by this // package. MetricsSubsystem = "state" )
Variables ¶
var InitStateVersion = Version{ Consensus: version.Consensus{ Block: version.BlockProtocol, App: 0, }, Software: version.TMVersion, }
InitStateVersion sets the Consensus.Block and Software versions, but leaves the Consensus.App version blank. The Consensus.App version will be set during the Handshake, once we hear from the app what protocol version it is running.
Functions ¶
func ExecCommitBlock ¶
func ExecCommitBlock( ctx context.Context, be *BlockExecutor, appConn abciclient.Client, block *types.Block, logger log.Logger, store Store, initialHeight int64, s State, ) ([]byte, error)
ExecCommitBlock executes and commits a block on the proxyApp without validating or mutating the state. It returns the application root hash (result of abci.Commit).
func MakeGenesisDocFromFile ¶
func MakeGenesisDocFromFile(genDocFile string) (*types.GenesisDoc, error)
MakeGenesisDocFromFile reads and unmarshals genesis doc from the given file.
func Rollback ¶
func Rollback(bs BlockStore, ss Store, removeBlock bool, privValidatorConfig *config.PrivValidatorConfig) (int64, []byte, error)
Rollback overwrites the current Tendermint state (height n) with the most recent previous state (height n - 1). Note that this function does not affect application state.
func TxPostCheckForState ¶
func TxPostCheckForState(state State) mempool.PostCheckFunc
func TxPostCheckFromStore ¶
func TxPostCheckFromStore(store Store) mempool.PostCheckFunc
TxPostCheckFromStore returns a function to filter transactions after processing. The function limits the gas wanted by a transaction to the block's maximum total gas.
func TxPreCheckForState ¶
func TxPreCheckForState(state State) mempool.PreCheckFunc
func TxPreCheckFromStore ¶
func TxPreCheckFromStore(store Store) mempool.PreCheckFunc
TxPreCheckFromStore returns a function to filter transactions before processing. The function limits the size of a transaction to the block's maximum data size.
Types ¶
type BlockExecutor ¶
type BlockExecutor struct {
// contains filtered or unexported fields
}
BlockExecutor provides the context and accessories for properly executing a block.
func NewBlockExecutor ¶
func NewBlockExecutor( stateStore Store, logger log.Logger, appClient abciclient.Client, pool mempool.Mempool, evpool EvidencePool, blockStore BlockStore, eventBus *eventbus.EventBus, metrics *Metrics, ) *BlockExecutor
NewBlockExecutor returns a new BlockExecutor with the passed-in EventBus.
func (*BlockExecutor) ApplyBlock ¶
func (blockExec *BlockExecutor) ApplyBlock( ctx context.Context, state State, blockID types.BlockID, block *types.Block, tracer otrace.Tracer) (State, error)
ApplyBlock validates the block against the state, executes it against the app, fires the relevant events, commits the app, and saves the new state and responses. It returns the new state. It's the only function that needs to be called from outside this package to process and commit an entire block. It takes a blockID to avoid recomputing the parts hash.
func (*BlockExecutor) CheckTxFromPeerProposal ¶
func (blockExec *BlockExecutor) CheckTxFromPeerProposal(ctx context.Context, tx types.Tx)
func (*BlockExecutor) Commit ¶
func (blockExec *BlockExecutor) Commit( ctx context.Context, state State, block *types.Block, txResults []*abci.ExecTxResult, ) (int64, error)
Commit locks the mempool, runs the ABCI Commit message, and updates the mempool. It returns the result of calling abci.Commit (the AppHash) and the height to retain (if any). The Mempool must be locked during commit and update because state is typically reset on Commit and old txs must be replayed against committed state before new txs are run in the mempool, lest they be invalid.
func (*BlockExecutor) CreateProposalBlock ¶
func (blockExec *BlockExecutor) CreateProposalBlock( ctx context.Context, height int64, state State, lastExtCommit *types.ExtendedCommit, proposerAddr []byte, ) (*types.Block, error)
CreateProposalBlock calls state.MakeBlock with evidence from the evpool and txs from the mempool. The max bytes must be big enough to fit the commit. Up to 1/10th of the block space is allcoated for maximum sized evidence. The rest is given to txs, up to the max gas.
Contract: application will not return more bytes than are sent over the wire.
func (*BlockExecutor) ExtendVote ¶
func (*BlockExecutor) GetMissingTxs ¶
func (blockExec *BlockExecutor) GetMissingTxs(txKeys []types.TxKey) []types.TxKey
func (*BlockExecutor) GetTxsForKeys ¶
func (blockExec *BlockExecutor) GetTxsForKeys(txKeys []types.TxKey) types.Txs
func (*BlockExecutor) ProcessProposal ¶
func (*BlockExecutor) Store ¶
func (blockExec *BlockExecutor) Store() Store
func (*BlockExecutor) ValidateBlock ¶
func (blockExec *BlockExecutor) ValidateBlock(ctx context.Context, state State, block *types.Block) error
ValidateBlock validates the given block against the given state. If the block is invalid, it returns an error. Validation does not mutate state, but does require historical information from the stateDB, ie. to verify evidence from a validator at an old height.
func (*BlockExecutor) VerifyVoteExtension ¶
type BlockStore ¶
type BlockStore interface { Base() int64 Height() int64 Size() int64 LoadBaseMeta() *types.BlockMeta LoadBlockMeta(height int64) *types.BlockMeta LoadBlock(height int64) *types.Block SaveBlock(block *types.Block, blockParts *types.PartSet, seenCommit *types.Commit) SaveBlockWithExtendedCommit(block *types.Block, blockParts *types.PartSet, seenCommit *types.ExtendedCommit) PruneBlocks(height int64) (uint64, error) LoadBlockByHash(hash []byte) *types.Block LoadBlockMetaByHash(hash []byte) *types.BlockMeta LoadBlockPart(height int64, index int) *types.Part LoadBlockCommit(height int64) *types.Commit LoadSeenCommit() *types.Commit LoadBlockExtendedCommit(height int64) *types.ExtendedCommit DeleteLatestBlock() error }
BlockStore defines the interface used by the ConsensusState.
type EmptyEvidencePool ¶
type EmptyEvidencePool struct{}
EmptyEvidencePool is an empty implementation of EvidencePool, useful for testing. It also complies to the consensus evidence pool interface
func (EmptyEvidencePool) AddEvidence ¶
func (EmptyEvidencePool) CheckEvidence ¶
func (EmptyEvidencePool) CheckEvidence(ctx context.Context, evList types.EvidenceList) error
func (EmptyEvidencePool) PendingEvidence ¶
func (EmptyEvidencePool) PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64)
func (EmptyEvidencePool) ReportConflictingVotes ¶
func (EmptyEvidencePool) ReportConflictingVotes(voteA, voteB *types.Vote)
func (EmptyEvidencePool) Update ¶
func (EmptyEvidencePool) Update(context.Context, State, types.EvidenceList)
type ErrAppBlockHeightTooHigh ¶
func (ErrAppBlockHeightTooHigh) Error ¶
func (e ErrAppBlockHeightTooHigh) Error() string
type ErrAppBlockHeightTooLow ¶
func (ErrAppBlockHeightTooLow) Error ¶
func (e ErrAppBlockHeightTooLow) Error() string
type ErrBlockHashMismatch ¶
func (ErrBlockHashMismatch) Error ¶
func (e ErrBlockHashMismatch) Error() string
type ErrInvalidBlock ¶
type ErrInvalidBlock error
type ErrLastStateMismatch ¶
func (ErrLastStateMismatch) Error ¶
func (e ErrLastStateMismatch) Error() string
type ErrNoConsensusParamsForHeight ¶
type ErrNoConsensusParamsForHeight struct {
Height int64
}
func (ErrNoConsensusParamsForHeight) Error ¶
func (e ErrNoConsensusParamsForHeight) Error() string
type ErrNoFinalizeBlockResponsesForHeight ¶
type ErrNoFinalizeBlockResponsesForHeight struct {
Height int64
}
func (ErrNoFinalizeBlockResponsesForHeight) Error ¶
func (e ErrNoFinalizeBlockResponsesForHeight) Error() string
type ErrNoValSetForHeight ¶
func (ErrNoValSetForHeight) Error ¶
func (e ErrNoValSetForHeight) Error() string
func (ErrNoValSetForHeight) Unwrap ¶
func (e ErrNoValSetForHeight) Unwrap() error
type ErrProxyAppConn ¶
type ErrProxyAppConn error
type ErrStateMismatch ¶
func (ErrStateMismatch) Error ¶
func (e ErrStateMismatch) Error() string
type ErrUnknownBlock ¶
type ErrUnknownBlock struct {
Height int64
}
func (ErrUnknownBlock) Error ¶
func (e ErrUnknownBlock) Error() string
type EvidencePool ¶
type EvidencePool interface { PendingEvidence(maxBytes int64) (ev []types.Evidence, size int64) AddEvidence(context.Context, types.Evidence) error Update(context.Context, State, types.EvidenceList) CheckEvidence(context.Context, types.EvidenceList) error }
EvidencePool defines the EvidencePool interface used by State.
type Metrics ¶
type Metrics struct { // Time between BeginBlock and EndBlock. BlockProcessingTime metrics.Histogram `metrics_buckettype:"exprange" metrics_bucketsizes:"0.01, 10, 10"` // ConsensusParamUpdates is the total number of times the application has // udated the consensus params since process start. //metrics:Number of consensus parameter updates returned by the application since process start. ConsensusParamUpdates metrics.Counter // ValidatorSetUpdates is the total number of times the application has // udated the validator set since process start. //metrics:Number of validator set updates returned by the application since process start. ValidatorSetUpdates metrics.Counter // ValidatorSetUpdates measures how long it takes async ABCI requests to be flushed before // committing application state FlushAppConnectionTime metrics.Histogram // ApplicationCommitTime meaures how long it takes to commit application state ApplicationCommitTime metrics.Histogram // UpdateMempoolTime meaures how long it takes to update mempool after commiting, including // reCheckTx UpdateMempoolTime metrics.Histogram }
Metrics contains metrics exposed by this package.
func NopMetrics ¶
func NopMetrics() *Metrics
func PrometheusMetrics ¶
type State ¶
type State struct { // FIXME: This can be removed as TMVersion is a constant, and version.Consensus should // eventually be replaced by VersionParams in ConsensusParams Version Version // immutable ChainID string InitialHeight int64 // should be 1, not 0, when starting from height 1 // LastBlockHeight=0 at genesis (ie. block(H=0) does not exist) LastBlockHeight int64 LastBlockID types.BlockID LastBlockTime time.Time // LastValidators is used to validate block.LastCommit. // Validators are persisted to the database separately every time they change, // so we can query for historical validator sets. // Note that if s.LastBlockHeight causes a valset change, // we set s.LastHeightValidatorsChanged = s.LastBlockHeight + 1 + 1 // Extra +1 due to nextValSet delay. NextValidators *types.ValidatorSet Validators *types.ValidatorSet LastValidators *types.ValidatorSet LastHeightValidatorsChanged int64 // Consensus parameters used for validating blocks. // Changes returned by FinalizeBlock and updated after Commit. ConsensusParams types.ConsensusParams LastHeightConsensusParamsChanged int64 // Merkle root of the results from executing prev block LastResultsHash []byte // the latest AppHash we've received from calling abci.Commit() AppHash []byte }
State is a short description of the latest committed block of the Tendermint consensus. It keeps all information necessary to validate new blocks, including the last validator set and the consensus params. All fields are exposed so the struct can be easily serialized, but none of them should be mutated directly. Instead, use state.Copy() or updateState(...). NOTE: not goroutine-safe.
func MakeGenesisState ¶
func MakeGenesisState(genDoc *types.GenesisDoc) (State, error)
MakeGenesisState creates state from types.GenesisDoc.
func MakeGenesisStateFromFile ¶
MakeGenesisStateFromFile reads and unmarshals state from the given file.
Used during replay and in tests.
func (State) MakeBlock ¶
func (state State) MakeBlock( height int64, txs []types.Tx, commit *types.Commit, evidence []types.Evidence, proposerAddress []byte, ) *types.Block
MakeBlock builds a block from the current state with the given txs, commit, and evidence. Note it also takes a proposerAddress because the state does not track rounds, and hence does not know the correct proposer. TODO: fix this!
type Store ¶
type Store interface { // Load loads the current state of the blockchain Load() (State, error) // LoadValidators loads the validator set at a given height LoadValidators(int64) (*types.ValidatorSet, error) // LoadFinalizeBlockResponses loads the responses to FinalizeBlock for a given height LoadFinalizeBlockResponses(int64) (*abci.ResponseFinalizeBlock, error) // LoadConsensusParams loads the consensus params for a given height LoadConsensusParams(int64) (types.ConsensusParams, error) // Save overwrites the previous state with the updated one Save(State) error // SaveFinalizeBlockResponses saves responses to FinalizeBlock for a given height SaveFinalizeBlockResponses(int64, *abci.ResponseFinalizeBlock) error // SaveValidatorSet saves the validator set at a given height SaveValidatorSets(int64, int64, *types.ValidatorSet) error // Bootstrap is used for bootstrapping state when not starting from a initial height. Bootstrap(State) error // PruneStates takes the height from which to prune up to (exclusive) PruneStates(int64) error // Close closes the connection with the database Close() error }
Store defines the state store interface
It is used to retrieve current state and save and load ABCI responses, validators and consensus parameters
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package indexer defines Tendermint's block and transaction event indexing logic.
|
Package indexer defines Tendermint's block and transaction event indexing logic. |
sink/psql
Package psql implements an event sink backed by a PostgreSQL database.
|
Package psql implements an event sink backed by a PostgreSQL database. |
test
|
|