Skip to content

Commit

Permalink
Merge branch 'berkeley' into dkijania/move_te_to_stage_2
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania authored Sep 8, 2023
2 parents c750e4a + 217e0b9 commit 9b67485
Show file tree
Hide file tree
Showing 20 changed files with 4,084 additions and 3,918 deletions.
2 changes: 0 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
/src/lib/ @MinaProtocol/protocol-eng-reviewers

/src/lib/blake2/ @MinaProtocol/crypto-eng-reviewers
/src/lib/cli_lib/ @MinaProtocol/product-eng-reviewers
/src/lib/mina_commands @MinaProtocol/product-eng-reviewers
/src/lib/mina_graphql @MinaProtocol/product-eng-reviewers
/src/lib/mina_numbers/ @MinaProtocol/crypto-eng-reviewers
/src/lib/crs/ @MinaProtocol/crypto-eng-reviewers
Expand Down
39 changes: 35 additions & 4 deletions frontend/ci-build-me/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,41 @@ const handler = async (event, req) => {
"mina",
{}
);
const circle = await runCircleBuild({
pull_request: prData.data,
});
return [buildkite, circle];
return [buildkite];
} else {
// NB: Users that are 'privately' a member of the org will not be able to trigger CI jobs
return [
"comment author is not (publically) a member of the core team",
"comment author is not (publically) a member of the core team",
];
}
}

// Mina CI Nightly Build section
else if (
// we are creating the comment
req.body.action == "created" &&
// and this is actually a pull request
req.body.issue.pull_request &&
req.body.issue.pull_request.url &&
// and the comment contents is exactly the slug we are looking for
req.body.comment.body == "!ci-nightly-me"
) {
const orgData = await getRequest(req.body.sender.organizations_url);
// and the comment author is part of the core team
if (
orgData.data.filter((org) => org.login == "MinaProtocol").length > 0
) {
const prData = await getRequest(req.body.issue.pull_request.url);
const buildkite = await runBuild(
{
sender: req.body.sender,
pull_request: prData.data,
},
"mina-end-to-end-nightlies",
{}
);
return [buildkite];
} else {
// NB: Users that are 'privately' a member of the org will not be able to trigger CI jobs
return [
Expand Down
186 changes: 184 additions & 2 deletions src/app/test_executive/hard_fork.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,32 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
@ [ { account_name = "fish1"; balance = "100"; timing = Untimed }
; { account_name = "fish2"; balance = "100"; timing = Untimed }
; { account_name = "fish3"; balance = "1000"; timing = Untimed }
(* account fully vested before hard fork *)
; { account_name = "timed1"
; balance = "10000" (* balance in Mina *)
; timing =
make_timing ~min_balance:10_000_000_000_000 ~cliff_time:100_000
~cliff_amount:1_000_000_000_000 ~vesting_period:1000
~vesting_increment:1_000_000_000_000
}
(* account starts vesting before hard fork, not fully vested after
cliff is before hard fork
*)
; { account_name = "timed2"
; balance = "10000" (* balance in Mina *)
; timing =
make_timing ~min_balance:10_000_000_000_000 ~cliff_time:499_995
~cliff_amount:2_000_000_000_000 ~vesting_period:5
~vesting_increment:3_000_000_000_000
}
(* cliff at hard fork, vesting with each slot *)
; { account_name = "timed3"
; balance = "20000" (* balance in Mina *)
; timing =
make_timing ~min_balance:20_000_000_000_000 ~cliff_time:500_000
~cliff_amount:2_000_000_000_000 ~vesting_period:1
~vesting_increment:1_000_000_000_000
}
]
; block_producers =
[ { node_name = "node-a"; account_name = "node-a-key" }
Expand Down Expand Up @@ -107,6 +133,15 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
let fish2 =
Core.String.Map.find_exn (Network.genesis_keypairs network) "fish2"
in
let timed1 =
Core.String.Map.find_exn (Network.genesis_keypairs network) "timed1"
in
let timed2 =
Core.String.Map.find_exn (Network.genesis_keypairs network) "timed2"
in
let timed3 =
Core.String.Map.find_exn (Network.genesis_keypairs network) "timed3"
in
let sender = fish2.keypair in
let receiver = fish1.keypair in
[%log info] "extra genesis keypairs: %s"
Expand Down Expand Up @@ -193,6 +228,107 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
in
[%log info] "ZkApp transaction included in transition frontier"
in
let get_account_balances (net_keypair : Network_keypair.t) =
let pk =
net_keypair.keypair.public_key |> Signature_lib.Public_key.compress
in
let account_id = Account_id.create pk Token_id.default in
let%map account_data =
Integration_test_lib.Graphql_requests.must_get_account_data
(Network.Node.get_ingress_uri node_a)
~logger ~account_id
in
let total_balance =
Currency.Balance.to_nanomina_int account_data.total_balance
in
let liquid_balance =
Currency.Balance.to_nanomina_int
(Option.value_exn account_data.liquid_balance_opt)
in
let locked_balance =
Currency.Balance.to_nanomina_int
(Option.value_exn account_data.locked_balance_opt)
in
(total_balance, liquid_balance, locked_balance)
in
let%bind () =
section "Check that timed1 account is fully vested"
(let%bind total_balance, liquid_balance, locked_balance =
get_account_balances timed1
in
[%log info]
"timed1 total balance = %d, liquid balance = %d, locked balance = \
%d (in nanomina)"
total_balance liquid_balance locked_balance ;
let expected_total_balance = 10_000_000_000_000 in
let expected_locked_balance =
(* skip the calculation, it's vested way before the fork *)
0
in
let expected_liquid_balance =
expected_total_balance - expected_locked_balance
in
if
not
( total_balance = expected_total_balance
&& liquid_balance = expected_liquid_balance
&& locked_balance = expected_locked_balance )
then
Malleable_error.hard_error_format
"timed1 account has unexpected balances. Expected total balance \
to be %d, liquid balance to be %d, and locked balance to be %d"
expected_total_balance expected_total_balance
expected_locked_balance
else return () )
in
let%bind () =
section "Check that timed2 account is partially vested"
(let%bind global_slot_since_hard_fork =
Integration_test_lib.Graphql_requests
.must_get_global_slot_since_hard_fork ~logger
(Network.Node.get_ingress_uri node_b)
in
let%bind total_balance, liquid_balance, locked_balance =
get_account_balances timed2
in
[%log info]
"At global slot since hard fork %d, timed2 total balance = %d, \
liquid balance = %d, locked balance = %d (in nanomina)"
(Mina_numbers.Global_slot_since_hard_fork.to_int
global_slot_since_hard_fork )
total_balance liquid_balance locked_balance ;
let expected_total_balance = 10_000_000_000_000 in
let expected_locked_balance =
let num_slots_since_cliff =
(* cliff at 499,995, hard fork at 500,000, so 5 slots before the fork *)
Mina_numbers.Global_slot_since_hard_fork.to_int
global_slot_since_hard_fork
+ 5
in
let vesting_periods_since_cliff = num_slots_since_cliff / 5 in
(* min balance - cliff amount - vesting *)
let calc_balance =
10_000_000_000_000 - 2_000_000_000_000
- (vesting_periods_since_cliff * 3_000_000_000_000)
in
max calc_balance 0
in
let expected_liquid_balance =
expected_total_balance - expected_locked_balance
in
if
not
( total_balance = expected_total_balance
&& liquid_balance = expected_liquid_balance
&& locked_balance = expected_locked_balance )
then
Malleable_error.hard_error_format
"timed2 account has unexpected balances. Expected total balance \
to be %d, liquid balance to be %d, and locked balance to be %d"
expected_total_balance expected_liquid_balance
expected_locked_balance
else return () )
in
let%bind () =
section "send a single signed payment between 2 fish accounts"
(let%bind { hash; _ } =
Expand Down Expand Up @@ -235,6 +371,51 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
(Wait_condition.ledger_proofs_emitted_since_genesis
~test_config:config ~num_proofs:1 ) )
in
let%bind () =
section_hard "Check vesting of timed3 account"
(let%bind global_slot_since_hard_fork =
Integration_test_lib.Graphql_requests
.must_get_global_slot_since_hard_fork ~logger
(Network.Node.get_ingress_uri node_b)
in
let%bind total_balance, liquid_balance, locked_balance =
get_account_balances timed3
in
[%log info]
"At global slot since hard fork %d, timed3 total balance = %d, \
liquid balance = %d, locked balance = %d (in nanomina)"
(Mina_numbers.Global_slot_since_hard_fork.to_int
global_slot_since_hard_fork )
total_balance liquid_balance locked_balance ;
let num_slots_since_fork_genesis =
Mina_numbers.Global_slot_since_hard_fork.to_int
global_slot_since_hard_fork
in
let expected_total_balance = 20_000_000_000_000 in
let expected_locked_balance =
let calc_balance =
(* min balance - cliff amount - vesting *)
20_000_000_000_000 - 2_000_000_000_000
- (num_slots_since_fork_genesis * 1_000_000_000_000)
in
max calc_balance 0
in
let expected_liquid_balance =
expected_total_balance - expected_locked_balance
in
if
not
( total_balance = expected_total_balance
&& liquid_balance = expected_liquid_balance
&& locked_balance = expected_locked_balance )
then
Malleable_error.hard_error_format
"timed3 account has unexpected balances. Expected total balance \
to be %d, liquid balance to be %d, and locked balance to be %d"
expected_total_balance expected_total_balance
expected_locked_balance
else return () )
in
let%bind () =
section_hard "checking height, global slot since genesis in best chain"
(let%bind blocks =
Expand Down Expand Up @@ -283,8 +464,9 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
else return () )
in
[%log info]
"All blocks in best tip have a height and global slot since genesis \
derived from hard fork config" ;
"All %d blocks in best tip have a height and global slot since \
genesis derived from hard fork config"
(List.length blocks) ;
return () )
in
section_hard "running replayer"
Expand Down
11 changes: 0 additions & 11 deletions src/app/test_executive/payments_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
(* TODO: test account creation fee *)
let config =
let open Test_config in
let make_timing ~min_balance ~cliff_time ~cliff_amount ~vesting_period
~vesting_increment : Mina_base.Account_timing.t =
let open Currency in
Timed
{ initial_minimum_balance = Balance.of_nanomina_int_exn min_balance
; cliff_time = Mina_numbers.Global_slot_since_genesis.of_int cliff_time
; cliff_amount = Amount.of_nanomina_int_exn cliff_amount
; vesting_period = Mina_numbers.Global_slot_span.of_int vesting_period
; vesting_increment = Amount.of_nanomina_int_exn vesting_increment
}
in
{ default with
requires_graphql = true
; genesis_ledger =
Expand Down
11 changes: 11 additions & 0 deletions src/app/test_executive/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,15 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct
else
let error = String.concat error_logs ~sep:"\n " in
Malleable_error.hard_error_string ("Replayer errors:\n " ^ error)

let make_timing ~min_balance ~cliff_time ~cliff_amount ~vesting_period
~vesting_increment : Mina_base.Account_timing.t =
let open Currency in
Timed
{ initial_minimum_balance = Balance.of_nanomina_int_exn min_balance
; cliff_time = Mina_numbers.Global_slot_since_genesis.of_int cliff_time
; cliff_amount = Amount.of_nanomina_int_exn cliff_amount
; vesting_period = Mina_numbers.Global_slot_span.of_int vesting_period
; vesting_increment = Amount.of_nanomina_int_exn vesting_increment
}
end
39 changes: 37 additions & 2 deletions src/lib/integration_test_lib/graphql_requests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@ module Graphql = struct
}
|}]

module Global_slot_since_hard_fork =
[%graphql
{|
query {
daemonStatus {
consensusTimeNow {
globalSlot @ppxCustom(module: "Scalars.GlobalSlotSinceHardFork")
}
}
}
|}]

module Best_chain =
(* "slot" is serialized using Graphql_lib.Scalars.Slot
to use that, we'd need to add the 'consensus' library,
Expand All @@ -174,8 +186,8 @@ module Graphql = struct
protocolState {
consensusState {
blockHeight
slotSinceGenesis @ppxCustom(module: "Graphql_lib.Scalars.GlobalSlotSinceGenesis")
slot @ppxCustom(module: "Graphql_lib.Scalars.GlobalSlotSinceHardFork")
slotSinceGenesis @ppxCustom(module: "Scalars.GlobalSlotSinceGenesis")
slot @ppxCustom(module: "Scalars.GlobalSlotSinceHardFork")
}
}
}
Expand Down Expand Up @@ -336,6 +348,29 @@ let get_peer_id ~logger node_uri =
let must_get_peer_id ~logger node_uri =
get_peer_id ~logger node_uri |> Deferred.bind ~f:Malleable_error.or_hard_error

let get_global_slot_since_hard_fork ~logger node_uri =
let open Deferred.Or_error.Let_syntax in
[%log info] "Getting global slot since hard fork from daemon status"
~metadata:[ ("node_uri", `String (Uri.to_string node_uri)) ] ;
let query_obj =
Graphql.Global_slot_since_hard_fork.(make @@ makeVariables ())
in
let%bind query_result_obj =
exec_graphql_request ~logger ~node_uri
~query_name:"global_slot_since_hard_fork" query_obj
in
[%log info] "global_slot_since_hard_fork, finished exec_graphql_request" ;
let res : Mina_numbers.Global_slot_since_hard_fork.t =
query_result_obj.daemonStatus.consensusTimeNow.globalSlot
in
[%log info] "global_slot_since_hard_fork, result of graphql query = %s"
(Mina_numbers.Global_slot_since_hard_fork.to_string res) ;
return res

let must_get_global_slot_since_hard_fork ~logger node_uri =
get_global_slot_since_hard_fork ~logger node_uri
|> Deferred.bind ~f:Malleable_error.or_hard_error

let get_best_chain ?max_length ~logger node_uri =
let open Deferred.Or_error.Let_syntax in
let query = Graphql.Best_chain.(make @@ makeVariables ?max_length ()) in
Expand Down
7 changes: 7 additions & 0 deletions src/lib/mina_graphql/doc.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
open Core_kernel

let date ?(extra = "") s =
sprintf
"%s (stringified Unix time - number of milliseconds since January 1, \
1970)%s"
s extra
Loading

0 comments on commit 9b67485

Please sign in to comment.