prepare

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName = "prepare_proposal"
)

Variables

View Source
var (
	EmptyResponse = abci.ResponsePrepareProposal{Txs: [][]byte{}}
)

Functions

func EncodeMsgsIntoTxBytes

func EncodeMsgsIntoTxBytes(txConfig client.TxConfig, msgs ...sdk.Msg) ([]byte, error)

EncodeMsgsIntoTxBytes encodes the given msgs into a single transaction.

func FullNodePrepareProposalHandler

func FullNodePrepareProposalHandler() sdk.PrepareProposalHandler

FullNodePrepareProposalHandler returns an EmptyResponse and logs an error if a node running in `--non-validating-full-node` mode attempts to run PrepareProposal.

func GetGroupMsgOther

func GetGroupMsgOther(availableTxs [][]byte, maxBytes uint64) ([][]byte, [][]byte)

GetGroupMsgOther returns two separate slices of byte txs given a single slice of byte txs and max bytes. The first slice contains the first N txs where the total bytes of the N txs is <= max bytes. The second slice contains the rest of txs, if any.

func PrepareProposalHandler

func PrepareProposalHandler(
	txConfig client.TxConfig,
	bridgeKeeper PrepareBridgeKeeper,
	clobKeeper PrepareClobKeeper,
	pricesKeeper PreparePricesKeeper,
	perpetualKeeper PreparePerpetualsKeeper,
) sdk.PrepareProposalHandler

PrepareProposalHandler is responsible for preparing a block proposal that's returned to Tendermint via ABCI++.

The returned txs are gathered in the following way to fit within the given request's max bytes:

  • "Fixed" Group: Bytes=unbound. Includes price updates and premium votes.
  • "Others" Group: Bytes=25% of max bytes minus "Fixed" Group size. Includes txs in the request.
  • "Order" Group: Bytes=75% of max bytes minus "Fixed" Group size. Includes order matches.
  • If there are extra available bytes and there are more txs in "Other" group, add more txs from this group.

func RemoveDisallowMsgs

func RemoveDisallowMsgs(ctx sdk.Context, decoder sdk.TxDecoder, txs [][]byte) [][]byte

RemoveDisallowMsgs removes any txs that contain a disallowed msg.

Types

type BridgeTxResponse

type BridgeTxResponse struct {
	Tx         []byte
	NumBridges int
}

BridgeTxResponse represents a response for creating 'AcknowledgeBridges' tx

func GetAcknowledgeBridgesTx

func GetAcknowledgeBridgesTx(
	ctx sdk.Context,
	txConfig client.TxConfig,
	bridgeKeeper PrepareBridgeKeeper,
) (BridgeTxResponse, error)

GetAcknowledgeBridgeTx returns a tx containing a list of `MsgAcknowledgeBridge`.

type FundingTxResponse

type FundingTxResponse struct {
	Tx       []byte
	NumVotes int
}

FundingTxResponse represents a response for creating `AddPremiumVotes` tx.

func GetAddPremiumVotesTx

func GetAddPremiumVotesTx(
	ctx sdk.Context,
	txConfig client.TxConfig,
	perpetualsKeeper PreparePerpetualsKeeper,
) (FundingTxResponse, error)

GetAddPremiumVotesTx returns a tx containing `MsgAddPremiumVotes`.

type OperationsTxResponse

type OperationsTxResponse struct {
	Tx            []byte
	NumOperations int
}

OperationTxResponse represents a response for creating 'ProposedOperations' tx

func GetProposedOperationsTx

func GetProposedOperationsTx(
	ctx sdk.Context,
	txConfig client.TxConfig,
	clobKeeper PrepareClobKeeper,
) (OperationsTxResponse, error)

GetProposedOperationsTx returns a tx containing `MsgProposedOperations`.

type PrepareBridgeKeeper

type PrepareBridgeKeeper interface {
	GetAcknowledgeBridges(ctx sdk.Context, blockTimestamp time.Time) *bridgetypes.MsgAcknowledgeBridges
}

PrepareBridgeKeeper defines the expected Bridge keeper used for `PrepareProposal`.

type PrepareClobKeeper

type PrepareClobKeeper interface {
	GetOperations(ctx sdk.Context) *clobtypes.MsgProposedOperations
}

PrepareClobKeeper defines the expected CLOB keeper used for `PrepareProposal`.

type PreparePerpetualsKeeper

type PreparePerpetualsKeeper interface {
	GetAddPremiumVotes(ctx sdk.Context) *perpstypes.MsgAddPremiumVotes
}

PreparePerpetualsKeeper defines the expected Perpetuals keeper used for `PrepareProposal`.

type PreparePricesKeeper

type PreparePricesKeeper interface {
	GetValidMarketPriceUpdates(ctx sdk.Context) *pricestypes.MsgUpdateMarketPrices
}

PreparePricesKeeper defines the expected Prices keeper used for `PrepareProposal`.

type PrepareProposalTxs

type PrepareProposalTxs struct {
	// Transactions.
	UpdateMarketPricesTx []byte
	AddPremiumVotesTx    []byte
	ProposedOperationsTx []byte
	AcknowledgeBridgesTx []byte
	OtherTxs             [][]byte

	// Bytes.
	// In general, there's no need to check for int64 overflow given that it would require
	// exabytes of memory to hit the max int64 value in bytes.
	MaxBytes  uint64
	UsedBytes uint64
}

PrepareProposalTxs is used as an intermediary storage for transactions when creating a proposal for `PrepareProposal`.

func NewPrepareProposalTxs

func NewPrepareProposalTxs(
	req abci.RequestPrepareProposal,
) (PrepareProposalTxs, error)

NewPrepareProposalTxs returns a new `PrepareProposalTxs` given the request.

func (*PrepareProposalTxs) AddOtherTxs

func (t *PrepareProposalTxs) AddOtherTxs(allTxs [][]byte) error

AddOtherTxs adds txs to the "other" tx category.

func (*PrepareProposalTxs) GetAvailableBytes

func (t *PrepareProposalTxs) GetAvailableBytes() uint64

GetAvailableBytes returns the available bytes for the proposal.

func (*PrepareProposalTxs) GetTxsInOrder

func (t *PrepareProposalTxs) GetTxsInOrder() ([][]byte, error)

GetTxsInOrder returns a list of txs in an order that the `ProcessProposal` expects.

func (*PrepareProposalTxs) SetAcknowledgeBridgesTx

func (t *PrepareProposalTxs) SetAcknowledgeBridgesTx(tx []byte) error

SetAcknowledgeBridgesTx sets the tx used for acknowledging bridges.

func (*PrepareProposalTxs) SetAddPremiumVotesTx

func (t *PrepareProposalTxs) SetAddPremiumVotesTx(tx []byte) error

SetAddPremiumVotesTx sets the tx used for adding premium votes.

func (*PrepareProposalTxs) SetProposedOperationsTx

func (t *PrepareProposalTxs) SetProposedOperationsTx(tx []byte) error

SetProposedOperationsTx sets the tx used for order operations.

func (*PrepareProposalTxs) SetUpdateMarketPricesTx

func (t *PrepareProposalTxs) SetUpdateMarketPricesTx(tx []byte) error

SetUpdateMarketPricesTx sets the tx used for updating market prices.

func (*PrepareProposalTxs) UpdateUsedBytes

func (t *PrepareProposalTxs) UpdateUsedBytes(
	bytesToRemove uint64,
	bytesToAdd uint64,
) error

UpdateUsedBytes updates the used bytes field. This returns an error if the num used bytes exceeds the max byte limit.

type PricesTxResponse

type PricesTxResponse struct {
	Tx         []byte
	NumMarkets int
}

PricesTxResponse represents a response for creating `UpdateMarketPrices` tx.

func GetUpdateMarketPricesTx

func GetUpdateMarketPricesTx(
	ctx sdk.Context,
	txConfig client.TxConfig,
	pricesKeeper PreparePricesKeeper,
) (PricesTxResponse, error)

GetUpdateMarketPricesTx returns a tx containing `MsgUpdateMarketPrices`.

Jump to

Keyboard shortcuts

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