Remove PackingEfficiency consideration from base fee in an upgrade
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
db6bd890d9
commit
fd714cbceb
@ -11,14 +11,20 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func computeNextBaseFee(baseFee types.BigInt, gasLimitUsed int64, noOfBlocks int) types.BigInt {
|
func computeNextBaseFee(baseFee types.BigInt, gasLimitUsed int64, noOfBlocks int, epoch abi.ChainEpoch) types.BigInt {
|
||||||
// deta := 1/PackingEfficiency * gasLimitUsed/noOfBlocks - build.BlockGasTarget
|
// deta := gasLimitUsed/noOfBlocks - build.BlockGasTarget
|
||||||
// change := baseFee * deta / BlockGasTarget / BaseFeeMaxChangeDenom
|
// change := baseFee * deta / BlockGasTarget
|
||||||
// nextBaseFee = baseFee + change
|
// nextBaseFee = baseFee + change
|
||||||
// nextBaseFee = max(nextBaseFee, build.MinimumBaseFee)
|
// nextBaseFee = max(nextBaseFee, build.MinimumBaseFee)
|
||||||
|
|
||||||
delta := build.PackingEfficiencyDenom * gasLimitUsed / (int64(noOfBlocks) * build.PackingEfficiencyNum)
|
var delta int64
|
||||||
delta -= build.BlockGasTarget
|
if epoch > build.UpgradeSmokeHeight {
|
||||||
|
delta = gasLimitUsed / int64(noOfBlocks)
|
||||||
|
delta -= build.BlockGasTarget
|
||||||
|
} else {
|
||||||
|
delta = build.PackingEfficiencyDenom * gasLimitUsed / (int64(noOfBlocks) * build.PackingEfficiencyNum)
|
||||||
|
delta -= build.BlockGasTarget
|
||||||
|
}
|
||||||
|
|
||||||
// cap change at 12.5% (BaseFeeMaxChangeDenom) by capping delta
|
// cap change at 12.5% (BaseFeeMaxChangeDenom) by capping delta
|
||||||
if delta > build.BlockGasTarget {
|
if delta > build.BlockGasTarget {
|
||||||
@ -73,5 +79,5 @@ func (cs *ChainStore) ComputeBaseFee(ctx context.Context, ts *types.TipSet) (abi
|
|||||||
}
|
}
|
||||||
parentBaseFee := ts.Blocks()[0].ParentBaseFee
|
parentBaseFee := ts.Blocks()[0].ParentBaseFee
|
||||||
|
|
||||||
return computeNextBaseFee(parentBaseFee, totalLimit, len(ts.Blocks())), nil
|
return computeNextBaseFee(parentBaseFee, totalLimit, len(ts.Blocks()), ts.Height()), nil
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ func TestBaseFee(t *testing.T) {
|
|||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
test := test
|
test := test
|
||||||
t.Run(fmt.Sprintf("%v", test), func(t *testing.T) {
|
t.Run(fmt.Sprintf("%v", test), func(t *testing.T) {
|
||||||
output := computeNextBaseFee(types.NewInt(test.basefee), test.limitUsed, test.noOfBlocks)
|
output := computeNextBaseFee(types.NewInt(test.basefee), test.limitUsed, test.noOfBlocks, 0)
|
||||||
assert.Equal(t, fmt.Sprintf("%d", test.output), output.String())
|
assert.Equal(t, fmt.Sprintf("%d", test.output), output.String())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user