Estimate FeeCap 20 blocks in the future

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera
2020-08-07 00:10:55 +02:00
parent 07bf155295
commit e1de0e3408
4 changed files with 33 additions and 9 deletions
+16 -1
View File
@@ -2,6 +2,7 @@ package full
import (
"context"
"math"
"sort"
"github.com/filecoin-project/lotus/build"
@@ -26,9 +27,23 @@ type GasAPI struct {
}
const MinGasPrice = 1
const BaseFeeEstimNBlocks = 20
func (a *GasAPI) GasEstimateFeeCap(ctx context.Context, maxqueueblks int64,
tsk types.TipSetKey) (types.BigInt, error) {
ts := a.Chain.GetHeaviestTipSet()
parentBaseFee := ts.Blocks()[0].ParentBaseFee
increaseFactor := math.Pow(1+1/build.BaseFeeMaxChangeDenom, BaseFeeEstimNBlocks)
out := types.BigMul(parentBaseFee, types.NewInt(uint64(increaseFactor*(1<<8))))
out = types.BigDiv(parentBaseFee, types.NewInt(1<<8))
return out, nil
}
func (a *GasAPI) GasEsitmateGasPremium(ctx context.Context, nblocksincl uint64,
sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) {
sender address.Address, gaslimit int64, _ types.TipSetKey) (types.BigInt, error) {
if nblocksincl == 0 {
nblocksincl = 1