prepare

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 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 int64) ([][]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
	Err        error
	NumBridges int
}

BridgeTxResponse represents a response for creating 'AcknowledgeBridges' tx

func GetAcknowledgeBridgesTx

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

GetAcknowledgeBridgeTx returns a tx containing a list of `MsgAcknowledgeBridge`. The response contains an error if encoding fails.

type FundingTxResponse

type FundingTxResponse struct {
	Tx       []byte
	Err      error
	NumVotes int
}

FundingTxResponse represents a response for creating `AddPremiumVotes` tx.

func GetAddPremiumVotesTx

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

GetAddPremiumVotesTx returns a tx containing `MsgAddPremiumVotes`. The response contains an error if encoding fails.

type OperationsTxResponse

type OperationsTxResponse struct {
	Tx            []byte
	Err           error
	NumOperations int
}

OperationTxResponse represents a response for creating 'ProposedOperations' tx

func GetProposedOperationsTx

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

GetProposedOperationsTx returns a tx containing `MsgProposedOperations`. The response contains an error if encoding fails.

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  int64
	UsedBytes int64
}

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() int64

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 int64,
	bytesToAdd int64,
) 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
	Err        error
	NumMarkets int
}

PricesTxResponse represents a response for creating `UpdateMarketPrices` tx.

func GetUpdateMarketPricesTx

func GetUpdateMarketPricesTx(
	ctx sdk.Context,
	txConfig client.TxConfig,
	proposerAddress []byte,
	pricesKeeper PreparePricesKeeper,
) PricesTxResponse

GetUpdateMarketPricesTx returns a tx containing `MsgUpdateMarketPrices`. The response contains an error if encoding fails.

Jump to

Keyboard shortcuts

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