123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 Nomadic Labs, <contact@nomadic-labs.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. *)(* *)(*****************************************************************************)openProtocol.Alpha_contexttypet=|Add_messagesof{messages:stringlist}|Cementof{rollup:Sc_rollup.t;commitment:Sc_rollup.Commitment.Hash.t}|Publishof{rollup:Sc_rollup.t;commitment:Sc_rollup.Commitment.t}|Refuteof{rollup:Sc_rollup.t;opponent:Sc_rollup.Staker.t;refutation:Sc_rollup.Game.refutation;}|Timeoutof{rollup:Sc_rollup.t;stakers:Sc_rollup.Game.Index.t}letencoding:tData_encoding.t=letopenData_encodinginletcasetagkindencodingprojinj=case~title:kind(Tagtag)(merge_objs(obj1(req"kind"(constantkind)))encoding)(funo->Option.map(funp->((),p))(projo))(fun((),p)->injp)indef"sc_rollup_node_l1_operation"@@union[case0"add_messages"(obj1(req"message"(list(string'Hex))))(functionAdd_messages{messages}->Somemessages|_->None)(funmessages->Add_messages{messages});case1"cement"(obj2(req"rollup"Sc_rollup.Address.encoding)(req"commitment"Sc_rollup.Commitment.Hash.encoding))(function|Cement{rollup;commitment}->Some(rollup,commitment)|_->None)(fun(rollup,commitment)->Cement{rollup;commitment});case2"publish"(obj2(req"rollup"Sc_rollup.Address.encoding)(req"commitment"Sc_rollup.Commitment.encoding))(function|Publish{rollup;commitment}->Some(rollup,commitment)|_->None)(fun(rollup,commitment)->Publish{rollup;commitment});case3"refute"(obj3(req"rollup"Sc_rollup.Address.encoding)(req"opponent"Sc_rollup.Staker.encoding)(req"refutation"Sc_rollup.Game.refutation_encoding))(function|Refute{rollup;opponent;refutation}->Some(rollup,opponent,refutation)|_->None)(fun(rollup,opponent,refutation)->Refute{rollup;opponent;refutation});case4"timeout"(obj2(req"rollup"Sc_rollup.Address.encoding)(req"stakers"Sc_rollup.Game.Index.encoding))(function|Timeout{rollup;stakers}->Some(rollup,stakers)|_->None)(fun(rollup,stakers)->Timeout{rollup;stakers});]letppppf=function|Add_messages{messages}->Format.fprintfppf"publishing %d messages to smart rollups' inbox"(List.lengthmessages)|Cement{rollup=_;commitment}->Format.fprintfppf"cementing commitment %a"Sc_rollup.Commitment.Hash.ppcommitment|Publish{rollup=_;commitment=Sc_rollup.Commitment.{inbox_level;_}}->Format.fprintfppf"publish commitment for level %a"Raw_level.ppinbox_level|Refute{rollup=_;opponent;refutation=Start_}->Format.fprintfppf"start refutation game against %a"Signature.Public_key_hash.ppopponent|Refute{rollup=_;opponent;refutation=Move{step=Dissection(first::_asd);_};}->letlast=List.lastfirstdinFormat.fprintfppf"dissection between ticks %a and %a (against %a)"Sc_rollup.Tick.ppfirst.tickSc_rollup.Tick.pplast.tickSignature.Public_key_hash.ppopponent|Refute{rollup=_;opponent;refutation=Move{step=Dissection[];_}}->Format.fprintfppf"dissection (against %a)"Signature.Public_key_hash.ppopponent|Refute{rollup=_;opponent;refutation=Move{choice;step=Proof_}}->Format.fprintfppf"proof for tick %a (against %a)"Sc_rollup.Tick.ppchoiceSignature.Public_key_hash.ppopponent|Timeout{rollup=_;stakers=_}->Format.fprintfppf"timeout"letto_manager_operation:t->packed_manager_operation=function|Add_messages{messages}->Manager(Sc_rollup_add_messages{messages})|Cement{rollup;commitment}->Manager(Sc_rollup_cement{rollup;commitment})|Publish{rollup;commitment}->Manager(Sc_rollup_publish{rollup;commitment})|Refute{rollup;opponent;refutation}->Manager(Sc_rollup_refute{rollup;opponent;refutation})|Timeout{rollup;stakers}->Manager(Sc_rollup_timeout{rollup;stakers})letof_manager_operation:typekind.kindmanager_operation->toption=function|Sc_rollup_add_messages{messages}->Some(Add_messages{messages})|Sc_rollup_cement{rollup;commitment}->Some(Cement{rollup;commitment})|Sc_rollup_publish{rollup;commitment}->Some(Publish{rollup;commitment})|Sc_rollup_refute{rollup;opponent;refutation}->Some(Refute{rollup;opponent;refutation})|Sc_rollup_timeout{rollup;stakers}->Some(Timeout{rollup;stakers})|_->None