pallet-evm: avoid double fee payment (#6858)

* pallet-evm: avoid double fee payment

* Only skip fee payment for successful calls
This commit is contained in:
Wei Tang
2020-08-13 14:53:42 +02:00
committed by GitHub
parent b6d444fdea
commit 7759b77c6d
+9 -10
View File
@@ -33,13 +33,12 @@ use codec::{Encode, Decode};
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize};
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
use frame_support::weights::Weight;
use frame_support::weights::{Weight, Pays};
use frame_support::traits::{Currency, ExistenceRequirement, Get};
use frame_support::dispatch::DispatchResultWithPostInfo;
use frame_system::RawOrigin;
use sp_core::{U256, H256, H160, Hasher};
use sp_runtime::{
DispatchResult, AccountId32, traits::{UniqueSaturatedInto, SaturatedConversion, BadOrigin},
};
use sp_runtime::{AccountId32, traits::{UniqueSaturatedInto, SaturatedConversion, BadOrigin}};
use sha3::{Digest, Keccak256};
pub use evm::{ExitReason, ExitSucceed, ExitError, ExitRevert, ExitFatal};
use evm::Config;
@@ -325,7 +324,7 @@ decl_module! {
gas_limit: u32,
gas_price: U256,
nonce: Option<U256>,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
T::CallOrigin::ensure_address_origin(&source, origin)?;
match Self::execute_call(
@@ -346,7 +345,7 @@ decl_module! {
},
}
Ok(())
Ok(Pays::No.into())
}
/// Issue an EVM create operation. This is similar to a contract creation transaction in
@@ -360,7 +359,7 @@ decl_module! {
gas_limit: u32,
gas_price: U256,
nonce: Option<U256>,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
T::CallOrigin::ensure_address_origin(&source, origin)?;
match Self::execute_create(
@@ -380,7 +379,7 @@ decl_module! {
},
}
Ok(())
Ok(Pays::No.into())
}
/// Issue an EVM create2 operation.
@@ -394,7 +393,7 @@ decl_module! {
gas_limit: u32,
gas_price: U256,
nonce: Option<U256>,
) -> DispatchResult {
) -> DispatchResultWithPostInfo {
T::CallOrigin::ensure_address_origin(&source, origin)?;
match Self::execute_create2(
@@ -415,7 +414,7 @@ decl_module! {
},
}
Ok(())
Ok(Pays::No.into())
}
}
}