From 8aa45f46497a577e6ed6c47f9818751402be3caf Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Wed, 16 Apr 2025 10:30:46 +0200 Subject: [PATCH 1/6] Quebec/Plugin: expose contract services We want to be able to re-use these declarations for tezlink --- .../lib_plugin/contract_services.mli | 287 ++++++++++++++++++ 1 file changed, 287 insertions(+) diff --git a/src/proto_021_PsQuebec/lib_plugin/contract_services.mli b/src/proto_021_PsQuebec/lib_plugin/contract_services.mli index a95787b3ed80..284d43dff015 100644 --- a/src/proto_021_PsQuebec/lib_plugin/contract_services.mli +++ b/src/proto_021_PsQuebec/lib_plugin/contract_services.mli @@ -201,3 +201,290 @@ module Implem : sig Environment.Error_monad.tzresult Lwt.t end + +module S : sig + val balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val spendable : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val balance_and_frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val spendable_and_frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val staked_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val staking_numerator : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Staking_pseudotoken.t ) + RPC_service.service + + val unstaked_frozen_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val unstaked_finalizable_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val unstake_requests : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Unstake_requests.prepared_finalize_unstake option ) + RPC_service.service + + val full_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val manager_key : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Signature.Public_key.t option ) + RPC_service.service + + val delegate : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Signature.Public_key_hash.t ) + RPC_service.service + + val counter : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Manager_counter.t ) + RPC_service.service + + val script : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Script.t ) + RPC_service.service + + val storage : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Script.expr ) + RPC_service.service + + type normalize_types_query = {normalize_types : bool} + + val normalize_types_query : normalize_types_query RPC_query.t + + val entrypoint_type : + ( [`GET], + RPC_context.t, + (RPC_context.t * Contract.t) * Entrypoint.t, + normalize_types_query, + unit, + Script.expr ) + RPC_service.service + + val list_entrypoints : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + normalize_types_query, + unit, + Michelson_v1_primitives.prim list list * (string * Script.expr) list ) + RPC_service.service + + val contract_big_map_get_opt : + ( [`POST], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + Script.expr * Script.expr, + Script.expr option ) + RPC_service.service + + val big_map_get : + ( [`GET], + RPC_context.t, + (RPC_context.t * Big_map.Id.t) * Script_expr_hash.t, + unit, + unit, + Script.expr ) + RPC_service.service + + type big_map_get_all_query = {offset : int option; length : int option} + + val rpc_arg_uint : int RPC_arg.t + + val big_map_get_all_query : big_map_get_all_query RPC_query.t + + val big_map_get_all : + ( [`GET], + RPC_context.t, + RPC_context.t * Big_map.Id.t, + big_map_get_all_query, + unit, + Script.expr list ) + RPC_service.service + + val info : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + normalize_types_query, + unit, + info ) + RPC_service.service + + val list : + ( [`GET], + RPC_context.t, + RPC_context.t, + unit, + unit, + Contract.t list ) + RPC_service.service + + val estimated_own_pending_slashed_amount : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + module Sapling : sig + val single_sapling_get_id : + context -> + Contract_hash.t -> + ( Sapling.Id.t option * context, + Error_monad.error Error_monad.trace ) + Pervasives.result + Lwt.t + + val make_service : + ('a, 'b) Sapling_services.S.Args.t -> + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + 'a, + unit, + 'b ) + RPC_service.service + * (context -> + Contract.t -> + 'a -> + unit -> + ('b option, Error_monad.error Error_monad.trace) Pervasives.result Lwt.t) + + val get_diff : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + Sapling_services.diff_query, + unit, + Sapling.root * Sapling.diff ) + RPC_service.service + * (context -> + Contract.t -> + Sapling_services.diff_query -> + unit -> + ( (Sapling.root * Sapling.diff) option, + Error_monad.error Error_monad.trace ) + Pervasives.result + Lwt.t) + + val register : unit -> unit + + val mk_call1 : + ( [< Resto.meth], + RPC_context.t, + RPC_context.t * 'a, + 'b, + unit, + 'c ) + RPC_service.t + * 'd -> + 'e #RPC_context.simple -> + 'e -> + 'a -> + 'b -> + 'c Error_monad.shell_tzresult Lwt.t + end +end -- GitLab From 8b7e345c011b664bc1aee0e303a85efaca700cb9 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Wed, 16 Apr 2025 11:28:13 +0200 Subject: [PATCH 2/6] Proto/Plugin: expose contract services in all proto after Quebec Because why not making them for all versions, we might need them at some point. Also, consistency. --- .../lib_plugin/contract_services.mli | 287 ++++++++++++++++++ .../lib_plugin/contract_services.mli | 287 ++++++++++++++++++ 2 files changed, 574 insertions(+) diff --git a/src/proto_022_PsRiotum/lib_plugin/contract_services.mli b/src/proto_022_PsRiotum/lib_plugin/contract_services.mli index f454a4e8604d..46c80215519b 100644 --- a/src/proto_022_PsRiotum/lib_plugin/contract_services.mli +++ b/src/proto_022_PsRiotum/lib_plugin/contract_services.mli @@ -201,3 +201,290 @@ module Implem : sig Environment.Error_monad.tzresult Lwt.t end + +module S : sig + val balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val spendable : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val balance_and_frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val spendable_and_frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val staked_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val staking_numerator : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Staking_pseudotoken.t ) + RPC_service.service + + val unstaked_frozen_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val unstaked_finalizable_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val unstake_requests : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Unstake_requests.For_RPC.prepared_finalize_unstake option ) + RPC_service.service + + val full_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val manager_key : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Signature.Public_key.t option ) + RPC_service.service + + val delegate : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Signature.Public_key_hash.t ) + RPC_service.service + + val counter : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Manager_counter.t ) + RPC_service.service + + val script : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Script.t ) + RPC_service.service + + val storage : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Script.expr ) + RPC_service.service + + type normalize_types_query = {normalize_types : bool} + + val normalize_types_query : normalize_types_query RPC_query.t + + val entrypoint_type : + ( [`GET], + RPC_context.t, + (RPC_context.t * Contract.t) * Entrypoint.t, + normalize_types_query, + unit, + Script.expr ) + RPC_service.service + + val list_entrypoints : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + normalize_types_query, + unit, + Michelson_v1_primitives.prim list list * (string * Script.expr) list ) + RPC_service.service + + val contract_big_map_get_opt : + ( [`POST], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + Script.expr * Script.expr, + Script.expr option ) + RPC_service.service + + val big_map_get : + ( [`GET], + RPC_context.t, + (RPC_context.t * Big_map.Id.t) * Script_expr_hash.t, + unit, + unit, + Script.expr ) + RPC_service.service + + type big_map_get_all_query = {offset : int option; length : int option} + + val rpc_arg_uint : int RPC_arg.t + + val big_map_get_all_query : big_map_get_all_query RPC_query.t + + val big_map_get_all : + ( [`GET], + RPC_context.t, + RPC_context.t * Big_map.Id.t, + big_map_get_all_query, + unit, + Script.expr list ) + RPC_service.service + + val info : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + normalize_types_query, + unit, + info ) + RPC_service.service + + val list : + ( [`GET], + RPC_context.t, + RPC_context.t, + unit, + unit, + Contract.t list ) + RPC_service.service + + val estimated_own_pending_slashed_amount : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + module Sapling : sig + val single_sapling_get_id : + context -> + Contract_hash.t -> + ( Sapling.Id.t option * context, + Error_monad.error Error_monad.trace ) + Pervasives.result + Lwt.t + + val make_service : + ('a, 'b) Sapling_services.S.Args.t -> + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + 'a, + unit, + 'b ) + RPC_service.service + * (context -> + Contract.t -> + 'a -> + unit -> + ('b option, Error_monad.error Error_monad.trace) Pervasives.result Lwt.t) + + val get_diff : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + Sapling_services.diff_query, + unit, + Sapling.root * Sapling.diff ) + RPC_service.service + * (context -> + Contract.t -> + Sapling_services.diff_query -> + unit -> + ( (Sapling.root * Sapling.diff) option, + Error_monad.error Error_monad.trace ) + Pervasives.result + Lwt.t) + + val register : unit -> unit + + val mk_call1 : + ( [< Resto.meth], + RPC_context.t, + RPC_context.t * 'a, + 'b, + unit, + 'c ) + RPC_service.t + * 'd -> + 'e #RPC_context.simple -> + 'e -> + 'a -> + 'b -> + 'c Error_monad.shell_tzresult Lwt.t + end +end diff --git a/src/proto_alpha/lib_plugin/contract_services.mli b/src/proto_alpha/lib_plugin/contract_services.mli index f454a4e8604d..46c80215519b 100644 --- a/src/proto_alpha/lib_plugin/contract_services.mli +++ b/src/proto_alpha/lib_plugin/contract_services.mli @@ -201,3 +201,290 @@ module Implem : sig Environment.Error_monad.tzresult Lwt.t end + +module S : sig + val balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val spendable : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val balance_and_frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val spendable_and_frozen_bonds : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val staked_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val staking_numerator : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Staking_pseudotoken.t ) + RPC_service.service + + val unstaked_frozen_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val unstaked_finalizable_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t option ) + RPC_service.service + + val unstake_requests : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Unstake_requests.For_RPC.prepared_finalize_unstake option ) + RPC_service.service + + val full_balance : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + val manager_key : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Signature.Public_key.t option ) + RPC_service.service + + val delegate : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Signature.Public_key_hash.t ) + RPC_service.service + + val counter : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Manager_counter.t ) + RPC_service.service + + val script : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Script.t ) + RPC_service.service + + val storage : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Script.expr ) + RPC_service.service + + type normalize_types_query = {normalize_types : bool} + + val normalize_types_query : normalize_types_query RPC_query.t + + val entrypoint_type : + ( [`GET], + RPC_context.t, + (RPC_context.t * Contract.t) * Entrypoint.t, + normalize_types_query, + unit, + Script.expr ) + RPC_service.service + + val list_entrypoints : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + normalize_types_query, + unit, + Michelson_v1_primitives.prim list list * (string * Script.expr) list ) + RPC_service.service + + val contract_big_map_get_opt : + ( [`POST], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + Script.expr * Script.expr, + Script.expr option ) + RPC_service.service + + val big_map_get : + ( [`GET], + RPC_context.t, + (RPC_context.t * Big_map.Id.t) * Script_expr_hash.t, + unit, + unit, + Script.expr ) + RPC_service.service + + type big_map_get_all_query = {offset : int option; length : int option} + + val rpc_arg_uint : int RPC_arg.t + + val big_map_get_all_query : big_map_get_all_query RPC_query.t + + val big_map_get_all : + ( [`GET], + RPC_context.t, + RPC_context.t * Big_map.Id.t, + big_map_get_all_query, + unit, + Script.expr list ) + RPC_service.service + + val info : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + normalize_types_query, + unit, + info ) + RPC_service.service + + val list : + ( [`GET], + RPC_context.t, + RPC_context.t, + unit, + unit, + Contract.t list ) + RPC_service.service + + val estimated_own_pending_slashed_amount : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + unit, + unit, + Tez.t ) + RPC_service.service + + module Sapling : sig + val single_sapling_get_id : + context -> + Contract_hash.t -> + ( Sapling.Id.t option * context, + Error_monad.error Error_monad.trace ) + Pervasives.result + Lwt.t + + val make_service : + ('a, 'b) Sapling_services.S.Args.t -> + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + 'a, + unit, + 'b ) + RPC_service.service + * (context -> + Contract.t -> + 'a -> + unit -> + ('b option, Error_monad.error Error_monad.trace) Pervasives.result Lwt.t) + + val get_diff : + ( [`GET], + RPC_context.t, + RPC_context.t * Contract.t, + Sapling_services.diff_query, + unit, + Sapling.root * Sapling.diff ) + RPC_service.service + * (context -> + Contract.t -> + Sapling_services.diff_query -> + unit -> + ( (Sapling.root * Sapling.diff) option, + Error_monad.error Error_monad.trace ) + Pervasives.result + Lwt.t) + + val register : unit -> unit + + val mk_call1 : + ( [< Resto.meth], + RPC_context.t, + RPC_context.t * 'a, + 'b, + unit, + 'c ) + RPC_service.t + * 'd -> + 'e #RPC_context.simple -> + 'e -> + 'a -> + 'b -> + 'c Error_monad.shell_tzresult Lwt.t + end +end -- GitLab From 1d85e9fd62524b0abe79c0e7efaec78a8e7d096b Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Tue, 15 Apr 2025 17:34:53 +0200 Subject: [PATCH 3/6] Tezlink/Node: manager_key rpc --- .../lib_dev/tezlink/tezlink_backend_sig.ml | 6 ++++ .../lib_dev/tezlink/tezos_services.ml | 29 ++++++++++++++++ .../bin_node/lib_dev/tezlink_services_impl.ml | 17 ++++++++++ .../Alpha- Test the -describe endpoint.out | 34 +++++++++++-------- 4 files changed, 72 insertions(+), 14 deletions(-) diff --git a/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml b/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml index e5c0190dc2d2..580e4bdd1bc3 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezlink_backend_sig.ml @@ -19,4 +19,10 @@ module type S = sig val balance : [> `Main] -> [> `Head of 'a] -> Contract.t -> Tez.t tzresult Lwt.t + + val manager_key : + [> `Main] -> + [> `Head of 'a] -> + Contract.t -> + Signature.public_key option tzresult Lwt.t end diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml b/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml index cea7c83ad0b5..143eb5e4742d 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml @@ -65,6 +65,16 @@ module Protocol_types = struct ~dst:encoding ~src:conversion_encoding end + + module Public_key = struct + include Tezlink_imports.Imported_env.Signature.Public_key + + let convert : Signature.Public_key.t -> t tzresult = + Tezos_types.convert_using_serialization + ~name:"public_key" + ~dst:encoding + ~src:Signature.Public_key.encoding + end end (** [wrap conversion service_implementation] changes the output type @@ -209,6 +219,17 @@ module Imported_services = struct ~output:Tezos_types.Tez.encoding (contract_arg_path "balance") + let manager_key : + ( [`GET], + tezlink_rpc_context, + tezlink_rpc_context * Tezos_types.Contract.t, + unit, + unit, + Protocol_types.Alpha_context.public_key option ) + Tezos_rpc.Service.t = + let open Tezos_rpc in + Service.subst1 Imported_protocol_plugin.Contract_services.S.manager_key + let constants : ( [`GET], tezlink_rpc_context, @@ -249,6 +270,14 @@ let build_block_dir (module Backend : Tezlink_backend_sig.S) = ~service:Imported_services.balance ~impl:(fun ({chain; block}, contract) _ _ -> Backend.balance chain block contract) + |> register_with_conversion + ~service:Imported_services.manager_key + ~impl:(fun ({chain; block}, contract) _ _ -> + Backend.manager_key chain block contract) + ~convert_output:(function + | None -> Result.return_none + | Some pk -> + Result.map Option.some @@ Protocol_types.Public_key.convert pk) |> register_with_conversion ~service:Imported_services.constants ~impl:(fun {block; chain} () () -> Backend.constants chain block) diff --git a/etherlink/bin_node/lib_dev/tezlink_services_impl.ml b/etherlink/bin_node/lib_dev/tezlink_services_impl.ml index 77b9b98a6d00..85d67fd93f92 100644 --- a/etherlink/bin_node/lib_dev/tezlink_services_impl.ml +++ b/etherlink/bin_node/lib_dev/tezlink_services_impl.ml @@ -19,6 +19,8 @@ module Path = struct "/tezlink/context/contracts/index/" ^ to_path Contract.encoding contract let balance contract = account contract ^ "/balance" + + let manager_key contract = account contract ^ "/manager_key" end let balance read chain block c = @@ -33,6 +35,17 @@ let balance read chain block c = (Path.balance c) (Data_encoding.Binary.of_bytes_exn Tez.encoding) +let manager_key read chain block c = + (* TODO: #7831 !17664 + Support non-default chain and block parameters. *) + ignore chain ; + ignore block ; + + Durable_storage.inspect_durable_and_decode_opt + read + (Path.manager_key c) + (Data_encoding.Binary.of_bytes_exn Signature.Public_key.encoding) + module type Backend = sig include Durable_storage.READER @@ -145,4 +158,8 @@ module Make (Backend : Backend) : Tezlink_backend_sig.S = struct (* TODO: #7831 !17664 we type [chain], even though we don't use it, to satisfy the compiler. *) let balance (chain : [> `Main]) = balance read chain + + (* TODO: #7831 !17664 + we type [chain], even though we don't use it, to satisfy the compiler. *) + let manager_key (chain : [> `Main]) = manager_key read chain end diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Test the -describe endpoint.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Test the -describe endpoint.out index c4abd351c3f7..fa39a1b94031 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Test the -describe endpoint.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Test the -describe endpoint.out @@ -25,13 +25,16 @@ Available services: Assess the health of the RPC server + tezlink/ + chains//blocks// - - GET /tezlink/chains//blocks//context/constants - All constants - - GET /tezlink/chains//blocks//context/contracts//balance - The spendable balance of a contract (in mutez), also known as - liquid balance. Corresponds to tez owned by the contract that are - neither staked, nor in unstaked requests, nor in frozen bonds. - Identical to the 'spendable' RPC. + + context/ + - GET /tezlink/chains//blocks//context/constants + All constants + - GET /tezlink/chains//blocks//context/contracts//balance + The spendable balance of a contract (in mutez), also known as + liquid balance. Corresponds to tez owned by the contract that are + neither staked, nor in unstaked requests, nor in frozen bonds. + Identical to the 'spendable' RPC. + - GET /tezlink/chains//blocks//context/contracts//manager_key + Access the manager of an implicit contract. - GET /tezlink/chains//blocks//helpers/current_level Returns the level of the interrogated block, or the one of a block located `offset` blocks after it in the chain. For instance, the @@ -78,13 +81,16 @@ Warning: Available services: + chains//blocks// - - GET /chains//blocks//context/constants - All constants - - GET /chains//blocks//context/contracts//balance - The spendable balance of a contract (in mutez), also known as liquid - balance. Corresponds to tez owned by the contract that are neither - staked, nor in unstaked requests, nor in frozen bonds. Identical to - the 'spendable' RPC. + + context/ + - GET /chains//blocks//context/constants + All constants + - GET /chains//blocks//context/contracts//balance + The spendable balance of a contract (in mutez), also known as + liquid balance. Corresponds to tez owned by the contract that are + neither staked, nor in unstaked requests, nor in frozen bonds. + Identical to the 'spendable' RPC. + - GET /chains//blocks//context/contracts//manager_key + Access the manager of an implicit contract. - GET /chains//blocks//helpers/current_level Returns the level of the interrogated block, or the one of a block located `offset` blocks after it in the chain. For instance, the next -- GitLab From 90d4bbb6f969f71b5461e6d6e5061187fd7c88e7 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Tue, 15 Apr 2025 17:53:14 +0200 Subject: [PATCH 4/6] Tezlink/Tezt: test manager_key rpc --- etherlink/tezt/tests/evm_sequencer.ml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 18efd15ad127..74a4157322c0 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -579,6 +579,32 @@ let test_tezlink_balance = (Tez.to_mutez res = 3800000000000) int ~error_msg:"Expected %R but got %L") ; unit +let account_rpc sequencer account key = + let path = + sf + "/tezlink/chains/main/blocks/head/context/contracts/%s/%s" + account.Account.public_key_hash + key + in + + let* res = + Curl.get_raw ~args:["-v"] (Evm_node.endpoint sequencer ^ path) + |> Runnable.run + in + return @@ JSON.parse ~origin:"curl_protocols" res + +let test_tezlink_manager_key = + register_tezlink_test + ~title:"Test of the manager_key rpc" + ~tags:["rpc"; "manager_key"] + @@ fun {sequencer; _} _protocol -> + let* res = account_rpc sequencer Constant.bootstrap1 "manager_key" in + Check.( + JSON.(res |> as_string_opt = None) + (option string) + ~error_msg:"Expected %R but got %L") ; + unit + let test_tezlink_version = register_tezlink_test ~title:"Test of the version rpc" @@ -13226,6 +13252,7 @@ let () = test_durable_storage_consistency [Alpha] ; test_tezlink_current_level [Alpha] ; test_tezlink_balance [Alpha] ; + test_tezlink_manager_key [Alpha] ; test_tezlink_protocols [Alpha] ; test_tezlink_version [Alpha] ; test_tezlink_constants [Alpha] ; -- GitLab From a2dcb381935f75ce095e7063f979469bebcaecf3 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Wed, 16 Apr 2025 11:16:52 +0200 Subject: [PATCH 5/6] Tezling/Node: import balance service instead of copy paste --- .../bin_node/lib_dev/tezlink/tezos_services.ml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml b/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml index 143eb5e4742d..4add7659b688 100644 --- a/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml +++ b/etherlink/bin_node/lib_dev/tezlink/tezos_services.ml @@ -193,12 +193,6 @@ module Imported_services = struct Tezos_rpc.Service.t = import_service Tezos_shell_services.Shell_services.Blocks.S.protocols - let contract_arg_path s = - let contract_path = Imported_protocol_plugin.RPC.Contract.S.path in - let contract_args = Imported_protocol.Alpha_context.Contract.rpc_arg in - Imported_env.RPC_path.(contract_path /: contract_args / s) - - (* TODO: #7876 Expose and import the service definition from the plugin. *) let balance : ( [`GET], tezlink_rpc_context, @@ -208,16 +202,7 @@ module Imported_services = struct Tezos_types.Tez.t ) Tezos_rpc.Service.t = Tezos_rpc.Service.subst1 - (* TODO: #7876 should be imported *) - @@ Tezos_rpc.Service.get_service - ~description: - "The spendable balance of a contract (in mutez), also known as \ - liquid balance. Corresponds to tez owned by the contract that are \ - neither staked, nor in unstaked requests, nor in frozen bonds. \ - Identical to the 'spendable' RPC." - ~query:Tezos_rpc.Query.empty - ~output:Tezos_types.Tez.encoding - (contract_arg_path "balance") + Imported_protocol_plugin.Contract_services.S.balance let manager_key : ( [`GET], -- GitLab From 08d2068d254da76ffd2dc95e1d56bf201d07ac33 Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Cornilleau Date: Wed, 16 Apr 2025 11:40:47 +0200 Subject: [PATCH 6/6] Tezlink/Tezt: cleanup tests tags --- etherlink/tezt/tests/evm_sequencer.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/etherlink/tezt/tests/evm_sequencer.ml b/etherlink/tezt/tests/evm_sequencer.ml index 74a4157322c0..cbcc7e3b0f06 100644 --- a/etherlink/tezt/tests/evm_sequencer.ml +++ b/etherlink/tezt/tests/evm_sequencer.ml @@ -462,7 +462,7 @@ let register_tezlink_test ~title ~tags scenario protocols = let test_tezlink_current_level = register_tezlink_test ~title:"Test of the current_level rpc" - ~tags:["evm"; "rpc"; "current_level"] + ~tags:["rpc"; "current_level"] @@ fun {sequencer; _} _protocol -> (* call the current_level rpc and parse the result *) let rpc_current_level ?offset block = @@ -538,7 +538,7 @@ let test_tezlink_current_level = let test_tezlink_protocols = register_tezlink_test ~title:"Test of the protocols rpc" - ~tags:["evm"; "rpc"; "protocols"] + ~tags:["rpc"; "protocols"] @@ fun {sequencer; _} _protocol -> (* call the protocols rpc and parse the result *) let rpc_protocols () = @@ -562,7 +562,7 @@ let test_tezlink_protocols = let test_tezlink_balance = register_tezlink_test ~title:"Test of the balance rpc" - ~tags:["evm"; "rpc"; "balance"] + ~tags:["rpc"; "balance"] @@ fun {sequencer; client; _} _protocol -> (* call the balance rpc and parse the result *) let endpoint = @@ -608,7 +608,7 @@ let test_tezlink_manager_key = let test_tezlink_version = register_tezlink_test ~title:"Test of the version rpc" - ~tags:["evm"; "rpc"; "version"] + ~tags:["rpc"; "version"] @@ fun {sequencer; _} _protocol -> (* call the version rpc and parse the result *) let rpc_version () = -- GitLab