Documentation ¶
Index ¶
- func DefaultProposerSelection(_ context.Context, h uint64, r uint32, valSet tmconsensus.ValidatorSet) tmconsensus.Validator
- type BlockAnnotation
- type ConsensusStrategy
- func (c *ConsensusStrategy) ChooseProposedBlock(ctx context.Context, phs []tmconsensus.ProposedHeader) (string, error)
- func (c *ConsensusStrategy) ConsiderProposedBlocks(ctx context.Context, phs []tmconsensus.ProposedHeader, ...) (string, error)
- func (c *ConsensusStrategy) DecidePrecommit(ctx context.Context, vs tmconsensus.VoteSummary) (string, error)
- func (c *ConsensusStrategy) EnterRound(ctx context.Context, rv tmconsensus.RoundView, ...) error
- func (s *ConsensusStrategy) Wait()
- type ConsensusStrategyConfig
- type Driver
- type DriverConfig
- type HTTPServer
- type HTTPServerConfig
- type PBDRetriever
- type PBDRetrieverConfig
- type ProposalDriverAnnotation
- type ProposerSelectionFunc
- type SDKTxBuf
- type TxManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultProposerSelection ¶
func DefaultProposerSelection( _ context.Context, h uint64, r uint32, valSet tmconsensus.ValidatorSet, ) tmconsensus.Validator
DefaultProposerSelection is the default ProposerSelectionFunc when otherwise unspecified in the ConsensusStrategyConfig.
Types ¶
type BlockAnnotation ¶
type BlockAnnotation struct { // The time that the proposer said that it proposed the block. // S suffix indicating string, to allow the Time method to exist without a name conflict. TimeS string `json:"Time"` }
BlockAnnotation is the data encoded as a block annotation. Block annotations are persisted on-chain, unlike proposal annotations which are not persisted to chain.
type ConsensusStrategy ¶
type ConsensusStrategy struct {
// contains filtered or unexported fields
}
func NewConsensusStrategy ¶
func NewConsensusStrategy( ctx context.Context, log *slog.Logger, cfg ConsensusStrategyConfig, ) *ConsensusStrategy
func (*ConsensusStrategy) ChooseProposedBlock ¶
func (c *ConsensusStrategy) ChooseProposedBlock( ctx context.Context, phs []tmconsensus.ProposedHeader, ) (string, error)
func (*ConsensusStrategy) ConsiderProposedBlocks ¶
func (c *ConsensusStrategy) ConsiderProposedBlocks( ctx context.Context, phs []tmconsensus.ProposedHeader, _ tmconsensus.ConsiderProposedBlocksReason, ) (string, error)
ConsiderProposedBlocks effectively chooses the first valid block in phs.
func (*ConsensusStrategy) DecidePrecommit ¶
func (c *ConsensusStrategy) DecidePrecommit( ctx context.Context, vs tmconsensus.VoteSummary, ) (string, error)
func (*ConsensusStrategy) EnterRound ¶
func (c *ConsensusStrategy) EnterRound( ctx context.Context, rv tmconsensus.RoundView, proposalOut chan<- tmconsensus.Proposal, ) error
func (*ConsensusStrategy) Wait ¶
func (s *ConsensusStrategy) Wait()
type ConsensusStrategyConfig ¶
type ConsensusStrategyConfig struct { // How to choose the proposer for a given round. // If nil, defaults to [DefaultProposerSelection]. ProposerSelection ProposerSelectionFunc // Needed to simulate transactions. AppManager appmanager.AppManager[transaction.Tx] // To get the pending transactions when proposing a block. // Maybe could be nil if signer is nil // and we know we will never propose a block? TxBuf *SDKTxBuf // The public key of our signer. // May be nil. SignerPubKey gcrypto.PubKey // How to provide our proposed block data to other network participants. BlockDataProvider gsbd.Provider ProposedBlockDataRetriever *PBDRetriever // The request cache indicating what block data requests are in flight // and which ones have already been completed. // Not yet entirely used. BlockDataRequestCache *gsbd.RequestCache }
ConsensusStrategyConfig is the configuration to pass to NewConsensusStrategy.
type DriverConfig ¶
type DriverConfig struct { ChainID string GenesisPath string AppManager appmanager.AppManager[transaction.Tx] Store storev2.RootStore TxStore txstore.Store InitChainRequests <-chan tmdriver.InitChainRequest FinalizeBlockRequests <-chan tmdriver.FinalizeBlockRequest LagStateUpdates <-chan tmelink.LagState TxBuffer *SDKTxBuf CatchupClient *gp2papi.CatchupClient BlockDataRequestCache *gsbd.RequestCache BlockDataStore gcstore.BlockDataStore }
type HTTPServer ¶
type HTTPServer struct {
// contains filtered or unexported fields
}
func NewHTTPServer ¶
func NewHTTPServer(ctx context.Context, log *slog.Logger, cfg HTTPServerConfig) *HTTPServer
func (*HTTPServer) Wait ¶
func (h *HTTPServer) Wait()
type HTTPServerConfig ¶
type HTTPServerConfig struct { Listener net.Listener FinalizationStore tmstore.FinalizationStore MirrorStore tmstore.MirrorStore CryptoRegistry *gcrypto.Registry Libp2pHost *tmlibp2p.Host Libp2pconn *tmlibp2p.Connection AppManager appmanager.AppManager[transaction.Tx] TxCodec transaction.Codec[transaction.Tx] Codec codec.Codec TxBuffer *SDKTxBuf }
type PBDRetriever ¶
type PBDRetriever struct {
// contains filtered or unexported fields
}
PBDRetriever, short for "Proposal Block Data" retriever, is responsible for retrieving the block data specified in proposal annotations.
func NewPBDRetriever ¶
func NewPBDRetriever( ctx context.Context, log *slog.Logger, cfg PBDRetrieverConfig, ) *PBDRetriever
func (*PBDRetriever) Wait ¶
func (r *PBDRetriever) Wait()
type PBDRetrieverConfig ¶
type PBDRetrieverConfig struct { // How to indicate availability of fetched proposed data. RequestCache *gsbd.RequestCache // How to decode transactions. Decoder transaction.Codec[transaction.Tx] // The libp2p host from which connections will be made. Host libp2phost.Host // How many worker goroutines to run. NWorkers int }
PBDRetrieverConfig is the configuration value passed to NewPBDRetriever.
type ProposalDriverAnnotation ¶
type ProposalDriverAnnotation struct { // Locations is a slice of addresses on where the proposer // expects the blodk data to be retrievable. Locations []gsbd.Location }
ProposalDriverAnnotation is the annotation to be JSON-marshaled and stored on proposed blocks, in the ConsensusStrategy.
type ProposerSelectionFunc ¶
type ProposerSelectionFunc func( ctx context.Context, height uint64, round uint32, curValSet tmconsensus.ValidatorSet, ) (choice tmconsensus.Validator)
ProposerSelectionFunc decides which validator is supposed to be proposing at a given height and round.
The ConsensusStrategy currently only inspects when deciding whether the current process should propose a block.
type SDKTxBuf ¶
SDKTxBuf is aliased to the fully qualified gtx.Buffer, just to simplify declarations elsewhere through the gserver package tree. The two long names for the generic types are unpleasant to repeat everywhere.
type TxManager ¶
type TxManager struct {
AppManager appmanager.AppManager[transaction.Tx]
}
TxManager wraps an AppManager in order to provide the callback functions needed to instantiate a gtxbuf.Buffer.
func (TxManager) AddTx ¶
func (m TxManager) AddTx( ctx context.Context, state corestore.ReaderMap, tx transaction.Tx, ) (corestore.ReaderMap, error)
AddTx uses m's AppManager to simulate the transaction against the given state. On success, it returns the new state. As of writing, AppManager.SimulateWithState does not return an error, although its signature allows for it. If that error is non-nil, it is returned wrapped. Otherwise, if the transaction result contains an error, AddTx returns that error wrapped in gtxbuf.TxInvalidError.
func (TxManager) TxDeleterFunc ¶
func (m TxManager) TxDeleterFunc( ctx context.Context, reject []transaction.Tx, ) func(tx transaction.Tx) bool
TxDeleterFunc returns a function that reports true when given a transaction with a hash identical to any transaction in the reject slice.