@@ -42,7 +42,9 @@ use fp_evm::{
4242use fp_storage:: { EthereumStorageSchema , PALLET_ETHEREUM_SCHEMA } ;
4343use frame_support:: {
4444 codec:: { Decode , Encode , MaxEncodedLen } ,
45- dispatch:: { DispatchInfo , DispatchResultWithPostInfo , Pays , PostDispatchInfo } ,
45+ dispatch:: {
46+ DispatchErrorWithPostInfo , DispatchInfo , DispatchResultWithPostInfo , Pays , PostDispatchInfo ,
47+ } ,
4648 scale_info:: TypeInfo ,
4749 traits:: { EnsureOrigin , Get , PalletInfoAccess , Time } ,
4850 weights:: Weight ,
@@ -55,7 +57,7 @@ use sp_runtime::{
5557 transaction_validity:: {
5658 InvalidTransaction , TransactionValidity , TransactionValidityError , ValidTransactionBuilder ,
5759 } ,
58- DispatchErrorWithPostInfo , RuntimeDebug , SaturatedConversion ,
60+ RuntimeDebug , SaturatedConversion ,
5961} ;
6062use sp_std:: { marker:: PhantomData , prelude:: * } ;
6163
@@ -241,7 +243,7 @@ pub mod pallet {
241243 Self :: validate_transaction_in_block ( source, & transaction) . expect (
242244 "pre-block transaction verification failed; the block cannot be built" ,
243245 ) ;
244- let r = Self :: apply_validated_transaction ( source, transaction)
246+ let ( r , _ ) = Self :: apply_validated_transaction ( source, transaction)
245247 . expect ( "pre-block apply transaction failed; the block cannot be built" ) ;
246248
247249 weight = weight. saturating_add ( r. actual_weight . unwrap_or_default ( ) ) ;
@@ -290,7 +292,7 @@ pub mod pallet {
290292 "pre log already exists; block is invalid" ,
291293 ) ;
292294
293- Self :: apply_validated_transaction ( source, transaction)
295+ Self :: apply_validated_transaction ( source, transaction) . map ( | ( post_info , _ ) | post_info )
294296 }
295297 }
296298
@@ -317,7 +319,7 @@ pub mod pallet {
317319
318320 /// Current building block's transactions and receipts.
319321 #[ pallet:: storage]
320- pub ( super ) type Pending < T : Config > =
322+ pub type Pending < T : Config > =
321323 StorageValue < _ , Vec < ( Transaction , TransactionStatus , Receipt ) > , ValueQuery > ;
322324
323325 /// The current Ethereum block.
@@ -558,14 +560,14 @@ impl<T: Config> Pallet<T> {
558560 fn apply_validated_transaction (
559561 source : H160 ,
560562 transaction : Transaction ,
561- ) -> DispatchResultWithPostInfo {
563+ ) -> Result < ( PostDispatchInfo , CallOrCreateInfo ) , DispatchErrorWithPostInfo > {
562564 let ( to, _, info) = Self :: execute ( source, & transaction, None ) ?;
563565
564566 let pending = Pending :: < T > :: get ( ) ;
565567 let transaction_hash = transaction. hash ( ) ;
566568 let transaction_index = pending. len ( ) as u32 ;
567569
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 ( ) {
569571 CallOrCreateInfo :: Call ( info) => (
570572 info. exit_reason . clone ( ) ,
571573 TransactionStatus {
@@ -680,21 +682,24 @@ impl<T: Config> Pallet<T> {
680682 extra_data,
681683 } ) ;
682684
683- Ok ( PostDispatchInfo {
684- actual_weight : {
685- let mut gas_to_weight = T :: GasWeightMapping :: gas_to_weight (
686- used_gas. standard . unique_saturated_into ( ) ,
687- true ,
688- ) ;
689- if let Some ( weight_info) = weight_info {
690- if let Some ( proof_size_usage) = weight_info. proof_size_usage {
691- * 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+ used_gas. standard . unique_saturated_into ( ) ,
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;
695+ }
692696 }
693- }
694- Some ( gas_to_weight)
695- } ,
696- pays_fee : Pays :: No ,
697- } )
697+ Some ( gas_to_weight)
698+ } ,
699+ pays_fee : Pays :: No ,
700+ } ) ,
701+ info,
702+ ) )
698703 }
699704
700705 /// Get current block hash
@@ -707,10 +712,7 @@ impl<T: Config> Pallet<T> {
707712 from : H160 ,
708713 transaction : & Transaction ,
709714 config : Option < evm:: Config > ,
710- ) -> Result <
711- ( Option < H160 > , Option < H160 > , CallOrCreateInfo ) ,
712- DispatchErrorWithPostInfo < PostDispatchInfo > ,
713- > {
715+ ) -> Result < ( Option < H160 > , Option < H160 > , CallOrCreateInfo ) , DispatchErrorWithPostInfo > {
714716 let (
715717 input,
716718 value,
@@ -963,7 +965,10 @@ impl<T: Config> Pallet<T> {
963965
964966pub struct ValidatedTransaction < T > ( PhantomData < T > ) ;
965967impl < T : Config > ValidatedTransactionT for ValidatedTransaction < T > {
966- fn apply ( source : H160 , transaction : Transaction ) -> DispatchResultWithPostInfo {
968+ fn apply (
969+ source : H160 ,
970+ transaction : Transaction ,
971+ ) -> Result < ( PostDispatchInfo , CallOrCreateInfo ) , DispatchErrorWithPostInfo > {
967972 Pallet :: < T > :: apply_validated_transaction ( source, transaction)
968973 }
969974}
0 commit comments