abci_client

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ABCI_TIMEOUT = 2 * time.Second

Variables

This section is empty.

Functions

func CreateAndStartEventBus

func CreateAndStartEventBus(logger cometlog.Logger) (*types.EventBus, error)

func CreateInitChainRequest

func CreateInitChainRequest(genesisState state.State, genesisDoc *types.GenesisDoc) *abcitypes.RequestInitChain

func UpdateState

func UpdateState(
	curState state.State,
	blockId *types.BlockID,
	blockHeader *types.Header,
	finalizeBlockRes *abcitypes.ResponseFinalizeBlock,
	validatorUpdates []*types.Validator,
) (state.State, error)

adapted from https://github.com/cometbft/cometbft/blob/9267594e0a17c01cc4a97b399ada5eaa8a734db5/state/execution.go#L478 updateState returns a new State updated according to the header and responses.

Types

type AbciClient

type AbciClient struct {
	Clients map[string]AbciCounterpartyClient // maps validator addresses to their clients

	Logger         cometlog.Logger
	CurState       state.State
	EventBus       types.EventBus
	LastBlock      *types.Block
	LastCommit     *types.ExtendedCommit
	Storage        storage.Storage
	IndexerService *txindex.IndexerService
	TxIndex        *indexerkv.TxIndex
	BlockIndex     *blockindexkv.BlockerIndexer

	// if this is true, then an error will be returned if the responses from the clients are not all equal.
	// can be used to check for nondeterminism in apps, but also slows down execution a bit,
	// though performance difference was not measured.
	ErrorOnUnequalResponses bool
	// contains filtered or unexported fields
}

AbciClient facilitates calls to the ABCI interface of multiple nodes. It also tracks the current state and a common logger.

var GlobalClient *AbciClient

func NewAbciClient

func NewAbciClient(clients map[string]AbciCounterpartyClient, logger cometlog.Logger, curState state.State, lastBlock *types.Block, lastCommit *types.ExtendedCommit, storage storage.Storage, errorOnUnequalResponses bool) *AbciClient

func (*AbciClient) CauseDoubleSign

func (a *AbciClient) CauseDoubleSign(address string) error

func (*AbciClient) CauseLightClientAttack

func (a *AbciClient) CauseLightClientAttack(address string, misbehaviourType string) error

func (*AbciClient) ConstructDuplicateVoteEvidence

func (a *AbciClient) ConstructDuplicateVoteEvidence(v *types.Validator) (*types.DuplicateVoteEvidence, error)

func (*AbciClient) ConstructLightClientAttackEvidence

func (a *AbciClient) ConstructLightClientAttackEvidence(
	v *types.Validator,
	misbehaviourType MisbehaviourType,
) (*types.LightClientAttackEvidence, error)

func (*AbciClient) CreateProposalBlock

func (a *AbciClient) CreateProposalBlock(
	proposerApp *AbciCounterpartyClient,
	proposerVal *types.Validator,
	height int64,
	curState state.State,
	lastExtCommit *types.ExtendedCommit,
	txs *types.Txs,
	misbehaviour *[]types.Evidence,
) (*types.Block, error)

Create a proposal block with the given height and proposer, and including the given tx and misbehaviour. Essentially a hollowed-out version of CreateProposalBlock in CometBFT, see https://github.com/cometbft/cometbft/blob/33d276831843854881e6365b9696ac39dda12922/state/execution.go#L101

func (*AbciClient) ExtendAndSignVote

func (a *AbciClient) ExtendAndSignVote(
	app *AbciCounterpartyClient,
	validator *types.Validator,
	valIndex int32,
	block *types.Block,
) (*types.Vote, error)

func (*AbciClient) GetCounterpartyFromAddress

func (a *AbciClient) GetCounterpartyFromAddress(address string) (*AbciCounterpartyClient, error)

func (*AbciClient) GetSigningStatus

func (a *AbciClient) GetSigningStatus(address string) (bool, error)

GetSigningStatus gets the signing status of the given address.

func (*AbciClient) GetSigningStatusMap

func (a *AbciClient) GetSigningStatusMap() map[string]bool

GetSigningStatusMap gets a copy of the signing status map that can be used for reading.

func (*AbciClient) GetTimeOffset

func (a *AbciClient) GetTimeOffset() time.Duration

func (*AbciClient) GetValidatorFromAddress

func (a *AbciClient) GetValidatorFromAddress(address string) (*types.Validator, error)

func (*AbciClient) IncrementTimeOffset

func (a *AbciClient) IncrementTimeOffset(additionalOffset time.Duration) error

func (*AbciClient) ProcessProposal

func (a *AbciClient) ProcessProposal(
	app *AbciCounterpartyClient,
	block *types.Block,
) (bool, error)

Calls ProcessProposal on a provided app, with the given block as proposed block.

func (*AbciClient) RunBlock

RunBlock runs a block with a specified transaction through the ABCI application. It calls RunBlockWithTimeAndProposer with the current time and the LastValidators.Proposer.

func (*AbciClient) RunBlockWithEvidence

func (a *AbciClient) RunBlockWithEvidence(tx *[]byte, misbehavingValidators map[*types.Validator]MisbehaviourType) (*abcitypes.ResponseCheckTx, *abcitypes.ResponseFinalizeBlock, *abcitypes.ResponseCommit, error)

RunBlockWithEvidence runs a block with a specified transaction through the ABCI application. It also produces the specified evidence for the specified misbehaving validators.

func (*AbciClient) RunBlockWithTimeAndProposer

func (a *AbciClient) RunBlockWithTimeAndProposer(
	tx *[]byte,
	blockTime time.Time,
	proposer *types.Validator,
	misbehavingValidators map[*types.Validator]MisbehaviourType,
) (*abcitypes.ResponseCheckTx, *abcitypes.ResponseFinalizeBlock, *abcitypes.ResponseCommit, error)

RunBlock runs a block with a specified transaction through the ABCI application. It calls BeginBlock, DeliverTx, EndBlock, Commit and then updates the state. RunBlock is safe for use by multiple goroutines simultaneously.

func (*AbciClient) RunEmptyBlocks

func (a *AbciClient) RunEmptyBlocks(numBlocks int) error

RunEmptyBlocks runs a specified number of empty blocks through ABCI.

func (*AbciClient) SendAbciInfo

func (a *AbciClient) SendAbciInfo() (*abcitypes.ResponseInfo, error)

func (*AbciClient) SendAbciQuery

func (a *AbciClient) SendAbciQuery(data []byte, path string, height int64, prove bool) (*abcitypes.ResponseQuery, error)

func (*AbciClient) SendCheckTx

func (a *AbciClient) SendCheckTx(tx *[]byte) (*abcitypes.ResponseCheckTx, error)

func (*AbciClient) SendCommit

func (a *AbciClient) SendCommit() (*abcitypes.ResponseCommit, error)

func (*AbciClient) SendFinalizeBlock

func (a *AbciClient) SendFinalizeBlock(
	block *types.Block,
	lastCommitInfo *abcitypes.CommitInfo,
) (*abcitypes.ResponseFinalizeBlock, error)

SendFinalizeBlock sends a FinalizeBlock request to all clients and collects the responses. The last commit of the AbciClient needs to be set when calling this.

func (*AbciClient) SendInitChain

func (a *AbciClient) SendInitChain(genesisState state.State, genesisDoc *types.GenesisDoc) error

func (*AbciClient) SetSigningStatus

func (a *AbciClient) SetSigningStatus(address string, status bool) error

func (*AbciClient) SyncApp

func (a *AbciClient) SyncApp(startHeight int64, client AbciCounterpartyClient) error

func (*AbciClient) UpdateStateFromBlock

func (a *AbciClient) UpdateStateFromBlock(
	blockId *types.BlockID,
	block *types.Block,
	finalizeBlockRes *abcitypes.ResponseFinalizeBlock,
) error

UpdateStateFromBlock updates the AbciClients state after running a block. It updates the last block height, last block ID, last block, and app hash.

func (*AbciClient) UpdateStateFromInit

func (a *AbciClient) UpdateStateFromInit(res *abcitypes.ResponseInitChain) error

type AbciCounterpartyClient

type AbciCounterpartyClient struct {
	Client           abciclient.Client
	NetworkAddress   string
	ValidatorAddress string

	PrivValidator types.PrivValidator
	// contains filtered or unexported fields
}

AbciCounterpartyClient is a wrapper around the ABCI client that is used to connect to the abci server. We keep extra information: * the address of the app * whether the app is alive * the priv validator associated with that app (i.e. its private key)

func NewAbciCounterpartyClient

func NewAbciCounterpartyClient(client abciclient.Client, networkAddress, validatorAddress string, privValidator types.PrivValidator) *AbciCounterpartyClient

NewAbciCounterpartyClient creates a new AbciCounterpartyClient. It always starts with isConnected = false. Call AbciClient.RetryDisconnectedClients to try to connect to the app.

type ClientUnreachableError

type ClientUnreachableError struct {
	Address string
}

func (*ClientUnreachableError) Error

func (e *ClientUnreachableError) Error() string

type MisbehaviourType

type MisbehaviourType int
const (
	DuplicateVote MisbehaviourType = iota
	Lunatic
	Amnesia
	Equivocation
)

Jump to

Keyboard shortcuts

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