Alpha: rename slot_durations into time_between_blocks

This commit is contained in:
Grégoire Henry 2018-03-15 15:04:31 +01:00 committed by Benjamin Canou
parent 4be6897368
commit 19cb91bcb6
8 changed files with 28 additions and 28 deletions

View File

@ -269,7 +269,7 @@ module Constants : sig
val blocks_per_commitment: context -> int32 val blocks_per_commitment: context -> int32
val blocks_per_roll_snapshot: context -> int32 val blocks_per_roll_snapshot: context -> int32
val voting_period_length: 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 first_free_baking_slot: context -> int
val max_signing_slot: context -> int val max_signing_slot: context -> int
val max_gas: context -> int val max_gas: context -> int

View File

@ -114,21 +114,21 @@ let () =
let minimal_time c priority pred_timestamp = let minimal_time c priority pred_timestamp =
let priority = Int32.of_int priority in 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 if Compare.Int32.(<=) p 0l then
ok acc ok acc
else match durations with else match durations with
| [] -> cumsum_slot_durations acc [ Period.one_minute ] p | [] -> cumsum_time_between_blocks acc [ Period.one_minute ] p
| [ last ] -> | [ last ] ->
Period.mult p last >>? fun period -> Period.mult p last >>? fun period ->
Timestamp.(acc +? period) Timestamp.(acc +? period)
| first :: durations -> | first :: durations ->
Timestamp.(acc +? first) >>? fun acc -> Timestamp.(acc +? first) >>? fun acc ->
let p = Int32.pred p in let p = Int32.pred p in
cumsum_slot_durations acc durations p in cumsum_time_between_blocks acc durations p in
Lwt.return Lwt.return
(cumsum_slot_durations (cumsum_time_between_blocks
pred_timestamp (Constants.slot_durations c) (Int32.succ priority)) pred_timestamp (Constants.time_between_blocks c) (Int32.succ priority))
let freeze_baking_bond ctxt { Block_header.priority ; _ } delegate = let freeze_baking_bond ctxt { Block_header.priority ; _ } delegate =
if Compare.Int.(priority >= Constants.first_free_baking_slot ctxt) if Compare.Int.(priority >= Constants.first_free_baking_slot ctxt)

View File

@ -24,7 +24,7 @@ val paying_priorities: context -> int list
(** [minimal_time ctxt priority pred_block_time] returns the minimal (** [minimal_time ctxt priority pred_block_time] returns the minimal
time, given the predecessor block timestamp [pred_block_time], time, given the predecessor block timestamp [pred_block_time],
after which a baker with priority [priority] is allowed to 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. *) time cannot be computed. *)
val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t

View File

@ -50,7 +50,7 @@ type constants = {
blocks_per_commitment: int32 ; blocks_per_commitment: int32 ;
blocks_per_roll_snapshot: int32 ; blocks_per_roll_snapshot: int32 ;
voting_period_length: int32 ; voting_period_length: int32 ;
slot_durations: Period_repr.t list ; time_between_blocks: Period_repr.t list ;
first_free_baking_slot: int ; first_free_baking_slot: int ;
max_signing_slot: int ; max_signing_slot: int ;
max_gas: int ; max_gas: int ;
@ -71,7 +71,7 @@ let default = {
blocks_per_commitment = 32l ; blocks_per_commitment = 32l ;
blocks_per_roll_snapshot = 256l ; blocks_per_roll_snapshot = 256l ;
voting_period_length = 32768l ; voting_period_length = 32768l ;
slot_durations = time_between_blocks =
List.map Period_repr.of_seconds_exn [ 60L ] ; List.map Period_repr.of_seconds_exn [ 60L ] ;
first_free_baking_slot = 16 ; first_free_baking_slot = 16 ;
max_signing_slot = 32 ; max_signing_slot = 32 ;
@ -111,7 +111,7 @@ let constants_encoding =
(* let open Data_encoding in *) (* let open Data_encoding in *)
Data_encoding.conv Data_encoding.conv
(fun c -> (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 module Compare_keys = Compare.List (Ed25519.Public_key) in
let preserved_cycles = let preserved_cycles =
opt Compare.Int.(=) opt Compare.Int.(=)
@ -128,9 +128,9 @@ let constants_encoding =
and voting_period_length = and voting_period_length =
opt Compare.Int32.(=) opt Compare.Int32.(=)
default.voting_period_length c.voting_period_length default.voting_period_length c.voting_period_length
and slot_durations = and time_between_blocks =
opt Compare_slot_durations.(=) opt Compare_time_between_blocks.(=)
default.slot_durations c.slot_durations default.time_between_blocks c.time_between_blocks
and first_free_baking_slot = and first_free_baking_slot =
opt Compare.Int.(=) opt Compare.Int.(=)
default.first_free_baking_slot c.first_free_baking_slot default.first_free_baking_slot c.first_free_baking_slot
@ -167,7 +167,7 @@ let constants_encoding =
blocks_per_commitment, blocks_per_commitment,
blocks_per_roll_snapshot, blocks_per_roll_snapshot,
voting_period_length, voting_period_length,
slot_durations, time_between_blocks,
first_free_baking_slot, first_free_baking_slot,
max_signing_slot, max_signing_slot,
max_gas), max_gas),
@ -183,7 +183,7 @@ let constants_encoding =
blocks_per_commitment, blocks_per_commitment,
blocks_per_roll_snapshot, blocks_per_roll_snapshot,
voting_period_length, voting_period_length,
slot_durations, time_between_blocks,
first_free_baking_slot, first_free_baking_slot,
max_signing_slot, max_signing_slot,
max_gas), max_gas),
@ -204,9 +204,9 @@ let constants_encoding =
unopt default.blocks_per_roll_snapshot blocks_per_roll_snapshot ; unopt default.blocks_per_roll_snapshot blocks_per_roll_snapshot ;
voting_period_length = voting_period_length =
unopt default.voting_period_length voting_period_length ; unopt default.voting_period_length voting_period_length ;
slot_durations = time_between_blocks =
unopt default.slot_durations @@ unopt default.time_between_blocks @@
slot_durations ; time_between_blocks ;
first_free_baking_slot = first_free_baking_slot =
unopt default.first_free_baking_slot first_free_baking_slot ; unopt default.first_free_baking_slot first_free_baking_slot ;
max_signing_slot = max_signing_slot =
@ -237,7 +237,7 @@ let constants_encoding =
(opt "blocks_per_commitment" int32) (opt "blocks_per_commitment" int32)
(opt "blocks_per_roll_snapshot" int32) (opt "blocks_per_roll_snapshot" int32)
(opt "voting_period_length" 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 "first_free_baking_slot" uint16)
(opt "max_signing_slot" uint16) (opt "max_signing_slot" uint16)
(opt "instructions_per_transaction" int31)) (opt "instructions_per_transaction" int31))

View File

@ -56,7 +56,7 @@ module S = struct
~output: (obj1 (req "blocks_per_roll_snapshot" int32)) ~output: (obj1 (req "blocks_per_roll_snapshot" int32))
RPC_path.(custom_root / "blocks_per_roll_snapshot") RPC_path.(custom_root / "blocks_per_roll_snapshot")
let slot_durations = let time_between_blocks =
RPC_service.post_service RPC_service.post_service
~description: "Slot durations" ~description: "Slot durations"
~query: RPC_query.empty ~query: RPC_query.empty
@ -124,8 +124,8 @@ let () =
register0 S.blocks_per_roll_snapshot begin fun ctxt () () -> register0 S.blocks_per_roll_snapshot begin fun ctxt () () ->
return (Constants.blocks_per_roll_snapshot ctxt) return (Constants.blocks_per_roll_snapshot ctxt)
end ; end ;
register0 S.slot_durations begin fun ctxt () () -> register0 S.time_between_blocks begin fun ctxt () () ->
return (Constants.slot_durations ctxt) return (Constants.time_between_blocks ctxt)
end ; end ;
register0 S.first_free_baking_slot begin fun ctxt () () -> register0 S.first_free_baking_slot begin fun ctxt () () ->
return (Constants.first_free_baking_slot 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 () () RPC_context.make_call0 S.blocks_per_commitment ctxt block () ()
let blocks_per_roll_snapshot ctxt block = let blocks_per_roll_snapshot ctxt block =
RPC_context.make_call0 S.blocks_per_roll_snapshot ctxt block () () RPC_context.make_call0 S.blocks_per_roll_snapshot ctxt block () ()
let slot_durations ctxt block = let time_between_blocks ctxt block =
RPC_context.make_call0 S.slot_durations ctxt block () () RPC_context.make_call0 S.time_between_blocks ctxt block () ()
let first_free_baking_slot ctxt block = let first_free_baking_slot ctxt block =
RPC_context.make_call0 S.first_free_baking_slot ctxt block () () RPC_context.make_call0 S.first_free_baking_slot ctxt block () ()
let max_signing_slot ctxt block = let max_signing_slot ctxt block =

View File

@ -24,7 +24,7 @@ val blocks_per_commitment:
val blocks_per_roll_snapshot: val blocks_per_roll_snapshot:
'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t '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 'a #RPC_context.simple -> 'a -> Period.t list shell_tzresult Lwt.t
val first_free_baking_slot: val first_free_baking_slot:

View File

@ -22,9 +22,9 @@ let blocks_per_roll_snapshot c =
let voting_period_length c = let voting_period_length c =
let constants = Raw_context.constants c in let constants = Raw_context.constants c in
constants.voting_period_length constants.voting_period_length
let slot_durations c = let time_between_blocks c =
let constants = Raw_context.constants c in let constants = Raw_context.constants c in
constants.slot_durations constants.time_between_blocks
let first_free_baking_slot c = let first_free_baking_slot c =
let constants = Raw_context.constants c in let constants = Raw_context.constants c in
constants.first_free_baking_slot constants.first_free_baking_slot

View File

@ -72,7 +72,7 @@ module Constants = struct
~output: (obj1 (req "time_before_reward" Period.encoding)) ~output: (obj1 (req "time_before_reward" Period.encoding))
RPC_path.(custom_root / "constants" / "time_before_reward") RPC_path.(custom_root / "constants" / "time_before_reward")
let slot_durations custom_root = let time_between_blocks custom_root =
RPC_service.post_service RPC_service.post_service
~description: "Slot durations" ~description: "Slot durations"
~query: RPC_query.empty ~query: RPC_query.empty