mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 13:46:43 +00:00
miner: gas limit strategy, target 3141592 & def gas price 50 Shannon
This commit is contained in:
parent
fc79d32dd3
commit
d9fb2c1707
3 changed files with 21 additions and 6 deletions
|
|
@ -149,7 +149,7 @@ var (
|
||||||
GasPriceFlag = cli.StringFlag{
|
GasPriceFlag = cli.StringFlag{
|
||||||
Name: "gasprice",
|
Name: "gasprice",
|
||||||
Usage: "Sets the minimal gasprice when mining transactions",
|
Usage: "Sets the minimal gasprice when mining transactions",
|
||||||
Value: new(big.Int).Mul(big.NewInt(500), common.Shannon).String(),
|
Value: new(big.Int).Mul(big.NewInt(50), common.Shannon).String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
UnlockedAccountFlag = cli.StringFlag{
|
UnlockedAccountFlag = cli.StringFlag{
|
||||||
|
|
@ -309,12 +309,12 @@ var (
|
||||||
GpoMinGasPriceFlag = cli.StringFlag{
|
GpoMinGasPriceFlag = cli.StringFlag{
|
||||||
Name: "gpomin",
|
Name: "gpomin",
|
||||||
Usage: "Minimum suggested gas price",
|
Usage: "Minimum suggested gas price",
|
||||||
Value: new(big.Int).Mul(big.NewInt(1), common.Szabo).String(),
|
Value: new(big.Int).Mul(big.NewInt(50), common.Shannon).String(),
|
||||||
}
|
}
|
||||||
GpoMaxGasPriceFlag = cli.StringFlag{
|
GpoMaxGasPriceFlag = cli.StringFlag{
|
||||||
Name: "gpomax",
|
Name: "gpomax",
|
||||||
Usage: "Maximum suggested gas price",
|
Usage: "Maximum suggested gas price",
|
||||||
Value: new(big.Int).Mul(big.NewInt(100), common.Szabo).String(),
|
Value: new(big.Int).Mul(big.NewInt(100), common.Shannon).String(),
|
||||||
}
|
}
|
||||||
GpoFullBlockRatioFlag = cli.IntFlag{
|
GpoFullBlockRatioFlag = cli.IntFlag{
|
||||||
Name: "gpofull",
|
Name: "gpofull",
|
||||||
|
|
|
||||||
|
|
@ -69,12 +69,27 @@ func CalcTD(block, parent *types.Block) *big.Int {
|
||||||
|
|
||||||
// CalcGasLimit computes the gas limit of the next block after parent.
|
// CalcGasLimit computes the gas limit of the next block after parent.
|
||||||
// The result may be modified by the caller.
|
// The result may be modified by the caller.
|
||||||
|
// This is miner strategy, not consensus protocol.
|
||||||
func CalcGasLimit(parent *types.Block) *big.Int {
|
func CalcGasLimit(parent *types.Block) *big.Int {
|
||||||
decay := new(big.Int).Div(parent.GasLimit(), params.GasLimitBoundDivisor)
|
// contrib = (parentGasUsed * 3 / 2) / 1024
|
||||||
contrib := new(big.Int).Mul(parent.GasUsed(), big.NewInt(3))
|
contrib := new(big.Int).Mul(parent.GasUsed(), big.NewInt(3))
|
||||||
contrib = contrib.Div(contrib, big.NewInt(2))
|
contrib = contrib.Div(contrib, big.NewInt(2))
|
||||||
contrib = contrib.Div(contrib, params.GasLimitBoundDivisor)
|
contrib = contrib.Div(contrib, params.GasLimitBoundDivisor)
|
||||||
|
|
||||||
|
// decay = parentGasLimit / 1024 -1
|
||||||
|
decay := new(big.Int).Div(parent.GasLimit(), params.GasLimitBoundDivisor)
|
||||||
|
decay.Sub(decay, big.NewInt(1))
|
||||||
|
|
||||||
|
/*
|
||||||
|
strategy: gasLimit of block-to-mine is set depending on parent's
|
||||||
|
gasUsed value. if parentGasUsed > parentGasLimit * (2/3) then we
|
||||||
|
increase it, otherwise lower it (or leave it unchanged if it's right
|
||||||
|
at that usage) the amount increased/decreased depends on how far away
|
||||||
|
from parentGasLimit * (2/3) parentGasUsed is.
|
||||||
|
|
||||||
|
however, if we're below the target (GenesisGasLimit) we increase the
|
||||||
|
limit as much as we can (parentGasLimit / 1024 -1)
|
||||||
|
*/
|
||||||
gl := new(big.Int).Sub(parent.GasLimit(), decay)
|
gl := new(big.Int).Sub(parent.GasLimit(), decay)
|
||||||
gl = gl.Add(gl, contrib)
|
gl = gl.Add(gl, contrib)
|
||||||
gl = gl.Add(gl, big.NewInt(1))
|
gl = gl.Add(gl, big.NewInt(1))
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ var (
|
||||||
Sha256WordGas = big.NewInt(12) //
|
Sha256WordGas = big.NewInt(12) //
|
||||||
|
|
||||||
MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be.
|
MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be.
|
||||||
GenesisGasLimit = big.NewInt(5000) // Gas limit of the Genesis block.
|
GenesisGasLimit = big.NewInt(3141592) // Gas limit of the Genesis block.
|
||||||
|
|
||||||
Sha3Gas = big.NewInt(30) // Once per SHA3 operation.
|
Sha3Gas = big.NewInt(30) // Once per SHA3 operation.
|
||||||
Sha256Gas = big.NewInt(60) //
|
Sha256Gas = big.NewInt(60) //
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue