prepare

package
v0.0.0-...-41d3419 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2025 License: AGPL-3.0, AGPL-3.0-or-later Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName = "prepare_proposal"
)

Variables

View Source
var (
	EmptyPrepareProposalResponse = abci.ResponsePrepareProposal{Txs: make([][]byte, 0)}
)

Functions

func EncodeMsgsIntoTxBytes

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

EncodeMsgsIntoTxBytes encodes the given msgs into a single transaction.

func FillRemainderWithOtherTxs

func FillRemainderWithOtherTxs(
	txSetterUtils TxSetterUtils,
	otherTxsRemainder [][]byte,
) error

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 GetFinalTxs

func GetFinalTxs(ctx sdk.Context, txs PrepareProposalTxs) ([][]byte, error)

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,
	clobKeeper PrepareClobKeeper,
	perpetualKeeper PreparePerpetualsKeeper,
	pricesKeeper ve.PreBlockExecPricesKeeper,
	ratelimitKeeper ve.VoteExtensionRateLimitKeeper,
	veCache *vecache.VeCache,
	veCodec codec.VoteExtensionCodec,
	extCommitCodec codec.ExtendedCommitCodec,
) 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 and VEs.
  • "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.

func SetOneFourthOtherTxsAndGetRemainder

func SetOneFourthOtherTxsAndGetRemainder(
	txSetterUtils TxSetterUtils,
) ([][]byte, error)

func SetVE

func SetVE(
	txSetterUtils TxSetterUtils,
	pricesKeeper ve.PreBlockExecPricesKeeper,
	ratelimitKeeper ve.VoteExtensionRateLimitKeeper,
	veCache *vecache.VeCache,
	voteCodec codec.VoteExtensionCodec,
	extCodec codec.ExtendedCommitCodec,
) error

Types

type FundingTxResponse

type FundingTxResponse struct {
	Tx       []byte
	NumVotes int
}

FundingTxResponse represents a response for creating `AddPremiumVotes` tx.

func GetAddPremiumVotesTx

func GetAddPremiumVotesTx(
	txSetterUtils TxSetterUtils,
	perpetualsKeeper PreparePerpetualsKeeper,
) (FundingTxResponse, error)

GetAddPremiumVotesTx returns a tx containing `MsgAddPremiumVotes`.

func SetPremiumVotesTx

func SetPremiumVotesTx(
	txSetterUtils TxSetterUtils,
	perpetualKeeper PreparePerpetualsKeeper,
) (FundingTxResponse, error)

type OperationsTxResponse

type OperationsTxResponse struct {
	Tx            []byte
	NumOperations int
}

OperationTxResponse represents a response for creating 'ProposedOperations' tx

func GetProposedOperationsTx

func GetProposedOperationsTx(
	txSetterUtils TxSetterUtils,
	clobKeeper PrepareClobKeeper,
) (OperationsTxResponse, error)

GetProposedOperationsTx returns a tx containing `MsgProposedOperations`.

func SetProposedOperationsTx

func SetProposedOperationsTx(
	txSetterUtils TxSetterUtils,
	clobKeeper PrepareClobKeeper,
) (OperationsTxResponse, error)

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 PrepareProposalTxs

type PrepareProposalTxs struct {
	AddPremiumVotesTx    []byte
	ProposedOperationsTx []byte
	OtherTxs             [][]byte
	ExtInfoBz            []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(veEnabled bool) ([][]byte, error)

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

func (*PrepareProposalTxs) SetAddPremiumVotesTx

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

SetAddPremiumVotesTx sets the tx used for adding premium votes.

func (*PrepareProposalTxs) SetExtInfoBz

func (t *PrepareProposalTxs) SetExtInfoBz(extInfoBz []byte) error

func (*PrepareProposalTxs) SetProposedOperationsTx

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

SetProposedOperationsTx sets the tx used for order operations.

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.

type TxSetterUtils

type TxSetterUtils struct {
	Ctx      sdk.Context
	TxConfig client.TxConfig
	Txs      *PrepareProposalTxs
	Request  *abci.RequestPrepareProposal
}

common params between tx setters

Jump to

Keyboard shortcuts

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