Alpha/Baker: use picotez for minimal_fees_per_{gas_unit,byte}
This commit is contained in:
parent
e3111bc574
commit
ee722a237a
@ -256,25 +256,23 @@ let minimal_fees_arg =
|
||||
| Some t -> return t
|
||||
| None -> fail (Bad_minimal_fees s)))
|
||||
|
||||
let minimal_fees_per_gas_unit_arg =
|
||||
let minimal_picotez_per_gas_unit_arg =
|
||||
arg
|
||||
~long:"minimal-fees-per-gas-unit"
|
||||
~long:"minimal-picotez-per-gas-unit"
|
||||
~placeholder:"amount"
|
||||
~doc:"exclude operations with fees per gas lower than this threshold (in tez)"
|
||||
~doc:"exclude operations with fees per gas lower than this threshold (in picotez)"
|
||||
(parameter (fun _ s ->
|
||||
match Tez.of_string s with
|
||||
| Some t -> return t
|
||||
| None -> fail (Bad_minimal_fees s)))
|
||||
try return (Z.of_string s)
|
||||
with _ -> fail (Bad_minimal_fees s)))
|
||||
|
||||
let minimal_fees_per_byte_arg =
|
||||
let minimal_picotez_per_byte_arg =
|
||||
arg
|
||||
~long:"minimal-fees-per-byte"
|
||||
~long:"minimal-picotez-per-byte"
|
||||
~placeholder:"amount"
|
||||
~doc:"exclude operations with fees per byte lower than this threshold (in tez)"
|
||||
(parameter (fun _ s ->
|
||||
match Tez.of_string s with
|
||||
| Some t -> return t
|
||||
| None -> fail (Bad_minimal_fees s)))
|
||||
try return (Z.of_string s)
|
||||
with _ -> fail (Bad_minimal_fees s)))
|
||||
|
||||
let no_waiting_for_endorsements_arg =
|
||||
switch
|
||||
|
@ -41,8 +41,8 @@ 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 minimal_fees_arg: (Tez.tez option, Proto_alpha.full) Clic.arg
|
||||
val minimal_fees_per_gas_unit_arg: (Tez.tez option, Proto_alpha.full) Clic.arg
|
||||
val minimal_fees_per_byte_arg: (Tez.tez option, Proto_alpha.full) Clic.arg
|
||||
val minimal_picotez_per_gas_unit_arg: (Z.t option, Proto_alpha.full) Clic.arg
|
||||
val minimal_picotez_per_byte_arg: (Z.t option, Proto_alpha.full) Clic.arg
|
||||
val no_waiting_for_endorsements_arg: (bool, Proto_alpha.full) Clic.arg
|
||||
val await_endorsements_arg: (bool, Proto_alpha.full) Clic.arg
|
||||
val force_switch: (bool, Proto_alpha.full) Clic.arg
|
||||
|
@ -41,9 +41,8 @@ let managers_index = 3
|
||||
|
||||
let default_max_priority = 64
|
||||
let default_minimal_fees = Tez.zero
|
||||
let default_minimal_fees_per_gas_unit =
|
||||
Option.unopt_exn (Failure "bad conversion") (Tez.of_mutez 10L)
|
||||
let default_minimal_fees_per_byte = Tez.zero
|
||||
let default_minimal_picotez_per_gas_unit = Z.of_int 10000
|
||||
let default_minimal_picotez_per_byte = Z.zero
|
||||
let default_await_endorsements = true
|
||||
|
||||
type state = {
|
||||
@ -57,9 +56,9 @@ type state = {
|
||||
(* Minimal operation fee required to include an operation in a block *)
|
||||
minimal_fees : Tez.t ;
|
||||
(* Minimal operation fee per gas required to include an operation in a block *)
|
||||
minimal_fees_per_gas_unit : Tez.t ;
|
||||
minimal_picotez_per_gas_unit : Z.t ;
|
||||
(* Minimal operation fee per byte required to include an operation in a block *)
|
||||
minimal_fees_per_byte : Tez.t ;
|
||||
minimal_picotez_per_byte : Z.t ;
|
||||
(* Await endorsements *)
|
||||
await_endorsements: bool ;
|
||||
(* truly mutable *)
|
||||
@ -68,8 +67,8 @@ type state = {
|
||||
|
||||
let create_state
|
||||
?(minimal_fees = default_minimal_fees)
|
||||
?(minimal_fees_per_gas_unit = default_minimal_fees_per_gas_unit)
|
||||
?(minimal_fees_per_byte = default_minimal_fees_per_byte)
|
||||
?(minimal_picotez_per_gas_unit = default_minimal_picotez_per_gas_unit)
|
||||
?(minimal_picotez_per_byte = default_minimal_picotez_per_byte)
|
||||
?(await_endorsements = default_await_endorsements)
|
||||
genesis context_path index delegates constants =
|
||||
{ genesis ;
|
||||
@ -78,8 +77,8 @@ let create_state
|
||||
delegates ;
|
||||
constants ;
|
||||
minimal_fees ;
|
||||
minimal_fees_per_gas_unit ;
|
||||
minimal_fees_per_byte ;
|
||||
minimal_picotez_per_gas_unit ;
|
||||
minimal_picotez_per_byte ;
|
||||
await_endorsements ;
|
||||
best_slot = None ;
|
||||
}
|
||||
@ -192,8 +191,8 @@ let sort_manager_operations
|
||||
~max_size
|
||||
~hard_gas_limit_per_block
|
||||
~minimal_fees
|
||||
~minimal_fees_per_gas_unit
|
||||
~minimal_fees_per_byte
|
||||
~minimal_picotez_per_gas_unit
|
||||
~minimal_picotez_per_byte
|
||||
(operations : Proto_alpha.operation list) =
|
||||
let compute_weight op (fee, gas) =
|
||||
let size = Data_encoding.Binary.length Operation.encoding op in
|
||||
@ -212,15 +211,17 @@ let sort_manager_operations
|
||||
else
|
||||
let (size, gas, _ratio) as weight = compute_weight op (fee, gas) in
|
||||
let open Alpha_environment in
|
||||
let enough_gas_fees =
|
||||
match Tez.(minimal_fees_per_gas_unit *? Z.to_int64 gas) with
|
||||
| Ok expected_fees -> Tez.(expected_fees <= fee)
|
||||
| _ -> false in
|
||||
let enough_size_fees =
|
||||
match Tez.(minimal_fees_per_byte *? Int64.of_int size) with
|
||||
| Ok fee_per_byte -> Tez.(fee_per_byte >= minimal_fees_per_byte)
|
||||
| Error _ -> false in
|
||||
if enough_size_fees && enough_gas_fees then
|
||||
let fees_in_picotez =
|
||||
Z.mul (Z.of_int64 (Tez.to_mutez fee)) (Z.of_int 1000) in
|
||||
let enough_fees_for_gas =
|
||||
let minimal_fees_in_picotez =
|
||||
Z.mul minimal_picotez_per_gas_unit gas in
|
||||
Z.compare minimal_fees_in_picotez fees_in_picotez <= 0 in
|
||||
let enough_fees_for_size =
|
||||
let minimal_fees_in_picotez =
|
||||
Z.mul minimal_picotez_per_byte (Z.of_int size) in
|
||||
Z.compare minimal_fees_in_picotez fees_in_picotez <= 0 in
|
||||
if enough_fees_for_size && enough_fees_for_gas then
|
||||
return_some (op, weight)
|
||||
else
|
||||
return_none
|
||||
@ -283,8 +284,8 @@ let classify_operations
|
||||
~block
|
||||
~hard_gas_limit_per_block
|
||||
~minimal_fees
|
||||
~minimal_fees_per_gas_unit
|
||||
~minimal_fees_per_byte
|
||||
~minimal_picotez_per_gas_unit
|
||||
~minimal_picotez_per_byte
|
||||
(ops: Proto_alpha.operation list) =
|
||||
Alpha_block_services.live_blocks cctxt ~chain:`Main ~block ()
|
||||
>>=? fun live_blocks ->
|
||||
@ -311,8 +312,8 @@ let classify_operations
|
||||
~max_size
|
||||
~hard_gas_limit_per_block
|
||||
~minimal_fees
|
||||
~minimal_fees_per_gas_unit
|
||||
~minimal_fees_per_byte
|
||||
~minimal_picotez_per_gas_unit
|
||||
~minimal_picotez_per_byte
|
||||
manager_operations
|
||||
>>=? fun ordered_operations ->
|
||||
(* Greedy heuristic *)
|
||||
@ -574,8 +575,8 @@ let forge_block
|
||||
?(best_effort = operations = None)
|
||||
?(sort = best_effort)
|
||||
?(minimal_fees = default_minimal_fees)
|
||||
?(minimal_fees_per_gas_unit = default_minimal_fees_per_gas_unit)
|
||||
?(minimal_fees_per_byte = default_minimal_fees_per_byte)
|
||||
?(minimal_picotez_per_gas_unit = default_minimal_picotez_per_gas_unit)
|
||||
?(minimal_picotez_per_byte = default_minimal_picotez_per_byte)
|
||||
?(await_endorsements = default_await_endorsements)
|
||||
?timestamp
|
||||
?mempool
|
||||
@ -598,8 +599,8 @@ let forge_block
|
||||
~hard_gas_limit_per_block
|
||||
~block:block
|
||||
~minimal_fees
|
||||
~minimal_fees_per_gas_unit
|
||||
~minimal_fees_per_byte
|
||||
~minimal_picotez_per_gas_unit
|
||||
~minimal_picotez_per_byte
|
||||
operations_arg
|
||||
>>=? fun (operations, overflowing_ops) ->
|
||||
(* Ensure that we retain operations up to the quota *)
|
||||
@ -649,8 +650,8 @@ let forge_block
|
||||
best_slot = None ;
|
||||
await_endorsements ;
|
||||
minimal_fees = default_minimal_fees ;
|
||||
minimal_fees_per_gas_unit = default_minimal_fees_per_gas_unit ;
|
||||
minimal_fees_per_byte = default_minimal_fees_per_byte ;
|
||||
minimal_picotez_per_gas_unit = default_minimal_picotez_per_gas_unit ;
|
||||
minimal_picotez_per_byte = default_minimal_picotez_per_byte ;
|
||||
} in
|
||||
filter_and_apply_operations ~timestamp ~protocol_data state bi (operations, overflowing_ops)
|
||||
>>=? fun (final_context, validation_result, operations) ->
|
||||
@ -881,8 +882,8 @@ let build_block
|
||||
classify_operations cctxt
|
||||
~hard_gas_limit_per_block
|
||||
~minimal_fees:state.minimal_fees
|
||||
~minimal_fees_per_gas_unit:state.minimal_fees_per_gas_unit
|
||||
~minimal_fees_per_byte:state.minimal_fees_per_byte
|
||||
~minimal_picotez_per_gas_unit:state.minimal_picotez_per_gas_unit
|
||||
~minimal_picotez_per_byte:state.minimal_picotez_per_byte
|
||||
~block operations
|
||||
>>=? fun (operations, overflowing_ops) ->
|
||||
let next_version =
|
||||
@ -1158,8 +1159,8 @@ let reveal_potential_nonces cctxt new_head =
|
||||
let create
|
||||
(cctxt : #Proto_alpha.full)
|
||||
?minimal_fees
|
||||
?minimal_fees_per_gas_unit
|
||||
?minimal_fees_per_byte
|
||||
?minimal_picotez_per_gas_unit
|
||||
?minimal_picotez_per_byte
|
||||
?await_endorsements
|
||||
?max_priority
|
||||
~context_path
|
||||
@ -1171,7 +1172,7 @@ let create
|
||||
Client_baking_simulator.load_context ~context_path >>= fun index ->
|
||||
Client_baking_simulator.check_context_consistency index bi.context >>=? fun () ->
|
||||
let state = create_state
|
||||
?minimal_fees ?minimal_fees_per_gas_unit ?minimal_fees_per_byte
|
||||
?minimal_fees ?minimal_picotez_per_gas_unit ?minimal_picotez_per_byte
|
||||
?await_endorsements
|
||||
genesis_hash context_path index delegates constants in
|
||||
return state
|
||||
|
@ -72,8 +72,8 @@ val forge_block:
|
||||
?best_effort:bool ->
|
||||
?sort:bool ->
|
||||
?minimal_fees: Tez.t ->
|
||||
?minimal_fees_per_gas_unit: Tez.t ->
|
||||
?minimal_fees_per_byte: Tez.t ->
|
||||
?minimal_picotez_per_gas_unit: Z.t ->
|
||||
?minimal_picotez_per_byte: Z.t ->
|
||||
?await_endorsements: bool ->
|
||||
?timestamp:Time.t ->
|
||||
?mempool:string ->
|
||||
@ -107,8 +107,8 @@ val forge_block:
|
||||
val create:
|
||||
#Proto_alpha.full ->
|
||||
?minimal_fees: Tez.t ->
|
||||
?minimal_fees_per_gas_unit: Tez.t ->
|
||||
?minimal_fees_per_byte: Tez.t ->
|
||||
?minimal_picotez_per_gas_unit: Z.t ->
|
||||
?minimal_picotez_per_byte: Z.t ->
|
||||
?await_endorsements: bool ->
|
||||
?max_priority: int ->
|
||||
context_path: string ->
|
||||
|
@ -30,8 +30,8 @@ let bake_block
|
||||
(cctxt : #Proto_alpha.full)
|
||||
?(chain = `Main)
|
||||
?minimal_fees
|
||||
?minimal_fees_per_gas_unit
|
||||
?minimal_fees_per_byte
|
||||
?minimal_picotez_per_gas_unit
|
||||
?minimal_picotez_per_byte
|
||||
?(await_endorsements = false)
|
||||
?force
|
||||
?max_priority
|
||||
@ -68,8 +68,8 @@ let bake_block
|
||||
Client_baking_forge.forge_block cctxt
|
||||
?force
|
||||
?minimal_fees
|
||||
?minimal_fees_per_gas_unit
|
||||
?minimal_fees_per_byte
|
||||
?minimal_picotez_per_gas_unit
|
||||
?minimal_picotez_per_byte
|
||||
~await_endorsements
|
||||
?timestamp:(if minimal_timestamp then None else Some (Time.now ()))
|
||||
?seed_nonce_hash
|
||||
|
@ -31,8 +31,8 @@ val bake_block:
|
||||
#Proto_alpha.full ->
|
||||
?chain:Chain_services.chain ->
|
||||
?minimal_fees: Tez.t ->
|
||||
?minimal_fees_per_gas_unit: Tez.t ->
|
||||
?minimal_fees_per_byte: Tez.t ->
|
||||
?minimal_picotez_per_gas_unit: Z.t ->
|
||||
?minimal_picotez_per_byte: Z.t ->
|
||||
?await_endorsements: bool ->
|
||||
?force:bool ->
|
||||
?max_priority: int ->
|
||||
|
@ -49,8 +49,8 @@ module Baker = struct
|
||||
let run
|
||||
(cctxt : #Proto_alpha.full)
|
||||
?minimal_fees
|
||||
?minimal_fees_per_gas_unit
|
||||
?minimal_fees_per_byte
|
||||
?minimal_picotez_per_gas_unit
|
||||
?minimal_picotez_per_byte
|
||||
?await_endorsements
|
||||
?max_priority
|
||||
~context_path
|
||||
@ -62,8 +62,8 @@ module Baker = struct
|
||||
cctxt#message "Baker started." >>= fun () ->
|
||||
Client_baking_forge.create cctxt
|
||||
?minimal_fees
|
||||
?minimal_fees_per_gas_unit
|
||||
?minimal_fees_per_byte
|
||||
?minimal_picotez_per_gas_unit
|
||||
?minimal_picotez_per_byte
|
||||
?await_endorsements
|
||||
?max_priority
|
||||
~context_path delegates block_stream >>=? fun () ->
|
||||
|
@ -37,8 +37,8 @@ module Baker : sig
|
||||
val run:
|
||||
#Proto_alpha.full ->
|
||||
?minimal_fees: Tez.t ->
|
||||
?minimal_fees_per_gas_unit: Tez.t ->
|
||||
?minimal_fees_per_byte: Tez.t ->
|
||||
?minimal_picotez_per_gas_unit: Z.t ->
|
||||
?minimal_picotez_per_byte: Z.t ->
|
||||
?await_endorsements: bool ->
|
||||
?max_priority: int ->
|
||||
context_path: string ->
|
||||
|
@ -58,8 +58,8 @@ let delegate_commands () =
|
||||
(args9
|
||||
max_priority_arg
|
||||
minimal_fees_arg
|
||||
minimal_fees_per_gas_unit_arg
|
||||
minimal_fees_per_byte_arg
|
||||
minimal_picotez_per_gas_unit_arg
|
||||
minimal_picotez_per_byte_arg
|
||||
await_endorsements_arg
|
||||
force_switch
|
||||
minimal_timestamp_switch
|
||||
@ -70,14 +70,14 @@ let delegate_commands () =
|
||||
~name:"baker" ~desc: "name of the delegate owning the baking right"
|
||||
@@ stop)
|
||||
(fun (max_priority, minimal_fees,
|
||||
minimal_fees_per_gas_unit, minimal_fees_per_byte,
|
||||
minimal_picotez_per_gas_unit, minimal_picotez_per_byte,
|
||||
await_endorsements, force,
|
||||
minimal_timestamp, mempool, context_path)
|
||||
delegate cctxt ->
|
||||
bake_block cctxt cctxt#block
|
||||
?minimal_fees
|
||||
?minimal_fees_per_gas_unit
|
||||
?minimal_fees_per_byte
|
||||
?minimal_picotez_per_gas_unit
|
||||
?minimal_picotez_per_byte
|
||||
~await_endorsements
|
||||
~force ?max_priority ~minimal_timestamp
|
||||
?mempool ?context_path delegate) ;
|
||||
@ -113,8 +113,8 @@ let baker_commands () =
|
||||
(args5
|
||||
max_priority_arg
|
||||
minimal_fees_arg
|
||||
minimal_fees_per_gas_unit_arg
|
||||
minimal_fees_per_byte_arg
|
||||
minimal_picotez_per_gas_unit_arg
|
||||
minimal_picotez_per_byte_arg
|
||||
no_waiting_for_endorsements_arg)
|
||||
(prefixes [ "run" ; "with" ; "local" ; "node" ]
|
||||
@@ param
|
||||
@ -122,15 +122,15 @@ let baker_commands () =
|
||||
~desc:"Path to the node data directory (e.g. $HOME/.tezos-node)"
|
||||
directory_parameter
|
||||
@@ seq_of_param Client_keys.Public_key_hash.alias_param)
|
||||
(fun (max_priority, minimal_fees, minimal_fees_per_gas_unit,
|
||||
minimal_fees_per_byte, no_waiting_for_endorsements)
|
||||
(fun (max_priority, minimal_fees, minimal_picotez_per_gas_unit,
|
||||
minimal_picotez_per_byte, no_waiting_for_endorsements)
|
||||
node_path delegates cctxt ->
|
||||
Tezos_signer_backends.Encrypted.decrypt_list
|
||||
cctxt (List.map fst delegates) >>=? fun () ->
|
||||
Client_daemon.Baker.run cctxt
|
||||
?minimal_fees
|
||||
?minimal_fees_per_gas_unit
|
||||
?minimal_fees_per_byte
|
||||
?minimal_picotez_per_gas_unit
|
||||
?minimal_picotez_per_byte
|
||||
?max_priority
|
||||
~await_endorsements:(not no_waiting_for_endorsements)
|
||||
~context_path:(Filename.concat node_path "context")
|
||||
|
Loading…
Reference in New Issue
Block a user