Documentation
      ¶
    
    
  
    
  
    Overview ¶
ACP176 implements the fee logic specified here: https://github.com/avalanche-foundation/ACPs/blob/main/ACPs/176-dynamic-evm-gas-limit-and-price-discovery-updates/README.md
Index ¶
- Constants
 - Variables
 - func DesiredTargetExcess(desiredTarget gas.Gas) gas.Gas
 - type State
 - func (s *State) AdvanceTime(seconds uint64)
 - func (s *State) Bytes() []byte
 - func (s *State) ConsumeGas(gasUsed uint64, extraGasUsed *big.Int) error
 - func (s *State) GasPrice() gas.Price
 - func (s *State) MaxCapacity() gas.Gas
 - func (s *State) Target() gas.Gas
 - func (s *State) UpdateTargetExcess(desiredTargetExcess gas.Gas)
 
Constants ¶
const ( MinTargetPerSecond = 1_000_000 // P TargetConversion = MaxTargetChangeRate * MaxTargetExcessDiff // D MaxTargetExcessDiff = 1 << 15 // Q MinGasPrice = 1 // M TimeToFillCapacity = 5 // in seconds TargetToMax = 2 // multiplier to convert from target per second to max per second TargetToPriceUpdateConversion = 87 // 87s ~= 60s * ln(2) which makes the price double at most every ~60 seconds MaxTargetChangeRate = 1024 // Controls the rate that the target can change per block. TargetToMaxCapacity = TargetToMax * TimeToFillCapacity MinMaxPerSecond = MinTargetPerSecond * TargetToMax MinMaxCapacity = MinMaxPerSecond * TimeToFillCapacity StateSize = 3 * wrappers.LongLen )
Variables ¶
var ErrStateInsufficientLength = errors.New("insufficient length for fee state")
    Functions ¶
Types ¶
type State ¶
State represents the current state of the gas pricing and constraints.
func ParseState ¶
ParseState returns the state from the provided bytes. It is the inverse of State.Bytes. This function allows for additional bytes to be padded at the end of the provided bytes.
func (*State) AdvanceTime ¶
AdvanceTime increases the gas capacity and decreases the gas excess based on the elapsed seconds.
func (*State) ConsumeGas ¶
ConsumeGas decreases the gas capacity and increases the gas excess by gasUsed + extraGasUsed. If the gas capacity is insufficient, an error is returned.
func (*State) GasPrice ¶
GasPrice returns the current required fee per gas.
GasPrice = MinGasPrice * e^(Excess / (Target() * TargetToPriceUpdateConversion))
func (*State) MaxCapacity ¶
MaxCapacity returns the maximum possible accrued gas capacity, `C`.
func (*State) Target ¶
Target returns the target gas consumed per second, `T`.
Target = MinTargetPerSecond * e^(TargetExcess / TargetConversion)
func (*State) UpdateTargetExcess ¶
UpdateTargetExcess updates the targetExcess to be as close as possible to the desiredTargetExcess without exceeding the maximum targetExcess change.