Merge pull request #3647 from filecoin-project/fix/enable-strict-basefee-check
re-enable baseFee lower bound check
This commit is contained in:
commit
72216fe917
@ -52,6 +52,7 @@ var RepublishInterval = time.Duration(10*build.BlockDelaySecs+build.PropagationD
|
|||||||
|
|
||||||
var minimumBaseFee = types.NewInt(uint64(build.MinimumBaseFee))
|
var minimumBaseFee = types.NewInt(uint64(build.MinimumBaseFee))
|
||||||
var baseFeeLowerBoundFactor = types.NewInt(10)
|
var baseFeeLowerBoundFactor = types.NewInt(10)
|
||||||
|
var baseFeeLowerBoundFactorConservative = types.NewInt(100)
|
||||||
|
|
||||||
var MaxActorPendingMessages = 1000
|
var MaxActorPendingMessages = 1000
|
||||||
|
|
||||||
@ -104,10 +105,6 @@ type MessagePoolEvtMessage struct {
|
|||||||
CID cid.Cid
|
CID cid.Cid
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is *temporary* mutilation until we have implemented uncapped miner penalties -- it will go
|
|
||||||
// away in the next fork.
|
|
||||||
var strictBaseFeeValidation = false
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// if the republish interval is too short compared to the pubsub timecache, adjust it
|
// if the republish interval is too short compared to the pubsub timecache, adjust it
|
||||||
minInterval := pubsub.TimeCacheDuration + time.Duration(build.PropagationDelaySecs)
|
minInterval := pubsub.TimeCacheDuration + time.Duration(build.PropagationDelaySecs)
|
||||||
@ -444,9 +441,19 @@ func (mp *MessagePool) verifyMsgBeforeAdd(m *types.SignedMessage, curTs *types.T
|
|||||||
// Note that for local messages, we always add them so that they can be accepted and republished
|
// Note that for local messages, we always add them so that they can be accepted and republished
|
||||||
// automatically.
|
// automatically.
|
||||||
publish := local
|
publish := local
|
||||||
if strictBaseFeeValidation && len(curTs.Blocks()) > 0 {
|
|
||||||
baseFee := curTs.Blocks()[0].ParentBaseFee
|
var baseFee big.Int
|
||||||
baseFeeLowerBound := getBaseFeeLowerBound(baseFee)
|
if len(curTs.Blocks()) > 0 {
|
||||||
|
baseFee = curTs.Blocks()[0].ParentBaseFee
|
||||||
|
} else {
|
||||||
|
var err error
|
||||||
|
baseFee, err = mp.api.ChainComputeBaseFee(context.TODO(), curTs)
|
||||||
|
if err != nil {
|
||||||
|
return false, xerrors.Errorf("computing basefee: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactorConservative)
|
||||||
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
|
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
|
||||||
if local {
|
if local {
|
||||||
log.Warnf("local message will not be immediately published because GasFeeCap doesn't meet the lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s)",
|
log.Warnf("local message will not be immediately published because GasFeeCap doesn't meet the lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s)",
|
||||||
@ -457,7 +464,6 @@ func (mp *MessagePool) verifyMsgBeforeAdd(m *types.SignedMessage, curTs *types.T
|
|||||||
m.Message.GasFeeCap, baseFeeLowerBound, ErrSoftValidationFailure)
|
m.Message.GasFeeCap, baseFeeLowerBound, ErrSoftValidationFailure)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return publish, nil
|
return publish, nil
|
||||||
}
|
}
|
||||||
@ -1344,8 +1350,8 @@ func (mp *MessagePool) Clear(local bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBaseFeeLowerBound(baseFee types.BigInt) types.BigInt {
|
func getBaseFeeLowerBound(baseFee, factor types.BigInt) types.BigInt {
|
||||||
baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor)
|
baseFeeLowerBound := types.BigDiv(baseFee, factor)
|
||||||
if baseFeeLowerBound.LessThan(minimumBaseFee) {
|
if baseFeeLowerBound.LessThan(minimumBaseFee) {
|
||||||
baseFeeLowerBound = minimumBaseFee
|
baseFeeLowerBound = minimumBaseFee
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("computing basefee: %w", err)
|
return xerrors.Errorf("computing basefee: %w", err)
|
||||||
}
|
}
|
||||||
baseFeeLowerBound := getBaseFeeLowerBound(baseFee)
|
baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactor)
|
||||||
|
|
||||||
pending, _ := mp.getPendingMessages(ts, ts)
|
pending, _ := mp.getPendingMessages(ts, ts)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func (mp *MessagePool) republishPendingMessages() error {
|
|||||||
mp.curTsLk.Unlock()
|
mp.curTsLk.Unlock()
|
||||||
return xerrors.Errorf("computing basefee: %w", err)
|
return xerrors.Errorf("computing basefee: %w", err)
|
||||||
}
|
}
|
||||||
baseFeeLowerBound := getBaseFeeLowerBound(baseFee)
|
baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactor)
|
||||||
|
|
||||||
pending := make(map[address.Address]map[uint64]*types.SignedMessage)
|
pending := make(map[address.Address]map[uint64]*types.SignedMessage)
|
||||||
mp.lk.Lock()
|
mp.lk.Lock()
|
||||||
|
Loading…
Reference in New Issue
Block a user