Alpha: add constant 'block_per_roll_snapshot'

This commit is contained in:
Grégoire Henry 2018-03-13 14:50:39 +01:00 committed by Benjamin Canou
parent 4e9fd509b3
commit 0283bee65b
9 changed files with 49 additions and 11 deletions

View File

@ -10,5 +10,6 @@
],
"slot_durations" : [ 1, 0 ],
"cycle_length" : 128,
"block_per_roll_snapshot" : 32,
"first_free_baking_slot" : 4
}

View File

@ -10,6 +10,7 @@
],
"slot_durations" : [ 1, 0 ],
"cycle_length" : 4,
"block_per_roll_snapshot" : 2,
"voting_period_length" : 2,
"time_before_reward" : 1,
"first_free_baking_slot" : 4

View File

@ -10,6 +10,7 @@
],
"slot_durations" : [ 1, 0 ],
"cycle_length" : 4,
"block_per_roll_snapshot" : 2,
"time_before_reward" : 1,
"first_free_baking_slot" : 4
}

View File

@ -266,6 +266,7 @@ module Constants : sig
val preserved_cycles: context -> int
val cycle_length: context -> int32
val blocks_per_commitment: context -> int32
val block_per_roll_snapshot: context -> int32
val voting_period_length: context -> int32
val time_before_reward: context -> Period.t
val slot_durations: context -> Period.t list

View File

@ -48,6 +48,7 @@ type constants = {
preserved_cycles: int ;
cycle_length: int32 ;
blocks_per_commitment: int32 ;
block_per_roll_snapshot: int32 ;
voting_period_length: int32 ;
time_before_reward: Period_repr.t ;
slot_durations: Period_repr.t list ;
@ -69,6 +70,7 @@ let default = {
preserved_cycles = 5 ;
cycle_length = 2048l ;
blocks_per_commitment = 32l ;
block_per_roll_snapshot = 256l ;
voting_period_length = 32768l ;
time_before_reward =
Period_repr.of_seconds_exn
@ -125,6 +127,9 @@ let constants_encoding =
and blocks_per_commitment =
opt Compare.Int32.(=)
default.blocks_per_commitment c.blocks_per_commitment
and block_per_roll_snapshot =
opt Compare.Int32.(=)
default.block_per_roll_snapshot c.block_per_roll_snapshot
and voting_period_length =
opt Compare.Int32.(=)
default.voting_period_length c.voting_period_length
@ -169,14 +174,15 @@ let constants_encoding =
((( preserved_cycles,
cycle_length,
blocks_per_commitment,
block_per_roll_snapshot,
voting_period_length,
time_before_reward,
slot_durations,
first_free_baking_slot,
max_signing_slot,
max_gas,
proof_of_work_threshold),
( bootstrap_keys,
max_gas),
( proof_of_work_threshold,
bootstrap_keys,
dictator_pubkey,
max_number_of_operations,
max_operation_data_length,
@ -185,14 +191,15 @@ let constants_encoding =
(fun ((( preserved_cycles,
cycle_length,
blocks_per_commitment,
block_per_roll_snapshot,
voting_period_length,
time_before_reward,
slot_durations,
first_free_baking_slot,
max_signing_slot,
max_gas,
proof_of_work_threshold),
( bootstrap_keys,
max_gas),
( proof_of_work_threshold,
bootstrap_keys,
dictator_pubkey,
max_number_of_operations,
max_operation_data_length,
@ -204,6 +211,8 @@ let constants_encoding =
unopt default.cycle_length cycle_length ;
blocks_per_commitment =
unopt default.blocks_per_commitment blocks_per_commitment ;
block_per_roll_snapshot =
unopt default.block_per_roll_snapshot block_per_roll_snapshot ;
voting_period_length =
unopt default.voting_period_length voting_period_length ;
time_before_reward =
@ -240,14 +249,15 @@ let constants_encoding =
(opt "preserved_cycles" uint8)
(opt "cycle_length" int32)
(opt "blocks_per_commitment" int32)
(opt "block_per_roll_snapshot" int32)
(opt "voting_period_length" int32)
(opt "time_before_reward" int64)
(opt "slot_durations" (list Period_repr.encoding))
(opt "first_free_baking_slot" uint16)
(opt "max_signing_slot" uint16)
(opt "instructions_per_transaction" int31)
(opt "proof_of_work_threshold" int64))
(obj6
(opt "instructions_per_transaction" int31))
(obj7
(opt "proof_of_work_threshold" int64)
(opt "bootstrap_keys" (list Ed25519.Public_key.encoding))
(opt "dictator_pubkey" Ed25519.Public_key.encoding)
(opt "max_number_of_operations" (list uint16))
@ -265,4 +275,8 @@ let read = function
| Some json ->
match Data_encoding.Json.(destruct constants_encoding json) with
| exception exn -> fail (Constant_read exn)
| c -> return c
| c ->
if Compare.Int32.(c.block_per_roll_snapshot > c.cycle_length) then
failwith "Invalid sandbox: 'block_per_roll_snapshot > cycle_length'"
else
return c

View File

@ -42,12 +42,20 @@ module S = struct
let blocks_per_commitment =
RPC_service.post_service
~description: "How many blocks beetween random seed's nonce commitment"
~description: "How many blocks between 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 block_per_roll_snapshot =
RPC_service.post_service
~description: "How many blocks between roll snapshots"
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "block_per_roll_snapshot" int32))
RPC_path.(custom_root / "block_per_roll_snapshot")
let time_before_reward =
RPC_service.post_service
~description: "Time before reward"
@ -121,6 +129,9 @@ let () =
register0 S.blocks_per_commitment begin fun ctxt () () ->
return (Constants.blocks_per_commitment ctxt)
end ;
register0 S.block_per_roll_snapshot begin fun ctxt () () ->
return (Constants.block_per_roll_snapshot ctxt)
end ;
register0 S.time_before_reward begin fun ctxt () () ->
return (Constants.time_before_reward ctxt)
end ;
@ -151,6 +162,8 @@ 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 block_per_roll_snapshot ctxt block =
RPC_context.make_call0 S.block_per_roll_snapshot ctxt block () ()
let time_before_reward ctxt block =
RPC_context.make_call0 S.time_before_reward ctxt block () ()
let slot_durations ctxt block =

View File

@ -21,6 +21,9 @@ val voting_period_length:
val blocks_per_commitment:
'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t
val block_per_roll_snapshot:
'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

View File

@ -16,6 +16,9 @@ let cycle_length c =
let blocks_per_commitment c =
let constants = Raw_context.constants c in
constants.blocks_per_commitment
let block_per_roll_snapshot c =
let constants = Raw_context.constants c in
constants.block_per_roll_snapshot
let voting_period_length c =
let constants = Raw_context.constants c in
constants.voting_period_length

View File

@ -10,6 +10,7 @@
],
"slot_durations" : [ 1, 0 ],
"cycle_length" : 4,
"block_per_roll_snapshot" : 2,
"time_before_reward" : 1,
"first_free_baking_slot" : 4
}