From fe284fa7b5f45d62b5f6dff106d17fc1ee23441c Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Thu, 15 Feb 2024 08:51:17 +0100 Subject: [PATCH 1/6] proto/delegate: expose min_delegated_in cycle in delegate_storage --- src/proto_alpha/lib_protocol/delegate_storage.ml | 13 +++++++++++++ src/proto_alpha/lib_protocol/delegate_storage.mli | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/proto_alpha/lib_protocol/delegate_storage.ml b/src/proto_alpha/lib_protocol/delegate_storage.ml index b58808258454..75fea2802c5c 100644 --- a/src/proto_alpha/lib_protocol/delegate_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_storage.ml @@ -392,6 +392,19 @@ module For_RPC = struct Stake_storage.For_RPC.get_staking_balance ctxt delegate else return Tez_repr.zero + let min_delegated_in_current_cycle ctxt delegate = + let open Lwt_result_syntax in + let current_cycle = (Raw_context.current_level ctxt).cycle in + let*! is_registered = registered ctxt delegate in + if is_registered then + let+ staking_balance = + Stake_storage.get_full_staking_balance ctxt delegate + in + Full_staking_balance_repr.min_delegated_in_cycle + ~current_cycle + staking_balance + else return Tez_repr.zero + let delegated_balance ctxt delegate = let open Lwt_result_syntax in let* staking_balance = staking_balance ctxt delegate in diff --git a/src/proto_alpha/lib_protocol/delegate_storage.mli b/src/proto_alpha/lib_protocol/delegate_storage.mli index 7593b5c85404..58c91f85e8e5 100644 --- a/src/proto_alpha/lib_protocol/delegate_storage.mli +++ b/src/proto_alpha/lib_protocol/delegate_storage.mli @@ -160,4 +160,7 @@ module For_RPC : sig val staking_balance : Raw_context.t -> Signature.Public_key_hash.t -> Tez_repr.t tzresult Lwt.t + + val min_delegated_in_current_cycle : + Raw_context.t -> Signature.Public_key_hash.t -> Tez_repr.t tzresult Lwt.t end -- GitLab From 8c0ab33f2fc5bff09151359e9ddf84704328483b Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Thu, 15 Feb 2024 08:47:55 +0100 Subject: [PATCH 2/6] proto/context: expose min_delegated_in_cycle for RPCs in alpha_context --- src/proto_alpha/lib_protocol/alpha_context.mli | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 5e40d58c7443..697bc0095a7b 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2488,6 +2488,9 @@ module Delegate : sig val staking_balance : context -> public_key_hash -> Tez.t tzresult Lwt.t + val min_delegated_in_current_cycle : + context -> public_key_hash -> Tez.t tzresult Lwt.t + val pending_denunciations : context -> public_key_hash -> Denunciations_repr.t tzresult Lwt.t -- GitLab From 0262e3dada31d2db1ae7bc7979cb946b520bf61f Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Thu, 15 Feb 2024 08:58:20 +0100 Subject: [PATCH 3/6] proto/RPC: add min_delegated_in_cycle to delegate info --- src/proto_alpha/lib_protocol/delegate_services.ml | 12 +++++++++++- src/proto_alpha/lib_protocol/delegate_services.mli | 1 + src/proto_alpha/lib_protocol/test/helpers/context.ml | 1 + .../lib_protocol/test/helpers/context.mli | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index d96373264562..78e57916afcd 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -116,6 +116,7 @@ type info = { frozen_deposits_limit : Tez.t option; delegated_contracts : Contract.t list; delegated_balance : Tez.t; + min_delegated_in_current_cycle : Tez.t; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; @@ -136,6 +137,7 @@ let info_encoding = frozen_deposits_limit; delegated_contracts; delegated_balance; + min_delegated_in_current_cycle; total_delegated_stake; staking_denominator; deactivated; @@ -151,6 +153,7 @@ let info_encoding = frozen_deposits_limit, delegated_contracts, delegated_balance, + min_delegated_in_current_cycle, deactivated, grace_period ), ( (total_delegated_stake, staking_denominator), @@ -162,6 +165,7 @@ let info_encoding = frozen_deposits_limit, delegated_contracts, delegated_balance, + min_delegated_in_current_cycle, deactivated, grace_period ), ( (total_delegated_stake, staking_denominator), @@ -174,6 +178,7 @@ let info_encoding = frozen_deposits_limit; delegated_contracts; delegated_balance; + min_delegated_in_current_cycle; total_delegated_stake; staking_denominator; deactivated; @@ -183,7 +188,7 @@ let info_encoding = pending_consensus_keys; }) (merge_objs - (obj9 + (obj10 (req "full_balance" Tez.encoding) (req "current_frozen_deposits" Tez.encoding) (req "frozen_deposits" Tez.encoding) @@ -191,6 +196,7 @@ let info_encoding = (opt "frozen_deposits_limit" Tez.encoding) (req "delegated_contracts" (list Contract.encoding)) (req "delegated_balance" Tez.encoding) + (req "min_delegated_in_current_cycle" Tez.encoding) (req "deactivated" bool) (req "grace_period" Cycle.encoding)) (merge_objs @@ -578,6 +584,9 @@ let register () = let* frozen_deposits_limit = Delegate.frozen_deposits_limit ctxt pkh in let*! delegated_contracts = Delegate.delegated_contracts ctxt pkh in let* delegated_balance = Delegate.For_RPC.delegated_balance ctxt pkh in + let* min_delegated_in_current_cycle = + Delegate.For_RPC.min_delegated_in_current_cycle ctxt pkh + in let* total_delegated_stake = Staking_pseudotokens.For_RPC.get_frozen_deposits_staked_tez ctxt @@ -604,6 +613,7 @@ let register () = frozen_deposits_limit; delegated_contracts; delegated_balance; + min_delegated_in_current_cycle; total_delegated_stake; staking_denominator; deactivated; diff --git a/src/proto_alpha/lib_protocol/delegate_services.mli b/src/proto_alpha/lib_protocol/delegate_services.mli index 17cb85ed0b55..be7bc6585733 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.mli +++ b/src/proto_alpha/lib_protocol/delegate_services.mli @@ -61,6 +61,7 @@ type info = { frozen_deposits_limit : Tez.t option; delegated_contracts : Contract.t list; delegated_balance : Tez.t; + min_delegated_in_current_cycle : Tez.t; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index db2eb18093b5..f8dad7726763 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -481,6 +481,7 @@ module Delegate = struct frozen_deposits_limit : Tez.t option; delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; + min_delegated_in_current_cycle : Tez.t; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index a90a8ba85b3d..16cee0d26ffa 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -250,6 +250,7 @@ module Delegate : sig frozen_deposits_limit : Tez.t option; delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; + min_delegated_in_current_cycle : Tez.t; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; -- GitLab From 05a4a565973c9a7eb282b20fe961f20ee6c5e47a Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Thu, 15 Feb 2024 08:59:12 +0100 Subject: [PATCH 4/6] proto/RPCs: add min_delegated_in_cycle RPC to delegate_services --- src/proto_alpha/lib_protocol/delegate_services.ml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index 78e57916afcd..4ce7a47a6336 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -411,6 +411,15 @@ module S = struct ~output:Tez.encoding RPC_path.(path / "delegated_balance") + let min_delegated_in_current_cycle = + RPC_service.get_service + ~description: + "Returns the minimum of delegated tez (in mutez) over the current \ + cycle." + ~query:RPC_query.empty + ~output:Tez.encoding + RPC_path.(path / "min_delegated_in_current_cycle") + let deactivated = RPC_service.get_service ~description: @@ -676,6 +685,12 @@ let register () = register1 ~chunked:false S.delegated_balance (fun ctxt pkh () () -> let* () = check_delegate_registered ctxt pkh in Delegate.For_RPC.delegated_balance ctxt pkh) ; + register1 + ~chunked:false + S.min_delegated_in_current_cycle + (fun ctxt pkh () () -> + let* () = check_delegate_registered ctxt pkh in + Delegate.For_RPC.min_delegated_in_current_cycle ctxt pkh) ; register1 ~chunked:false S.total_delegated_stake (fun ctxt pkh () () -> let* () = check_delegate_registered ctxt pkh in Staking_pseudotokens.For_RPC.get_frozen_deposits_staked_tez -- GitLab From 3ed01652618945f42cb0af99c92cda70f1aa269d Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Thu, 15 Feb 2024 11:50:40 +0100 Subject: [PATCH 5/6] tests/tezt: update regression tests --- ...lient) RPC regression tests- delegates.out | 8 ++-- ...light) RPC regression tests- delegates.out | 8 ++-- ...proxy) RPC regression tests- delegates.out | 8 ++-- ...a_dir) RPC regression tests- delegates.out | 8 ++-- ...r_rpc) RPC regression tests- delegates.out | 8 ++-- ... - delegate - consensus - destination).out | 39 ++++++++++++------- ...- delegate - consensus -- destination).out | 39 ++++++++++++------- ...-- delegate - consensus - destination).out | 39 ++++++++++++------- ...- delegate - consensus -- destination).out | 39 ++++++++++++------- ...lpha- Test register with consensus key.out | 10 +++-- ... set consensus key - baker is delegate.out | 24 +++++++----- ... consensus key - baker is not delegate.out | 24 +++++++----- 12 files changed, 157 insertions(+), 97 deletions(-) diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out index 9528e8733acd..6b257eca7b6f 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out @@ -20,9 +20,11 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 5, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 5, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/full_balance' diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out index 06e165d99971..a6d3e60d3c92 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out @@ -20,9 +20,11 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 5, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 5, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client --mode light rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/full_balance' diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out index 0e3cf04b9dda..eb6bf7c4a23e 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out @@ -20,9 +20,11 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 5, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 5, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client --mode proxy rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/full_balance' diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out index 9528e8733acd..6b257eca7b6f 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out @@ -20,9 +20,11 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 5, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 5, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/full_balance' diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out index 9528e8733acd..6b257eca7b6f 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out @@ -20,9 +20,11 @@ { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 5, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 5, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/full_balance' diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out index e066f38f2334..704b30d6e9d3 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out @@ -29,18 +29,22 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "4000000333333", "current_frozen_deposits": "200000016667", "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -49,18 +53,22 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' @@ -98,9 +106,10 @@ This sequence of operations was run: { "full_balance": "238000528932", "current_frozen_deposits": "200000181573", "frozen_deposits": "200000083984", "staking_balance": "238000528932", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 4, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", "min_delegated_in_current_cycle": "4", + "deactivated": false, "grace_period": 4, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out index 892b917c3981..dbbd212eaff6 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out @@ -29,18 +29,22 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "4000000333333", "current_frozen_deposits": "200000016667", "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -49,18 +53,22 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' @@ -98,9 +106,10 @@ This sequence of operations was run: { "full_balance": "238000528932", "current_frozen_deposits": "200000181573", "frozen_deposits": "200000083984", "staking_balance": "238000528932", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 4, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", "min_delegated_in_current_cycle": "4", + "deactivated": false, "grace_period": 4, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out index f7aefc6ee837..97a61ff6bc64 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out @@ -29,18 +29,22 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "3999999999716", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -49,18 +53,22 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' @@ -98,9 +106,10 @@ This sequence of operations was run: { "full_balance": "238000509096", "current_frozen_deposits": "200000164892", "frozen_deposits": "200000067317", "staking_balance": "238000509096", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 4, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", "min_delegated_in_current_cycle": "18", + "deactivated": false, "grace_period": 4, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out index 1e092ea539b0..0ae5f6b77c13 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out @@ -29,18 +29,22 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "3999999999716", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -49,18 +53,22 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' @@ -98,9 +106,10 @@ This sequence of operations was run: { "full_balance": "238000509096", "current_frozen_deposits": "200000164892", "frozen_deposits": "200000067317", "staking_balance": "238000509096", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 4, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", "min_delegated_in_current_cycle": "18", + "deactivated": false, "grace_period": 4, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out index 3259d73cdb5f..7bea90479067 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out @@ -64,8 +64,9 @@ This sequence of operations was run: { "full_balance": "999999999385", "current_frozen_deposits": "0", "frozen_deposits": "0", "staking_balance": "999999999385", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", + "delegated_balance": "0", "min_delegated_in_current_cycle": "999999999385", + "deactivated": false, "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -77,6 +78,7 @@ This sequence of operations was run: { "full_balance": "999999999385", "current_frozen_deposits": "49999999970", "frozen_deposits": "0", "staking_balance": "999999999385", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", + "delegated_balance": "0", "min_delegated_in_current_cycle": "949999999415", + "deactivated": false, "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out index e8100cb21f00..1eb937a52cbe 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out @@ -29,18 +29,22 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "4000000333333", "current_frozen_deposits": "200000016667", "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -49,7 +53,9 @@ This sequence of operations was run: { "full_balance": "4000003298113", "current_frozen_deposits": "200000164906", "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out index c4a3c8433dfe..4444e752bbec 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out @@ -29,18 +29,22 @@ This sequence of operations was run: { "full_balance": "4000000000000", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "3999999999716", "current_frozen_deposits": "200000000000", "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": [ { "cycle": 2, "pkh": "[PUBLIC_KEY_HASH]" } ] } @@ -49,7 +53,9 @@ This sequence of operations was run: { "full_balance": "4000002964496", "current_frozen_deposits": "200000148225", "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "deactivated": false, "grace_period": 3, - "total_delegated_stake": "0", "staking_denominator": "0", - "voting_power": "4000000000000", "remaining_proposals": 20, + "delegated_balance": "0", + "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "grace_period": 3, "total_delegated_stake": "0", + "staking_denominator": "0", "voting_power": "4000000000000", + "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } -- GitLab From 44eec783e021cab11d6609d1eca88740624dd1dc Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Thu, 15 Feb 2024 11:57:28 +0100 Subject: [PATCH 6/6] docs/proto: update alpha changelog --- docs/protocols/alpha.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 1327428db3ca..3dd2bbc73aed 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -107,6 +107,11 @@ Adaptive Issuance (ongoing) - Adjust total supply tracked for AI (estimated in O) so that it matches the actual total supply. (MR :gl:`!11996`) +- Add min_delegated_in_current_cycle field in delegates info obtained via ``GET '/chains/main/blocks/[BLOCK_ID]]/context/delegates/[PUBLIC_KEY_HASH]'`` (MR :gl:`!12018``) + +- Add RPC to get min_delegated_in_current_cycle for a delegate using ``GET '/chains/main/blocks/[BLOCK_ID]]/context/delegates/[PUBLIC_KEY_HASH]/min_delegated_in_current_cycle'`` (MR :gl:`!12018`) + + Gas improvements ---------------- -- GitLab