Documentation
¶
Index ¶
- Constants
- Variables
- func FullNodeProcessProposalHandler(txConfig client.TxConfig, bridgeKeeepr ProcessBridgeKeeper, ...) sdk.ProcessProposalHandler
- func IncorrectNumberUpdatesError(expected, actual int) error
- func IncorrectPriceUpdateForMarket(marketID uint32, expected, actual uint64) error
- func InvalidMarketPriceUpdateError(err error) error
- func IsDisallowClobOrderMsgInOtherTxs(targetMsg sdk.Msg) bool
- func MissingPriceUpdateForMarket(marketID uint32) error
- func ProcessProposalHandler(txConfig client.TxConfig, bridgeKeeper ProcessBridgeKeeper, ...) sdk.ProcessProposalHandler
- type AcknowledgeBridgesTx
- type AddPremiumVotesTx
- type DefaultUpdateMarketPriceTxDecoder
- type MultiMsgsTx
- type OtherMsgsTx
- type ProcessBridgeKeeper
- type ProcessClobKeeper
- type ProcessPerpetualKeeper
- type ProcessPricesKeeper
- type ProcessProposalTxs
- type ProcessStakingKeeper
- type ProposedOperationsTx
- type SingleMsgTx
- type SlinkyMarketPriceDecoder
- type UpdateMarketPriceTxDecoder
- type UpdateMarketPricesTx
Constants ¶
const ConsensusRound = sdk.ContextKey("consensus_round")
const (
ModuleName = "process_proposal"
)
Variables ¶
var ( // 1 - 99: Default. ErrDecodingTxBytes = errorsmod.Register(ModuleName, 1, "Decoding tx bytes failed") ErrMsgValidateBasic = errorsmod.Register(ModuleName, 2, "ValidateBasic failed on msg") ErrUnexpectedNumMsgs = errorsmod.Register(ModuleName, 3, "Unexpected num of msgs") ErrUnexpectedMsgType = errorsmod.Register(ModuleName, 4, "Unexpected msg type") ErrProposedPriceValidation = errorsmod.Register(ModuleName, 5, "Validation of proposed MsgUpdateMarketPrices failed") )
Functions ¶
func FullNodeProcessProposalHandler ¶
func FullNodeProcessProposalHandler( txConfig client.TxConfig, bridgeKeeepr ProcessBridgeKeeper, clobKeeper ProcessClobKeeper, stakingKeeper ProcessStakingKeeper, perpetualKeeper ProcessPerpetualKeeper, pricesTxDecoder UpdateMarketPriceTxDecoder, ) sdk.ProcessProposalHandler
FullNodeProcessProposalHandler is the `ProcessProposal` implementation for full-nodes. This implementation calculates and reports MEV metrics and always returns `abci.ResponseProcessProposal_ACCEPT`. Validators within the validator set should never use this implementation.
func IsDisallowClobOrderMsgInOtherTxs ¶
IsDisallowClobOrderMsgInOtherTxs returns true if the given msg type is not allowed to be in a proposed block as part of OtherTxs. Otherwise, returns false.
func ProcessProposalHandler ¶
func ProcessProposalHandler( txConfig client.TxConfig, bridgeKeeper ProcessBridgeKeeper, clobKeeper ProcessClobKeeper, stakingKeeper ProcessStakingKeeper, perpetualKeeper ProcessPerpetualKeeper, pricesKeeper ProcessPricesKeeper, pricesTxDecoder UpdateMarketPriceTxDecoder, ) sdk.ProcessProposalHandler
ProcessProposalHandler is responsible for ensuring that the list of txs in the proposed block are valid. Specifically, this validates:
- Tx bytes can be decoded to a valid tx.
- Txs are ordered correctly.
- Required "app-injected message" txs are included.
- No duplicate "app-injected message" txs are present (i.e. no "app-injected msg" in "other" txs).
- All messages are "valid" (i.e. `Msg.ValidateBasic` does not return errors).
- All proposed prices within `MsgUpdateMarketPrices` are valid according to non-deterministic validation.
Note: `MsgUpdateMarketPrices` is an exception to only doing stateless validation. In order for this msg to be valid, the proposed price update values are compared against the local index price. Because the outcome depends on the local index price, this validation is dependent on "in-memory state"; therefore, this check is NOT stateless. Note: stakingKeeper and perpetualKeeper are only needed for MEV calculations.
Types ¶
type AcknowledgeBridgesTx ¶
type AcknowledgeBridgesTx struct {
// contains filtered or unexported fields
}
AcknowledgeBridgesTx represents `MsgAcknowledgeBridge`s tx that can be validated.
func DecodeAcknowledgeBridgesTx ¶
func DecodeAcknowledgeBridgesTx( ctx sdk.Context, bridgeKeeper ProcessBridgeKeeper, decoder sdk.TxDecoder, txBytes []byte, ) (*AcknowledgeBridgesTx, error)
DecodeAcknowledgeBridgesTx returns a new `AcknowledgeBridgesTx` after validating the following:
- decodes the given tx bytes
- checks the msg is of expected type
If error occurs during any of the checks, returns error.
func (*AcknowledgeBridgesTx) GetMsg ¶
func (abt *AcknowledgeBridgesTx) GetMsg() sdk.Msg
GetMsg returns the underlying `MsgAcknowledgeBridges`.
func (*AcknowledgeBridgesTx) Validate ¶
func (abt *AcknowledgeBridgesTx) Validate() error
Validate returns an error if: - msg fails `ValidateBasic`. - bridge events are non empty and bridging is disabled. - first bridge event ID is not the one to be next acknowledged. - last bridge event ID has not been recognized. - a bridge event's content is not the same as in server state.
type AddPremiumVotesTx ¶
type AddPremiumVotesTx struct {
// contains filtered or unexported fields
}
AddPremiumVotesTx represents `MsgAddPremiumVotes` tx that can be validated.
func DecodeAddPremiumVotesTx ¶
func DecodeAddPremiumVotesTx(decoder sdk.TxDecoder, txBytes []byte) (*AddPremiumVotesTx, error)
DecodeAddPremiumVotesTx returns a new `AddPremiumVotesTx` after validating the following:
- decodes the given tx bytes
- checks the num of msgs in the tx matches expectations
- checks the msg is of expected type
If error occurs during any of the checks, returns error.
func (*AddPremiumVotesTx) GetMsg ¶
func (afst *AddPremiumVotesTx) GetMsg() sdk.Msg
GetMsg returns the underlying `MsgAddPremiumVotes`.
func (*AddPremiumVotesTx) Validate ¶
func (afst *AddPremiumVotesTx) Validate() error
Validate returns an error if the underlying msg fails `ValidateBasic`.
type DefaultUpdateMarketPriceTxDecoder ¶
type DefaultUpdateMarketPriceTxDecoder struct {
// contains filtered or unexported fields
}
DefaultUpdateMarketPriceTxDecoder is the default implementation of the MarketPriceDecoder interface. This implementation is expected to default MarketPriceUpdates in accordance with the bitoro process-proposal logic pre vote-extensions
func NewDefaultUpdateMarketPriceTxDecoder ¶
func NewDefaultUpdateMarketPriceTxDecoder( pk ProcessPricesKeeper, txDecoder sdk.TxDecoder) *DefaultUpdateMarketPriceTxDecoder
NewDefaultUpdateMarketPriceTxDecoder returns a new DefaultUpdateMarketPriceTxDecoder
func (*DefaultUpdateMarketPriceTxDecoder) DecodeUpdateMarketPricesTx ¶
func (mpd *DefaultUpdateMarketPriceTxDecoder) DecodeUpdateMarketPricesTx( ctx sdk.Context, txs [][]byte) (*UpdateMarketPricesTx, error)
DecodeUpdateMarketPricesTx returns a new `UpdateMarketPricesTx` after validating the following:
- decodes the given tx bytes
- checks the num of msgs in the tx matches expectations
- checks the msg is of expected type
If error occurs during any of the checks, returns error.
func (DefaultUpdateMarketPriceTxDecoder) GetTxOffset ¶
func (mpd DefaultUpdateMarketPriceTxDecoder) GetTxOffset(sdk.Context) int
GetTxOffset returns the offset that other injected txs should be placed with respect to their normally expected indices. No offset is expected for the default implementation.
type MultiMsgsTx ¶
type MultiMsgsTx interface {
// Validate checks if the underlying msgs are valid or not.
// Returns error if one of the msgs is invalid. Otherwise, returns nil.
Validate() error
// GetMsgs returns the underlying msgs in the tx.
GetMsgs() []sdk.Msg
}
MultiMsgsTx represents a tx with multiple msgs.
type OtherMsgsTx ¶
type OtherMsgsTx struct {
// contains filtered or unexported fields
}
OtherMsgsTx represents tx msgs in the "other" category that can be validated.
func DecodeOtherMsgsTx ¶
func DecodeOtherMsgsTx(decoder sdk.TxDecoder, txBytes []byte) (*OtherMsgsTx, error)
DecodeOtherMsgsTx returns a new `OtherMsgsTx` after validating the following:
- decodes the given tx bytes
- checks the num of msgs in the tx is not 0
- checks the msgs do not contain "app-injected msgs" or "internal msgs" or "unsupported msgs"
- checks the msgs do not contain "nested msgs" that fail `ValidateNestedMsg`
- checks the msgs do not contain top-level msgs that are not allowed in OtherTxs
If error occurs during any of the checks, returns error.
func (*OtherMsgsTx) GetMsgs ¶
func (omt *OtherMsgsTx) GetMsgs() []sdk.Msg
GetMsgs returns the underlying msgs in the tx.
func (*OtherMsgsTx) Validate ¶
func (omt *OtherMsgsTx) Validate() error
Validate returns an error if one of the underlying msgs fails `ValidateBasic`.
type ProcessBridgeKeeper ¶
type ProcessBridgeKeeper interface {
GetAcknowledgedEventInfo(
ctx sdk.Context,
) (acknowledgedEventInfo bridgetypes.BridgeEventInfo)
GetRecognizedEventInfo(
ctx sdk.Context,
) (recognizedEventInfo bridgetypes.BridgeEventInfo)
GetBridgeEventFromServer(ctx sdk.Context, id uint32) (event bridgetypes.BridgeEvent, found bool)
GetSafetyParams(ctx sdk.Context) (safetyParams bridgetypes.SafetyParams)
}
ProcessBridgeKeeper defines the expected bridge keeper used for `ProcessProposal`.
type ProcessClobKeeper ¶
type ProcessClobKeeper interface {
RecordMevMetricsIsEnabled() bool
RecordMevMetrics(
ctx sdk.Context,
stakingKeeper ProcessStakingKeeper,
perpetualKeeper ProcessPerpetualKeeper,
msgProposedOperations *types.MsgProposedOperations,
)
}
ProcessClobKeeper defines the expected clob keeper used for `ProcessProposal`.
type ProcessPerpetualKeeper ¶
type ProcessPerpetualKeeper interface {
MaybeProcessNewFundingTickEpoch(ctx sdk.Context)
GetPerpetual(ctx sdk.Context, id uint32) (val perptypes.Perpetual, err error)
}
ProcessPerpetualKeeper defines the expected perpetual keeper used for `ProcessProposal`.
type ProcessPricesKeeper ¶
type ProcessPricesKeeper interface {
PerformStatefulPriceUpdateValidation(
ctx sdk.Context,
marketPriceUpdates *pricestypes.MsgUpdateMarketPrices,
performNonDeterministicValidation bool,
) error
}
ProcessPricesKeeper defines the expected Prices keeper used for `ProcessProposal`.
type ProcessProposalTxs ¶
type ProcessProposalTxs struct {
// Single msg txs.
ProposedOperationsTx *ProposedOperationsTx
AcknowledgeBridgesTx *AcknowledgeBridgesTx
AddPremiumVotesTx *AddPremiumVotesTx
UpdateMarketPricesTx *UpdateMarketPricesTx // abstract over MarketPriceUpdates from VEs or default.
// Multi msgs txs.
OtherTxs []*OtherMsgsTx
}
ProcessProposalTxs is used as an intermediary struct to validate a proposed list of txs for `ProcessProposal`.
func DecodeProcessProposalTxs ¶
func DecodeProcessProposalTxs( ctx sdk.Context, decoder sdk.TxDecoder, req *abci.RequestProcessProposal, bridgeKeeper ProcessBridgeKeeper, pricesTxDecoder UpdateMarketPriceTxDecoder, ) (*ProcessProposalTxs, error)
DecodeProcessProposalTxs returns a new `processProposalTxs`.
func (*ProcessProposalTxs) Validate ¶
func (ppt *ProcessProposalTxs) Validate() error
Validate performs `ValidateBasic` on the underlying msgs that are part of the txs. Returns nil if all are valid. Otherwise, returns error.
Exception: for UpdateMarketPricesTx, we perform "in-memory stateful" validation to ensure that the new proposed prices are "valid" in comparison to index prices.
type ProcessStakingKeeper ¶
type ProcessStakingKeeper interface {
GetValidatorByConsAddr(ctx context.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, err error)
}
ProcessStakingKeeper defines the expected staking keeper used for `ProcessProposal`.
type ProposedOperationsTx ¶
type ProposedOperationsTx struct {
// contains filtered or unexported fields
}
ProposedOperationsTx represents `MsgProposedOperations` tx that can be validated.
func DecodeProposedOperationsTx ¶
func DecodeProposedOperationsTx(decoder sdk.TxDecoder, txBytes []byte) (*ProposedOperationsTx, error)
DecodeProposedOperationsTx returns a new `ProposedOperationsTx` after validating the following:
- decodes the given tx bytes
- checks the num of msgs in the tx matches expectations
- checks the msg is of expected type
If error occurs during any of the checks, returns error.
func (*ProposedOperationsTx) GetMsg ¶
func (pmot *ProposedOperationsTx) GetMsg() sdk.Msg
GetMsg returns the underlying `MsgProposedOperations`.
func (*ProposedOperationsTx) Validate ¶
func (pmot *ProposedOperationsTx) Validate() error
Validate returns an error if the underlying msg fails `ValidateBasic`.
type SingleMsgTx ¶
type SingleMsgTx interface {
// validate checks if the underlying msg is valid or not.
// Returns error if invalid. Otherwise, returns nil.
Validate() error
// getMsg returns the underlying msg in the tx.
GetMsg() sdk.Msg
}
SingleMsgTx represents a tx with a single msg.
type SlinkyMarketPriceDecoder ¶
type SlinkyMarketPriceDecoder struct {
// contains filtered or unexported fields
}
SlinkyMarketPriceDecoder wraps an existing MarketPriceDecoder with logic to verify that the MarketPriceUpdateTx was indeed derived from vote-extensions injected into the block.
func NewSlinkyMarketPriceDecoder ¶
func NewSlinkyMarketPriceDecoder( decoder UpdateMarketPriceTxDecoder, agg prices.PriceUpdateGenerator) *SlinkyMarketPriceDecoder
NewSlinkyMarketPriceDecoder returns a new SlinkyMarketPriceDecoder
func (*SlinkyMarketPriceDecoder) DecodeUpdateMarketPricesTx ¶
func (mpd *SlinkyMarketPriceDecoder) DecodeUpdateMarketPricesTx( ctx sdk.Context, txs [][]byte) (*UpdateMarketPricesTx, error)
DecodeUpdateMarketPricesTx returns a new `UpdateMarketPricesTx` after validating the following:
- the underlying decoder decodes successfully
- the UpdateMarketPricesTx follows correctly from the vote-extensions
- vote-extensions are enabled: each price per market-id is derived from the injected extended commit
- vote-extensions are disabled: no price updates are proposed
- vote-extensions are inserted into the block if necessary
If error occurs during any of the checks, returns error.
func (*SlinkyMarketPriceDecoder) GetTxOffset ¶
func (mpd *SlinkyMarketPriceDecoder) GetTxOffset(ctx sdk.Context) int
GetTxOffset returns the offset that other injected txs should be placed with respect to their normally expected indices. If vote-extensions are enabled, constants.OracleVEInjectedTxs is the expected offset, otherwise 0 is the expected offset.
type UpdateMarketPriceTxDecoder ¶
type UpdateMarketPriceTxDecoder interface {
// DecodeUpdateMarketPricesTx decodes the tx-bytes from the RequestProcessProposal and returns a MarketPriceUpdateTx.
DecodeUpdateMarketPricesTx(ctx sdk.Context, txs [][]byte) (*UpdateMarketPricesTx, error)
// GetTxOffset returns the offset that other injected txs should be placed with respect to their normally
// expected indices. This method is used to account for injected vote-extensions, or any other injected
// txs from dependencies.
GetTxOffset(ctx sdk.Context) int
}
MarketPriceDecoder is an interface for decoding market price transactions, This interface is responsible for distinguishing between logic for unmarshalling MarketPriceUpdates, between MarketPriceUpdates determined by the proposer's price-cache, and from VoteExtensions.
type UpdateMarketPricesTx ¶
type UpdateMarketPricesTx struct {
// contains filtered or unexported fields
}
UpdateMarketPricesTx represents `MsgUpdateMarketPrices` tx that can be validated.
func DecodeUpdateMarketPricesTx ¶
func DecodeUpdateMarketPricesTx( ctx sdk.Context, pricesKeeper ProcessPricesKeeper, decoder sdk.TxDecoder, txBytes []byte, ) (*UpdateMarketPricesTx, error)
DecodeAddPremiumVotesTx returns a new `UpdateMarketPricesTx` after validating the following:
- decodes the given tx bytes
- checks the num of msgs in the tx matches expectations
- checks the msg is of expected type
If error occurs during any of the checks, returns error.
func NewUpdateMarketPricesTx ¶
func NewUpdateMarketPricesTx( ctx sdk.Context, pk ProcessPricesKeeper, msg *pricestypes.MsgUpdateMarketPrices) *UpdateMarketPricesTx
func (*UpdateMarketPricesTx) GetMsg ¶
func (umpt *UpdateMarketPricesTx) GetMsg() sdk.Msg
GetMsg returns the underlying `MsgUpdateMarketPrices`.
func (*UpdateMarketPricesTx) Validate ¶
func (umpt *UpdateMarketPricesTx) Validate() error
Validate returns an error if: - the underlying msg fails `ValidateBasic` - the underlying msg values are not "valid" according to the index price.
Source Files
¶
- acknowledge_bridges.go
- default_market_price_decoder.go
- errors.go
- expected_keepers.go
- full_node_process_proposal.go
- funding_premium_votes.go
- market_price_decoder.go
- market_prices.go
- metrics.go
- other_msgs.go
- process_proposal.go
- proposed_operations.go
- slinky_market_price_decoder.go
- transactions.go
- types.go
- utils.go
- utils_disallow_msgs.go