Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compatible] Stop txn/network after slot feature #14516

Merged
merged 39 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
11dc67b
Add slot_tx_end to compile config
joaosreis Sep 25, 2023
7aefd8a
Create CLI flag. Add config to daemon config
joaosreis Sep 25, 2023
b273c44
Create block after stop slot using empty staged ledger diff
joaosreis Sep 25, 2023
ef37faf
Split CLI flag into enable/disable
joaosreis Sep 25, 2023
7cd90d5
Add stop tx feature to validator
joaosreis Sep 27, 2023
6be8cd7
Add stop slot feature to mina commands
joaosreis Sep 27, 2023
c638cf0
Add slot_chain_end to compile config
joaosreis Nov 3, 2023
f13a7a4
Update slot transaction and chain end flags in CLI
joaosreis Nov 3, 2023
5aaba0a
Convert slot numbers to global slot type
joaosreis Nov 3, 2023
fabb4c9
Move txn slot check from mina_commands to graphql
joaosreis Nov 3, 2023
d9cdec8
Add SlotTxEndTest to test suite
joaosreis Nov 3, 2023
d2f3649
Add slot_tx_end and slot_chain_end definitions to
joaosreis Nov 5, 2023
737b567
Removed one BP
joaosreis Nov 10, 2023
c08d084
Fix stop tx slot comparison
joaosreis Nov 15, 2023
07d6076
Add missing slot_chain_end features
joaosreis Nov 15, 2023
4628a04
Better test structure
joaosreis Nov 17, 2023
cdd6a70
Change build configs
joaosreis Nov 17, 2023
840ea35
Remove CLI configuration flags. Use compile config directly.
joaosreis Nov 28, 2023
2560a66
Adjustments to block production and validation. Add notifications
joaosreis Nov 28, 2023
21ce836
Add slot_chain_end tests and other fixes to integration test
joaosreis Dec 20, 2023
da70971
Revert uneeded changes
joaosreis Dec 20, 2023
1f3b8bc
Run test even when slot params are not set (validate usual behaviour)
joaosreis Dec 20, 2023
a440364
Merge remote-tracking branch 'origin/compatible' into joaosreis/hf-st…
joaosreis Dec 20, 2023
0b70f8a
Reformat slot_end_test.ml
joaosreis Dec 21, 2023
da03efb
Move log slot_*_end message logic to outer BP run function
joaosreis Jan 8, 2024
5887673
Don't run test if neither slot_*_end params are set
joaosreis Jan 8, 2024
7938ca6
Use genesis timestamp to compute test end timestamp
joaosreis Jan 8, 2024
ce59ea4
Allow overriding slot_*_end with runtime config
joaosreis Jan 9, 2024
697b9af
Reject transactions at transaction pool level
joaosreis Jan 10, 2024
77fc86f
Fix missing versioned type update
joaosreis Jan 10, 2024
dc8ca49
Remove unnecessary changes
joaosreis Jan 10, 2024
2073d43
Merge branch 'compatible' into joaosreis/hf-stop-txn-after-slot-compa…
joaosreis Jan 10, 2024
8897d8b
Add new txn pool test case
joaosreis Jan 22, 2024
e1d5168
Flatten logic
joaosreis Jan 22, 2024
9f75c63
Merge remote-tracking branch 'origin/compatible' into joaosreis/hf-st…
joaosreis Jan 22, 2024
8f19650
Revert format changes
joaosreis Jan 23, 2024
c9c86fa
Merge branch 'compatible' into joaosreis/hf-stop-txn-after-slot-compa…
joaosreis Jan 23, 2024
cb1c7ec
Merge branch 'compatible' into joaosreis/hf-stop-txn-after-slot-compa…
georgeee Jan 24, 2024
df06db5
Fix integration test slowness and flakiness
joaosreis Jan 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/test_executive/dune
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
participating_state
graph_algorithms
visualization
block_time
)
(instrumentation (backend bisect_ppx))
(preprocess (pps ppx_coda ppx_jane ppx_deriving_yojson ppx_coda ppx_version)))
203 changes: 203 additions & 0 deletions src/app/test_executive/slot_end_test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
open Core
open Integration_test_lib

module Make (Inputs : Intf.Test.Inputs_intf) = struct
open Inputs
open Engine
open Dsl

open Test_common.Make (Inputs)

(* TODO: find a way to avoid this type alias (first class module signatures restrictions make this tricky) *)
type network = Network.t

type node = Network.Node.t

type dsl = Dsl.t

let num_extra_keys = 100

let slot_tx_end = 10

let slot_chain_end = 15

let sender_account_prefix = "sender-account-"

let config =
let open Test_config in
{ default with
requires_graphql = true
; genesis_ledger =
[ { Test_Account.account_name = "receiver-key"
; balance = "9999999"
; timing = Untimed
}
; { account_name = "sender-1-key"; balance = "0"; timing = Untimed }
; { account_name = "sender-2-key"; balance = "0"; timing = Untimed }
; { account_name = "sender-3-key"; balance = "0"; timing = Untimed }
; { account_name = "snark-node-key"; balance = "0"; timing = Untimed }
]
@ List.init num_extra_keys ~f:(fun i ->
{ Test_Account.account_name =
sprintf "%s-%d" sender_account_prefix i
; balance = "1000"
; timing = Untimed
} )
; block_producers =
[ { node_name = "receiver"; account_name = "receiver-key" }
; { node_name = "sender-1"; account_name = "sender-1-key" }
; { node_name = "sender-2"; account_name = "sender-2-key" }
; { node_name = "sender-3"; account_name = "sender-3-key" }
]
; snark_coordinator =
Some
{ node_name = "snark-node"
; account_name = "snark-node-key"
; worker_nodes = 4
}
; txpool_max_size = 10_000_000
; snark_worker_fee = "0.0002"
; num_archive_nodes = 0
; proof_config =
{ proof_config_default with
work_delay = Some 1
; transaction_capacity =
Some Runtime_config.Proof_keys.Transaction_capacity.small
}
; slot_tx_end = Some slot_tx_end
; slot_chain_end = Some slot_chain_end
}

let fee = Currency.Fee.of_int 10_000_000

let amount = Currency.Amount.of_int 10_000_000

let tx_delay_ms = 5000

let run network t =
let open Malleable_error.Let_syntax in
let logger = Logger.create () in
let num_slots = slot_chain_end + 5 in
let receiver =
String.Map.find_exn (Network.block_producers network) "receiver"
in
let%bind receiver_pub_key = pub_key_of_node receiver in
let bp_senders =
String.Map.remove (Network.block_producers network) "receiver"
|> String.Map.data
in
let sender_kps =
String.Map.fold (Network.genesis_keypairs network) ~init:[]
~f:(fun ~key ~data acc ->
if String.is_prefix key ~prefix:sender_account_prefix then data :: acc
else acc )
in
let sender_priv_keys =
List.map sender_kps ~f:(fun kp -> kp.keypair.private_key)
in
let pk_to_string = Signature_lib.Public_key.Compressed.to_base58_check in
[%log info] "receiver: %s" (pk_to_string receiver_pub_key) ;
let%bind () =
Malleable_error.List.iter sender_kps ~f:(fun s ->
let pk = s.keypair.public_key |> Signature_lib.Public_key.compress in
return ([%log info] "sender: %s" (pk_to_string pk)) )
in
let window_ms =
(Network.constraint_constants network).block_window_duration_ms
in
let all_nodes = Network.all_nodes network in
let%bind () =
wait_for t
(Wait_condition.nodes_to_initialize (String.Map.data all_nodes))
in
let%bind () =
section_hard "wait for 3 blocks to be produced (warm-up)"
(wait_for t (Wait_condition.blocks_to_be_produced 3))
in
let genesis_timestamp =
Block_time.to_time
@@ Block_time.of_int64
(Network.genesis_constants network).protocol.genesis_state_timestamp
in
let end_t =
Time.add genesis_timestamp
(Time.Span.of_ms @@ float_of_int (num_slots * window_ms))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessarily aligned to the network's notion of slots. You probably want to compute an offset from the genesis timestamp.

in
let slot_tx_end = Mina_numbers.Global_slot.of_int slot_tx_end in
let slot_chain_end = Mina_numbers.Global_slot.of_int slot_chain_end in
let%bind () =
section_hard "spawn transaction sending"
(let num_payments = num_slots * window_ms / tx_delay_ms in
let repeat_count = Unsigned.UInt32.of_int num_payments in
let repeat_delay_ms = Unsigned.UInt32.of_int tx_delay_ms in
let num_sender_keys = List.length sender_priv_keys in
let n_bp_senders = List.length bp_senders in
let keys_per_sender = num_sender_keys / n_bp_senders in
[%log info]
"will now send %d payments from as many accounts. %d nodes will \
send %d payments each from distinct keys"
num_payments n_bp_senders keys_per_sender ;
Malleable_error.List.fold ~init:sender_priv_keys bp_senders
~f:(fun keys node ->
let keys0, rest = List.split_n keys keys_per_sender in
Integration_test_lib.Graphql_requests.must_send_test_payments
~repeat_count ~repeat_delay_ms ~logger ~senders:keys0
~receiver_pub_key ~amount ~fee
(Network.Node.get_ingress_uri node)
>>| const rest )
>>| const () )
in
let%bind () =
section
(Printf.sprintf "wait until slot %d" num_slots)
Async.(at end_t >>= const Malleable_error.ok_unit)
in
let ok_if_true s =
Malleable_error.ok_if_true ~error:(Error.of_string s) ~error_type:`Soft
in
let%bind blocks =
Integration_test_lib.Graphql_requests
.must_get_best_chain_for_slot_end_test ~max_length:(2 * num_slots) ~logger
(Network.Node.get_ingress_uri receiver)
in
let%bind () =
section "blocks produced before slot_tx_end"
( ok_if_true "only empty blocks were produced before slot_tx_end"
@@ List.exists blocks ~f:(fun block ->
Mina_numbers.Global_slot.(
of_uint32 block.slot_since_genesis < slot_tx_end)
&& ( block.command_transaction_count <> 0
|| block.snark_work_count <> 0
|| block.coinbase <> 0 ) ) )
in
let%bind () =
section "blocks produced after slot_tx_end"
(Malleable_error.List.iter blocks ~f:(fun block ->
let msg =
Printf.sprintf
"non-empty block after slot_tx_end. block slot since genesis: \
%s, txn count: %d, snark work count: %d, coinbase: %d"
(Mina_numbers.Global_slot.to_string block.slot_since_genesis)
block.command_transaction_count block.snark_work_count
block.coinbase
in
ok_if_true msg
( Mina_numbers.Global_slot.(
of_uint32 block.slot_since_genesis < slot_tx_end)
|| block.command_transaction_count = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: I'd put conjunction group into braces for clarity (not necessary, but required me to remember operator precedence to be sure it works)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I certainly agree. It just turns out the formatter doesn't let me keep them :)

&& block.snark_work_count = 0 && block.coinbase = 0 ) ) )
in
let%bind () =
section "blocks produced before slot_chain_end"
( ok_if_true "no block produced before slot_chain_end"
@@ List.exists blocks ~f:(fun block ->
Mina_numbers.Global_slot.(
of_uint32 block.slot_since_genesis < slot_chain_end) ) )
in
section "no blocks produced after slot_chain_end"
( ok_if_true "blocks produced after slot_chain_end"
@@ not
@@ List.exists blocks ~f:(fun block ->
Mina_numbers.Global_slot.(
of_uint32 block.slot_since_genesis >= slot_chain_end) ) )
end
1 change: 1 addition & 0 deletions src/app/test_executive/slot_end_test.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module Make : Integration_test_lib.Intf.Test.Functor_intf
1 change: 1 addition & 0 deletions src/app/test_executive/test_executive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ let tests : test list =
; ("medium-bootstrap", (module Medium_bootstrap.Make : Intf.Test.Functor_intf))
; ( "block-prod-prio"
, (module Block_production_priority.Make : Intf.Test.Functor_intf) )
; ("slot-end", (module Slot_end_test.Make : Intf.Test.Functor_intf))
]

let report_test_errors ~log_error_set ~internal_error_set =
Expand Down
2 changes: 2 additions & 0 deletions src/config/debug.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/dev.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/dev_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/dev_snark.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/devnet.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@
(* 2*block_window_duration *)
[%%define compaction_interval 360000]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/fake_hash.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/fuzz_medium.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/fuzz_small.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
3 changes: 3 additions & 0 deletions src/config/integration_tests.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
(* This profile is only used for the test executive binary, so we don't need
snark keys, a valid genesis proof, etc. *)
[%%import "/src/config/proof_level/none.mlh"]

[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/mainnet.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@
(* 2*block_window_duration *)
[%%define compaction_interval 360000]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/nonconsensus_mainnet.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

[%%undef consensus_mechanism]
[%%undef compaction_interval]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/nonconsensus_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/print_versioned_types.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_archive_processor.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_catchup.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_five_even_txns.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_full_epoch.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_holy_grail.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
[%%import "/src/config/fork.mlh"]
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
[%%import "/src/config/fork.mlh"]
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_snarkless.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%define compaction_interval 360000]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_snarkless_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_split.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_split_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/test_postake_three_producers.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 0]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/testnet_postake.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/testnet_postake_many_producers.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/testnet_postake_many_producers_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
[%%import "/src/config/features/dev.mlh"]
[%%undef compaction_interval]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
2 changes: 2 additions & 0 deletions src/config/testnet_postake_medium_curves.mlh
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@
(* 2*block_window_duration *)
[%%define compaction_interval 360000]
[%%define vrf_poll_interval 5000]
[%%undef slot_tx_end]
[%%undef slot_chain_end]
Loading