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

Besu increases gasLimit when no --target-gas-limit is specified #7614

Open
phearnot opened this issue Sep 13, 2024 · 3 comments
Open

Besu increases gasLimit when no --target-gas-limit is specified #7614

phearnot opened this issue Sep 13, 2024 · 3 comments
Labels
bug Something isn't working non mainnet (private networks) not related to mainnet features - covers privacy, permissioning, IBFT2, QBFT P3 Medium (ex: JSON-RPC request not working with a specific client library due to loose spec assumtion)

Comments

@phearnot
Copy link

I'm attempting to limit gas usage in a private network, but Besu seems not to honor gasLimit from genesis config, and instead increases gas limit up to the value configured for sepolia (0x1c9c380). However, the docs for the --target-gas-limit command line option state that

If a value for target-gas-limit is not specified, the block gas limit remains at the value specified in the genesis file.

Steps to reproduce

I'm using the following genesis.json:

{
  "alloc": {},
  "baseFeePerGas": "0x3b9aca00",
  "blobGasUsed": null,
  "coinbase": "0x0000000000000000000000000000000000000000",
  "config": {
    "arrowGlacierBlock": 0,
    "berlinBlock": 0,
    "byzantiumBlock": 0,
    "cancunTime": 0,
    "chainId": 88817,
    "constantinopleBlock": 0,
    "daoForkBlock": 0,
    "eip150Block": 0,
    "eip155Block": 0,
    "eip158Block": 0,
    "ethash": {},
    "grayGlacierBlock": 0,
    "homesteadBlock": 0,
    "istanbulBlock": 0,
    "londonBlock": 0,
    "muirGlacierBlock": 0,
    "petersburgBlock": 0,
    "shanghaiTime": 0,
    "terminalTotalDifficulty": 0,
    "terminalTotalDifficultyPassed": true
  },
  "difficulty": "0x0",
  "excessBlobGas": null,
  "extraData": "0x",
  "gasLimit": "0x1000000",
  "gasUsed": "0x0",
  "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "nonce": "0x0",
  "number": "0x0",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp": "0x660e5e00"
}

I'm starting the docker container with besu 24.8.0:

docker run -v ./genesis-testnet.json:/etc/genesis.json --rm -p 8551:8551 hyperledger/besu:latest --genesis-file=/etc/genesis.json --engine-rpc-enabled --engine-jwt-disabled --engine-host-allowlist='*' --target-gas-limit=16777216

Then I attempt to manually forge the new block:

❯ curl -sd '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":54}'  0:8551 | jq '.result|{hash, gasLimit}'
{
  "hash": "0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69",
  "gasLimit": "0x1000000"
}

❯ curl -sd '{
  "jsonrpc":"2.0","method":"engine_forkchoiceUpdatedV3","params":[{
  "headBlockHash":"0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69",
  "safeBlockHash":"0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69",
  "finalizedBlockHash":"0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69"
  },{
  "timestamp":"0x66e412d8",
  "prevRandao":"0x1c5f0544ea78e1127df6e8bf1dfbbf32665a16a475c8f77b4463327594825747",
  "suggestedFeeRecipient":"0x6c7d59240748b02d93d70586a99834bd94d0bddb",
  "withdrawals":[],
  "parentBeaconBlockRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"}],"id":1
}'  0:8551 | jq '.result.payloadId'
"0x7172362e07312627"

❯ curl -sd '{"jsonrpc":"2.0","method":"engine_getPayloadV3","params":["0x7172362e07312627"],"id":1}' 0:8551 | jq .result.executionPayload.gasLimit
"0x1003fff"

Note that gas limit has increased from 0x1000000 in genesis to 0x1003fff. Now I add --target-gas-limit=16777216 to the command line and retry:

❯ curl -sd '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x0", false],"id":54}'  0:8551 | jq '.result|{hash, gasLimit}'
{
  "hash": "0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69",
  "gasLimit": "0x1000000"
}
❯ curl -sd '{
  "jsonrpc":"2.0","method":"engine_forkchoiceUpdatedV3","params":[{
  "headBlockHash":"0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69",
  "safeBlockHash":"0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69",
  "finalizedBlockHash":"0x697ebb1c00a66913ac23d12b68b71f33e3184c4782fd08084e6d89afd3561d69"
  },{
  "timestamp":"0x66e412ff",
  "prevRandao":"0x1c5f0544ea78e1127df6e8bf1dfbbf32665a16a475c8f77b4463327594825747",
  "suggestedFeeRecipient":"0x6c7d59240748b02d93d70586a99834bd94d0bddb",
  "withdrawals":[],
  "parentBeaconBlockRoot":"0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421"}],"id":1
}'  0:8551 | jq '.result.payloadId'
"0x7172362e07312602"
❯ curl -sd '{"jsonrpc":"2.0","method":"engine_getPayloadV3","params":["0x7172362e07312602"],"id":1}' 0:8551 | jq .result.executionPayload.gasLimit
"0x1000000"

I expect besu to keep gasLimit when no --target-gas-limit is set, but for some reason it does not work as expected.

@phearnot phearnot changed the title Besu increases gasLimit when no --target-gas-limit is specified Besu increases gasLimit when no --target-gas-limit is specified Sep 13, 2024
@phearnot phearnot changed the title Besu increases gasLimit when no --target-gas-limit is specified Besu increases gasLimit when no --target-gas-limit is specified Sep 13, 2024
@macfarla macfarla self-assigned this Sep 16, 2024
@macfarla
Copy link
Contributor

I have reproduced the same behaviour as you. The gasLimit in the header increases when target-gas-limit is absent from the cmd line. Next step is to find in the code where this calculation is done.

@macfarla macfarla added the non mainnet (private networks) not related to mainnet features - covers privacy, permissioning, IBFT2, QBFT label Oct 15, 2024
@macfarla
Copy link
Contributor

unassigning myself as I'm not actively looking at this right now.

@macfarla macfarla removed their assignment Oct 15, 2024
@actioncoininc
Copy link

@jflo jflo added bug Something isn't working P3 Medium (ex: JSON-RPC request not working with a specific client library due to loose spec assumtion) labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working non mainnet (private networks) not related to mainnet features - covers privacy, permissioning, IBFT2, QBFT P3 Medium (ex: JSON-RPC request not working with a specific client library due to loose spec assumtion)
Projects
None yet
Development

No branches or pull requests

4 participants