-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from hyeonLewis/kip-239
[KIP-239] EXTCODEHASH opcode for Kaia
- Loading branch information
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
--- | ||
kip: 239 | ||
title: EXTCODEHASH opcode for Kaia | ||
author: Lewis (@hyeonLewis) | ||
discussions-to: https://github.com/kaiachain/kips/issues/38 | ||
status: Draft | ||
type: Core | ||
created: 2024-12-27 | ||
--- | ||
|
||
## Simple Summary | ||
|
||
Clarifies and aligns the implementation of `EXTCODEHASH` opcode with [EIP-1052](https://eips.ethereum.org/EIPS/eip-1052) and [EIP-2929](https://eips.ethereum.org/EIPS/eip-2929). | ||
|
||
## Abstract | ||
|
||
This KIP explains the historical implementation differences of `EXTCODEHASH` in Kaia compared to Ethereum. It also specifies the complete alignment with EIPs starting from the Prague hardfork. | ||
|
||
## Motivation | ||
|
||
The `EXTCODEHASH` opcode in Kaia has had implementation differences from EIPs. These difference was fixed in the Cancun hardfork but require further alignment, particularly regarding gas costs after the Prague hardfork. This KIP aims to provide clear explanation of the changes and ensure complete compatibility with EIPs. | ||
|
||
## Specification | ||
|
||
### Parameters | ||
|
||
| Parameter | Value | | ||
| ----------------- | -------------------------------------------------------------------- | | ||
| `ZERO_CODE_HASH` | `0x0000000000000000000000000000000000000000000000000000000000000000` | | ||
| `EMPTY_CODE_HASH` | `0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470` | | ||
|
||
### EIP-1052 | ||
|
||
The `EXTCODEHASH` opcode according to EIP-1052 should return: | ||
|
||
- For non-existent accounts: `ZERO_CODE_HASH` | ||
- For accounts with no code: `EMPTY_CODE_HASH` | ||
|
||
In Kaia, the `EXTCODEHASH` opcode returns: | ||
|
||
| Hardfork | Non-existent | No code | Note | | ||
| ------------- | ----------------- | ----------------- | -------------------------------------------------------- | | ||
| Before Cancun | `EMPTY_CODE_HASH` | `EMPTY_CODE_HASH` | Wrong EIP-1052 implementation for non-existent accounts. | | ||
| Cancun | `ZERO_CODE_HASH` | `EMPTY_CODE_HASH` | Fully compatible with EIP-1052. | | ||
| Prague | `ZERO_CODE_HASH` | `EMPTY_CODE_HASH` | | | ||
|
||
### EIP-2929 | ||
|
||
The constant gas cost for `EXTCODEHASH` opcode, which is same as `WarmStorageReadCostEIP2929`, should be 100 after the Kore hardfork which introduced EIP-2929. | ||
|
||
In Kaia, the `EXTCODEHASH` opcode has the following gas costs: | ||
|
||
| Hardfork | Constant gas cost | Note | | ||
| ----------- | ----------------- | -------------------------------------------------------- | | ||
| Before Kore | 400 | `ExtcodeHashGasConstantinople` | | ||
| Kore | 100 | Brought EIP-2929. | | ||
| Cancun | 400 | Fixed `EXTCODEHASH`, but accidentally shadowed EIP-2929. | | ||
| Prague | 100 | Fully compatible with EIP-2929. | | ||
|
||
## Backwards Compatibility | ||
|
||
The fix of gas cost for `EXTCODEHASH` opcode is backwards incompatible since the Prague hardfork. Note that the EIP-1052 implementation was already fixed in the Cancun hardfork. | ||
|
||
## References | ||
|
||
[EIP-1052](https://eips.ethereum.org/EIPS/eip-1052) | ||
[EIP-2929](https://eips.ethereum.org/EIPS/eip-2929) | ||
|
||
## Copyright | ||
|
||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |