diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 7d2aa8e00..a688f7847 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -265,6 +265,7 @@ module Constants : sig val preserved_cycles: context -> int val cycle_length: context -> int32 + val blocks_per_commitment: context -> int32 val voting_period_length: context -> int32 val time_before_reward: context -> Period.t val slot_durations: context -> Period.t list diff --git a/src/proto_alpha/lib_protocol/src/constants_repr.ml b/src/proto_alpha/lib_protocol/src/constants_repr.ml index 590891ac9..b1e8af1df 100644 --- a/src/proto_alpha/lib_protocol/src/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/src/constants_repr.ml @@ -47,6 +47,7 @@ let bootstrap_wealth = type constants = { preserved_cycles: int ; cycle_length: int32 ; + blocks_per_commitment: int32 ; voting_period_length: int32 ; time_before_reward: Period_repr.t ; slot_durations: Period_repr.t list ; @@ -67,6 +68,7 @@ let read_public_key s = Ed25519.Public_key.of_hex_exn (`Hex s) let default = { preserved_cycles = 5 ; cycle_length = 2048l ; + blocks_per_commitment = 32l ; voting_period_length = 32768l ; time_before_reward = Period_repr.of_seconds_exn @@ -120,6 +122,9 @@ let constants_encoding = and cycle_length = opt Compare.Int32.(=) default.cycle_length c.cycle_length + and blocks_per_commitment = + opt Compare.Int32.(=) + default.blocks_per_commitment c.blocks_per_commitment and voting_period_length = opt Compare.Int32.(=) default.voting_period_length c.voting_period_length @@ -163,6 +168,7 @@ let constants_encoding = in ((( preserved_cycles, cycle_length, + blocks_per_commitment, voting_period_length, time_before_reward, slot_durations, @@ -178,6 +184,7 @@ let constants_encoding = michelson_maximum_type_size)), ()) ) (fun ((( preserved_cycles, cycle_length, + blocks_per_commitment, voting_period_length, time_before_reward, slot_durations, @@ -195,6 +202,8 @@ let constants_encoding = unopt default.preserved_cycles preserved_cycles ; cycle_length = unopt default.cycle_length cycle_length ; + blocks_per_commitment = + unopt default.blocks_per_commitment blocks_per_commitment ; voting_period_length = unopt default.voting_period_length voting_period_length ; time_before_reward = @@ -227,9 +236,10 @@ let constants_encoding = Data_encoding.( merge_objs (merge_objs - (obj9 + (obj10 (opt "preserved_cycles" uint8) (opt "cycle_length" int32) + (opt "blocks_per_commitment" int32) (opt "voting_period_length" int32) (opt "time_before_reward" int64) (opt "slot_durations" (list Period_repr.encoding)) diff --git a/src/proto_alpha/lib_protocol/src/constants_services.ml b/src/proto_alpha/lib_protocol/src/constants_services.ml index 100092d10..81ae281b8 100644 --- a/src/proto_alpha/lib_protocol/src/constants_services.ml +++ b/src/proto_alpha/lib_protocol/src/constants_services.ml @@ -40,6 +40,14 @@ module S = struct ~output: (obj1 (req "voting_period_length" int32)) RPC_path.(custom_root / "voting_period_length") + let blocks_per_commitment = + RPC_service.post_service + ~description: "How many blocks beetween random seed's nonce commitment" + ~query: RPC_query.empty + ~input: empty + ~output: (obj1 (req "blocks_per_commitment" int32)) + RPC_path.(custom_root / "blocks_per_commitment") + let time_before_reward = RPC_service.post_service ~description: "Time before reward" @@ -110,6 +118,9 @@ let () = register0 S.voting_period_length begin fun ctxt () () -> return (Constants.voting_period_length ctxt) end ; + register0 S.blocks_per_commitment begin fun ctxt () () -> + return (Constants.blocks_per_commitment ctxt) + end ; register0 S.time_before_reward begin fun ctxt () () -> return (Constants.time_before_reward ctxt) end ; @@ -138,6 +149,8 @@ let preserved_cycles ctxt block = RPC_context.make_call0 S.preserved_cycles ctxt block () () let voting_period_length ctxt block = RPC_context.make_call0 S.voting_period_length ctxt block () () +let blocks_per_commitment ctxt block = + RPC_context.make_call0 S.blocks_per_commitment ctxt block () () let time_before_reward ctxt block = RPC_context.make_call0 S.time_before_reward ctxt block () () let slot_durations 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 81060f60c..75664a92e 100644 --- a/src/proto_alpha/lib_protocol/src/constants_services.mli +++ b/src/proto_alpha/lib_protocol/src/constants_services.mli @@ -18,6 +18,9 @@ val cycle_length: val voting_period_length: 'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t +val blocks_per_commitment: + 'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t + val time_before_reward: 'a #RPC_context.simple -> 'a -> Period.t shell_tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/src/constants_storage.ml b/src/proto_alpha/lib_protocol/src/constants_storage.ml index a14a229f5..8a5a7df30 100644 --- a/src/proto_alpha/lib_protocol/src/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/src/constants_storage.ml @@ -13,6 +13,9 @@ let preserved_cycles c = let cycle_length c = let constants = Raw_context.constants c in constants.cycle_length +let blocks_per_commitment c = + let constants = Raw_context.constants c in + constants.blocks_per_commitment let voting_period_length c = let constants = Raw_context.constants c in constants.voting_period_length