-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix check of EIP-3607 transaction for internal calls #1018
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 |
frame/evm/src/runner/stack.rs
Outdated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I'd say in non-transactional context we don't care, @nanocryk to confirm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply the other suggestions and change this to a single if statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed this was missing, thank you @koushiro! A test for it would be great.
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise.
frame/evm/src/runner/stack.rs
Outdated
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_call
oreth_estimateGas
RPC, we will skip the checks for the EIP-3607.related PR and discuss: #905
cc @tgmichel @nanocryk