From 11e10aeaca37b4254abccc7f43db77c0d897a924 Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Wed, 5 Jul 2023 18:22:01 +0200 Subject: [PATCH 1/4] Proto/ai: swap matches --- .../lib_protocol/unstake_requests_storage.ml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/proto_alpha/lib_protocol/unstake_requests_storage.ml b/src/proto_alpha/lib_protocol/unstake_requests_storage.ml index 7f2a1e41e2e6..ca3acf37acef 100644 --- a/src/proto_alpha/lib_protocol/unstake_requests_storage.ml +++ b/src/proto_alpha/lib_protocol/unstake_requests_storage.ml @@ -97,15 +97,13 @@ let prepare_finalize_unstake ctxt contract = let max_slashing_period = Constants_storage.max_slashing_period ctxt in let preserved_plus_slashing = preserved_cycles + max_slashing_period in let current_cycle = (Raw_context.current_level ctxt).cycle in - match Cycle_repr.sub current_cycle preserved_plus_slashing with - | None (* no finalizable cycle *) -> return None - | Some greatest_finalizable_cycle -> ( - let* requests_opt = - Storage.Contract.Unstake_requests.find ctxt contract - in - match requests_opt with - | None | Some {delegate = _; requests = []} -> return None - | Some {delegate; requests} -> + let* requests_opt = Storage.Contract.Unstake_requests.find ctxt contract in + match requests_opt with + | None | Some {delegate = _; requests = []} -> return None + | Some {delegate; requests} -> ( + match Cycle_repr.sub current_cycle preserved_plus_slashing with + | None (* no finalizable cycle *) -> return None + | Some greatest_finalizable_cycle -> let* slashing_history_opt = Storage.Contract.Slashed_deposits.find ctxt -- GitLab From 56da8b8eef43d84aa3e9afbbef543dcf37dfe2dc Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Wed, 5 Jul 2023 18:24:48 +0200 Subject: [PATCH 2/4] Proto/ai: return something even if there is no unfinalizable cycle --- src/proto_alpha/lib_protocol/unstake_requests_storage.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/unstake_requests_storage.ml b/src/proto_alpha/lib_protocol/unstake_requests_storage.ml index ca3acf37acef..cfd02d0d53cc 100644 --- a/src/proto_alpha/lib_protocol/unstake_requests_storage.ml +++ b/src/proto_alpha/lib_protocol/unstake_requests_storage.ml @@ -102,7 +102,8 @@ let prepare_finalize_unstake ctxt contract = | None | Some {delegate = _; requests = []} -> return None | Some {delegate; requests} -> ( match Cycle_repr.sub current_cycle preserved_plus_slashing with - | None (* no finalizable cycle *) -> return None + | None (* no finalizable cycle *) -> + return_some {finalizable = []; unfinalizable = {delegate; requests}} | Some greatest_finalizable_cycle -> let* slashing_history_opt = Storage.Contract.Slashed_deposits.find -- GitLab From 4ec91d5f05cbbf110660c1940c695ba383f51809 Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Wed, 5 Jul 2023 18:25:22 +0200 Subject: [PATCH 3/4] Proto/ai: return None -> return_none --- src/proto_alpha/lib_protocol/unstake_requests_storage.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/unstake_requests_storage.ml b/src/proto_alpha/lib_protocol/unstake_requests_storage.ml index cfd02d0d53cc..0cc73b3c19bb 100644 --- a/src/proto_alpha/lib_protocol/unstake_requests_storage.ml +++ b/src/proto_alpha/lib_protocol/unstake_requests_storage.ml @@ -99,7 +99,7 @@ let prepare_finalize_unstake ctxt contract = let current_cycle = (Raw_context.current_level ctxt).cycle in let* requests_opt = Storage.Contract.Unstake_requests.find ctxt contract in match requests_opt with - | None | Some {delegate = _; requests = []} -> return None + | None | Some {delegate = _; requests = []} -> return_none | Some {delegate; requests} -> ( match Cycle_repr.sub current_cycle preserved_plus_slashing with | None (* no finalizable cycle *) -> -- GitLab From cb5de8b873dec98b81d324144a704e0c1b1f811a Mon Sep 17 00:00:00 2001 From: Lucas Randazzo Date: Wed, 5 Jul 2023 18:27:09 +0200 Subject: [PATCH 4/4] Proto/ai: fix description --- src/proto_alpha/lib_protocol/unstake_requests_storage.mli | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/unstake_requests_storage.mli b/src/proto_alpha/lib_protocol/unstake_requests_storage.mli index 5d75ee4a97f4..3f6317b942a6 100644 --- a/src/proto_alpha/lib_protocol/unstake_requests_storage.mli +++ b/src/proto_alpha/lib_protocol/unstake_requests_storage.mli @@ -50,8 +50,7 @@ val prepared_finalize_unstake_encoding : the [finalizable_field] as well as the remaining unfinalizable requests that should be kept in the storage in [unfinalizable]. - It returns [None] if there are no finalizable unstake requests (regardless - of whether there are unstake requests at all). *) + It returns [None] if there are no unstake requests. *) val prepare_finalize_unstake : Raw_context.t -> Contract_repr.t -> -- GitLab