Alpha: remove constant first_free_baking_slot

This commit is contained in:
Grégoire Henry 2018-03-22 17:07:18 +01:00 committed by Benjamin Canou
parent 162bd73e85
commit 670249f580
18 changed files with 20 additions and 75 deletions

View File

@ -11,6 +11,5 @@
"blocks_per_roll_snapshot" : 4,
"blocks_per_cycle" : 8,
"preserved_cycles" : 2,
"first_free_baking_slot" : 4,
"proof_of_work_threshold": "-1"
}

View File

@ -24,6 +24,5 @@
"blocks_per_cycle" : 128,
"blocks_per_roll_snapshot" : 32,
"preserved_cycles" : 1,
"first_free_baking_slot" : 4,
"proof_of_work_threshold": "-1"
}

View File

@ -40,8 +40,7 @@ init_sandboxed_client() {
"time_between_blocks" : [ "1", "0" ],
"blocks_per_roll_snapshot" : 4,
"blocks_per_cycle" : 8,
"preserved_cycles" : 2,
"first_free_baking_slot" : 4
"preserved_cycles" : 2
}
EOF
fi

View File

@ -37,15 +37,14 @@ let commands () =
@@ stop)
(fun () delegate cctxt -> endorse_block cctxt delegate) ;
command ~group ~desc: "Forge and inject block using the delegate rights."
(args4 max_priority_arg force_switch
free_baking_switch minimal_timestamp_switch)
(args3 max_priority_arg force_switch minimal_timestamp_switch)
(prefixes [ "bake"; "for" ]
@@ Client_keys.Public_key_hash.source_param
~name:"baker" ~desc: "name of the delegate owning the baking right"
@@ stop)
(fun (max_priority, force, free_baking, minimal_timestamp) delegate cctxt ->
(fun (max_priority, force, minimal_timestamp) delegate cctxt ->
bake_block cctxt cctxt#block
~force ?max_priority ~minimal_timestamp ~free_baking delegate) ;
~force ?max_priority ~minimal_timestamp delegate) ;
command ~group ~desc: "Forge and inject a seed-nonce revelation operation."
no_options
(prefixes [ "reveal"; "nonce"; "for" ]

View File

@ -162,7 +162,7 @@ let forge_block cctxt ?(chain = `Main) block
(List.nth_opt rights priority) in
return (priority, time)
end
| `Auto (src_pkh, max_priority, free_baking) ->
| `Auto (src_pkh, max_priority) ->
Alpha_services.Helpers.current_level
cctxt ~offset:1l (chain, block)>>=? fun { level } ->
Alpha_services.Delegate.Baking_rights.get cctxt
@ -171,21 +171,11 @@ let forge_block cctxt ?(chain = `Main) block
~delegates:[src_pkh]
(chain, block) >>=? fun possibilities ->
try
begin
if free_baking then
Alpha_services.Constants.all cctxt
(chain, block) >>=? fun { parametric = {
first_free_baking_slot ;
} } ->
return first_free_baking_slot
else
return 0
end >>=? fun min_prio ->
let { Alpha_services.Delegate.Baking_rights.priority = prio ;
timestamp = time } =
List.find
(fun (p : Alpha_services.Delegate.Baking_rights.t) ->
p.level = level && p.priority >= min_prio)
p.level = level)
possibilities in
return (prio, time)
with Not_found ->

View File

@ -44,7 +44,7 @@ val forge_block:
?best_effort:bool ->
?sort:bool ->
?timestamp:Time.t ->
priority:[`Set of int | `Auto of (public_key_hash * int option * bool)] ->
priority:[`Set of int | `Auto of (public_key_hash * int option)] ->
?seed_nonce_hash:Nonce_hash.t ->
src_sk:Client_keys.sk_uri ->
unit ->

View File

@ -12,7 +12,7 @@ open Alpha_context
let bake_block (cctxt : #Proto_alpha.full)
?(chain = `Main) block
?force ?max_priority ?(free_baking=false) ?(minimal_timestamp=false)
?force ?max_priority ?(minimal_timestamp=false)
?src_sk delegate =
begin
match src_sk with
@ -34,7 +34,7 @@ let bake_block (cctxt : #Proto_alpha.full)
?timestamp:(if minimal_timestamp then None else Some (Time.now ()))
?force
?seed_nonce_hash ~src_sk block
~priority:(`Auto (delegate, max_priority, free_baking)) () >>=? fun block_hash ->
~priority:(`Auto (delegate, max_priority)) () >>=? fun block_hash ->
begin
match seed_nonce with
| None -> return ()

View File

@ -17,7 +17,6 @@ val bake_block:
Block_services.block ->
?force:bool ->
?max_priority: int ->
?free_baking: bool ->
?minimal_timestamp: bool ->
?src_sk:Client_keys.sk_uri ->
public_key_hash ->

View File

@ -80,7 +80,6 @@ let protocol_parameters =
"blocks_per_cycle" : 4,
"blocks_per_roll_snapshot" : 2,
"preserved_cycles" : 1,
"first_free_baking_slot" : 4,
"proof_of_work_threshold": "-1"
}
|json} in
@ -103,7 +102,6 @@ let vote_protocol_parameters =
"blocks_per_cycle" : 4,
"blocks_per_roll_snapshot" : 2,
"preserved_cycles" : 1,
"first_free_baking_slot" : 4,
"blocks_per_voting_period": 2,
"proof_of_work_threshold": "-1"
}
@ -536,7 +534,7 @@ module Baking = struct
~force:true
~best_effort:false
~sort:false
~priority:(`Auto (contract.pkh, Some 1024, false))
~priority:(`Auto (contract.pkh, Some 1024))
?seed_nonce_hash
~src_sk
()

View File

@ -186,13 +186,6 @@ let max_priority_arg =
try return (int_of_string s)
with _ -> fail (Bad_max_priority s)))
let free_baking_switch =
switch
~long:"free-baking"
?short:None
~doc:"only consider free baking slots"
()
let endorsement_delay_arg =
default_arg
~long:"endorsement-delay"

View File

@ -23,7 +23,6 @@ val delegate_arg: (Signature.Public_key_hash.t option, Proto_alpha.full) Clic.ar
val delegatable_switch: (bool, Proto_alpha.full) Clic.arg
val spendable_switch: (bool, Proto_alpha.full) Clic.arg
val max_priority_arg: (int option, Proto_alpha.full) Clic.arg
val free_baking_switch: (bool, Proto_alpha.full) Clic.arg
val force_switch: (bool, Proto_alpha.full) Clic.arg
val minimal_timestamp_switch: (bool, Proto_alpha.full) Clic.arg
val endorsement_delay_arg: (int, Proto_alpha.full) Clic.arg

View File

@ -316,7 +316,6 @@ module Constants : sig
blocks_per_roll_snapshot: int32 ;
blocks_per_voting_period: int32 ;
time_between_blocks: Period.t list ;
first_free_baking_slot: int ;
endorsers_per_block: int ;
hard_gas_limit_per_operation: Z.t ;
hard_gas_limit_per_block: Z.t ;
@ -343,7 +342,6 @@ module Constants : sig
val blocks_per_roll_snapshot: context -> int32
val blocks_per_voting_period: context -> int32
val time_between_blocks: context -> Period.t list
val first_free_baking_slot: context -> int
val endorsers_per_block: context -> int
val hard_gas_limit_per_operation: context -> Z.t
val hard_gas_limit_per_block: context -> Z.t

View File

@ -799,7 +799,7 @@ let begin_full_construction ctxt pred_timestamp protocol_data =
Baking.check_baking_rights
ctxt protocol_data pred_timestamp >>=? fun delegate_pk ->
let delegate_pkh = Signature.Public_key.hash delegate_pk in
Baking.freeze_baking_deposit ctxt protocol_data delegate_pkh >>=? fun (ctxt, deposit) ->
Baking.freeze_baking_deposit ctxt delegate_pkh >>=? fun (ctxt, deposit) ->
let ctxt = Fitness.increase ctxt in
return (ctxt, protocol_data, delegate_pk, deposit)
@ -823,8 +823,7 @@ let begin_application ctxt block_header pred_timestamp =
(Invalid_commitment
{ expected = current_level.expected_commitment }) >>=? fun () ->
let delegate_pkh = Signature.Public_key.hash delegate_pk in
Baking.freeze_baking_deposit ctxt
block_header.protocol_data.contents delegate_pkh >>=? fun (ctxt, deposit) ->
Baking.freeze_baking_deposit ctxt delegate_pkh >>=? fun (ctxt, deposit) ->
let ctxt = Fitness.increase ctxt in
return (ctxt, delegate_pk, deposit)

View File

@ -163,14 +163,11 @@ let earlier_predecessor_timestamp ctxt level =
Lwt.return Timestamp.(current_timestamp +? delay) >>=? fun result ->
return result
let freeze_baking_deposit ctxt { Block_header.priority ; _ } delegate =
if Compare.Int.(priority >= Constants.first_free_baking_slot ctxt)
then return (ctxt, Tez.zero)
else
let deposit = Constants.block_security_deposit ctxt in
Delegate.freeze_deposit ctxt delegate deposit
|> trace Cannot_freeze_baking_deposit >>=? fun ctxt ->
return (ctxt, deposit)
let freeze_baking_deposit ctxt delegate =
let deposit = Constants.block_security_deposit ctxt in
Delegate.freeze_deposit ctxt delegate deposit
|> trace Cannot_freeze_baking_deposit >>=? fun ctxt ->
return (ctxt, deposit)
let freeze_endorsement_deposit ctxt delegate n =
let deposit = Constants.endorsement_security_deposit ctxt in
@ -204,9 +201,6 @@ let check_endorsements_rights c level slots =
(Inconsistent_endorsement (List.map Signature.Public_key.hash all_delegates)) >>=? fun () ->
return delegate
let paying_priorities c =
0 --> (Constants.first_free_baking_slot c - 1)
type error += Incorrect_priority
let endorsement_reward ctxt ~block_priority:prio n =
@ -248,7 +242,7 @@ let select_delegate delegate delegate_list max_priority =
let first_baking_priorities
ctxt
?(max_priority = Constants.first_free_baking_slot ctxt)
?(max_priority = 32)
delegate level =
baking_priorities ctxt level >>=? fun delegate_list ->
select_delegate delegate delegate_list max_priority

View File

@ -19,8 +19,6 @@ type error += Cannot_freeze_baking_deposit (* `Permanent *)
type error += Cannot_freeze_endorsement_deposit (* `Permanent *)
type error += Invalid_block_signature of Block_hash.t * Signature.Public_key_hash.t (* `Permanent *)
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
@ -39,7 +37,6 @@ val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t
funds to claim baking rights. *)
val freeze_baking_deposit:
context ->
Block_header.contents ->
public_key_hash ->
(context * Tez.t) tzresult Lwt.t
@ -55,7 +52,6 @@ val freeze_endorsement_deposit:
(** [check_baking_rights ctxt block pred_timestamp] verifies that:
* the contract that owned the roll at cycle start has the block signer as delegate.
* the timestamp is coherent with the announced slot.
* the deposit have been payed if the slot is below [Constants.first_free_baking_slot].
*)
val check_baking_rights:
context -> Block_header.contents -> Time.t ->

View File

@ -50,7 +50,6 @@ type parametric = {
blocks_per_roll_snapshot: int32 ;
blocks_per_voting_period: int32 ;
time_between_blocks: Period_repr.t list ;
first_free_baking_slot: int ;
endorsers_per_block: int ;
hard_gas_limit_per_operation: Z.t ;
hard_gas_limit_per_block: Z.t ;
@ -78,7 +77,6 @@ let default = {
blocks_per_voting_period = 32768l ;
time_between_blocks =
List.map Period_repr.of_seconds_exn [ 60L ] ;
first_free_baking_slot = 16 ;
endorsers_per_block = 32 ;
hard_gas_limit_per_operation = Z.of_int 400_000 ;
hard_gas_limit_per_block = Z.of_int 4_000_000 ;
@ -119,7 +117,6 @@ let parametric_encoding =
c.blocks_per_roll_snapshot,
c.blocks_per_voting_period,
c.time_between_blocks,
c.first_free_baking_slot,
c.endorsers_per_block,
c.hard_gas_limit_per_operation,
c.hard_gas_limit_per_block),
@ -143,7 +140,6 @@ let parametric_encoding =
blocks_per_roll_snapshot,
blocks_per_voting_period,
time_between_blocks,
first_free_baking_slot,
endorsers_per_block,
hard_gas_limit_per_operation,
hard_gas_limit_per_block),
@ -167,7 +163,6 @@ let parametric_encoding =
blocks_per_roll_snapshot ;
blocks_per_voting_period ;
time_between_blocks ;
first_free_baking_slot ;
endorsers_per_block ;
hard_gas_limit_per_operation ;
hard_gas_limit_per_block ;
@ -187,14 +182,13 @@ let parametric_encoding =
hard_storage_limit_per_block ;
} )
(merge_objs
(obj10
(obj9
(req "preserved_cycles" uint8)
(req "blocks_per_cycle" int32)
(req "blocks_per_commitment" int32)
(req "blocks_per_roll_snapshot" int32)
(req "blocks_per_voting_period" int32)
(req "time_between_blocks" (list Period_repr.encoding))
(req "first_free_baking_slot" uint16)
(req "endorsers_per_block" uint16)
(req "hard_gas_limit_per_operation" z)
(req "hard_gas_limit_per_block" z))

View File

@ -25,9 +25,6 @@ let blocks_per_voting_period c =
let time_between_blocks c =
let constants = Raw_context.constants c in
constants.time_between_blocks
let first_free_baking_slot c =
let constants = Raw_context.constants c in
constants.first_free_baking_slot
let endorsers_per_block c =
let constants = Raw_context.constants c in
constants.endorsers_per_block

View File

@ -57,9 +57,6 @@ let constants_encoding =
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
and endorsers_per_block =
opt Compare.Int.(=)
default.endorsers_per_block c.endorsers_per_block
@ -118,7 +115,6 @@ let constants_encoding =
blocks_per_roll_snapshot,
blocks_per_voting_period,
time_between_blocks,
first_free_baking_slot,
endorsers_per_block,
hard_gas_limit_per_operation,
hard_gas_limit_per_block),
@ -142,7 +138,6 @@ let constants_encoding =
blocks_per_roll_snapshot,
blocks_per_voting_period,
time_between_blocks,
first_free_baking_slot,
endorsers_per_block,
hard_gas_limit_per_operation,
hard_gas_limit_per_block),
@ -175,8 +170,6 @@ let constants_encoding =
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 ;
endorsers_per_block =
unopt default.endorsers_per_block endorsers_per_block ;
hard_gas_limit_per_operation =
@ -213,14 +206,13 @@ let constants_encoding =
unopt default.hard_storage_limit_per_block hard_storage_limit_per_block ;
} )
(merge_objs
(obj10
(obj9
(opt "preserved_cycles" uint8)
(opt "blocks_per_cycle" int32)
(opt "blocks_per_commitment" int32)
(opt "blocks_per_roll_snapshot" int32)
(opt "blocks_per_voting_period" int32)
(opt "time_between_blocks" (list Period_repr.encoding))
(opt "first_free_baking_slot" uint16)
(opt "endorsers_per_block" uint16)
(opt "hard_gas_limit_per_operation" z)
(opt "hard_gas_limit_per_block" z))