diff --git a/consensus/dummy/dynamic_fees.go b/consensus/dummy/dynamic_fees.go index 566d72b301..289ac0907c 100644 --- a/consensus/dummy/dynamic_fees.go +++ b/consensus/dummy/dynamic_fees.go @@ -56,15 +56,14 @@ func CalcBaseFee(config *params.ChainConfig, feeConfig commontype.FeeConfig, par // Add in the gas used by the parent block in the correct place // If the parent consumed gas within the rollup window, add the consumed // gas in. - expectedRollUp := params.RollupWindow - if roll < expectedRollUp { - slot := expectedRollUp - 1 - roll + if roll < params.RollupWindow { + slot := params.RollupWindow - 1 - roll start := slot * wrappers.LongLen updateLongWindow(newRollupWindow, start, parent.GasUsed) } // Calculate the amount of gas consumed within the rollup window. - totalGas := sumLongWindow(newRollupWindow, int(expectedRollUp)) + totalGas := sumLongWindow(newRollupWindow, params.RollupWindow) if totalGas == parentGasTarget { return newRollupWindow, baseFee, nil @@ -93,9 +92,9 @@ func CalcBaseFee(config *params.ChainConfig, feeConfig commontype.FeeConfig, par // for the interval during which no blocks were produced. // We use roll/rollupWindow, so that the transition is applied for every [rollupWindow] seconds // that has elapsed between the parent and this block. - if roll > expectedRollUp { + if roll > params.RollupWindow { // Note: roll/params.RollupWindow must be greater than 1 since we've checked that roll > params.RollupWindow - baseFeeDelta = new(big.Int).Mul(baseFeeDelta, new(big.Int).SetUint64(roll/expectedRollUp)) + baseFeeDelta = new(big.Int).Mul(baseFeeDelta, new(big.Int).SetUint64(roll/params.RollupWindow)) } baseFee.Sub(baseFee, baseFeeDelta) } diff --git a/params/config_extra.go b/params/config_extra.go index b69f9553a5..c8f292d914 100644 --- a/params/config_extra.go +++ b/params/config_extra.go @@ -10,6 +10,7 @@ import ( "math/big" "github.com/ava-labs/avalanchego/snow" + "github.com/ava-labs/avalanchego/utils/wrappers" "github.com/ava-labs/subnet-evm/commontype" "github.com/ava-labs/subnet-evm/utils" "github.com/ethereum/go-ethereum/common" @@ -19,8 +20,8 @@ const ( maxJSONLen = 64 * 1024 * 1024 // 64MB // Consensus Params - RollupWindow uint64 = 10 - DynamicFeeExtraDataSize = 80 + RollupWindow = 10 // in seconds + DynamicFeeExtraDataSize = wrappers.LongLen * RollupWindow // For legacy tests MinGasPrice int64 = 225_000_000_000