From aeaf565f88e283a2349891cca7bde01bcbd5b987 Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Mon, 26 Feb 2024 15:09:06 +0800 Subject: [PATCH 01/15] Add EIP: EXTCODEHASH optimize --- EIPS/eip-x.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 EIPS/eip-x.md diff --git a/EIPS/eip-x.md b/EIPS/eip-x.md new file mode 100644 index 00000000000000..d228023270777b --- /dev/null +++ b/EIPS/eip-x.md @@ -0,0 +1,84 @@ +--- +eip: x +title: EXTCODEHASH optimize +description: Modify the output value of a situation in EXTCODEHASH +author: Jame (@ZWJKFLC) +discussions-to: https://ethereum-magicians.org/t/tbd/tbd +type: Standards Track +category: Core +status: Draft +created: 2024-02-26 +--- + + + +## Abstract + +This EIP proposal is an optimization for [EIP-1052](https://eips.ethereum.org/EIPS/eip-1052), +For addresses with balance but the code is still 0x, the codehash should still be 0x. + + +## Motivation + +`EIP-1052` was proposed to save gas fees. +In order to include the role of `BALANCE`, let the codehash of the address without balance be 0x, and the codehash of the address with balance be hash(0x). +The contract address can be calculated in advance. Whether it is create or create2, it is possible that the contract is not created but has a balance. For security, you can actually only use keccak256(add.code) == keccak256(bytes(" ")) instead of add.codehash == 0, which makes the original intention of EIP-1052 meaningless. +For example, uniswap V2 uses stored addresses to determine whether a contract exists. If this `EXTCODEHASH` is optimized, can save a huge amount of gas. + +If someone uses a codehash of 0x to determine whether a contract has been created, due to intuition and the lack of details in many documents, they will not think that the codehash of an address with a balance will change from 0x to hash (0x). If someone maliciously attacks at this time, it will cause some bad effects. + + + +## Specification +The behaviour of `EXTCODEHASH` is changed in the following way: + +1. When calling EXTCODEHASH, the codehash of the address with balance is still 0x + +## Rationale +Change [go-ethereum](https://github.com/rjl493456442/go-ethereum/blob/master/core/vm/instructions.go#L539) code + +After modification +```go +func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) { + slot := callContext.stack.peek() + address := common.BigToAddress(slot) + + codeHash := interpreter.evm.StateDB.GetCodeHash(address).Bytes() + // hash(0x)=c5d246... + targetCodeHash := common.HexToHash("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") + if bytes.Equal(codeHash, targetCodeHash[:]) { + slot.SetUint64(0) + } else { + slot.SetBytes(codeHash) + } + return nil, nil +} +``` + +Source code +```go +func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) { + slot := callContext.stack.peek() + address := common.BigToAddress(slot) + if interpreter.evm.StateDB.Empty(address) { + slot.SetUint64(0) + } else { + slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(address).Bytes()) + } + return nil, nil +} +``` + + + +## Backwards Compatibility +Needs discussion. +It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is hash(0x). + +## Security Considerations +Needs discussion. +It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is hash(0x). + +## Copyright +Copyright and related rights waived via [CC0](../LICENSE.md). + \ No newline at end of file From 804e975339de291511cacc5dc570112efc18e1a9 Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Mon, 26 Feb 2024 15:16:41 +0800 Subject: [PATCH 02/15] Update and rename eip-x.md to eip-8261.md --- EIPS/{eip-x.md => eip-8261.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-x.md => eip-8261.md} (99%) diff --git a/EIPS/eip-x.md b/EIPS/eip-8261.md similarity index 99% rename from EIPS/eip-x.md rename to EIPS/eip-8261.md index d228023270777b..20e847ff43a5de 100644 --- a/EIPS/eip-x.md +++ b/EIPS/eip-8261.md @@ -1,5 +1,5 @@ --- -eip: x +eip: 8261 title: EXTCODEHASH optimize description: Modify the output value of a situation in EXTCODEHASH author: Jame (@ZWJKFLC) From 9a6b7419d66340cc569ed6db134d47078ac2a10c Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Mon, 26 Feb 2024 15:28:32 +0800 Subject: [PATCH 03/15] Fix EIP Walidator and Markdown Linter checks --- EIPS/eip-8261.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/EIPS/eip-8261.md b/EIPS/eip-8261.md index 20e847ff43a5de..962600cced5398 100644 --- a/EIPS/eip-8261.md +++ b/EIPS/eip-8261.md @@ -3,10 +3,10 @@ eip: 8261 title: EXTCODEHASH optimize description: Modify the output value of a situation in EXTCODEHASH author: Jame (@ZWJKFLC) -discussions-to: https://ethereum-magicians.org/t/tbd/tbd -type: Standards Track +discussions-to: https://ethereum-magicians.org/t/eip-8261-extcodehash-optimize/18946 category: Core status: Draft +type: Standards Track created: 2024-02-26 --- @@ -14,7 +14,7 @@ created: 2024-02-26 ## Abstract -This EIP proposal is an optimization for [EIP-1052](https://eips.ethereum.org/EIPS/eip-1052), +This EIP proposal is an optimization for [EIP-1052](./eip-1052), For addresses with balance but the code is still 0x, the codehash should still be 0x. @@ -30,12 +30,15 @@ If someone uses a codehash of 0x to determine whether a contract has been create ## Specification + The behaviour of `EXTCODEHASH` is changed in the following way: 1. When calling EXTCODEHASH, the codehash of the address with balance is still 0x + ## Rationale -Change [go-ethereum](https://github.com/rjl493456442/go-ethereum/blob/master/core/vm/instructions.go#L539) code + +Code reference for go-ethereum After modification ```go @@ -70,15 +73,19 @@ func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx ``` - ## Backwards Compatibility + Needs discussion. It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is hash(0x). + ## Security Considerations + Needs discussion. It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is hash(0x). + ## Copyright Copyright and related rights waived via [CC0](../LICENSE.md). + \ No newline at end of file From 853ffcb8d6584fca37c2e8f338f64303ad1c5c1b Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Mon, 26 Feb 2024 15:30:16 +0800 Subject: [PATCH 04/15] update --- EIPS/eip-8261.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-8261.md b/EIPS/eip-8261.md index 962600cced5398..235c2f60e51b49 100644 --- a/EIPS/eip-8261.md +++ b/EIPS/eip-8261.md @@ -4,9 +4,9 @@ title: EXTCODEHASH optimize description: Modify the output value of a situation in EXTCODEHASH author: Jame (@ZWJKFLC) discussions-to: https://ethereum-magicians.org/t/eip-8261-extcodehash-optimize/18946 -category: Core status: Draft type: Standards Track +category: Core created: 2024-02-26 --- @@ -41,6 +41,7 @@ The behaviour of `EXTCODEHASH` is changed in the following way: Code reference for go-ethereum After modification + ```go func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) { slot := callContext.stack.peek() @@ -58,7 +59,9 @@ func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx } ``` + Source code + ```go func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) { slot := callContext.stack.peek() @@ -88,4 +91,3 @@ It is unclear whether there is a situation where codehash is actually used to de ## Copyright Copyright and related rights waived via [CC0](../LICENSE.md). - \ No newline at end of file From d031fc0fa864a493730c38016cff9d6e1d8ddee0 Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Mon, 26 Feb 2024 15:32:09 +0800 Subject: [PATCH 05/15] Fix Markdown Linter checks --- EIPS/eip-8261.md | 1 + 1 file changed, 1 insertion(+) diff --git a/EIPS/eip-8261.md b/EIPS/eip-8261.md index 235c2f60e51b49..1945bc9045c8e0 100644 --- a/EIPS/eip-8261.md +++ b/EIPS/eip-8261.md @@ -89,5 +89,6 @@ It is unclear whether there is a situation where codehash is actually used to de ## Copyright + Copyright and related rights waived via [CC0](../LICENSE.md). From c733ec30eeb1170cfe59d1608d023208109c5750 Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Tue, 27 Feb 2024 11:39:51 +0800 Subject: [PATCH 06/15] update eip number --- EIPS/eip-8261.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-8261.md b/EIPS/eip-8261.md index 1945bc9045c8e0..040c28066d5dde 100644 --- a/EIPS/eip-8261.md +++ b/EIPS/eip-8261.md @@ -1,9 +1,9 @@ --- -eip: 8261 +eip: 7637 title: EXTCODEHASH optimize description: Modify the output value of a situation in EXTCODEHASH author: Jame (@ZWJKFLC) -discussions-to: https://ethereum-magicians.org/t/eip-8261-extcodehash-optimize/18946 +discussions-to: https://ethereum-magicians.org/t/eip-7637-extcodehash-optimize/18946 status: Draft type: Standards Track category: Core From 571645dbbe9ecf61d48afb779de31861b981c9b7 Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Tue, 27 Feb 2024 11:41:57 +0800 Subject: [PATCH 07/15] Update file names and fix link references --- EIPS/{eip-8261.md => eip-7637.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename EIPS/{eip-8261.md => eip-7637.md} (97%) diff --git a/EIPS/eip-8261.md b/EIPS/eip-7637.md similarity index 97% rename from EIPS/eip-8261.md rename to EIPS/eip-7637.md index 040c28066d5dde..7e850f3fbc820c 100644 --- a/EIPS/eip-8261.md +++ b/EIPS/eip-7637.md @@ -14,7 +14,7 @@ created: 2024-02-26 ## Abstract -This EIP proposal is an optimization for [EIP-1052](./eip-1052), +This EIP proposal is an optimization for [EIP-1052](./eip-1052.md), For addresses with balance but the code is still 0x, the codehash should still be 0x. From f05a8ea9ecf569c01fd52412c76b204d6f53a34b Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Wed, 28 Feb 2024 10:59:46 +0800 Subject: [PATCH 08/15] Fix expression format,Optimize expression,Update Reference Implementation --- EIPS/eip-7637.md | 83 +++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index 7e850f3fbc820c..7e2c98b716c3e2 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -8,84 +8,89 @@ status: Draft type: Standards Track category: Core created: 2024-02-26 +requires: 1052 --- ## Abstract -This EIP proposal is an optimization for [EIP-1052](./eip-1052.md), -For addresses with balance but the code is still 0x, the codehash should still be 0x. +This proposal is an optimization for [EIP-1052](./eip-1052.md), +For addresses with a balance, but without code, the codehash should still be `0x`. +When an address `add.code == 0x` and `add.balance != 0`, `add.codehash==0` is required instead of `add.codehash==keccak256("")` ## Motivation -`EIP-1052` was proposed to save gas fees. -In order to include the role of `BALANCE`, let the codehash of the address without balance be 0x, and the codehash of the address with balance be hash(0x). -The contract address can be calculated in advance. Whether it is create or create2, it is possible that the contract is not created but has a balance. For security, you can actually only use keccak256(add.code) == keccak256(bytes(" ")) instead of add.codehash == 0, which makes the original intention of EIP-1052 meaningless. -For example, uniswap V2 uses stored addresses to determine whether a contract exists. If this `EXTCODEHASH` is optimized, can save a huge amount of gas. - -If someone uses a codehash of 0x to determine whether a contract has been created, due to intuition and the lack of details in many documents, they will not think that the codehash of an address with a balance will change from 0x to hash (0x). If someone maliciously attacks at this time, it will cause some bad effects. - +EIP-1052 was proposed to save gas fees. However, due to some flaws in the set specifications, in actual applications, due to safety concerns, they will not actually be used. In order for eip-1052 to be truly useful, it should be optimized. ## Specification The behaviour of `EXTCODEHASH` is changed in the following way: -1. When calling EXTCODEHASH, the codehash of the address with balance is still 0x +1. When calling `EXTCODEHASH`, the codehash of the address with balance is still `0x` ## Rationale -Code reference for go-ethereum +In its specific implementation, in order to include the role of `BALANCE`, let the codehash of the address without balance be `0x`, and the codehash of the address with balance be `keccak256("")`. + +The contract address can be calculated in advance. Whether it is `CREATE` or `CREATE2`, it is possible that the contract is not created but has a balance. For security, you can actually only use `keccak256(add.code) == keccak256("")` instead of `add.codehash == 0`, which makes the original intention of EIP-1052 meaningless. + +For example, uniswap V2 uses stored addresses to determine whether a contract exists. If this `EXTCODEHASH` is optimized, can save a huge amount of gas. + +If someone uses a `add.codehash==0` to determine whether a contract has been created, due to intuition and the lack of details in many documents, they will not think that the codehash of an address with a balance will change from `0x` to `keccak256("")`. If someone maliciously attacks at this time, it will cause some bad effects. + + +## Reference Implementation + +Code reference for execution-specs After modification -```go -func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) { - slot := callContext.stack.peek() - address := common.BigToAddress(slot) - - codeHash := interpreter.evm.StateDB.GetCodeHash(address).Bytes() - // hash(0x)=c5d246... - targetCodeHash := common.HexToHash("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470") - if bytes.Equal(codeHash, targetCodeHash[:]) { - slot.SetUint64(0) - } else { - slot.SetBytes(codeHash) - } - return nil, nil -} +```python +def extcodehash(evm: Evm) -> None: + address = to_address(pop(evm.stack)) + charge_gas(evm, GAS_CODE_HASH) + account = get_account(evm.env.state, address) + codehash = U256.from_be_bytes(keccak256(account.code)) + if codehash == U256(hexstr="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"): + codehash = U256(0) + push(evm.stack, codehash) + evm.pc += 1 ``` Source code -```go -func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, callContext *callCtx) ([]byte, error) { - slot := callContext.stack.peek() - address := common.BigToAddress(slot) - if interpreter.evm.StateDB.Empty(address) { - slot.SetUint64(0) - } else { - slot.SetBytes(interpreter.evm.StateDB.GetCodeHash(address).Bytes()) - } - return nil, nil -} +```python +def extcodehash(evm: Evm) -> None: + address = to_address(pop(evm.stack)) + charge_gas(evm, GAS_CODE_HASH) + account = get_account(evm.env.state, address) + if account == EMPTY_ACCOUNT: + codehash = U256(0) + else: + codehash = U256.from_be_bytes(keccak256(account.code)) + + push(evm.stack, codehash) + evm.pc += 1 ``` ## Backwards Compatibility + Needs discussion. -It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is hash(0x). +It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is `keccak256("")`. ## Security Considerations + Needs discussion. -It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is hash(0x). +It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is `keccak256("")`. ## Copyright From 73884633ec4cda59721c2902111eb0f369342c95 Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Wed, 28 Feb 2024 11:09:50 +0800 Subject: [PATCH 09/15] Fix some descriptions and EIP Walidator check --- EIPS/eip-7637.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index 7e2c98b716c3e2..146dcfbd4ff657 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -22,7 +22,7 @@ When an address `add.code == 0x` and `add.balance != 0`, `add.codehash==0` is re ## Motivation -EIP-1052 was proposed to save gas fees. However, due to some flaws in the set specifications, in actual applications, due to safety concerns, they will not actually be used. In order for eip-1052 to be truly useful, it should be optimized. +EIP-1052 was proposed to save gas fees. However, due to some flaws in the set specifications, in actual applications, due to safety concerns, they will not actually be used. In order for EIP-1052 to be truly useful, it should be optimized. ## Specification @@ -34,15 +34,22 @@ The behaviour of `EXTCODEHASH` is changed in the following way: ## Rationale -In its specific implementation, in order to include the role of `BALANCE`, let the codehash of the address without balance be `0x`, and the codehash of the address with balance be `keccak256("")`. +EIP-1052 In order to include the function of `BALANCE`, let the `EXTCODEHASH` of the address without balance be `0x`, and the `EXTCODEHASH` of the address with balance be `keccak256("")`. -The contract address can be calculated in advance. Whether it is `CREATE` or `CREATE2`, it is possible that the contract is not created but has a balance. For security, you can actually only use `keccak256(add.code) == keccak256("")` instead of `add.codehash == 0`, which makes the original intention of EIP-1052 meaningless. +The contract address can be calculated in advance. Whether it is `CREATE` or `CREATE2`, it is possible that the contract is not created but has a balance. For security, You can actually only use `keccak256(add.code) == keccak256("")` or `add.code.length ==0` instead of `add.codehash == 0`,, which makes the original intention of EIP-1052 meaningless. For example, uniswap V2 uses stored addresses to determine whether a contract exists. If this `EXTCODEHASH` is optimized, can save a huge amount of gas. If someone uses a `add.codehash==0` to determine whether a contract has been created, due to intuition and the lack of details in many documents, they will not think that the codehash of an address with a balance will change from `0x` to `keccak256("")`. If someone maliciously attacks at this time, it will cause some bad effects. +## Backwards Compatibility + + +Needs discussion. +It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is `keccak256("")`. + + ## Reference Implementation Code reference for execution-specs @@ -79,13 +86,6 @@ def extcodehash(evm: Evm) -> None: ``` -## Backwards Compatibility - - -Needs discussion. -It is unclear whether there is a situation where codehash is actually used to determine whether an address has a balance and the codehash is `keccak256("")`. - - ## Security Considerations From a8893950dd940667961f8561e90bc6907b9e794e Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Wed, 28 Feb 2024 11:19:33 +0800 Subject: [PATCH 10/15] update Motivation --- EIPS/eip-7637.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index 146dcfbd4ff657..1837421e63eff3 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -24,6 +24,8 @@ When an address `add.code == 0x` and `add.balance != 0`, `add.codehash==0` is re EIP-1052 was proposed to save gas fees. However, due to some flaws in the set specifications, in actual applications, due to safety concerns, they will not actually be used. In order for EIP-1052 to be truly useful, it should be optimized. +If someone uses it based on the proposal of EIP-1052 and does not notice the change when `add.balance != 0`, there may be security issues. + ## Specification From 25d76bb93d72f768d376b3a0a2c5d08f8c0a3c4b Mon Sep 17 00:00:00 2001 From: Jame <71260863+ZWJKFLC@users.noreply.github.com> Date: Wed, 17 Apr 2024 10:58:38 +0800 Subject: [PATCH 11/15] Update EIPS/eip-7637.md Co-authored-by: g11tech --- EIPS/eip-7637.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index 1837421e63eff3..d7eb223a61c60a 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -31,7 +31,7 @@ If someone uses it based on the proposal of EIP-1052 and does not notice the cha The behaviour of `EXTCODEHASH` is changed in the following way: -1. When calling `EXTCODEHASH`, the codehash of the address with balance is still `0x` +1. When calling `EXTCODEHASH`, the codehash of the address with balance but no code is still `0x` ## Rationale From 0cec6c44fdb297de656c05d671d617a311a55492 Mon Sep 17 00:00:00 2001 From: Jame <71260863+ZWJKFLC@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:42:13 +0800 Subject: [PATCH 12/15] Update EIPS/eip-7637.md Co-authored-by: g11tech --- EIPS/eip-7637.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index d7eb223a61c60a..7b205c16913373 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -1,6 +1,6 @@ --- eip: 7637 -title: EXTCODEHASH optimize +title: Optimize EOA EXTCODEHASH description: Modify the output value of a situation in EXTCODEHASH author: Jame (@ZWJKFLC) discussions-to: https://ethereum-magicians.org/t/eip-7637-extcodehash-optimize/18946 From c756abb5a781fb686582f162d090fd3d3ce8595e Mon Sep 17 00:00:00 2001 From: Jame <71260863+ZWJKFLC@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:42:21 +0800 Subject: [PATCH 13/15] Update EIPS/eip-7637.md Co-authored-by: g11tech --- EIPS/eip-7637.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index 7b205c16913373..0101d805d89d18 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -1,7 +1,7 @@ --- eip: 7637 title: Optimize EOA EXTCODEHASH -description: Modify the output value of a situation in EXTCODEHASH +description: Modify the output value of EXTCODEHASH for EOA accounts to `0x` author: Jame (@ZWJKFLC) discussions-to: https://ethereum-magicians.org/t/eip-7637-extcodehash-optimize/18946 status: Draft From 8c3e379cb1c7efa1eb72a779dbcabeb96e051bcf Mon Sep 17 00:00:00 2001 From: zwjkf <503755414@qq.com> Date: Wed, 12 Jun 2024 09:51:28 +0800 Subject: [PATCH 14/15] Remove excess spaces --- EIPS/eip-7637.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index 0101d805d89d18..ae9f8abe123ea6 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -1,6 +1,6 @@ --- eip: 7637 -title: Optimize EOA EXTCODEHASH +title: Optimize EOA EXTCODEHASH description: Modify the output value of EXTCODEHASH for EOA accounts to `0x` author: Jame (@ZWJKFLC) discussions-to: https://ethereum-magicians.org/t/eip-7637-extcodehash-optimize/18946 From 07aa3acd288afca4f2c290d87bafca7b4e4b344a Mon Sep 17 00:00:00 2001 From: Jame <71260863+ZWJKFLC@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:18:11 +0800 Subject: [PATCH 15/15] Update EIPS/eip-7637.md Fix code logic Co-authored-by: g11tech --- EIPS/eip-7637.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/EIPS/eip-7637.md b/EIPS/eip-7637.md index ae9f8abe123ea6..8bc356b8e06853 100644 --- a/EIPS/eip-7637.md +++ b/EIPS/eip-7637.md @@ -63,9 +63,12 @@ def extcodehash(evm: Evm) -> None: address = to_address(pop(evm.stack)) charge_gas(evm, GAS_CODE_HASH) account = get_account(evm.env.state, address) - codehash = U256.from_be_bytes(keccak256(account.code)) - if codehash == U256(hexstr="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"): + if account == EMPTY_ACCOUNT: codehash = U256(0) + else: + codehash = U256.from_be_bytes(keccak256(account.code)) + if codehash == U256(hexstr="c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"): + codehash = U256(0) push(evm.stack, codehash) evm.pc += 1 ```