@@ -42,7 +42,9 @@ use fp_evm::{
42
42
use fp_storage:: { EthereumStorageSchema , PALLET_ETHEREUM_SCHEMA } ;
43
43
use frame_support:: {
44
44
codec:: { Decode , Encode , MaxEncodedLen } ,
45
- dispatch:: { DispatchInfo , DispatchResultWithPostInfo , Pays , PostDispatchInfo } ,
45
+ dispatch:: {
46
+ DispatchErrorWithPostInfo , DispatchInfo , DispatchResultWithPostInfo , Pays , PostDispatchInfo ,
47
+ } ,
46
48
scale_info:: TypeInfo ,
47
49
traits:: { EnsureOrigin , Get , PalletInfoAccess , Time } ,
48
50
weights:: Weight ,
@@ -55,7 +57,7 @@ use sp_runtime::{
55
57
transaction_validity:: {
56
58
InvalidTransaction , TransactionValidity , TransactionValidityError , ValidTransactionBuilder ,
57
59
} ,
58
- DispatchErrorWithPostInfo , RuntimeDebug , SaturatedConversion ,
60
+ RuntimeDebug , SaturatedConversion ,
59
61
} ;
60
62
use sp_std:: { marker:: PhantomData , prelude:: * } ;
61
63
@@ -241,7 +243,7 @@ pub mod pallet {
241
243
Self :: validate_transaction_in_block ( source, & transaction) . expect (
242
244
"pre-block transaction verification failed; the block cannot be built" ,
243
245
) ;
244
- let r = Self :: apply_validated_transaction ( source, transaction)
246
+ let ( r , _ ) = Self :: apply_validated_transaction ( source, transaction)
245
247
. expect ( "pre-block apply transaction failed; the block cannot be built" ) ;
246
248
247
249
weight = weight. saturating_add ( r. actual_weight . unwrap_or_default ( ) ) ;
@@ -290,7 +292,7 @@ pub mod pallet {
290
292
"pre log already exists; block is invalid" ,
291
293
) ;
292
294
293
- Self :: apply_validated_transaction ( source, transaction)
295
+ Self :: apply_validated_transaction ( source, transaction) . map ( | ( post_info , _ ) | post_info )
294
296
}
295
297
}
296
298
@@ -558,14 +560,14 @@ impl<T: Config> Pallet<T> {
558
560
fn apply_validated_transaction (
559
561
source : H160 ,
560
562
transaction : Transaction ,
561
- ) -> DispatchResultWithPostInfo {
563
+ ) -> Result < ( PostDispatchInfo , CallOrCreateInfo ) , DispatchErrorWithPostInfo > {
562
564
let ( to, _, info) = Self :: execute ( source, & transaction, None ) ?;
563
565
564
566
let pending = Pending :: < T > :: get ( ) ;
565
567
let transaction_hash = transaction. hash ( ) ;
566
568
let transaction_index = pending. len ( ) as u32 ;
567
569
568
- let ( reason, status, weight_info, used_gas, dest, extra_data) = match info {
570
+ let ( reason, status, weight_info, used_gas, dest, extra_data) = match info. clone ( ) {
569
571
CallOrCreateInfo :: Call ( info) => (
570
572
info. exit_reason . clone ( ) ,
571
573
TransactionStatus {
@@ -680,24 +682,27 @@ impl<T: Config> Pallet<T> {
680
682
extra_data,
681
683
} ) ;
682
684
683
- Ok ( PostDispatchInfo {
684
- actual_weight : {
685
- let mut gas_to_weight = T :: GasWeightMapping :: gas_to_weight (
686
- sp_std:: cmp:: max (
687
- used_gas. standard . unique_saturated_into ( ) ,
688
- used_gas. effective . unique_saturated_into ( ) ,
689
- ) ,
690
- true ,
691
- ) ;
692
- if let Some ( weight_info) = weight_info {
693
- if let Some ( proof_size_usage) = weight_info. proof_size_usage {
694
- * gas_to_weight. proof_size_mut ( ) = proof_size_usage;
685
+ Ok ( (
686
+ PostDispatchInfo {
687
+ actual_weight : {
688
+ let mut gas_to_weight = T :: GasWeightMapping :: gas_to_weight (
689
+ sp_std:: cmp:: max (
690
+ used_gas. standard . unique_saturated_into ( ) ,
691
+ used_gas. effective . unique_saturated_into ( ) ,
692
+ ) ,
693
+ true ,
694
+ ) ;
695
+ if let Some ( weight_info) = weight_info {
696
+ if let Some ( proof_size_usage) = weight_info. proof_size_usage {
697
+ * gas_to_weight. proof_size_mut ( ) = proof_size_usage;
698
+ }
695
699
}
696
- }
697
- Some ( gas_to_weight)
700
+ Some ( gas_to_weight)
701
+ } ,
702
+ pays_fee : Pays :: No ,
698
703
} ,
699
- pays_fee : Pays :: No ,
700
- } )
704
+ info ,
705
+ ) )
701
706
}
702
707
703
708
/// Get current block hash
@@ -710,10 +715,7 @@ impl<T: Config> Pallet<T> {
710
715
from : H160 ,
711
716
transaction : & Transaction ,
712
717
config : Option < evm:: Config > ,
713
- ) -> Result <
714
- ( Option < H160 > , Option < H160 > , CallOrCreateInfo ) ,
715
- DispatchErrorWithPostInfo < PostDispatchInfo > ,
716
- > {
718
+ ) -> Result < ( Option < H160 > , Option < H160 > , CallOrCreateInfo ) , DispatchErrorWithPostInfo > {
717
719
let (
718
720
input,
719
721
value,
@@ -966,7 +968,10 @@ impl<T: Config> Pallet<T> {
966
968
967
969
pub struct ValidatedTransaction < T > ( PhantomData < T > ) ;
968
970
impl < T : Config > ValidatedTransactionT for ValidatedTransaction < T > {
969
- fn apply ( source : H160 , transaction : Transaction ) -> DispatchResultWithPostInfo {
971
+ fn apply (
972
+ source : H160 ,
973
+ transaction : Transaction ,
974
+ ) -> Result < ( PostDispatchInfo , CallOrCreateInfo ) , DispatchErrorWithPostInfo > {
970
975
Pallet :: < T > :: apply_validated_transaction ( source, transaction)
971
976
}
972
977
}
0 commit comments