From f2c312a487ce51cca9b29c0b690317fe3b754d9f Mon Sep 17 00:00:00 2001 From: hyeonLewis Date: Fri, 27 Dec 2024 13:35:58 +0900 Subject: [PATCH 1/2] Add EXTCODEHASH opcode for Kaia --- KIPs/kip-239.md | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 KIPs/kip-239.md diff --git a/KIPs/kip-239.md b/KIPs/kip-239.md new file mode 100644 index 0000000..273890b --- /dev/null +++ b/KIPs/kip-239.md @@ -0,0 +1,71 @@ +--- +kip: 239 +title: EXTCODEHASH opcode for Kaia +author: Lewis (@hyeonLewis) +discussions-to: TBD +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/). From 906185afb7b79c0a3e4df5291b35ce321b817fc1 Mon Sep 17 00:00:00 2001 From: hyeonLewis Date: Fri, 27 Dec 2024 13:42:11 +0900 Subject: [PATCH 2/2] Add discussion-to --- KIPs/kip-239.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KIPs/kip-239.md b/KIPs/kip-239.md index 273890b..24769de 100644 --- a/KIPs/kip-239.md +++ b/KIPs/kip-239.md @@ -2,7 +2,7 @@ kip: 239 title: EXTCODEHASH opcode for Kaia author: Lewis (@hyeonLewis) -discussions-to: TBD +discussions-to: https://github.com/kaiachain/kips/issues/38 status: Draft type: Core created: 2024-12-27