Rename last occurences of miner into baker
This commit is contained in:
parent
ed75bc5acd
commit
b25f35e2b5
@ -124,7 +124,7 @@ let commands () =
|
|||||||
(args2 force_switch max_priority_arg)
|
(args2 force_switch max_priority_arg)
|
||||||
(prefixes [ "endorse"; "for" ]
|
(prefixes [ "endorse"; "for" ]
|
||||||
@@ Client_keys.Public_key_hash.alias_param
|
@@ Client_keys.Public_key_hash.alias_param
|
||||||
~name:"miner" ~desc: "name of the delegate owning the endorsement right"
|
~name:"baker" ~desc: "name of the delegate owning the endorsement right"
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun (force, max_priority) (_, delegate) cctxt ->
|
(fun (force, max_priority) (_, delegate) cctxt ->
|
||||||
endorse_block cctxt
|
endorse_block cctxt
|
||||||
@ -133,7 +133,7 @@ let commands () =
|
|||||||
(args3 max_priority_arg force_switch free_baking_switch)
|
(args3 max_priority_arg force_switch free_baking_switch)
|
||||||
(prefixes [ "mine"; "for" ]
|
(prefixes [ "mine"; "for" ]
|
||||||
@@ Client_keys.Public_key_hash.alias_param
|
@@ Client_keys.Public_key_hash.alias_param
|
||||||
~name:"miner" ~desc: "name of the delegate owning the baking right"
|
~name:"baker" ~desc: "name of the delegate owning the baking right"
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun (max_priority, force, free_baking) (_, delegate) cctxt ->
|
(fun (max_priority, force, free_baking) (_, delegate) cctxt ->
|
||||||
mine_block cctxt cctxt.config.block
|
mine_block cctxt cctxt.config.block
|
||||||
|
@ -124,7 +124,7 @@ let fee_arg =
|
|||||||
tez_arg
|
tez_arg
|
||||||
~default:"0.05"
|
~default:"0.05"
|
||||||
~parameter:"-fee"
|
~parameter:"-fee"
|
||||||
~doc:"The fee in \xEA\x9C\xA9 to pay to the miner."
|
~doc:"The fee in \xEA\x9C\xA9 to pay to the baker."
|
||||||
|
|
||||||
let max_priority_arg =
|
let max_priority_arg =
|
||||||
arg
|
arg
|
||||||
|
@ -161,7 +161,7 @@ let check_signature_and_update_public_key ctxt id public_key op =
|
|||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
let apply_sourced_operation
|
let apply_sourced_operation
|
||||||
ctxt miner_contract pred_block block_prio
|
ctxt baker_contract pred_block block_prio
|
||||||
operation origination_nonce ops =
|
operation origination_nonce ops =
|
||||||
match ops with
|
match ops with
|
||||||
| Manager_operations { source ; public_key ; fee ; counter ; operations = contents } ->
|
| Manager_operations { source ; public_key ; fee ; counter ; operations = contents } ->
|
||||||
@ -173,7 +173,7 @@ let apply_sourced_operation
|
|||||||
ctxt source counter >>=? fun () ->
|
ctxt source counter >>=? fun () ->
|
||||||
Contract.increment_counter ctxt source >>=? fun ctxt ->
|
Contract.increment_counter ctxt source >>=? fun ctxt ->
|
||||||
Contract.spend ctxt source fee >>=? fun ctxt ->
|
Contract.spend ctxt source fee >>=? fun ctxt ->
|
||||||
(match miner_contract with
|
(match baker_contract with
|
||||||
| None -> return ctxt
|
| None -> return ctxt
|
||||||
| Some contract ->
|
| Some contract ->
|
||||||
Contract.credit ctxt contract fee) >>=? fun ctxt ->
|
Contract.credit ctxt contract fee) >>=? fun ctxt ->
|
||||||
@ -209,7 +209,7 @@ let apply_sourced_operation
|
|||||||
fork_test_network ctxt hash expiration >>= fun ctxt ->
|
fork_test_network ctxt hash expiration >>= fun ctxt ->
|
||||||
return (ctxt, origination_nonce, None)
|
return (ctxt, origination_nonce, None)
|
||||||
|
|
||||||
let apply_anonymous_operation ctxt miner_contract origination_nonce kind =
|
let apply_anonymous_operation ctxt baker_contract origination_nonce kind =
|
||||||
match kind with
|
match kind with
|
||||||
| Seed_nonce_revelation { level ; nonce } ->
|
| Seed_nonce_revelation { level ; nonce } ->
|
||||||
let level = Level.from_raw ctxt level in
|
let level = Level.from_raw ctxt level in
|
||||||
@ -218,7 +218,7 @@ let apply_anonymous_operation ctxt miner_contract origination_nonce kind =
|
|||||||
Reward.record ctxt
|
Reward.record ctxt
|
||||||
delegate_to_reward level.cycle reward_amount >>=? fun ctxt ->
|
delegate_to_reward level.cycle reward_amount >>=? fun ctxt ->
|
||||||
begin
|
begin
|
||||||
match miner_contract with
|
match baker_contract with
|
||||||
| None -> return (ctxt, origination_nonce)
|
| None -> return (ctxt, origination_nonce)
|
||||||
| Some contract ->
|
| Some contract ->
|
||||||
Contract.credit
|
Contract.credit
|
||||||
@ -228,7 +228,7 @@ let apply_anonymous_operation ctxt miner_contract origination_nonce kind =
|
|||||||
| Faucet { id = manager } ->
|
| Faucet { id = manager } ->
|
||||||
(* Free tez for all! *)
|
(* Free tez for all! *)
|
||||||
begin
|
begin
|
||||||
match miner_contract with
|
match baker_contract with
|
||||||
| None -> return None
|
| None -> return None
|
||||||
| Some contract -> Contract.get_delegate_opt ctxt contract
|
| Some contract -> Contract.get_delegate_opt ctxt contract
|
||||||
end >>=? fun delegate ->
|
end >>=? fun delegate ->
|
||||||
@ -239,19 +239,19 @@ let apply_anonymous_operation ctxt miner_contract origination_nonce kind =
|
|||||||
return (ctxt, origination_nonce)
|
return (ctxt, origination_nonce)
|
||||||
|
|
||||||
let apply_operation
|
let apply_operation
|
||||||
ctxt miner_contract pred_block block_prio operation =
|
ctxt baker_contract pred_block block_prio operation =
|
||||||
match operation.contents with
|
match operation.contents with
|
||||||
| Anonymous_operations ops ->
|
| Anonymous_operations ops ->
|
||||||
let origination_nonce = Contract.initial_origination_nonce operation.hash in
|
let origination_nonce = Contract.initial_origination_nonce operation.hash in
|
||||||
fold_left_s
|
fold_left_s
|
||||||
(fun (ctxt, origination_nonce) ->
|
(fun (ctxt, origination_nonce) ->
|
||||||
apply_anonymous_operation ctxt miner_contract origination_nonce)
|
apply_anonymous_operation ctxt baker_contract origination_nonce)
|
||||||
(ctxt, origination_nonce) ops >>=? fun (ctxt, origination_nonce) ->
|
(ctxt, origination_nonce) ops >>=? fun (ctxt, origination_nonce) ->
|
||||||
return (ctxt, Contract.originated_contracts origination_nonce, None)
|
return (ctxt, Contract.originated_contracts origination_nonce, None)
|
||||||
| Sourced_operations op ->
|
| Sourced_operations op ->
|
||||||
let origination_nonce = Contract.initial_origination_nonce operation.hash in
|
let origination_nonce = Contract.initial_origination_nonce operation.hash in
|
||||||
apply_sourced_operation
|
apply_sourced_operation
|
||||||
ctxt miner_contract pred_block block_prio
|
ctxt baker_contract pred_block block_prio
|
||||||
operation origination_nonce op >>=? fun (ctxt, origination_nonce, err) ->
|
operation origination_nonce op >>=? fun (ctxt, origination_nonce, err) ->
|
||||||
return (ctxt, Contract.originated_contracts origination_nonce, err)
|
return (ctxt, Contract.originated_contracts origination_nonce, err)
|
||||||
|
|
||||||
@ -277,10 +277,10 @@ let begin_full_construction ctxt pred_timestamp proto_header =
|
|||||||
(Block_header.parse_unsigned_proto_header
|
(Block_header.parse_unsigned_proto_header
|
||||||
proto_header) >>=? fun proto_header ->
|
proto_header) >>=? fun proto_header ->
|
||||||
Baking.check_baking_rights
|
Baking.check_baking_rights
|
||||||
ctxt proto_header pred_timestamp >>=? fun miner ->
|
ctxt proto_header pred_timestamp >>=? fun baker ->
|
||||||
Baking.pay_baking_bond ctxt proto_header miner >>=? fun ctxt ->
|
Baking.pay_baking_bond ctxt proto_header baker >>=? fun ctxt ->
|
||||||
let ctxt = Fitness.increase ctxt in
|
let ctxt = Fitness.increase ctxt in
|
||||||
return (ctxt, proto_header, miner)
|
return (ctxt, proto_header, baker)
|
||||||
|
|
||||||
let begin_partial_construction ctxt =
|
let begin_partial_construction ctxt =
|
||||||
let ctxt = Fitness.increase ctxt in
|
let ctxt = Fitness.increase ctxt in
|
||||||
@ -290,18 +290,18 @@ let begin_application ctxt block_header pred_timestamp =
|
|||||||
Baking.check_proof_of_work_stamp ctxt block_header >>=? fun () ->
|
Baking.check_proof_of_work_stamp ctxt block_header >>=? fun () ->
|
||||||
Baking.check_fitness_gap ctxt block_header >>=? fun () ->
|
Baking.check_fitness_gap ctxt block_header >>=? fun () ->
|
||||||
Baking.check_baking_rights
|
Baking.check_baking_rights
|
||||||
ctxt block_header.proto pred_timestamp >>=? fun miner ->
|
ctxt block_header.proto pred_timestamp >>=? fun baker ->
|
||||||
Baking.check_signature ctxt block_header miner >>=? fun () ->
|
Baking.check_signature ctxt block_header baker >>=? fun () ->
|
||||||
Baking.pay_baking_bond ctxt block_header.proto miner >>=? fun ctxt ->
|
Baking.pay_baking_bond ctxt block_header.proto baker >>=? fun ctxt ->
|
||||||
let ctxt = Fitness.increase ctxt in
|
let ctxt = Fitness.increase ctxt in
|
||||||
return (ctxt, miner)
|
return (ctxt, baker)
|
||||||
|
|
||||||
let finalize_application ctxt block_proto_header miner =
|
let finalize_application ctxt block_proto_header baker =
|
||||||
(* end of level (from this point nothing should fail) *)
|
(* end of level (from this point nothing should fail) *)
|
||||||
let priority = block_proto_header.Block_header.priority in
|
let priority = block_proto_header.Block_header.priority in
|
||||||
let reward = Baking.base_baking_reward ctxt ~priority in
|
let reward = Baking.base_baking_reward ctxt ~priority in
|
||||||
Nonce.record_hash ctxt
|
Nonce.record_hash ctxt
|
||||||
miner reward block_proto_header.seed_nonce_hash >>=? fun ctxt ->
|
baker reward block_proto_header.seed_nonce_hash >>=? fun ctxt ->
|
||||||
Reward.pay_due_rewards ctxt >>=? fun ctxt ->
|
Reward.pay_due_rewards ctxt >>=? fun ctxt ->
|
||||||
(* end of cycle *)
|
(* end of cycle *)
|
||||||
may_start_new_cycle ctxt >>=? fun ctxt ->
|
may_start_new_cycle ctxt >>=? fun ctxt ->
|
||||||
|
@ -24,7 +24,7 @@ let () =
|
|||||||
~id:"baking.timestamp_too_early"
|
~id:"baking.timestamp_too_early"
|
||||||
~title:"Block forged too early"
|
~title:"Block forged too early"
|
||||||
~description:"The block timestamp is before the first slot \
|
~description:"The block timestamp is before the first slot \
|
||||||
for this miner at this level"
|
for this baker at this level"
|
||||||
~pp:(fun ppf (r, p) ->
|
~pp:(fun ppf (r, p) ->
|
||||||
Format.fprintf ppf "Block forged too early (%a is before %a)"
|
Format.fprintf ppf "Block forged too early (%a is before %a)"
|
||||||
Time.pp_hum p Time.pp_hum r)
|
Time.pp_hum p Time.pp_hum r)
|
||||||
@ -78,7 +78,7 @@ let () =
|
|||||||
~id:"baking.cannot_pay_baking_bond"
|
~id:"baking.cannot_pay_baking_bond"
|
||||||
~title:"Cannot pay baking bond"
|
~title:"Cannot pay baking bond"
|
||||||
~description:
|
~description:
|
||||||
"Impossible to take the required tokens on the miner's contract"
|
"Impossible to take the required tokens on the baker's contract"
|
||||||
~pp:(fun ppf () -> Format.fprintf ppf "Cannot pay the baking bond")
|
~pp:(fun ppf () -> Format.fprintf ppf "Cannot pay the baking bond")
|
||||||
Data_encoding.unit
|
Data_encoding.unit
|
||||||
(function Cannot_pay_baking_bond -> Some () | _ -> None)
|
(function Cannot_pay_baking_bond -> Some () | _ -> None)
|
||||||
|
@ -23,7 +23,7 @@ val paying_priorities: context -> int list
|
|||||||
val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t
|
val minimal_time: context -> int -> Time.t -> Time.t tzresult Lwt.t
|
||||||
(** [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 miner with priority [priority] is allowed to
|
after which a baker with priority [priority] is allowed to
|
||||||
mine. Fail with [Invalid_slot_durations_constant] if the minimal
|
mine. Fail with [Invalid_slot_durations_constant] if the minimal
|
||||||
time cannot be computed. *)
|
time cannot be computed. *)
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ let rpc_services = Services_registration.rpc_services
|
|||||||
type validation_mode =
|
type validation_mode =
|
||||||
| Application of {
|
| Application of {
|
||||||
block_header : Tezos_context.Block_header.t ;
|
block_header : Tezos_context.Block_header.t ;
|
||||||
miner : Tezos_context.public_key_hash ;
|
baker : Tezos_context.public_key_hash ;
|
||||||
}
|
}
|
||||||
| Partial_construction of {
|
| Partial_construction of {
|
||||||
predecessor : Block_hash.t ;
|
predecessor : Block_hash.t ;
|
||||||
@ -35,7 +35,7 @@ type validation_mode =
|
|||||||
| Full_construction of {
|
| Full_construction of {
|
||||||
predecessor : Block_hash.t ;
|
predecessor : Block_hash.t ;
|
||||||
block_proto_header : Tezos_context.Block_header.proto_header ;
|
block_proto_header : Tezos_context.Block_header.proto_header ;
|
||||||
miner : Tezos_context.public_key_hash ;
|
baker : Tezos_context.public_key_hash ;
|
||||||
}
|
}
|
||||||
|
|
||||||
type validation_state =
|
type validation_state =
|
||||||
@ -65,8 +65,8 @@ let begin_application
|
|||||||
let timestamp = block_header.shell.timestamp in
|
let timestamp = block_header.shell.timestamp in
|
||||||
Tezos_context.init ~level ~timestamp ~fitness ctxt >>=? fun ctxt ->
|
Tezos_context.init ~level ~timestamp ~fitness ctxt >>=? fun ctxt ->
|
||||||
Apply.begin_application
|
Apply.begin_application
|
||||||
ctxt block_header pred_timestamp >>=? fun (ctxt, miner) ->
|
ctxt block_header pred_timestamp >>=? fun (ctxt, baker) ->
|
||||||
let mode = Application { block_header ; miner } in
|
let mode = Application { block_header ; baker } in
|
||||||
return { mode ; ctxt ; op_count = 0 }
|
return { mode ; ctxt ; op_count = 0 }
|
||||||
|
|
||||||
let begin_construction
|
let begin_construction
|
||||||
@ -90,27 +90,27 @@ let begin_construction
|
|||||||
| Some proto_header ->
|
| Some proto_header ->
|
||||||
Apply.begin_full_construction
|
Apply.begin_full_construction
|
||||||
ctxt pred_timestamp
|
ctxt pred_timestamp
|
||||||
proto_header >>=? fun (ctxt, block_proto_header, miner) ->
|
proto_header >>=? fun (ctxt, block_proto_header, baker) ->
|
||||||
let mode =
|
let mode =
|
||||||
Full_construction { predecessor ; miner ; block_proto_header } in
|
Full_construction { predecessor ; baker ; block_proto_header } in
|
||||||
return (mode, ctxt)
|
return (mode, ctxt)
|
||||||
end >>=? fun (mode, ctxt) ->
|
end >>=? fun (mode, ctxt) ->
|
||||||
return { mode ; ctxt ; op_count = 0 }
|
return { mode ; ctxt ; op_count = 0 }
|
||||||
|
|
||||||
let apply_operation ({ mode ; ctxt ; op_count } as data) operation =
|
let apply_operation ({ mode ; ctxt ; op_count } as data) operation =
|
||||||
let pred_block, block_prio, miner_contract =
|
let pred_block, block_prio, baker_contract =
|
||||||
match mode with
|
match mode with
|
||||||
| Partial_construction { predecessor } ->
|
| Partial_construction { predecessor } ->
|
||||||
predecessor, 0, None
|
predecessor, 0, None
|
||||||
| Application
|
| Application
|
||||||
{ miner ; block_header = { shell = { predecessor } ;
|
{ baker ; block_header = { shell = { predecessor } ;
|
||||||
proto = block_proto_header } }
|
proto = block_proto_header } }
|
||||||
| Full_construction { predecessor ; block_proto_header ; miner } ->
|
| Full_construction { predecessor ; block_proto_header ; baker } ->
|
||||||
predecessor,
|
predecessor,
|
||||||
block_proto_header.priority,
|
block_proto_header.priority,
|
||||||
Some (Tezos_context.Contract.default_contract miner) in
|
Some (Tezos_context.Contract.default_contract baker) in
|
||||||
Apply.apply_operation
|
Apply.apply_operation
|
||||||
ctxt miner_contract pred_block block_prio operation
|
ctxt baker_contract pred_block block_prio operation
|
||||||
>>=? fun (ctxt, _contracts, _ignored_script_error) ->
|
>>=? fun (ctxt, _contracts, _ignored_script_error) ->
|
||||||
let op_count = op_count + 1 in
|
let op_count = op_count + 1 in
|
||||||
return { data with ctxt ; op_count }
|
return { data with ctxt ; op_count }
|
||||||
@ -120,9 +120,9 @@ let finalize_block { mode ; ctxt ; op_count } = match mode with
|
|||||||
let ctxt = Tezos_context.finalize ctxt in
|
let ctxt = Tezos_context.finalize ctxt in
|
||||||
return ctxt
|
return ctxt
|
||||||
| Application
|
| Application
|
||||||
{ miner ; block_header = { proto = block_proto_header } }
|
{ baker ; block_header = { proto = block_proto_header } }
|
||||||
| Full_construction { block_proto_header ; miner } ->
|
| Full_construction { block_proto_header ; baker } ->
|
||||||
Apply.finalize_application ctxt block_proto_header miner >>=? fun ctxt ->
|
Apply.finalize_application ctxt block_proto_header baker >>=? fun ctxt ->
|
||||||
let { level } : Tezos_context.Level.t =
|
let { level } : Tezos_context.Level.t =
|
||||||
Tezos_context. Level.current ctxt in
|
Tezos_context. Level.current ctxt in
|
||||||
let priority = block_proto_header.priority in
|
let priority = block_proto_header.priority in
|
||||||
|
@ -240,7 +240,7 @@ let () = register1
|
|||||||
minimal_timestamp ctxt slot timestamp)
|
minimal_timestamp ctxt slot timestamp)
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
(* ctxt accept_failing_script miner_contract pred_block block_prio operation *)
|
(* ctxt accept_failing_script baker_contract pred_block block_prio operation *)
|
||||||
register1 Services.Helpers.apply_operation
|
register1 Services.Helpers.apply_operation
|
||||||
(fun ctxt (pred_block, hash, forged_operation, signature) ->
|
(fun ctxt (pred_block, hash, forged_operation, signature) ->
|
||||||
match Data_encoding.Binary.of_bytes
|
match Data_encoding.Binary.of_bytes
|
||||||
@ -250,11 +250,11 @@ let () =
|
|||||||
| Some (shell, contents) ->
|
| Some (shell, contents) ->
|
||||||
let operation = { hash ; shell ; contents ; signature } in
|
let operation = { hash ; shell ; contents ; signature } in
|
||||||
let level = Tezos_context.Level.current ctxt in
|
let level = Tezos_context.Level.current ctxt in
|
||||||
Baking.baking_priorities ctxt level >>=? fun (Misc.LCons (miner_pkh, _)) ->
|
Baking.baking_priorities ctxt level >>=? fun (Misc.LCons (baker_pkh, _)) ->
|
||||||
let miner_contract = Contract.default_contract miner_pkh in
|
let baker_contract = Contract.default_contract baker_pkh in
|
||||||
let block_prio = 0 in
|
let block_prio = 0 in
|
||||||
Apply.apply_operation
|
Apply.apply_operation
|
||||||
ctxt (Some miner_contract) pred_block block_prio operation
|
ctxt (Some baker_contract) pred_block block_prio operation
|
||||||
>>=? function
|
>>=? function
|
||||||
| (_ctxt, _, Some script_err) -> Lwt.return (Error script_err)
|
| (_ctxt, _, Some script_err) -> Lwt.return (Error script_err)
|
||||||
| (_ctxt, contracts, None) -> Lwt.return (Ok contracts)) ;
|
| (_ctxt, contracts, None) -> Lwt.return (Ok contracts)) ;
|
||||||
|
@ -547,7 +547,7 @@ module Rewards = struct
|
|||||||
else cmp1
|
else cmp1
|
||||||
end)(struct
|
end)(struct
|
||||||
type value = Tez_repr.t
|
type value = Tez_repr.t
|
||||||
let name = "level miner contract"
|
let name = "level baker contract"
|
||||||
let encoding = Tez_repr.encoding
|
let encoding = Tez_repr.encoding
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user