From d68ec379429b1081107b78b7f0237b51d7485545 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 8 Sep 2020 09:33:21 +0300 Subject: [PATCH 1/4] reenable baseFee lower bound check --- chain/messagepool/messagepool.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index f6799be73..033d30059 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -104,10 +104,6 @@ type MessagePoolEvtMessage struct { 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() { // if the republish interval is too short compared to the pubsub timecache, adjust it minInterval := pubsub.TimeCacheDuration + time.Duration(build.PropagationDelaySecs) @@ -444,7 +440,7 @@ 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 // automatically. publish := local - if strictBaseFeeValidation && len(curTs.Blocks()) > 0 { + if len(curTs.Blocks()) > 0 { baseFee := curTs.Blocks()[0].ParentBaseFee baseFeeLowerBound := getBaseFeeLowerBound(baseFee) if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) { From 044202b37f77677b5b725ab2b721c70593a6e3a6 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 11 Sep 2020 17:11:57 +0300 Subject: [PATCH 2/4] use conservative base fee lower bound factor for strict checks --- chain/messagepool/messagepool.go | 5 +++-- chain/messagepool/pruning.go | 2 +- chain/messagepool/repub.go | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 033d30059..03584d275 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -52,6 +52,7 @@ var RepublishInterval = time.Duration(10*build.BlockDelaySecs+build.PropagationD var minimumBaseFee = types.NewInt(uint64(build.MinimumBaseFee)) var baseFeeLowerBoundFactor = types.NewInt(10) +var baseFeeLowerBoundFactorConservative = types.NewInt(100) var MaxActorPendingMessages = 1000 @@ -442,7 +443,7 @@ func (mp *MessagePool) verifyMsgBeforeAdd(m *types.SignedMessage, curTs *types.T publish := local if len(curTs.Blocks()) > 0 { baseFee := curTs.Blocks()[0].ParentBaseFee - baseFeeLowerBound := getBaseFeeLowerBound(baseFee) + baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactorConservative) if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) { 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)", @@ -1340,7 +1341,7 @@ 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) if baseFeeLowerBound.LessThan(minimumBaseFee) { baseFeeLowerBound = minimumBaseFee diff --git a/chain/messagepool/pruning.go b/chain/messagepool/pruning.go index fd8199b89..d0e53795a 100644 --- a/chain/messagepool/pruning.go +++ b/chain/messagepool/pruning.go @@ -46,7 +46,7 @@ func (mp *MessagePool) pruneMessages(ctx context.Context, ts *types.TipSet) erro if err != nil { return xerrors.Errorf("computing basefee: %w", err) } - baseFeeLowerBound := getBaseFeeLowerBound(baseFee) + baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactor) pending, _ := mp.getPendingMessages(ts, ts) diff --git a/chain/messagepool/repub.go b/chain/messagepool/repub.go index 375360bce..db31e18c2 100644 --- a/chain/messagepool/repub.go +++ b/chain/messagepool/repub.go @@ -28,7 +28,7 @@ func (mp *MessagePool) republishPendingMessages() error { mp.curTsLk.Unlock() return xerrors.Errorf("computing basefee: %w", err) } - baseFeeLowerBound := getBaseFeeLowerBound(baseFee) + baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactor) pending := make(map[address.Address]map[uint64]*types.SignedMessage) mp.lk.Lock() From 0a5494dd7962a517d3531ef28366d3bf359e8720 Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 14 Sep 2020 22:05:24 +0300 Subject: [PATCH 3/4] use the factor in getBaseFeeLowerBound --- chain/messagepool/messagepool.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 03584d275..984f696da 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -1342,7 +1342,7 @@ func (mp *MessagePool) Clear(local bool) { } func getBaseFeeLowerBound(baseFee, factor types.BigInt) types.BigInt { - baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor) + baseFeeLowerBound := types.BigDiv(baseFee, factor) if baseFeeLowerBound.LessThan(minimumBaseFee) { baseFeeLowerBound = minimumBaseFee } From 172bfacae0cdc7ee51031c71bfdbacac77ddfc7c Mon Sep 17 00:00:00 2001 From: vyzo Date: Mon, 14 Sep 2020 22:20:26 +0300 Subject: [PATCH 4/4] compute baseFee for check even in null rounds --- chain/messagepool/messagepool.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 984f696da..96900925f 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -441,18 +441,27 @@ 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 // automatically. publish := local + + var baseFee big.Int if len(curTs.Blocks()) > 0 { - baseFee := curTs.Blocks()[0].ParentBaseFee - baseFeeLowerBound := getBaseFeeLowerBound(baseFee, baseFeeLowerBoundFactorConservative) - if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) { - 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)", - m.Message.GasFeeCap, baseFeeLowerBound) - publish = false - } else { - return false, xerrors.Errorf("GasFeeCap doesn't meet base fee lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s): %w", - m.Message.GasFeeCap, baseFeeLowerBound, ErrSoftValidationFailure) - } + 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 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)", + m.Message.GasFeeCap, baseFeeLowerBound) + publish = false + } else { + return false, xerrors.Errorf("GasFeeCap doesn't meet base fee lower bound for inclusion in the next 20 blocks (GasFeeCap: %s, baseFeeLowerBound: %s): %w", + m.Message.GasFeeCap, baseFeeLowerBound, ErrSoftValidationFailure) } }