Skip to content

Commit d019a66

Browse files
authored
pallet-evm: avoid double fee payment (paritytech#6858)
* pallet-evm: avoid double fee payment * Only skip fee payment for successful calls
1 parent ed4f7a1 commit d019a66

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

frame/evm/src/lib.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ use codec::{Encode, Decode};
3333
#[cfg(feature = "std")]
3434
use serde::{Serialize, Deserialize};
3535
use frame_support::{ensure, decl_module, decl_storage, decl_event, decl_error};
36-
use frame_support::weights::Weight;
36+
use frame_support::weights::{Weight, Pays};
3737
use frame_support::traits::{Currency, ExistenceRequirement, Get};
38+
use frame_support::dispatch::DispatchResultWithPostInfo;
3839
use frame_system::RawOrigin;
3940
use sp_core::{U256, H256, H160, Hasher};
40-
use sp_runtime::{
41-
DispatchResult, AccountId32, traits::{UniqueSaturatedInto, SaturatedConversion, BadOrigin},
42-
};
41+
use sp_runtime::{AccountId32, traits::{UniqueSaturatedInto, SaturatedConversion, BadOrigin}};
4342
use sha3::{Digest, Keccak256};
4443
pub use evm::{ExitReason, ExitSucceed, ExitError, ExitRevert, ExitFatal};
4544
use evm::Config;
@@ -325,7 +324,7 @@ decl_module! {
325324
gas_limit: u32,
326325
gas_price: U256,
327326
nonce: Option<U256>,
328-
) -> DispatchResult {
327+
) -> DispatchResultWithPostInfo {
329328
T::CallOrigin::ensure_address_origin(&source, origin)?;
330329

331330
match Self::execute_call(
@@ -346,7 +345,7 @@ decl_module! {
346345
},
347346
}
348347

349-
Ok(())
348+
Ok(Pays::No.into())
350349
}
351350

352351
/// Issue an EVM create operation. This is similar to a contract creation transaction in
@@ -360,7 +359,7 @@ decl_module! {
360359
gas_limit: u32,
361360
gas_price: U256,
362361
nonce: Option<U256>,
363-
) -> DispatchResult {
362+
) -> DispatchResultWithPostInfo {
364363
T::CallOrigin::ensure_address_origin(&source, origin)?;
365364

366365
match Self::execute_create(
@@ -380,7 +379,7 @@ decl_module! {
380379
},
381380
}
382381

383-
Ok(())
382+
Ok(Pays::No.into())
384383
}
385384

386385
/// Issue an EVM create2 operation.
@@ -394,7 +393,7 @@ decl_module! {
394393
gas_limit: u32,
395394
gas_price: U256,
396395
nonce: Option<U256>,
397-
) -> DispatchResult {
396+
) -> DispatchResultWithPostInfo {
398397
T::CallOrigin::ensure_address_origin(&source, origin)?;
399398

400399
match Self::execute_create2(
@@ -415,7 +414,7 @@ decl_module! {
415414
},
416415
}
417416

418-
Ok(())
417+
Ok(Pays::No.into())
419418
}
420419
}
421420
}

0 commit comments

Comments
 (0)