diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index e2195f8c9328f5ed473f57a8c3853e129edc6954..b0f8f76914d6a47238c951f7c4627c2f0b574316 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -54,6 +54,57 @@ Protocol parameters Bug Fixes --------- +10s Blocks Time (MR :gl:`!11288`) +--------------------------------- + +Blocks time have been reduced from 15 seconds to 10 seconds. That is, a block +can be produced with a delay of 10 seconds with respect to the previous block, +if both blocks have round 0. This change comes with updating many related +protocol parameters in order to match the reduced blocks time. In particular, +the following quantities are kept the same: + +- the minimal time period of a cycle (namely, 2 days, 20 hours, and 16 minutes), +- the length of the nonce revelation period (namely, around 2 hours and 8 minutes) +- the number of nonce commitments per cycle (namely, 128), +- the number of stake snapshots per cycle (namely, 16), +- the maximum rewards per minute (namely 80 tez), and therefore roughly the same inflation, +- the minimal "time to live" of an operation (namely, 1 hour), +- the block gas limit per minute (namely 10400000 gas), +- the ratio between the liquidity baking subsidy and the maximum rewards per block (namely, 1/16). + +.. list-table:: Changes to protocol parameters + :widths: 50 25 25 + :header-rows: 1 + + * - Parameter (unit) + - Old (oxford) value + - New value + * - ``minimal_block_delay`` (seconds) + - ``15`` + - ``10`` + * - ``delay_increment_per_round`` (seconds) + - ``8`` + - ``5`` + * - ``blocks_per_cycle`` (blocks) + - ``16384`` + - ``24576`` + * - ``blocks_per_commitment`` (blocks) + - ``128`` + - ``192`` + * - ``nonce_revelation_threshold`` (blocks) + - ``512`` + - ``768`` + * - ``blocks_per_stake_snapshot`` (blocks) + - ``1024`` + - ``1536`` + * - ``max_operations_time_to_live`` (blocks) + - ``240`` + - ``360`` + * - ``hard_gas_limit_per_block`` (gas unit) + - ``2600000`` + - ``1733333`` + + Minor Changes ------------- diff --git a/manifest/main.ml b/manifest/main.ml index 736d723b75492efdc652f01f93b97511b0474c88..7786f2b517b94fd08d360d550872e73574ab8b61 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -5392,6 +5392,7 @@ end = struct octez_test_helpers |> open_; test_helpers |> if_some |> open_; octez_base_test_helpers |> open_; + parameters |> if_some |> if_ N.(number >= 019) |> open_; plugin |> if_some |> open_; ] in diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 5e51b8c3ab00e1013fa79f29b504a3de026a2012..97e6a172dcce6f9aecbc3373bc73a4eea73fd6c5 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -98,7 +98,7 @@ let default_dal = let constants_mainnet = let consensus_committee_size = 7000 in - let block_time = 15 in + let block_time = 10 in let Constants.Generated. { consensus_threshold; @@ -132,21 +132,21 @@ let constants_mainnet = consensus_rights_delay = 5; blocks_preservation_cycles = 1; delegate_parameters_activation_delay = 5; - blocks_per_cycle = 16384l; - blocks_per_commitment = 128l; - nonce_revelation_threshold = 512l; - blocks_per_stake_snapshot = 1024l; + blocks_per_cycle = 24576l; + blocks_per_commitment = 192l; + nonce_revelation_threshold = 768l; + blocks_per_stake_snapshot = 1536l; cycles_per_voting_period = 5l; hard_gas_limit_per_operation = Gas.Arith.(integral_of_int_exn 1_040_000); - hard_gas_limit_per_block = Gas.Arith.(integral_of_int_exn 2_600_000); - (* When reducing block times, consider adapting this constant so + hard_gas_limit_per_block = Gas.Arith.(integral_of_int_exn 1_733_333); + (* When reducing blocks time, consider adapting this constant so the block production's overhead is not too important. *) proof_of_work_threshold = Int64.(sub (shift_left 1L 48) 1L); minimal_stake = Tez.(mul_exn one 6_000); minimal_frozen_stake = Tez.(mul_exn one 600); (* VDF's difficulty must be a multiple of `nonce_revelation_threshold` times the block time. At the moment it is equal to 8B = 8000 * 5 * .2M with - - 8000 ~= 512 * 15 that is nonce_revelation_threshold * block time + - 8000 ~= 768 * 10 that is nonce_revelation_threshold * block time - .2M ~= number of modular squaring per second on benchmark machine with 2.8GHz CPU - 5: security factor (strictly higher than the ratio between highest CPU @@ -185,9 +185,9 @@ let constants_mainnet = The unit for this value is a block. *) - max_operations_time_to_live = 240; + max_operations_time_to_live = 360; minimal_block_delay = Period.of_seconds_exn (Int64.of_int block_time); - delay_increment_per_round = Period.of_seconds_exn 8L; + delay_increment_per_round = Period.of_seconds_exn 5L; consensus_committee_size; consensus_threshold; (* 4667 slots *) diff --git a/src/proto_alpha/lib_protocol/delegate_rewards.ml b/src/proto_alpha/lib_protocol/delegate_rewards.ml index 419300489035f30e2cb06cba78aac68ba995a8d6..0b61dae93a05691e22178f2f2c18de065ea8dfa7 100644 --- a/src/proto_alpha/lib_protocol/delegate_rewards.ml +++ b/src/proto_alpha/lib_protocol/delegate_rewards.ml @@ -93,12 +93,12 @@ module M = struct | Liquidity_baking_subsidy -> issuance_weights.liquidity_baking_subsidy_weight | Seed_nonce_revelation_tip -> - (* Seed nonce revelation rewards are given every [blocks_per_commitment](=128)th block *) + (* Seed nonce revelation rewards are given every [blocks_per_commitment](=192)th block *) let blocks_per_commitment = Int32.to_int csts.blocks_per_commitment in issuance_weights.seed_nonce_revelation_tip_weight * blocks_per_commitment | Vdf_revelation_tip -> - (* Vdf revelation rewards are given every [blocks_per_commitment](=128)th block *) + (* Vdf revelation rewards are given every [blocks_per_commitment](=192)th block *) let blocks_per_commitment = Int32.to_int csts.blocks_per_commitment in issuance_weights.vdf_revelation_tip_weight * blocks_per_commitment in diff --git a/src/proto_alpha/lib_protocol/per_block_votes_repr.ml b/src/proto_alpha/lib_protocol/per_block_votes_repr.ml index dc10200105d6d9f3fe69c05e71ea7e24bc679e19..a30dd1bc94811af630b56ad4d74758ee68dd0a14 100644 --- a/src/proto_alpha/lib_protocol/per_block_votes_repr.ml +++ b/src/proto_alpha/lib_protocol/per_block_votes_repr.ml @@ -105,11 +105,11 @@ module Adaptive_issuance_launch_EMA = Votes_EMA_repr.Make (struct baker_contrib = (1/2) * ema_max * (1 - 2^(-1/k)) - where k is the number of blocks in 2 weeks (which is 80640). + where k is the number of blocks in 2 weeks (which is 120960). Because of a small accumulation of rounding errors, two more blocks are actually needed. *) - let baker_contribution = Z.of_int 8595 + let baker_contribution = Z.of_int 5730 let ema_max = 2_000_000_000l end) diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 1400af066c7aa5ce299d34c3754d6770656c63ab..8d1ad90eadb240ef5df8a4cb9183a3edcf0409c9 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -935,6 +935,63 @@ let[@warning "-32"] get_previous_protocol_constants ctxt = context." | Some constants -> return constants) +let update_block_time_related_constants (c : Constants_parametric_repr.t) = + let divide_period p = + Period_repr.of_seconds_exn + Int64.(div (mul (Period_repr.to_seconds p) 2L) 3L) + in + let minimal_block_delay = divide_period c.minimal_block_delay in + let delay_increment_per_round = divide_period c.delay_increment_per_round in + let hard_gas_limit_per_block = + let two = Z.(succ one) in + let three = Z.(succ two) in + Gas_limit_repr.Arith.( + integral_exn + (Z.div (Z.mul (integral_to_z c.hard_gas_limit_per_block) two) three)) + in + let half_more x = Int32.(div (mul 3l x) 2l) in + let blocks_per_cycle = half_more c.blocks_per_cycle in + let blocks_per_commitment = half_more c.blocks_per_commitment in + let nonce_revelation_threshold = half_more c.nonce_revelation_threshold in + let blocks_per_stake_snapshot = half_more c.blocks_per_stake_snapshot in + let max_operations_time_to_live = 3 * c.max_operations_time_to_live / 2 in + { + c with + blocks_per_cycle; + blocks_per_commitment; + nonce_revelation_threshold; + blocks_per_stake_snapshot; + max_operations_time_to_live; + minimal_block_delay; + delay_increment_per_round; + hard_gas_limit_per_block; + } + +let update_cycle_eras ctxt level ~prev_blocks_per_cycle ~blocks_per_cycle + ~blocks_per_commitment = + let open Lwt_result_syntax in + let* cycle_eras = get_cycle_eras ctxt in + let current_era = Level_repr.current_era cycle_eras in + let current_cycle = + let level_position = + Int32.sub level (Raw_level_repr.to_int32 current_era.first_level) + in + Cycle_repr.add + current_era.first_cycle + (Int32.to_int (Int32.div level_position prev_blocks_per_cycle)) + in + let new_cycle_era = + Level_repr. + { + first_level = Raw_level_repr.of_int32_exn (Int32.succ level); + first_cycle = Cycle_repr.succ current_cycle; + blocks_per_cycle; + blocks_per_commitment; + } + in + let*? new_cycle_eras = Level_repr.add_cycle_era new_cycle_era cycle_eras in + set_cycle_eras ctxt new_cycle_eras + (* You should ensure that if the type `Constants_parametric_repr.t` is different from `Constants_parametric_previous_repr.t` or the value of these constants is modified, is changed from the previous protocol, then @@ -1173,6 +1230,28 @@ let prepare_first_block ~level ~timestamp _chain_id ctxt = direct_ticket_spending_enable; } in + let block_time_is_at_least_8s = + (* This check is used to trigger the constants changes at migration on + this protocol for network that have block time strictly greater + than 7s such as mainnet and ghostnet *) + Compare.Int64.(Period_repr.to_seconds c.minimal_block_delay >= 8L) + in + let* ctxt, constants = + if block_time_is_at_least_8s then + let new_constants : Constants_parametric_repr.t = + update_block_time_related_constants constants + in + let* ctxt = + update_cycle_eras + ctxt + level + ~prev_blocks_per_cycle:constants.blocks_per_cycle + ~blocks_per_cycle:new_constants.blocks_per_cycle + ~blocks_per_commitment:new_constants.blocks_per_commitment + in + return (ctxt, new_constants) + else return (ctxt, constants) + in let*! ctxt = add_constants ctxt constants in return ctxt in diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 0c9b54d0e464d98c5225688b43b780200a2997fb..7114052632f28777a86d61711a7356607c7a5132 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1371,7 +1371,7 @@ module Stake = struct That is, the increment is done every [blocks_per_stake_snaphot] blocks and reset at the end of cycles. So, it goes up to [blocks_per_cycle / blocks_per_stake_snaphot], which is currently - 16 (= 8192/512 -- the concrete values can be found in + 16 (= 24576/1536 -- the concrete values can be found in {!val:Default_parameters.constants_mainnet}), then comes back to 0, so that a UInt16 is big enough. diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml index a0353eae4a61b3f987a37171ba254273d5a141ab..a3e31178aecda798228bd7d92a8f05a55476a0bb 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_seed.ml @@ -212,14 +212,24 @@ let test_revelation_early_wrong_right_twice () = let cycle_for_rewards = Block.current_cycle b in let* b = Block.bake ~policy:(Block.By_account baker_pkh) ~operation b in (* test that the baker gets the tip reward plus the baking reward*) - let* reward_to_liquid = + let* tip_to_liquid = + Adaptive_issuance_helpers.portion_of_rewards_to_liquid_for_cycle + ~policy + (B b) + cycle_for_rewards + pkh + tip + in + let* baking_reward_to_liquid = Adaptive_issuance_helpers.portion_of_rewards_to_liquid_for_cycle ~policy (B b) cycle_for_rewards pkh - Test_tez.(tip +! baking_reward_fixed_portion) + baking_reward_fixed_portion in + let reward_to_liquid = Test_tez.(baking_reward_to_liquid +! tip_to_liquid) in + let* () = balance_was_credited ~loc:__LOC__ (B b) baker baker_bal reward_to_liquid in @@ -432,14 +442,23 @@ let test_early_incorrect_unverified_correct_already_vdf () = let cycle_for_rewards = Block.current_cycle b in let* b = Block.bake ~policy:(Block.By_account baker_pkh) ~operation b in (* test that the baker gets the tip reward plus the baking reward*) - let* reward_to_liquid = + let* tip_to_liquid = + Adaptive_issuance_helpers.portion_of_rewards_to_liquid_for_cycle + ~policy + (B b) + cycle_for_rewards + pkh + seed_nonce_revelation_tip + in + let* baking_reward_to_liquid = Adaptive_issuance_helpers.portion_of_rewards_to_liquid_for_cycle ~policy (B b) cycle_for_rewards pkh - Test_tez.(seed_nonce_revelation_tip +! baking_reward_fixed_portion) + baking_reward_fixed_portion in + let reward_to_liquid = Test_tez.(tip_to_liquid +! baking_reward_to_liquid) in let* () = balance_was_credited ~loc:__LOC__ (B b) baker baker_bal reward_to_liquid in @@ -519,13 +538,24 @@ let test_early_incorrect_unverified_correct_already_vdf () = (* verify the balance was credited following operation inclusion *) let cycle_for_rewards = Block.current_cycle b in let* b = Block.bake ~policy:(Block.By_account baker_pkh) ~operation b in - let* reward_to_liquid = + let* tip_to_liquid = + Adaptive_issuance_helpers.portion_of_rewards_to_liquid_for_cycle + ~policy + (B b) + cycle_for_rewards + pkh + vdf_nonce_revelation_tip + in + let* baking_reward_to_liquid = Adaptive_issuance_helpers.portion_of_rewards_to_liquid_for_cycle ~policy (B b) cycle_for_rewards pkh - Test_tez.(vdf_nonce_revelation_tip +! baking_reward_fixed_portion) + baking_reward_fixed_portion + in + let reward_to_liquid = + Test_tez.(tip_to_liquid +! baking_reward_to_liquid) in let* () = balance_was_credited ~loc:__LOC__ (B b) baker baker_bal reward_to_liquid diff --git a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml index fa7d0362f193a1cc527d6cb446494dbe37c3bf24..54ee6f5d98dd1977f03216c8d76d5092e0ab05f2 100644 --- a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml +++ b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml @@ -444,6 +444,10 @@ let make_batch_test_block_one_origination name contract gas_sampler = ("both lists and single operations", test_mixed_operations); ] +let hard_gas_limit_per_operation = 1_040_000 + +let hard_gas_limit_per_block = 1_733_333 + (** Tests the consumption of all gas in a block, should pass *) let test_consume_exactly_all_block_gas () = let open Lwt_result_syntax in @@ -451,14 +455,17 @@ let test_consume_exactly_all_block_gas () = let* block, src_list, dst = block_with_one_origination number_of_ops nil_contract in - (* assumptions: - hard gas limit per operation = 1_040_000 - hard gas limit per block = 2_600_000 - *) let lld = - List.map - (fun src -> - [(src, dst, Alpha_context.Gas.Arith.integral_of_int_exn 1040000)]) + List.mapi + (fun i src -> + [ + ( src, + dst, + Alpha_context.Gas.Arith.integral_of_int_exn + (if i = number_of_ops - 1 then + hard_gas_limit_per_block - hard_gas_limit_per_operation + else hard_gas_limit_per_operation) ); + ]) src_list in let* _, _, _ = bake_operations_with_gas block lld in @@ -468,14 +475,10 @@ let test_consume_exactly_all_block_gas () = operations, should fail *) let test_malformed_block_max_limit_reached () = let open Lwt_result_syntax in - let number_of_ops = 6 in + let number_of_ops = 2 in let* block, src_list, dst = block_with_one_origination number_of_ops nil_contract in - (* assumptions: - hard gas limit per operation = 1040000 - hard gas limit per block = 5200000 - *) let lld = List.mapi (fun i src -> @@ -483,7 +486,9 @@ let test_malformed_block_max_limit_reached () = ( src, dst, Alpha_context.Gas.Arith.integral_of_int_exn - (if i = number_of_ops - 1 then 1 else 1040000) ); + (if i = number_of_ops - 1 then + hard_gas_limit_per_block - hard_gas_limit_per_operation + 1 + else hard_gas_limit_per_operation) ); ]) src_list in @@ -500,14 +505,10 @@ let test_malformed_block_max_limit_reached () = operation list, should fail *) let test_malformed_block_max_limit_reached' () = let open Lwt_result_syntax in - let number_of_ops = 6 in + let number_of_ops = 2 in let* block, src_list, dst = block_with_one_origination number_of_ops nil_contract in - (* assumptions: - hard gas limit per operation = 1040000 - hard gas limit per block = 5200000 - *) let lld = List.mapi (fun i src -> @@ -515,7 +516,9 @@ let test_malformed_block_max_limit_reached' () = ( src, dst, Alpha_context.Gas.Arith.integral_of_int_exn - (if i = number_of_ops - 1 then 1 else 1040000) ); + (if i = number_of_ops - 1 then + hard_gas_limit_per_block - hard_gas_limit_per_operation + 1 + else hard_gas_limit_per_operation) ); ]) src_list in diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml index cbc00cf513196def660afb606028d9820b561de5..214910e074eaa24b98f2b7c32b80acdaeada0205 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml @@ -997,7 +997,7 @@ module Interpreter_tests = struct let*? amount_tez = Tez.one_mutez *? Int64.of_int 15 in let* operation1 = Op.transaction - ~gas_limit:Max + ~gas_limit:High ~fee (B block_start) src @@ -1012,7 +1012,7 @@ module Interpreter_tests = struct let*@ counter = Alpha_context.Contract.get_counter ctx pkh in let* operation2 = Op.transaction - ~gas_limit:Max + ~gas_limit:High ~counter ~fee (B block_start) diff --git a/src/proto_alpha/lib_protocol/test/integration/test_adaptive_issuance_launch.ml b/src/proto_alpha/lib_protocol/test/integration/test_adaptive_issuance_launch.ml index 080c686e4debc2f14070249fa652373c3ed131a9..cbb75e645266483ef571f6f0e0533926c2cda56f 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_adaptive_issuance_launch.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_adaptive_issuance_launch.ml @@ -469,7 +469,7 @@ let tests = `Quick (test_launch 1000000l (* This means that the threshold is set at 0.05% *) - 59l); + 88l); Tztest.tztest "the EMA reaches the vote threshold at the expected level and adaptive \ issuance launches (realistic threshold, vote enabled)" @@ -477,7 +477,7 @@ let tests = (test_launch Default_parameters.constants_test.adaptive_issuance .launch_ema_threshold - 187259l + 280894l (* This vote duration is consistent with the result of the unit test for this EMA in ../unit/test_adaptive_issuance_ema.ml*)); @@ -487,7 +487,7 @@ let tests = `Quick (test_does_not_launch_without_feature_flag 1000000l (* This means that the threshold is set at 0.05% *) - 59l); + 88l); Tztest.tztest "the EMA reaches the vote threshold at the expected level and adaptive \ issuance does not launch (realistic threshold, vote disabled)" @@ -495,7 +495,7 @@ let tests = (test_does_not_launch_without_feature_flag Default_parameters.constants_test.adaptive_issuance .launch_ema_threshold - 187259l + 280894l (* This vote duration is consistent with the result of the unit test for this EMA in ../unit/test_adaptive_issuance_ema.ml*)); diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/dune b/src/proto_alpha/lib_protocol/test/integration/validate/dune index 9811a7ed551273e80d3a2210a9a2f52189aa64c4..1542ee049ac9be481262ed3ba34cc20f0945812e 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/dune +++ b/src/proto_alpha/lib_protocol/test/integration/validate/dune @@ -14,6 +14,7 @@ octez-libs.test-helpers octez-protocol-alpha-libs.test-helpers octez-libs.base-test-helpers + tezos-protocol-alpha.parameters octez-protocol-alpha-libs.plugin) (library_flags (:standard -linkall)) (flags @@ -28,6 +29,7 @@ -open Tezos_test_helpers -open Tezos_alpha_test_helpers -open Tezos_base_test_helpers + -open Tezos_protocol_alpha_parameters -open Tezos_protocol_plugin_alpha) (modules generator_descriptors diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml index 558fbfa793b5323fef6e955d47818b9738cd20b3..d9d4f2f9bb3ac8a38daa0780207c19ee0a9cf89c 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml @@ -402,7 +402,7 @@ let manager_parameters : Parameters.t -> ctxt_req -> Parameters.t = let hard_gas_limit_per_block = match hard_gas_limit_per_block with | Some gb -> gb - | None -> Gas.Arith.(integral_of_int_exn 5_200_000) + | None -> Default_parameters.constants_mainnet.hard_gas_limit_per_block in let dal = {params.constants.dal with feature_enable = flags.dal} in let sc_rollup = diff --git a/src/proto_alpha/lib_protocol/test/unit/test_adaptive_issuance_ema.ml b/src/proto_alpha/lib_protocol/test/unit/test_adaptive_issuance_ema.ml index f1ba74b51b3a88074a3bb6281f9c44747b1c58af..b5475afab6f44a62c0caefa3df35c6646b3cb63c 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_adaptive_issuance_ema.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_adaptive_issuance_ema.ml @@ -184,7 +184,7 @@ let test_ema_decreases_off_bound () = 1_000_000l) ema_range -(* Test that 80642 On votes are needed to move from 0% to 50%. *) +(* Test that 120961 On votes are needed to move from 0% to 50%. *) let test_ema_many_on () = let open Lwt_result_syntax in let open Per_block_votes_repr in @@ -201,10 +201,10 @@ let test_ema_many_on () = ~loc:__LOC__ 1_000_000_000l (compute_new_ema_n - (Stdlib.List.init 80642 (fun _ -> Per_block_vote_on)) + (Stdlib.List.init 120961 (fun _ -> Per_block_vote_on)) initial_ema) -(* Test that 80642 Off votes are needed to move from 100% to 50%. *) +(* Test that 120961 Off votes are needed to move from 100% to 50%. *) let test_ema_many_off () = let open Lwt_result_syntax in let open Per_block_votes_repr in @@ -220,7 +220,7 @@ let test_ema_many_off () = Assert.leq_int32 ~loc:__LOC__ (compute_new_ema_n - (Stdlib.List.init 80642 (fun _ -> Per_block_vote_off)) + (Stdlib.List.init 120961 (fun _ -> Per_block_vote_off)) initial_ema) 1_000_000_000l @@ -241,7 +241,7 @@ let test_ema_many_many_on () = ~loc:__LOC__ 1_600_000_000l (compute_new_ema_n - (Stdlib.List.init 187259 (fun _ -> Per_block_vote_on)) + (Stdlib.List.init 280894 (fun _ -> Per_block_vote_on)) initial_ema) (* Test that the EMA update function is symmetric: @@ -288,15 +288,15 @@ let tests = `Quick test_ema_decreases_off_bound; Tztest.tztest - "EMA goes from 0% to 50% in 80642 On votes" + "EMA goes from 0% to 50% in 120961 On votes" `Quick test_ema_many_on; Tztest.tztest - "EMA goes from 100% to 50% in 80642 Off votes" + "EMA goes from 100% to 50% in 120961 Off votes" `Quick test_ema_many_off; Tztest.tztest - "EMA goes from 0% to 80% in 187259 On votes" + "EMA goes from 0% to 80% in 280894 On votes" `Quick test_ema_many_many_on; Tztest.tztest diff --git a/tezt/tests/baker_test.ml b/tezt/tests/baker_test.ml index cb5d66b23d40ec1d5d501c74ae13a6f3af7d7caf..096a95485ecd53fc2bd82ea55232bda2260fb37a 100644 --- a/tezt/tests/baker_test.ml +++ b/tezt/tests/baker_test.ml @@ -30,6 +30,38 @@ Subject: Run the baker while performing a lot of transfers *) +let hooks = Tezos_regression.hooks + +let baker_reward_test = + Protocol.register_regression_test + ~__FILE__ + ~title:"Baker rewards" + ~tags:["baker"; "rewards"] + ~uses:(fun protocol -> [Protocol.baker protocol]) + (fun protocol -> + let* parameter_file = + Protocol.write_parameter_file + ~base:(Either.Right (protocol, Some Constants_mainnet)) + [] + in + let* node, client = + Client.init_with_protocol + `Client + ~protocol + ~timestamp:Now + ~parameter_file + () + in + let level_2_promise = Node.wait_for_level node 2 in + let* baker = Baker.init ~protocol node client in + Log.info "Wait for new head." ; + Baker.log_events baker ; + let* _ = level_2_promise in + let* _ = + Client.RPC.call ~hooks client @@ RPC.get_chain_block_metadata () + in + unit) + let baker_test ?force_apply protocol ~keys = let* parameter_file = Protocol.write_parameter_file @@ -156,6 +188,7 @@ let baker_remote_test = let register ~protocols = baker_simple_test protocols ; + baker_reward_test protocols ; baker_stresstest protocols ; baker_stresstest_apply protocols ; baker_bls_test protocols ; diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index 3a718c8bb01f827f1537fd408a6c305b6f497d41..34c66cc1ea662f565f8a84dc423450a00a358ca0 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -2782,7 +2782,7 @@ let e2e_tests = { constants = Protocol.Constants_mainnet; attestation_lag = 2; - block_delay = 15; + block_delay = 10; number_of_dal_slots = 1; beforehand_slot_injection = 1; num_extra_nodes = 1; diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out index 748ea5751a321bfaad0d37a9faa5825422bd179d..1bdf69cf6f602c0d84306d94ee705ed5390d22f5 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out @@ -14,7 +14,7 @@ "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "blocks_per_stake_snapshot": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", - "hard_gas_limit_per_block": "2600000", + "hard_gas_limit_per_block": "1733333", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "minimal_frozen_stake": "600000000", "vdf_difficulty": "50000", "origination_size": 257, @@ -27,7 +27,7 @@ "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, - "max_operations_time_to_live": 240, "minimal_block_delay": "1", + "max_operations_time_to_live": 360, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, "consensus_threshold": 0, "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out index 8c04ab06a856e7de59726f774e01e21fadb5f75b..296dd6f32fc8dcf979256dedca0ee5cced30a9d0 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out @@ -14,7 +14,7 @@ "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "blocks_per_stake_snapshot": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", - "hard_gas_limit_per_block": "2600000", + "hard_gas_limit_per_block": "1733333", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "minimal_frozen_stake": "600000000", "vdf_difficulty": "50000", "origination_size": 257, @@ -27,7 +27,7 @@ "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, - "max_operations_time_to_live": 240, "minimal_block_delay": "1", + "max_operations_time_to_live": 360, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, "consensus_threshold": 0, "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out index 152594ea4155823ed10fb677c419a4876685737f..3c4fd283f2c3f3a7587b0742fc8cb07dc540e32e 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out @@ -14,7 +14,7 @@ "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "blocks_per_stake_snapshot": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", - "hard_gas_limit_per_block": "2600000", + "hard_gas_limit_per_block": "1733333", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "minimal_frozen_stake": "600000000", "vdf_difficulty": "50000", "origination_size": 257, @@ -27,7 +27,7 @@ "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, - "max_operations_time_to_live": 240, "minimal_block_delay": "1", + "max_operations_time_to_live": 360, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, "consensus_threshold": 0, "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out index f8368c908b0e8f6405faa400b28562b1d1ca92d9..57e26d9e7df7a253efbc475cfaf166532be812d2 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out @@ -14,7 +14,7 @@ "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "blocks_per_stake_snapshot": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", - "hard_gas_limit_per_block": "2600000", + "hard_gas_limit_per_block": "1733333", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "minimal_frozen_stake": "600000000", "vdf_difficulty": "50000", "origination_size": 257, @@ -27,7 +27,7 @@ "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, - "max_operations_time_to_live": 240, "minimal_block_delay": "1", + "max_operations_time_to_live": 360, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, "consensus_threshold": 0, "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out index f8368c908b0e8f6405faa400b28562b1d1ca92d9..57e26d9e7df7a253efbc475cfaf166532be812d2 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out @@ -14,7 +14,7 @@ "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "blocks_per_stake_snapshot": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", - "hard_gas_limit_per_block": "2600000", + "hard_gas_limit_per_block": "1733333", "proof_of_work_threshold": "4611686018427387903", "minimal_stake": "6000000000", "minimal_frozen_stake": "600000000", "vdf_difficulty": "50000", "origination_size": 257, @@ -27,7 +27,7 @@ "cost_per_byte": "250", "hard_storage_limit_per_operation": "60000", "quorum_min": 2000, "quorum_max": 7000, "min_proposal_quorum": 500, "liquidity_baking_toggle_ema_threshold": 1000000000, - "max_operations_time_to_live": 240, "minimal_block_delay": "1", + "max_operations_time_to_live": 360, "minimal_block_delay": "1", "delay_increment_per_round": "1", "consensus_committee_size": 256, "consensus_threshold": 0, "minimal_participation_ratio": { "numerator": 2, "denominator": 3 }, diff --git a/tezt/tests/expected/baker_test.ml/Alpha- Baker rewards.out b/tezt/tests/expected/baker_test.ml/Alpha- Baker rewards.out new file mode 100644 index 0000000000000000000000000000000000000000..4188051db3bea475549d9f60cdb08246a8d08093 --- /dev/null +++ b/tezt/tests/expected/baker_test.ml/Alpha- Baker rewards.out @@ -0,0 +1,126 @@ + +./octez-client rpc get /chains/main/blocks/head/metadata +{ "protocol": "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK", + "next_protocol": "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK", + "test_chain_status": { "status": "not_running" }, "max_operations_ttl": 2, + "max_operation_data_length": 32768, "max_block_header_length": 289, + "max_operation_list_length": + [ { "max_size": 4194304, "max_op": 2048 }, { "max_size": 32768 }, + { "max_size": 135168, "max_op": 132 }, { "max_size": 524288 } ], + "proposer": "[PUBLIC_KEY_HASH]", + "baker": "[PUBLIC_KEY_HASH]", + "level_info": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false }, + "voting_period_info": + { "voting_period": + { "index": 0, "kind": "proposal", "start_position": 0 }, + "position": 1, "remaining": 122878 }, "nonce_hash": null, + "deactivated": [], + "balance_updates": + [ { "kind": "minted", "category": "bootstrap", + "change": "-20000000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "minted", "category": "baking rewards", "change": "-333334", + "origin": "block" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "333334", "origin": "block" }, + { "kind": "minted", "category": "baking rewards", "change": "-2999999", + "origin": "block" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "2999999", "origin": "block" } ], + "liquidity_baking_toggle_ema": 0, "adaptive_issuance_vote_ema": 0, + "implicit_operations_results": + [ { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-1157000", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "1157000", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-100", + "origin": "migration" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "100", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "4628", "paid_storage_size_diff": "4628" }, + { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-494500", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "494500", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "1978", "paid_storage_size_diff": "1978" }, + { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-477750", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "477750", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-1000000", + "origin": "migration" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "1000000", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "1911", "paid_storage_size_diff": "1911" }, + { "kind": "transaction", + "storage": + [ { "int": "1" }, { "int": "833433" }, { "int": "100" }, + { "bytes": "01e927f00ef734dfc85919635e9afc9166c83ef9fc00" }, + { "bytes": "0115eb0104481a6d7921160bc982c5e0a561cd8a3a00" } ], + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-833333", + "origin": "subsidy" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "833333", "origin": "subsidy" } ], + "consumed_milligas": "2261927", "storage_size": "4629", + "paid_storage_size_diff": "1" } ], + "proposer_consensus_key": "[PUBLIC_KEY_HASH]", + "baker_consensus_key": "[PUBLIC_KEY_HASH]", + "consumed_milligas": "0" } diff --git a/tezt/tests/expected/baker_test.ml/Nairobi- Baker rewards.out b/tezt/tests/expected/baker_test.ml/Nairobi- Baker rewards.out new file mode 100644 index 0000000000000000000000000000000000000000..c47486ab5c036cde2fc96702903848312f5bc74a --- /dev/null +++ b/tezt/tests/expected/baker_test.ml/Nairobi- Baker rewards.out @@ -0,0 +1,121 @@ + +./octez-client rpc get /chains/main/blocks/head/metadata +{ "protocol": "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf", + "next_protocol": "PtNairobiyssHuh87hEhfVBGCVrK3WnS8Z2FT4ymB5tAa4r1nQf", + "test_chain_status": { "status": "not_running" }, "max_operations_ttl": 2, + "max_operation_data_length": 32768, "max_block_header_length": 289, + "max_operation_list_length": + [ { "max_size": 4194304, "max_op": 2048 }, { "max_size": 32768 }, + { "max_size": 135168, "max_op": 132 }, { "max_size": 524288 } ], + "proposer": "[PUBLIC_KEY_HASH]", + "baker": "[PUBLIC_KEY_HASH]", + "level_info": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false }, + "voting_period_info": + { "voting_period": + { "index": 0, "kind": "proposal", "start_position": 0 }, + "position": 1, "remaining": 81918 }, "nonce_hash": null, + "deactivated": [], + "balance_updates": + [ { "kind": "minted", "category": "bootstrap", + "change": "-20000000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "delegate": "[PUBLIC_KEY_HASH]", + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "delegate": "[PUBLIC_KEY_HASH]", + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "delegate": "[PUBLIC_KEY_HASH]", + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "delegate": "[PUBLIC_KEY_HASH]", + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "delegate": "[PUBLIC_KEY_HASH]", + "change": "400000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "minted", "category": "baking rewards", "change": "-5000000", + "origin": "block" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "5000000", "origin": "block" } ], + "liquidity_baking_toggle_ema": 0, + "implicit_operations_results": + [ { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-1157000", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "1157000", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-100", + "origin": "migration" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "100", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "4628", "paid_storage_size_diff": "4628" }, + { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-494500", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "494500", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "1978", "paid_storage_size_diff": "1978" }, + { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-477750", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "477750", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-1000000", + "origin": "migration" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "1000000", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "1911", "paid_storage_size_diff": "1911" }, + { "kind": "transaction", + "storage": + [ { "int": "1" }, { "int": "1250100" }, { "int": "100" }, + { "bytes": "01e927f00ef734dfc85919635e9afc9166c83ef9fc00" }, + { "bytes": "0115eb0104481a6d7921160bc982c5e0a561cd8a3a00" } ], + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-1250000", + "origin": "subsidy" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "1250000", "origin": "subsidy" } ], + "consumed_milligas": "2263472", "storage_size": "4630", + "paid_storage_size_diff": "2" } ], + "proposer_consensus_key": "[PUBLIC_KEY_HASH]", + "baker_consensus_key": "[PUBLIC_KEY_HASH]", + "consumed_milligas": "0" } diff --git a/tezt/tests/expected/baker_test.ml/Oxford- Baker rewards.out b/tezt/tests/expected/baker_test.ml/Oxford- Baker rewards.out new file mode 100644 index 0000000000000000000000000000000000000000..3f370137bdebccdc86727a4bbf89f22d218d17b7 --- /dev/null +++ b/tezt/tests/expected/baker_test.ml/Oxford- Baker rewards.out @@ -0,0 +1,126 @@ + +./octez-client rpc get /chains/main/blocks/head/metadata +{ "protocol": "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH", + "next_protocol": "ProxfordYmVfjWnRcgjWH36fW6PArwqykTFzotUxRs6gmTcZDuH", + "test_chain_status": { "status": "not_running" }, "max_operations_ttl": 2, + "max_operation_data_length": 32768, "max_block_header_length": 289, + "max_operation_list_length": + [ { "max_size": 4194304, "max_op": 2048 }, { "max_size": 32768 }, + { "max_size": 135168, "max_op": 132 }, { "max_size": 524288 } ], + "proposer": "[PUBLIC_KEY_HASH]", + "baker": "[PUBLIC_KEY_HASH]", + "level_info": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false }, + "voting_period_info": + { "voting_period": + { "index": 0, "kind": "proposal", "start_position": 0 }, + "position": 1, "remaining": 81918 }, "nonce_hash": null, + "deactivated": [], + "balance_updates": + [ { "kind": "minted", "category": "bootstrap", + "change": "-20000000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "400000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "3600000000000", "origin": "migration" }, + { "kind": "minted", "category": "baking rewards", "change": "-500000", + "origin": "block" }, + { "kind": "freezer", "category": "deposits", + "staker": { "baker": "[PUBLIC_KEY_HASH]" }, + "change": "500000", "origin": "block" }, + { "kind": "minted", "category": "baking rewards", "change": "-4499999", + "origin": "block" }, + { "kind": "contract", + "contract": "[PUBLIC_KEY_HASH]", + "change": "4499999", "origin": "block" } ], + "liquidity_baking_toggle_ema": 0, "adaptive_issuance_vote_ema": 0, + "implicit_operations_results": + [ { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-1157000", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "1157000", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-100", + "origin": "migration" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "100", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "4628", "paid_storage_size_diff": "4628" }, + { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-494500", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "494500", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "1978", "paid_storage_size_diff": "1978" }, + { "kind": "origination", + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-64250", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "64250", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-477750", + "origin": "migration" }, + { "kind": "burned", "category": "storage fees", + "change": "477750", "origin": "migration" }, + { "kind": "minted", "category": "subsidy", "change": "-1000000", + "origin": "migration" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "1000000", "origin": "migration" } ], + "originated_contracts": [ "[CONTRACT_HASH]" ], + "storage_size": "1911", "paid_storage_size_diff": "1911" }, + { "kind": "transaction", + "storage": + [ { "int": "1" }, { "int": "1250099" }, { "int": "100" }, + { "bytes": "01e927f00ef734dfc85919635e9afc9166c83ef9fc00" }, + { "bytes": "0115eb0104481a6d7921160bc982c5e0a561cd8a3a00" } ], + "balance_updates": + [ { "kind": "minted", "category": "subsidy", "change": "-1249999", + "origin": "subsidy" }, + { "kind": "contract", + "contract": "[CONTRACT_HASH]", + "change": "1249999", "origin": "subsidy" } ], + "consumed_milligas": "2261931", "storage_size": "4630", + "paid_storage_size_diff": "2" } ], + "proposer_consensus_key": "[PUBLIC_KEY_HASH]", + "baker_consensus_key": "[PUBLIC_KEY_HASH]", + "consumed_milligas": "0" } diff --git a/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (mainnet_lag-2_time-15_preinject-1_sl.out b/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (mainnet_lag-2_time-10_preinject-1_sl.out similarity index 100% rename from tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (mainnet_lag-2_time-15_preinject-1_sl.out rename to tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (mainnet_lag-2_time-10_preinject-1_sl.out diff --git a/tezt/tests/manager_operations.ml b/tezt/tests/manager_operations.ml index 66fa752b7a3274bf3bdf0d2bd8bd62c90a39055c..0c81c69d7bbc187e3b6f3319f6ba6103816c6f97 100644 --- a/tezt/tests/manager_operations.ml +++ b/tezt/tests/manager_operations.ml @@ -978,15 +978,27 @@ module Deserialisation = struct end module Gas_limits = struct - (** Build a batch of transfers with the same given gas limit for every one of - them. *) - let mk_batch ?(source = Constant.bootstrap2) ?(dest = Constant.bootstrap3) ~nb - ~gas_limit client = + (** Build a batch of transfers with specific gas limit for every one of + them. *) + let mk_batch ?(source = Constant.bootstrap2) ?(dest = Constant.bootstrap3) + ~operations_gas_limit client = let open Operation.Manager in let fee = 1_000_000 in let* counter = get_next_counter client ~source:Constant.bootstrap1 in - let transfers = List.map (fun _ -> transfer ~dest ()) (range 1 nb) in - make_batch ~source ~gas_limit ~fee ~counter transfers |> return + List.mapi + (fun i gas_limit -> + let counter = counter + i in + let payload = transfer ~dest () in + make ~source ~fee ~gas_limit ~counter payload) + operations_gas_limit + |> return + + let remaining_gas_after_big_operation ~(protocol : Protocol.t) + (limits : Helpers.hard_gas_limits) = + match protocol with + | Alpha -> + limits.hard_gas_limit_per_block - limits.hard_gas_limit_per_operation + | Nairobi | Oxford -> limits.hard_gas_limit_per_operation let block_below_ops_below = Protocol.register_test @@ -996,13 +1008,12 @@ module Gas_limits = struct @@ fun protocol -> let* nodes = Helpers.init ~protocol () in let* limits = Helpers.gas_limits nodes.main.client in + let gas_limit = remaining_gas_after_big_operation ~protocol limits in (* Gas limit per op is ok *) - let* batch = - mk_batch - ~nb:2 - ~gas_limit:limits.hard_gas_limit_per_operation - nodes.main.client + let operations_gas_limit = + [limits.hard_gas_limit_per_operation; gas_limit] in + let* batch = mk_batch ~operations_gas_limit nodes.main.client in let* _oph = Memchecks.with_validated_checks ~__LOC__ @@ -1020,12 +1031,11 @@ module Gas_limits = struct @@ fun protocol -> let* nodes = Helpers.init ~protocol () in let* limits = Helpers.gas_limits nodes.main.client in - let* batch = - mk_batch - ~nb:2 - ~gas_limit:(limits.hard_gas_limit_per_operation + 1) - nodes.main.client + let gas_limit = remaining_gas_after_big_operation ~protocol limits in + let operations_gas_limit = + [limits.hard_gas_limit_per_operation + 1; gas_limit - 2] in + let* batch = mk_batch ~operations_gas_limit nodes.main.client in let* _oph = Memchecks.with_refused_checks ~__LOC__ nodes @@ fun () -> (* Gas limit per op is too high *) @@ -1046,12 +1056,10 @@ module Gas_limits = struct (limits.hard_gas_limit_per_block / limits.hard_gas_limit_per_operation) + 1 in - let* batch = - mk_batch - ~nb:too_many_ops - ~gas_limit:limits.hard_gas_limit_per_operation - nodes.main.client + let operations_gas_limit = + List.init too_many_ops (fun _i -> limits.hard_gas_limit_per_operation) in + let* batch = mk_batch ~operations_gas_limit nodes.main.client in let* _oph = Memchecks.with_refused_checks ~__LOC__ nodes @@ fun () -> Operation.Manager.inject ~force:true batch nodes.main.client