Documentation ¶
Index ¶
- Variables
- type AbciApp
- func (a *AbciApp) ApplySnapshotChunk(ctx context.Context, req *abciTypes.RequestApplySnapshotChunk) (*abciTypes.ResponseApplySnapshotChunk, error)
- func (a *AbciApp) ChainID() string
- func (a *AbciApp) CheckTx(ctx context.Context, incoming *abciTypes.RequestCheckTx) (*abciTypes.ResponseCheckTx, error)
- func (a *AbciApp) Commit(ctx context.Context, _ *abciTypes.RequestCommit) (*abciTypes.ResponseCommit, error)
- func (a *AbciApp) ExtendVote(ctx context.Context, req *abciTypes.RequestExtendVote) (*abciTypes.ResponseExtendVote, error)
- func (a *AbciApp) FinalizeBlock(ctx context.Context, req *abciTypes.RequestFinalizeBlock) (*abciTypes.ResponseFinalizeBlock, error)
- func (a *AbciApp) Info(ctx context.Context, _ *abciTypes.RequestInfo) (*abciTypes.ResponseInfo, error)
- func (a *AbciApp) InitChain(ctx context.Context, req *abciTypes.RequestInitChain) (*abciTypes.ResponseInitChain, error)
- func (a *AbciApp) ListSnapshots(ctx context.Context, req *abciTypes.RequestListSnapshots) (*abciTypes.ResponseListSnapshots, error)
- func (a *AbciApp) LoadSnapshotChunk(ctx context.Context, req *abciTypes.RequestLoadSnapshotChunk) (*abciTypes.ResponseLoadSnapshotChunk, error)
- func (a *AbciApp) OfferSnapshot(ctx context.Context, req *abciTypes.RequestOfferSnapshot) (*abciTypes.ResponseOfferSnapshot, error)
- func (a *AbciApp) PrepareProposal(ctx context.Context, req *abciTypes.RequestPrepareProposal) (*abciTypes.ResponsePrepareProposal, error)
- func (a *AbciApp) ProcessProposal(ctx context.Context, req *abciTypes.RequestProcessProposal) (*abciTypes.ResponseProcessProposal, error)
- func (a *AbciApp) Query(ctx context.Context, req *abciTypes.RequestQuery) (*abciTypes.ResponseQuery, error)
- func (a *AbciApp) SetEventBroadcaster(fn EventBroadcaster)
- func (a *AbciApp) VerifyVoteExtension(ctx context.Context, req *abciTypes.RequestVerifyVoteExtension) (*abciTypes.ResponseVerifyVoteExtension, error)
- type AbciConfig
- type AbciOpt
- type AtomicCommitter
- type ConsensusParams
- type DBBootstrapModule
- type EventBroadcaster
- type KVStore
- type SnapshotModule
- type TxApp
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTxNotFound is indicates when the a transaction was not found in the // nodes blocks or mempool. ErrTxNotFound = errors.New("transaction not found") )
Functions ¶
This section is empty.
Types ¶
type AbciApp ¶
type AbciApp struct {
// contains filtered or unexported fields
}
func NewAbciApp ¶
func NewAbciApp(cfg *AbciConfig, kv KVStore, snapshotter SnapshotModule, bootstrapper DBBootstrapModule, txRouter TxApp, consensusParams *txapp.ConsensusParams, log log.Logger) *AbciApp
func (*AbciApp) ApplySnapshotChunk ¶
func (a *AbciApp) ApplySnapshotChunk(ctx context.Context, req *abciTypes.RequestApplySnapshotChunk) (*abciTypes.ResponseApplySnapshotChunk, error)
ApplySnapshotChunk is on the state sync connection
func (*AbciApp) CheckTx ¶
func (a *AbciApp) CheckTx(ctx context.Context, incoming *abciTypes.RequestCheckTx) (*abciTypes.ResponseCheckTx, error)
CheckTx is the "Guardian of the mempool: every node runs CheckTx before letting a transaction into its local mempool". Also "The transaction may come from an external user or another node". Further "CheckTx validates the transaction against the current state of the application, for example, checking signatures and account balances, but does not apply any of the state changes described in the transaction."
This method must reject transactions that are invalid and/or may be crafted to attack the network by flooding the mempool or filling blocks with rejected transactions.
This method is also used to re-check mempool transactions after blocks are mined. This is used to *evict* previously accepted transactions that become invalid, which may happen for a variety of reason only the application can decide, such as changes in account balance and last mined nonce.
It is important to use this method rather than include failing transactions in blocks, particularly if the failure mode involves the transaction author spending no gas or achieving including in the block with little effort.
func (*AbciApp) Commit ¶
func (a *AbciApp) Commit(ctx context.Context, _ *abciTypes.RequestCommit) (*abciTypes.ResponseCommit, error)
Commit persists the state changes. This is called under mempool lock in cometbft, unlike FinalizeBlock.
func (*AbciApp) ExtendVote ¶
func (a *AbciApp) ExtendVote(ctx context.Context, req *abciTypes.RequestExtendVote) (*abciTypes.ResponseExtendVote, error)
ExtendVote creates an application specific vote extension.
- ResponseExtendVote.vote_extension is application-generated information that will be signed by CometBFT and attached to the Precommit message.
- The Application may choose to use an empty vote extension (0 length).
- The contents of RequestExtendVote correspond to the proposed block on which the consensus algorithm will send the Precommit message.
- ResponseExtendVote.vote_extension will only be attached to a non-nil Precommit message. If the consensus algorithm is to precommit nil, it will not call RequestExtendVote.
- The Application logic that creates the extension can be non-deterministic.
func (*AbciApp) FinalizeBlock ¶
func (a *AbciApp) FinalizeBlock(ctx context.Context, req *abciTypes.RequestFinalizeBlock) (*abciTypes.ResponseFinalizeBlock, error)
FinalizeBlock is on the consensus connection
func (*AbciApp) Info ¶
func (a *AbciApp) Info(ctx context.Context, _ *abciTypes.RequestInfo) (*abciTypes.ResponseInfo, error)
Info is part of the Info/Query connection.
func (*AbciApp) InitChain ¶
func (a *AbciApp) InitChain(ctx context.Context, req *abciTypes.RequestInitChain) (*abciTypes.ResponseInitChain, error)
func (*AbciApp) ListSnapshots ¶
func (a *AbciApp) ListSnapshots(ctx context.Context, req *abciTypes.RequestListSnapshots) (*abciTypes.ResponseListSnapshots, error)
ListSnapshots is on the state sync connection
func (*AbciApp) LoadSnapshotChunk ¶
func (a *AbciApp) LoadSnapshotChunk(ctx context.Context, req *abciTypes.RequestLoadSnapshotChunk) (*abciTypes.ResponseLoadSnapshotChunk, error)
LoadSnapshotChunk is on the state sync connection
func (*AbciApp) OfferSnapshot ¶
func (a *AbciApp) OfferSnapshot(ctx context.Context, req *abciTypes.RequestOfferSnapshot) (*abciTypes.ResponseOfferSnapshot, error)
OfferSnapshot is on the state sync connection
func (*AbciApp) PrepareProposal ¶
func (a *AbciApp) PrepareProposal(ctx context.Context, req *abciTypes.RequestPrepareProposal) (*abciTypes.ResponsePrepareProposal, error)
func (*AbciApp) ProcessProposal ¶
func (a *AbciApp) ProcessProposal(ctx context.Context, req *abciTypes.RequestProcessProposal) (*abciTypes.ResponseProcessProposal, error)
ProcessProposal should validate the received blocks and reject the block if: 1. transactions are not ordered by nonces 2. nonce is less than the last committed nonce for the account 3. duplicates or gaps in the nonces 4. transaction size is greater than the max_tx_bytes else accept the proposed block.
func (*AbciApp) Query ¶
func (a *AbciApp) Query(ctx context.Context, req *abciTypes.RequestQuery) (*abciTypes.ResponseQuery, error)
func (*AbciApp) SetEventBroadcaster ¶
func (a *AbciApp) SetEventBroadcaster(fn EventBroadcaster)
func (*AbciApp) VerifyVoteExtension ¶
func (a *AbciApp) VerifyVoteExtension(ctx context.Context, req *abciTypes.RequestVerifyVoteExtension) (*abciTypes.ResponseVerifyVoteExtension, error)
Verify application's vote extension data
type AbciConfig ¶
type AbciConfig struct { GenesisAppHash []byte ChainID string ApplicationVersion uint64 GenesisAllocs map[string]*big.Int GasEnabled bool }
AbciConfig includes data that defines the chain and allow the application to satisfy the ABCI Application interface.
type AtomicCommitter ¶ added in v0.6.5
type ConsensusParams ¶
type ConsensusParams interface { // VotingPeriod is the vote expiration period // for validator joins and resolutions. // We may want these to be separate in the future. VotingPeriod() int64 }
ConsensusParams returns kwil specific consensus parameters. I made this its own separate interface (instead of adding it to AbciConfig) since this should be dynamic and changeable via voting.
type DBBootstrapModule ¶
type DBBootstrapModule interface { // Offers a snapshot (metadata) to the bootstrapper and decides whether to accept the snapshot or not OfferSnapshot(snapshot *snapshots.Snapshot) error // Offers a snapshot Chunk to the bootstrapper, once all the chunks corresponding to the snapshot are received, the databases are restored from the chunks ApplySnapshotChunk(chunk []byte, index uint32) ([]uint32, snapshots.Status, error) // Signifies the end of the db restoration IsDBRestored() bool }
DBBootstrapModule is an interface for a struct that implements bootstrapping
type SnapshotModule ¶
type SnapshotModule interface { // Checks if databases are to be snapshotted at a particular height IsSnapshotDue(height uint64) bool // Starts the snapshotting process, Locking databases need to be handled outside this fn CreateSnapshot(height uint64) error // Lists all the available snapshots in the snapshotstore and returns the snapshot metadata ListSnapshots() ([]snapshots.Snapshot, error) // Returns the snapshot chunk of index chunkId at a given height LoadSnapshotChunk(height uint64, format uint32, chunkID uint32) []byte }
SnapshotModule is an interface for a struct that implements snapshotting
type TxApp ¶
type TxApp interface { // accounts -> string([]accound_identifier) : *big.Int(balance) GenesisInit(ctx context.Context, validators []*types.Validator, accounts []*types.Account, initialHeight int64) error ApplyMempool(ctx context.Context, tx *transactions.Transaction) error // Begin signals that a new block has begun. Begin(ctx context.Context) error Finalize(ctx context.Context, blockHeight int64) (apphash []byte, validatorUpgrades []*types.Validator, err error) Commit(ctx context.Context) error Execute(ctx txapp.TxContext, tx *transactions.Transaction) *txapp.TxResponse ProposerTxs(ctx context.Context, txNonce uint64, maxTxSize int64, proposerAddr []byte) ([][]byte, error) UpdateValidator(ctx context.Context, validator []byte, power int64) error GetValidators(ctx context.Context) ([]*types.Validator, error) AccountInfo(ctx context.Context, acctID []byte, getUncommitted bool) (balance *big.Int, nonce int64, err error) }
TxApp is an application that can process transactions. It has methods for beginning and ending blocks, applying transactions, and managing a mempool