diff --git a/frame/ethereum/src/lib.rs b/frame/ethereum/src/lib.rs index 7d30528a0b..a3e645c429 100644 --- a/frame/ethereum/src/lib.rs +++ b/frame/ethereum/src/lib.rs @@ -492,7 +492,7 @@ impl Pallet { let (base_fee, _) = T::FeeCalculator::min_gas_price(); let (who, _) = pallet_evm::Pallet::::account_basic(&origin); - let mut v = CheckEvmTransaction::::new( + let mut v = CheckEvmTransaction::new( who.clone(), CheckEvmTransactionConfig { evm_config: T::config(), @@ -506,16 +506,14 @@ impl Pallet { proof_size_base_cost, ); - T::OnCheckEvmTransaction::::on_check_evm_transaction( - &mut v, &origin, - ) - .map_err(|e| e.0)?; + T::OnCheckEvmTransaction::on_check_evm_transaction(&mut v, &origin) + .map_err(|e| InvalidTransactionWrapper::from(e).0)?; - v.validate_in_pool_for() + v.validate_in_pool() .and_then(|v| v.with_chain_id()) .and_then(|v| v.with_base_fee()) .and_then(|v| v.with_balance()) - .map_err(|e| e.0)?; + .map_err(|e| InvalidTransactionWrapper::from(e).0)?; // EIP-3607: https://eips.ethereum.org/EIPS/eip-3607 // Do not allow transactions for which `tx.sender` has any code deployed. @@ -867,7 +865,7 @@ impl Pallet { let (base_fee, _) = T::FeeCalculator::min_gas_price(); let (who, _) = pallet_evm::Pallet::::account_basic(&origin); - let mut v = CheckEvmTransaction::::new( + let mut v = CheckEvmTransaction::new( who, CheckEvmTransactionConfig { evm_config: T::config(), @@ -881,16 +879,14 @@ impl Pallet { proof_size_base_cost, ); - T::OnCheckEvmTransaction::::on_check_evm_transaction( - &mut v, &origin, - ) - .map_err(|e| TransactionValidityError::Invalid(e.0))?; + T::OnCheckEvmTransaction::on_check_evm_transaction(&mut v, &origin) + .map_err(|e| TransactionValidityError::Invalid(InvalidTransactionWrapper::from(e).0))?; v.validate_in_block() .and_then(|v| v.with_chain_id()) .and_then(|v| v.with_base_fee()) .and_then(|v| v.with_balance()) - .map_err(|e| TransactionValidityError::Invalid(e.0))?; + .map_err(|e| TransactionValidityError::Invalid(InvalidTransactionWrapper::from(e).0))?; Ok(()) } diff --git a/frame/ethereum/src/mock.rs b/frame/ethereum/src/mock.rs index 339c5f7814..a53e80b85e 100644 --- a/frame/ethereum/src/mock.rs +++ b/frame/ethereum/src/mock.rs @@ -180,7 +180,7 @@ impl pallet_evm::Config for Test { type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type Timestamp = Timestamp; type WeightInfo = (); - type OnCheckEvmTransaction> = (); + type OnCheckEvmTransaction = (); } parameter_types! { diff --git a/frame/evm/precompile/dispatch/src/mock.rs b/frame/evm/precompile/dispatch/src/mock.rs index 37f1547f43..5d9b501370 100644 --- a/frame/evm/precompile/dispatch/src/mock.rs +++ b/frame/evm/precompile/dispatch/src/mock.rs @@ -166,7 +166,7 @@ impl pallet_evm::Config for Test { type GasLimitPovSizeRatio = (); type Timestamp = Timestamp; type WeightInfo = (); - type OnCheckEvmTransaction> = (); + type OnCheckEvmTransaction = (); } pub(crate) struct MockHandle { diff --git a/frame/evm/src/lib.rs b/frame/evm/src/lib.rs index 816ced3279..d01faaae1d 100644 --- a/frame/evm/src/lib.rs +++ b/frame/evm/src/lib.rs @@ -179,10 +179,7 @@ pub mod pallet { } // Called when transaction info for validation is created - type OnCheckEvmTransaction>: OnCheckEvmTransaction< - Self, - E, - >; + type OnCheckEvmTransaction: OnCheckEvmTransaction; } #[pallet::call] @@ -1054,12 +1051,18 @@ impl OnCreate for Tuple { } } -pub trait OnCheckEvmTransaction> { - fn on_check_evm_transaction(v: &mut CheckEvmTransaction, origin: &H160) -> Result<(), E>; +pub trait OnCheckEvmTransaction { + fn on_check_evm_transaction( + v: &mut CheckEvmTransaction, + origin: &H160, + ) -> Result<(), TransactionValidationError>; } -impl> OnCheckEvmTransaction for () { - fn on_check_evm_transaction(_v: &mut CheckEvmTransaction, _origin: &H160) -> Result<(), E> { +impl OnCheckEvmTransaction for () { + fn on_check_evm_transaction( + _v: &mut CheckEvmTransaction, + _origin: &H160, + ) -> Result<(), TransactionValidationError> { Ok(()) } } diff --git a/frame/evm/src/mock.rs b/frame/evm/src/mock.rs index 82f81800af..acc51e5ca1 100644 --- a/frame/evm/src/mock.rs +++ b/frame/evm/src/mock.rs @@ -33,7 +33,6 @@ use sp_std::{boxed::Box, prelude::*, str::FromStr}; use crate::{ EnsureAddressNever, EnsureAddressRoot, FeeCalculator, IdentityAddressMapping, IsPrecompileResult, Precompile, PrecompileHandle, PrecompileResult, PrecompileSet, - TransactionValidationError, }; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -163,7 +162,7 @@ impl crate::Config for Test { type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type Timestamp = Timestamp; type WeightInfo = (); - type OnCheckEvmTransaction> = (); + type OnCheckEvmTransaction = (); } /// Example PrecompileSet with only Identity precompile. diff --git a/frame/evm/src/runner/stack.rs b/frame/evm/src/runner/stack.rs index 513c21c9a5..ee5a511749 100644 --- a/frame/evm/src/runner/stack.rs +++ b/frame/evm/src/runner/stack.rs @@ -377,7 +377,7 @@ where weight = weight.saturating_add(inner_weight); let nonce = nonce.unwrap_or(source_account.nonce); - let mut v = fp_evm::CheckEvmTransaction::::new( + let mut v = fp_evm::CheckEvmTransaction::new( source_account, fp_evm::CheckEvmTransactionConfig { evm_config, @@ -402,13 +402,20 @@ where proof_size_base_cost, ); - T::OnCheckEvmTransaction::>::on_check_evm_transaction(&mut v, &source) - .map_err(|error| RunnerError { error, weight })?; + T::OnCheckEvmTransaction::on_check_evm_transaction(&mut v, &source).map_err(|error| { + RunnerError { + error: error.into(), + weight, + } + })?; v.validate_in_block() .and_then(|v| v.with_base_fee()) .and_then(|v| v.with_balance()) - .map_err(|error| RunnerError { error, weight })?; + .map_err(|error| RunnerError { + error: error.into(), + weight, + })?; Ok(()) } diff --git a/precompiles/tests-external/lib.rs b/precompiles/tests-external/lib.rs index d903980a24..24302734c3 100644 --- a/precompiles/tests-external/lib.rs +++ b/precompiles/tests-external/lib.rs @@ -254,6 +254,7 @@ mod tests { type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; + type OnCheckEvmTransaction = (); } parameter_types! { diff --git a/primitives/evm/src/validation.rs b/primitives/evm/src/validation.rs index c6f1ed2342..b8e3987f0b 100644 --- a/primitives/evm/src/validation.rs +++ b/primitives/evm/src/validation.rs @@ -45,18 +45,17 @@ pub struct CheckEvmTransactionConfig<'config> { } #[derive(Debug)] -pub struct CheckEvmTransaction<'config, E: From> { +pub struct CheckEvmTransaction<'config> { pub who: Account, pub config: CheckEvmTransactionConfig<'config>, pub transaction: CheckEvmTransactionInput, pub weight_limit: Option, pub proof_size_base_cost: Option, - _marker: sp_std::marker::PhantomData, } /// Transaction validation errors #[repr(u8)] -#[derive(num_enum::FromPrimitive, num_enum::IntoPrimitive, Debug)] +#[derive(num_enum::FromPrimitive, num_enum::IntoPrimitive, Debug, PartialEq)] pub enum TransactionValidationError { /// The transaction gas limit is too low GasLimitTooLow, @@ -83,7 +82,7 @@ pub enum TransactionValidationError { UnknownError, } -impl<'config, E: From> CheckEvmTransaction<'config, E> { +impl<'config> CheckEvmTransaction<'config> { pub fn new( who: Account, config: CheckEvmTransactionConfig<'config>, @@ -97,49 +96,48 @@ impl<'config, E: From> CheckEvmTransaction<'config, transaction, weight_limit, proof_size_base_cost, - _marker: Default::default(), } } - pub fn validate_in_pool_for(&self) -> Result<&Self, E> { + pub fn validate_in_pool(&self) -> Result<&Self, TransactionValidationError> { if self.transaction.nonce < self.who.nonce { - return Err(TransactionValidationError::TxNonceTooLow.into()); + return Err(TransactionValidationError::TxNonceTooLow); } self.validate_common() } - pub fn validate_in_block(&self) -> Result<&Self, E> { + pub fn validate_in_block(&self) -> Result<&Self, TransactionValidationError> { if self.transaction.nonce > self.who.nonce { - return Err(TransactionValidationError::TxNonceTooHigh.into()); + return Err(TransactionValidationError::TxNonceTooHigh); } else if self.transaction.nonce < self.who.nonce { - return Err(TransactionValidationError::TxNonceTooLow.into()); + return Err(TransactionValidationError::TxNonceTooLow); } self.validate_common() } - pub fn with_chain_id(&self) -> Result<&Self, E> { + pub fn with_chain_id(&self) -> Result<&Self, TransactionValidationError> { // Chain id matches the one in the signature. if let Some(chain_id) = self.transaction.chain_id { if chain_id != self.config.chain_id { - return Err(TransactionValidationError::InvalidChainId.into()); + return Err(TransactionValidationError::InvalidChainId); } } Ok(self) } - pub fn with_base_fee(&self) -> Result<&Self, E> { + pub fn with_base_fee(&self) -> Result<&Self, TransactionValidationError> { // Get fee data from either a legacy or typed transaction input. let (gas_price, _) = self.transaction_fee_input()?; if self.config.is_transactional || gas_price > U256::zero() { // Transaction max fee is at least the current base fee. if gas_price < self.config.base_fee { - return Err(TransactionValidationError::GasPriceTooLow.into()); + return Err(TransactionValidationError::GasPriceTooLow); } } Ok(self) } - pub fn with_balance(&self) -> Result<&Self, E> { + pub fn with_balance(&self) -> Result<&Self, TransactionValidationError> { // Get fee data from either a legacy or typed transaction input. let (max_fee_per_gas, _) = self.transaction_fee_input()?; @@ -156,7 +154,7 @@ impl<'config, E: From> CheckEvmTransaction<'config, if self.config.is_transactional || fee > U256::zero() { let total_payment = self.transaction.value.saturating_add(fee); if self.who.balance < total_payment { - return Err(TransactionValidationError::BalanceTooLow.into()); + return Err(TransactionValidationError::BalanceTooLow); } } Ok(self) @@ -165,7 +163,9 @@ impl<'config, E: From> CheckEvmTransaction<'config, // Returns the max_fee_per_gas (or gas_price for legacy txns) as well as an optional // effective_gas_price for EIP-1559 transactions. effective_gas_price represents // the total (fee + tip) that would be paid given the current base_fee. - pub fn transaction_fee_input(&self) -> Result<(U256, Option), E> { + pub fn transaction_fee_input( + &self, + ) -> Result<(U256, Option), TransactionValidationError> { match ( self.transaction.gas_price, self.transaction.max_fee_per_gas, @@ -180,7 +180,7 @@ impl<'config, E: From> CheckEvmTransaction<'config, // EIP-1559 tip. (None, Some(max_fee_per_gas), Some(max_priority_fee_per_gas)) => { if max_priority_fee_per_gas > max_fee_per_gas { - return Err(TransactionValidationError::PriorityFeeTooHigh.into()); + return Err(TransactionValidationError::PriorityFeeTooHigh); } let effective_gas_price = self .config @@ -192,7 +192,7 @@ impl<'config, E: From> CheckEvmTransaction<'config, } _ => { if self.config.is_transactional { - Err(TransactionValidationError::InvalidFeeInput.into()) + Err(TransactionValidationError::InvalidFeeInput) } else { // Allow non-set fee input for non-transactional calls. Ok((U256::zero(), None)) @@ -201,7 +201,7 @@ impl<'config, E: From> CheckEvmTransaction<'config, } } - pub fn validate_common(&self) -> Result<&Self, E> { + pub fn validate_common(&self) -> Result<&Self, TransactionValidationError> { if self.config.is_transactional { // Try to subtract the proof_size_base_cost from the Weight proof_size limit or fail. // Validate the weight limit can afford recording the proof size cost. @@ -233,12 +233,12 @@ impl<'config, E: From> CheckEvmTransaction<'config, }; if gasometer.record_transaction(transaction_cost).is_err() { - return Err(TransactionValidationError::GasLimitTooLow.into()); + return Err(TransactionValidationError::GasLimitTooLow); } // Transaction gas limit is within the upper bound block gas limit. if self.transaction.gas_limit > self.config.block_gas_limit { - return Err(TransactionValidationError::GasLimitTooHigh.into()); + return Err(TransactionValidationError::GasLimitTooHigh); } } @@ -250,41 +250,8 @@ impl<'config, E: From> CheckEvmTransaction<'config, mod tests { use super::*; - #[derive(Debug, PartialEq)] - pub enum TestError { - GasLimitTooLow, - GasLimitTooHigh, - GasPriceTooLow, - PriorityFeeTooHigh, - BalanceTooLow, - TxNonceTooLow, - TxNonceTooHigh, - InvalidFeeInput, - InvalidChainId, - InvalidSignature, - UnknownError, - } - static SHANGHAI_CONFIG: evm::Config = evm::Config::shanghai(); - impl From for TestError { - fn from(e: TransactionValidationError) -> Self { - match e { - TransactionValidationError::GasLimitTooLow => TestError::GasLimitTooLow, - TransactionValidationError::GasLimitTooHigh => TestError::GasLimitTooHigh, - TransactionValidationError::GasPriceTooLow => TestError::GasPriceTooLow, - TransactionValidationError::PriorityFeeTooHigh => TestError::PriorityFeeTooHigh, - TransactionValidationError::BalanceTooLow => TestError::BalanceTooLow, - TransactionValidationError::TxNonceTooLow => TestError::TxNonceTooLow, - TransactionValidationError::TxNonceTooHigh => TestError::TxNonceTooHigh, - TransactionValidationError::InvalidFeeInput => TestError::InvalidFeeInput, - TransactionValidationError::InvalidChainId => TestError::InvalidChainId, - TransactionValidationError::InvalidSignature => TestError::InvalidSignature, - TransactionValidationError::UnknownError => TestError::UnknownError, - } - } - } - struct TestCase { pub blockchain_gas_limit: U256, pub blockchain_base_fee: U256, @@ -321,7 +288,7 @@ mod tests { } } - fn test_env<'config>(who: Account, input: TestCase) -> CheckEvmTransaction<'config, TestError> { + fn test_env<'config>(who: Account, input: TestCase) -> CheckEvmTransaction<'config> { let TestCase { blockchain_gas_limit, blockchain_base_fee, @@ -337,7 +304,7 @@ mod tests { weight_limit, proof_size_base_cost, } = input; - CheckEvmTransaction::::new( + CheckEvmTransaction::new( who, CheckEvmTransactionConfig { evm_config: &SHANGHAI_CONFIG, @@ -367,7 +334,7 @@ mod tests { fn default_transaction<'config>( who: Account, is_transactional: bool, - ) -> CheckEvmTransaction<'config, TestError> { + ) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.is_transactional = is_transactional; test_env(who, input) @@ -376,7 +343,7 @@ mod tests { fn transaction_gas_limit_low<'config>( who: Account, is_transactional: bool, - ) -> CheckEvmTransaction<'config, TestError> { + ) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.gas_limit = U256::from(1u8); input.is_transactional = is_transactional; @@ -386,7 +353,7 @@ mod tests { fn transaction_gas_limit_low_proof_size<'config>( who: Account, is_transactional: bool, - ) -> CheckEvmTransaction<'config, TestError> { + ) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.weight_limit = Some(Weight::from_parts(1, 1)); input.proof_size_base_cost = Some(2); @@ -394,23 +361,19 @@ mod tests { test_env(who, input) } - fn transaction_gas_limit_high<'config>( - who: Account, - ) -> CheckEvmTransaction<'config, TestError> { + fn transaction_gas_limit_high<'config>(who: Account) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.blockchain_gas_limit = U256::from(1u8); test_env(who, input) } - fn transaction_nonce_high<'config>(who: Account) -> CheckEvmTransaction<'config, TestError> { + fn transaction_nonce_high<'config>(who: Account) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.nonce = U256::from(10u8); test_env(who, input) } - fn transaction_invalid_chain_id<'config>( - who: Account, - ) -> CheckEvmTransaction<'config, TestError> { + fn transaction_invalid_chain_id<'config>(who: Account) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.chain_id = Some(555u64); test_env(who, input) @@ -419,7 +382,7 @@ mod tests { fn transaction_none_fee<'config>( who: Account, is_transactional: bool, - ) -> CheckEvmTransaction<'config, TestError> { + ) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.max_fee_per_gas = None; input.max_priority_fee_per_gas = None; @@ -427,9 +390,7 @@ mod tests { test_env(who, input) } - fn transaction_max_fee_low<'config>( - is_transactional: bool, - ) -> CheckEvmTransaction<'config, TestError> { + fn transaction_max_fee_low<'config>(is_transactional: bool) -> CheckEvmTransaction<'config> { let who = Account::default(); let mut input = TestCase::default(); input.max_fee_per_gas = Some(U256::from(1u8)); @@ -440,7 +401,7 @@ mod tests { fn transaction_priority_fee_high<'config>( is_transactional: bool, - ) -> CheckEvmTransaction<'config, TestError> { + ) -> CheckEvmTransaction<'config> { let who = Account::default(); let mut input = TestCase::default(); input.max_priority_fee_per_gas = Some(U256::from(1_100_000_000)); @@ -448,10 +409,7 @@ mod tests { test_env(who, input) } - fn transaction_max_fee_high<'config>( - who: Account, - tip: bool, - ) -> CheckEvmTransaction<'config, TestError> { + fn transaction_max_fee_high<'config>(who: Account, tip: bool) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.max_fee_per_gas = Some(U256::from(5_000_000_000u128)); if !tip { @@ -460,7 +418,7 @@ mod tests { test_env(who, input) } - fn legacy_transaction<'config>(who: Account) -> CheckEvmTransaction<'config, TestError> { + fn legacy_transaction<'config>(who: Account) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.gas_price = Some(U256::from(1_000_000_000u128)); input.max_fee_per_gas = None; @@ -471,7 +429,7 @@ mod tests { fn invalid_transaction_mixed_fees<'config>( who: Account, is_transactional: bool, - ) -> CheckEvmTransaction<'config, TestError> { + ) -> CheckEvmTransaction<'config> { let mut input = TestCase::default(); input.max_fee_per_gas = Some(U256::from(1_000_000_000u128)); input.gas_price = Some(U256::from(1_000_000_000u128)); @@ -490,7 +448,7 @@ mod tests { }; let test = default_transaction(who, true); // Pool - assert!(test.validate_in_pool_for().is_ok()); + assert!(test.validate_in_pool().is_ok()); // Block assert!(test.validate_in_block().is_ok()); } @@ -504,13 +462,13 @@ mod tests { }; let test = default_transaction(who, true); // Pool - let res = test.validate_in_pool_for(); + let res = test.validate_in_pool(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::TxNonceTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::TxNonceTooLow); // Block let res = test.validate_in_block(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::TxNonceTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::TxNonceTooLow); } #[test] @@ -521,7 +479,7 @@ mod tests { nonce: U256::from(1u8), }; let test = transaction_nonce_high(who); - let res = test.validate_in_pool_for(); + let res = test.validate_in_pool(); assert!(res.is_ok()); } @@ -547,13 +505,13 @@ mod tests { let is_transactional = true; let test = transaction_gas_limit_low(who, is_transactional); // Pool - let res = test.validate_in_pool_for(); + let res = test.validate_in_pool(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasLimitTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::GasLimitTooLow); // Block let res = test.validate_in_block(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasLimitTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::GasLimitTooLow); } #[test] @@ -566,7 +524,7 @@ mod tests { let is_transactional = false; let test = transaction_gas_limit_low(who, is_transactional); // Pool - let res = test.validate_in_pool_for(); + let res = test.validate_in_pool(); assert!(res.is_ok()); // Block let res = test.validate_in_block(); @@ -583,13 +541,13 @@ mod tests { let is_transactional = true; let test = transaction_gas_limit_low_proof_size(who, is_transactional); // Pool - let res = test.validate_in_pool_for(); + let res = test.validate_in_pool(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasLimitTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::GasLimitTooLow); // Block let res = test.validate_in_block(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasLimitTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::GasLimitTooLow); } #[test] @@ -602,7 +560,7 @@ mod tests { let is_transactional = false; let test = transaction_gas_limit_low_proof_size(who, is_transactional); // Pool - let res = test.validate_in_pool_for(); + let res = test.validate_in_pool(); assert!(res.is_ok()); // Block let res = test.validate_in_block(); @@ -618,13 +576,19 @@ mod tests { }; let test = transaction_gas_limit_high(who); // Pool - let res = test.validate_in_pool_for(); + let res = test.validate_in_pool(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasLimitTooHigh); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::GasLimitTooHigh + ); // Block let res = test.validate_in_block(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasLimitTooHigh); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::GasLimitTooHigh + ); } #[test] @@ -643,7 +607,7 @@ mod tests { let test = transaction_invalid_chain_id(who); let res = test.with_chain_id(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::InvalidChainId); + assert_eq!(res.unwrap_err(), TransactionValidationError::InvalidChainId); } #[test] @@ -667,7 +631,10 @@ mod tests { let test = transaction_none_fee(who, true); let res = test.with_base_fee(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::InvalidFeeInput); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::InvalidFeeInput + ); } #[test] @@ -686,12 +653,12 @@ mod tests { let test = transaction_max_fee_low(true); let res = test.with_base_fee(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasPriceTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::GasPriceTooLow); // Non-transactional let test = transaction_max_fee_low(false); let res = test.with_base_fee(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::GasPriceTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::GasPriceTooLow); } #[test] @@ -701,12 +668,18 @@ mod tests { let test = transaction_priority_fee_high(true); let res = test.with_base_fee(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::PriorityFeeTooHigh); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::PriorityFeeTooHigh + ); // Non-transactional let test = transaction_priority_fee_high(false); let res = test.with_base_fee(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::PriorityFeeTooHigh); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::PriorityFeeTooHigh + ); } #[test] @@ -737,12 +710,12 @@ mod tests { let test = default_transaction(who.clone(), true); let res = test.with_balance(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::BalanceTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::BalanceTooLow); // Non-transactional let test = default_transaction(who, false); let res = test.with_balance(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::BalanceTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::BalanceTooLow); } #[test] @@ -755,7 +728,10 @@ mod tests { let test = transaction_none_fee(who, true); let res = test.with_balance(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::InvalidFeeInput); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::InvalidFeeInput + ); } #[test] @@ -820,7 +796,7 @@ mod tests { let test = legacy_transaction(who); let res = test.with_balance(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::BalanceTooLow); + assert_eq!(res.unwrap_err(), TransactionValidationError::BalanceTooLow); } #[test] @@ -835,7 +811,10 @@ mod tests { let test = invalid_transaction_mixed_fees(who.clone(), is_transactional); let res = test.with_balance(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::InvalidFeeInput); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::InvalidFeeInput + ); // Succeeds for non-transactional. let is_transactional = false; let test = invalid_transaction_mixed_fees(who, is_transactional); @@ -852,7 +831,10 @@ mod tests { let test = invalid_transaction_mixed_fees(who.clone(), is_transactional); let res = test.with_base_fee(); assert!(res.is_err()); - assert_eq!(res.unwrap_err(), TestError::InvalidFeeInput); + assert_eq!( + res.unwrap_err(), + TransactionValidationError::InvalidFeeInput + ); // Succeeds for non-transactional. let is_transactional = false; let test = invalid_transaction_mixed_fees(who, is_transactional); diff --git a/template/runtime/src/lib.rs b/template/runtime/src/lib.rs index 8475918abc..01786cdf67 100644 --- a/template/runtime/src/lib.rs +++ b/template/runtime/src/lib.rs @@ -350,7 +350,7 @@ impl pallet_evm::Config for Runtime { type GasLimitPovSizeRatio = GasLimitPovSizeRatio; type Timestamp = Timestamp; type WeightInfo = pallet_evm::weights::SubstrateWeight; - type OnCheckEvmTransaction> = (); + type OnCheckEvmTransaction = (); } parameter_types! {