temporarily allow negative perfoming chains
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
8a018ce3ba
commit
97fddc45d9
@ -81,6 +81,10 @@ const (
|
|||||||
localUpdates = "update"
|
localUpdates = "update"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// this is *temporary* mutilation until we have implemented uncapped miner penalties -- it will go
|
||||||
|
// away in the next fork.
|
||||||
|
var allowNegativeChains = true
|
||||||
|
|
||||||
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)
|
||||||
@ -389,7 +393,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
|
// Note that for local messages, we always add them so that they can be accepted and republished
|
||||||
// automatically.
|
// automatically.
|
||||||
publish := local
|
publish := local
|
||||||
if len(curTs.Blocks()) > 0 {
|
if !allowNegativeChains && len(curTs.Blocks()) > 0 {
|
||||||
baseFee := curTs.Blocks()[0].ParentBaseFee
|
baseFee := curTs.Blocks()[0].ParentBaseFee
|
||||||
baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor)
|
baseFeeLowerBound := types.BigDiv(baseFee, baseFeeLowerBoundFactor)
|
||||||
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
|
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
|
||||||
|
@ -100,7 +100,7 @@ loop:
|
|||||||
// check the baseFee lower bound -- only republish messages that can be included in the chain
|
// check the baseFee lower bound -- only republish messages that can be included in the chain
|
||||||
// within the next 20 blocks.
|
// within the next 20 blocks.
|
||||||
for _, m := range chain.msgs {
|
for _, m := range chain.msgs {
|
||||||
if m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
|
if !allowNegativeChains && m.Message.GasFeeCap.LessThan(baseFeeLowerBound) {
|
||||||
chain.Invalidate()
|
chain.Invalidate()
|
||||||
continue loop
|
continue loop
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (mp *MessagePool) selectMessagesOptimal(curTs, ts *types.TipSet, tq float64
|
|||||||
return chains[i].Before(chains[j])
|
return chains[i].Before(chains[j])
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(chains) != 0 && chains[0].gasPerf < 0 {
|
if !allowNegativeChains && len(chains) != 0 && chains[0].gasPerf < 0 {
|
||||||
log.Warnw("all messages in mpool have non-positive gas performance", "bestGasPerf", chains[0].gasPerf)
|
log.Warnw("all messages in mpool have non-positive gas performance", "bestGasPerf", chains[0].gasPerf)
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ func (mp *MessagePool) selectMessagesOptimal(curTs, ts *types.TipSet, tq float64
|
|||||||
last := len(chains)
|
last := len(chains)
|
||||||
for i, chain := range chains {
|
for i, chain := range chains {
|
||||||
// did we run out of performing chains?
|
// did we run out of performing chains?
|
||||||
if chain.gasPerf < 0 {
|
if !allowNegativeChains && chain.gasPerf < 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ tailLoop:
|
|||||||
for gasLimit >= minGas && last < len(chains) {
|
for gasLimit >= minGas && last < len(chains) {
|
||||||
// trim if necessary
|
// trim if necessary
|
||||||
if chains[last].gasLimit > gasLimit {
|
if chains[last].gasLimit > gasLimit {
|
||||||
chains[last].Trim(gasLimit, mp, baseFee, false)
|
chains[last].Trim(gasLimit, mp, baseFee, allowNegativeChains)
|
||||||
}
|
}
|
||||||
|
|
||||||
// push down if it hasn't been invalidated
|
// push down if it hasn't been invalidated
|
||||||
@ -243,7 +243,7 @@ tailLoop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if gasPerf < 0 we have no more profitable chains
|
// if gasPerf < 0 we have no more profitable chains
|
||||||
if chain.gasPerf < 0 {
|
if !allowNegativeChains && chain.gasPerf < 0 {
|
||||||
break tailLoop
|
break tailLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ tailLoop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dependencies fit, just trim it
|
// dependencies fit, just trim it
|
||||||
chain.Trim(gasLimit-depGasLimit, mp, baseFee, false)
|
chain.Trim(gasLimit-depGasLimit, mp, baseFee, allowNegativeChains)
|
||||||
last += i
|
last += i
|
||||||
continue tailLoop
|
continue tailLoop
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ func (mp *MessagePool) selectMessagesGreedy(curTs, ts *types.TipSet) ([]*types.S
|
|||||||
return chains[i].Before(chains[j])
|
return chains[i].Before(chains[j])
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(chains) != 0 && chains[0].gasPerf < 0 {
|
if !allowNegativeChains && len(chains) != 0 && chains[0].gasPerf < 0 {
|
||||||
log.Warnw("all messages in mpool have non-positive gas performance", "bestGasPerf", chains[0].gasPerf)
|
log.Warnw("all messages in mpool have non-positive gas performance", "bestGasPerf", chains[0].gasPerf)
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ func (mp *MessagePool) selectMessagesGreedy(curTs, ts *types.TipSet) ([]*types.S
|
|||||||
last := len(chains)
|
last := len(chains)
|
||||||
for i, chain := range chains {
|
for i, chain := range chains {
|
||||||
// did we run out of performing chains?
|
// did we run out of performing chains?
|
||||||
if chain.gasPerf < 0 {
|
if !allowNegativeChains && chain.gasPerf < 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +389,7 @@ func (mp *MessagePool) selectMessagesGreedy(curTs, ts *types.TipSet) ([]*types.S
|
|||||||
tailLoop:
|
tailLoop:
|
||||||
for gasLimit >= minGas && last < len(chains) {
|
for gasLimit >= minGas && last < len(chains) {
|
||||||
// trim
|
// trim
|
||||||
chains[last].Trim(gasLimit, mp, baseFee, false)
|
chains[last].Trim(gasLimit, mp, baseFee, allowNegativeChains)
|
||||||
|
|
||||||
// push down if it hasn't been invalidated
|
// push down if it hasn't been invalidated
|
||||||
if chains[last].valid {
|
if chains[last].valid {
|
||||||
@ -409,7 +409,7 @@ tailLoop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if gasPerf < 0 we have no more profitable chains
|
// if gasPerf < 0 we have no more profitable chains
|
||||||
if chain.gasPerf < 0 {
|
if !allowNegativeChains && chain.gasPerf < 0 {
|
||||||
break tailLoop
|
break tailLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ func (mp *MessagePool) selectPriorityMessages(pending map[address.Address]map[ui
|
|||||||
return chains[i].Before(chains[j])
|
return chains[i].Before(chains[j])
|
||||||
})
|
})
|
||||||
|
|
||||||
if len(chains) != 0 && chains[0].gasPerf < 0 {
|
if !allowNegativeChains && len(chains) != 0 && chains[0].gasPerf < 0 {
|
||||||
log.Warnw("all priority messages in mpool have negative gas performance", "bestGasPerf", chains[0].gasPerf)
|
log.Warnw("all priority messages in mpool have negative gas performance", "bestGasPerf", chains[0].gasPerf)
|
||||||
return nil, gasLimit
|
return nil, gasLimit
|
||||||
}
|
}
|
||||||
@ -479,7 +479,7 @@ func (mp *MessagePool) selectPriorityMessages(pending map[address.Address]map[ui
|
|||||||
// 3. Merge chains until the block limit, as long as they have non-negative gas performance
|
// 3. Merge chains until the block limit, as long as they have non-negative gas performance
|
||||||
last := len(chains)
|
last := len(chains)
|
||||||
for i, chain := range chains {
|
for i, chain := range chains {
|
||||||
if chain.gasPerf < 0 {
|
if !allowNegativeChains && chain.gasPerf < 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,7 +497,7 @@ func (mp *MessagePool) selectPriorityMessages(pending map[address.Address]map[ui
|
|||||||
tailLoop:
|
tailLoop:
|
||||||
for gasLimit >= minGas && last < len(chains) {
|
for gasLimit >= minGas && last < len(chains) {
|
||||||
// trim, discarding negative performing messages
|
// trim, discarding negative performing messages
|
||||||
chains[last].Trim(gasLimit, mp, baseFee, false)
|
chains[last].Trim(gasLimit, mp, baseFee, allowNegativeChains)
|
||||||
|
|
||||||
// push down if it hasn't been invalidated
|
// push down if it hasn't been invalidated
|
||||||
if chains[last].valid {
|
if chains[last].valid {
|
||||||
@ -517,7 +517,7 @@ tailLoop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if gasPerf < 0 we have no more profitable chains
|
// if gasPerf < 0 we have no more profitable chains
|
||||||
if chain.gasPerf < 0 {
|
if !allowNegativeChains && chain.gasPerf < 0 {
|
||||||
break tailLoop
|
break tailLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,6 +729,11 @@ func TestPriorityMessageSelection2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPriorityMessageSelection3(t *testing.T) {
|
func TestPriorityMessageSelection3(t *testing.T) {
|
||||||
|
allowNegativeChains = false
|
||||||
|
defer func() {
|
||||||
|
allowNegativeChains = true
|
||||||
|
}()
|
||||||
|
|
||||||
mp, tma := makeTestMpool()
|
mp, tma := makeTestMpool()
|
||||||
|
|
||||||
// the actors
|
// the actors
|
||||||
|
Loading…
Reference in New Issue
Block a user