@@ -14,13 +14,16 @@ import (
14
14
"github.com/filecoin-project/lotus/chain/messagepool/gasguess"
15
15
"github.com/filecoin-project/lotus/chain/types"
16
16
"github.com/filecoin-project/lotus/chain/vm"
17
+ "github.com/filecoin-project/specs-actors/actors/abi"
17
18
)
18
19
19
20
var bigBlockGasLimit = big .NewInt (build .BlockGasLimit )
20
21
21
22
// this is *temporary* mutilation until we have implemented uncapped miner penalties -- it will go
22
23
// away in the next fork.
23
- var allowNegativeChains = true
24
+ func allowNegativeChains (epoch abi.ChainEpoch ) bool {
25
+ return epoch < 100000000000
26
+ }
24
27
25
28
const MaxBlocks = 15
26
29
@@ -104,7 +107,7 @@ func (mp *MessagePool) selectMessagesOptimal(curTs, ts *types.TipSet, tq float64
104
107
return chains [i ].Before (chains [j ])
105
108
})
106
109
107
- if ! allowNegativeChains && len (chains ) != 0 && chains [0 ].gasPerf < 0 {
110
+ if ! allowNegativeChains ( curTs . Height ()) && len (chains ) != 0 && chains [0 ].gasPerf < 0 {
108
111
log .Warnw ("all messages in mpool have non-positive gas performance" , "bestGasPerf" , chains [0 ].gasPerf )
109
112
return result , nil
110
113
}
@@ -157,7 +160,7 @@ func (mp *MessagePool) selectMessagesOptimal(curTs, ts *types.TipSet, tq float64
157
160
last := len (chains )
158
161
for i , chain := range chains {
159
162
// did we run out of performing chains?
160
- if ! allowNegativeChains && chain .gasPerf < 0 {
163
+ if ! allowNegativeChains ( curTs . Height ()) && chain .gasPerf < 0 {
161
164
break
162
165
}
163
166
@@ -221,7 +224,7 @@ tailLoop:
221
224
for gasLimit >= minGas && last < len (chains ) {
222
225
// trim if necessary
223
226
if chains [last ].gasLimit > gasLimit {
224
- chains [last ].Trim (gasLimit , mp , baseFee , allowNegativeChains )
227
+ chains [last ].Trim (gasLimit , mp , baseFee , allowNegativeChains ( curTs . Height ()) )
225
228
}
226
229
227
230
// push down if it hasn't been invalidated
@@ -247,7 +250,7 @@ tailLoop:
247
250
}
248
251
249
252
// if gasPerf < 0 we have no more profitable chains
250
- if ! allowNegativeChains && chain .gasPerf < 0 {
253
+ if ! allowNegativeChains ( curTs . Height ()) && chain .gasPerf < 0 {
251
254
break tailLoop
252
255
}
253
256
@@ -288,7 +291,7 @@ tailLoop:
288
291
}
289
292
290
293
// dependencies fit, just trim it
291
- chain .Trim (gasLimit - depGasLimit , mp , baseFee , allowNegativeChains )
294
+ chain .Trim (gasLimit - depGasLimit , mp , baseFee , allowNegativeChains ( curTs . Height ()) )
292
295
last += i
293
296
continue tailLoop
294
297
}
@@ -353,7 +356,7 @@ func (mp *MessagePool) selectMessagesGreedy(curTs, ts *types.TipSet) ([]*types.S
353
356
return chains [i ].Before (chains [j ])
354
357
})
355
358
356
- if ! allowNegativeChains && len (chains ) != 0 && chains [0 ].gasPerf < 0 {
359
+ if ! allowNegativeChains ( curTs . Height ()) && len (chains ) != 0 && chains [0 ].gasPerf < 0 {
357
360
log .Warnw ("all messages in mpool have non-positive gas performance" , "bestGasPerf" , chains [0 ].gasPerf )
358
361
return result , nil
359
362
}
@@ -364,7 +367,7 @@ func (mp *MessagePool) selectMessagesGreedy(curTs, ts *types.TipSet) ([]*types.S
364
367
last := len (chains )
365
368
for i , chain := range chains {
366
369
// did we run out of performing chains?
367
- if ! allowNegativeChains && chain .gasPerf < 0 {
370
+ if ! allowNegativeChains ( curTs . Height ()) && chain .gasPerf < 0 {
368
371
break
369
372
}
370
373
@@ -393,7 +396,7 @@ func (mp *MessagePool) selectMessagesGreedy(curTs, ts *types.TipSet) ([]*types.S
393
396
tailLoop:
394
397
for gasLimit >= minGas && last < len (chains ) {
395
398
// trim
396
- chains [last ].Trim (gasLimit , mp , baseFee , allowNegativeChains )
399
+ chains [last ].Trim (gasLimit , mp , baseFee , allowNegativeChains ( curTs . Height ()) )
397
400
398
401
// push down if it hasn't been invalidated
399
402
if chains [last ].valid {
@@ -413,7 +416,7 @@ tailLoop:
413
416
}
414
417
415
418
// if gasPerf < 0 we have no more profitable chains
416
- if ! allowNegativeChains && chain .gasPerf < 0 {
419
+ if ! allowNegativeChains ( curTs . Height ()) && chain .gasPerf < 0 {
417
420
break tailLoop
418
421
}
419
422
@@ -475,15 +478,15 @@ func (mp *MessagePool) selectPriorityMessages(pending map[address.Address]map[ui
475
478
return chains [i ].Before (chains [j ])
476
479
})
477
480
478
- if ! allowNegativeChains && len (chains ) != 0 && chains [0 ].gasPerf < 0 {
481
+ if ! allowNegativeChains ( ts . Height ()) && len (chains ) != 0 && chains [0 ].gasPerf < 0 {
479
482
log .Warnw ("all priority messages in mpool have negative gas performance" , "bestGasPerf" , chains [0 ].gasPerf )
480
483
return nil , gasLimit
481
484
}
482
485
483
486
// 3. Merge chains until the block limit, as long as they have non-negative gas performance
484
487
last := len (chains )
485
488
for i , chain := range chains {
486
- if ! allowNegativeChains && chain .gasPerf < 0 {
489
+ if ! allowNegativeChains ( ts . Height ()) && chain .gasPerf < 0 {
487
490
break
488
491
}
489
492
@@ -501,7 +504,7 @@ func (mp *MessagePool) selectPriorityMessages(pending map[address.Address]map[ui
501
504
tailLoop:
502
505
for gasLimit >= minGas && last < len (chains ) {
503
506
// trim, discarding negative performing messages
504
- chains [last ].Trim (gasLimit , mp , baseFee , allowNegativeChains )
507
+ chains [last ].Trim (gasLimit , mp , baseFee , allowNegativeChains ( ts . Height ()) )
505
508
506
509
// push down if it hasn't been invalidated
507
510
if chains [last ].valid {
@@ -521,7 +524,7 @@ tailLoop:
521
524
}
522
525
523
526
// if gasPerf < 0 we have no more profitable chains
524
- if ! allowNegativeChains && chain .gasPerf < 0 {
527
+ if ! allowNegativeChains ( ts . Height ()) && chain .gasPerf < 0 {
525
528
break tailLoop
526
529
}
527
530
0 commit comments