From 19cb91bcb6f3645f451a7fda3c5f6a1de60b6c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Thu, 15 Mar 2018 15:04:31 +0100 Subject: [PATCH] Alpha: rename `slot_durations` into `time_between_blocks` --- .../lib_protocol/src/alpha_context.mli | 2 +- src/proto_alpha/lib_protocol/src/baking.ml | 10 ++++---- src/proto_alpha/lib_protocol/src/baking.mli | 2 +- .../lib_protocol/src/constants_repr.ml | 24 +++++++++---------- .../lib_protocol/src/constants_services.ml | 10 ++++---- .../lib_protocol/src/constants_services.mli | 2 +- .../lib_protocol/src/constants_storage.ml | 4 ++-- src/proto_alpha/lib_protocol/src/services.ml | 2 +- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 3e9e290ba..d10411fb7 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -269,7 +269,7 @@ module Constants : sig val blocks_per_commitment: context -> int32 val blocks_per_roll_snapshot: context -> int32 val voting_period_length: context -> int32 - val slot_durations: context -> Period.t list + val time_between_blocks: context -> Period.t list val first_free_baking_slot: context -> int val max_signing_slot: context -> int val max_gas: context -> int diff --git a/src/proto_alpha/lib_protocol/src/baking.ml b/src/proto_alpha/lib_protocol/src/baking.ml index 7866eaf24..6a0669ffc 100644 --- a/src/proto_alpha/lib_protocol/src/baking.ml +++ b/src/proto_alpha/lib_protocol/src/baking.ml @@ -114,21 +114,21 @@ let () = let minimal_time c priority pred_timestamp = let priority = Int32.of_int priority in - let rec cumsum_slot_durations acc durations p = + let rec cumsum_time_between_blocks acc durations p = if Compare.Int32.(<=) p 0l then ok acc else match durations with - | [] -> cumsum_slot_durations acc [ Period.one_minute ] p + | [] -> cumsum_time_between_blocks acc [ Period.one_minute ] p | [ last ] -> Period.mult p last >>? fun period -> Timestamp.(acc +? period) | first :: durations -> Timestamp.(acc +? first) >>? fun acc -> let p = Int32.pred p in - cumsum_slot_durations acc durations p in + cumsum_time_between_blocks acc durations p in Lwt.return - (cumsum_slot_durations - pred_timestamp (Constants.slot_durations c) (Int32.succ priority)) + (cumsum_time_between_blocks + pred_timestamp (Constants.time_between_blocks c) (Int32.succ priority)) let freeze_baking_bond ctxt { Block_header.priority ; _ } delegate = if Compare.Int.(priority >= Constants.first_free_baking_slot ctxt) diff --git a/src/proto_alpha/lib_protocol/src/baking.mli b/src/proto_alpha/lib_protocol/src/baking.mli index 14990200d..251b22d5a 100644 --- a/src/proto_alpha/lib_protocol/src/baking.mli +++ b/src/proto_alpha/lib_protocol/src/baking.mli @@ -24,7 +24,7 @@ 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 - bake. Fail with [Invalid_slot_durations_constant] if the minimal + bake. Fail with [Invalid_time_between_blocks_constant] if the minimal time cannot be computed. *) val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/src/constants_repr.ml b/src/proto_alpha/lib_protocol/src/constants_repr.ml index 0d7b2b69c..c7283f242 100644 --- a/src/proto_alpha/lib_protocol/src/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/src/constants_repr.ml @@ -50,7 +50,7 @@ type constants = { blocks_per_commitment: int32 ; blocks_per_roll_snapshot: int32 ; voting_period_length: int32 ; - slot_durations: Period_repr.t list ; + time_between_blocks: Period_repr.t list ; first_free_baking_slot: int ; max_signing_slot: int ; max_gas: int ; @@ -71,7 +71,7 @@ let default = { blocks_per_commitment = 32l ; blocks_per_roll_snapshot = 256l ; voting_period_length = 32768l ; - slot_durations = + time_between_blocks = List.map Period_repr.of_seconds_exn [ 60L ] ; first_free_baking_slot = 16 ; max_signing_slot = 32 ; @@ -111,7 +111,7 @@ let constants_encoding = (* let open Data_encoding in *) Data_encoding.conv (fun c -> - let module Compare_slot_durations = Compare.List (Period_repr) in + let module Compare_time_between_blocks = Compare.List (Period_repr) in let module Compare_keys = Compare.List (Ed25519.Public_key) in let preserved_cycles = opt Compare.Int.(=) @@ -128,9 +128,9 @@ let constants_encoding = and voting_period_length = opt Compare.Int32.(=) default.voting_period_length c.voting_period_length - and slot_durations = - opt Compare_slot_durations.(=) - default.slot_durations c.slot_durations + 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 @@ -167,7 +167,7 @@ let constants_encoding = blocks_per_commitment, blocks_per_roll_snapshot, voting_period_length, - slot_durations, + time_between_blocks, first_free_baking_slot, max_signing_slot, max_gas), @@ -183,7 +183,7 @@ let constants_encoding = blocks_per_commitment, blocks_per_roll_snapshot, voting_period_length, - slot_durations, + time_between_blocks, first_free_baking_slot, max_signing_slot, max_gas), @@ -204,9 +204,9 @@ let constants_encoding = unopt default.blocks_per_roll_snapshot blocks_per_roll_snapshot ; voting_period_length = unopt default.voting_period_length voting_period_length ; - slot_durations = - unopt default.slot_durations @@ - slot_durations ; + 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 ; max_signing_slot = @@ -237,7 +237,7 @@ let constants_encoding = (opt "blocks_per_commitment" int32) (opt "blocks_per_roll_snapshot" int32) (opt "voting_period_length" int32) - (opt "slot_durations" (list Period_repr.encoding)) + (opt "time_between_blocks" (list Period_repr.encoding)) (opt "first_free_baking_slot" uint16) (opt "max_signing_slot" uint16) (opt "instructions_per_transaction" int31)) diff --git a/src/proto_alpha/lib_protocol/src/constants_services.ml b/src/proto_alpha/lib_protocol/src/constants_services.ml index d41336b81..d41af9994 100644 --- a/src/proto_alpha/lib_protocol/src/constants_services.ml +++ b/src/proto_alpha/lib_protocol/src/constants_services.ml @@ -56,7 +56,7 @@ module S = struct ~output: (obj1 (req "blocks_per_roll_snapshot" int32)) RPC_path.(custom_root / "blocks_per_roll_snapshot") - let slot_durations = + let time_between_blocks = RPC_service.post_service ~description: "Slot durations" ~query: RPC_query.empty @@ -124,8 +124,8 @@ let () = register0 S.blocks_per_roll_snapshot begin fun ctxt () () -> return (Constants.blocks_per_roll_snapshot ctxt) end ; - register0 S.slot_durations begin fun ctxt () () -> - return (Constants.slot_durations ctxt) + register0 S.time_between_blocks begin fun ctxt () () -> + return (Constants.time_between_blocks ctxt) end ; register0 S.first_free_baking_slot begin fun ctxt () () -> return (Constants.first_free_baking_slot ctxt) @@ -153,8 +153,8 @@ let blocks_per_commitment ctxt block = RPC_context.make_call0 S.blocks_per_commitment ctxt block () () let blocks_per_roll_snapshot ctxt block = RPC_context.make_call0 S.blocks_per_roll_snapshot ctxt block () () -let slot_durations ctxt block = - RPC_context.make_call0 S.slot_durations ctxt block () () +let time_between_blocks ctxt block = + RPC_context.make_call0 S.time_between_blocks ctxt block () () let first_free_baking_slot ctxt block = RPC_context.make_call0 S.first_free_baking_slot ctxt block () () let max_signing_slot ctxt block = diff --git a/src/proto_alpha/lib_protocol/src/constants_services.mli b/src/proto_alpha/lib_protocol/src/constants_services.mli index d6191b016..6133d4191 100644 --- a/src/proto_alpha/lib_protocol/src/constants_services.mli +++ b/src/proto_alpha/lib_protocol/src/constants_services.mli @@ -24,7 +24,7 @@ val blocks_per_commitment: val blocks_per_roll_snapshot: 'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t -val slot_durations: +val time_between_blocks: 'a #RPC_context.simple -> 'a -> Period.t list shell_tzresult Lwt.t val first_free_baking_slot: diff --git a/src/proto_alpha/lib_protocol/src/constants_storage.ml b/src/proto_alpha/lib_protocol/src/constants_storage.ml index 8f20d1db3..f95d87511 100644 --- a/src/proto_alpha/lib_protocol/src/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/src/constants_storage.ml @@ -22,9 +22,9 @@ let blocks_per_roll_snapshot c = let voting_period_length c = let constants = Raw_context.constants c in constants.voting_period_length -let slot_durations c = +let time_between_blocks c = let constants = Raw_context.constants c in - constants.slot_durations + constants.time_between_blocks let first_free_baking_slot c = let constants = Raw_context.constants c in constants.first_free_baking_slot diff --git a/src/proto_alpha/lib_protocol/src/services.ml b/src/proto_alpha/lib_protocol/src/services.ml index 63a686a06..d28d10b00 100644 --- a/src/proto_alpha/lib_protocol/src/services.ml +++ b/src/proto_alpha/lib_protocol/src/services.ml @@ -72,7 +72,7 @@ module Constants = struct ~output: (obj1 (req "time_before_reward" Period.encoding)) RPC_path.(custom_root / "constants" / "time_before_reward") - let slot_durations custom_root = + let time_between_blocks custom_root = RPC_service.post_service ~description: "Slot durations" ~query: RPC_query.empty