Skip to content

Commit

Permalink
Merge branch 'main' into chore/accept-1-denom
Browse files Browse the repository at this point in the history
  • Loading branch information
davidterpay authored Jan 12, 2024
2 parents 51b98f7 + e6f642f commit 579da06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
22 changes: 10 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

This document specifies the feemarket module.

The feemarket module is an implementation of the Additive Increase Multiplicative Decrease (AIMD) EIP-1559
feemarket. More information about the implementation can be found [here](./x/feemarket/README.md).
The feemarket module is an implementation of the Additive Increase Multiplicative Decrease (AIMD) EIP-1559
feemarket. More information about the implementation can be found [here](./x/feemarket/README.md).

This module is planned to be used in the Cosmos Hub.

Expand Down Expand Up @@ -107,7 +107,7 @@ The feemarket module provides a keeper interface for accessing the KVStore.

```go
type FeeMarketKeeper interface {
// Get the current state from the store.
// Get the current state from the store.
GetState(ctx sdk.Context) (types.State, error)

// Set the state in the store.
Expand All @@ -118,8 +118,8 @@ type FeeMarketKeeper interface {

// Set the params in the store.
SetParams(ctx sdk.Context, params types.Params) error
// Get the current minimum gas prices (base fee) from the store.

// Get the current minimum gas prices (base fee) from the store.
GetMinGasPrices(ctx sdk.Context) (sdk.Coins, error)
}
```
Expand Down Expand Up @@ -212,9 +212,8 @@ when it is above or below the target +/- threshold.

### Beta

The default send enabled value controls send transfer capability for all
coin denominations unless specifically included in the array of `SendEnabled`
parameters.
Beta is the amount we multiplicatively decrease the learning rate
when it is within the target +/- threshold.

### Theta

Expand Down Expand Up @@ -248,13 +247,13 @@ TargetBlockUtilization is the target block utilization for the current block.

### MaxBlockUtilization

MaxBlockUtilization is the maximum block utilization. Once this has been surpassed,
MaxBlockUtilization is the maximum block utilization. Once this has been surpassed,
no more transactions will be added to the current block.

### Window

Window defines the window size for calculating an adaptive learning rate
over a moving window of blocks. The default EIP1559 implementation uses
over a moving window of blocks. The default EIP1559 implementation uses
a window of size 1.

### FeeDenom
Expand All @@ -264,7 +263,7 @@ FeeDenom is the denom that will be used for all fee payments.
### Enabled

Enabled is a boolean that determines whether the EIP1559 fee market is
enabled. This can be used to add the feemarket module and enable it
enabled. This can be used to add the feemarket module and enable it
through governance at a later time.

```protobuf
Expand Down Expand Up @@ -536,4 +535,3 @@ Example Output:
]
}
```

16 changes: 8 additions & 8 deletions x/feemarket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> * **`Target Block Size`**: This is the target block gas consumption.
> * **`Max Block Size`**: This is the maximum block gas consumption.
This plugin implements the AIMD (Additive Increase Multiplicative Decrease) EIP-1559 fee market as described in this [AIMD EIP-1559](https://ieeexplore.ieee.org/document/9680496) research publication.
This plugin implements the AIMD (Additive Increase Multiplicative Decrease) EIP-1559 fee market as described in this [AIMD EIP-1559](https://arxiv.org/abs/2110.04753) research publication.

The AIMD EIP-1559 fee market is a slight modification to Ethereum's EIP-1559 fee market. Specifically it introduces the notion of a adaptive learning rate which scales the base fee (reserve price to be included in a block) more aggressively when the network is congested and less aggressively when the network is not congested. This is primarily done to address the often cited criticism of EIP-1559 that it's base fee often lags behind the current demand for block space. The learning rate on Ethereum is effectively hard-coded to be 12.5%, which means that between any two blocks the base fee can maximally increase by 12.5% or decrease by 12.5%. Additionally, AIMD EIP-1559 differs from Ethereum's EIP-1559 by considering a configured time window (number of blocks) to consider when calculating and comparing target block utilization and current block utilization.

Expand Down Expand Up @@ -47,11 +47,11 @@ The calculation for the updated base fee for the next block is as follows:
blockConsumption := sumBlockSizesInWindow(window) / (window * maxBlockSize)

if blockConsumption < gamma || blockConsumption > 1 - gamma {
// MAX_LEARNING_RATE is a constant that configured by the chain developer
newLearningRate := min(MaxLearningRate, alpha + currencyLearningRate)
// MAX_LEARNING_RATE is a constant that is configured by the chain developer
newLearningRate := min(MaxLearningRate, alpha + currentLearningRate)
} else {
// MIN_LEARNING_RATE is a constant that configured by the chain developer
newLearningRate := max(MinLearningRate, beta * currencyLearningRate)
// MIN_LEARNING_RATE is a constant that is configured by the chain developer
newLearningRate := max(MinLearningRate, beta * currentLearningRate)
}

// netGasDelta returns the net gas difference between every block in the window and the target block size.
Expand Down Expand Up @@ -80,7 +80,7 @@ In this example, we expect the learning rate to additively increase and the base

```golang
blockConsumption := sumBlockSizesInWindow(1) / (1 * 100) == 0
maxLearningRate := min(1.0, 0.025 + 0.125) == 0.15
newLearningRate := min(1.0, 0.025 + 0.125) == 0.15
newBaseFee := 10 * (1 + 0.15 * (0 - 50) / 50) == 8.5
```

Expand All @@ -92,7 +92,7 @@ In this example, we expect the learning rate to multiplicatively increase and th

```golang
blockConsumption := sumBlockSizesInWindow(1) / (1 * 100) == 1
maxLearningRate := min(1.0, 0.025 + 0.125) == 0.15
newLearningRate := min(1.0, 0.025 + 0.125) == 0.15
newBaseFee := 10 * (1 + 0.95 * 0.125) == 11.875
```

Expand All @@ -104,7 +104,7 @@ In this example, we expect the learning rate to decrease and the base fee to rem

```golang
blockConsumption := sumBlockSizesInWindow(1) / (1 * 100) == 0.5
maxLearningRate := max(0.0125, 0.95 * 0.125) == 0.11875
newLearningRate := max(0.0125, 0.95 * 0.125) == 0.11875
newBaseFee := 10 * (1 + 0.11875 * (0 - 50) / 50) == 10
```

Expand Down

0 comments on commit 579da06

Please sign in to comment.