Documentation ¶
Index ¶
- Constants
- Variables
- func FullNodeProcessProposalHandler(txConfig client.TxConfig, bridgeKeeepr ProcessBridgeKeeper, ...) sdk.ProcessProposalHandler
- func GetAppInjectedMsgIdxMaps(numTxs int) (map[txtype]int, map[int]txtype)
- func IsDisallowClobOrderMsgInOtherTxs(targetMsg sdk.Msg) bool
- func ProcessProposalHandler(txConfig client.TxConfig, bridgeKeeper ProcessBridgeKeeper, ...) sdk.ProcessProposalHandler
- type AcknowledgeBridgesTx
- type AddPremiumVotesTx
- type MultiMsgsTx
- type OtherMsgsTx
- type ProcessBridgeKeeper
- type ProcessClobKeeper
- type ProcessPerpetualKeeper
- type ProcessPricesKeeper
- type ProcessProposalTxs
- type ProcessStakingKeeper
- type ProposedOperationsTx
- type SingleMsgTx
- type UpdateMarketPricesTx
Constants ¶
const ( ProposedOperationsTxType txtype = 1 AcknowledgeBridgesTxType txtype = 2 AddPremiumVotesTxType txtype = 3 UpdateMarketPricesTxType txtype = 4 )
const ConsensusRound = sdk.ContextKey("consensus_round")
const (
MinTxsCount = 4
)
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") )
Functions ¶
func FullNodeProcessProposalHandler ¶
func FullNodeProcessProposalHandler( txConfig client.TxConfig, bridgeKeeepr ProcessBridgeKeeper, clobKeeper ProcessClobKeeper, stakingKeeper ProcessStakingKeeper, perpetualKeeper ProcessPerpetualKeeper, pricesKeeper ProcessPricesKeeper, ) 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 GetAppInjectedMsgIdxMaps ¶
GetAppInjectedMsgIdxMaps returns two maps. The first map is `txtype` to the index where that particular `txtype` msg can be found in the block proposal's list of txs. The second map is the reverse of the first map.
func IsDisallowClobOrderMsgInOtherTxs ¶ added in v0.3.0
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, ) 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`. - 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 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) }
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) GetSettlementPpm( ctx sdk.Context, perpetualId uint32, quantums *big.Int, index *big.Int, ) ( bigNetSettlementPpm *big.Int, newFundingIndex *big.Int, err error, ) 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 UpdateSmoothedPrices( ctx sdk.Context, ) 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 // 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, pricesKeeper ProcessPricesKeeper, ) (*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 sdk.Context, consAddr sdk.ConsAddress) (validator stakingtypes.Validator, found bool)
}
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 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 (*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.