hyperledger / besu

An enterprise-grade Java-based, Apache 2.0 licensed Ethereum client https://wiki.hyperledger.org/display/besu
https://www.hyperledger.org/projects/besu
Apache License 2.0
1.44k stars 765 forks source link

Fix parsing `gasLimit` parameter when its value is > `Long.MAX_VALUE` #7116

Closed fab-10 closed 2 months ago

fab-10 commented 2 months ago

PR description

When calling eth_estimateGas with the gas field set to the maximum value 0xffffffffffffffff or anything greater than 0x7fffffffffffffff, the endpoint returns and error says parameters are invalid, due to the fact that we use a long to fix the value, and it cannot fit these values. This is not the correct behavior, so the fix is to cap the value to Long.MAX_VALUE, in case the input field has a greater value, since in practice gas limit will not reach such value. The deserializer has been rename to GasDeserializer since it is now specific to gas and not generic long values.

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

Locally, you can run these tests to catch failures early: