New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd, core, params: dynamic gas ceiling on heavy blocks #3025
Conversation
136f836
to
23adc66
Compare
@@ -43,6 +47,15 @@ var ( | |||
MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be. | |||
GenesisGasLimit = big.NewInt(4712388) // Gas limit of the Genesis block. | |||
TargetGasLimit = new(big.Int).Set(GenesisGasLimit) // The artificial target | |||
HardGasLimit *big.Int // Hard gas limit never to allow going over |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would put all of these in the miner package since it's a miner strategy params, not consensus protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would introduce a core -> miner dependency, since I'm updating the current ceil during import (it should probably be moved into some chain config, but that's invasive for now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK well in that case maybe put in new file in package params
? Just want to avoid having miner strategy params in a file called "protocol_params" and right next to consensus protocol params. Came to think of it, we should actually move TargetGasLimit
too (though later I suppose to minimize diff now) since it's also miner strat.
c73d01c
to
530406e
Compare
MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be. | ||
GenesisGasLimit = big.NewInt(4712388) // Gas limit of the Genesis block. | ||
TargetGasLimit = new(big.Int).Set(GenesisGasLimit) // The artificial target | ||
MinGasLimit = big.NewInt(5000) // Minimum the gas limit may ever be. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this constant used anywhere?
// Update the current gas limit (mining only) based on import times | ||
params.CurrentGasCeilLock.Lock() | ||
if time.Since(bstart) > params.BlockTimeLimit { | ||
params.CurrentGasCeil = new(big.Int).Div(params.CurrentGasCeil, params.CurrentGasCeilDiv) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinGasLimit
might be useful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was also thinking that we could just point to to 0 since it would take a lot of time for the chain to react anyway.
|
||
// however, if we're now below the target (TargetGasLimit) we increase the | ||
// limit as much as we can (parentGasLimit / 1024 -1) | ||
if gl.Cmp(params.TargetGasLimit) < 0 { | ||
gl.Add(parent.GasLimit(), decay) | ||
gl.Set(common.BigMin(gl, params.TargetGasLimit)) | ||
} | ||
// If the hard gas limit is exceeded, mandatorilly decrease | ||
if params.HardGasLimit != nil && gl.Cmp(params.HardGasLimit) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if someone sets HardGasLimit < TargetGasLimit?
@@ -963,12 +964,21 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) { | |||
events = append(events, ChainSplitEvent{block, logs}) | |||
} | |||
stats.processed++ | |||
|
|||
// Update the current gas limit (mining only) based on import times |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make sense to divide by gas used, so it's measuring how quickly/slowly gas is consumed, rather than how long the block takes.
530406e
to
95d7a17
Compare
Hard limit removed, ceil is increased in increments of 1/1024. PTAL |
95d7a17
to
3ea2fdd
Compare
3ea2fdd
to
8bd421f
Compare
No description provided.