abci

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

ApplySnapshotChunk is on the state sync connection

func (*AbciApp) ChainID

func (a *AbciApp) ChainID() string

func (*AbciApp) CheckTx

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

Commit persists the state changes. This is called under mempool lock in cometbft, unlike FinalizeBlock.

func (*AbciApp) ExtendVote

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

FinalizeBlock is on the consensus connection

func (*AbciApp) Info

Info is part of the Info/Query connection.

func (*AbciApp) InitChain

func (*AbciApp) ListSnapshots

ListSnapshots is on the state sync connection

func (*AbciApp) LoadSnapshotChunk

LoadSnapshotChunk is on the state sync connection

func (*AbciApp) OfferSnapshot

OfferSnapshot is on the state sync connection

func (*AbciApp) ProcessProposal

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 (*AbciApp) SetEventBroadcaster

func (a *AbciApp) SetEventBroadcaster(fn EventBroadcaster)

func (*AbciApp) VerifyVoteExtension

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 AbciOpt

type AbciOpt func(*AbciApp)

func WithLogger

func WithLogger(logger log.Logger) AbciOpt

type AtomicCommitter added in v0.6.5

type AtomicCommitter interface {
	Begin(ctx context.Context, idempotencyKey []byte) error
	Precommit(ctx context.Context) ([]byte, error)
	Commit(ctx context.Context) error
}

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 EventBroadcaster

type EventBroadcaster func(ctx context.Context, proposer []byte) error

type KVStore added in v0.6.5

type KVStore interface {
	Get(key []byte) ([]byte, error)
	Set(key []byte, value []byte) error
}

KVStore is an interface for a basic key-value store

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL