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

@karalabe karalabe commented Sep 22, 2016

No description provided.

@karalabe karalabe force-pushed the karalabe:dynamic-gas-limits branch Sep 22, 2016
params/protocol_params.go Outdated
@@ -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

This comment has been minimized.

@Gustav-Simonsson

Gustav-Simonsson Sep 22, 2016
Member

Would put all of these in the miner package since it's a miner strategy params, not consensus protocol.

This comment has been minimized.

@karalabe

karalabe Sep 22, 2016
Author Member

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

This comment has been minimized.

@Gustav-Simonsson

Gustav-Simonsson Sep 22, 2016
Member

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.

@karalabe karalabe force-pushed the karalabe:dynamic-gas-limits branch Sep 22, 2016
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.

This comment has been minimized.

@pirapira

pirapira Sep 23, 2016
Member

Is this constant used anywhere?

core/blockchain.go Outdated
// 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)

This comment has been minimized.

@pirapira

pirapira Sep 23, 2016
Member

MinGasLimit might be useful here.

This comment has been minimized.

@karalabe

karalabe Sep 23, 2016
Author Member

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.

core/block_validator.go Outdated

// 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 {

This comment has been minimized.

@Arachnid

Arachnid Sep 24, 2016
Contributor

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

This comment has been minimized.

@Arachnid

Arachnid Sep 24, 2016
Contributor

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 karalabe force-pushed the karalabe:dynamic-gas-limits branch Sep 28, 2016
@karalabe
Copy link
Member Author

@karalabe karalabe commented Sep 28, 2016

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

@karalabe karalabe force-pushed the karalabe:dynamic-gas-limits branch Sep 28, 2016
@karalabe karalabe force-pushed the karalabe:dynamic-gas-limits branch to 8bd421f Sep 28, 2016
@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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants