Skip to content

Gas Power

Bitkincoin edited this page Mar 4, 2022 · 1 revision

Gas power


GasPower limits the > GasLimit of transactions and events, which a validator may originate.

The underlying mechanism is based on > MedianTime. The allocated gas power is proportional to the amount of time that has passed since previous event, whose time is measured in > MedianTime. It isn't possible to bias the > MedianTime, unless more than 1/2W of the network collude about the shift of time.

Gas power windows

Gas power has 2 windows - long term window and short term window, each of them has its own set of constants. The formulas work the same for each window, and only window constants differ.

  • Long-term window increases slowly, but has a high maximum accumulated value. This window controls an average load (txs and events per second).

  • Short-term window increases rapidly, but has a low maximum accumulated value. This window controls load peaks (txs and events per second).

Exact formula for each window

Constants for each validator:

  • TotalPerH = determines the gas power allocation per hour in the whole network.

  • validator’s gas per hour = > TotalPerH * > validator’s stake / > total stake.

  • max gas power = > validator’s gas per hour * > MaxStashedPeriod.

  • startup gas = max(> validator’s gas per hour * > StartupPeriod, > MinStartupGasPower).

if {e.SelfParent} != nil {prev gas left} = e.SelfParent.GasPowerLeft {prev median time} = e.SelfParent.MedianTime else if prevEpoch.LastConfirmedEvent[validator] exists {prev gas left} = max(prevEpoch.LastConfirmedEvent[validator].GasPowerLeft, {startup gas}) {prev median time} = prevEpoch.LastConfirmedEvent[validator].MedianTime else {gas stashed} = {startup gas} {prev median time} = prevEpoch.Time {gas power allocated} = ({e.MedianTime} - {prev median time}) * {validator’s gas per hour} / hour {GasPower} = {prev gas left} + {gas power allocated} if {GasPower} > {max gas power} {GasPower} = {max gas power} {e.GasPowerLeft} = {GasPower} - {e.GasPowerUsed}

return {GasPower}, {e.GasPowerLeft}

Clone this wiki locally