vote_extensions

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExtendVoteHandler

type ExtendVoteHandler struct {
	SlinkyExtendVoteHandler sdk.ExtendVoteHandler
	PricesTxDecoder         process.UpdateMarketPriceTxDecoder
	PricesKeeper            PricesKeeper
}

ExtendVoteHandler is a wrapper around the Slinky ExtendVoteHandler. This wrapper is responsible for applying the newest MarketPriceUpdates in a block so that the prices to be submitted in a vote extension are determined on the latest available information.

func (*ExtendVoteHandler) ExtendVoteHandler

func (e *ExtendVoteHandler) ExtendVoteHandler() sdk.ExtendVoteHandler

ExtendVoteHandler returns a sdk.ExtendVoteHandler, responsible for the following:

  1. Decoding the x/prices MsgUpdateMarketPrices in the current block - fail on errors
  2. Validating the proposed MsgUpdateMarketPrices in accordance with the ProcessProposal check
  3. Updating the market prices in the PricesKeeper so that the GetValidMarketPriceUpdates function returns the latest available market prices
  4. Calling the Slinky ExtendVoteHandler to handle the rest of ExtendVote

See: https://github.com/dydxprotocol/slinky/blob/a5b1d3d3a2723e4746b5d588c512d7cc052dc0ff/abci/ve/vote_extension.go#L77 for the Slinky ExtendVoteHandler logic.

type NoopPriceApplier

type NoopPriceApplier struct{}

func (NoopPriceApplier) ApplyPricesFromVoteExtensions

func (n NoopPriceApplier) ApplyPricesFromVoteExtensions(
	_ sdk.Context, _ *cometabci.RequestFinalizeBlock) (map[slinkytypes.CurrencyPair]*big.Int, error)

func (NoopPriceApplier) GetPricesForValidator

func (n NoopPriceApplier) GetPricesForValidator(_ sdk.ConsAddress) map[slinkytypes.CurrencyPair]*big.Int

type OraclePrices

type OraclePrices struct {
	PricesKeeper PricesKeeper
}

OraclePrices is an implementation of the Slinky OracleClient interface. This object is responsible for requesting prices from the x/prices module, and injecting those prices into the vote-extension. The

func NewOraclePrices

func NewOraclePrices(pricesKeeper PricesKeeper) *OraclePrices

NewOraclePrices returns a new OracleClient object.

func (*OraclePrices) Prices

Prices is called in ExtendVoteHandler to determine which Prices are put into the extended commit. This method is responsible for doing the following:

  1. Get the latest prices from the x/prices module's indexPriceCache via GetValidMarketPriceUpdates
  2. Translate the response from x/prices into a QueryPricesResponse, and return it.

This method fails if:

  • The passed in context is not an sdk.Context

func (*OraclePrices) Start

func (o *OraclePrices) Start(_ context.Context) error

Start is a no-op.

func (*OraclePrices) Stop

func (o *OraclePrices) Stop() error

Stop is a no-op.

type PricesKeeper

type PricesKeeper interface {
	GetCurrencyPairFromID(ctx sdk.Context, id uint64) (cp oracletypes.CurrencyPair, found bool)
	GetValidMarketPriceUpdates(ctx sdk.Context) *pricestypes.MsgUpdateMarketPrices
	UpdateMarketPrices(
		ctx sdk.Context,
		updates []*pricestypes.MsgUpdateMarketPrices_MarketPrice,
	) (err error)
}

PricesKeeper is the expected interface for the x/price keeper used by the vote extension handlers

Jump to

Keyboard shortcuts

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