Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eip1559): Adding state helper funcs #18

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions proto/feemarket/eip1559/v1/feemarket.proto

This file was deleted.

18 changes: 0 additions & 18 deletions proto/feemarket/feemarket/v1/default.proto

This file was deleted.

42 changes: 32 additions & 10 deletions proto/feemarket/feemarket/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,42 @@ option go_package = "github.com/skip-mev/feemarket/x/feemarket/types";

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "feemarket/feemarket/v1/params.proto";

// GenesisState defines the feemarket module's genesis state.
message GenesisState {
// Plugin is the FeeMarket implementation plugged into the feemarket module.
// Must implement x/feemarket/types/FeeMarketImplementation
bytes plugin = 1 [ (cosmos_proto.accepts_interface) =
"feemarket.feemarket.v1.FeeMarketImplementation" ];
// Params are the parameters for the feemarket module. These parameters
// can be utilized to implement both the base EIP-1559 fee market and
// and the AIMD EIP-1559 fee market.
Params params = 1 [ (gogoproto.nullable) = false ];

// Params are the parameters for the feemarket module.
Params params = 2 [ (gogoproto.nullable) = false ];
// BaseFee is the current base fee. This is denominated in the fee
// per gas unit.
string base_fee = 2 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];

// LearningRate is the current learning rate.
string learning_rate = 3 [
(cosmos_proto.scalar) = "cosmos.Legacy",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// Utilization contains the current state of the AIMD fee market.
BlockUtilization utilization = 4 [ (gogoproto.nullable) = false ];
}

// Params defines the parameters for the feemarket module.
message Params {
// Enabled is a flag to enable or disable the feemarket module.
bool enabled = 1;
// BlockUtilization contains the current state of the AIMD fee market. This
// structure tracks total block utilization within a window of blocks.
message BlockUtilization {
// Window contains a list of the last blocks' utilization
// values. This is used to calculate the next base fee. This
// stores the number of units of gas consumed per block.
repeated uint64 window = 1;

// Index is the index of the current block in the block utilization window.
uint64 index = 4;
}
18 changes: 0 additions & 18 deletions proto/feemarket/feemarket/v1/panic.proto

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
syntax = "proto3";
package feemarket.eip1559.v1;
package feemarket.feemarket.v1;

option go_package = "github.com/skip-mev/feemarket/x/feemarket/plugins/eip1559/types";
option go_package = "github.com/skip-mev/feemarket/x/feemarket/types";

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

// Params contains the required set of parameters for the EIP1559 fee market
// plugin implementation.
message Params {
// Window determines the number of previous blocks to consider when
// calculating block utilization.
uint64 window = 1;

// Alpha is the amount we additively increase the learninig rate
// when it is above or below the target +/- threshold.
string alpha = 2 [
string alpha = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// Beta is the amount we multiplicatively decrease the learning rate
// when it is within the target +/- threshold.
string beta = 3 [
string beta = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
Expand All @@ -33,48 +29,49 @@ message Params {
// above or below the target +/- threshold, we additively increase the
// learning rate by Alpha. Otherwise, we multiplicatively decrease the
// learning rate by Beta.
string theta = 4 [
string theta = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// Delta is the amount we additively increase/decrease the base fee when the
// net block utilization difference in the window is above/below the target utilization.
string delta = 5 [
string delta = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// TargetBlockSize is the target block utilization rate. This is denominated in
// gas units consumed.
uint64 target_block_size = 6;

// MaxBlockSize is the upper bound for the block size. This is denominated in
// gas units consumed.
uint64 max_block_size = 7;

// MinBaseFee determines the initial base fee of the module and the global minimum
// for the network. This is denominated in fee per gas unit.
string min_base_fee = 8 [
string min_base_fee = 5 [
(cosmos_proto.scalar) = "cosmos.Int",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
(gogoproto.nullable) = false
];


// MinLearningRate is the lower bound for the learning rate.
string min_learning_rate = 9 [
string min_learning_rate = 6 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// MaxLearningRate is the upper bound for the learning rate.
string max_learning_rate = 10 [
string max_learning_rate = 7 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];

// TargetBlockUtilization is the target block utilization.
uint64 target_block_utilization = 8;

// MaxBlockUtilization is the maximum block utilization.
uint64 max_block_utilization = 9;

// Enabled is a boolean that determines whether the EIP1559 fee market is enabled.
bool enabled = 10;
}
5 changes: 2 additions & 3 deletions x/feemarket/plugins/eip1559/types/aimd_eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@ var (
// within the window.
func DefaultAIMDParams() Params {
return NewParams(
DefaultAIMDWindow,
DefaultAIMDAlpha,
DefaultAIMDBeta,
DefaultAIMDTheta,
DefaultAIMDDelta,
DefaultAIMDTargetBlockSize,
DefaultAIMDMaxBlockSize,
DefaultAIMDMinBaseFee,
DefaultAIMDMinLearningRate,
DefaultAIMDMaxLearningRate,
Expand All @@ -81,5 +78,7 @@ func DefaultAIMDState() State {
DefaultAIMDMinBaseFee,
DefaultAIMDMinLearningRate,
DefaultAIMDWindow,
DefaultAIMDTargetBlockSize,
DefaultAIMDMaxBlockSize,
)
}
5 changes: 2 additions & 3 deletions x/feemarket/plugins/eip1559/types/eip1559.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,10 @@ var (
// rate adjustment algorithm.
func DefaultParams() Params {
return NewParams(
DefaultWindow,
DefaultAlpha,
DefaultBeta,
DefaultTheta,
DefaultDelta,
DefaultTargetBlockSize,
DefaultMaxBlockSize,
DefaultMinBaseFee,
DefaultMinLearningRate,
DefaultMaxLearningRate,
Expand All @@ -69,5 +66,7 @@ func DefaultState() State {
DefaultMinBaseFee,
DefaultMinLearningRate,
DefaultWindow,
DefaultTargetBlockSize,
DefaultMaxBlockSize,
)
}
Loading
Loading