Skip to content

Commit

Permalink
pallet-evm: avoid double fee payment (paritytech#6858)
Browse files Browse the repository at this point in the history
* pallet-evm: avoid double fee payment

* Only skip fee payment for successful calls
  • Loading branch information
sorpaas authored Aug 13, 2020
1 parent ed4f7a1 commit d019a66
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions frame/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand All @@ -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(
Expand All @@ -380,7 +379,7 @@ decl_module! {
},
}

Ok(())
Ok(Pays::No.into())
}

/// Issue an EVM create2 operation.
Expand All @@ -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(
Expand All @@ -415,7 +414,7 @@ decl_module! {
},
}

Ok(())
Ok(Pays::No.into())
}
}
}
Expand Down

0 comments on commit d019a66

Please sign in to comment.