123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108(*****************************************************************************)(* *)(* SPDX-License-Identifier: MIT *)(* Copyright (c) 2023 Functori, <contact@functori.com> *)(* Copyright (c) 2023 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(*****************************************************************************)moduleConfiguration=structtypetag=Transactiontypefee_parameters=Injector_common.fee_parameterlettags=[Transaction]letstring_of_purpose=functionTransaction->"Transaction"letdefault_fee_parameters={Injector_common.minimal_fees={Injector_common.mutez=100L};minimal_nanotez_per_byte=Q.of_int1000;minimal_nanotez_per_gas_unit=Q.of_int100;force_low_fee=false;fee_cap={Injector_common.mutez=1_000_000L};burn_cap={Injector_common.mutez=1_000_000L};}end(* The rest of this module is adapted from
[lib_smart_rollup_node/injector.ml] *)typestate={cctxt:Client_context.full;fee_parameters:Configuration.fee_parameters;minimal_block_delay:int64;delay_increment_per_round:int64;}openInjector_sigsmoduleParameters:PARAMETERSwithtypestate=stateandtypeTag.t=Configuration.tagandtypeOperation.t=Injector_server_operation.t=structtypenonrecstate=stateletevents_section=["injector";"server"]moduleTag:TAGwithtypet=Configuration.tag=structtypet=Configuration.tagletcompare=Stdlib.compareletequal=Stdlib.(=)lethash=Hashtbl.hashletstring_of_tag=Configuration.string_of_purposeletppppft=Format.pp_print_stringppf(string_of_tagt)letencoding:tData_encoding.t=letopenData_encodinginmatchConfiguration.tagswith(* first case can be removed once we have multiple tags *)|[tag]->convstring_of_tag(fun_->tag)string|tags->string_enum(List.map(funt->(string_of_tagt,t))tags)endmoduleOperation=Injector_server_operation(* Very coarse approximation for the number of operation we
expect for each block *)lettable_estimated_size:Tag.t->int=functionTransaction->100letoperation_tag:Operation.t->Tag.t=function|Transaction_->Transaction(* TODO: https://gitlab.com/tezos/tezos/-/issues/6281
revise if multiple operation kinds have different fee parameter
structures *)letfee_parameter{fee_parameters;_}_=fee_parameters(* TODO: https://gitlab.com/tezos/tezos/-/issues/3459
Decide if some batches must have all the operations succeed. See
{!Injector_common.Parameter.batch_must_succeed}. *)letbatch_must_succeed_=`At_least_oneletretry_unsuccessful_operation_node_ctxt(_op:Operation.t)status=letopenLwt_syntaxinmatchstatuswith|Backtracked|Skipped|Other_branch->(* Always retry backtracked or skipped operations, or operations that
are on another branch because of a reorg. *)returnRetry|Failederror->((* TODO: https://gitlab.com/tezos/tezos/-/issues/4071
Think about which operations should be retried and when. *)matchclassify_traceerrorwith|Permanent|Outdated->returnForget|Branch|Temporary->returnRetry)|Never_included->(* Forget operations that are never included *)returnForgetendincludeInjector_functor.Make(Parameters)