cip | title | author | discussions-to | status | type | category | created | license |
---|---|---|---|---|---|---|---|---|
60 |
Add GASLIMIT opcode and block header field |
Karl Bartel (@karlb) |
Final |
Standards Track |
Ring 0 |
2023-04-05 |
Apache 2.0 |
Add the GASLIMIT
opcode (0x45
) and add the gasLimit field to the block header.
This CIP consists of two related changes:
- Adding the respective block gas limit to each block header
- Providing the
GASLIMIT
opcode to allow contracts to read this value during contract execution
In addition to providing useful information, the suggested changes provide the gas limit information in the same way Ethereum does. This makes development easier for people coming from Ethereum and makes more Ethereum based tools work out of the box.
Add a GASLIMIT
opcode at 0x45
Op | Input | Output | Cost |
---|---|---|---|
0x45 | 0 | 1 | 2 |
Adding the gas limit to the block header will change the header's hash value for blocks after the hard fork. For the hash calculation, the gas limit will be appended to the list of the hashed values.
In JSON-RPC responses, the gas limit will show up under the gasLimit
key as before, but the value will be fetched from the block header. As a result, gas limits are also returned for pruned blocks after implementing this CIP, which matches the behaviour on Ethereum.
To provide maximum compatibility, the details are chosen to match Ethereum where possible.
One exception is the order of values in the header hash calculation, since having the new element at the end makes it easier to handle it as an optional field in the serialized RLP, reducing the need to explicitly check the hard fork when (de)serializing block headers. At the moment, Celo can't exactly match Ethereum's headers anyway due to the Istanbul consensus data in the header. If there is an opportunity to adapt Ethereum's hashes in later CIPs, moving the gas limit field can be done at that time.
Since a new opcode affects the consensus, this change has to be part of a hard fork. From a user's perspective, backwards compatibility is maintained.
See this PR
This CIP has no known security implications.
This work is licensed under the Apache License, Version 2.0.