diff --git a/x/txfees/keeper/mempool-1559/code.go b/x/txfees/keeper/mempool-1559/code.go index 53089173da8..0d1d8ba4043 100644 --- a/x/txfees/keeper/mempool-1559/code.go +++ b/x/txfees/keeper/mempool-1559/code.go @@ -47,8 +47,9 @@ var ( // Max increase per block is a factor of 1.06, max decrease is 9/10 // If recovering at ~30M gas per block, decrease is .94 - MaxBlockChangeRate = sdk.NewDec(1).Quo(sdk.NewDec(10)) - TargetGas = int64(75_000_000) + MaxBlockChangeRate = sdk.NewDec(1).Quo(sdk.NewDec(10)) + TargetGas = int64(187_500_000) + TargetBlockSpacePercent = sdk.MustNewDecFromStr("0.625") // In face of continuous spam, will take ~19 blocks from base fee > spam cost, to mempool eviction // ceil(log_{1.06}(RecheckFeeConstant)) // So potentially 1.8 minutes of impaired UX from 1559 nodes on top of time to get to base fee > spam. diff --git a/x/txfees/module.go b/x/txfees/module.go index 6b7c2ee63c3..88dd648c393 100644 --- a/x/txfees/module.go +++ b/x/txfees/module.go @@ -191,7 +191,7 @@ func (am AppModule) CheckAndSetTargetGas(ctx sdk.Context) { return } - newBlockMaxGas := newConsensusParams.Block.MaxGas + newBlockMaxGas := mempool1559.TargetBlockSpacePercent.Mul(sdk.NewDec(newConsensusParams.Block.MaxGas)).TruncateInt().Int64() mempool1559.TargetGas = newBlockMaxGas return } diff --git a/x/txfees/module_test.go b/x/txfees/module_test.go index 250ef732131..f6d9e2645aa 100644 --- a/x/txfees/module_test.go +++ b/x/txfees/module_test.go @@ -62,19 +62,19 @@ func TestBeginBlock(t *testing.T) { ) // Begin block hasn't happened yet, target gas should be equal to hard coded default value - hardCodedGasTarget := int64(75_000_000) + hardCodedGasTarget := int64(187_500_000) require.Equal(t, hardCodedGasTarget, mempool1559.TargetGas) // Run begin block ctx = RunBeginBlock(ctx, app) // Target gas should be updated to the value set in InitChain - defaultBlockMaxGas := sims.DefaultConsensusParams.Block.MaxGas - require.Equal(t, defaultBlockMaxGas, mempool1559.TargetGas) + defaultBlockTargetGas := mempool1559.TargetBlockSpacePercent.Mul(sdk.NewDec(sims.DefaultConsensusParams.Block.MaxGas)).TruncateInt().Int64() + require.Equal(t, defaultBlockTargetGas, mempool1559.TargetGas) // Run begin block again, should not update target gas ctx = RunBeginBlock(ctx, app) - require.Equal(t, defaultBlockMaxGas, mempool1559.TargetGas) + require.Equal(t, defaultBlockTargetGas, mempool1559.TargetGas) // Update the consensus params newDefaultBlockMaxGas := int64(300_000_000) @@ -83,7 +83,7 @@ func TestBeginBlock(t *testing.T) { app.ConsensusParamsKeeper.Set(ctx, &newConsensusParams) // Ensure that the consensus params have not been updated yet - require.Equal(t, defaultBlockMaxGas, mempool1559.TargetGas) + require.Equal(t, defaultBlockTargetGas, mempool1559.TargetGas) // Run begin block again, should update target gas RunBeginBlock(ctx, app)