block-sdk/block/proposals/utils.go
David Terpay b9d6761776
feat(ABCI): New Proposal Struct with Associated Metadata (#126)
* new proto types for proposal info

* new proposal type

* nits

* lane input

* lint

* feat(ABCI): Deprecating `CheckOrderHandler` with new Proposal MetaData (#127)

* refactor without checkorder

* nits

* more nits

* lint

* nits

* feat(ABCI): Updating MEV lane to have no `CheckOrder` handler + testing (#128)

* updating mev lane

* nits

* preventing adding multiple bid txs in prepare

* update
2023-09-28 11:10:13 -04:00

40 lines
1.1 KiB
Go

package proposals
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// MaxUint64 is the maximum value of a uint64.
MaxUint64 = 1<<64 - 1
)
type (
// LaneLimits defines the constraints for a partial proposal. Each lane must only propose
// transactions that satisfy these constraints. Otherwise the partial proposal update will
// be rejected.
LaneLimits struct {
// MaxTxBytes is the maximum number of bytes allowed in the partial proposal.
MaxTxBytes int64
// MaxGasLimit is the maximum gas limit allowed in the partial proposal.
MaxGasLimit uint64
}
)
// GetBlockLimits retrieves the maximum number of bytes and gas limit allowed in a block.
func GetBlockLimits(ctx sdk.Context) (int64, uint64) {
blockParams := ctx.ConsensusParams().Block
// If the max gas is set to 0, then the max gas limit for the block can be infinite.
// Otherwise we use the max gas limit casted as a uint64 which is how gas limits are
// extracted from sdk.Tx's.
var maxGasLimit uint64
if maxGas := blockParams.MaxGas; maxGas > 0 {
maxGasLimit = uint64(maxGas)
} else {
maxGasLimit = MaxUint64
}
return blockParams.MaxBytes, maxGasLimit
}