From 3be9840e7444f64edc7c8bfe96b45aa01e6da101 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Thu, 15 Feb 2024 11:26:21 +0100 Subject: [PATCH 01/11] tezt/tests/adaptive_issuance: bake with all accounts by default Otherwise when baking for many cycles we would be deactivated --- tezt/tests/adaptive_issuance.ml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index f6732fb1781e..c2c594f5a405 100644 --- a/tezt/tests/adaptive_issuance.ml +++ b/tezt/tests/adaptive_issuance.ml @@ -35,6 +35,8 @@ let blocks_per_cycle = 4 let nonce_revelation_threshold = 2 +let bootstrap_accounts = Constant.all_secret_keys + module Helpers = struct let level_type : RPC.level Check.typ = Check.convert @@ -52,6 +54,17 @@ module Helpers = struct ~error_msg:"expected current_period = %R, got %L" ; unit + let bake ?ai_vote + ?(keys = List.map (fun x -> x.Account.alias) bootstrap_accounts) ~endpoint + ~protocol client = + Client.bake_for + ~endpoint + ~minimal_timestamp:true + ~protocol + ~keys + client + ?ai_vote + let bake_n_cycles bake ?keys n client = let* current_level = get_current_level client in let current_level = current_level.level in @@ -135,8 +148,6 @@ let default_overrides = (["adaptive_issuance_launch_ema_threshold"], `Int 1); ] -let bootstrap_accounts = Constant.all_secret_keys - let launch_ema_threshold client = let* json = Client.RPC.call client @@ RPC.get_chain_block_context_constants () @@ -171,13 +182,7 @@ let activate_ai protocol sandbox_client sandbox_endpoint = assert (JSON.is_null launch_cycle) ; (* Make delegate vote for AI activation*) let bake ?keys client = - Client.bake_for - ~endpoint:sandbox_endpoint - ~minimal_timestamp:true - ~protocol - ?keys - client - ~ai_vote:On + Helpers.bake ~ai_vote:On ~endpoint:sandbox_endpoint ~protocol ?keys client in (* The vote should have passed during the first cycle *) let* () = @@ -739,10 +744,7 @@ let test_staking = Constant.bootstrap2.public_key_hash in Log.info "Numerator/denominator before: %d/%d " numerator denominator ; - - let bake ?keys client = - Client.bake_for ~endpoint ~minimal_timestamp:true ~protocol ?keys client - in + let bake = Helpers.bake ~ai_vote:Pass ~endpoint ~protocol in let* () = Helpers.bake_n_cycles bake 1 client_1 in let stake0 = -- GitLab From b1169ef3dd50c94f891a92981ae9009eb18a3aad Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 16 Feb 2024 17:59:29 +0100 Subject: [PATCH 02/11] tezt/tests/adaptive_issuance: update balances due to new right distrib --- tezt/tests/adaptive_issuance.ml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index c2c594f5a405..d7610be99a1c 100644 --- a/tezt/tests/adaptive_issuance.ml +++ b/tezt/tests/adaptive_issuance.ml @@ -1076,20 +1076,20 @@ let test_staking = (* check slashed and rewarded amounts *) (* total amounts *) - let total_amount_rewarded = 1450001824 in - let total_amount_slashed = 8700010946 in + let total_amount_rewarded = 1450001868 in + let total_amount_slashed = 8700011216 in (* slashed stakers (including baker) unstake deposit *) let amount_rewarded_from_unstake_stakers_deposits = 7142857 in - let amount_slashed_from_unstake_stakers_deposits = 42857144 in + let amount_slashed_from_unstake_stakers_deposits = 42857145 in (* slashed stake *) let amount_rewarded_from_stakers_deposits = 7178393 in let amount_slashed_from_stakers_deposits = 43070362 in (* slashing baker (bootstrap2) stake*) - let amount_rewarded_from_baker_deposits = 1435680574 in - let amount_slashed_from_baker_deposits = 8614083440 in + let amount_rewarded_from_baker_deposits = 1435680618 in + let amount_slashed_from_baker_deposits = 8614083709 in assert ( check_with_roundings -- GitLab From c95d4211035adc4c70a2fe360191a03cca8c19af Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Thu, 8 Feb 2024 08:48:41 +0100 Subject: [PATCH 03/11] proto/delegate_cycle: group slashing related end-of-cycle actions --- src/proto_alpha/lib_protocol/delegate_cycles.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index 4bd8974f7cc2..1f828c3f1a44 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -204,11 +204,11 @@ let cycle_end ctxt last_cycle = Delegate_slashed_deposits_storage.apply_and_clear_denunciations ctxt in let new_cycle = Cycle_repr.add last_cycle 1 in + let*! ctxt = Already_denounced_storage.clear_outdated_cycle ctxt ~new_cycle in let* ctxt = Delegate_sampler.select_new_distribution_at_cycle_end ctxt ~new_cycle in let*! ctxt = Delegate_consensus_key.activate ctxt ~new_cycle in - let*! ctxt = Already_denounced_storage.clear_outdated_cycle ctxt ~new_cycle in let* ctxt, deactivated_delegates = update_activity ctxt last_cycle in let* ctxt, autostake_balance_updates = match Staking.staking_automation ctxt with -- GitLab From 1de2de08c99d6663a95e1c2b606e2a3a8b535eb6 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Tue, 13 Feb 2024 20:31:12 +0100 Subject: [PATCH 04/11] proto/delegate_cycles: update activity before computing staking rights distribution This change make the inactive delegate loose their staking rights one cycle earlier. --- src/proto_alpha/lib_protocol/delegate_cycles.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index 1f828c3f1a44..d67daac5c47c 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -205,11 +205,11 @@ let cycle_end ctxt last_cycle = in let new_cycle = Cycle_repr.add last_cycle 1 in let*! ctxt = Already_denounced_storage.clear_outdated_cycle ctxt ~new_cycle in + let* ctxt, deactivated_delegates = update_activity ctxt last_cycle in let* ctxt = Delegate_sampler.select_new_distribution_at_cycle_end ctxt ~new_cycle in let*! ctxt = Delegate_consensus_key.activate ctxt ~new_cycle in - let* ctxt, deactivated_delegates = update_activity ctxt last_cycle in let* ctxt, autostake_balance_updates = match Staking.staking_automation ctxt with | Manual_staking -> return (ctxt, []) -- GitLab From 58a78b41665338d2307e8fcf1167e6f262b04882 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Tue, 13 Feb 2024 20:38:59 +0100 Subject: [PATCH 05/11] proto/delegate_cycles: autostaking preceed staking rights computation This ensure that the rights are computed with an optimal stake and that they respects the deposit limit. TODO: check how this interact with "for_next_cycle_unstaking" --- src/proto_alpha/lib_protocol/delegate_cycles.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index d67daac5c47c..b170134fd1ce 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -206,15 +206,15 @@ let cycle_end ctxt last_cycle = let new_cycle = Cycle_repr.add last_cycle 1 in let*! ctxt = Already_denounced_storage.clear_outdated_cycle ctxt ~new_cycle in let* ctxt, deactivated_delegates = update_activity ctxt last_cycle in - let* ctxt = - Delegate_sampler.select_new_distribution_at_cycle_end ctxt ~new_cycle - in - let*! ctxt = Delegate_consensus_key.activate ctxt ~new_cycle in let* ctxt, autostake_balance_updates = match Staking.staking_automation ctxt with | Manual_staking -> return (ctxt, []) | Auto_staking -> adjust_frozen_stakes ctxt ~deactivated_delegates in + let* ctxt = + Delegate_sampler.select_new_distribution_at_cycle_end ctxt ~new_cycle + in + let*! ctxt = Delegate_consensus_key.activate ctxt ~new_cycle in let* ctxt = Forbidden_delegates_storage.update_at_cycle_end_after_slashing ctxt -- GitLab From 967f709b7f92f5e8d2437692aef717adead017ee Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Wed, 14 Feb 2024 22:01:11 +0100 Subject: [PATCH 06/11] tests/consensus_key: reset regression --- ...legate with (baker - delegate - consensus - destination).out | 2 +- ...egate with (baker - delegate - consensus -- destination).out | 2 +- ...egate with (baker -- delegate - consensus - destination).out | 2 +- ...gate with (baker -- delegate - consensus -- destination).out | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 cb0219480fd4..5cdd1a09377a 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 @@ -104,7 +104,7 @@ This sequence of operations was run: ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "238000528932", "current_frozen_deposits": "200000181573", - "frozen_deposits": "200000083984", "staking_balance": "238000528932", + "frozen_deposits": "200000083983", "staking_balance": "238000528932", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "min_delegated_in_current_cycle": "4", "deactivated": false, "grace_period": 4, "pending_denunciations": false, 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 2f3c81352c2a..945261d8da9e 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 @@ -104,7 +104,7 @@ This sequence of operations was run: ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "238000528932", "current_frozen_deposits": "200000181573", - "frozen_deposits": "200000083984", "staking_balance": "238000528932", + "frozen_deposits": "200000083983", "staking_balance": "238000528932", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "min_delegated_in_current_cycle": "4", "deactivated": false, "grace_period": 4, "pending_denunciations": false, 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 7efa88268e39..e86e3964537f 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 @@ -104,7 +104,7 @@ This sequence of operations was run: ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "238000509096", "current_frozen_deposits": "200000164892", - "frozen_deposits": "200000067317", "staking_balance": "238000509096", + "frozen_deposits": "200000067302", "staking_balance": "238000509096", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "min_delegated_in_current_cycle": "18", "deactivated": false, "grace_period": 4, "pending_denunciations": false, 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 44c911183185..f845c4c2c4ee 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 @@ -104,7 +104,7 @@ This sequence of operations was run: ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]' { "full_balance": "238000509096", "current_frozen_deposits": "200000164892", - "frozen_deposits": "200000067317", "staking_balance": "238000509096", + "frozen_deposits": "200000067302", "staking_balance": "238000509096", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", "min_delegated_in_current_cycle": "18", "deactivated": false, "grace_period": 4, "pending_denunciations": false, -- GitLab From 3734388e754a3e31d52a50fe94ae7f989a171723 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Wed, 14 Feb 2024 22:18:37 +0100 Subject: [PATCH 07/11] proto/test: account for changes in computation rights --- .../test/integration/consensus/test_frozen_deposits.ml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml index 6dec06831d79..594b17134a07 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml @@ -483,8 +483,10 @@ let test_cannot_bake_with_zero_deposits_limit () = Op.set_deposits_limit (B genesis) contract1 (Some Tez.zero) in let* b = Block.bake ~policy:(By_account account2) ~operation genesis in + (* autostaking happens before staking right computations, + so the limit will apply in constants.consensus_rights_delay+1 *) let expected_number_of_cycles_with_rights_from_previous_deposit = - constants.consensus_rights_delay + Constants.max_slashing_period - 1 + constants.consensus_rights_delay in let* b = Block.bake_until_n_cycle_end @@ -513,8 +515,8 @@ let test_cannot_bake_with_zero_deposits_limit () = | Block.No_slots_found_for _ -> true | _ -> false) in - (* Unstaked frozen deposits are released one cycle later. *) - let* b = Block.bake_until_cycle_end b in + (* Unstaked frozen deposits are released two cycles later. *) + let* b = Block.bake_until_n_cycle_end 2 b in let* ufd = Context.Contract.unstaked_frozen_balance (B b) (Implicit account1) in -- GitLab From 256e3d64400351bef382370b981380d33149f4a4 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 16 Feb 2024 17:16:30 +0100 Subject: [PATCH 08/11] proto/delegate_cycles: document cycle end --- src/proto_alpha/lib_protocol/delegate_cycles.ml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index b170134fd1ce..298137167432 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -196,33 +196,45 @@ let adjust_frozen_stakes ctxt ~deactivated_delegates : let cycle_end ctxt last_cycle = let open Lwt_result_syntax in + (* attributing attesting rewards *) let* ctxt, unrevealed_nonces = Seed_storage.cycle_end ctxt last_cycle in let* ctxt, attesting_balance_updates = distribute_attesting_rewards ctxt last_cycle unrevealed_nonces in + (* Applying slashing related to expiring denunciations *) let* ctxt, slashing_balance_updates = Delegate_slashed_deposits_storage.apply_and_clear_denunciations ctxt in let new_cycle = Cycle_repr.add last_cycle 1 in let*! ctxt = Already_denounced_storage.clear_outdated_cycle ctxt ~new_cycle in + (* Deactivating delegates which didn't participate to consensus for too long *) let* ctxt, deactivated_delegates = update_activity ctxt last_cycle in + (* Applying autostaking. Do not move before slashing. Keep before rights + computation for optimising rights*) let* ctxt, autostake_balance_updates = match Staking.staking_automation ctxt with | Manual_staking -> return (ctxt, []) | Auto_staking -> adjust_frozen_stakes ctxt ~deactivated_delegates in + (* Computing future staking rights *) let* ctxt = Delegate_sampler.select_new_distribution_at_cycle_end ctxt ~new_cycle in + (* Activating consensus key for the cycle to come *) let*! ctxt = Delegate_consensus_key.activate ctxt ~new_cycle in + (* trying to unforbid delegates for the cycle to come. *) let* ctxt = Forbidden_delegates_storage.update_at_cycle_end_after_slashing ctxt ~new_cycle in + (* clear deprecated cycles data. *) let* ctxt = Stake_storage.clear_at_cycle_end ctxt ~new_cycle in let* ctxt = Delegate_sampler.clear_outdated_sampling_data ctxt ~new_cycle in + (* activate delegate parameters for the cycle to come. *) let*! ctxt = Delegate_staking_parameters.activate ctxt ~new_cycle in + (* updating AI coefficient. It should remain after all balance changes of the + cycle-end operations *) let* ctxt = Adaptive_issuance_storage.update_stored_rewards_at_cycle_end ctxt ~new_cycle in -- GitLab From 2c01f78357b9714c715e7a9f923a561ee2ab7f48 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Thu, 15 Feb 2024 13:24:31 +0100 Subject: [PATCH 09/11] tezt/tests/adaptive_issuance: more explicit error message --- tezt/tests/adaptive_issuance.ml | 70 ++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index d7610be99a1c..19ef8ce5cd21 100644 --- a/tezt/tests/adaptive_issuance.ml +++ b/tezt/tests/adaptive_issuance.ml @@ -416,6 +416,15 @@ type bu_check = { let check_with_roundings got expected = got >= expected - 1 && got <= expected + 1 +let assert_with_roundings ~__LOC__ got expected = + if not (check_with_roundings got expected) then + Test.fail + "@[%s: Asserted equality (up to rounding) failed. got %d, expected \ + %d.@]@." + __LOC__ + got + expected + let check_balance_updates balance_updates (predicates : bu_check list) = List.iter (fun {pred; change; msg} -> @@ -431,11 +440,13 @@ let check_balance_updates balance_updates (predicates : bu_check list) = pre_filtered) then Test.fail - "Inconsistant balance update: %s, could it be a regression, got: %s" + "@[Inconsistant balance update, could it be a regression.@. \ + Expected:@ @[%s, change amount: %d@]@.Got:@ @[%s@]@]" msg + change (List.fold_left (fun acc x -> - acc ^ "\n" ^ Operation_receipt.Balance_updates.to_string x) + acc ^ "@ " ^ Operation_receipt.Balance_updates.to_string x) "" pre_filtered)) predicates @@ -1091,35 +1102,32 @@ let test_staking = let amount_rewarded_from_baker_deposits = 1435680618 in let amount_slashed_from_baker_deposits = 8614083709 in - assert ( - check_with_roundings - amount_rewarded_from_unstake_stakers_deposits - (int_of_float (float amount_slashed_from_unstake_stakers_deposits /. 6.))) ; - - assert ( - check_with_roundings - amount_rewarded_from_stakers_deposits - (int_of_float (float amount_slashed_from_stakers_deposits /. 6.))) ; - - assert ( - check_with_roundings - amount_rewarded_from_baker_deposits - (int_of_float (float amount_slashed_from_baker_deposits /. 6.))) ; - - assert ( - check_with_roundings - (amount_rewarded_from_unstake_stakers_deposits - + amount_rewarded_from_stakers_deposits - + amount_rewarded_from_baker_deposits) - total_amount_rewarded) ; - - assert ( - check_with_roundings - (amount_slashed_from_unstake_stakers_deposits - + amount_slashed_from_stakers_deposits + amount_slashed_from_baker_deposits - ) - total_amount_slashed) ; - + assert_with_roundings + ~__LOC__ + amount_rewarded_from_unstake_stakers_deposits + (int_of_float (float amount_slashed_from_unstake_stakers_deposits /. 6.)) ; + + assert_with_roundings + ~__LOC__ + amount_rewarded_from_stakers_deposits + (int_of_float (float amount_slashed_from_stakers_deposits /. 6.)) ; + + assert_with_roundings + ~__LOC__ + amount_rewarded_from_baker_deposits + (int_of_float (float amount_slashed_from_baker_deposits /. 6.)) ; + + assert_with_roundings + ~__LOC__ + (amount_rewarded_from_unstake_stakers_deposits + + amount_rewarded_from_stakers_deposits + amount_rewarded_from_baker_deposits + ) + total_amount_rewarded ; + assert_with_roundings + ~__LOC__ + (amount_slashed_from_unstake_stakers_deposits + + amount_slashed_from_stakers_deposits + amount_slashed_from_baker_deposits) + total_amount_slashed ; let check_opr ~kind ~category ~change ~staker ~msg ~delayed_operation_hash = let open Operation_receipt.Balance_updates in { -- GitLab From f7b3bcc0fd915cca8f8e48874ca18ea86b785f0a Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Thu, 15 Feb 2024 14:41:10 +0100 Subject: [PATCH 10/11] tezt/tests/adaptive_issuance: variable margin in checks --- tezt/tests/adaptive_issuance.ml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index 19ef8ce5cd21..19d8d03cef7f 100644 --- a/tezt/tests/adaptive_issuance.ml +++ b/tezt/tests/adaptive_issuance.ml @@ -409,15 +409,15 @@ type bu_check = { msg : string; } -(* some values might be slightly different (+-1 mutez) because of roundings and +(* some values might be slightly different (+-[margin] mutez) because of roundings and randomness in baking rights that may affect the overall rewards coming from previous blocks, to avoid flakiness we test the "rounded range" of those values *) -let check_with_roundings got expected = - got >= expected - 1 && got <= expected + 1 +let check_with_roundings ?(margin = 1) got expected = + got >= expected - margin && got <= expected + margin -let assert_with_roundings ~__LOC__ got expected = - if not (check_with_roundings got expected) then +let assert_with_roundings ~__LOC__ ?margin got expected = + if not (check_with_roundings ?margin got expected) then Test.fail "@[%s: Asserted equality (up to rounding) failed. got %d, expected \ %d.@]@." @@ -1118,12 +1118,14 @@ let test_staking = (int_of_float (float amount_slashed_from_baker_deposits /. 6.)) ; assert_with_roundings + ~margin:3 (* as we sum 3 amounts *) ~__LOC__ (amount_rewarded_from_unstake_stakers_deposits + amount_rewarded_from_stakers_deposits + amount_rewarded_from_baker_deposits ) total_amount_rewarded ; assert_with_roundings + ~margin:3 (* as we sum 3 amounts *) ~__LOC__ (amount_slashed_from_unstake_stakers_deposits + amount_slashed_from_stakers_deposits + amount_slashed_from_baker_deposits) -- GitLab From 142b9728dd0fa5028e26071dd628f1526122dcd7 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 16 Feb 2024 19:04:31 +0100 Subject: [PATCH 11/11] docs/protocols/alpha: changelog entry for end-of-cycle actions reordering --- docs/protocols/alpha.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index be92fd1226ba..86121420f9eb 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -68,6 +68,9 @@ Data Availability Layer (ongoing) Adaptive Issuance (ongoing) ---------------------------- +- Active-delegates update and autostaking are now done before staking-rights computation + at cycle end. (MR :gl:`!11972`) + - The staking balance is now explicitly initialized when a delegate is registered. (MR :gl:`!11197`) - The issuance reward coeff is now computed only once. -- GitLab