Skip to content

Investigate dynamicfee module behavior #285

@tbruyelle

Description

@tbruyelle

Problem Statement

Between blocks 6,965,515 and 6,965,686, the AtomOne blockchain experienced sustained high gas consumption (~66M gas per block, well above the 50M target), yet the gas price barely increased — only +1.9% over 15 blocks. This report investigates why the AIMD EIP-1559 algorithm fails to respond adequately to moderate but persistent congestion, and evaluates parameter changes to fix the issue.

Image

Algorithm Overview

The dynamic fee module implements AIMD EIP-1559 with an adaptive learning rate. At the end of each block:

  1. Learning rate (LR) update based on average gas consumption across a sliding window:

    • If avg ≤ gamma OR avg ≥ (1 - gamma) → LR increases additively: LR = min(MaxLR, Alpha + LR)
    • If gamma < avg < (1 - gamma) → LR decreases multiplicatively: LR = max(MinLR, Beta × LR)
  2. Base gas price update using the current block's gas and the newly computed LR:

    adjustment = 1 + LR × (blockGas - targetGas) / targetGas
    newPrice = price × adjustment
    

Current Parameters

Parameter Value Description
Alpha 0.025 Additive LR increase
Beta 0.95 Multiplicative LR decrease
Gamma 0.25 Equilibrium band threshold
MinLearningRate 0.01 LR floor
MaxLearningRate 0.50 LR ceiling
Window 8 Sliding window size (blocks)
TargetBlockUtilization 0.5 Target = 50% of MaxBlockGas
MaxBlockGas 100,000,000 Maximum gas per block
MinBaseGasPrice 0.01 Price floor

Root Cause Analysis

The learning rate collapses to its minimum

With gamma = 0.25, the equilibrium band is [0.25, 0.75]. The LR only increases when average window utilization falls below 25% or exceeds 75%. During the congested period:

  • Blocks consistently consume ~66M gas (66% of max)
  • Window average utilization: 42–58% (varies as the window slides)
  • This falls squarely inside the [0.25, 0.75] band
  • Therefore the LR decreases every block: LR = 0.95 × LR
  • After ~45 blocks, the LR bottoms out at MinLearningRate = 0.01

With LR = 0.01, price adjustments are negligible

blockGas    = 66,066,947
targetGas   = 50,000,000
adjustment  = 1 + 0.01 × (66M - 50M) / 50M
            = 1 + 0.01 × 0.3213
            = 1.003213  →  only +0.32% per block

Over 15 blocks: 1.003213^15 ≈ 1.049+4.9% total increase.

For comparison, with LR = 0.5 (the maximum), the same block would produce:

adjustment = 1 + 0.5 × 0.3213 = 1.1607  →  +16% per block

The paradox

The algorithm is designed so that utilization between 25% and 75% is considered "normal", triggering LR reduction for stability. But 66% utilization is 32% above the 50% target — this is meaningful congestion that should produce a price signal. The current parameterization treats it as equilibrium.

Parameter Analysis

MinLearningRate (floor for LR)

Raising MinLR provides a constant, bounded improvement. The price adjustment per block scales linearly with MinLR. With MinLR=0.05, every block above target produces at least a 0.05 × (gas - target) / target relative price change, regardless of how long the congestion has lasted.

  • Predictable: the impact is always exactly MinLR / 0.01 times the current behavior
  • No runaway risk: LR is capped, so the maximum per-block adjustment is bounded
  • Drawback: does not adapt — responds the same whether congestion lasts 5 blocks or 500

Gamma (equilibrium band width)

Gamma controls when the algorithm considers utilization "abnormal" enough to increase the LR. Reducing gamma from 0.25 to 0.35 narrows the equilibrium band from [0.25, 0.75] to [0.35, 0.65].

  • Adaptive: when window average exceeds 65%, the LR starts climbing, producing exponentially stronger price signals
  • Self-correcting: once congestion subsides and avg drops below 65%, the LR decreases again
  • Risk: if congestion persists, LR can climb to high values (0.29 for gamma=0.35, 0.47 for gamma=0.40), causing rapid price escalation

Window size

Reducing the window from 8 to 4 blocks alone has minimal impact (+16.4% vs +15.8%). The fundamental issue is the gamma band, not the averaging period. However, a smaller window combined with aggressive gamma (G=0.40+W=4) amplifies volatility to dangerous levels (+1805%).

Recommendations

The two key levers serve distinct purposes:

  • MinLR = guaranteed minimum response speed (safety net)
  • Gamma = how quickly the algorithm escalates under persistent congestion (adaptivity)

Option A — Conservative: MinLearningRate: 0.01 → 0.05

Single parameter change. Provides 5× the floor responsiveness. Behavior remains bounded and linear — no risk of runaway pricing. Best choice if predictability is the priority.

Image

Option B Gamma: 0.25 → 0.35 + MinLearningRate: 0.01 → 0.025

Image

Combined approach that addresses both aspects of the problem:

  1. Gamma=0.35 narrows the equilibrium band to [0.35, 0.65], so sustained >65% utilization triggers adaptive LR increases instead of LR decay. The LR can climb to ~0.30 during persistent congestion, producing meaningful price pressure.

  2. MinLR=0.025 raises the response floor by 2.5×, ensuring the price always reacts even during moderate congestion that stays within the equilibrium band.

Result: +113% price increase over 100 congested blocks. Max price 0.033 in the test dataset. Price returns to floor when congestion ends. Faithful to the AIMD spirit — gentle at first, then escalating if congestion persists.

Option C — Recommended for current traffic: MinLearningRate: 0.01 → 0.125 + Window: 8 → 4

Image

Given AtomOne's low blockspace usage, this pragmatic approach prioritizes guaranteed responsiveness:

  1. MinLR=0.125 matches the base EIP-1559 learning rate, ensuring every above-target block produces a meaningful price signal (+4% per block at 66M gas).

  2. Window=4 provides mild smoothing without masking short congestion bursts. A 3-block congestion run pushes the window average to ~50M (target) instead of being diluted across 8 blocks.

  3. The AIMD machinery (alpha, beta, gamma) remains in place. If traffic grows and the alarm mechanism starts triggering, the LR can still adapt upward from 0.125 toward MaxLR=0.50.

This combines the responsiveness of base EIP-1559 with the smoothing and adaptivity of AIMD — without the extreme volatility of Window=1.

Gamma=0.40 or higher

The [0.40, 0.60] band is too narrow. It creates explosive positive feedback loops during sustained above-target usage. The price reached 0.12 (12× starting price) in testing — too volatile for production use.

Image

Standard EIP-1559 for example

Image

You can find all the generated charts in interactive mode here https://atomone-hub.github.io/govbox/sim_dynamicfee_params.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions