@@ -250,7 +250,11 @@ pub type AdditionalSigned = (u32, u32, Hash, Hash, (), (), ());
250250#[ derive( PartialEq , Eq , Clone , RuntimeDebug , TypeInfo ) ]
251251pub struct SignedExtensions < Call > {
252252 encode_payload : SignedExtra ,
253- additional_signed : AdditionalSigned ,
253+ // It may be set to `None` if extensions are decoded. We are never reconstructing transactions
254+ // (and it makes no sense to do that) => decoded version of `SignedExtensions` is only used to
255+ // read fields of `encode_payload`. And when resigning transaction, we're reconstructing
256+ // `SignedExtensions` from the scratch.
257+ additional_signed : Option < AdditionalSigned > ,
254258 _data : sp_std:: marker:: PhantomData < Call > ,
255259}
256260
@@ -262,9 +266,13 @@ impl<Call> parity_scale_codec::Encode for SignedExtensions<Call> {
262266
263267impl < Call > parity_scale_codec:: Decode for SignedExtensions < Call > {
264268 fn decode < I : parity_scale_codec:: Input > (
265- _input : & mut I ,
269+ input : & mut I ,
266270 ) -> Result < Self , parity_scale_codec:: Error > {
267- unimplemented ! ( "SignedExtensions are never meant to be decoded, they are only used to create transaction" ) ;
271+ SignedExtra :: decode ( input) . map ( |encode_payload| SignedExtensions {
272+ encode_payload,
273+ additional_signed : None ,
274+ _data : Default :: default ( ) ,
275+ } )
268276 }
269277}
270278
@@ -287,15 +295,15 @@ impl<Call> SignedExtensions<Call> {
287295 ( ) , // Check weight
288296 tip. into ( ) , // transaction payment / tip (compact encoding)
289297 ) ,
290- additional_signed : (
298+ additional_signed : Some ( (
291299 spec_version,
292300 transaction_version,
293301 genesis_hash,
294302 era. signed_payload ( genesis_hash) ,
295303 ( ) ,
296304 ( ) ,
297305 ( ) ,
298- ) ,
306+ ) ) ,
299307 _data : Default :: default ( ) ,
300308 }
301309 }
@@ -335,7 +343,14 @@ where
335343 fn additional_signed (
336344 & self ,
337345 ) -> Result < Self :: AdditionalSigned , frame_support:: unsigned:: TransactionValidityError > {
338- Ok ( self . additional_signed )
346+ // we shall not ever see this error in relay, because we are never signing decoded
347+ // transactions. Instead we're constructing and signing new transactions. So the error code
348+ // is kinda random here
349+ self . additional_signed . ok_or_else ( || {
350+ frame_support:: unsigned:: TransactionValidityError :: Unknown (
351+ frame_support:: unsigned:: UnknownTransaction :: Custom ( 0xFF ) ,
352+ )
353+ } )
339354 }
340355
341356 fn pre_dispatch (
0 commit comments