Fix check of EIP-3607 transaction for internal calls#1018
Fix check of EIP-3607 transaction for internal calls#1018sorpaas merged 3 commits intopolkadot-evm:masterfrom koushiro:improve-eip3607-check
Conversation
Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction. If the source of this EVM operation is from an internal call, like from `eth_call` or `eth_estimateGas` RPC, we will skip the checks for the EIP-3607.
|
@sorpaas PTAL |
| // Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction. | ||
| // If the source of this EVM operation is from an internal call, like from `eth_call` or `eth_estimateGas` RPC, | ||
| // we will skip the checks for the EIP-3607. | ||
| if is_transactional { | ||
| // EIP-3607: https://eips.ethereum.org/EIPS/eip-3607 | ||
| // Do not allow transactions for which `tx.sender` has any code deployed. | ||
| // | ||
| // We extend the principle of this EIP to also prevent `tx.sender` to be the address | ||
| // of a precompile. While mainnet Ethereum currently only has stateless precompiles, | ||
| // projects using Frontier can have stateful precompiles that can manage funds or | ||
| // which calls other contracts that expects this precompile address to be trustworthy. | ||
| if !<AccountCodes<T>>::get(source).is_empty() || precompiles.is_precompile(source) { | ||
| return Err(RunnerError { | ||
| error: Error::<T>::TransactionMustComeFromEOA, | ||
| weight, | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
| // Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction. | |
| // If the source of this EVM operation is from an internal call, like from `eth_call` or `eth_estimateGas` RPC, | |
| // we will skip the checks for the EIP-3607. | |
| if is_transactional { | |
| // EIP-3607: https://eips.ethereum.org/EIPS/eip-3607 | |
| // Do not allow transactions for which `tx.sender` has any code deployed. | |
| // | |
| // We extend the principle of this EIP to also prevent `tx.sender` to be the address | |
| // of a precompile. While mainnet Ethereum currently only has stateless precompiles, | |
| // projects using Frontier can have stateful precompiles that can manage funds or | |
| // which calls other contracts that expects this precompile address to be trustworthy. | |
| if !<AccountCodes<T>>::get(source).is_empty() || precompiles.is_precompile(source) { | |
| return Err(RunnerError { | |
| error: Error::<T>::TransactionMustComeFromEOA, | |
| weight, | |
| }); | |
| } | |
| } | |
| // Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction. | |
| // If the source of this EVM operation is from an internal call, like from `eth_call` or `eth_estimateGas` RPC, | |
| // we will skip the checks for the EIP-3607. | |
| // | |
| // EIP-3607: https://eips.ethereum.org/EIPS/eip-3607 | |
| // Do not allow transactions for which `tx.sender` has any code deployed. | |
| // | |
| // We extend the principle of this EIP to also prevent `tx.sender` to be the address | |
| // of a precompile. While mainnet Ethereum currently only has stateless precompiles, | |
| // projects using Frontier can have stateful precompiles that can manage funds or | |
| // which calls other contracts that expects this precompile address to be trustworthy. | |
| if is_transactional && !<AccountCodes<T>>::get(source).is_empty() || precompiles.is_precompile(source) { | |
| return Err(RunnerError { | |
| error: Error::<T>::TransactionMustComeFromEOA, | |
| weight, | |
| }); | |
| } |
There was a problem hiding this comment.
There was a problem hiding this comment.
Good question, I'd say in non-transactional context we don't care, @nanocryk to confirm
There was a problem hiding this comment.
Sounds good to me
@nanocryk so calling non-transactional call with stateful precompiles as the source will be fine, right?
There was a problem hiding this comment.
Please apply the other suggestions and change this to a single if statement.
|
Once this PR is merged, @sorpaas can you cherry-pick it to the polkadot-v0.9.36, polkadot-v0.9.37 and polkadot-v0.9.38 branches? |
| // Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction. | ||
| // If the source of this EVM operation is from an internal call, like from `eth_call` or `eth_estimateGas` RPC, | ||
| // we will skip the checks for the EIP-3607. | ||
| if is_transactional { | ||
| // EIP-3607: https://eips.ethereum.org/EIPS/eip-3607 | ||
| // Do not allow transactions for which `tx.sender` has any code deployed. | ||
| // | ||
| // We extend the principle of this EIP to also prevent `tx.sender` to be the address | ||
| // of a precompile. While mainnet Ethereum currently only has stateless precompiles, | ||
| // projects using Frontier can have stateful precompiles that can manage funds or | ||
| // which calls other contracts that expects this precompile address to be trustworthy. | ||
| if !<AccountCodes<T>>::get(source).is_empty() || precompiles.is_precompile(source) { | ||
| return Err(RunnerError { | ||
| error: Error::<T>::TransactionMustComeFromEOA, | ||
| weight, | ||
| }); | ||
| } | ||
| } |
There was a problem hiding this comment.
Please apply the other suggestions and change this to a single if statement.
* Improve check of EIP-3607 Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction. If the source of this EVM operation is from an internal call, like from `eth_call` or `eth_estimateGas` RPC, we will skip the checks for the EIP-3607. * fix eip-3607 tests * apply review suggtions
* Improve check of EIP-3607 Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction. If the source of this EVM operation is from an internal call, like from `eth_call` or `eth_estimateGas` RPC, we will skip the checks for the EIP-3607. * fix eip-3607 tests * apply review suggtions
Only check the restrictions of EIP-3607 if the source of the EVM operation is from an external transaction.
If the source of this EVM operation is from an internal call, like from
eth_calloreth_estimateGasRPC, we will skip the checks for the EIP-3607.related PR and discuss: #905
cc @tgmichel @nanocryk