From 4be689736858bae3b942897149faf8e8b3bb4eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Thu, 15 Mar 2018 15:03:23 +0100 Subject: [PATCH] Alpha: rename `cycle_length` into `blocks_per_cycle` --- .../lib_protocol/src/alpha_context.mli | 2 +- src/proto_alpha/lib_protocol/src/baking.ml | 2 +- .../lib_protocol/src/constants_repr.ml | 22 +++++++++---------- .../lib_protocol/src/constants_services.ml | 14 ++++++------ .../lib_protocol/src/constants_services.mli | 2 +- .../lib_protocol/src/constants_storage.ml | 4 ++-- .../lib_protocol/src/level_repr.ml | 6 ++--- .../lib_protocol/src/level_repr.mli | 2 +- .../lib_protocol/src/level_storage.ml | 4 ++-- .../lib_protocol/src/raw_context.ml | 2 +- src/proto_alpha/lib_protocol/src/services.ml | 6 ++--- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 12276bdad..3e9e290ba 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -265,7 +265,7 @@ module Constants : sig val faucet_credit: Tez.t val preserved_cycles: context -> int - val cycle_length: context -> int32 + val blocks_per_cycle: context -> int32 val blocks_per_commitment: context -> int32 val blocks_per_roll_snapshot: context -> int32 val voting_period_length: context -> int32 diff --git a/src/proto_alpha/lib_protocol/src/baking.ml b/src/proto_alpha/lib_protocol/src/baking.ml index 3a2cf1061..7866eaf24 100644 --- a/src/proto_alpha/lib_protocol/src/baking.ml +++ b/src/proto_alpha/lib_protocol/src/baking.ml @@ -269,7 +269,7 @@ let check_fitness_gap ctxt (block : Block_header.t) = let last_of_a_cycle ctxt l = Compare.Int32.(Int32.succ l.Level.cycle_position = - Constants.cycle_length ctxt) + Constants.blocks_per_cycle ctxt) let dawn_of_a_new_cycle ctxt = let level = Level.current ctxt in diff --git a/src/proto_alpha/lib_protocol/src/constants_repr.ml b/src/proto_alpha/lib_protocol/src/constants_repr.ml index fccbc4fdb..0d7b2b69c 100644 --- a/src/proto_alpha/lib_protocol/src/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/src/constants_repr.ml @@ -46,7 +46,7 @@ let bootstrap_wealth = type constants = { preserved_cycles: int ; - cycle_length: int32 ; + blocks_per_cycle: int32 ; blocks_per_commitment: int32 ; blocks_per_roll_snapshot: int32 ; voting_period_length: int32 ; @@ -67,7 +67,7 @@ let read_public_key s = Ed25519.Public_key.of_hex_exn (`Hex s) let default = { preserved_cycles = 5 ; - cycle_length = 4096l ; + blocks_per_cycle = 4096l ; blocks_per_commitment = 32l ; blocks_per_roll_snapshot = 256l ; voting_period_length = 32768l ; @@ -116,9 +116,9 @@ let constants_encoding = let preserved_cycles = opt Compare.Int.(=) default.preserved_cycles c.preserved_cycles - and cycle_length = + and blocks_per_cycle = opt Compare.Int32.(=) - default.cycle_length c.cycle_length + default.blocks_per_cycle c.blocks_per_cycle and blocks_per_commitment = opt Compare.Int32.(=) default.blocks_per_commitment c.blocks_per_commitment @@ -163,7 +163,7 @@ let constants_encoding = default.michelson_maximum_type_size c.michelson_maximum_type_size in ((( preserved_cycles, - cycle_length, + blocks_per_cycle, blocks_per_commitment, blocks_per_roll_snapshot, voting_period_length, @@ -179,7 +179,7 @@ let constants_encoding = token_per_rolls, michelson_maximum_type_size)), ()) ) (fun ((( preserved_cycles, - cycle_length, + blocks_per_cycle, blocks_per_commitment, blocks_per_roll_snapshot, voting_period_length, @@ -196,8 +196,8 @@ let constants_encoding = michelson_maximum_type_size)), ()) -> { preserved_cycles = unopt default.preserved_cycles preserved_cycles ; - cycle_length = - unopt default.cycle_length cycle_length ; + blocks_per_cycle = + unopt default.blocks_per_cycle blocks_per_cycle ; blocks_per_commitment = unopt default.blocks_per_commitment blocks_per_commitment ; blocks_per_roll_snapshot = @@ -233,7 +233,7 @@ let constants_encoding = (merge_objs (obj9 (opt "preserved_cycles" uint8) - (opt "cycle_length" int32) + (opt "blocks_per_cycle" int32) (opt "blocks_per_commitment" int32) (opt "blocks_per_roll_snapshot" int32) (opt "voting_period_length" int32) @@ -261,7 +261,7 @@ let read = function match Data_encoding.Json.(destruct constants_encoding json) with | exception exn -> fail (Constant_read exn) | c -> - if Compare.Int32.(c.blocks_per_roll_snapshot > c.cycle_length) then - failwith "Invalid sandbox: 'blocks_per_roll_snapshot > cycle_length'" + if Compare.Int32.(c.blocks_per_roll_snapshot > c.blocks_per_cycle) then + failwith "Invalid sandbox: 'blocks_per_roll_snapshot > blocks_per_cycle'" else return c diff --git a/src/proto_alpha/lib_protocol/src/constants_services.ml b/src/proto_alpha/lib_protocol/src/constants_services.ml index 804c34218..d41336b81 100644 --- a/src/proto_alpha/lib_protocol/src/constants_services.ml +++ b/src/proto_alpha/lib_protocol/src/constants_services.ml @@ -24,13 +24,13 @@ module S = struct ~output: (obj1 (req "preserved_cycles" int31)) RPC_path.(custom_root / "preserved_cycles") - let cycle_length = + let blocks_per_cycle = RPC_service.post_service ~description: "Cycle length" ~query: RPC_query.empty ~input: empty - ~output: (obj1 (req "cycle_length" int32)) - RPC_path.(custom_root / "cycle_length") + ~output: (obj1 (req "blocks_per_cycle" int32)) + RPC_path.(custom_root / "blocks_per_cycle") let voting_period_length = RPC_service.post_service @@ -112,8 +112,8 @@ let () = register0 S.preserved_cycles begin fun ctxt () () -> return (Constants.preserved_cycles ctxt) end ; - register0 S.cycle_length begin fun ctxt () () -> - return (Constants.cycle_length ctxt) + register0 S.blocks_per_cycle begin fun ctxt () () -> + return (Constants.blocks_per_cycle ctxt) end ; register0 S.voting_period_length begin fun ctxt () () -> return (Constants.voting_period_length ctxt) @@ -143,8 +143,8 @@ let () = return (Data_encoding.Json.(schema error_encoding)) end -let cycle_length ctxt block = - RPC_context.make_call0 S.cycle_length ctxt block () () +let blocks_per_cycle ctxt block = + RPC_context.make_call0 S.blocks_per_cycle ctxt block () () let preserved_cycles ctxt block = RPC_context.make_call0 S.preserved_cycles ctxt block () () let voting_period_length 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 7e4c6f97c..d6191b016 100644 --- a/src/proto_alpha/lib_protocol/src/constants_services.mli +++ b/src/proto_alpha/lib_protocol/src/constants_services.mli @@ -12,7 +12,7 @@ open Alpha_context val preserved_cycles: 'a #RPC_context.simple -> 'a -> int shell_tzresult Lwt.t -val cycle_length: +val blocks_per_cycle: 'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t val voting_period_length: diff --git a/src/proto_alpha/lib_protocol/src/constants_storage.ml b/src/proto_alpha/lib_protocol/src/constants_storage.ml index a8ee98a8a..8f20d1db3 100644 --- a/src/proto_alpha/lib_protocol/src/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/src/constants_storage.ml @@ -10,9 +10,9 @@ let preserved_cycles c = let constants = Raw_context.constants c in constants.preserved_cycles -let cycle_length c = +let blocks_per_cycle c = let constants = Raw_context.constants c in - constants.cycle_length + constants.blocks_per_cycle let blocks_per_commitment c = let constants = Raw_context.constants c in constants.blocks_per_commitment diff --git a/src/proto_alpha/lib_protocol/src/level_repr.ml b/src/proto_alpha/lib_protocol/src/level_repr.ml index 4a547d6eb..dacf3071e 100644 --- a/src/proto_alpha/lib_protocol/src/level_repr.ml +++ b/src/proto_alpha/lib_protocol/src/level_repr.ml @@ -72,7 +72,7 @@ let root first_level = } let from_raw - ~first_level ~cycle_length ~voting_period_length + ~first_level ~blocks_per_cycle ~voting_period_length ~blocks_per_commitment level = let raw_level = Raw_level_repr.to_int32 level in @@ -80,8 +80,8 @@ let from_raw let level_position = Compare.Int32.max 0l (Int32.sub raw_level first_level) in let cycle = - Cycle_repr.of_int32_exn (Int32.div level_position cycle_length) in - let cycle_position = Int32.rem level_position cycle_length in + Cycle_repr.of_int32_exn (Int32.div level_position blocks_per_cycle) in + let cycle_position = Int32.rem level_position blocks_per_cycle in let voting_period = Voting_period_repr.of_int32_exn (Int32.div level_position voting_period_length) in diff --git a/src/proto_alpha/lib_protocol/src/level_repr.mli b/src/proto_alpha/lib_protocol/src/level_repr.mli index 01dee8a04..48ffe64b8 100644 --- a/src/proto_alpha/lib_protocol/src/level_repr.mli +++ b/src/proto_alpha/lib_protocol/src/level_repr.mli @@ -29,7 +29,7 @@ val root: Raw_level_repr.t -> level val from_raw: first_level:Raw_level_repr.t -> - cycle_length:int32 -> + blocks_per_cycle:int32 -> voting_period_length:int32 -> blocks_per_commitment:int32 -> Raw_level_repr.t -> level diff --git a/src/proto_alpha/lib_protocol/src/level_storage.ml b/src/proto_alpha/lib_protocol/src/level_storage.ml index 3c36e262f..16b5f8bcb 100644 --- a/src/proto_alpha/lib_protocol/src/level_storage.ml +++ b/src/proto_alpha/lib_protocol/src/level_storage.ml @@ -18,7 +18,7 @@ let from_raw c ?offset l = let first_level = Raw_context.first_level c in Level_repr.from_raw ~first_level - ~cycle_length:constants.Constants_repr.cycle_length + ~blocks_per_cycle:constants.Constants_repr.blocks_per_cycle ~voting_period_length:constants.Constants_repr.voting_period_length ~blocks_per_commitment:constants.Constants_repr.blocks_per_commitment l @@ -48,7 +48,7 @@ let first_level_in_cycle ctxt c = (Int32.add (Raw_level_repr.to_int32 first_level) (Int32.mul - constants.Constants_repr.cycle_length + constants.Constants_repr.blocks_per_cycle (Cycle_repr.to_int32 c)))) let last_level_in_cycle ctxt c = diff --git a/src/proto_alpha/lib_protocol/src/raw_context.ml b/src/proto_alpha/lib_protocol/src/raw_context.ml index 1d4a47a86..c7b0ca829 100644 --- a/src/proto_alpha/lib_protocol/src/raw_context.ml +++ b/src/proto_alpha/lib_protocol/src/raw_context.ml @@ -203,7 +203,7 @@ let prepare ~level ~timestamp ~fitness ctxt = let level = Level_repr.from_raw ~first_level - ~cycle_length:constants.Constants_repr.cycle_length + ~blocks_per_cycle:constants.Constants_repr.blocks_per_cycle ~voting_period_length:constants.Constants_repr.voting_period_length ~blocks_per_commitment:constants.Constants_repr.blocks_per_commitment level in diff --git a/src/proto_alpha/lib_protocol/src/services.ml b/src/proto_alpha/lib_protocol/src/services.ml index e4fe7ced6..63a686a06 100644 --- a/src/proto_alpha/lib_protocol/src/services.ml +++ b/src/proto_alpha/lib_protocol/src/services.ml @@ -48,13 +48,13 @@ end module Constants = struct - let cycle_length custom_root = + let blocks_per_cycle custom_root = RPC_service.post_service ~description: "Cycle length" ~query: RPC_query.empty ~input: empty - ~output: (obj1 (req "cycle_length" int32)) - RPC_path.(custom_root / "constants" / "cycle_length") + ~output: (obj1 (req "blocks_per_cycle" int32)) + RPC_path.(custom_root / "constants" / "blocks_per_cycle") let voting_period_length custom_root = RPC_service.post_service