@@ -33,9 +33,10 @@ use alloc::{collections::btree_map::BTreeMap, vec, vec::Vec};
3333use codec:: { Decode , DecodeLimit , Encode } ;
3434use core:: cmp;
3535use cumulus_primitives_core:: {
36- relay_chain, AbridgedHostConfiguration , ChannelInfo , ChannelStatus , CollationInfo ,
37- CumulusDigestItem , GetChannelInfo , ListChannelInfos , MessageSendError , OutboundHrmpMessage ,
38- ParaId , PersistedValidationData , UpwardMessage , UpwardMessageSender , XcmpMessageHandler ,
36+ relay_chain:: { self , UMPSignal , UMP_SEPARATOR } ,
37+ AbridgedHostConfiguration , ChannelInfo , ChannelStatus , CollationInfo , CumulusDigestItem ,
38+ GetChannelInfo , ListChannelInfos , MessageSendError , OutboundHrmpMessage , ParaId ,
39+ PersistedValidationData , UpwardMessage , UpwardMessageSender , XcmpMessageHandler ,
3940 XcmpMessageSource ,
4041} ;
4142use cumulus_primitives_parachain_inherent:: { v0, MessageQueueChain , ParachainInherentData } ;
@@ -361,8 +362,8 @@ pub mod pallet {
361362 UpwardMessages :: < T > :: put ( & up[ ..num as usize ] ) ;
362363 * up = up. split_off ( num as usize ) ;
363364
364- // Send the core selector UMP signal.
365- Self :: send_ump_signal ( ) ;
365+ // Send the pending UMP signals + the core selector UMP signal.
366+ Self :: send_ump_signals ( ) ;
366367
367368 // If the total size of the pending messages is less than the threshold,
368369 // we decrease the fee factor, since the queue is less congested.
@@ -585,7 +586,7 @@ pub mod pallet {
585586 validation_data : vfp,
586587 relay_chain_state,
587588 relay_parent_descendants,
588- collator_peer_id : _ ,
589+ collator_peer_id,
589590 } = data;
590591
591592 // Check that the associated relay chain block number is as expected.
@@ -693,6 +694,12 @@ pub mod pallet {
693694
694695 <T :: OnSystemEvent as OnSystemEvent >:: on_validation_data ( & vfp) ;
695696
697+ if let Some ( collator_peer_id) = collator_peer_id {
698+ PendingUpwardSignals :: < T > :: mutate ( |signals| {
699+ signals. push ( UMPSignal :: ApprovedPeer ( collator_peer_id) . encode ( ) ) ;
700+ } ) ;
701+ }
702+
696703 total_weight. saturating_accrue ( Self :: enqueue_inbound_downward_messages (
697704 relevant_messaging_state. dmq_mqc_head ,
698705 inbound_messages_data. downward_messages ,
@@ -905,14 +912,20 @@ pub mod pallet {
905912
906913 /// Upward messages that were sent in a block.
907914 ///
908- /// This will be cleared in `on_initialize` of each new block.
915+ /// This will be cleared in `on_initialize` for each new block.
909916 #[ pallet:: storage]
910917 pub type UpwardMessages < T : Config > = StorageValue < _ , Vec < UpwardMessage > , ValueQuery > ;
911918
912- /// Upward messages that are still pending and not yet send to the relay chain.
919+ /// Upward messages that are still pending and not yet sent to the relay chain.
913920 #[ pallet:: storage]
914921 pub type PendingUpwardMessages < T : Config > = StorageValue < _ , Vec < UpwardMessage > , ValueQuery > ;
915922
923+ /// Upward signals that are still pending and not yet sent to the relay chain.
924+ ///
925+ /// This will be cleared in `on_finalize` for each block.
926+ #[ pallet:: storage]
927+ pub type PendingUpwardSignals < T : Config > = StorageValue < _ , Vec < UpwardMessage > , ValueQuery > ;
928+
916929 /// The factor to multiply the base delivery fee by for UMP.
917930 #[ pallet:: storage]
918931 pub type UpwardDeliveryFeeFactor < T : Config > =
@@ -1508,22 +1521,25 @@ impl<T: Config> Pallet<T> {
15081521 }
15091522
15101523 /// Send the ump signals
1511- fn send_ump_signal ( ) {
1512- use cumulus_primitives_core:: relay_chain:: { UMPSignal , UMP_SEPARATOR } ;
1524+ fn send_ump_signals ( ) {
1525+ // Take the pending UMP signals.
1526+ let mut ump_signals = PendingUpwardSignals :: < T > :: take ( ) ;
1527+ // Append the core selector signal.
1528+ if let Some ( core_info) =
1529+ CumulusDigestItem :: find_core_info ( & frame_system:: Pallet :: < T > :: digest ( ) )
1530+ {
1531+ ump_signals. push (
1532+ UMPSignal :: SelectCore ( core_info. selector , core_info. claim_queue_offset ) . encode ( ) ,
1533+ ) ;
1534+ }
15131535
1514- UpwardMessages :: < T > :: mutate ( |up| {
1515- if let Some ( core_info) =
1516- CumulusDigestItem :: find_core_info ( & frame_system:: Pallet :: < T > :: digest ( ) )
1517- {
1536+ // Send all the UMP signals.
1537+ if !ump_signals. is_empty ( ) {
1538+ UpwardMessages :: < T > :: mutate ( |up| {
15181539 up. push ( UMP_SEPARATOR ) ;
1519-
1520- // Send the core selector signal.
1521- up. push (
1522- UMPSignal :: SelectCore ( core_info. selector , core_info. claim_queue_offset )
1523- . encode ( ) ,
1524- ) ;
1525- }
1526- } ) ;
1540+ up. append ( & mut ump_signals) ;
1541+ } ) ;
1542+ }
15271543 }
15281544
15291545 /// Open HRMP channel for using it in benchmarks or tests.
0 commit comments