Hey @edmundedgar and @vbuterin , thanks for the comments!
TARGET_GASUSED is a constant that is used in the
BASEFEE adjustment formula, it is the amount of gas we target to use and miners adjust the
BASEFEE up or down depending on how the actual gas usage deviates from this value. Specifically, miners set a block’s
PARENT_BASEFEE + PARENT_BASEFEE * DELTA // TARGET_GASUSED // BASEFEE_MAX_CHANGE_DENOMINATOR, where
DELTA = PARENT_GASUSED - TARGET_GASUSED.
BASEFEE is maintained under consensus by the ethash engine. In the
verifyHeader() method a header is invalidated if the
BASEFEE increases or decreases relative to
PARENT_BASEFEE more than the allowed amount (
PARENT_BASEFEE // BASEFEE_MAX_CHANGE_DENOMINATOR).
@vbuterin per your comment the above is not quite right. I will update the consensus engine so that the exact value from the basefee adjustment formula is enforced, not just an upper and lower bound on the value. The need for this is apparent, currently a miner could change their basefee adjustment algo to submit arbitrary
BASEFEEs that are valid so long as they are within the upper and lower limits e.g. they could raise the
BASEFEE by as much as
PARENT_BASEFEE // BASEFEE_MAX_CHANGE_DENOMINATOR even if
PARENT_GASUSED is below
TARGET_GASUSED. That’s an oversight on my part, but a simple fix to make. Thank you for pointing it out!