123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 Nomadic Labs, <contact@nomadic-labs.com> *)(* Copyright (c) 2023 Functori, <contact@functori.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5165
Add coverage unit tests *)moduleMake(C:Gossipsub_intf.WORKER_CONFIGURATION):Gossipsub_intf.WORKERwithmoduleGS=C.GSandmoduleMonad=C.MonadandmoduleStream=C.Stream=structmoduleGS=C.GSmoduleMonad=C.MonadmoduleStream=C.StreammoduleView=GS.IntrospectionmoduleTopic=GS.TopicmodulePeer=GS.PeermoduleMessage_id=GS.Message_idmoduleMessage=GS.Messagetype'acancellation_handle={schedule_cancellation:unit->'aMonad.t;(** A handle for a cancellable looping monad. When
[schedule_cancellation ()] is called, the internal monad is
returned. Details on how the returned monad resovles or is cancelled
depends on the loop's implementation. *)}(** A worker has one of the following statuses:
- [Starting] in case it is initialized with {!make} but not started yet.
- [Running] in case the function [start] has been called. *)typeworker_status=|Starting|Runningof{heartbeat_handle:unitcancellation_handle;event_loop_handle:unitcancellation_handle;}typemessage_with_header={message:Message.t;topic:Topic.t;message_id:Message_id.t;}typep2p_message=|Graftof{topic:Topic.t}|Pruneof{topic:Topic.t;px:Peer.tSeq.t;backoff:GS.Span.t}|IHaveof{topic:Topic.t;message_ids:Message_id.tlist}|IWantof{message_ids:Message_id.tlist}|Subscribeof{topic:Topic.t}|Unsubscribeof{topic:Topic.t}|Message_with_headerofmessage_with_header(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5323
The payloads of the variants about are quite simular to those of GS (types
graft, prune, ...). We could reuse them if we move the peer field
outside. *)typep2p_input=|In_messageof{from_peer:Peer.t;p2p_message:p2p_message}|New_connectionof{peer:Peer.t;direct:bool;outbound:bool}|Disconnectionof{peer:Peer.t}typeapp_input=|Publish_messageofmessage_with_header|JoinofTopic.t|LeaveofTopic.ttypep2p_output=|Out_messageof{to_peer:Peer.t;p2p_message:p2p_message}|Disconnectof{peer:Peer.t}|Kickof{peer:Peer.t}|Connectof{px:Peer.t;origin:Peer.t}|Forgetof{px:Peer.t;origin:Peer.t}typeapp_output=message_with_header(** The different kinds of events the Gossipsub worker handles. *)typeevent=Heartbeat|P2P_inputofp2p_input|App_inputofapp_input(** The worker's state is made of its status, the gossipsub automaton's state,
and a stream of events to process. It also has two output streams to
communicate with the application and P2P layers. *)typet={gossip_state:GS.state;status:worker_status;events_stream:eventStream.t;p2p_output_stream:p2p_outputStream.t;app_output_stream:app_outputStream.t;events_logging:event->unitMonad.t;}letsend_p2p_output~emit_p2p_output~mk_output=letemitto_peer=emit_p2p_output@@mk_outputto_peerinSeq.iteremitletsend_p2p_message~emit_p2p_outputp2p_message=send_p2p_output~emit_p2p_output~mk_output:(funto_peer->Out_message{to_peer;p2p_message})(** From the worker's perspective, handling publishing a message consists in:
- Sending it to peers returned in [to_publish] field of
[GS.Publish_message] output);
Note that it's the responsability of the automaton modules to filter out
peers based on various criteria (bad score, connection expired, ...). *)lethandle_publish_message~emit_p2p_outputpublish_message=function|gstate,GS.Publish_message{to_publish}->let({topic;message_id;message}:GS.publish_message)=publish_messageinletmessage_with_header={message;topic;message_id}inletp2p_message=Message_with_headermessage_with_headerinsend_p2p_message~emit_p2p_outputp2p_message(Peer.Set.to_seqto_publish);gstate|gstate,GS.Already_published->gstate(** From the worker's perspective, handling receiving a message consists in:
- Sending it to peers returned in [to_route] field of
[GS.Route_message] output);
- Notifying the application layer if it is interesed in it.
Note that it's the responsability of the automaton modules to filter out
peers based on various criteria (bad score, connection expired, ...). *)lethandle_receive_message~emit_p2p_output~emit_app_outputreceived_message=function|gstate,GS.Route_message{to_route}->let({sender=_;topic;message_id;message}:GS.receive_message)=received_messageinletmessage_with_header={message;topic;message_id}inletp2p_message=Message_with_headermessage_with_headerinsend_p2p_message~emit_p2p_outputp2p_message(Peer.Set.to_seqto_route);lethas_joined=View.(has_joinedtopic@@viewgstate)inifhas_joinedthenemit_app_outputmessage_with_header;gstate|gstate,GS.Already_received|gstate,GS.Not_subscribed|gstate,GS.Invalid_message|gstate,GS.Unknown_validity->gstate(** From the worker's perspective, the outcome of joining a new topic from the
application layer are:
- Sending [Subscribe] messages to connected peers with that topic;
- Sending [Graft] messages to the newly construced topic's mesh. *)lethandle_join~emit_p2p_outputtopic=function|gstate,GS.Already_joined->gstate|gstate,Joining_topic{to_graft}->letpeers=View.(viewgstate|>get_connected_peers)in(* It's important to send [Subscribe] before [Graft], as the other peer
would ignore the [Graft] message if we did not subscribe to the
topic first. *)send_p2p_message~emit_p2p_output(Subscribe{topic})(List.to_seqpeers);send_p2p_message~emit_p2p_output(Graft{topic})(Peer.Set.to_seqto_graft);gstate(** From the worker's perspective, the outcome of leaving a topic by the
application layer are:
- Sending [Prune] messages to the topic's mesh;
- Sending [Unsubscribe] messages to connected peers. *)lethandle_leave~emit_p2p_outputtopic=function|gstate,GS.Not_joined->gstate|gstate,Leaving_topic{to_prune;noPX_peers}->letview=View.viewgstateinletpeers=View.get_connected_peersviewinletbackoff=(View.limitsview).unsubscribe_backoffin(* Sending [Prune] before [Unsubscribe] to let full-connection peers
clean their mesh before handling [Unsubscribe] message. *)Peer.Set.iter(funpeer_to_prune->(* Send Prune messages with adequate px. *)letprune=letpx=GS.select_px_peersgstate~peer_to_prunetopic~noPX_peers|>List.to_seqinPrune{topic;px;backoff}insend_p2p_message~emit_p2p_outputprune(Seq.returnpeer_to_prune))to_prune;send_p2p_message~emit_p2p_output(Unsubscribe{topic})(List.to_seqpeers);gstate(** When a new peer is connected, the worker will send a [Subscribe] message
to that peer for each topic the local peer tracks. *)lethandle_new_connection~emit_p2p_outputpeer=function|gstate,GS.Peer_already_known->gstate|gstate,Peer_added->View.(viewgstate|>get_our_topics)|>List.iter(funtopic->send_p2p_message~emit_p2p_output(Subscribe{topic})(Seq.returnpeer));gstate(** When a peer is disconnected, the worker has nothing to do, as:
- It cannot send [Prune] or [Unsubscribe] to the remote peer because the
connection is closed;
- [Prune] or [Unsubscribe] are already handled when calling
{!GS.remove_peer}. *)lethandle_disconnection=functiongstate,GS.Removing_peer->gstate(** When a [Graft] request from a remote peer is received, the worker forwards
it to the automaton. In certain cases the peer needs to be pruned. Other
than that there is nothing else to do. *)lethandle_graft~emit_p2p_outputpeertopic(gstate,output)=letbackoff=View.(viewgstate|>limits).prune_backoffinletdo_prune~do_px=letprune=letpx=ifdo_pxthenGS.select_px_peersgstate~peer_to_prune:peertopic~noPX_peers:Peer.Set.empty|>List.to_seqelseSeq.emptyinPrune{topic;px;backoff}insend_p2p_message~emit_p2p_outputprune(Seq.returnpeer)in(* NOTE: if the cases when we send a Prune change, be sure to also update
the backoffs accordingly in the automaton. *)matchoutputwith|GS.Peer_already_in_mesh|Unexpected_grafting_peer|Grafting_successfully->gstate|Peer_filtered|Unsubscribed_topic|Grafting_direct_peer|Grafting_peer_with_negative_score|Peer_backed_off->do_prune~do_px:false;gstate|Mesh_full->do_prune~do_px:true;gstate(** When a [Subscribe] request from a remote peer is received, the worker just
forwards it to the automaton. There is nothing else to do. *)lethandle_subscribe=function|gstate,(GS.Subscribed|Subscribe_to_unknown_peer)->gstate(** When a [Unsubscribe] request from a remote peer is received, the worker just
forwards it to the automaton. There is nothing else to do. *)lethandle_unsubscribe=function|gstate,(GS.Unsubscribed|Unsubscribe_from_unknown_peer)->gstate(** When an [IHave] control message from a remote peer is received, the
automaton checks whether it is interested is some full messages whose ids
are given. If so, the worker requests them from the remote peer via an
[IWant] message. *)lethandle_ihave~emit_p2p_output({peer;_}:GS.ihave)=function|gstate,GS.Message_requested_message_idsmessage_ids->ifnot(List.is_emptymessage_ids)thensend_p2p_message~emit_p2p_output(IWant{message_ids})(Seq.returnpeer);gstate|(gstate,(GS.Ihave_from_peer_with_low_score_|Too_many_recv_ihave_messages_|Too_many_sent_iwant_messages_|Message_topic_not_tracked))->(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5424
Penalize peers with negative score or non expected behaviour
(revisit all the outputs in different apply event functions). *)gstate(** When an [IWant] control message from a remote peer is received, the
automaton checks which full messages it can send back (based on message
availability and on the number of received requests). Selected messages,
if any, are transmitted to the remote peer via [Message_with_header]. *)lethandle_iwant~emit_p2p_output({peer;_}:GS.iwant)=function|gstate,GS.On_iwant_messages_to_route{routed_message_ids}->Message_id.Map.iter(funmessage_idstatus->matchstatuswith|`Messagemessage->lettopic=Message_id.get_topicmessage_idin(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5415
Don't provide a topic when it can be inferred (e.g. from
Message_id.t). This also applies for Message_with_header and IHave. *)letmessage_with_header={message;topic;message_id}inletp2p_message=Message_with_headermessage_with_headerinsend_p2p_message~emit_p2p_outputp2p_message(Seq.returnpeer)|_->())routed_message_ids;gstate|gstate,GS.Iwant_from_peer_with_low_score_->(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5424
Penalize peers with negative score or non expected behaviour
(revisit all the outputs in different apply event functions). *)gstate(** When a [Prune] control message from a remote peer is received, the
automaton removes that peer from the given topic's mesh. It also filters
the given collection of alternative peers to connect to. The worker then
asks the P2P part to connect to those peeers. *)lethandle_prune~emit_p2p_output~from_peerinput_px=function|(gstate,(GS.Prune_topic_not_tracked|Peer_not_in_mesh|Ignore_PX_score_too_low_|No_PX))->send_p2p_output~emit_p2p_output~mk_output:(funto_peer->Forget{px=to_peer;origin=from_peer})input_px;gstate|gstate,GS.PXpeers->send_p2p_output~emit_p2p_output~mk_output:(funto_peer->Connect{px=to_peer;origin=from_peer})(Peer.Set.to_seqpeers);(* Forget peers that were filtered out by the automaton. *)send_p2p_output~emit_p2p_output~mk_output:(funto_peer->Forget{px=to_peer;origin=from_peer})(Peer.Set.to_seq@@Peer.Set.(diff(of_seqinput_px)peers));gstate(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5426
Add more verification/attacks protections as done in Rust. *)(** On a [Heartbeat] events, the worker sends graft and prune messages
following the automaton's output. It also sends [IHave] messages (computed
by the automaton as well). *)lethandle_heartheat~emit_p2p_output=function|gstate,GS.Heartbeat{to_graft;to_prune;noPX_peers}->letiterpmapmk_msg=Peer.Map.iter(funpeertopicset->Topic.Set.iter(funtopic->send_p2p_message~emit_p2p_output(mk_msgpeertopic)(Seq.returnpeer))topicset)pmapin(* Send Graft messages. *)iterto_graft(fun_peertopic->Graft{topic});(* Send Prune messages with adequate px. *)letbackoff=View.(viewgstate|>limits).prune_backoffiniterto_prune(funpeer_to_prunetopic->letpx=GS.select_px_peersgstate~peer_to_prunetopic~noPX_peers|>List.to_seqinPrune{topic;px;backoff});(* Send IHave messages. *)GS.select_gossip_messagesgstate|>List.iter(funGS.{peer;topic;message_ids}->ifnot(List.is_emptymessage_ids)thensend_p2p_message~emit_p2p_output(IHave{topic;message_ids})(Seq.returnpeer));gstate(** Handling application events. *)letapply_app_event~emit_p2p_outputgossip_state=function|Publish_message{message;message_id;topic}->letpublish_message=GS.{topic;message_id;message}inGS.publish_messagepublish_messagegossip_state|>handle_publish_message~emit_p2p_outputpublish_message|Jointopic->GS.join{topic}gossip_state|>handle_join~emit_p2p_outputtopic|Leavetopic->GS.leave{topic}gossip_state|>handle_leave~emit_p2p_outputtopic(** Handling messages received from the P2P network. *)letapply_p2p_message~emit_p2p_output~emit_app_outputgossip_statefrom_peer=function|Message_with_header{message;topic;message_id}->letreceive_message={GS.sender=from_peer;topic;message_id;message}inGS.handle_receive_messagereceive_messagegossip_state|>handle_receive_message~emit_p2p_output~emit_app_outputreceive_message|Graft{topic}->letgraft:GS.graft={peer=from_peer;topic}inGS.handle_graftgraftgossip_state|>handle_graft~emit_p2p_outputfrom_peertopic|Subscribe{topic}->letsubscribe:GS.subscribe={peer=from_peer;topic}inGS.handle_subscribesubscribegossip_state|>handle_subscribe|Unsubscribe{topic}->letunsubscribe:GS.unsubscribe={peer=from_peer;topic}inGS.handle_unsubscribeunsubscribegossip_state|>handle_unsubscribe|IHave{topic;message_ids}->(* The automaton should guarantee that the list is not empty. *)letihave:GS.ihave={peer=from_peer;topic;message_ids}inGS.handle_ihaveihavegossip_state|>handle_ihave~emit_p2p_outputihave|IWant{message_ids}->(* The automaton should guarantee that the list is not empty. *)letiwant:GS.iwant={peer=from_peer;message_ids}inGS.handle_iwantiwantgossip_state|>handle_iwant~emit_p2p_outputiwant|Prune{topic;px;backoff}->letprune:GS.prune={peer=from_peer;topic;px;backoff}inGS.handle_pruneprunegossip_state|>handle_prune~emit_p2p_output~from_peerpx(** Handling events received from P2P layer. *)letapply_p2p_event~emit_p2p_output~emit_app_outputgossip_state=function|New_connection{peer;direct;outbound}->GS.add_peer{direct;outbound;peer}gossip_state|>handle_new_connection~emit_p2p_outputpeer|Disconnection{peer}->GS.remove_peer{peer}gossip_state|>handle_disconnection|In_message{from_peer;p2p_message}->apply_p2p_message~emit_p2p_output~emit_app_outputgossip_statefrom_peerp2p_message(** This is the main function of the worker. It interacts with the Gossipsub
automaton given an event. The function possibly sends messages to the P2P
and application layers via the functions [emit_p2p_output] and [emit_app_output]
and returns the new automaton's state. *)letapply_event~emit_p2p_output~emit_app_outputgossip_state=function(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5326
Notify the GS worker about the status of messages sent to peers. *)|Heartbeat->(* TODO: https://gitlab.com/tezos/tezos/-/issues/5170
Do we want to detect cases where two successive [Heartbeat] events
would be handled (e.g. because the first one is late)? *)GS.heartbeatgossip_state|>handle_heartheat~emit_p2p_output|P2P_inputevent->apply_p2p_event~emit_p2p_output~emit_app_outputgossip_stateevent|App_inputevent->apply_app_event~emit_p2p_outputgossip_stateevent(** A helper function that pushes events in the state *)letpushet=Stream.pushet.events_streamletapp_inputtinput=push(App_inputinput)tletp2p_inputtinput=push(P2P_inputinput)t(** This function returns a {!cancellation_handle} for a looping monad
that pushes [Heartbeat] events in the [t.events_stream] every
[heartbeat_span].
When the loop is canceled, the returned monad may take up to
[heartbeat_span] to resolve. *)letheartbeat_events_producer~heartbeat_spant=letopenMonadinletshutdown=reffalseinletstream=t.events_streaminletrecloop()=let*()=Monad.sleepheartbeat_spaninStream.pushHeartbeatstream;if!shutdownthenreturn()elseloop()inletpromise=loop()inletschedule_cancellation()=shutdown:=true;promisein{schedule_cancellation}(** This function returns a {!cancellation_handle} for a looping monad
that consumes pushed events in [t.events_stream], if any.
When the loop is canceled, the returned monad will need an additional
extra event to consume in order to resolve. *)letevent_loopt=letopenMonadinletshutdown=reffalseinletrev_pushstreame=Stream.pushestreaminletemit_p2p_output=rev_pusht.p2p_output_streaminletemit_app_output=rev_pusht.app_output_streaminletevents_stream=t.events_streaminletevents_logging=t.events_logginginletrecloopgossip_state=let*event=Stream.popevents_streaminif!shutdownthenreturn()elselet*()=events_loggingeventinloop@@apply_event~emit_p2p_output~emit_app_outputgossip_stateeventinletpromise=loopt.gossip_stateinletschedule_cancellation()=shutdown:=true;promisein{schedule_cancellation}letstarttopicst=matcht.statuswith|Starting->letheartbeat_span=View.((viewt.gossip_state).limits.heartbeat_interval)inletheartbeat_handle=heartbeat_events_producer~heartbeat_spantinletevent_loop_handle=event_looptinletstatus=Running{heartbeat_handle;event_loop_handle}inlett={twithstatus}inList.iter(funtopic->app_inputt(Jointopic))topics;t|Running_->(* FIXME: https://gitlab.com/tezos/tezos/-/issues/5166
Better error handling *)Format.eprintf"A worker is already running for this state!@.";assertfalse(** Shutting down may require waiting up [heartbeat_span] to stop the
heartbeat event loop. *)letshutdownstate=letopenC.Monadinmatchstate.statuswith|Starting->return()|Running{heartbeat_handle;event_loop_handle;_}->(* First, we schedule event_loop cancellation without waiting for the
promise to resolve (i.e. for an input in the stream to be read). *)letevent_loop_promise=event_loop_handle.schedule_cancellation()in(* Then, we schedule heartbeat cancellation, which will push a last
[Heartbeat] event in the stream before its returned promise is
resolved. *)let*()=heartbeat_handle.schedule_cancellation()in(* Now, we are sure that an event has been pushed to the event stream
after [event_loop] cancellation. So, [event_loop_promise] can be
resolved. *)event_loop_promiseletmake?(events_logging=fun_event->Monad.return())rnglimitsparameters={gossip_state=GS.makernglimitsparameters;status=Starting;events_stream=Stream.empty();p2p_output_stream=Stream.empty();app_output_stream=Stream.empty();events_logging;}letp2p_output_streamt=t.p2p_output_streamletapp_output_streamt=t.app_output_streamletis_subscribedstatetopic=GS.Introspection.(has_joinedtopic(viewstate.gossip_state))letpp_listpp_elt=Format.pp_print_list~pp_sep:(funfmt()->Format.fprintffmt"; ")pp_eltletpp_message_with_headerfmt{message;message_id;topic}=Format.fprintffmt"Message_with_header{message=%a, message_id=%a, topic=%a}"Message.ppmessageMessage_id.ppmessage_idTopic.pptopicletpp_p2p_messagefmt=function|Graft{topic}->Format.fprintffmt"Graft{topic=%a}"Topic.pptopic|Prune{topic;px;backoff}->Format.fprintffmt"Prune{topic=%a, px=%a, backoff=%a}"Topic.pptopic(pp_listPeer.pp)(List.of_seqpx)GS.Span.ppbackoff|IHave{topic;message_ids}->Format.fprintffmt"IHave{topic=%a, message_ids=%a}"Topic.pptopic(pp_listMessage_id.pp)message_ids|IWant{message_ids}->Format.fprintffmt"IWant{message_ids=%a}"(pp_listMessage_id.pp)message_ids|Subscribe{topic}->Format.fprintffmt"Subscribe{topic=%a}"Topic.pptopic|Unsubscribe{topic}->Format.fprintffmt"Unsubscribe{topic=%a}"Topic.pptopic|Message_with_headermessage_with_header->pp_message_with_headerfmtmessage_with_headerletpp_p2p_outputfmt=function|Disconnect{peer}->Format.fprintffmt"Disconnect{peer=%a}"Peer.pppeer|Kick{peer}->Format.fprintffmt"Kick{peer=%a}"Peer.pppeer|Connect{px;origin}->Format.fprintffmt"Connect{px=%a; origin=%a}"Peer.pppxPeer.pporigin|Forget{px;origin}->Format.fprintffmt"Forget{px=%a; origin=%a}"Peer.pppxPeer.pporigin|Out_message{to_peer;p2p_message}->Format.fprintffmt"Out_message{peer=%a, p2p_message=%a}"Peer.ppto_peerpp_p2p_messagep2p_messageletpp_app_output=pp_message_with_headerend