diff --git a/scripts/protocol_parameters.json b/scripts/protocol_parameters.json index 96cfca723..e561eb46e 100644 --- a/scripts/protocol_parameters.json +++ b/scripts/protocol_parameters.json @@ -11,6 +11,5 @@ "blocks_per_roll_snapshot" : 4, "blocks_per_cycle" : 8, "preserved_cycles" : 2, - "first_free_baking_slot" : 4, "proof_of_work_threshold": "-1" } diff --git a/src/bin_client/test/protocol_parameters.json b/src/bin_client/test/protocol_parameters.json index 600f6ae5c..bf2b26fcb 100644 --- a/src/bin_client/test/protocol_parameters.json +++ b/src/bin_client/test/protocol_parameters.json @@ -24,6 +24,5 @@ "blocks_per_cycle" : 128, "blocks_per_roll_snapshot" : 32, "preserved_cycles" : 1, - "first_free_baking_slot" : 4, "proof_of_work_threshold": "-1" } diff --git a/src/bin_client/tezos-init-sandboxed-client.sh b/src/bin_client/tezos-init-sandboxed-client.sh index 1aed24352..11a35852f 100755 --- a/src/bin_client/tezos-init-sandboxed-client.sh +++ b/src/bin_client/tezos-init-sandboxed-client.sh @@ -40,8 +40,7 @@ init_sandboxed_client() { "time_between_blocks" : [ "1", "0" ], "blocks_per_roll_snapshot" : 4, "blocks_per_cycle" : 8, - "preserved_cycles" : 2, - "first_free_baking_slot" : 4 + "preserved_cycles" : 2 } EOF fi diff --git a/src/proto_alpha/lib_baking/client_baking_commands.ml b/src/proto_alpha/lib_baking/client_baking_commands.ml index 020bf102f..309d77d27 100644 --- a/src/proto_alpha/lib_baking/client_baking_commands.ml +++ b/src/proto_alpha/lib_baking/client_baking_commands.ml @@ -37,15 +37,14 @@ let commands () = @@ stop) (fun () delegate cctxt -> endorse_block cctxt delegate) ; command ~group ~desc: "Forge and inject block using the delegate rights." - (args4 max_priority_arg force_switch - free_baking_switch minimal_timestamp_switch) + (args3 max_priority_arg force_switch minimal_timestamp_switch) (prefixes [ "bake"; "for" ] @@ Client_keys.Public_key_hash.source_param ~name:"baker" ~desc: "name of the delegate owning the baking right" @@ stop) - (fun (max_priority, force, free_baking, minimal_timestamp) delegate cctxt -> + (fun (max_priority, force, minimal_timestamp) delegate cctxt -> bake_block cctxt cctxt#block - ~force ?max_priority ~minimal_timestamp ~free_baking delegate) ; + ~force ?max_priority ~minimal_timestamp delegate) ; command ~group ~desc: "Forge and inject a seed-nonce revelation operation." no_options (prefixes [ "reveal"; "nonce"; "for" ] diff --git a/src/proto_alpha/lib_baking/client_baking_forge.ml b/src/proto_alpha/lib_baking/client_baking_forge.ml index c99d7807c..bb1f08b5c 100644 --- a/src/proto_alpha/lib_baking/client_baking_forge.ml +++ b/src/proto_alpha/lib_baking/client_baking_forge.ml @@ -162,7 +162,7 @@ let forge_block cctxt ?(chain = `Main) block (List.nth_opt rights priority) in return (priority, time) end - | `Auto (src_pkh, max_priority, free_baking) -> + | `Auto (src_pkh, max_priority) -> Alpha_services.Helpers.current_level cctxt ~offset:1l (chain, block)>>=? fun { level } -> Alpha_services.Delegate.Baking_rights.get cctxt @@ -171,21 +171,11 @@ let forge_block cctxt ?(chain = `Main) block ~delegates:[src_pkh] (chain, block) >>=? fun possibilities -> try - begin - if free_baking then - Alpha_services.Constants.all cctxt - (chain, block) >>=? fun { parametric = { - first_free_baking_slot ; - } } -> - return first_free_baking_slot - else - return 0 - end >>=? fun min_prio -> let { Alpha_services.Delegate.Baking_rights.priority = prio ; timestamp = time } = List.find (fun (p : Alpha_services.Delegate.Baking_rights.t) -> - p.level = level && p.priority >= min_prio) + p.level = level) possibilities in return (prio, time) with Not_found -> diff --git a/src/proto_alpha/lib_baking/client_baking_forge.mli b/src/proto_alpha/lib_baking/client_baking_forge.mli index fda19fde4..f2b55eff4 100644 --- a/src/proto_alpha/lib_baking/client_baking_forge.mli +++ b/src/proto_alpha/lib_baking/client_baking_forge.mli @@ -44,7 +44,7 @@ val forge_block: ?best_effort:bool -> ?sort:bool -> ?timestamp:Time.t -> - priority:[`Set of int | `Auto of (public_key_hash * int option * bool)] -> + priority:[`Set of int | `Auto of (public_key_hash * int option)] -> ?seed_nonce_hash:Nonce_hash.t -> src_sk:Client_keys.sk_uri -> unit -> diff --git a/src/proto_alpha/lib_baking/client_baking_lib.ml b/src/proto_alpha/lib_baking/client_baking_lib.ml index 0f0dbd21f..8803bc265 100644 --- a/src/proto_alpha/lib_baking/client_baking_lib.ml +++ b/src/proto_alpha/lib_baking/client_baking_lib.ml @@ -12,7 +12,7 @@ open Alpha_context let bake_block (cctxt : #Proto_alpha.full) ?(chain = `Main) block - ?force ?max_priority ?(free_baking=false) ?(minimal_timestamp=false) + ?force ?max_priority ?(minimal_timestamp=false) ?src_sk delegate = begin match src_sk with @@ -34,7 +34,7 @@ let bake_block (cctxt : #Proto_alpha.full) ?timestamp:(if minimal_timestamp then None else Some (Time.now ())) ?force ?seed_nonce_hash ~src_sk block - ~priority:(`Auto (delegate, max_priority, free_baking)) () >>=? fun block_hash -> + ~priority:(`Auto (delegate, max_priority)) () >>=? fun block_hash -> begin match seed_nonce with | None -> return () diff --git a/src/proto_alpha/lib_baking/client_baking_lib.mli b/src/proto_alpha/lib_baking/client_baking_lib.mli index 373867783..7a6278b23 100644 --- a/src/proto_alpha/lib_baking/client_baking_lib.mli +++ b/src/proto_alpha/lib_baking/client_baking_lib.mli @@ -17,7 +17,6 @@ val bake_block: Block_services.block -> ?force:bool -> ?max_priority: int -> - ?free_baking: bool -> ?minimal_timestamp: bool -> ?src_sk:Client_keys.sk_uri -> public_key_hash -> diff --git a/src/proto_alpha/lib_baking/test/proto_alpha_helpers.ml b/src/proto_alpha/lib_baking/test/proto_alpha_helpers.ml index 7d65e28fa..36e596679 100644 --- a/src/proto_alpha/lib_baking/test/proto_alpha_helpers.ml +++ b/src/proto_alpha/lib_baking/test/proto_alpha_helpers.ml @@ -80,7 +80,6 @@ let protocol_parameters = "blocks_per_cycle" : 4, "blocks_per_roll_snapshot" : 2, "preserved_cycles" : 1, - "first_free_baking_slot" : 4, "proof_of_work_threshold": "-1" } |json} in @@ -103,7 +102,6 @@ let vote_protocol_parameters = "blocks_per_cycle" : 4, "blocks_per_roll_snapshot" : 2, "preserved_cycles" : 1, - "first_free_baking_slot" : 4, "blocks_per_voting_period": 2, "proof_of_work_threshold": "-1" } @@ -536,7 +534,7 @@ module Baking = struct ~force:true ~best_effort:false ~sort:false - ~priority:(`Auto (contract.pkh, Some 1024, false)) + ~priority:(`Auto (contract.pkh, Some 1024)) ?seed_nonce_hash ~src_sk () diff --git a/src/proto_alpha/lib_client/client_proto_args.ml b/src/proto_alpha/lib_client/client_proto_args.ml index 321012908..1f5333d14 100644 --- a/src/proto_alpha/lib_client/client_proto_args.ml +++ b/src/proto_alpha/lib_client/client_proto_args.ml @@ -186,13 +186,6 @@ let max_priority_arg = try return (int_of_string s) with _ -> fail (Bad_max_priority s))) -let free_baking_switch = - switch - ~long:"free-baking" - ?short:None - ~doc:"only consider free baking slots" - () - let endorsement_delay_arg = default_arg ~long:"endorsement-delay" diff --git a/src/proto_alpha/lib_client/client_proto_args.mli b/src/proto_alpha/lib_client/client_proto_args.mli index 9049b1a73..610c9325f 100644 --- a/src/proto_alpha/lib_client/client_proto_args.mli +++ b/src/proto_alpha/lib_client/client_proto_args.mli @@ -23,7 +23,6 @@ val delegate_arg: (Signature.Public_key_hash.t option, Proto_alpha.full) Clic.ar val delegatable_switch: (bool, Proto_alpha.full) Clic.arg val spendable_switch: (bool, Proto_alpha.full) Clic.arg val max_priority_arg: (int option, Proto_alpha.full) Clic.arg -val free_baking_switch: (bool, Proto_alpha.full) Clic.arg val force_switch: (bool, Proto_alpha.full) Clic.arg val minimal_timestamp_switch: (bool, Proto_alpha.full) Clic.arg val endorsement_delay_arg: (int, Proto_alpha.full) Clic.arg diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 7a1275b28..3a7f4fdfa 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -316,7 +316,6 @@ module Constants : sig blocks_per_roll_snapshot: int32 ; blocks_per_voting_period: int32 ; time_between_blocks: Period.t list ; - first_free_baking_slot: int ; endorsers_per_block: int ; hard_gas_limit_per_operation: Z.t ; hard_gas_limit_per_block: Z.t ; @@ -343,7 +342,6 @@ module Constants : sig val blocks_per_roll_snapshot: context -> int32 val blocks_per_voting_period: context -> int32 val time_between_blocks: context -> Period.t list - val first_free_baking_slot: context -> int val endorsers_per_block: context -> int val hard_gas_limit_per_operation: context -> Z.t val hard_gas_limit_per_block: context -> Z.t diff --git a/src/proto_alpha/lib_protocol/src/apply.ml b/src/proto_alpha/lib_protocol/src/apply.ml index 71a2ac6fa..8c8c85914 100644 --- a/src/proto_alpha/lib_protocol/src/apply.ml +++ b/src/proto_alpha/lib_protocol/src/apply.ml @@ -799,7 +799,7 @@ let begin_full_construction ctxt pred_timestamp protocol_data = Baking.check_baking_rights ctxt protocol_data pred_timestamp >>=? fun delegate_pk -> let delegate_pkh = Signature.Public_key.hash delegate_pk in - Baking.freeze_baking_deposit ctxt protocol_data delegate_pkh >>=? fun (ctxt, deposit) -> + Baking.freeze_baking_deposit ctxt delegate_pkh >>=? fun (ctxt, deposit) -> let ctxt = Fitness.increase ctxt in return (ctxt, protocol_data, delegate_pk, deposit) @@ -823,8 +823,7 @@ let begin_application ctxt block_header pred_timestamp = (Invalid_commitment { expected = current_level.expected_commitment }) >>=? fun () -> let delegate_pkh = Signature.Public_key.hash delegate_pk in - Baking.freeze_baking_deposit ctxt - block_header.protocol_data.contents delegate_pkh >>=? fun (ctxt, deposit) -> + Baking.freeze_baking_deposit ctxt delegate_pkh >>=? fun (ctxt, deposit) -> let ctxt = Fitness.increase ctxt in return (ctxt, delegate_pk, deposit) diff --git a/src/proto_alpha/lib_protocol/src/baking.ml b/src/proto_alpha/lib_protocol/src/baking.ml index 5de61ea40..9e79086d8 100644 --- a/src/proto_alpha/lib_protocol/src/baking.ml +++ b/src/proto_alpha/lib_protocol/src/baking.ml @@ -163,14 +163,11 @@ let earlier_predecessor_timestamp ctxt level = Lwt.return Timestamp.(current_timestamp +? delay) >>=? fun result -> return result -let freeze_baking_deposit ctxt { Block_header.priority ; _ } delegate = - if Compare.Int.(priority >= Constants.first_free_baking_slot ctxt) - then return (ctxt, Tez.zero) - else - let deposit = Constants.block_security_deposit ctxt in - Delegate.freeze_deposit ctxt delegate deposit - |> trace Cannot_freeze_baking_deposit >>=? fun ctxt -> - return (ctxt, deposit) +let freeze_baking_deposit ctxt delegate = + let deposit = Constants.block_security_deposit ctxt in + Delegate.freeze_deposit ctxt delegate deposit + |> trace Cannot_freeze_baking_deposit >>=? fun ctxt -> + return (ctxt, deposit) let freeze_endorsement_deposit ctxt delegate n = let deposit = Constants.endorsement_security_deposit ctxt in @@ -204,9 +201,6 @@ let check_endorsements_rights c level slots = (Inconsistent_endorsement (List.map Signature.Public_key.hash all_delegates)) >>=? fun () -> return delegate -let paying_priorities c = - 0 --> (Constants.first_free_baking_slot c - 1) - type error += Incorrect_priority let endorsement_reward ctxt ~block_priority:prio n = @@ -248,7 +242,7 @@ let select_delegate delegate delegate_list max_priority = let first_baking_priorities ctxt - ?(max_priority = Constants.first_free_baking_slot ctxt) + ?(max_priority = 32) delegate level = baking_priorities ctxt level >>=? fun delegate_list -> select_delegate delegate delegate_list max_priority diff --git a/src/proto_alpha/lib_protocol/src/baking.mli b/src/proto_alpha/lib_protocol/src/baking.mli index 714b72365..370e1d83b 100644 --- a/src/proto_alpha/lib_protocol/src/baking.mli +++ b/src/proto_alpha/lib_protocol/src/baking.mli @@ -19,8 +19,6 @@ type error += Cannot_freeze_baking_deposit (* `Permanent *) type error += Cannot_freeze_endorsement_deposit (* `Permanent *) type error += Invalid_block_signature of Block_hash.t * Signature.Public_key_hash.t (* `Permanent *) -val paying_priorities: context -> int list - (** [minimal_time ctxt priority pred_block_time] returns the minimal time, given the predecessor block timestamp [pred_block_time], after which a baker with priority [priority] is allowed to @@ -39,7 +37,6 @@ val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t funds to claim baking rights. *) val freeze_baking_deposit: context -> - Block_header.contents -> public_key_hash -> (context * Tez.t) tzresult Lwt.t @@ -55,7 +52,6 @@ val freeze_endorsement_deposit: (** [check_baking_rights ctxt block pred_timestamp] verifies that: * the contract that owned the roll at cycle start has the block signer as delegate. * the timestamp is coherent with the announced slot. - * the deposit have been payed if the slot is below [Constants.first_free_baking_slot]. *) val check_baking_rights: context -> Block_header.contents -> Time.t -> diff --git a/src/proto_alpha/lib_protocol/src/constants_repr.ml b/src/proto_alpha/lib_protocol/src/constants_repr.ml index 8a94563e4..be1575fe4 100644 --- a/src/proto_alpha/lib_protocol/src/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/src/constants_repr.ml @@ -50,7 +50,6 @@ type parametric = { blocks_per_roll_snapshot: int32 ; blocks_per_voting_period: int32 ; time_between_blocks: Period_repr.t list ; - first_free_baking_slot: int ; endorsers_per_block: int ; hard_gas_limit_per_operation: Z.t ; hard_gas_limit_per_block: Z.t ; @@ -78,7 +77,6 @@ let default = { blocks_per_voting_period = 32768l ; time_between_blocks = List.map Period_repr.of_seconds_exn [ 60L ] ; - first_free_baking_slot = 16 ; endorsers_per_block = 32 ; hard_gas_limit_per_operation = Z.of_int 400_000 ; hard_gas_limit_per_block = Z.of_int 4_000_000 ; @@ -119,7 +117,6 @@ let parametric_encoding = c.blocks_per_roll_snapshot, c.blocks_per_voting_period, c.time_between_blocks, - c.first_free_baking_slot, c.endorsers_per_block, c.hard_gas_limit_per_operation, c.hard_gas_limit_per_block), @@ -143,7 +140,6 @@ let parametric_encoding = blocks_per_roll_snapshot, blocks_per_voting_period, time_between_blocks, - first_free_baking_slot, endorsers_per_block, hard_gas_limit_per_operation, hard_gas_limit_per_block), @@ -167,7 +163,6 @@ let parametric_encoding = blocks_per_roll_snapshot ; blocks_per_voting_period ; time_between_blocks ; - first_free_baking_slot ; endorsers_per_block ; hard_gas_limit_per_operation ; hard_gas_limit_per_block ; @@ -187,14 +182,13 @@ let parametric_encoding = hard_storage_limit_per_block ; } ) (merge_objs - (obj10 + (obj9 (req "preserved_cycles" uint8) (req "blocks_per_cycle" int32) (req "blocks_per_commitment" int32) (req "blocks_per_roll_snapshot" int32) (req "blocks_per_voting_period" int32) (req "time_between_blocks" (list Period_repr.encoding)) - (req "first_free_baking_slot" uint16) (req "endorsers_per_block" uint16) (req "hard_gas_limit_per_operation" z) (req "hard_gas_limit_per_block" z)) diff --git a/src/proto_alpha/lib_protocol/src/constants_storage.ml b/src/proto_alpha/lib_protocol/src/constants_storage.ml index f6bdb7004..72c529cf7 100644 --- a/src/proto_alpha/lib_protocol/src/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/src/constants_storage.ml @@ -25,9 +25,6 @@ let blocks_per_voting_period c = let time_between_blocks c = let constants = Raw_context.constants c in constants.time_between_blocks -let first_free_baking_slot c = - let constants = Raw_context.constants c in - constants.first_free_baking_slot let endorsers_per_block c = let constants = Raw_context.constants c in constants.endorsers_per_block diff --git a/src/proto_alpha/lib_protocol/src/parameters_repr.ml b/src/proto_alpha/lib_protocol/src/parameters_repr.ml index 5f80cf40c..19d8bdbeb 100644 --- a/src/proto_alpha/lib_protocol/src/parameters_repr.ml +++ b/src/proto_alpha/lib_protocol/src/parameters_repr.ml @@ -57,9 +57,6 @@ let constants_encoding = and time_between_blocks = opt Compare_time_between_blocks.(=) default.time_between_blocks c.time_between_blocks - and first_free_baking_slot = - opt Compare.Int.(=) - default.first_free_baking_slot c.first_free_baking_slot and endorsers_per_block = opt Compare.Int.(=) default.endorsers_per_block c.endorsers_per_block @@ -118,7 +115,6 @@ let constants_encoding = blocks_per_roll_snapshot, blocks_per_voting_period, time_between_blocks, - first_free_baking_slot, endorsers_per_block, hard_gas_limit_per_operation, hard_gas_limit_per_block), @@ -142,7 +138,6 @@ let constants_encoding = blocks_per_roll_snapshot, blocks_per_voting_period, time_between_blocks, - first_free_baking_slot, endorsers_per_block, hard_gas_limit_per_operation, hard_gas_limit_per_block), @@ -175,8 +170,6 @@ let constants_encoding = time_between_blocks = unopt default.time_between_blocks @@ time_between_blocks ; - first_free_baking_slot = - unopt default.first_free_baking_slot first_free_baking_slot ; endorsers_per_block = unopt default.endorsers_per_block endorsers_per_block ; hard_gas_limit_per_operation = @@ -213,14 +206,13 @@ let constants_encoding = unopt default.hard_storage_limit_per_block hard_storage_limit_per_block ; } ) (merge_objs - (obj10 + (obj9 (opt "preserved_cycles" uint8) (opt "blocks_per_cycle" int32) (opt "blocks_per_commitment" int32) (opt "blocks_per_roll_snapshot" int32) (opt "blocks_per_voting_period" int32) (opt "time_between_blocks" (list Period_repr.encoding)) - (opt "first_free_baking_slot" uint16) (opt "endorsers_per_block" uint16) (opt "hard_gas_limit_per_operation" z) (opt "hard_gas_limit_per_block" z))