Skip to content
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: verify the eth tip #2864

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions primitives/src/unchecked_extrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::{evm::EthereumTransactionMessage, signature::AcalaMultiSignature, to_bytes, Address, Balance};
use frame_support::ensure;
use frame_support::{
dispatch::{DispatchInfo, GetDispatchInfo},
traits::{ExtrinsicCall, Get},
Expand Down Expand Up @@ -106,6 +107,12 @@ where
target: "evm", "Ethereum eth_msg: {:?}", eth_msg
);

// module_evm::Call::eth_call, ensure tip is zero to prevent miner attacks
// module_evm::Call::eth_call_v2, tip encoded in gas_price
if eth_msg.gas_price.is_zero() {
ensure!(eth_msg.tip.is_zero(), InvalidTransaction::BadProof);
}

if !eth_msg.access_list.len().is_zero() {
// Not yet supported, require empty
return Err(InvalidTransaction::BadProof.into());
Expand Down Expand Up @@ -154,6 +161,12 @@ where
target: "evm", "Eip2930 eth_msg: {:?}", eth_msg
);

// module_evm::Call::eth_call, ensure tip is zero to prevent miner attacks
// module_evm::Call::eth_call_v2, tip encoded in gas_price
if eth_msg.gas_price.is_zero() {
ensure!(eth_msg.tip.is_zero(), InvalidTransaction::BadProof);
}

let (tx_gas_price, tx_gas_limit) = if eth_msg.gas_price.is_zero() {
recover_sign_data(&eth_msg, TxFeePerGas::get(), StorageDepositPerByte::get())
.ok_or(InvalidTransaction::BadProof)?
Expand Down
Loading
Loading