Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

karalabe
Copy link
Member

No description provided.

@@ -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

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.

Copy link
Member Author

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).

Copy link

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.

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.
Copy link
Member

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)
Copy link
Member

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.

Copy link
Member Author

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 {
Copy link
Contributor

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
Copy link
Contributor

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.

@karalabe
Copy link
Member Author

Hard limit removed, ceil is increased in increments of 1/1024. PTAL

@obscuren obscuren added this to the 1.6.0 milestone Feb 13, 2017
@fjl fjl closed this Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants