[Review] Add GASLIMIT opcode #374
Closed
karlb
started this conversation in
CIP Discussions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Simple Summary
Add the
GASLIMIT
opcode (0x45
) and add the gasLimit field to the block header.Abstract
This CIP consists of two related changes:
GASLIMIT
opcode to allow contracts to read this value during contract executionMotivation
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.
Specification
Add a
GASLIMIT
opcode at0x45
: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.Rationale
To provide maximum compatibility, the details are chosen 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.
Backwards Compatibility
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.
Implementation
An implementation suggestion is available at celo-org/celo-blockchain#2062
Security Considerations
This CIP has no known security implications.
License
This work is licensed under the Apache License, Version 2.0.
Beta Was this translation helpful? Give feedback.
All reactions