oracle

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: 16 Imported by: 8

README

Oracle PreBlock Handler

Overview

Writing vote extensions to state is possible using the SDK's PreBlocker - which allows you to modify the state before the block is executed and committed. Since the vote extensions not directly accessible from the PreBlocker, we inject the vote extensions in PrepareProposal and verify them in ProcessProposal before a block is accepted by the network.

The PreBlockHandler assumes that the vote extensions are already verified by validators in the network and are ready to be aggregated. A bad vote extension included in a proposal implies that the network has accepted a bad proposal.

Usage

To use the preblock handler, you need to initialize the preblock handler in your app.go file. By default, we encourage users to use the aggregation function defined in abci/preblock/math to aggregate the votes. This will aggregate all prices and calculate a stake-weighted median for each supported asset.

The PreBlockHandler currently only supports assets that are initialized in the oracle keeper. However, allowing any type of asset can be supported with a small modification to WritePrices (TBD whether we will support this).

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PreBlockHandler

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

PreBlockHandler is responsible for aggregating oracle data from each validator and writing the oracle data into the store before any transactions are executed/finalized for a given block.

func NewOraclePreBlockHandler

NewOraclePreBlockHandler returns a new PreBlockHandler. The handler is responsible for writing oracle data included in vote extensions to state.

func (*PreBlockHandler) PreBlocker deprecated

func (h *PreBlockHandler) PreBlocker() sdk.PreBlocker

PreBlocker is called by the base app before the block is finalized. It is responsible for aggregating oracle data from each validator and writing the oracle data to the store.

Deprecated: using PreBlocker requires wrapping module Manager's PreBlock call. This method should no longer be used. Use WrappedPreBlocker instead to handle this functionality automatically.

func (*PreBlockHandler) WrappedPreBlocker

func (h *PreBlockHandler) WrappedPreBlocker(mm *module.Manager) sdk.PreBlocker

WrappedPreBlocker is called by the base app before the block is finalized. It is responsible for calling the module manager's PreBlock method, aggregating oracle data from each validator and writing the oracle data to the store.

Jump to

Keyboard shortcuts

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