types

package
v0.0.0-...-5416434 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package types is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	// ModuleName is the name of the dynamicfee module.
	ModuleName = "dynamicfee"
	// StoreKey is the store key string for the dynamicfee module.
	StoreKey = ModuleName
)

Variables

View Source
var (
	// DefaultWindow is the default window size for the sliding window
	// used to calculate the base fee. In the base EIP-1559 implementation,
	// only the previous block is considered.
	DefaultWindow uint64 = 1

	// DefaultAlpha is not used in the base EIP-1559 implementation.
	DefaultAlpha = math.LegacyMustNewDecFromStr("0.0")

	// DefaultBeta is not used in the base EIP-1559 implementation.
	DefaultBeta = math.LegacyMustNewDecFromStr("1.0")

	// DefaultGamma is not used in the base EIP-1559 implementation.
	DefaultGamma = math.LegacyMustNewDecFromStr("0.0")

	// DefaultMinBaseGasPrice is the default minimum base gas price.
	DefaultMinBaseGasPrice = math.LegacyMustNewDecFromStr("0.01")

	// DefaultTargetBlockUtilization is the default target block utilization.
	DefaultTargetBlockUtilization = math.LegacyMustNewDecFromStr("0.5")

	// DefaultMaxBlockGas is the default max block gas that is used
	// when consensus_params.block.max_gas returns 0 or -1
	DefaultMaxBlockGas uint64 = 100_000_000

	// DefaultMinLearningRate is not used in the base EIP-1559 implementation.
	DefaultMinLearningRate = math.LegacyMustNewDecFromStr("0.125")

	// DefaultMaxLearningRate is not used in the base EIP-1559 implementation.
	DefaultMaxLearningRate = math.LegacyMustNewDecFromStr("0.125")

	// DefaultFeeDenom is the Cosmos SDK default bond denom.
	DefaultFeeDenom = photontypes.Denom
)
View Source
var (
	// DefaultAIMDWindow is the default window size for the sliding window
	// used to calculate the base fee.
	DefaultAIMDWindow uint64 = 8

	// DefaultAIMDAlpha is the default alpha value for the learning
	// rate calculation. This value determines how much we want to additively
	// increase the learning rate when the target block size is exceeded.
	DefaultAIMDAlpha = math.LegacyMustNewDecFromStr("0.025")

	// DefaultAIMDBeta is the default beta value for the learning rate
	// calculation. This value determines how much we want to multiplicatively
	// decrease the learning rate when the target gas is not met.
	DefaultAIMDBeta = math.LegacyMustNewDecFromStr("0.95")

	// DefaultAIMDGamma is the default threshold for determining whether
	// to increase or decrease the learning rate. In this case, we increase
	// the learning rate if the block gas within the window is greater
	// than 0.75 or less than 0.25. Otherwise, we multiplicatively decrease
	// the learning rate.
	DefaultAIMDGamma = math.LegacyMustNewDecFromStr("0.25")

	// DefaultAIMDMinBaseGasPrice is the default minimum base gas price.
	DefaultAIMDMinBaseGasPrice = DefaultMinBaseGasPrice

	// DefaultAIMDTargetBlockUtilization is the default target block utilization.
	DefaultAIMDTargetBlockUtilization = math.LegacyMustNewDecFromStr("0.5")

	// DefaultMaxBlockGas is the default max block gas that is used
	// when consensus_params.block.max_gas returns 0 or -1
	DefaultAIMDMaxBlockGas uint64 = 100_000_000

	// DefaultAIMDMinLearningRate is the default minimum learning rate.
	DefaultAIMDMinLearningRate = math.LegacyMustNewDecFromStr("0.01")

	// DefaultAIMDMaxLearningRate is the default maximum learning rate.
	DefaultAIMDMaxLearningRate = math.LegacyMustNewDecFromStr("0.50")

	// DefaultAIMDFeeDenom is the Cosmos SDK default bond denom.
	DefaultAIMDFeeDenom = DefaultFeeDenom
)
View Source
var (
	ErrNoFeeCoins      = sdkerrors.New(ModuleName, 1, "no fee coin provided. Must provide one.")
	ErrTooManyFeeCoins = sdkerrors.New(ModuleName, 2, "too many fee coins provided. Only one fee coin may be provided")
	ErrResolverNotSet  = sdkerrors.New(ModuleName, 3, "denom resolver interface not set. Only the dynamicfee base fee denomination can be used")
	ErrMaxGasExceeded  = sdkerrors.New(ModuleName, 4, "block gas cannot exceed max block gas")
)
View Source
var (
	ErrInvalidLengthGenesis        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowGenesis          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	// KeyParams is the store key for the dynamicfee module's parameters.
	KeyParams = []byte{prefixParams}

	// KeyState is the store key for the dynamicfee module's data.
	KeyState = []byte{prefixState}

	// KeyEnabledHeight is the store key for the dynamicfee module's enabled height.
	KeyEnabledHeight = []byte{prefixEnableHeight}
)
View Source
var (
	ErrInvalidLengthParams        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowParams          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthQuery        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowQuery          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthTx        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTx          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
)
View Source
var Msg_serviceDesc = _Msg_serviceDesc
View Source
var Query_serviceDesc = _Query_serviceDesc

Functions

func GetTargetBlockGas

func GetTargetBlockGas(maxBlockGas uint64, params Params) uint64

func RegisterInterfaces

func RegisterInterfaces(registry types.InterfaceRegistry)

RegisterInterfaces registers the x/dynamicfee interfaces (messages + msg server) on the provided InterfaceRegistry.

func RegisterLegacyAminoCodec

func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the necessary x/dynamicfee interfaces (messages) on the provided LegacyAmino codec.

func RegisterMsgServer

func RegisterMsgServer(s grpc1.Server, srv MsgServer)

func RegisterQueryHandler

func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterQueryHandler registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterQueryHandlerClient

func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error

RegisterQueryHandlerClient registers the http handlers for service Query to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "QueryClient" to call the correct interceptors.

func RegisterQueryHandlerFromEndpoint

func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterQueryHandlerServer

func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error

RegisterQueryHandlerServer registers the http handlers for service Query to "mux". UnaryRPC :call QueryServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.

func RegisterQueryServer

func RegisterQueryServer(s grpc1.Server, srv QueryServer)

Types

type DenomResolver

type DenomResolver interface {
	// ConvertToDenom converts deccoin into the equivalent amount of the token denominated in denom.
	ConvertToDenom(ctx context.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error)
	// ExtraDenoms returns a list of denoms in addition of `Params.base_denom` it's possible to pay fees with
	ExtraDenoms(ctx context.Context) ([]string, error)
}

DenomResolver is an interface to convert a given token to the dynamicfee's base token.

type ErrorDenomResolver

type ErrorDenomResolver struct{}

ErrorDenomResolver is a test implementation of the DenomResolver interface. It returns an error for all coins that are not the baseDenom. NOTE: DO NOT USE THIS IN PRODUCTION

func (*ErrorDenomResolver) ConvertToDenom

func (r *ErrorDenomResolver) ConvertToDenom(_ context.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error)

ConvertToDenom returns an error for all coins that are not the denom.

func (*ErrorDenomResolver) ExtraDenoms

func (r *ErrorDenomResolver) ExtraDenoms(_ context.Context) ([]string, error)

type GasPriceRequest

type GasPriceRequest struct {
	// denom we are querying gas price in
	Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"`
}

GasPriceRequest is the request type for the Query/GasPrice RPC method.

func (*GasPriceRequest) Descriptor

func (*GasPriceRequest) Descriptor() ([]byte, []int)

func (*GasPriceRequest) GetDenom

func (m *GasPriceRequest) GetDenom() string

func (*GasPriceRequest) Marshal

func (m *GasPriceRequest) Marshal() (dAtA []byte, err error)

func (*GasPriceRequest) MarshalTo

func (m *GasPriceRequest) MarshalTo(dAtA []byte) (int, error)

func (*GasPriceRequest) MarshalToSizedBuffer

func (m *GasPriceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GasPriceRequest) ProtoMessage

func (*GasPriceRequest) ProtoMessage()

func (*GasPriceRequest) Reset

func (m *GasPriceRequest) Reset()

func (*GasPriceRequest) Size

func (m *GasPriceRequest) Size() (n int)

func (*GasPriceRequest) String

func (m *GasPriceRequest) String() string

func (*GasPriceRequest) Unmarshal

func (m *GasPriceRequest) Unmarshal(dAtA []byte) error

func (*GasPriceRequest) XXX_DiscardUnknown

func (m *GasPriceRequest) XXX_DiscardUnknown()

func (*GasPriceRequest) XXX_Marshal

func (m *GasPriceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GasPriceRequest) XXX_Merge

func (m *GasPriceRequest) XXX_Merge(src proto.Message)

func (*GasPriceRequest) XXX_Size

func (m *GasPriceRequest) XXX_Size() int

func (*GasPriceRequest) XXX_Unmarshal

func (m *GasPriceRequest) XXX_Unmarshal(b []byte) error

type GasPriceResponse

type GasPriceResponse struct {
	Price types.DecCoin `protobuf:"bytes,1,opt,name=price,proto3" json:"price"`
}

GasPriceResponse is the response type for the Query/GasPrice RPC method. Returns a gas price in specified denom.

func (*GasPriceResponse) Descriptor

func (*GasPriceResponse) Descriptor() ([]byte, []int)

func (*GasPriceResponse) GetPrice

func (m *GasPriceResponse) GetPrice() types.DecCoin

func (*GasPriceResponse) Marshal

func (m *GasPriceResponse) Marshal() (dAtA []byte, err error)

func (*GasPriceResponse) MarshalTo

func (m *GasPriceResponse) MarshalTo(dAtA []byte) (int, error)

func (*GasPriceResponse) MarshalToSizedBuffer

func (m *GasPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GasPriceResponse) ProtoMessage

func (*GasPriceResponse) ProtoMessage()

func (*GasPriceResponse) Reset

func (m *GasPriceResponse) Reset()

func (*GasPriceResponse) Size

func (m *GasPriceResponse) Size() (n int)

func (*GasPriceResponse) String

func (m *GasPriceResponse) String() string

func (*GasPriceResponse) Unmarshal

func (m *GasPriceResponse) Unmarshal(dAtA []byte) error

func (*GasPriceResponse) XXX_DiscardUnknown

func (m *GasPriceResponse) XXX_DiscardUnknown()

func (*GasPriceResponse) XXX_Marshal

func (m *GasPriceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GasPriceResponse) XXX_Merge

func (m *GasPriceResponse) XXX_Merge(src proto.Message)

func (*GasPriceResponse) XXX_Size

func (m *GasPriceResponse) XXX_Size() int

func (*GasPriceResponse) XXX_Unmarshal

func (m *GasPriceResponse) XXX_Unmarshal(b []byte) error

type GasPricesRequest

type GasPricesRequest struct {
}

GasPriceRequest is the request type for the Query/GasPrices RPC method.

func (*GasPricesRequest) Descriptor

func (*GasPricesRequest) Descriptor() ([]byte, []int)

func (*GasPricesRequest) Marshal

func (m *GasPricesRequest) Marshal() (dAtA []byte, err error)

func (*GasPricesRequest) MarshalTo

func (m *GasPricesRequest) MarshalTo(dAtA []byte) (int, error)

func (*GasPricesRequest) MarshalToSizedBuffer

func (m *GasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GasPricesRequest) ProtoMessage

func (*GasPricesRequest) ProtoMessage()

func (*GasPricesRequest) Reset

func (m *GasPricesRequest) Reset()

func (*GasPricesRequest) Size

func (m *GasPricesRequest) Size() (n int)

func (*GasPricesRequest) String

func (m *GasPricesRequest) String() string

func (*GasPricesRequest) Unmarshal

func (m *GasPricesRequest) Unmarshal(dAtA []byte) error

func (*GasPricesRequest) XXX_DiscardUnknown

func (m *GasPricesRequest) XXX_DiscardUnknown()

func (*GasPricesRequest) XXX_Marshal

func (m *GasPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GasPricesRequest) XXX_Merge

func (m *GasPricesRequest) XXX_Merge(src proto.Message)

func (*GasPricesRequest) XXX_Size

func (m *GasPricesRequest) XXX_Size() int

func (*GasPricesRequest) XXX_Unmarshal

func (m *GasPricesRequest) XXX_Unmarshal(b []byte) error

type GasPricesResponse

type GasPricesResponse struct {
	Prices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=prices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"prices"`
}

GasPricesResponse is the response type for the Query/GasPrices RPC method. Returns a gas price in all available denoms.

func (*GasPricesResponse) Descriptor

func (*GasPricesResponse) Descriptor() ([]byte, []int)

func (*GasPricesResponse) GetPrices

func (*GasPricesResponse) Marshal

func (m *GasPricesResponse) Marshal() (dAtA []byte, err error)

func (*GasPricesResponse) MarshalTo

func (m *GasPricesResponse) MarshalTo(dAtA []byte) (int, error)

func (*GasPricesResponse) MarshalToSizedBuffer

func (m *GasPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GasPricesResponse) ProtoMessage

func (*GasPricesResponse) ProtoMessage()

func (*GasPricesResponse) Reset

func (m *GasPricesResponse) Reset()

func (*GasPricesResponse) Size

func (m *GasPricesResponse) Size() (n int)

func (*GasPricesResponse) String

func (m *GasPricesResponse) String() string

func (*GasPricesResponse) Unmarshal

func (m *GasPricesResponse) Unmarshal(dAtA []byte) error

func (*GasPricesResponse) XXX_DiscardUnknown

func (m *GasPricesResponse) XXX_DiscardUnknown()

func (*GasPricesResponse) XXX_Marshal

func (m *GasPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GasPricesResponse) XXX_Merge

func (m *GasPricesResponse) XXX_Merge(src proto.Message)

func (*GasPricesResponse) XXX_Size

func (m *GasPricesResponse) XXX_Size() int

func (*GasPricesResponse) XXX_Unmarshal

func (m *GasPricesResponse) XXX_Unmarshal(b []byte) error

type GenesisState

type GenesisState struct {
	// Params are the parameters for the dynamicfee module. These parameters
	// can be utilized to implement both the base EIP-1559 dynamic fee pricing
	// and the AIMD EIP-1559 dynamic fee pricing.
	Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
	// State contains the current state of the AIMD dynamic fee pricer.
	State State `protobuf:"bytes,2,opt,name=state,proto3" json:"state"`
}

GenesisState defines the dynamicfee module's genesis state.

func DefaultAIMDGenesisState

func DefaultAIMDGenesisState() *GenesisState

DefaultAIMDGenesisState returns a default genesis state that implements the AIMD EIP-1559 dynamic fee pricing implementation.

func DefaultGenesisState

func DefaultGenesisState() *GenesisState

DefaultGenesisState returns a default genesis state that implements the EIP-1559 dynamic fee pricing implementation without the AIMD learning rate adjustment algorithm.

func GetGenesisStateFromAppState

func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState

GetGenesisStateFromAppState returns x/dynamicfee GenesisState given raw application genesis state.

func NewGenesisState

func NewGenesisState(
	params Params,
	state State,
) *GenesisState

NewGenesisState returns a new genesis state for the module.

func (*GenesisState) Descriptor

func (*GenesisState) Descriptor() ([]byte, []int)

func (*GenesisState) GetParams

func (m *GenesisState) GetParams() Params

func (*GenesisState) GetState

func (m *GenesisState) GetState() State

func (*GenesisState) Marshal

func (m *GenesisState) Marshal() (dAtA []byte, err error)

func (*GenesisState) MarshalTo

func (m *GenesisState) MarshalTo(dAtA []byte) (int, error)

func (*GenesisState) MarshalToSizedBuffer

func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*GenesisState) ProtoMessage

func (*GenesisState) ProtoMessage()

func (*GenesisState) Reset

func (m *GenesisState) Reset()

func (*GenesisState) Size

func (m *GenesisState) Size() (n int)

func (*GenesisState) String

func (m *GenesisState) String() string

func (*GenesisState) Unmarshal

func (m *GenesisState) Unmarshal(dAtA []byte) error

func (*GenesisState) ValidateBasic

func (gs *GenesisState) ValidateBasic() error

ValidateBasic performs basic validation of the genesis state data returning an error for any failed validation criteria.

func (*GenesisState) XXX_DiscardUnknown

func (m *GenesisState) XXX_DiscardUnknown()

func (*GenesisState) XXX_Marshal

func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*GenesisState) XXX_Merge

func (m *GenesisState) XXX_Merge(src proto.Message)

func (*GenesisState) XXX_Size

func (m *GenesisState) XXX_Size() int

func (*GenesisState) XXX_Unmarshal

func (m *GenesisState) XXX_Unmarshal(b []byte) error

type MsgClient

type MsgClient interface {
	// UpdateParams defines a method for updating the dynamicfee module
	// parameters.
	UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}

MsgClient is the client API for Msg service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewMsgClient

func NewMsgClient(cc grpc1.ClientConn) MsgClient

type MsgServer

type MsgServer interface {
	// UpdateParams defines a method for updating the dynamicfee module
	// parameters.
	UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
}

MsgServer is the server API for Msg service.

type MsgUpdateParams

type MsgUpdateParams struct {
	// Authority defines the authority that is updating the dynamicfee module
	// parameters.
	Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
	// Params defines the new parameters for the dynamicfee module.
	Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
}

MsgUpdateParams defines the sdk.Msg/UpdateParams request type. It contains the new parameters for the dynamicfee module.

func NewMsgUpdateParams

func NewMsgUpdateParams(authority string, params Params) MsgUpdateParams

NewMsgUpdateParams returns a new message to update the x/dynamicfee module's parameters.

func (*MsgUpdateParams) Descriptor

func (*MsgUpdateParams) Descriptor() ([]byte, []int)

func (*MsgUpdateParams) GetAuthority

func (m *MsgUpdateParams) GetAuthority() string

func (*MsgUpdateParams) GetParams

func (m *MsgUpdateParams) GetParams() Params

func (*MsgUpdateParams) GetSigners

func (m *MsgUpdateParams) GetSigners() []sdk.AccAddress

GetSigners implements GetSigners for the msg.

func (*MsgUpdateParams) Marshal

func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error)

func (*MsgUpdateParams) MarshalTo

func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error)

func (*MsgUpdateParams) MarshalToSizedBuffer

func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgUpdateParams) ProtoMessage

func (*MsgUpdateParams) ProtoMessage()

func (*MsgUpdateParams) Reset

func (m *MsgUpdateParams) Reset()

func (*MsgUpdateParams) Size

func (m *MsgUpdateParams) Size() (n int)

func (*MsgUpdateParams) String

func (m *MsgUpdateParams) String() string

func (*MsgUpdateParams) Unmarshal

func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error

func (*MsgUpdateParams) ValidateBasic

func (m *MsgUpdateParams) ValidateBasic() error

ValidateBasic determines whether the information in the message is formatted correctly, specifically whether the authority is a valid acc-address.

func (*MsgUpdateParams) XXX_DiscardUnknown

func (m *MsgUpdateParams) XXX_DiscardUnknown()

func (*MsgUpdateParams) XXX_Marshal

func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgUpdateParams) XXX_Merge

func (m *MsgUpdateParams) XXX_Merge(src proto.Message)

func (*MsgUpdateParams) XXX_Size

func (m *MsgUpdateParams) XXX_Size() int

func (*MsgUpdateParams) XXX_Unmarshal

func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error

type MsgUpdateParamsResponse

type MsgUpdateParamsResponse struct {
}

MsgUpdateParamsResponse defines the response structure for executing a MsgUpdateParams message.

func (*MsgUpdateParamsResponse) Descriptor

func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int)

func (*MsgUpdateParamsResponse) Marshal

func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error)

func (*MsgUpdateParamsResponse) MarshalTo

func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error)

func (*MsgUpdateParamsResponse) MarshalToSizedBuffer

func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgUpdateParamsResponse) ProtoMessage

func (*MsgUpdateParamsResponse) ProtoMessage()

func (*MsgUpdateParamsResponse) Reset

func (m *MsgUpdateParamsResponse) Reset()

func (*MsgUpdateParamsResponse) Size

func (m *MsgUpdateParamsResponse) Size() (n int)

func (*MsgUpdateParamsResponse) String

func (m *MsgUpdateParamsResponse) String() string

func (*MsgUpdateParamsResponse) Unmarshal

func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error

func (*MsgUpdateParamsResponse) XXX_DiscardUnknown

func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown()

func (*MsgUpdateParamsResponse) XXX_Marshal

func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgUpdateParamsResponse) XXX_Merge

func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message)

func (*MsgUpdateParamsResponse) XXX_Size

func (m *MsgUpdateParamsResponse) XXX_Size() int

func (*MsgUpdateParamsResponse) XXX_Unmarshal

func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error

type Params

type Params struct {
	// Alpha is the amount we additively increase the learning rate
	// when it is above or below the target +/- threshold.
	//
	// Must be > 0.
	Alpha cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=alpha,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"alpha"`
	// Beta is the amount we multiplicatively decrease the learning rate
	// when it is within the target +/- threshold.
	//
	// Must be [0, 1].
	Beta cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=beta,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"beta"`
	// Gamma is the threshold for the learning rate. If the learning rate is
	// above or below the target +/- threshold, we additively increase the
	// learning rate by Alpha. Otherwise, we multiplicatively decrease the
	// learning rate by Beta.
	//
	// Must be [0, 0.5].
	Gamma cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=gamma,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"gamma"`
	// MinBaseGasPrice determines the initial gas price of the module and the
	// global minimum for the network.
	MinBaseGasPrice cosmossdk_io_math.LegacyDec `` /* 139-byte string literal not displayed */
	// TargetBlockUtilization is the target block utilization expressed as a
	// decimal value between 0 and 1. It is the target percentage utilization
	// of the block in relation to the consensus_params.block.max_gas parameter.
	TargetBlockUtilization cosmossdk_io_math.LegacyDec `` /* 158-byte string literal not displayed */
	// DefaultMaxBlockGas is the default max block gas.
	// This parameter is used by the dynamicfee module
	// in the case consensus_params.block.max_gas returns 0 or -1.
	DefaultMaxBlockGas uint64 `protobuf:"varint,7,opt,name=default_max_block_gas,json=defaultMaxBlockGas,proto3" json:"default_max_block_gas,omitempty"`
	// MinLearningRate is the lower bound for the learning rate.
	MinLearningRate cosmossdk_io_math.LegacyDec `` /* 137-byte string literal not displayed */
	// MaxLearningRate is the upper bound for the learning rate.
	MaxLearningRate cosmossdk_io_math.LegacyDec `` /* 137-byte string literal not displayed */
	// Window defines the window size for calculating an adaptive learning rate
	// over a moving window of blocks.
	Window uint64 `protobuf:"varint,10,opt,name=window,proto3" json:"window,omitempty"`
	// FeeDenom is the denom that will be used for all fee payments.
	FeeDenom string `protobuf:"bytes,11,opt,name=fee_denom,json=feeDenom,proto3" json:"fee_denom,omitempty"`
	// Enabled is a boolean that determines whether the EIP1559 dynamic fee
	// pricing is enabled.
	Enabled bool `protobuf:"varint,12,opt,name=enabled,proto3" json:"enabled,omitempty"`
}

Params contains the required set of parameters for the EIP1559 dynamic fee pricing implementation.

func DefaultAIMDParams

func DefaultAIMDParams() Params

DefaultAIMDParams returns a default set of parameters that implements the AIMD EIP-1559 dynamic fee pricing implementation. These parameters allow for the learning rate to be dynamically adjusted based on the block gas within the window.

func DefaultParams

func DefaultParams() Params

DefaultParams returns a default set of parameters that implements the EIP-1559 dynamic fee pricing implementation without the AIMD learning rate adjustment algorithm.

func NewParams

func NewParams(
	window uint64,
	alpha math.LegacyDec,
	beta math.LegacyDec,
	gamma math.LegacyDec,
	minBaseGasPrice math.LegacyDec,
	targetBlockUtilization math.LegacyDec,
	defaultMaxBlockGas uint64,
	minLearingRate math.LegacyDec,
	maxLearningRate math.LegacyDec,
	feeDenom string,
	enabled bool,
) Params

NewParams instantiates a new EIP-1559 Params object. This params object is utilized to implement both the base EIP-1559 fee and AIMD EIP-1559 dynamic fee pricing implementations.

func (*Params) Descriptor

func (*Params) Descriptor() ([]byte, []int)

func (*Params) GetDefaultMaxBlockGas

func (m *Params) GetDefaultMaxBlockGas() uint64

func (*Params) GetEnabled

func (m *Params) GetEnabled() bool

func (*Params) GetFeeDenom

func (m *Params) GetFeeDenom() string

func (*Params) GetWindow

func (m *Params) GetWindow() uint64

func (*Params) Marshal

func (m *Params) Marshal() (dAtA []byte, err error)

func (*Params) MarshalTo

func (m *Params) MarshalTo(dAtA []byte) (int, error)

func (*Params) MarshalToSizedBuffer

func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Params) ProtoMessage

func (*Params) ProtoMessage()

func (*Params) Reset

func (m *Params) Reset()

func (*Params) Size

func (m *Params) Size() (n int)

func (*Params) String

func (m *Params) String() string

func (*Params) Unmarshal

func (m *Params) Unmarshal(dAtA []byte) error

func (*Params) ValidateBasic

func (p *Params) ValidateBasic() error

ValidateBasic performs basic validation on the parameters.

func (*Params) XXX_DiscardUnknown

func (m *Params) XXX_DiscardUnknown()

func (*Params) XXX_Marshal

func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Params) XXX_Merge

func (m *Params) XXX_Merge(src proto.Message)

func (*Params) XXX_Size

func (m *Params) XXX_Size() int

func (*Params) XXX_Unmarshal

func (m *Params) XXX_Unmarshal(b []byte) error

type ParamsRequest

type ParamsRequest struct {
}

ParamsRequest is the request type for the Query/Params RPC method.

func (*ParamsRequest) Descriptor

func (*ParamsRequest) Descriptor() ([]byte, []int)

func (*ParamsRequest) Marshal

func (m *ParamsRequest) Marshal() (dAtA []byte, err error)

func (*ParamsRequest) MarshalTo

func (m *ParamsRequest) MarshalTo(dAtA []byte) (int, error)

func (*ParamsRequest) MarshalToSizedBuffer

func (m *ParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ParamsRequest) ProtoMessage

func (*ParamsRequest) ProtoMessage()

func (*ParamsRequest) Reset

func (m *ParamsRequest) Reset()

func (*ParamsRequest) Size

func (m *ParamsRequest) Size() (n int)

func (*ParamsRequest) String

func (m *ParamsRequest) String() string

func (*ParamsRequest) Unmarshal

func (m *ParamsRequest) Unmarshal(dAtA []byte) error

func (*ParamsRequest) XXX_DiscardUnknown

func (m *ParamsRequest) XXX_DiscardUnknown()

func (*ParamsRequest) XXX_Marshal

func (m *ParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ParamsRequest) XXX_Merge

func (m *ParamsRequest) XXX_Merge(src proto.Message)

func (*ParamsRequest) XXX_Size

func (m *ParamsRequest) XXX_Size() int

func (*ParamsRequest) XXX_Unmarshal

func (m *ParamsRequest) XXX_Unmarshal(b []byte) error

type ParamsResponse

type ParamsResponse struct {
	Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
}

ParamsResponse is the response type for the Query/Params RPC method.

func (*ParamsResponse) Descriptor

func (*ParamsResponse) Descriptor() ([]byte, []int)

func (*ParamsResponse) GetParams

func (m *ParamsResponse) GetParams() Params

func (*ParamsResponse) Marshal

func (m *ParamsResponse) Marshal() (dAtA []byte, err error)

func (*ParamsResponse) MarshalTo

func (m *ParamsResponse) MarshalTo(dAtA []byte) (int, error)

func (*ParamsResponse) MarshalToSizedBuffer

func (m *ParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ParamsResponse) ProtoMessage

func (*ParamsResponse) ProtoMessage()

func (*ParamsResponse) Reset

func (m *ParamsResponse) Reset()

func (*ParamsResponse) Size

func (m *ParamsResponse) Size() (n int)

func (*ParamsResponse) String

func (m *ParamsResponse) String() string

func (*ParamsResponse) Unmarshal

func (m *ParamsResponse) Unmarshal(dAtA []byte) error

func (*ParamsResponse) XXX_DiscardUnknown

func (m *ParamsResponse) XXX_DiscardUnknown()

func (*ParamsResponse) XXX_Marshal

func (m *ParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ParamsResponse) XXX_Merge

func (m *ParamsResponse) XXX_Merge(src proto.Message)

func (*ParamsResponse) XXX_Size

func (m *ParamsResponse) XXX_Size() int

func (*ParamsResponse) XXX_Unmarshal

func (m *ParamsResponse) XXX_Unmarshal(b []byte) error

type QueryClient

type QueryClient interface {
	// Params returns the current dynamicfee module parameters.
	Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error)
	// State returns the current dynamicfee module state.
	State(ctx context.Context, in *StateRequest, opts ...grpc.CallOption) (*StateResponse, error)
	// GasPrice returns the current dynamicfee module gas price
	// for specified denom.
	GasPrice(ctx context.Context, in *GasPriceRequest, opts ...grpc.CallOption) (*GasPriceResponse, error)
	// GasPrices returns the current dynamicfee module list of gas prices
	// in all available denoms.
	GasPrices(ctx context.Context, in *GasPricesRequest, opts ...grpc.CallOption) (*GasPricesResponse, error)
}

QueryClient is the client API for Query service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewQueryClient

func NewQueryClient(cc grpc1.ClientConn) QueryClient

type QueryServer

type QueryServer interface {
	// Params returns the current dynamicfee module parameters.
	Params(context.Context, *ParamsRequest) (*ParamsResponse, error)
	// State returns the current dynamicfee module state.
	State(context.Context, *StateRequest) (*StateResponse, error)
	// GasPrice returns the current dynamicfee module gas price
	// for specified denom.
	GasPrice(context.Context, *GasPriceRequest) (*GasPriceResponse, error)
	// GasPrices returns the current dynamicfee module list of gas prices
	// in all available denoms.
	GasPrices(context.Context, *GasPricesRequest) (*GasPricesResponse, error)
}

QueryServer is the server API for Query service.

type State

type State struct {
	// BaseGasPrice is the current base fee. This is denominated in the fee per
	// gas unit.
	BaseGasPrice cosmossdk_io_math.LegacyDec `` /* 128-byte string literal not displayed */
	// LearningRate is the current learning rate.
	LearningRate cosmossdk_io_math.LegacyDec `` /* 126-byte string literal not displayed */
	// Window contains a list of the last blocks' gas values. This is used
	// to calculate the next base fee. This stores the number of units of gas
	// consumed per block.
	Window []uint64 `protobuf:"varint,3,rep,packed,name=window,proto3" json:"window,omitempty"`
	// Index is the index of the current block in the block gas window.
	Index uint64 `protobuf:"varint,4,opt,name=index,proto3" json:"index,omitempty"`
}

State is utilized to track the current state of the dynamic fee pricer. This includes the current base fee, learning rate, and block gas within the specified AIMD window.

func DefaultAIMDState

func DefaultAIMDState() State

DefaultAIMDState returns the default state for the AIMD EIP-1559 dynamic fee pricing implementation. This implementation uses a sliding window to track the block gas and dynamically adjusts the learning rate based on the gas within the window.

func DefaultState

func DefaultState() State

DefaultState returns the default state for the EIP-1559 dynamic fee pricing implementation without the AIMD learning rate adjustment algorithm.

func NewState

func NewState(
	windowSize uint64,
	baseGasPrice math.LegacyDec,
	learningRate math.LegacyDec,
) State

NewState instantiates a new dynamicfee state instance. This is utilized to implement both the base EIP-1559 dynamic fee pricing implementation and the AIMD EIP-1559 dynamic fee pricing implementation. Note that on init, you initialize both the minimum and current base gas price to the same value.

func (*State) Descriptor

func (*State) Descriptor() ([]byte, []int)

func (*State) GetAverageGas

func (s *State) GetAverageGas(maxBlockGas uint64) math.LegacyDec

GetAverageGas returns the average gas of the block window.

func (*State) GetIndex

func (m *State) GetIndex() uint64

func (*State) GetNetGas

func (s *State) GetNetGas(maxBlockGas uint64, params Params) math.Int

GetNetGas returns the net gas of the block window.

func (*State) GetWindow

func (m *State) GetWindow() []uint64

func (*State) IncrementHeight

func (s *State) IncrementHeight()

IncrementHeight increments the current height of the state.

func (*State) Marshal

func (m *State) Marshal() (dAtA []byte, err error)

func (*State) MarshalTo

func (m *State) MarshalTo(dAtA []byte) (int, error)

func (*State) MarshalToSizedBuffer

func (m *State) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*State) ProtoMessage

func (*State) ProtoMessage()

func (*State) Reset

func (m *State) Reset()

func (*State) Size

func (m *State) Size() (n int)

func (*State) String

func (m *State) String() string

func (*State) Unmarshal

func (m *State) Unmarshal(dAtA []byte) error

func (*State) Update

func (s *State) Update(gas, maxBlockGas uint64) error

Update updates the block gas for the current height with the given transaction gas i.e. gas limit.

func (*State) UpdateBaseGasPrice

func (s *State) UpdateBaseGasPrice(logger log.Logger, params Params, maxBlockGas uint64) (gasPrice math.LegacyDec)

UpdateBaseGasPrice updates the learning rate and base gas price based on the AIMD learning rate adjustment algorithm. The learning rate is updated based on the average gas of the block window. The base gas price is update using the new learning rate. Please see the EIP-1559 specification for more details.

func (*State) UpdateLearningRate

func (s *State) UpdateLearningRate(params Params, maxBlockGas uint64) (lr math.LegacyDec)

UpdateLearningRate updates the learning rate based on the AIMD learning rate adjustment algorithm. The learning rate is updated based on the average gas of the block window. There are two cases that can occur:

  1. The average gas is above the target threshold. In this case, the learning rate is increased by the alpha parameter. This occurs when blocks are nearly full or empty.
  2. The average gas is below the target threshold. In this case, the learning rate is decreased by the beta parameter. This occurs when blocks are relatively close to the target block gas.

For more details, please see the EIP-1559 specification.

func (*State) ValidateBasic

func (s *State) ValidateBasic() error

ValidateBasic performs basic validation on the state.

func (*State) XXX_DiscardUnknown

func (m *State) XXX_DiscardUnknown()

func (*State) XXX_Marshal

func (m *State) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*State) XXX_Merge

func (m *State) XXX_Merge(src proto.Message)

func (*State) XXX_Size

func (m *State) XXX_Size() int

func (*State) XXX_Unmarshal

func (m *State) XXX_Unmarshal(b []byte) error

type StateRequest

type StateRequest struct {
}

StateRequest is the request type for the Query/State RPC method.

func (*StateRequest) Descriptor

func (*StateRequest) Descriptor() ([]byte, []int)

func (*StateRequest) Marshal

func (m *StateRequest) Marshal() (dAtA []byte, err error)

func (*StateRequest) MarshalTo

func (m *StateRequest) MarshalTo(dAtA []byte) (int, error)

func (*StateRequest) MarshalToSizedBuffer

func (m *StateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*StateRequest) ProtoMessage

func (*StateRequest) ProtoMessage()

func (*StateRequest) Reset

func (m *StateRequest) Reset()

func (*StateRequest) Size

func (m *StateRequest) Size() (n int)

func (*StateRequest) String

func (m *StateRequest) String() string

func (*StateRequest) Unmarshal

func (m *StateRequest) Unmarshal(dAtA []byte) error

func (*StateRequest) XXX_DiscardUnknown

func (m *StateRequest) XXX_DiscardUnknown()

func (*StateRequest) XXX_Marshal

func (m *StateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StateRequest) XXX_Merge

func (m *StateRequest) XXX_Merge(src proto.Message)

func (*StateRequest) XXX_Size

func (m *StateRequest) XXX_Size() int

func (*StateRequest) XXX_Unmarshal

func (m *StateRequest) XXX_Unmarshal(b []byte) error

type StateResponse

type StateResponse struct {
	State State `protobuf:"bytes,1,opt,name=state,proto3" json:"state"`
}

StateResponse is the response type for the Query/State RPC method.

func (*StateResponse) Descriptor

func (*StateResponse) Descriptor() ([]byte, []int)

func (*StateResponse) GetState

func (m *StateResponse) GetState() State

func (*StateResponse) Marshal

func (m *StateResponse) Marshal() (dAtA []byte, err error)

func (*StateResponse) MarshalTo

func (m *StateResponse) MarshalTo(dAtA []byte) (int, error)

func (*StateResponse) MarshalToSizedBuffer

func (m *StateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*StateResponse) ProtoMessage

func (*StateResponse) ProtoMessage()

func (*StateResponse) Reset

func (m *StateResponse) Reset()

func (*StateResponse) Size

func (m *StateResponse) Size() (n int)

func (*StateResponse) String

func (m *StateResponse) String() string

func (*StateResponse) Unmarshal

func (m *StateResponse) Unmarshal(dAtA []byte) error

func (*StateResponse) XXX_DiscardUnknown

func (m *StateResponse) XXX_DiscardUnknown()

func (*StateResponse) XXX_Marshal

func (m *StateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*StateResponse) XXX_Merge

func (m *StateResponse) XXX_Merge(src proto.Message)

func (*StateResponse) XXX_Size

func (m *StateResponse) XXX_Size() int

func (*StateResponse) XXX_Unmarshal

func (m *StateResponse) XXX_Unmarshal(b []byte) error

type TestDenomResolver

type TestDenomResolver struct{}

TestDenomResolver is a test implementation of the DenomResolver interface. It returns "feeCoin.Amount baseDenom" for all coins that are not the baseDenom. NOTE: DO NOT USE THIS IN PRODUCTION

func (*TestDenomResolver) ConvertToDenom

func (r *TestDenomResolver) ConvertToDenom(_ context.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error)

ConvertToDenom returns "coin.Amount denom" for all coins that are not the denom.

func (*TestDenomResolver) ExtraDenoms

func (r *TestDenomResolver) ExtraDenoms(_ context.Context) ([]string, error)

type UnimplementedMsgServer

type UnimplementedMsgServer struct {
}

UnimplementedMsgServer can be embedded to have forward compatible implementations.

func (*UnimplementedMsgServer) UpdateParams

type UnimplementedQueryServer

type UnimplementedQueryServer struct {
}

UnimplementedQueryServer can be embedded to have forward compatible implementations.

func (*UnimplementedQueryServer) GasPrice

func (*UnimplementedQueryServer) GasPrices

func (*UnimplementedQueryServer) Params

func (*UnimplementedQueryServer) State

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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