mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
Modifying miner.recommit flag and its adjustment function. (#370)
* changed min/max/current recommit values * Remove Hardcoded min/max * Code Sanitization * Skipping tests for constant recommit interval * Adding default miner.recommit value * Minor Change
This commit is contained in:
parent
8c3423ca7c
commit
4fb3f5ddee
3 changed files with 27 additions and 19 deletions
|
|
@ -88,7 +88,7 @@ var Defaults = Config{
|
||||||
Miner: miner.Config{
|
Miner: miner.Config{
|
||||||
GasCeil: 8000000,
|
GasCeil: 8000000,
|
||||||
GasPrice: big.NewInt(params.GWei),
|
GasPrice: big.NewInt(params.GWei),
|
||||||
Recommit: 3 * time.Second,
|
Recommit: 125 * time.Second,
|
||||||
},
|
},
|
||||||
TxPool: core.DefaultTxPoolConfig,
|
TxPool: core.DefaultTxPoolConfig,
|
||||||
RPCGasCap: 50000000,
|
RPCGasCap: 50000000,
|
||||||
|
|
|
||||||
|
|
@ -389,24 +389,27 @@ func (w *worker) close() {
|
||||||
|
|
||||||
// recalcRecommit recalculates the resubmitting interval upon feedback.
|
// recalcRecommit recalculates the resubmitting interval upon feedback.
|
||||||
func recalcRecommit(minRecommit, prev time.Duration, target float64, inc bool) time.Duration {
|
func recalcRecommit(minRecommit, prev time.Duration, target float64, inc bool) time.Duration {
|
||||||
var (
|
// var (
|
||||||
prevF = float64(prev.Nanoseconds())
|
// prevF = float64(prev.Nanoseconds())
|
||||||
next float64
|
// next float64
|
||||||
)
|
// )
|
||||||
if inc {
|
// if inc {
|
||||||
next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target+intervalAdjustBias)
|
// next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target+intervalAdjustBias)
|
||||||
max := float64(maxRecommitInterval.Nanoseconds())
|
// max := float64(maxRecommitInterval.Nanoseconds())
|
||||||
if next > max {
|
// if next > max {
|
||||||
next = max
|
// next = max
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target-intervalAdjustBias)
|
// next = prevF*(1-intervalAdjustRatio) + intervalAdjustRatio*(target-intervalAdjustBias)
|
||||||
min := float64(minRecommit.Nanoseconds())
|
// min := float64(minRecommit.Nanoseconds())
|
||||||
if next < min {
|
// if next < min {
|
||||||
next = min
|
// next = min
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return time.Duration(int64(next))
|
// log.Info("Recalc Commit", "Prev", prev, "Next", next)
|
||||||
|
|
||||||
|
//returning the Same prev value to keep the recommit interval constant
|
||||||
|
return time.Duration(int64(prev))
|
||||||
}
|
}
|
||||||
|
|
||||||
// newWorkLoop is a standalone goroutine to submit new sealing work upon received events.
|
// newWorkLoop is a standalone goroutine to submit new sealing work upon received events.
|
||||||
|
|
|
||||||
|
|
@ -434,10 +434,15 @@ func testRegenerateMiningBlock(t *testing.T, chainConfig *params.ChainConfig, en
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAdjustIntervalEthash(t *testing.T) {
|
func TestAdjustIntervalEthash(t *testing.T) {
|
||||||
|
// Skipping this test as recommit interval would remain constant
|
||||||
|
t.Skip()
|
||||||
testAdjustInterval(t, ethashChainConfig, ethash.NewFaker())
|
testAdjustInterval(t, ethashChainConfig, ethash.NewFaker())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAdjustIntervalClique(t *testing.T) {
|
func TestAdjustIntervalClique(t *testing.T) {
|
||||||
|
|
||||||
|
// Skipping this test as recommit interval would remain constant
|
||||||
|
t.Skip()
|
||||||
testAdjustInterval(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
testAdjustInterval(t, cliqueChainConfig, clique.New(cliqueChainConfig.Clique, rawdb.NewMemoryDatabase()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue