ve

package
v0.0.0-...-23a414b Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2024 License: AGPL-3.0, AGPL-3.0-or-later Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanAndValidateExtCommitInfoInPrepareProposal

func CleanAndValidateExtCommitInfoInPrepareProposal(
	ctx sdk.Context,
	extCommitInfo cometabci.ExtendedCommitInfo,
	veCodec codec.VoteExtensionCodec,
	pricesKeeper PreBlockExecPricesKeeper,
	ratelimitKeeper VoteExtensionRateLimitKeeper,
	veCache *vecache.VeCache,
) (cometabci.ExtendedCommitInfo, error)

func GetMaxMarketPairs

func GetMaxMarketPairs(ctx sdk.Context, pricesKeeper PreBlockExecPricesKeeper) uint32

func IsVoteExtensionSeen

func IsVoteExtensionSeen(veCache *vecache.VeCache, consAddress string, currHeight int64) bool

func ValidateBigIntSDaiConversionRateValue

func ValidateBigIntSDaiConversionRateValue(ctx sdk.Context, sDaiConversionRate *big.Int, ratelimitKeeper VoteExtensionRateLimitKeeper) error

func ValidateExtendedCommitAgainstLastCommit

func ValidateExtendedCommitAgainstLastCommit(extCommitInfo cometabci.ExtendedCommitInfo, cmtLastCommit comet.CommitInfo) error

ValidateExtendedCommitAgainstLastCommit validates an ExtendedCommitInfo against a LastCommit. Specifically, it checks that the ExtendedCommit + LastCommit (for the same height), are consistent with each other + that they are ordered correctly (by voting power) in accordance with comet(https://github.com/cometbft/cometbft/blob/4ce0277b35f31985bbf2c25d3806a184a4510010/types/validator_set.go#L784).

func ValidateExtendedCommitInfoInProcessProposal

func ValidateExtendedCommitInfoInProcessProposal(
	ctx sdk.Context,
	height int64,
	extCommitInfo cometabci.ExtendedCommitInfo,
	veCodec codec.VoteExtensionCodec,
	pricesKeeper PreBlockExecPricesKeeper,
	ratelimitKeeper VoteExtensionRateLimitKeeper,
	validateVEConsensusInfo ValidateVEConsensusInfoFn,
) error

func ValidateMarketCountInVE

func ValidateMarketCountInVE(
	ctx sdk.Context,
	ve vetypes.DaemonVoteExtension,
	pricesKeeper PreBlockExecPricesKeeper,
) error

func ValidatePricesBytesSizeInVE

func ValidatePricesBytesSizeInVE(
	ctx sdk.Context,
	ve vetypes.DaemonVoteExtension,
) error

func ValidateSDaiConversionRateHeightInVE

func ValidateSDaiConversionRateHeightInVE(
	ctx sdk.Context,
	ratelimitKeeper VoteExtensionRateLimitKeeper,
) error

func ValidateSDaiConversionRateSizeInVE

func ValidateSDaiConversionRateSizeInVE(
	ctx sdk.Context,
	ve vetypes.DaemonVoteExtension,
) error

func ValidateSDaiConversionRateValueInVE

func ValidateSDaiConversionRateValueInVE(
	ctx sdk.Context,
	ve vetypes.DaemonVoteExtension,
	ratelimitKeeper VoteExtensionRateLimitKeeper,
) error

func ValidateVEConsensusInfo

func ValidateVEConsensusInfo(
	ctx sdk.Context,
	valStore voteweighted.ValidatorStore,
	extCommit cometabci.ExtendedCommitInfo,
) error

ValidateVoteExtensions defines a helper function for verifying vote extension signatures that may be passed or manually injected into a block proposal from a proposer in PrepareProposal. It returns an error if any signature is invalid or if unexpected vote extensions and/or signatures are found or less than 2/3 power is received.

func ValidateVEMarketsAndPrices

func ValidateVEMarketsAndPrices(
	ctx sdk.Context,
	pricesKeeper PreBlockExecPricesKeeper,
	veBytes []byte,
	voteCodec codec.VoteExtensionCodec,
) error

func ValidateVeSDaiConversionRate

func ValidateVeSDaiConversionRate(
	ctx sdk.Context,
	ratelimitKeeper VoteExtensionRateLimitKeeper,
	veBytes []byte,
	voteCodec codec.VoteExtensionCodec,
) error

Types

type ErrPanic

type ErrPanic struct {
	Err error
}

ErrPanic is an error that is returned when a panic occurs in the ABCI handler.

func (ErrPanic) Error

func (e ErrPanic) Error() string

func (ErrPanic) Label

func (e ErrPanic) Label() string

type ExtendVoteClobKeeper

type ExtendVoteClobKeeper interface {
	GetSingleMarketClobMetadata(ctx sdk.Context, clobPair clobtypes.ClobPair) clobtypes.ClobMetadata
	GetClobPair(ctx sdk.Context, id clobtypes.ClobPairId) (val clobtypes.ClobPair, found bool)
}

type ExtendVotePerpetualsKeeper

type ExtendVotePerpetualsKeeper interface {
	GetPerpetual(
		ctx sdk.Context,
		id uint32,
	) (val perptypes.Perpetual, err error)
}

type OracleClientError

type OracleClientError struct {
	Err error
}

OracleClientError is an error that is returned when the oracle client's response is invalid.

func (OracleClientError) Error

func (e OracleClientError) Error() string

func (OracleClientError) Label

func (e OracleClientError) Label() string

type PreBlockError

type PreBlockError struct {
	Err error
}

PreBlockError is an error that is returned when the pre-block simulation fails.

func (PreBlockError) Error

func (e PreBlockError) Error() string

func (PreBlockError) Label

func (e PreBlockError) Label() string

type PreBlockExecPricesKeeper

type PreBlockExecPricesKeeper interface {
	PerformStatefulPriceUpdateValidation(
		ctx sdk.Context,
		marketPriceUpdate *pricestypes.MarketPriceUpdate,
	) (isSpotValid bool, isPnlValid bool)

	UpdateSmoothedSpotPrices(
		ctx sdk.Context,
		linearInterpolateFunc func(v0 uint64, v1 uint64, ppm uint32) (uint64, error),
	) error

	GetValidMarketSpotPriceUpdates(ctx sdk.Context) []*pricestypes.MarketSpotPriceUpdate

	GetAllMarketParams(ctx sdk.Context) []pricestypes.MarketParam

	GetMarketParam(ctx sdk.Context, id uint32) (market pricestypes.MarketParam, exists bool)

	GetSmoothedSpotPrice(markedId uint32) (uint64, bool)
}

PreparePricesKeeper defines the expected Prices keeper used for `PrepareProposal`.

type TransformPricesError

type TransformPricesError struct {
	Err error
}

TransformPricesError is an error that is returned when there is a failure in attempting to transform the prices returned from the oracle server to the format expected by the validator set.

func (TransformPricesError) Error

func (e TransformPricesError) Error() string

func (TransformPricesError) Label

func (e TransformPricesError) Label() string

type VEApplierInterface

type VEApplierInterface interface {
	ApplyVE(ctx sdk.Context, txs [][]byte, writeToCache bool) error
}

type VEPricePair

type VEPricePair struct {
	SpotPrice uint64
	PnlPrice  uint64
}

type ValidateVEConsensusInfoFn

type ValidateVEConsensusInfoFn func(
	ctx sdk.Context,
	extInfo cometabci.ExtendedCommitInfo,
) error

ValidateVoteExtensionsFn defines the function for validating vote extensions. This function is not explicitly used to validate the oracle data but rather that the signed vote extensions included in the proposal are valid and provide a super-majority of vote extensions for the current block. This method is expected to be used in PrepareProposal and ProcessProposal.

func NewValidateVEConsensusInfo

func NewValidateVEConsensusInfo(validatorStore voteweighted.ValidatorStore) ValidateVEConsensusInfoFn

NewDefaultValidateVoteExtensionsFn returns a new DefaultValidateVoteExtensionsFn.

type ValidateVoteExtensionError

type ValidateVoteExtensionError struct {
	Err error
}

ValidateVoteExtensionError is an error that is returned when there is a failure in validating a vote extension.

func (ValidateVoteExtensionError) Error

func (ValidateVoteExtensionError) Label

type VoteExtensionHandler

type VoteExtensionHandler struct {
	// contains filtered or unexported fields
}

func NewVoteExtensionHandler

func NewVoteExtensionHandler(
	logger log.Logger,
	voteCodec codec.VoteExtensionCodec,
	pricesKeeper PreBlockExecPricesKeeper,
	perpetualsKeeper ExtendVotePerpetualsKeeper,
	clobKeeper ExtendVoteClobKeeper,
	rateLimitKeeper VoteExtensionRateLimitKeeper,
	sDAIEventManager sdaiserver.SDAIEventManager,
	veApplier VEApplierInterface,
) *VoteExtensionHandler

func (*VoteExtensionHandler) ExtendVoteHandler

func (h *VoteExtensionHandler) ExtendVoteHandler() sdk.ExtendVoteHandler

Returns a handler that extends pre-commit votes with the current prices pulled from the perpetually running price daemon In the case of an error, the handler will return an empty vote extension ensuring liveness in the case of a price daemon failure

func (*VoteExtensionHandler) GetVEBytes

func (h *VoteExtensionHandler) GetVEBytes(ctx sdk.Context) ([]byte, error)

func (*VoteExtensionHandler) ValidateVE

func (h *VoteExtensionHandler) ValidateVE(
	ctx sdk.Context,
	veBytes []byte,
	blockHeight int64,
) (resp *abci.ResponseVerifyVoteExtension, err error)

func (*VoteExtensionHandler) VerifyVoteExtensionHandler

func (h *VoteExtensionHandler) VerifyVoteExtensionHandler() sdk.VerifyVoteExtensionHandler

type VoteExtensionRateLimitKeeper

type VoteExtensionRateLimitKeeper interface {
	GetSDAIPrice(ctx sdk.Context) (price *big.Int, found bool)
	GetSDAILastBlockUpdated(ctx sdk.Context) (blockHeight *big.Int, found bool)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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