3607: update to use empty code hash instead of codesize (#3632)

This commit is contained in:
Marius van der Wijden 2021-06-29 06:46:18 +02:00 committed by GitHub
parent 6854f0274c
commit 93e9a74809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -11,7 +11,7 @@ created: 2021-06-10
## Simple Summary ## Simple Summary
Do not allow transactions for which `tx.sender` has any code deployed, i.e. `tx.sender` has `CODESIZE != 0` Do not allow transactions for which `tx.sender` has any code deployed, i.e. `tx.sender` has a `CODEHASH != EMPTYCODEHASH`
## Abstract ## Abstract
@ -38,7 +38,8 @@ This EIP is to specify this behaviour to always forbid such transactions. This f
## Specification ## Specification
Any transaction where `tx.sender` has a `CODESIZE != 0` MUST be rejected as invalid. Any transaction where `tx.sender` has a `CODEHASH != EMPTYCODEHASH` MUST be rejected as invalid.
With `EMPTYCODEHASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470`.
## Rationale ## Rationale
@ -76,8 +77,8 @@ A set of test cases can be found [here](https://github.com/ethereum/tests/pull/8
The following check must be added to the state transition checks after checking that the nonce of the sender is correct. The following check must be added to the state transition checks after checking that the nonce of the sender is correct.
``` ```
// Make sure the sender is an EOA // Make sure the sender is an EOA
Set cs to the CodeSize of the sender account Set ch to the CodeHash of the sender account
if cs is not 0 then if cs is not equal to EmptyCodeHash then
return ErrSenderNoEOA return ErrSenderNoEOA
end if end if
``` ```

View File

@ -7,9 +7,9 @@ index 18777d8d4..3b25155c6 100644
} }
} }
+ // Make sure the sender is an EOA + // Make sure the sender is an EOA
+ if codesize := st.state.GetCodeSize(st.msg.From()); codesize != 0 { + if codeHash := st.state.GetCodeHash(st.msg.From()); codeHash != emptyCodeHash {
+ return fmt.Errorf("%w: address %v, codesize: %d", ErrSenderNoEOA, + return fmt.Errorf("%w: address %v, codehash: %s", ErrSenderNoEOA,
+ st.msg.From().Hex(), codesize) + st.msg.From().Hex(), codeHash)
+ } + }
// Make sure that transaction feeCap is greater than the baseFee (post london) // Make sure that transaction feeCap is greater than the baseFee (post london)
if st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber) { if st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber) {