mixin the previous chain's effective performance to capture effect of dependencies

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
vyzo 2020-08-12 19:50:35 +03:00 committed by Jakub Sztandera
parent ccfb33c294
commit d25f386bb5
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -27,6 +27,7 @@ type msgChain struct {
gasLimit int64 gasLimit int64
gasPerf float64 gasPerf float64
effPerf float64 effPerf float64
bp float64
valid bool valid bool
merged bool merged bool
next *msgChain next *msgChain
@ -810,18 +811,13 @@ func (mc *msgChain) Trim(gasLimit int64, mp *MessagePool, baseFee types.BigInt,
mc.gasReward = new(big.Int).Sub(mc.gasReward, gasReward) mc.gasReward = new(big.Int).Sub(mc.gasReward, gasReward)
mc.gasLimit -= mc.msgs[i].Message.GasLimit mc.gasLimit -= mc.msgs[i].Message.GasLimit
if mc.gasLimit > 0 { if mc.gasLimit > 0 {
bp := 1.0
if mc.gasPerf != 0 { // prevent div by 0
bp = mc.effPerf / mc.gasPerf
}
mc.gasPerf = mp.getGasPerf(mc.gasReward, mc.gasLimit) mc.gasPerf = mp.getGasPerf(mc.gasReward, mc.gasLimit)
if mc.bp != 0 {
if mc.effPerf != 0 { // keep effPerf 0 if it is 0 mc.setEffPerf()
mc.effPerf = bp * mc.gasPerf
} }
} else { } else {
mc.gasPerf = 0 mc.gasPerf = 0
mc.effPerf = 0
} }
i-- i--
} }
@ -849,7 +845,17 @@ func (mc *msgChain) Invalidate() {
} }
func (mc *msgChain) SetEffectivePerf(bp float64) { func (mc *msgChain) SetEffectivePerf(bp float64) {
mc.effPerf = mc.gasPerf * bp mc.bp = bp
mc.setEffPerf()
}
func (mc *msgChain) setEffPerf() {
effPerf := mc.gasPerf * mc.bp
if mc.prev != nil {
effPerf = (effPerf*float64(mc.gasLimit) + mc.prev.effPerf*float64(mc.prev.gasLimit)) / float64(mc.gasLimit+mc.prev.gasLimit)
}
mc.effPerf = effPerf
} }
func (mc *msgChain) SetNullEffectivePerf() { func (mc *msgChain) SetNullEffectivePerf() {