Mining -> Baking
This commit is contained in:
parent
6dd9f2289a
commit
1bdae93ffd
@ -8,7 +8,7 @@
|
||||
(**************************************************************************)
|
||||
|
||||
open Client_commands
|
||||
open Logging.Client.Mining
|
||||
open Logging.Client.Baking
|
||||
|
||||
let run cctxt ?max_priority ~delay ?min_date delegates ~endorsement ~denunciation ~baking =
|
||||
(* TODO really detach... *)
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
open Client_commands
|
||||
open Logging.Client.Mining
|
||||
open Logging.Client.Baking
|
||||
|
||||
let generate_proof_of_work_nonce () =
|
||||
Sodium.Random.Bigbytes.generate Constants.proof_of_work_nonce_size
|
||||
@ -32,7 +32,7 @@ let rec forge_block_header
|
||||
let signed_header =
|
||||
Environment.Ed25519.Signature.append delegate_sk unsigned_header in
|
||||
let block_hash = Block_hash.hash_bytes [signed_header] in
|
||||
if Mining.check_hash block_hash stamp_threshold then
|
||||
if Baking.check_hash block_hash stamp_threshold then
|
||||
signed_header
|
||||
else
|
||||
loop () in
|
||||
@ -146,7 +146,7 @@ let forge_block cctxt block
|
||||
with Not_found ->
|
||||
failwith "No slot found at level %a" Raw_level.pp level
|
||||
end >>=? fun (priority, minimal_timestamp) ->
|
||||
(* lwt_log_info "Mining block at level %a prio %d" *)
|
||||
(* lwt_log_info "Baking block at level %a prio %d" *)
|
||||
(* Raw_level.pp level priority >>= fun () -> *)
|
||||
begin
|
||||
match timestamp, minimal_timestamp with
|
||||
|
@ -53,7 +53,7 @@ val forge_block:
|
||||
operations and add them to the block. Otherwise, provided
|
||||
operations will be used. In both cases, they will be validated.
|
||||
|
||||
* Mining priority: If [`Auto] is used, it will be computed from
|
||||
* Baking priority: If [`Auto] is used, it will be computed from
|
||||
the public key hash of the specified contract, optionally capped
|
||||
to a maximum value, and optionnaly restricting for free baking slot.
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
||||
"Script_ir_translator",
|
||||
"Script_interpreter",
|
||||
|
||||
"Mining",
|
||||
"Baking",
|
||||
"Amendment",
|
||||
"Apply",
|
||||
|
||||
|
@ -65,10 +65,10 @@ let apply_delegate_operation_content
|
||||
fail_unless
|
||||
(Block_hash.equal block pred_block)
|
||||
(Wrong_endorsement_predecessor (pred_block, block)) >>=? fun () ->
|
||||
Mining.check_signing_rights ctxt slot delegate >>=? fun () ->
|
||||
Baking.check_signing_rights ctxt slot delegate >>=? fun () ->
|
||||
let ctxt = Fitness.increase ctxt in
|
||||
Mining.pay_endorsement_bond ctxt delegate >>=? fun (ctxt, bond) ->
|
||||
Mining.endorsement_reward ~block_priority >>=? fun reward ->
|
||||
Baking.pay_endorsement_bond ctxt delegate >>=? fun (ctxt, bond) ->
|
||||
Baking.endorsement_reward ~block_priority >>=? fun reward ->
|
||||
let { cycle = current_cycle } : Level.t = Level.current ctxt in
|
||||
Lwt.return Tez.(reward +? bond) >>=? fun full_reward ->
|
||||
Reward.record ctxt delegate current_cycle full_reward
|
||||
@ -249,7 +249,7 @@ let apply_operation
|
||||
return (ctxt, Contract.originated_contracts origination_nonce, err)
|
||||
|
||||
let may_start_new_cycle ctxt =
|
||||
Mining.dawn_of_a_new_cycle ctxt >>=? function
|
||||
Baking.dawn_of_a_new_cycle ctxt >>=? function
|
||||
| None -> return ctxt
|
||||
| Some last_cycle ->
|
||||
let new_cycle = Cycle.succ last_cycle in
|
||||
@ -269,9 +269,9 @@ let begin_full_construction ctxt pred_timestamp proto_header =
|
||||
Lwt.return
|
||||
(Block_header.parse_unsigned_proto_header
|
||||
proto_header) >>=? fun proto_header ->
|
||||
Mining.check_baking_rights
|
||||
Baking.check_baking_rights
|
||||
ctxt proto_header pred_timestamp >>=? fun miner ->
|
||||
Mining.pay_baking_bond ctxt proto_header miner >>=? fun ctxt ->
|
||||
Baking.pay_baking_bond ctxt proto_header miner >>=? fun ctxt ->
|
||||
let ctxt = Fitness.increase ctxt in
|
||||
return (ctxt, proto_header, miner)
|
||||
|
||||
@ -280,19 +280,19 @@ let begin_partial_construction ctxt =
|
||||
return ctxt
|
||||
|
||||
let begin_application ctxt block_header pred_timestamp =
|
||||
Mining.check_proof_of_work_stamp ctxt block_header >>=? fun () ->
|
||||
Mining.check_fitness_gap ctxt block_header >>=? fun () ->
|
||||
Mining.check_baking_rights
|
||||
Baking.check_proof_of_work_stamp ctxt block_header >>=? fun () ->
|
||||
Baking.check_fitness_gap ctxt block_header >>=? fun () ->
|
||||
Baking.check_baking_rights
|
||||
ctxt block_header.proto pred_timestamp >>=? fun miner ->
|
||||
Mining.check_signature ctxt block_header miner >>=? fun () ->
|
||||
Mining.pay_baking_bond ctxt block_header.proto miner >>=? fun ctxt ->
|
||||
Baking.check_signature ctxt block_header miner >>=? fun () ->
|
||||
Baking.pay_baking_bond ctxt block_header.proto miner >>=? fun ctxt ->
|
||||
let ctxt = Fitness.increase ctxt in
|
||||
return (ctxt, miner)
|
||||
|
||||
let finalize_application ctxt block_proto_header miner =
|
||||
(* end of level (from this point nothing should fail) *)
|
||||
let priority = block_proto_header.Block_header.priority in
|
||||
let reward = Mining.base_baking_reward ctxt ~priority in
|
||||
let reward = Baking.base_baking_reward ctxt ~priority in
|
||||
Nonce.record_hash ctxt
|
||||
miner reward block_proto_header.seed_nonce_hash >>=? fun ctxt ->
|
||||
Reward.pay_due_rewards ctxt >>=? fun ctxt ->
|
||||
|
@ -54,7 +54,7 @@ module Header = struct
|
||||
|
||||
let priority custom_root =
|
||||
RPC.service
|
||||
~description: "Mining priority of the block."
|
||||
~description: "Baking priority of the block."
|
||||
~input: empty
|
||||
~output: (wrap_tzerror uint16)
|
||||
RPC.Path.(custom_root / "header" / "priority")
|
||||
|
@ -231,7 +231,7 @@ let () =
|
||||
|
||||
let minimal_timestamp ctxt prio =
|
||||
let prio = match prio with None -> 0 | Some p -> p in
|
||||
Mining.minimal_time ctxt prio
|
||||
Baking.minimal_time ctxt prio
|
||||
|
||||
let () = register1
|
||||
Services.Helpers.minimal_timestamp
|
||||
@ -250,7 +250,7 @@ let () =
|
||||
| Some (shell, contents) ->
|
||||
let operation = { hash ; shell ; contents ; signature } in
|
||||
let level = Tezos_context.Level.current ctxt in
|
||||
Mining.baking_priorities ctxt level >>=? fun (Misc.LCons (miner_pkh, _)) ->
|
||||
Baking.baking_priorities ctxt level >>=? fun (Misc.LCons (miner_pkh, _)) ->
|
||||
let miner_contract = Contract.default_contract miner_pkh in
|
||||
let block_prio = 0 in
|
||||
Apply.apply_operation
|
||||
@ -335,7 +335,7 @@ let default_max_baking_priority ctxt arg =
|
||||
|
||||
let baking_rights ctxt level max =
|
||||
let max = default_max_baking_priority ctxt max in
|
||||
Mining.baking_priorities ctxt level >>=? fun contract_list ->
|
||||
Baking.baking_priorities ctxt level >>=? fun contract_list ->
|
||||
let rec loop l n =
|
||||
match n with
|
||||
| 0 -> return []
|
||||
@ -358,7 +358,7 @@ let () =
|
||||
List.mapi
|
||||
(fun prio c ->
|
||||
let timestamp = Timestamp.current ctxt in
|
||||
Mining.minimal_time ctxt prio timestamp >>= function
|
||||
Baking.minimal_time ctxt prio timestamp >>= function
|
||||
| Error _ -> Lwt.return None
|
||||
| Ok minimal_timestamp -> Lwt.return (Some (c, minimal_timestamp)))
|
||||
slots
|
||||
@ -389,13 +389,13 @@ let baking_rights_for_delegate
|
||||
then return []
|
||||
else
|
||||
loop (Level.succ ctxt level) >>=? fun t ->
|
||||
Mining.first_baking_priorities
|
||||
Baking.first_baking_priorities
|
||||
ctxt ~max_priority contract level >>=? fun priorities ->
|
||||
let raw_level = level.level in
|
||||
Error_monad.map_s
|
||||
(fun priority ->
|
||||
let timestamp = Timestamp.current ctxt in
|
||||
Mining.minimal_time ctxt priority timestamp >>=? fun time ->
|
||||
Baking.minimal_time ctxt priority timestamp >>=? fun time ->
|
||||
return (raw_level, priority, time))
|
||||
priorities >>=? fun priorities ->
|
||||
return (priorities @ t)
|
||||
@ -414,7 +414,7 @@ let default_max_endorsement_priority ctxt arg =
|
||||
|
||||
let endorsement_rights ctxt level max =
|
||||
let max = default_max_endorsement_priority ctxt max in
|
||||
Mining.endorsement_priorities ctxt level >>=? fun contract_list ->
|
||||
Baking.endorsement_priorities ctxt level >>=? fun contract_list ->
|
||||
let rec loop l n =
|
||||
match n with
|
||||
| 0 -> return []
|
||||
@ -453,7 +453,7 @@ let endorsement_rights_for_delegate
|
||||
then return []
|
||||
else
|
||||
loop (Level.succ ctxt level) >>=? fun t ->
|
||||
Mining.first_endorsement_slots
|
||||
Baking.first_endorsement_slots
|
||||
ctxt ~max_priority contract level >>=? fun slots ->
|
||||
let raw_level = level.level in
|
||||
let slots = List.rev_map (fun slot -> (raw_level, slot)) slots in
|
||||
|
@ -84,7 +84,7 @@ module Node = struct
|
||||
end
|
||||
module Client = struct
|
||||
module Blocks = Make(struct let name = "client.blocks" end)
|
||||
module Mining = Make(struct let name = "client.baking" end)
|
||||
module Baking = Make(struct let name = "client.baking" end)
|
||||
module Endorsement = Make(struct let name = "client.endorsement" end)
|
||||
module Revelation = Make(struct let name = "client.revealation" end)
|
||||
module Denunciation = Make(struct let name = "client.denunciation" end)
|
||||
|
@ -39,7 +39,7 @@ module Node : sig
|
||||
end
|
||||
module Client : sig
|
||||
module Blocks : LOG
|
||||
module Mining : LOG
|
||||
module Baking : LOG
|
||||
module Endorsement : LOG
|
||||
module Revelation : LOG
|
||||
module Denunciation : LOG
|
||||
|
@ -388,7 +388,7 @@ module Assert = struct
|
||||
|
||||
let wrong_delegate ~msg =
|
||||
Assert.contain_error ~msg ~f:begin ecoproto_error (function
|
||||
| Mining.Wrong_delegate _ -> true
|
||||
| Baking.Wrong_delegate _ -> true
|
||||
| _ -> false)
|
||||
end
|
||||
|
||||
@ -409,7 +409,7 @@ module Assert = struct
|
||||
|
||||
end
|
||||
|
||||
module Mining = struct
|
||||
module Baking = struct
|
||||
|
||||
let mine block (contract: Account.t) operations =
|
||||
let operations = List.map (fun op -> Client_node_rpcs.Blob op) operations in
|
||||
@ -433,7 +433,7 @@ module Mining = struct
|
||||
|
||||
let endorsement_reward block =
|
||||
Client_proto_rpcs.Header.priority !rpc_config block >>=? fun prio ->
|
||||
Mining.endorsement_reward ~block_priority:prio >|=
|
||||
Baking.endorsement_reward ~block_priority:prio >|=
|
||||
Environment.wrap_error >>|?
|
||||
Tez.to_cents
|
||||
|
||||
|
@ -92,7 +92,7 @@ module Account : sig
|
||||
|
||||
end
|
||||
|
||||
module Mining : sig
|
||||
module Baking : sig
|
||||
|
||||
val mine:
|
||||
Client_node_rpcs.Blocks.block ->
|
||||
|
@ -19,27 +19,27 @@ let default_account =
|
||||
let test_double_endorsement contract block =
|
||||
|
||||
(* Double endorsement for the same level *)
|
||||
Helpers.Mining.mine block contract [] >>=? fun b1 ->
|
||||
Helpers.Baking.mine block contract [] >>=? fun b1 ->
|
||||
|
||||
(* branch root *)
|
||||
Helpers.Mining.mine (`Hash b1) contract [] >>=? fun b2 ->
|
||||
Helpers.Baking.mine (`Hash b1) contract [] >>=? fun b2 ->
|
||||
(* changing branch *)
|
||||
Helpers.Mining.mine (`Hash b1) contract [] >>=? fun b2' ->
|
||||
Helpers.Baking.mine (`Hash b1) contract [] >>=? fun b2' ->
|
||||
|
||||
(* branch root *)
|
||||
Helpers.Endorse.endorse contract (`Hash b2) >>=? fun op ->
|
||||
Helpers.Mining.mine (`Hash b2) contract [ op ] >>=? fun _b3 ->
|
||||
Helpers.Baking.mine (`Hash b2) contract [ op ] >>=? fun _b3 ->
|
||||
|
||||
Helpers.Endorse.endorse contract (`Hash b2') >>=? fun op ->
|
||||
Helpers.Mining.mine (`Hash b2') contract [ op ] >>=? fun b3' ->
|
||||
Helpers.Baking.mine (`Hash b2') contract [ op ] >>=? fun b3' ->
|
||||
|
||||
Helpers.Endorse.endorse contract (`Hash b3') >>=? fun op ->
|
||||
Helpers.Mining.mine (`Hash b3') contract [ op ] >>=? fun b4' ->
|
||||
Helpers.Baking.mine (`Hash b3') contract [ op ] >>=? fun b4' ->
|
||||
|
||||
(* TODO: Inject double endorsement op ! *)
|
||||
Helpers.Mining.mine (`Hash b4') contract []
|
||||
Helpers.Baking.mine (`Hash b4') contract []
|
||||
|
||||
(* FIXME: Mining.Invalid_signature is unclassified *)
|
||||
(* FIXME: Baking.Invalid_signature is unclassified *)
|
||||
let test_invalid_signature block =
|
||||
let public_key =
|
||||
Environment.Ed25519.Public_key.of_b58check_exn
|
||||
@ -50,7 +50,7 @@ let test_invalid_signature block =
|
||||
DYfTKhq7rDQujdn5WWzwUMeV3agaZ6J2vPQT58jJAJPi" in
|
||||
let account =
|
||||
Helpers.Account.create ~keys:(secret_key, public_key) "WRONG SIGNATURE" in
|
||||
Helpers.Mining.mine block account [] >>= fun res ->
|
||||
Helpers.Baking.mine block account [] >>= fun res ->
|
||||
Assert.generic_economic_error ~msg:__LOC__ res ;
|
||||
return ()
|
||||
|
||||
@ -64,34 +64,34 @@ let contain_tzerror ?(msg="") ~f t =
|
||||
let test_wrong_delegate ~miner contract block =
|
||||
begin
|
||||
Helpers.Endorse.endorse ~slot:1 contract block >>=? fun op ->
|
||||
Helpers.Mining.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Baking.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Endorse.endorse ~slot:2 contract block >>=? fun op ->
|
||||
Helpers.Mining.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Baking.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Endorse.endorse ~slot:3 contract block >>=? fun op ->
|
||||
Helpers.Mining.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Baking.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Endorse.endorse ~slot:4 contract block >>=? fun op ->
|
||||
Helpers.Mining.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Baking.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Endorse.endorse ~slot:5 contract block >>=? fun op ->
|
||||
Helpers.Mining.mine block miner [ op ] >>=? fun _ ->
|
||||
Helpers.Baking.mine block miner [ op ] >>=? fun _ ->
|
||||
return ()
|
||||
end >>= fun res ->
|
||||
Assert.failed_to_preapply ~msg:__LOC__ begin function
|
||||
| Mining.Wrong_delegate _ -> true
|
||||
| Baking.Wrong_delegate _ -> true
|
||||
| _ -> false
|
||||
end res ;
|
||||
Lwt.return_unit
|
||||
|
||||
let test_invalid_endorsement_slot contract block =
|
||||
Helpers.Endorse.endorse ~slot:~-1 contract block >>=? fun op ->
|
||||
Helpers.Mining.mine block contract [ op ] >>= fun res ->
|
||||
Helpers.Baking.mine block contract [ op ] >>= fun res ->
|
||||
Assert.failed_to_preapply ~msg:__LOC__ ~op:(Blob op) begin function
|
||||
| Mining.Invalid_endorsement_slot _ -> true
|
||||
| Baking.Invalid_endorsement_slot _ -> true
|
||||
| _ -> false
|
||||
end res ;
|
||||
Helpers.Endorse.endorse ~slot:16 contract block >>=? fun op ->
|
||||
Helpers.Mining.mine block contract [ op ] >>= fun res ->
|
||||
Helpers.Baking.mine block contract [ op ] >>= fun res ->
|
||||
Assert.failed_to_preapply ~msg:__LOC__ ~op:(Blob op) begin function
|
||||
| Mining.Invalid_endorsement_slot _ -> true
|
||||
| Baking.Invalid_endorsement_slot _ -> true
|
||||
| _ -> false
|
||||
end res ;
|
||||
return ()
|
||||
@ -114,7 +114,7 @@ let test_endorsement_rewards block0 =
|
||||
get_endorser_except [ b1 ] accounts >>=? fun (account0, slot0) ->
|
||||
Helpers.Account.balance ~block:block0 account0 >>=? fun balance0 ->
|
||||
Helpers.Endorse.endorse ~slot:slot0 account0 block0 >>=? fun op ->
|
||||
Helpers.Mining.mine block0 b1 [ op ] >>=? fun hash1 ->
|
||||
Helpers.Baking.mine block0 b1 [ op ] >>=? fun hash1 ->
|
||||
Helpers.display_level (`Hash hash1) >>=? fun () ->
|
||||
Assert.balance_equal ~block:(`Hash hash1) ~msg:__LOC__ account0
|
||||
(Int64.sub (Tez.to_cents balance0) bond) >>=? fun () ->
|
||||
@ -125,31 +125,31 @@ let test_endorsement_rewards block0 =
|
||||
get_endorser_except [ b1 ; account0 ] accounts >>=? fun (account1, slot1) ->
|
||||
Helpers.Account.balance ~block:block1 account1 >>=? fun balance1 ->
|
||||
Helpers.Endorse.endorse ~slot:slot1 account1 block1 >>=? fun op ->
|
||||
Helpers.Mining.mine block1 b1 [ op ] >>=? fun hash2 ->
|
||||
Helpers.Baking.mine block1 b1 [ op ] >>=? fun hash2 ->
|
||||
Helpers.display_level (`Hash hash2) >>=? fun () ->
|
||||
Assert.balance_equal ~block:(`Hash hash2) ~msg:__LOC__ account1
|
||||
(Int64.sub (Tez.to_cents balance1) bond) >>=? fun () ->
|
||||
|
||||
(* Check rewards after one cycle for account0 *)
|
||||
Helpers.Mining.mine (`Hash hash2) b1 [] >>=? fun hash3 ->
|
||||
Helpers.Baking.mine (`Hash hash2) b1 [] >>=? fun hash3 ->
|
||||
Helpers.display_level (`Hash hash3) >>=? fun () ->
|
||||
Helpers.Mining.mine (`Hash hash3) b1 [] >>=? fun hash4 ->
|
||||
Helpers.Baking.mine (`Hash hash3) b1 [] >>=? fun hash4 ->
|
||||
Helpers.display_level (`Hash hash4) >>=? fun () ->
|
||||
Helpers.Mining.mine (`Hash hash4) b1 [] >>=? fun hash5 ->
|
||||
Helpers.Baking.mine (`Hash hash4) b1 [] >>=? fun hash5 ->
|
||||
Helpers.display_level (`Hash hash5) >>=? fun () ->
|
||||
Helpers.Mining.endorsement_reward block1 >>=? fun rw0 ->
|
||||
Helpers.Baking.endorsement_reward block1 >>=? fun rw0 ->
|
||||
Assert.balance_equal ~block:(`Hash hash5) ~msg:__LOC__ account0
|
||||
(Int64.add (Tez.to_cents balance0) rw0) >>=? fun () ->
|
||||
|
||||
(* Check rewards after one cycle for account1 *)
|
||||
Helpers.Mining.endorsement_reward (`Hash hash2) >>=? fun rw1 ->
|
||||
Helpers.Baking.endorsement_reward (`Hash hash2) >>=? fun rw1 ->
|
||||
Assert.balance_equal ~block:(`Hash hash5) ~msg:__LOC__ account1
|
||||
(Int64.add (Tez.to_cents balance1) rw1) >>=? fun () ->
|
||||
|
||||
(* #2 endorse and check reward only on the good chain *)
|
||||
Helpers.Mining.mine (`Hash hash5) b1 []>>=? fun hash6a ->
|
||||
Helpers.Baking.mine (`Hash hash5) b1 []>>=? fun hash6a ->
|
||||
Helpers.display_level (`Hash hash6a) >>=? fun () ->
|
||||
Helpers.Mining.mine (`Hash hash5) b1 [] >>=? fun hash6b ->
|
||||
Helpers.Baking.mine (`Hash hash5) b1 [] >>=? fun hash6b ->
|
||||
Helpers.display_level (`Hash hash6b) >>=? fun () ->
|
||||
|
||||
(* working on head *)
|
||||
@ -158,7 +158,7 @@ let test_endorsement_rewards block0 =
|
||||
Helpers.Account.balance ~block:(`Hash hash6a) account3 >>=? fun balance3 ->
|
||||
Helpers.Endorse.endorse
|
||||
~slot:slot3 account3 (`Hash hash6a) >>=? fun ops ->
|
||||
Helpers.Mining.mine (`Hash hash6a) b1 [ ops ] >>=? fun hash7a ->
|
||||
Helpers.Baking.mine (`Hash hash6a) b1 [ ops ] >>=? fun hash7a ->
|
||||
Helpers.display_level (`Hash hash7a) >>=? fun () ->
|
||||
|
||||
(* working on fork *)
|
||||
@ -166,17 +166,17 @@ let test_endorsement_rewards block0 =
|
||||
get_endorser_except [ b1 ] accounts >>=? fun (account4, slot4) ->
|
||||
Helpers.Account.balance ~block:(`Hash hash7a) account4 >>=? fun _balance4 ->
|
||||
Helpers.Endorse.endorse ~slot:slot4 account4 (`Hash hash6b) >>=? fun ops ->
|
||||
Helpers.Mining.mine (`Hash hash6b) b1 [ ops ] >>=? fun _new_fork ->
|
||||
Helpers.Baking.mine (`Hash hash6b) b1 [ ops ] >>=? fun _new_fork ->
|
||||
Helpers.display_level (`Hash _new_fork) >>=? fun () ->
|
||||
Helpers.Account.balance ~block:(`Hash hash7a) account4 >>=? fun balance4 ->
|
||||
|
||||
Helpers.Mining.mine (`Hash hash7a) b1 [] >>=? fun hash8a ->
|
||||
Helpers.Baking.mine (`Hash hash7a) b1 [] >>=? fun hash8a ->
|
||||
Helpers.display_level (`Hash hash8a) >>=? fun () ->
|
||||
Helpers.Mining.mine (`Hash hash8a) b1 [] >>=? fun hash9a ->
|
||||
Helpers.Baking.mine (`Hash hash8a) b1 [] >>=? fun hash9a ->
|
||||
Helpers.display_level (`Hash hash9a) >>=? fun () ->
|
||||
|
||||
(* Check rewards after one cycle *)
|
||||
Helpers.Mining.endorsement_reward (`Hash hash7a) >>=? fun reward ->
|
||||
Helpers.Baking.endorsement_reward (`Hash hash7a) >>=? fun reward ->
|
||||
Assert.balance_equal ~block:(`Hash hash9a) ~msg:__LOC__ account3
|
||||
(Int64.add (Tez.to_cents balance3) reward) >>=? fun () ->
|
||||
|
||||
@ -226,7 +226,7 @@ let run genesis =
|
||||
(* Endorse with a wrong slot : -1 and max (16) *)
|
||||
test_invalid_endorsement_slot b3 genesis >>=? fun () ->
|
||||
|
||||
(* FIXME: Mining.Invalid_signature is still unclassified *)
|
||||
(* FIXME: Baking.Invalid_signature is still unclassified *)
|
||||
test_invalid_signature genesis >>=? fun _ ->
|
||||
|
||||
(* FIXME: cannot inject double endorsement operation yet, but the
|
||||
|
@ -12,7 +12,7 @@ module Assert = Helpers.Assert
|
||||
|
||||
let run blkid ({ b1 ; b2 ; _ } : Helpers.Account.bootstrap_accounts) =
|
||||
|
||||
Helpers.Mining.mine blkid b1 [] >>=? fun blkh ->
|
||||
Helpers.Baking.mine blkid b1 [] >>=? fun blkh ->
|
||||
let foo = Helpers.Account.create "foo" in
|
||||
|
||||
(* Origination with amount = 0 tez *)
|
||||
|
@ -12,7 +12,7 @@ module Assert = Helpers.Assert
|
||||
|
||||
let run blkid ({ b1 ; b2 ; b3 ; _ } : Helpers.Account.bootstrap_accounts) =
|
||||
|
||||
Helpers.Mining.mine blkid b1 [] >>=? fun blkh ->
|
||||
Helpers.Baking.mine blkid b1 [] >>=? fun blkh ->
|
||||
let foo = Helpers.Account.create "foo" in
|
||||
let bar = Helpers.Account.create "bar" in
|
||||
|
||||
|
@ -20,11 +20,11 @@ let print_level head =
|
||||
|
||||
let run_change_to_demo_proto block
|
||||
({ b1 ; b2 ; b3 ; b4 ; b5 } : Account.bootstrap_accounts) =
|
||||
Mining.mine block b1 [] >>=? fun head ->
|
||||
Baking.mine block b1 [] >>=? fun head ->
|
||||
Format.eprintf "Entering `Proposal` voting period@.";
|
||||
Assert.check_voting_period_kind ~msg:__LOC__ ~block:(`Hash head)
|
||||
Voting_period.Proposal >>=? fun () ->
|
||||
Mining.mine (`Hash head) b2 [] >>=? fun head ->
|
||||
Baking.mine (`Hash head) b2 [] >>=? fun head ->
|
||||
|
||||
(* 1. Propose the 'demo' protocol as b1 (during the Proposal period) *)
|
||||
Protocol.proposals
|
||||
@ -33,9 +33,9 @@ let run_change_to_demo_proto block
|
||||
[demo_protocol] >>=? fun op ->
|
||||
|
||||
(* Mine blocks to switch to next vote period (Testing_vote) *)
|
||||
Mining.mine (`Hash head) b3 [op] >>=? fun head ->
|
||||
Baking.mine (`Hash head) b3 [op] >>=? fun head ->
|
||||
Format.eprintf "Entering `Testing_vote` voting period@.";
|
||||
Mining.mine (`Hash head) b4 [] >>=? fun head ->
|
||||
Baking.mine (`Hash head) b4 [] >>=? fun head ->
|
||||
Assert.check_voting_period_kind ~msg:__LOC__ ~block:(`Hash head)
|
||||
Voting_period.Testing_vote >>=? fun () ->
|
||||
|
||||
@ -54,18 +54,18 @@ let run_change_to_demo_proto block
|
||||
all_accounts >>=? fun operations ->
|
||||
|
||||
(* Mine blocks to switch to next vote period (Testing) *)
|
||||
Mining.mine (`Hash head) b5 operations >>=? fun head ->
|
||||
Baking.mine (`Hash head) b5 operations >>=? fun head ->
|
||||
Format.eprintf "Entering `Testing` voting period@.";
|
||||
Mining.mine (`Hash head) b1 [] >>=? fun head ->
|
||||
Baking.mine (`Hash head) b1 [] >>=? fun head ->
|
||||
Assert.check_voting_period_kind ~msg:__LOC__ ~block:(`Hash head)
|
||||
Voting_period.Testing >>=? fun () ->
|
||||
|
||||
(* 3. Test the proposed protocol *)
|
||||
|
||||
(* Mine blocks to switch to next vote period (Promote_vote) *)
|
||||
Mining.mine (`Hash head) b2 [] >>=? fun head ->
|
||||
Baking.mine (`Hash head) b2 [] >>=? fun head ->
|
||||
Format.eprintf "Entering `Promote_vote` voting period@.";
|
||||
Mining.mine (`Hash head) b3 [] >>=? fun head ->
|
||||
Baking.mine (`Hash head) b3 [] >>=? fun head ->
|
||||
Assert.check_voting_period_kind ~msg:__LOC__ ~block:(`Hash head)
|
||||
Voting_period.Promotion_vote >>=? fun () ->
|
||||
|
||||
@ -75,8 +75,8 @@ let run_change_to_demo_proto block
|
||||
|
||||
(* Mine blocks to switch to end the vote cycle (back to Proposal) *)
|
||||
Format.eprintf "Switching to `demo` protocol@.";
|
||||
Mining.mine (`Hash head) b4 operations >>=? fun head ->
|
||||
Mining.mine (`Hash head) b5 [] >>=? fun head ->
|
||||
Baking.mine (`Hash head) b4 operations >>=? fun head ->
|
||||
Baking.mine (`Hash head) b5 [] >>=? fun head ->
|
||||
|
||||
Assert.check_protocol
|
||||
~msg:__LOC__ ~block:(`Hash head) demo_protocol >>=? fun () ->
|
||||
|
@ -337,10 +337,10 @@ init_with_transfer $CONTRACT_PATH/transfer_to.tz $key2 Unit 1000 bootstrap1
|
||||
assert_balance test_transfer_account1 "100.00 ꜩ"
|
||||
$client transfer 100 from bootstrap1 to transfer_to \
|
||||
-arg "\"$(get_contract_addr test_transfer_account1)\""
|
||||
assert_balance test_transfer_account1 "200.00 ꜩ" # Why isn't this 200 ꜩ? Mining fee?
|
||||
assert_balance test_transfer_account1 "200.00 ꜩ" # Why isn't this 200 ꜩ? Baking fee?
|
||||
$client transfer 100 from bootstrap1 to transfer_to \
|
||||
-arg "\"$(get_contract_addr test_transfer_account2)\""
|
||||
assert_balance test_transfer_account2 "120.00 ꜩ" # Why isn't this 120 ꜩ? Mining fee?
|
||||
assert_balance test_transfer_account2 "120.00 ꜩ" # Why isn't this 120 ꜩ? Baking fee?
|
||||
|
||||
# Tests create_account
|
||||
init_with_transfer $CONTRACT_PATH/create_account.tz $key2 \
|
||||
|
Loading…
Reference in New Issue
Block a user