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

Block gaslimit target decays to 3141592 with custom genesis gasLimit #2185

Closed
aiman opened this issue Feb 8, 2016 · 5 comments
Closed

Block gaslimit target decays to 3141592 with custom genesis gasLimit #2185

aiman opened this issue Feb 8, 2016 · 5 comments

Comments

@aiman
Copy link

aiman commented Feb 8, 2016

I am running tests on a private network using the example genesis block linked at the go-ethereum wiki page Private network, with the addition of a 1 ether allocation for address 0xffffffffffffffffffffffffffffffffffffffff.

{
    "nonce": "0xdeadbeefdeadbeef",
    "timestamp": "0x0",
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "extraData": "0x686f727365",
    "gasLimit": "0x8000000",
    "difficulty": "0x400",
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "coinbase": "0x3333333333333333333333333333333333333333",
    "alloc": {
        "fffffffffffffffffffffffffffffffffffffff0": {
            "balance": "1000000000000000000"
        }
    }
} 

Note I have left the gasLimit 0x8000000 (134217728) unchanged.

I am launching a single instance of geth 1.3.3 as follows:

geth \
    --mine \
    --networkid 1234 \
    --nodiscover \
    --maxpeers 0 \
    --genesis /deadbeef.json \
    --etherbase 0xffffffffffffffffffffffffffffffffffffffff

I observed that the block gasLimit decays toward the frontier gas target 3141592:

> eth.getBlock(0).gasLimit
134217728
> eth.getBlock(500).gasLimit
82347720
> eth.getBlock(1000).gasLimit
50523715
> eth.getBlock(1500).gasLimit
30998596

Updating the genesis block with a gasLimit of 0x2fefe2 (3141602), the gasLimit reaches 3141592 in the next block and remains there:

> eth.getBlock(0).gasLimit
3141602
> eth.getBlock(1).gasLimit
3141592
> eth.getBlock(50).gasLimit
3141592

But this is not expected behaviour. geth should respect the gasLimit that is set in the imported genesis block deadbeef.json.

I traced the issue to worker.commitNewWork(), which makes a call to core.CalcGasLimit(parent) to determine the gaslimit for the next block. It seems like core.CalcGasLimit() references params.GenesisGasLimit, but that variable is not updated from the imported genesis file and so remains at the geth default of 3141592. As a result the calculated gas target is adjusted downwards from the parent block gas limit towards 3141592.

@karalabe
Copy link
Member

karalabe commented Feb 8, 2016

The gas limit specified in the genesis block is the limit of the genesis block itself, not the chain. You cannot influence the chain's target gas limit from the outside using Geth. You could always build your own version of Geth that has a modified parameter set to target a different block limit, but I don't think we aim to support such a use case any time soon via CLI parameters.

@aiman
Copy link
Author

aiman commented Feb 8, 2016

That makes sense now. I did not think there was such a thing as a chain gas limit separate from the genesis block. Thanks!

@aiman aiman changed the title Block gas target decays to 3141592 with custom genesis gasLimit Block gaslimt target decays to 3141592 with custom genesis gasLimit Feb 8, 2016
@aiman aiman changed the title Block gaslimt target decays to 3141592 with custom genesis gasLimit Block gaslimit target decays to 3141592 with custom genesis gasLimit Feb 8, 2016
@narayanprusty
Copy link

@karalabe where in the source code I can change the gasLimit? You can point me to that file?

@Jacodelange
Copy link

@pnarayanprusty were you able to change the gasLimit of the chain?

@karalabe
Copy link
Member

karalabe commented Jul 4, 2017

Just set your target gas limit in your miner to whatever you want --targetgaslimit and mine till it gets there.

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

No branches or pull requests

4 participants