aggregator

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommitPricesError

type CommitPricesError struct {
	Err error
}

CommitPricesError is an error that is returned when there is a failure in committing the prices to state.

func (CommitPricesError) Error

func (e CommitPricesError) Error() string

func (CommitPricesError) Label

func (e CommitPricesError) Label() string

type DefaultVoteAggregator

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

func (*DefaultVoteAggregator) AggregateOracleVotes

func (dva *DefaultVoteAggregator) AggregateOracleVotes(ctx sdk.Context, votes []Vote) (map[connecttypes.CurrencyPair]*big.Int, error)

func (*DefaultVoteAggregator) GetPriceForValidator

func (dva *DefaultVoteAggregator) GetPriceForValidator(validator sdk.ConsAddress) map[connecttypes.CurrencyPair]*big.Int

type PriceAggregationError

type PriceAggregationError struct {
	Err error
}

PriceAggregationError is an error that is returned when there is a failure in aggregating the prices.

func (PriceAggregationError) Error

func (e PriceAggregationError) Error() string

func (PriceAggregationError) Label

func (e PriceAggregationError) Label() string

type PriceApplier

type PriceApplier interface {
	// ApplyPricesFromVoteExtensions derives the aggregate prices per asset in accordance with the given
	// vote extensions + VoteAggregator. If a price exists for an asset, it is written to state. The
	// prices aggregated from vote-extensions are returned if no errors are encountered in execution,
	// otherwise an error is returned + nil prices.
	ApplyPricesFromVoteExtensions(ctx sdk.Context, req *cometabci.RequestFinalizeBlock) (map[connecttypes.CurrencyPair]*big.Int, error)

	// GetPriceForValidator gets the prices reported by a given validator. This method depends
	// on the prices from the latest set of aggregated votes.
	GetPricesForValidator(validator sdk.ConsAddress) map[connecttypes.CurrencyPair]*big.Int
}

PriceApplier is an interface used in `ExtendVote` and `PreBlock` to apply the prices derived from the latest votes to state.

func NewOraclePriceApplier

func NewOraclePriceApplier(
	va VoteAggregator,
	ok connectabcitypes.OracleKeeper,
	voteExtensionCodec codec.VoteExtensionCodec,
	extendedCommitCodec codec.ExtendedCommitCodec,
	logger log.Logger,
) PriceApplier

NewOraclePriceApplier returns a new oraclePriceApplier.

type Vote

type Vote struct {
	// ConsAddress is the validator that submitted the vote extension.
	ConsAddress sdk.ConsAddress
	// OracleVoteExtension
	OracleVoteExtension vetypes.OracleVoteExtension
}

Vote encapsulates the validator and oracle data contained within a vote extension.

func GetOracleVotes

func GetOracleVotes(
	proposal [][]byte,
	veCodec codec.VoteExtensionCodec,
	extCommitCodec codec.ExtendedCommitCodec,
) ([]Vote, error)

GetOracleVotes returns all oracle vote extensions that were injected into the block. Note that all vote extensions included are necessarily valid at this point because the vote extensions were validated by the vote extension and proposal handlers.

type VoteAggregator

type VoteAggregator interface {
	// AggregateOracleVotes ingresses vote information which contains all
	// vote extensions each validator extended in the previous block. it is important
	// to note that
	//  1. The vote extension may be nil, in which case the validator is not providing
	//     any oracle data for the current block. This could have occurred because the
	//     validator was offline, or its local oracle service was down.
	//  2. The vote extension may contain prices updates for only a subset of currency pairs.
	//     This could have occurred because the price providers for the validator were
	//     offline, or the price providers did not provide a price update for a given
	//     currency pair.
	//
	// In order for a currency pair to be included in the final oracle price, the currency
	// pair must be provided by a super-majority (2/3+) of validators. This is enforced by the
	// price aggregator but can be replaced by the application.
	//
	// Notice: This method overwrites the VoteAggregator's local view of prices.
	AggregateOracleVotes(ctx sdk.Context, votes []Vote) (map[connecttypes.CurrencyPair]*big.Int, error)

	// GetPriceForValidator gets the prices reported by a given validator. This method depends
	// on the prices from the latest set of aggregated votes.
	GetPriceForValidator(validator sdk.ConsAddress) map[connecttypes.CurrencyPair]*big.Int
}

VoteAggregator is an interface that defines the methods for aggregating oracle votes into a set of prices. This object holds both the aggregated price resulting from a given set of votes, and the prices reported by each validator.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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