Skip to content

Commit

Permalink
code not yet compiling, all nodes in network are now stored as maps a…
Browse files Browse the repository at this point in the history
…nd not lists, also genesis keys are in maps
  • Loading branch information
QuiteStochastic committed Feb 3, 2023
1 parent 6271167 commit 57e4e03
Show file tree
Hide file tree
Showing 7 changed files with 455 additions and 248 deletions.
49 changes: 38 additions & 11 deletions src/app/test_executive/payments_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
(* TODO: test snark work *)
let config =
let open Test_config in
let open Test_config.Wallet in
(* let open Test_config.Wallet in *)
let make_timing ~min_balance ~cliff_time ~cliff_amount ~vesting_period
~vesting_increment : Mina_base.Account_timing.t =
let open Currency in
Expand All @@ -36,24 +36,51 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
in
{ default with
requires_graphql = true
; block_producers =
[ { balance = "400000"; timing = Untimed } (* 400_000_000_000_000 *)
; { balance = "300000"; timing = Untimed } (* 300_000_000_000_000 *)
; { balance = "30000"
; genesis_ledger =
[ { account_name = "block-producer1-key"
; balance = "400000"
; timing = Untimed
}
; { account_name = "block-producer2-key"
; balance = "300000"
; timing = Untimed
}
; { account_name = "block-producer3-key"
; balance = "30000"
; timing =
make_timing ~min_balance:10_000_000_000_000 ~cliff_time:8
~cliff_amount:0 ~vesting_period:4
~vesting_increment:5_000_000_000_000
}
(* 30_000_000_000_000 mina is the total. initially, the balance will be 10k mina. after 8 global slots, the cliff is hit, although the cliff amount is 0. 4 slots after that, 5_000_000_000_000 mina will vest, and 4 slots after that another 5_000_000_000_000 will vest, and then twice again, for a total of 30k mina all fully liquid and unlocked at the end of the schedule*)
; { account_name = "snark-node-key"
; balance = "1000"
; timing = Untimed
}
; { account_name = "extra1"; balance = "1000"; timing = Untimed }
; { account_name = "extra2"; balance = "1000"; timing = Untimed }
]
; extra_genesis_accounts =
[ { balance = "1000"; timing = Untimed }
; { balance = "1000"; timing = Untimed }
; block_producers =
[ { node_name = "block-producer1"
; account_name = "block-producer1-key"
}
(* 400_000_000_000_000 *)
; { node_name = "block-producer2"
; account_name = "block-producer2-key"
}
(* 300_000_000_000_000 *)
; { node_name = "block-producer3"
; account_name = "block-producer3-key"
}
(* 30_000_000_000_000 mina is the total. initially, the balance will be 10k mina. after 8 global slots, the cliff is hit, although the cliff amount is 0. 4 slots after that, 5_000_000_000_000 mina will vest, and 4 slots after that another 5_000_000_000_000 will vest, and then twice again, for a total of 30k mina all fully liquid and unlocked at the end of the schedule*)
]
; num_archive_nodes = 1
; num_snark_workers = 4
; snark_worker =
Some
{ node_name = "snark-node"
; account_name = "snark-node-key"
; replicas = 4
}
; snark_worker_fee = "0.0001"
; num_archive_nodes = 1
; proof_config =
{ proof_config_default with
work_delay = Some 1
Expand Down
73 changes: 53 additions & 20 deletions src/app/test_executive/snark_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,39 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
}
}

(*
TODO, new config format should look like
let config =
let open Test_config in
let open Test_config.Wallet in
{ default with
requires_graphql = true
; genesis_ledger = [
{ key_name = "bp1_key"; balance = "400000"; timing = Untimed }
; { key_name = "bp2_key"; balance = "300000"; timing = Untimed }
; { key_name = "extra1_key"; balance = "1000"; timing = Untimed }
; { key_name = "extra2_key"; balance = "1000"; timing = Untimed }
; { key_name = "snark_worker1_key"; balance = "10"; timing = Untimed }
]
; block_producers =
[ { node_name = "bp1"; node_key_name = "bp1_key" }
; { node_name = "bp2"; node_key_name = "bp2_key" }
]
; num_archive_nodes = 0
; snark_workers = [
{ node_name = "snark_worker"; node_key_name = "snark_worker1_key"; replicas = 4 }
]
; snark_worker_fee = "0.0001"
; proof_config =
{ proof_config_default with
work_delay = Some 1
; transaction_capacity =
Some Runtime_config.Proof_keys.Transaction_capacity.small
}
}
*)

let run network t =
let open Malleable_error.Let_syntax in
let logger = Logger.create () in
Expand All @@ -67,7 +100,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let sender_pub_key =
sender_kp.public_key |> Signature_lib.Public_key.compress
in

(* let snark_worker_pk = Test_config.default.snark_worker_public_key in *)
let%bind () =
section_hard
"send out a bunch more txns to fill up the snark ledger, then wait for \
Expand Down Expand Up @@ -96,25 +129,25 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
wait_for t
(Wait_condition.ledger_proofs_emitted_since_genesis ~num_proofs:1) )
in
let%bind () =
section_hard "check snark worker's account balance"
(let%bind { total_balance = snark_worker_balance; _ } =
Network.Node.must_get_account_data ~logger untimed_node_b
~public_key:Test_config.default.snark_worker_public_key
in
if
Currency.Amount.( >= )
(Currency.Balance.to_amount snark_worker_balance)
snark_worker_expected
then Malleable_error.return ()
else
Malleable_error.soft_error_format ~value:()
"Error with snark_worker_balance. snark_worker_balance is %d and \
should be %d. snark fee is %d"
(Currency.Balance.to_int snark_worker_balance)
(Currency.Amount.to_int snark_worker_expected)
(Currency.Fee.to_int fee) )
in
(* let%bind () =
section_hard "check snark worker's account balance"
(let%bind { total_balance = snark_worker_balance; _ } =
Network.Node.must_get_account_data ~logger untimed_node_b
~public_key:snark_worker_pk
in
if
Currency.Amount.( >= )
(Currency.Balance.to_amount snark_worker_balance)
snark_worker_expected
then Malleable_error.return ()
else
Malleable_error.soft_error_format ~value:()
"Error with snark_worker_balance. snark_worker_balance is %d and \
should be %d. snark fee is %d"
(Currency.Balance.to_int snark_worker_balance)
(Currency.Amount.to_int snark_worker_expected)
(Currency.Fee.to_int fee) )
in *)
section_hard "dfasdfdasf"
(let%bind hash =
let%map { hash; _ } =
Expand Down
File renamed without changes.
62 changes: 32 additions & 30 deletions src/lib/integration_test_cloud_engine/kubernetes_network.ml
Original file line number Diff line number Diff line change
Expand Up @@ -834,15 +834,14 @@ end
type t =
{ namespace : string
; constants : Test_config.constants
; seeds : Node.t list
; block_producers : Node.t list
; snark_coordinators : Node.t list
; snark_workers : Node.t list
; archive_nodes : Node.t list
; testnet_log_filter : string (* ; keypairs : Signature_lib.Keypair.t list *)
; block_producer_keypairs : Signature_lib.Keypair.t list
; extra_genesis_keypairs : Signature_lib.Keypair.t list
; nodes_by_pod_id : Node.t String.Map.t
; seeds : Node.t Core.String.Map.t
; block_producers : Node.t Core.String.Map.t
; snark_coordinators : Node.t Core.String.Map.t
; snark_workers : Node.t Core.String.Map.t
; archive_nodes : Node.t Core.String.Map.t
; nodes_by_pod_id : Node.t Core.String.Map.t
; testnet_log_filter : string
; genesis_keypairs : Network_keypair.t Core.String.Map.t
}

let constants { constants; _ } = constants
Expand All @@ -863,34 +862,37 @@ let archive_nodes { archive_nodes; _ } = archive_nodes

(* all_nodes returns all *actual* mina nodes; note that a snark_worker is a pod within the network but not technically a mina node, therefore not included here. snark coordinators on the other hand ARE mina nodes *)
let all_nodes { seeds; block_producers; snark_coordinators; archive_nodes; _ } =
List.concat [ seeds; block_producers; snark_coordinators; archive_nodes ]
List.concat
[ Core.String.Map.to_alist seeds
; Core.String.Map.to_alist block_producers
; Core.String.Map.to_alist snark_coordinators
; Core.String.Map.to_alist archive_nodes
]
|> Core.String.Map.of_alist_exn

(* all_pods returns everything in the network. remember that snark_workers will never initialize and will never sync, and aren't supposed to *)
let all_pods
{ seeds
; block_producers
; snark_coordinators
; snark_workers
; archive_nodes
; _
} =
List.concat
[ seeds; block_producers; snark_coordinators; snark_workers; archive_nodes ]
(* TODO snark workers and snark coordinators have the same key name, but different workload ids*)
let all_pods { nodes_by_pod_id; _ } = Core.String.Map.data nodes_by_pod_id

(* all_non_seed_pods returns everything in the network except seed nodes *)
let all_non_seed_pods
{ block_producers; snark_coordinators; snark_workers; archive_nodes; _ } =
List.concat
[ block_producers; snark_coordinators; snark_workers; archive_nodes ]
let all_non_seed_pods { nodes_by_pod_id; seeds; _ } =
let seedlist = Core.String.Map.keys seeds in
let rec remove_all_keys_in_list mp lst =
match lst with
| [] ->
mp
| hd :: tl ->
remove_all_keys_in_list (Core.String.Map.remove mp hd) tl
in
Core.String.Map.data (remove_all_keys_in_list nodes_by_pod_id seedlist)

let all_keypairs { block_producer_keypairs; extra_genesis_keypairs; _ } =
block_producer_keypairs @ extra_genesis_keypairs
let genesis_keypairs { genesis_keypairs; _ } = genesis_keypairs

let block_producer_keypairs { block_producer_keypairs; _ } =
block_producer_keypairs
(* let block_producer_keypairs { block_producer_keypairs; _ } =
block_producer_keypairs
let extra_genesis_keypairs { extra_genesis_keypairs; _ } =
extra_genesis_keypairs
let extra_genesis_keypairs { extra_genesis_keypairs; _ } =
extra_genesis_keypairs *)

let lookup_node_by_pod_id t = Map.find t.nodes_by_pod_id

Expand Down
Loading

0 comments on commit 57e4e03

Please sign in to comment.