-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into aljo242/module
- Loading branch information
Showing
16 changed files
with
941 additions
and
384 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
syntax = "proto3"; | ||
package feemarket.eip1559.v1; | ||
|
||
option go_package = "github.com/skip-mev/feemarket/x/feemarket/plugins/eip1559/types"; | ||
|
||
import "cosmos_proto/cosmos.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "feemarket/eip1559/v1/params.proto"; | ||
|
||
// EIP1559 is the contains the Additive Increase Multiplicative Decrease | ||
// (AIMD) EIP-1559 fee market parameters and state. This can be utilized | ||
// to implement AIMD EIP-1559 and legacy EIP-1559 fee market. | ||
message EIP1559 { | ||
option (cosmos_proto.implements_interface) = | ||
"feemarket.feemarket.v1.FeeMarketImplementation"; | ||
|
||
// Params are the parameters of the AIMD fee market. | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
|
||
// State is the current state of the AIMD fee market. | ||
State state = 2 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// State contains the current state of the AIMD fee market. | ||
message State { | ||
// BaseFee is the current base fee. This is denominated in the fee | ||
// per gas unit. | ||
string base_fee = 1 [ | ||
(cosmos_proto.scalar) = "cosmos.Int", | ||
(gogoproto.customtype) = "cosmossdk.io/math.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
// LearningRate is the current learning rate. | ||
string learning_rate = 2 [ | ||
(cosmos_proto.scalar) = "cosmos.Legacy", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(gogoproto.nullable) = false | ||
]; | ||
|
||
// BlockUtilizationWindow contains a list of the last blocks' utilization | ||
// values. This is used to calculate the next base fee. | ||
repeated uint64 block_utilization_window = 3; | ||
|
||
// Index is the index of the current block in the block utilization window. | ||
uint64 index = 4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package types | ||
|
||
import "cosmossdk.io/math" | ||
|
||
// Note: The following constants are the default values for the AIMD EIP-1559 | ||
// fee market implementation. This implements an adjustable learning rate | ||
// algorithm that is not present in the base EIP-1559 implementation. | ||
|
||
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.LegacyDec = 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 utilization is not met. | ||
DefaultAIMDBeta math.LegacyDec = math.LegacyMustNewDecFromStr("0.95") | ||
|
||
// DefaultAIMDTheta 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 utilization within the window is greater | ||
// than 0.75 or less than 0.25. Otherwise, we multiplicatively decrease | ||
// the learning rate. | ||
DefaultAIMDTheta math.LegacyDec = math.LegacyMustNewDecFromStr("0.25") | ||
|
||
// DefaultAIMDDelta is the default delta value for how much we additively | ||
// increase or decrease the base fee when the net block utilization within | ||
// the window is not equal to the target utilization. | ||
DefaultAIMDDelta math.LegacyDec = math.LegacyMustNewDecFromStr("0.0") | ||
|
||
// DefaultAIMDTargetBlockSize is the default target block utilization. This | ||
// is the default on Ethereum. This denominated in units of gas consumed in | ||
// a block. | ||
DefaultAIMDTargetBlockSize uint64 = 15_000_000 | ||
|
||
// DefaultAIMDMaxBlockSize is the default maximum block utilization. | ||
// This is the default on Ethereum. This denominated in units of gas | ||
// consumed in a block. | ||
DefaultAIMDMaxBlockSize uint64 = 30_000_000 | ||
|
||
// DefaultAIMDMinBaseFee is the default minimum base fee. This is the | ||
// default on Ethereum. Note that ethereum is denominated in 1e18 wei. | ||
// Cosmos chains will likely want to change this to 1e6. | ||
DefaultAIMDMinBaseFee math.Int = math.NewInt(1_000_000_000) | ||
|
||
// DefaultAIMDMinLearningRate is the default minimum learning rate. | ||
DefaultAIMDMinLearningRate math.LegacyDec = math.LegacyMustNewDecFromStr("0.01") | ||
|
||
// DefaultAIMDMaxLearningRate is the default maximum learning rate. | ||
DefaultAIMDMaxLearningRate math.LegacyDec = math.LegacyMustNewDecFromStr("0.50") | ||
) | ||
|
||
// DefaultAIMDParams returns a default set of parameters that implements | ||
// the AIMD EIP-1559 fee market implementation. These parameters allow for | ||
// the learning rate to be dynamically adjusted based on the block utilization | ||
// within the window. | ||
func DefaultAIMDParams() Params { | ||
return NewParams( | ||
DefaultAIMDWindow, | ||
DefaultAIMDAlpha, | ||
DefaultAIMDBeta, | ||
DefaultAIMDTheta, | ||
DefaultAIMDDelta, | ||
DefaultAIMDTargetBlockSize, | ||
DefaultAIMDMaxBlockSize, | ||
DefaultAIMDMinBaseFee, | ||
DefaultAIMDMinLearningRate, | ||
DefaultAIMDMaxLearningRate, | ||
) | ||
} | ||
|
||
// DefaultAIMDState returns a default set of state that implements | ||
// the AIMD EIP-1559 fee market implementation. | ||
func DefaultAIMDState() State { | ||
return NewState( | ||
DefaultAIMDMinBaseFee, | ||
DefaultAIMDMinLearningRate, | ||
DefaultAIMDWindow, | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.