Draft: RPC: Pretty print conflicts at registration time
Context
This MR makes the registration of RPCs display conflicts in a human readable way on stderr when they happen. This is especially useful for developers when adding new RPCs or changing existing ones (see e.g., this thread).
Manually testing the MR
Apply the following patch:
diff --git a/src/proto_alpha/lib_protocol/contract_services.ml b/src/proto_alpha/lib_protocol/contract_services.ml
index ee2a3a66a4..3c4a3ad1d8 100644
--- a/src/proto_alpha/lib_protocol/contract_services.ml
+++ b/src/proto_alpha/lib_protocol/contract_services.ml
@@ -117,6 +117,13 @@ module S = struct
~output:Script.expr_encoding
RPC_path.(custom_root /: Contract.rpc_arg / "storage")
+ let nothing =
+ RPC_service.get_service
+ ~description:"Do nothing"
+ ~query:RPC_query.empty
+ ~output:unit
+ RPC_path.(custom_root / "nothing")
+
type normalize_types_query = {normalize_types : bool}
let normalize_types_query : normalize_types_query RPC_query.t =
@@ -522,6 +529,7 @@ let[@coq_axiom_with_reason "gadt"] register () =
script
>|=? fun (script, ctxt) -> (Some script, ctxt))
>|=? fun (script, _ctxt) -> {balance; delegate; script; counter}) ;
+ register0 ~chunked:false S.nothing (fun _ _ _ -> return_unit) ;
S.Sapling.register ()
let list ctxt block = RPC_context.make_call0 S.list ctxt block () ()
and check that running make displays
Error in registration of service GET /context/contracts/nothing (Do nothing):
Type conflict for nothing with argument contract_id in /context/contracts/nothing
Checklist
- [-] Document the interface of any function added or modified (see the coding guidelines)
- [-] Document any change to the user interface, including configuration parameters (see node configuration)
- [-] Provide automatic testing (see the testing guide).
- [-] For new features and bug fixes, add an item in the appropriate changelog (
docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR
Edited by Alain Mebsout